1 @c Copyright (C) 1988-2023 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-2023 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)
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
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 -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]} @gol
208 -fpermitted-flt-eval-methods=@var{standard} @gol
209 -fplan9-extensions -fsigned-bitfields -funsigned-bitfields @gol
210 -fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}] @gol
211 -fsso-struct=@var{endianness}}
213 @item C++ Language Options
214 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
215 @gccoptlist{-fabi-version=@var{n} -fno-access-control @gol
216 -faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new @gol
217 -fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n} @gol
218 -fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n} @gol
219 -fno-elide-constructors @gol
220 -fno-enforce-eh-specs @gol
221 -fno-gnu-keywords @gol
222 -fno-implicit-templates @gol
223 -fno-implicit-inline-templates @gol
224 -fno-implement-inlines @gol
225 -fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts @gol
226 -fmodule-implicit-inline @gol
227 -fno-module-lazy @gol
228 -fmodule-mapper=@var{specification} @gol
229 -fmodule-version-ignore @gol
231 -fnew-inheriting-ctors @gol
232 -fnew-ttp-matching @gol
233 -fno-nonansi-builtins -fnothrow-opt -fno-operator-names @gol
234 -fno-optional-diags -fpermissive @gol
235 -fno-pretty-templates @gol
236 -fno-rtti -fsized-deallocation @gol
237 -ftemplate-backtrace-limit=@var{n} @gol
238 -ftemplate-depth=@var{n} @gol
239 -fno-threadsafe-statics -fuse-cxa-atexit @gol
240 -fno-weak -nostdinc++ @gol
241 -fvisibility-inlines-hidden @gol
242 -fvisibility-ms-compat @gol
243 -fext-numeric-literals @gol
244 -flang-info-include-translate@r{[}=@var{header}@r{]} @gol
245 -flang-info-include-translate-not @gol
246 -flang-info-module-cmi@r{[}=@var{module}@r{]} @gol
247 -stdlib=@var{libstdc++,libc++} @gol
248 -Wabi-tag -Wcatch-value -Wcatch-value=@var{n} @gol
249 -Wno-class-conversion -Wclass-memaccess @gol
250 -Wcomma-subscript -Wconditionally-supported @gol
251 -Wno-conversion-null -Wctad-maybe-unsupported @gol
252 -Wctor-dtor-privacy -Wdangling-reference @gol
253 -Wno-delete-incomplete @gol
254 -Wdelete-non-virtual-dtor -Wno-deprecated-array-compare @gol
255 -Wdeprecated-copy -Wdeprecated-copy-dtor @gol
256 -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion @gol
257 -Weffc++ -Wno-exceptions -Wextra-semi -Wno-inaccessible-base @gol
258 -Wno-inherited-variadic-ctor -Wno-init-list-lifetime @gol
259 -Winvalid-constexpr -Winvalid-imported-macros @gol
260 -Wno-invalid-offsetof -Wno-literal-suffix @gol
261 -Wmismatched-new-delete -Wmismatched-tags @gol
262 -Wmultiple-inheritance -Wnamespaces -Wnarrowing @gol
263 -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor @gol
264 -Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n} @gol
265 -Wrange-loop-construct -Wredundant-move -Wredundant-tags @gol
266 -Wreorder -Wregister @gol
267 -Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates @gol
268 -Wno-non-template-friend -Wold-style-cast @gol
269 -Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo @gol
270 -Wsized-deallocation -Wsuggest-final-methods @gol
271 -Wsuggest-final-types -Wsuggest-override @gol
272 -Wno-terminate -Wuseless-cast -Wno-vexing-parse @gol
273 -Wvirtual-inheritance @gol
274 -Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant}
276 @item Objective-C and Objective-C++ Language Options
277 @xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling
278 Objective-C and Objective-C++ Dialects}.
279 @gccoptlist{-fconstant-string-class=@var{class-name} @gol
280 -fgnu-runtime -fnext-runtime @gol
281 -fno-nil-receivers @gol
282 -fobjc-abi-version=@var{n} @gol
283 -fobjc-call-cxx-cdtors @gol
284 -fobjc-direct-dispatch @gol
285 -fobjc-exceptions @gol
288 -fobjc-std=objc1 @gol
289 -fno-local-ivars @gol
290 -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} @gol
291 -freplace-objc-classes @gol
294 -Wassign-intercept -Wno-property-assign-default @gol
295 -Wno-protocol -Wobjc-root-class -Wselector @gol
296 -Wstrict-selector-match @gol
297 -Wundeclared-selector}
299 @item Diagnostic Message Formatting Options
300 @xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
301 @gccoptlist{-fmessage-length=@var{n} @gol
302 -fdiagnostics-plain-output @gol
303 -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]} @gol
304 -fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]} @gol
305 -fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]} @gol
306 -fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]} @gol
307 -fno-diagnostics-show-option -fno-diagnostics-show-caret @gol
308 -fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers @gol
309 -fno-diagnostics-show-cwe @gol
310 -fno-diagnostics-show-rule @gol
311 -fdiagnostics-minimum-margin-width=@var{width} @gol
312 -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch @gol
313 -fdiagnostics-show-template-tree -fno-elide-type @gol
314 -fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]} @gol
315 -fdiagnostics-show-path-depths @gol
316 -fno-show-column @gol
317 -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} @gol
318 -fdiagnostics-column-origin=@var{origin} @gol
319 -fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}}
321 @item Warning Options
322 @xref{Warning Options,,Options to Request or Suppress Warnings}.
323 @gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic @gol
324 -pedantic-errors @gol
325 -w -Wextra -Wall -Wabi=@var{n} @gol
326 -Waddress -Wno-address-of-packed-member -Waggregate-return @gol
327 -Walloc-size-larger-than=@var{byte-size} -Walloc-zero @gol
328 -Walloca -Walloca-larger-than=@var{byte-size} @gol
329 -Wno-aggressive-loop-optimizations @gol
330 -Warith-conversion @gol
331 -Warray-bounds -Warray-bounds=@var{n} -Warray-compare @gol
332 -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias @gol
333 -Wno-attribute-warning @gol
334 -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} @gol
335 -Wbool-compare -Wbool-operation @gol
336 -Wno-builtin-declaration-mismatch @gol
337 -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat @gol
338 -Wc11-c2x-compat @gol
339 -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat @gol
341 -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions @gol
342 -Wno-c++20-extensions -Wno-c++23-extensions @gol
343 -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual @gol
344 -Wchar-subscripts @gol
345 -Wclobbered -Wcomment @gol
346 -Wconversion -Wno-coverage-mismatch -Wno-cpp @gol
347 -Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} @gol
349 -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init @gol
350 -Wdisabled-optimization @gol
351 -Wno-discarded-array-qualifiers -Wno-discarded-qualifiers @gol
352 -Wno-div-by-zero -Wdouble-promotion @gol
353 -Wduplicated-branches -Wduplicated-cond @gol
354 -Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion @gol
355 -Wenum-int-mismatch @gol
356 -Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors @gol
357 -Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2 @gol
358 -Wno-format-contains-nul -Wno-format-extra-args @gol
359 -Wformat-nonliteral -Wformat-overflow=@var{n} @gol
360 -Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} @gol
361 -Wformat-y2k -Wframe-address @gol
362 -Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object @gol
363 -Wno-if-not-aligned -Wno-ignored-attributes @gol
364 -Wignored-qualifiers -Wno-incompatible-pointer-types @gol
365 -Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n} @gol
366 -Wno-implicit-function-declaration -Wno-implicit-int @gol
367 -Winfinite-recursion @gol
368 -Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context @gol
369 -Wno-int-to-pointer-cast -Wno-invalid-memory-model @gol
370 -Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init @gol
371 -Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op @gol
372 -Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized @gol
373 -Wmemset-elt-size -Wmemset-transposed-args @gol
374 -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces @gol
375 -Wmissing-field-initializers -Wmissing-format-attribute @gol
376 -Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile @gol
377 -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare @gol
378 -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol
379 -Wnull-dereference -Wno-odr @gol
380 -Wopenacc-parallelism @gol
382 -Wno-overflow -Woverlength-strings -Wno-override-init-side-effects @gol
383 -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol
384 -Wparentheses -Wno-pedantic-ms-format @gol
385 -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol
386 -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol
387 -Wrestrict -Wno-return-local-addr -Wreturn-type @gol
388 -Wno-scalar-storage-order -Wsequence-point @gol
389 -Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local @gol
390 -Wno-shadow-ivar @gol
391 -Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value @gol
392 -Wno-shift-overflow -Wshift-overflow=@var{n} @gol
393 -Wsign-compare -Wsign-conversion @gol
394 -Wno-sizeof-array-argument @gol
395 -Wsizeof-array-div @gol
396 -Wsizeof-pointer-div -Wsizeof-pointer-memaccess @gol
397 -Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing @gol
398 -Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
399 -Wstring-compare @gol
400 -Wno-stringop-overflow -Wno-stringop-overread @gol
401 -Wno-stringop-truncation -Wstrict-flex-arrays @gol
402 -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} @gol
403 -Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum @gol
404 -Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand @gol
405 -Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs @gol
406 -Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef @gol
407 -Wuninitialized -Wunknown-pragmas @gol
408 -Wunsuffixed-float-constants -Wunused @gol
409 -Wunused-but-set-parameter -Wunused-but-set-variable @gol
410 -Wunused-const-variable -Wunused-const-variable=@var{n} @gol
411 -Wunused-function -Wunused-label -Wunused-local-typedefs @gol
413 -Wunused-parameter -Wno-unused-result @gol
414 -Wunused-value -Wunused-variable @gol
415 -Wno-varargs -Wvariadic-macros @gol
416 -Wvector-operation-performance @gol
417 -Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than @gol
418 -Wvolatile-register-var -Wwrite-strings @gol
419 -Wxor-used-as-pow @gol
420 -Wzero-length-bounds}
422 @item Static Analyzer Options
425 -fanalyzer-call-summaries @gol
426 -fanalyzer-checker=@var{name} @gol
427 -fno-analyzer-feasibility @gol
428 -fanalyzer-fine-grained @gol
429 -fno-analyzer-state-merge @gol
430 -fno-analyzer-state-purge @gol
431 -fanalyzer-transitivity @gol
432 -fno-analyzer-undo-inlining @gol
433 -fanalyzer-verbose-edges @gol
434 -fanalyzer-verbose-state-changes @gol
435 -fanalyzer-verbosity=@var{level} @gol
437 -fdump-analyzer-callgraph @gol
438 -fdump-analyzer-exploded-graph @gol
439 -fdump-analyzer-exploded-nodes @gol
440 -fdump-analyzer-exploded-nodes-2 @gol
441 -fdump-analyzer-exploded-nodes-3 @gol
442 -fdump-analyzer-exploded-paths @gol
443 -fdump-analyzer-feasibility @gol
444 -fdump-analyzer-json @gol
445 -fdump-analyzer-state-purge @gol
446 -fdump-analyzer-stderr @gol
447 -fdump-analyzer-supergraph @gol
448 -fdump-analyzer-untracked @gol
449 -Wno-analyzer-double-fclose @gol
450 -Wno-analyzer-double-free @gol
451 -Wno-analyzer-exposure-through-output-file @gol
452 -Wno-analyzer-exposure-through-uninit-copy @gol
453 -Wno-analyzer-fd-access-mode-mismatch @gol
454 -Wno-analyzer-fd-double-close @gol
455 -Wno-analyzer-fd-leak @gol
456 -Wno-analyzer-fd-phase-mismatch @gol
457 -Wno-analyzer-fd-type-mismatch @gol
458 -Wno-analyzer-fd-use-after-close @gol
459 -Wno-analyzer-fd-use-without-check @gol
460 -Wno-analyzer-file-leak @gol
461 -Wno-analyzer-free-of-non-heap @gol
462 -Wno-analyzer-imprecise-fp-arithmetic @gol
463 -Wno-analyzer-infinite-recursion @gol
464 -Wno-analyzer-jump-through-null @gol
465 -Wno-analyzer-malloc-leak @gol
466 -Wno-analyzer-mismatching-deallocation @gol
467 -Wno-analyzer-null-argument @gol
468 -Wno-analyzer-null-dereference @gol
469 -Wno-analyzer-out-of-bounds @gol
470 -Wno-analyzer-possible-null-argument @gol
471 -Wno-analyzer-possible-null-dereference @gol
472 -Wno-analyzer-putenv-of-auto-var @gol
473 -Wno-analyzer-shift-count-negative @gol
474 -Wno-analyzer-shift-count-overflow @gol
475 -Wno-analyzer-stale-setjmp-buffer @gol
476 -Wno-analyzer-tainted-allocation-size @gol
477 -Wno-analyzer-tainted-assertion @gol
478 -Wno-analyzer-tainted-array-index @gol
479 -Wno-analyzer-tainted-divisor @gol
480 -Wno-analyzer-tainted-offset @gol
481 -Wno-analyzer-tainted-size @gol
482 -Wanalyzer-too-complex @gol
483 -Wno-analyzer-unsafe-call-within-signal-handler @gol
484 -Wno-analyzer-use-after-free @gol
485 -Wno-analyzer-use-of-pointer-in-stale-stack-frame @gol
486 -Wno-analyzer-use-of-uninitialized-value @gol
487 -Wno-analyzer-va-arg-type-mismatch @gol
488 -Wno-analyzer-va-list-exhausted @gol
489 -Wno-analyzer-va-list-leak @gol
490 -Wno-analyzer-va-list-use-after-va-end @gol
491 -Wno-analyzer-write-to-const @gol
492 -Wno-analyzer-write-to-string-literal @gol
495 @item C and Objective-C-only Warning Options
496 @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
497 -Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs @gol
498 -Wold-style-declaration -Wold-style-definition @gol
499 -Wstrict-prototypes -Wtraditional -Wtraditional-conversion @gol
500 -Wdeclaration-after-statement -Wpointer-sign}
502 @item Debugging Options
503 @xref{Debugging Options,,Options for Debugging Your Program}.
504 @gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} @gol
505 -gbtf -gctf -gctf@var{level} @gol
506 -ggdb -grecord-gcc-switches -gno-record-gcc-switches @gol
507 -gstrict-dwarf -gno-strict-dwarf @gol
508 -gas-loc-support -gno-as-loc-support @gol
509 -gas-locview-support -gno-as-locview-support @gol
510 -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 @gol
511 -gstatement-frontiers -gno-statement-frontiers @gol
512 -gvariable-location-views -gno-variable-location-views @gol
513 -ginternal-reset-location-views -gno-internal-reset-location-views @gol
514 -ginline-points -gno-inline-points @gol
515 -gvms -gz@r{[}=@var{type}@r{]} @gol
516 -gsplit-dwarf -gdescribe-dies -gno-describe-dies @gol
517 -fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section @gol
518 -fno-eliminate-unused-debug-types @gol
519 -femit-struct-debug-baseonly -femit-struct-debug-reduced @gol
520 -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} @gol
521 -fno-eliminate-unused-debug-symbols -femit-class-debug-always @gol
522 -fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol
523 -fvar-tracking -fvar-tracking-assignments}
525 @item Optimization Options
526 @xref{Optimize Options,,Options that Control Optimization}.
527 @gccoptlist{-faggressive-loop-optimizations @gol
528 -falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
529 -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
530 -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
531 -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
532 -fno-allocation-dce -fallow-store-data-races @gol
533 -fassociative-math -fauto-profile -fauto-profile[=@var{path}] @gol
534 -fauto-inc-dec -fbranch-probabilities @gol
536 -fcombine-stack-adjustments -fconserve-stack @gol
537 -fcompare-elim -fcprop-registers -fcrossjumping @gol
538 -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
539 -fcx-limited-range @gol
540 -fdata-sections -fdce -fdelayed-branch @gol
541 -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively @gol
542 -fdevirtualize-at-ltrans -fdse @gol
543 -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects @gol
544 -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol
546 -fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol
547 -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity @gol
548 -fgcse-sm -fhoist-adjacent-loads -fif-conversion @gol
549 -fif-conversion2 -findirect-inlining @gol
550 -finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
551 -finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone @gol
552 -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const @gol
553 -fipa-reference -fipa-reference-addressable @gol
554 -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} @gol
555 -flive-patching=@var{level} @gol
556 -fira-region=@var{region} -fira-hoist-pressure @gol
557 -fira-loop-pressure -fno-ira-share-save-slots @gol
558 -fno-ira-share-spill-slots @gol
559 -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute @gol
560 -fivopts -fkeep-inline-functions -fkeep-static-functions @gol
561 -fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage @gol
562 -floop-block -floop-interchange -floop-strip-mine @gol
563 -floop-unroll-and-jam -floop-nest-optimize @gol
564 -floop-parallelize-all -flra-remat -flto -flto-compression-level @gol
565 -flto-partition=@var{alg} -fmerge-all-constants @gol
566 -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves @gol
567 -fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg @gol
568 -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @gol
569 -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole @gol
570 -fno-peephole2 -fno-printf-return-value -fno-sched-interblock @gol
571 -fno-sched-spec -fno-signed-zeros @gol
572 -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
573 -fomit-frame-pointer -foptimize-sibling-calls @gol
574 -fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
575 -fprefetch-loop-arrays @gol
576 -fprofile-correction @gol
577 -fprofile-use -fprofile-use=@var{path} -fprofile-partial-training @gol
578 -fprofile-values -fprofile-reorder-functions @gol
579 -freciprocal-math -free -frename-registers -freorder-blocks @gol
580 -freorder-blocks-algorithm=@var{algorithm} @gol
581 -freorder-blocks-and-partition -freorder-functions @gol
582 -frerun-cse-after-loop -freschedule-modulo-scheduled-loops @gol
583 -frounding-math -fsave-optimization-record @gol
584 -fsched2-use-superblocks -fsched-pressure @gol
585 -fsched-spec-load -fsched-spec-load-dangerous @gol
586 -fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] @gol
587 -fsched-group-heuristic -fsched-critical-path-heuristic @gol
588 -fsched-spec-insn-heuristic -fsched-rank-heuristic @gol
589 -fsched-last-insn-heuristic -fsched-dep-count-heuristic @gol
590 -fschedule-fusion @gol
591 -fschedule-insns -fschedule-insns2 -fsection-anchors @gol
592 -fselective-scheduling -fselective-scheduling2 @gol
593 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
594 -fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate @gol
595 -fsignaling-nans @gol
596 -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops@gol
598 -fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt @gol
599 -fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing @gol
600 -fthread-jumps -ftracer -ftree-bit-ccp @gol
601 -ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol
602 -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts @gol
603 -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting @gol
604 -ftree-loop-if-convert -ftree-loop-im @gol
605 -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns @gol
606 -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol
607 -ftree-loop-vectorize @gol
608 -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta @gol
609 -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra @gol
610 -ftree-switch-conversion -ftree-tail-merge @gol
611 -ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init @gol
612 -funconstrained-commons -funit-at-a-time -funroll-all-loops @gol
613 -funroll-loops -funsafe-math-optimizations -funswitch-loops @gol
614 -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt @gol
615 -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs @gol
616 --param @var{name}=@var{value}
617 -O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
619 @item Program Instrumentation Options
620 @xref{Instrumentation Options,,Program Instrumentation Options}.
621 @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage @gol
622 -fprofile-abs-path @gol
623 -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} @gol
624 -fprofile-info-section -fprofile-info-section=@var{name} @gol
625 -fprofile-note=@var{path} -fprofile-prefix-path=@var{path} @gol
626 -fprofile-update=@var{method} -fprofile-filter-files=@var{regex} @gol
627 -fprofile-exclude-files=@var{regex} @gol
628 -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} @gol
629 -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol
630 -fsanitize-trap -fsanitize-trap=@var{style} @gol
631 -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol
632 -fsanitize-undefined-trap-on-error -fbounds-check @gol
633 -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} @gol
634 -fharden-compares -fharden-conditional-branches @gol
635 -fstack-protector -fstack-protector-all -fstack-protector-strong @gol
636 -fstack-protector-explicit -fstack-check @gol
637 -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
638 -fno-stack-limit -fsplit-stack @gol
639 -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
640 -fvtv-counts -fvtv-debug @gol
641 -finstrument-functions -finstrument-functions-once @gol
642 -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol
643 -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}} @gol
644 -fprofile-prefix-map=@var{old}=@var{new}
646 @item Preprocessor Options
647 @xref{Preprocessor Options,,Options Controlling the Preprocessor}.
648 @gccoptlist{-A@var{question}=@var{answer} @gol
649 -A-@var{question}@r{[}=@var{answer}@r{]} @gol
650 -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} @gol
651 -dD -dI -dM -dN -dU @gol
652 -fdebug-cpp -fdirectives-only -fdollars-in-identifiers @gol
653 -fexec-charset=@var{charset} -fextended-identifiers @gol
654 -finput-charset=@var{charset} -flarge-source-files @gol
655 -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} @gol
656 -fno-canonical-system-headers -fpch-deps -fpch-preprocess @gol
657 -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion @gol
658 -fwide-exec-charset=@var{charset} -fworking-directory @gol
659 -H -imacros @var{file} -include @var{file} @gol
660 -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules @gol
661 -no-integrated-cpp -P -pthread -remap @gol
662 -traditional -traditional-cpp -trigraphs @gol
663 -U@var{macro} -undef @gol
664 -Wp,@var{option} -Xpreprocessor @var{option}}
666 @item Assembler Options
667 @xref{Assembler Options,,Passing Options to the Assembler}.
668 @gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
671 @xref{Link Options,,Options for Linking}.
672 @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol
673 -nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ @gol
674 -e @var{entry} --entry=@var{entry} @gol
675 -pie -pthread -r -rdynamic @gol
676 -s -static -static-pie -static-libgcc -static-libstdc++ @gol
677 -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
678 -shared -shared-libgcc -symbolic @gol
679 -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol
680 -u @var{symbol} -z @var{keyword}}
682 @item Directory Options
683 @xref{Directory Options,,Options for Directory Search}.
684 @gccoptlist{-B@var{prefix} -I@var{dir} -I- @gol
685 -idirafter @var{dir} @gol
686 -imacros @var{file} -imultilib @var{dir} @gol
687 -iplugindir=@var{dir} -iprefix @var{file} @gol
688 -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} @gol
689 -iwithprefix @var{dir} -iwithprefixbefore @var{dir} @gol
690 -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix @gol
691 -nostdinc -nostdinc++ --sysroot=@var{dir}}
693 @item Code Generation Options
694 @xref{Code Gen Options,,Options for Code Generation Conventions}.
695 @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
696 -ffixed-@var{reg} -fexceptions @gol
697 -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables @gol
698 -fasynchronous-unwind-tables @gol
700 -finhibit-size-directive -fcommon -fno-ident @gol
701 -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt @gol
702 -fno-jump-tables -fno-bit-tests @gol
703 -frecord-gcc-switches @gol
704 -freg-struct-return -fshort-enums -fshort-wchar @gol
705 -fverbose-asm -fpack-struct[=@var{n}] @gol
706 -fleading-underscore -ftls-model=@var{model} @gol
707 -fstack-reuse=@var{reuse_level} @gol
708 -ftrampolines -ftrapv -fwrapv @gol
709 -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} @gol
710 -fstrict-volatile-bitfields -fsync-libcalls}
712 @item Developer Options
713 @xref{Developer Options,,GCC Developer Options}.
714 @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
715 -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
716 -fchecking -fchecking=@var{n}
717 -fdbg-cnt-list @gol -fdbg-cnt=@var{counter-value-list} @gol
718 -fdisable-ipa-@var{pass_name} @gol
719 -fdisable-rtl-@var{pass_name} @gol
720 -fdisable-rtl-@var{pass-name}=@var{range-list} @gol
721 -fdisable-tree-@var{pass_name} @gol
722 -fdisable-tree-@var{pass-name}=@var{range-list} @gol
723 -fdump-debug -fdump-earlydebug @gol
724 -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links @gol
725 -fdump-final-insns@r{[}=@var{file}@r{]} @gol
726 -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
728 -fdump-lang-@var{switch} @gol
729 -fdump-lang-@var{switch}-@var{options} @gol
730 -fdump-lang-@var{switch}-@var{options}=@var{filename} @gol
732 -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} @gol
733 -fdump-statistics @gol
735 -fdump-tree-@var{switch} @gol
736 -fdump-tree-@var{switch}-@var{options} @gol
737 -fdump-tree-@var{switch}-@var{options}=@var{filename} @gol
738 -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second @gol
739 -fenable-@var{kind}-@var{pass} @gol
740 -fenable-@var{kind}-@var{pass}=@var{range-list} @gol
741 -fira-verbose=@var{n} @gol
742 -flto-report -flto-report-wpa -fmem-report-wpa @gol
743 -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report @gol
744 -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} @gol
745 -fmultiflags -fprofile-report @gol
746 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
747 -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
748 -fstats -fstack-usage -ftime-report -ftime-report-details @gol
749 -fvar-tracking-assignments-toggle -gtoggle @gol
750 -print-file-name=@var{library} -print-libgcc-file-name @gol
751 -print-multi-directory -print-multi-lib -print-multi-os-directory @gol
752 -print-prog-name=@var{program} -print-search-dirs -Q @gol
753 -print-sysroot -print-sysroot-headers-suffix @gol
754 -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
756 @item Machine-Dependent Options
757 @xref{Submodel Options,,Machine-Dependent Options}.
758 @c This list is ordered alphanumerically by subsection name.
759 @c Try and put the significant identifier (CPU or system) first,
760 @c so users have a clue at guessing where the ones they want will be.
762 @emph{AArch64 Options}
763 @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian @gol
764 -mgeneral-regs-only @gol
765 -mcmodel=tiny -mcmodel=small -mcmodel=large @gol
766 -mstrict-align -mno-strict-align @gol
767 -momit-leaf-frame-pointer @gol
768 -mtls-dialect=desc -mtls-dialect=traditional @gol
769 -mtls-size=@var{size} @gol
770 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 @gol
771 -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div @gol
772 -mpc-relative-literal-loads @gol
773 -msign-return-address=@var{scope} @gol
774 -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
775 +@var{b-key}]|@var{bti} @gol
776 -mharden-sls=@var{opts} @gol
777 -march=@var{name} -mcpu=@var{name} -mtune=@var{name} @gol
778 -moverride=@var{string} -mverbose-cost-dump @gol
779 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} @gol
780 -mstack-protector-guard-offset=@var{offset} -mtrack-speculation @gol
783 @emph{Adapteva Epiphany Options}
784 @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs @gol
785 -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf @gol
786 -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} @gol
787 -mround-nearest -mlong-calls -mshort-calls -msmall16 @gol
788 -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} @gol
789 -msplit-vecmove-early -m1reg-@var{reg}}
791 @emph{AMD GCN Options}
792 @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
795 @gccoptlist{-mbarrel-shifter -mjli-always @gol
796 -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 @gol
797 -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr @gol
798 -mea -mno-mpy -mmul32x16 -mmul64 -matomic @gol
799 -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap @gol
800 -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape @gol
801 -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof @gol
802 -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved @gol
803 -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} @gol
804 -mvolatile-cache -mtp-regno=@var{regno} @gol
805 -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc @gol
806 -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi @gol
807 -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none @gol
808 -mlra-priority-compact -mlra-priority-noncompact -mmillicode @gol
809 -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} @gol
810 -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame @gol
811 -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} @gol
812 -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
815 @gccoptlist{-mapcs-frame -mno-apcs-frame @gol
816 -mabi=@var{name} @gol
817 -mapcs-stack-check -mno-apcs-stack-check @gol
818 -mapcs-reentrant -mno-apcs-reentrant @gol
819 -mgeneral-regs-only @gol
820 -msched-prolog -mno-sched-prolog @gol
821 -mlittle-endian -mbig-endian @gol
823 -mfloat-abi=@var{name} @gol
824 -mfp16-format=@var{name}
825 -mthumb-interwork -mno-thumb-interwork @gol
826 -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
827 -mtune=@var{name} -mprint-tune-info @gol
828 -mstructure-size-boundary=@var{n} @gol
829 -mabort-on-noreturn @gol
830 -mlong-calls -mno-long-calls @gol
831 -msingle-pic-base -mno-single-pic-base @gol
832 -mpic-register=@var{reg} @gol
833 -mnop-fun-dllimport @gol
834 -mpoke-function-name @gol
835 -mthumb -marm -mflip-thumb @gol
836 -mtpcs-frame -mtpcs-leaf-frame @gol
837 -mcaller-super-interworking -mcallee-super-interworking @gol
838 -mtp=@var{name} -mtls-dialect=@var{dialect} @gol
839 -mword-relocations @gol
840 -mfix-cortex-m3-ldrd @gol
841 -mfix-cortex-a57-aes-1742098 @gol
842 -mfix-cortex-a72-aes-1655431 @gol
843 -munaligned-access @gol
844 -mneon-for-64bits @gol
845 -mslow-flash-data @gol
846 -masm-syntax-unified @gol
848 -mverbose-cost-dump @gol
851 -mfix-cmse-cve-2021-35465 @gol
852 -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} @gol
854 -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
855 [+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
858 @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args @gol
859 -mbranch-cost=@var{cost} @gol
860 -mcall-prologues -mgas-isr-prologues -mint8 @gol
861 -mdouble=@var{bits} -mlong-double=@var{bits} @gol
862 -mn_flash=@var{size} -mno-interrupts @gol
863 -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack @gol
864 -mfract-convert-truncate @gol
865 -mshort-calls -nodevicelib -nodevicespecs @gol
866 -Waddr-space-convert -Wmisspelled-isr}
868 @emph{Blackfin Options}
869 @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} @gol
870 -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer @gol
871 -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly @gol
872 -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library @gol
873 -mno-id-shared-library -mshared-library-id=@var{n} @gol
874 -mleaf-id-shared-library -mno-leaf-id-shared-library @gol
875 -msep-data -mno-sep-data -mlong-calls -mno-long-calls @gol
876 -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram @gol
880 @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} @gol
881 -msim -msdata=@var{sdata-type}}
884 @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
885 -mtune=@var{cpu} -mmax-stack-frame=@var{n} @gol
886 -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
887 -mstack-align -mdata-align -mconst-align @gol
888 -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue @gol
889 -melf -maout -sim -sim2 @gol
890 -mmul-bug-workaround -mno-mul-bug-workaround}
893 @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} @gol
894 -mbig-endian -EB -mlittle-endian -EL @gol
895 -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu @gol
896 -mfloat-abi=@var{name} @gol
897 -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust @gol
898 -mdsp -medsp -mvdsp @gol
899 -mdiv -msmart -mhigh-registers -manchor @gol
900 -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt @gol
901 -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
903 @emph{Darwin Options}
904 @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
905 -arch_only -bind_at_load -bundle -bundle_loader @gol
906 -client_name -compatibility_version -current_version @gol
908 -dependency-file -dylib_file -dylinker_install_name @gol
909 -dynamic -dynamiclib -exported_symbols_list @gol
910 -filelist -flat_namespace -force_cpusubtype_ALL @gol
911 -force_flat_namespace -headerpad_max_install_names @gol
913 -image_base -init -install_name -keep_private_externs @gol
914 -multi_module -multiply_defined -multiply_defined_unused @gol
915 -noall_load -no_dead_strip_inits_and_terms @gol
916 -nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
917 -pagezero_size -prebind -prebind_all_twolevel_modules @gol
918 -private_bundle -read_only_relocs -sectalign @gol
919 -sectobjectsymbols -whyload -seg1addr @gol
920 -sectcreate -sectobjectsymbols -sectorder @gol
921 -segaddr -segs_read_only_addr -segs_read_write_addr @gol
922 -seg_addr_table -seg_addr_table_filename -seglinkedit @gol
923 -segprot -segs_read_only_addr -segs_read_write_addr @gol
924 -single_module -static -sub_library -sub_umbrella @gol
925 -twolevel_namespace -umbrella -undefined @gol
926 -unexported_symbols_list -weak_reference_mismatches @gol
927 -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} @gol
928 -mkernel -mone-byte-bool}
930 @emph{DEC Alpha Options}
931 @gccoptlist{-mno-fp-regs -msoft-float @gol
932 -mieee -mieee-with-inexact -mieee-conformant @gol
933 -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
934 -mtrap-precision=@var{mode} -mbuild-constants @gol
935 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
936 -mbwx -mmax -mfix -mcix @gol
937 -mfloat-vax -mfloat-ieee @gol
938 -mexplicit-relocs -msmall-data -mlarge-data @gol
939 -msmall-text -mlarge-text @gol
940 -mmemory-latency=@var{time}}
943 @gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version}
944 -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re
945 -mjmpext -mjmp32 -malu32 -mcpu=@var{version}}
948 @gccoptlist{-msmall-model -mno-lsim}
951 @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
954 @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
955 -mhard-float -msoft-float @gol
956 -malloc-cc -mfixed-cc -mdword -mno-dword @gol
957 -mdouble -mno-double @gol
958 -mmedia -mno-media -mmuladd -mno-muladd @gol
959 -mfdpic -minline-plt -mgprel-ro -multilib-library-pic @gol
960 -mlinked-fp -mlong-calls -malign-labels @gol
961 -mlibrary-pic -macc-4 -macc-8 @gol
962 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
963 -moptimize-membar -mno-optimize-membar @gol
964 -mscc -mno-scc -mcond-exec -mno-cond-exec @gol
965 -mvliw-branch -mno-vliw-branch @gol
966 -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
967 -mno-nested-cond-exec -mtomcat-stats @gol
971 @emph{GNU/Linux Options}
972 @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
973 -tno-android-cc -tno-android-ld}
975 @emph{H8/300 Options}
976 @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
979 @gccoptlist{-march=@var{architecture-type} @gol
980 -matomic-libcalls -mbig-switch @gol
981 -mcaller-copies -mdisable-fpregs -mdisable-indexing @gol
982 -mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
983 -mfixed-range=@var{register-range} @gol
984 -mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls @gol
985 -mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs @gol
986 -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
987 -mno-jump-in-delay -mno-long-load-store @gol
988 -mno-portable-runtime -mno-soft-float @gol
989 -mno-space-regs -msoft-float -mpa-risc-1-0 @gol
990 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
991 -mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio @gol
992 -munix=@var{unix-std} -nolibdld -static -threads}
995 @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
996 -mvolatile-asm-stop -mregister-names -msdata -mno-sdata @gol
997 -mconstant-gp -mauto-pic -mfused-madd @gol
998 -minline-float-divide-min-latency @gol
999 -minline-float-divide-max-throughput @gol
1000 -mno-inline-float-divide @gol
1001 -minline-int-divide-min-latency @gol
1002 -minline-int-divide-max-throughput @gol
1003 -mno-inline-int-divide @gol
1004 -minline-sqrt-min-latency -minline-sqrt-max-throughput @gol
1005 -mno-inline-sqrt @gol
1006 -mdwarf2-asm -mearly-stop-bits @gol
1007 -mfixed-range=@var{register-range} -mtls-size=@var{tls-size} @gol
1008 -mtune=@var{cpu-type} -milp32 -mlp64 @gol
1009 -msched-br-data-spec -msched-ar-data-spec -msched-control-spec @gol
1010 -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec @gol
1011 -msched-spec-ldc -msched-spec-control-ldc @gol
1012 -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns @gol
1013 -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path @gol
1014 -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost @gol
1015 -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1018 @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled @gol
1019 -msign-extend-enabled -muser-enabled}
1021 @emph{LoongArch Options}
1022 @gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} @gol
1023 -mfpu=@var{fpu-type} -msoft-float -msingle-float -mdouble-float @gol
1024 -mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division @gol
1025 -mcond-move-int -mno-cond-move-int @gol
1026 -mcond-move-float -mno-cond-move-float @gol
1027 -memcpy -mno-memcpy -mstrict-align -mno-strict-align @gol
1028 -mmax-inline-memcpy-size=@var{n} @gol
1029 -mexplicit-relocs -mno-explicit-relocs @gol
1030 -mdirect-extern-access -mno-direct-extern-access @gol
1031 -mcmodel=@var{code-model}}
1033 @emph{M32R/D Options}
1034 @gccoptlist{-m32r2 -m32rx -m32r @gol
1036 -malign-loops -mno-align-loops @gol
1037 -missue-rate=@var{number} @gol
1038 -mbranch-cost=@var{number} @gol
1039 -mmodel=@var{code-size-model-type} @gol
1040 -msdata=@var{sdata-type} @gol
1041 -mno-flush-func -mflush-func=@var{name} @gol
1042 -mno-flush-trap -mflush-trap=@var{number} @gol
1046 @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1048 @emph{M680x0 Options}
1049 @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} @gol
1050 -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
1051 -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 @gol
1052 -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 @gol
1053 -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort @gol
1054 -mno-short -mhard-float -m68881 -msoft-float -mpcrel @gol
1055 -malign-int -mstrict-align -msep-data -mno-sep-data @gol
1056 -mshared-library-id=n -mid-shared-library -mno-id-shared-library @gol
1057 -mxgot -mno-xgot -mlong-jump-table-offsets}
1059 @emph{MCore Options}
1060 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
1061 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
1062 -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
1063 -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
1064 -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1066 @emph{MicroBlaze Options}
1067 @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} @gol
1068 -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift @gol
1069 -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss @gol
1070 -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt @gol
1071 -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} @gol
1072 -mpic-data-is-text-relative}
1075 @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
1076 -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 @gol
1077 -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 @gol
1078 -mips16 -mno-mips16 -mflip-mips16 @gol
1079 -minterlink-compressed -mno-interlink-compressed @gol
1080 -minterlink-mips16 -mno-interlink-mips16 @gol
1081 -mabi=@var{abi} -mabicalls -mno-abicalls @gol
1082 -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot @gol
1083 -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float @gol
1084 -mno-float -msingle-float -mdouble-float @gol
1085 -modd-spreg -mno-odd-spreg @gol
1086 -mabs=@var{mode} -mnan=@var{encoding} @gol
1087 -mdsp -mno-dsp -mdspr2 -mno-dspr2 @gol
1088 -mmcu -mmno-mcu @gol
1090 -mvirt -mno-virt @gol
1093 -mginv -mno-ginv @gol
1094 -mmicromips -mno-micromips @gol
1096 -mloongson-mmi -mno-loongson-mmi @gol
1097 -mloongson-ext -mno-loongson-ext @gol
1098 -mloongson-ext2 -mno-loongson-ext2 @gol
1099 -mfpu=@var{fpu-type} @gol
1100 -msmartmips -mno-smartmips @gol
1101 -mpaired-single -mno-paired-single -mdmx -mno-mdmx @gol
1102 -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc @gol
1103 -mlong64 -mlong32 -msym32 -mno-sym32 @gol
1104 -G@var{num} -mlocal-sdata -mno-local-sdata @gol
1105 -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt @gol
1106 -membedded-data -mno-embedded-data @gol
1107 -muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
1108 -mcode-readable=@var{setting} @gol
1109 -msplit-addresses -mno-split-addresses @gol
1110 -mexplicit-relocs -mno-explicit-relocs @gol
1111 -mcheck-zero-division -mno-check-zero-division @gol
1112 -mdivide-traps -mdivide-breaks @gol
1113 -mload-store-pairs -mno-load-store-pairs @gol
1114 -munaligned-access -mno-unaligned-access @gol
1115 -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
1116 -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp @gol
1117 -mfix-24k -mno-fix-24k @gol
1118 -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
1119 -mfix-r5900 -mno-fix-r5900 @gol
1120 -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 @gol
1121 -mfix-vr4120 -mno-fix-vr4120 @gol
1122 -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 @gol
1123 -mflush-func=@var{func} -mno-flush-func @gol
1124 -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely @gol
1125 -mcompact-branches=@var{policy} @gol
1126 -mfp-exceptions -mno-fp-exceptions @gol
1127 -mvr4130-align -mno-vr4130-align -msynci -mno-synci @gol
1128 -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 @gol
1129 -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address @gol
1130 -mframe-header-opt -mno-frame-header-opt}
1133 @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
1134 -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
1135 -melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
1136 -mno-base-addresses -msingle-exit -mno-single-exit}
1138 @emph{MN10300 Options}
1139 @gccoptlist{-mmult-bug -mno-mult-bug @gol
1140 -mno-am33 -mam33 -mam33-2 -mam34 @gol
1141 -mtune=@var{cpu-type} @gol
1142 -mreturn-pointer-on-d0 @gol
1143 -mno-crt0 -mrelax -mliw -msetlb}
1145 @emph{Moxie Options}
1146 @gccoptlist{-meb -mel -mmul.x -mno-crt0}
1148 @emph{MSP430 Options}
1149 @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax @gol
1151 -mcode-region= -mdata-region= @gol
1152 -msilicon-errata= -msilicon-errata-warn= @gol
1153 -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1155 @emph{NDS32 Options}
1156 @gccoptlist{-mbig-endian -mlittle-endian @gol
1157 -mreduced-regs -mfull-regs @gol
1158 -mcmov -mno-cmov @gol
1159 -mext-perf -mno-ext-perf @gol
1160 -mext-perf2 -mno-ext-perf2 @gol
1161 -mext-string -mno-ext-string @gol
1162 -mv3push -mno-v3push @gol
1163 -m16bit -mno-16bit @gol
1164 -misr-vector-size=@var{num} @gol
1165 -mcache-block-size=@var{num} @gol
1166 -march=@var{arch} @gol
1167 -mcmodel=@var{code-model} @gol
1168 -mctor-dtor -mrelax}
1170 @emph{Nios II Options}
1171 @gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt @gol
1172 -mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} @gol
1174 -mno-bypass-cache -mbypass-cache @gol
1175 -mno-cache-volatile -mcache-volatile @gol
1176 -mno-fast-sw-div -mfast-sw-div @gol
1177 -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div @gol
1178 -mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} @gol
1179 -mcustom-fpu-cfg=@var{name} @gol
1180 -mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} @gol
1181 -march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1183 @emph{Nvidia PTX Options}
1184 @gccoptlist{-m64 -mmainkernel -moptimize}
1186 @emph{OpenRISC Options}
1187 @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div @gol
1188 -msoft-mul -msoft-div @gol
1189 -msoft-float -mhard-float -mdouble-float -munordered-float @gol
1190 -mcmov -mror -mrori -msext -msfimm -mshftimm @gol
1191 -mcmodel=@var{code-model}}
1193 @emph{PDP-11 Options}
1194 @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
1195 -mint32 -mno-int16 -mint16 -mno-int32 @gol
1196 -msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1198 @emph{PowerPC Options}
1199 See RS/6000 and PowerPC Options.
1202 @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop @gol
1203 -mabi=@var{variant}}
1205 @emph{RISC-V Options}
1206 @gccoptlist{-mbranch-cost=@var{N-instruction} @gol
1208 -mabi=@var{ABI-string} @gol
1209 -mfdiv -mno-fdiv @gol
1211 -misa-spec=@var{ISA-spec-string} @gol
1212 -march=@var{ISA-string} @gol
1213 -mtune=@var{processor-string} @gol
1214 -mpreferred-stack-boundary=@var{num} @gol
1215 -msmall-data-limit=@var{N-bytes} @gol
1216 -msave-restore -mno-save-restore @gol
1217 -mshorten-memrefs -mno-shorten-memrefs @gol
1218 -mstrict-align -mno-strict-align @gol
1219 -mcmodel=medlow -mcmodel=medany @gol
1220 -mexplicit-relocs -mno-explicit-relocs @gol
1221 -mrelax -mno-relax @gol
1222 -mriscv-attribute -mno-riscv-attribute @gol
1223 -malign-data=@var{type} @gol
1224 -mbig-endian -mlittle-endian @gol
1225 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
1226 -mstack-protector-guard-offset=@var{offset} @gol
1227 -mcsr-check -mno-csr-check}
1230 @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol
1231 -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 @gol
1232 -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1234 @emph{RS/6000 and PowerPC Options}
1235 @gccoptlist{-mcpu=@var{cpu-type} @gol
1236 -mtune=@var{cpu-type} @gol
1237 -mcmodel=@var{code-model} @gol
1239 -maltivec -mno-altivec @gol
1240 -mpowerpc-gpopt -mno-powerpc-gpopt @gol
1241 -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
1242 -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd @gol
1243 -mfprnd -mno-fprnd @gol
1244 -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp @gol
1245 -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
1246 -m64 -m32 -mxl-compat -mno-xl-compat -mpe @gol
1247 -malign-power -malign-natural @gol
1248 -msoft-float -mhard-float -mmultiple -mno-multiple @gol
1249 -mupdate -mno-update @gol
1250 -mavoid-indexed-addresses -mno-avoid-indexed-addresses @gol
1251 -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
1252 -mstrict-align -mno-strict-align -mrelocatable @gol
1253 -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
1254 -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
1255 -mdynamic-no-pic -mswdiv -msingle-pic-base @gol
1256 -mprioritize-restricted-insns=@var{priority} @gol
1257 -msched-costly-dep=@var{dependence_type} @gol
1258 -minsert-sched-nops=@var{scheme} @gol
1259 -mcall-aixdesc -mcall-eabi -mcall-freebsd @gol
1260 -mcall-linux -mcall-netbsd -mcall-openbsd @gol
1261 -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi @gol
1262 -mtraceback=@var{traceback_type} @gol
1263 -maix-struct-return -msvr4-struct-return @gol
1264 -mabi=@var{abi-type} -msecure-plt -mbss-plt @gol
1265 -mlongcall -mno-longcall -mpltseq -mno-pltseq @gol
1266 -mblock-move-inline-limit=@var{num} @gol
1267 -mblock-compare-inline-limit=@var{num} @gol
1268 -mblock-compare-inline-loop-limit=@var{num} @gol
1269 -mno-block-ops-unaligned-vsx @gol
1270 -mstring-compare-inline-limit=@var{num} @gol
1271 -misel -mno-isel @gol
1272 -mvrsave -mno-vrsave @gol
1273 -mmulhw -mno-mulhw @gol
1274 -mdlmzb -mno-dlmzb @gol
1275 -mprototype -mno-prototype @gol
1276 -msim -mmvme -mads -myellowknife -memb -msdata @gol
1277 -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} @gol
1278 -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision @gol
1279 -mno-recip-precision @gol
1280 -mveclibabi=@var{type} -mfriz -mno-friz @gol
1281 -mpointers-to-nested-functions -mno-pointers-to-nested-functions @gol
1282 -msave-toc-indirect -mno-save-toc-indirect @gol
1283 -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol
1284 -mcrypto -mno-crypto -mhtm -mno-htm @gol
1285 -mquad-memory -mno-quad-memory @gol
1286 -mquad-memory-atomic -mno-quad-memory-atomic @gol
1287 -mcompat-align-parm -mno-compat-align-parm @gol
1288 -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware @gol
1289 -mgnu-attribute -mno-gnu-attribute @gol
1290 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
1291 -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed @gol
1292 -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect @gol
1293 -mprivileged -mno-privileged}
1296 @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu@gol
1298 -mbig-endian-data -mlittle-endian-data @gol
1301 -mas100-syntax -mno-as100-syntax@gol
1303 -mmax-constant-size=@gol
1306 -mallow-string-insns -mno-allow-string-insns@gol
1308 -mno-warn-multiple-fast-interrupts@gol
1309 -msave-acc-in-interrupts}
1311 @emph{S/390 and zSeries Options}
1312 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1313 -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp @gol
1314 -mlong-double-64 -mlong-double-128 @gol
1315 -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack @gol
1316 -msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
1317 -m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol
1318 -mhtm -mvx -mzvector @gol
1319 -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip @gol
1320 -mfused-madd -mno-fused-madd @gol
1321 -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard @gol
1322 -mhotpatch=@var{halfwords},@var{halfwords}}
1325 @gccoptlist{-m1 -m2 -m2e @gol
1326 -m2a-nofpu -m2a-single-only -m2a-single -m2a @gol
1328 -m4-nofpu -m4-single-only -m4-single -m4 @gol
1329 -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al @gol
1330 -mb -ml -mdalign -mrelax @gol
1331 -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave @gol
1332 -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct @gol
1333 -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol
1334 -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol
1335 -maccumulate-outgoing-args @gol
1336 -matomic-model=@var{atomic-model} @gol
1337 -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch @gol
1338 -mcbranch-force-delay-slot @gol
1339 -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra @gol
1340 -mpretend-cmove -mtas}
1342 @emph{Solaris 2 Options}
1343 @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text @gol
1346 @emph{SPARC Options}
1347 @gccoptlist{-mcpu=@var{cpu-type} @gol
1348 -mtune=@var{cpu-type} @gol
1349 -mcmodel=@var{code-model} @gol
1350 -mmemory-model=@var{mem-model} @gol
1351 -m32 -m64 -mapp-regs -mno-app-regs @gol
1352 -mfaster-structs -mno-faster-structs -mflat -mno-flat @gol
1353 -mfpu -mno-fpu -mhard-float -msoft-float @gol
1354 -mhard-quad-float -msoft-quad-float @gol
1355 -mstack-bias -mno-stack-bias @gol
1356 -mstd-struct-return -mno-std-struct-return @gol
1357 -munaligned-doubles -mno-unaligned-doubles @gol
1358 -muser-mode -mno-user-mode @gol
1359 -mv8plus -mno-v8plus -mvis -mno-vis @gol
1360 -mvis2 -mno-vis2 -mvis3 -mno-vis3 @gol
1361 -mvis4 -mno-vis4 -mvis4b -mno-vis4b @gol
1362 -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld @gol
1363 -mpopc -mno-popc -msubxc -mno-subxc @gol
1364 -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc @gol
1367 @emph{System V Options}
1368 @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1371 @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
1372 -mprolog-function -mno-prolog-function -mspace @gol
1373 -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
1374 -mapp-regs -mno-app-regs @gol
1375 -mdisable-callt -mno-disable-callt @gol
1376 -mv850e2v3 -mv850e2 -mv850e1 -mv850es @gol
1377 -mv850e -mv850 -mv850e3v5 @gol
1388 @gccoptlist{-mg -mgnu -munix -mlra}
1390 @emph{Visium Options}
1391 @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float @gol
1392 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1395 @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 @gol
1396 -mpointer-size=@var{size}}
1398 @emph{VxWorks Options}
1399 @gccoptlist{-mrtp -non-static -Bstatic -Bdynamic @gol
1400 -Xbind-lazy -Xbind-now}
1403 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1404 -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default @gol
1405 -mfpmath=@var{unit} @gol
1406 -masm=@var{dialect} -mno-fancy-math-387 @gol
1407 -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float @gol
1408 -mno-wide-multiply -mrtd -malign-double @gol
1409 -mpreferred-stack-boundary=@var{num} @gol
1410 -mincoming-stack-boundary=@var{num} @gol
1411 -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait @gol
1412 -mrecip -mrecip=@var{opt} @gol
1413 -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} @gol
1414 -mmove-max=@var{bits} -mstore-max=@var{bits} @gol
1415 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
1416 -mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl @gol
1417 -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes @gol
1418 -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd @gol
1419 -mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves @gol
1420 -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop @gol
1421 -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp @gol
1422 -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol
1423 -mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call @gol
1424 -mavx512vbmi2 -mavx512bf16 -menqcmd @gol
1425 -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @gol
1426 -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid @gol
1427 -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk@gol
1428 -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni@gol
1429 -mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 @gol
1430 -mprefetchi -mraoint @gol
1431 -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops @gol
1432 -minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
1434 -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} @gol
1435 -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
1436 -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 @gol
1437 -mregparm=@var{num} -msseregparm @gol
1438 -mveclibabi=@var{type} -mvect8-ret-in-mem @gol
1439 -mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign @gol
1440 -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol
1441 -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
1442 -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} @gol
1443 -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
1444 -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} @gol
1445 -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
1446 -malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
1447 -mstack-protector-guard-reg=@var{reg} @gol
1448 -mstack-protector-guard-offset=@var{offset} @gol
1449 -mstack-protector-guard-symbol=@var{symbol} @gol
1450 -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop @gol
1451 -mindirect-branch=@var{choice} -mfunction-return=@var{choice} @gol
1452 -mindirect-branch-register -mharden-sls=@var{choice} @gol
1453 -mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access @gol
1454 -munroll-only-small-loops -mlam=@var{choice}}
1456 @emph{x86 Windows Options}
1457 @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
1458 -mnop-fun-dllimport -mthread @gol
1459 -municode -mwin32 -mwindows -fno-set-stack-executable}
1461 @emph{Xstormy16 Options}
1464 @emph{Xtensa Options}
1465 @gccoptlist{-mconst16 -mno-const16 @gol
1466 -mfused-madd -mno-fused-madd @gol
1468 -mserialize-volatile -mno-serialize-volatile @gol
1469 -mtext-section-literals -mno-text-section-literals @gol
1470 -mauto-litpools -mno-auto-litpools @gol
1471 -mtarget-align -mno-target-align @gol
1472 -mlongcalls -mno-longcalls @gol
1473 -mabi=@var{abi-type} @gol
1474 -mextra-l32r-costs=@var{cycles}}
1476 @emph{zSeries Options}
1477 See S/390 and zSeries Options.
1481 @node Overall Options
1482 @section Options Controlling the Kind of Output
1484 Compilation can involve up to four stages: preprocessing, compilation
1485 proper, assembly and linking, always in that order. GCC is capable of
1486 preprocessing and compiling several files either into several
1487 assembler input files, or into one assembler input file; then each
1488 assembler input file produces an object file, and linking combines all
1489 the object files (those newly compiled, and those specified as input)
1490 into an executable file.
1492 @cindex file name suffix
1493 For any given input file, the file name suffix determines what kind of
1494 compilation is done:
1498 C source code that must be preprocessed.
1501 C source code that should not be preprocessed.
1504 C++ source code that should not be preprocessed.
1507 Objective-C source code. Note that you must link with the @file{libobjc}
1508 library to make an Objective-C program work.
1511 Objective-C source code that should not be preprocessed.
1515 Objective-C++ source code. Note that you must link with the @file{libobjc}
1516 library to make an Objective-C++ program work. Note that @samp{.M} refers
1517 to a literal capital M@.
1519 @item @var{file}.mii
1520 Objective-C++ source code that should not be preprocessed.
1523 C, C++, Objective-C or Objective-C++ header file to be turned into a
1524 precompiled header (default), or C, C++ header file to be turned into an
1525 Ada spec (via the @option{-fdump-ada-spec} switch).
1528 @itemx @var{file}.cp
1529 @itemx @var{file}.cxx
1530 @itemx @var{file}.cpp
1531 @itemx @var{file}.CPP
1532 @itemx @var{file}.c++
1534 C++ source code that must be preprocessed. Note that in @samp{.cxx},
1535 the last two letters must both be literally @samp{x}. Likewise,
1536 @samp{.C} refers to a literal capital C@.
1540 Objective-C++ source code that must be preprocessed.
1542 @item @var{file}.mii
1543 Objective-C++ source code that should not be preprocessed.
1547 @itemx @var{file}.hp
1548 @itemx @var{file}.hxx
1549 @itemx @var{file}.hpp
1550 @itemx @var{file}.HPP
1551 @itemx @var{file}.h++
1552 @itemx @var{file}.tcc
1553 C++ header file to be turned into a precompiled header or Ada spec.
1556 @itemx @var{file}.for
1557 @itemx @var{file}.ftn
1558 Fixed form Fortran source code that should not be preprocessed.
1561 @itemx @var{file}.FOR
1562 @itemx @var{file}.fpp
1563 @itemx @var{file}.FPP
1564 @itemx @var{file}.FTN
1565 Fixed form Fortran source code that must be preprocessed (with the traditional
1568 @item @var{file}.f90
1569 @itemx @var{file}.f95
1570 @itemx @var{file}.f03
1571 @itemx @var{file}.f08
1572 Free form Fortran source code that should not be preprocessed.
1574 @item @var{file}.F90
1575 @itemx @var{file}.F95
1576 @itemx @var{file}.F03
1577 @itemx @var{file}.F08
1578 Free form Fortran source code that must be preprocessed (with the
1579 traditional preprocessor).
1591 D documentation code (Ddoc).
1593 @item @var{file}.ads
1594 Ada source code file that contains a library unit declaration (a
1595 declaration of a package, subprogram, or generic, or a generic
1596 instantiation), or a library unit renaming declaration (a package,
1597 generic, or subprogram renaming declaration). Such files are also
1600 @item @var{file}.adb
1601 Ada source code file containing a library unit body (a subprogram or
1602 package body). Such files are also called @dfn{bodies}.
1604 @c GCC also knows about some suffixes for languages not yet included:
1612 @itemx @var{file}.sx
1613 Assembler code that must be preprocessed.
1616 An object file to be fed straight into linking.
1617 Any file name with no recognized suffix is treated this way.
1621 You can specify the input language explicitly with the @option{-x} option:
1624 @item -x @var{language}
1625 Specify explicitly the @var{language} for the following input files
1626 (rather than letting the compiler choose a default based on the file
1627 name suffix). This option applies to all following input files until
1628 the next @option{-x} option. Possible values for @var{language} are:
1630 c c-header cpp-output
1631 c++ c++-header c++-system-header c++-user-header c++-cpp-output
1632 objective-c objective-c-header objective-c-cpp-output
1633 objective-c++ objective-c++-header objective-c++-cpp-output
1634 assembler assembler-with-cpp
1637 f77 f77-cpp-input f95 f95-cpp-input
1642 Turn off any specification of a language, so that subsequent files are
1643 handled according to their file name suffixes (as they are if @option{-x}
1644 has not been used at all).
1647 If you only want some of the stages of compilation, you can use
1648 @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1649 one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1650 @command{gcc} is to stop. Note that some combinations (for example,
1651 @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1656 Compile or assemble the source files, but do not link. The linking
1657 stage simply is not done. The ultimate output is in the form of an
1658 object file for each source file.
1660 By default, the object file name for a source file is made by replacing
1661 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1663 Unrecognized input files, not requiring compilation or assembly, are
1668 Stop after the stage of compilation proper; do not assemble. The output
1669 is in the form of an assembler code file for each non-assembler input
1672 By default, the assembler file name for a source file is made by
1673 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1675 Input files that don't require compilation are ignored.
1679 Stop after the preprocessing stage; do not run the compiler proper. The
1680 output is in the form of preprocessed source code, which is sent to the
1683 Input files that don't require preprocessing are ignored.
1685 @cindex output file option
1688 Place the primary output in file @var{file}. This applies to whatever
1689 sort of output is being produced, whether it be an executable file, an
1690 object file, an assembler file or preprocessed C code.
1692 If @option{-o} is not specified, the default is to put an executable
1693 file in @file{a.out}, the object file for
1694 @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1695 assembler file in @file{@var{source}.s}, a precompiled header file in
1696 @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1699 Though @option{-o} names only the primary output, it also affects the
1700 naming of auxiliary and dump outputs. See the examples below. Unless
1701 overridden, both auxiliary outputs and dump outputs are placed in the
1702 same directory as the primary output. In auxiliary outputs, the suffix
1703 of the input file is replaced with that of the auxiliary output file
1704 type; in dump outputs, the suffix of the dump file is appended to the
1705 input file suffix. In compilation commands, the base name of both
1706 auxiliary and dump outputs is that of the primary output; in compile and
1707 link commands, the primary output name, minus the executable suffix, is
1708 combined with the input file name. If both share the same base name,
1709 disregarding the suffix, the result of the combination is that base
1710 name, otherwise, they are concatenated, separated by a dash.
1716 will use @file{foo.o} as the primary output, and place aux outputs and
1717 dumps next to it, e.g., aux file @file{foo.dwo} for
1718 @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1719 @option{-fdump-rtl-final}.
1721 If a non-linker output file is explicitly specified, aux and dump files
1722 by default take the same base name:
1725 gcc -c foo.c -o dir/foobar.o ...
1728 will name aux outputs @file{dir/foobar.*} and dump outputs
1729 @file{dir/foobar.c.*}.
1731 A linker output will instead prefix aux and dump outputs:
1734 gcc foo.c bar.c -o dir/foobar ...
1737 will generally name aux outputs @file{dir/foobar-foo.*} and
1738 @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1739 @file{dir/foobar-bar.c.*}.
1741 The one exception to the above is when the executable shares the base
1742 name with the single input:
1745 gcc foo.c -o dir/foo ...
1748 in which case aux outputs are named @file{dir/foo.*} and dump outputs
1749 named @file{dir/foo.c.*}.
1751 The location and the names of auxiliary and dump outputs can be adjusted
1752 by the options @option{-dumpbase}, @option{-dumpbase-ext},
1753 @option{-dumpdir}, @option{-save-temps=cwd}, and
1754 @option{-save-temps=obj}.
1757 @item -dumpbase @var{dumpbase}
1759 This option sets the base name for auxiliary and dump output files. It
1760 does not affect the name of the primary output file. Intermediate
1761 outputs, when preserved, are not regarded as primary outputs, but as
1765 gcc -save-temps -S foo.c
1768 saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1769 then compiles to the (implied) output file @file{foo.s}, whereas:
1772 gcc -save-temps -dumpbase save-foo -c foo.c
1775 preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1776 an intermediate, thus auxiliary output), and then assembles to the
1777 (implied) output file @file{foo.o}.
1779 Absent this option, dump and aux files take their names from the input
1780 file, or from the (non-linker) output file, if one is explicitly
1781 specified: dump output files (e.g. those requested by @option{-fdump-*}
1782 options) with the input name suffix, and aux output files (those
1783 requested by other non-dump options, e.g. @code{-save-temps},
1784 @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1786 Similar suffix differentiation of dump and aux outputs can be attained
1787 for explicitly-given @option{-dumpbase basename.suf} by also specifying
1788 @option{-dumpbase-ext .suf}.
1790 If @var{dumpbase} is explicitly specified with any directory component,
1791 any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1792 @option{-save-temps=*}) is ignored, and instead of appending to it,
1793 @var{dumpbase} fully overrides it:
1796 gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1797 -dumpdir pfx- -save-temps=cwd ...
1800 creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1801 @file{dir/} in @option{-o}, the @file{./} prefix implied by
1802 @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1804 When @option{-dumpbase} is specified in a command that compiles multiple
1805 inputs, or that compiles and then links, it may be combined with
1806 @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1807 file is compiled using the combined @var{dumppfx}, and default values
1808 for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1812 gcc foo.c bar.c -c -dumpbase main ...
1815 creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1816 overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1817 as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1818 and @file{main-bar.*}.
1820 An empty string specified as @var{dumpbase} avoids the influence of the
1821 output basename in the naming of auxiliary and dump outputs during
1822 compilation, computing default values :
1825 gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1828 will name aux outputs @file{dir/foo.*} and dump outputs
1829 @file{dir/foo.c.*}. Note how their basenames are taken from the input
1830 name, but the directory still defaults to that of the output.
1832 The empty-string dumpbase does not prevent the use of the output
1833 basename for outputs during linking:
1836 gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1839 The compilation of the source files will name auxiliary outputs
1840 @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1841 @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1842 linking will use @file{dir/foobar.} as the prefix for dumps and
1846 @item -dumpbase-ext @var{auxdropsuf}
1847 @opindex dumpbase-ext
1848 When forming the name of an auxiliary (but not a dump) output file, drop
1849 trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1850 suffixes. If not specified, this option defaults to the suffix of a
1851 default @var{dumpbase}, i.e., the suffix of the input file when
1852 @option{-dumpbase} is not present in the command line, or @var{dumpbase}
1853 is combined with @var{dumppfx}.
1856 gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1859 creates @file{dir/foo.o} as the main output, and generates auxiliary
1860 outputs in @file{dir/x-foo.*}, taking the location of the primary
1861 output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1862 outputs retain the suffix: @file{dir/x-foo.c.*}.
1864 This option is disregarded if it does not match the suffix of a
1865 specified @var{dumpbase}, except as an alternative to the executable
1866 suffix when appending the linker output base name to @var{dumppfx}, as
1870 gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1873 creates @file{main.out} as the primary output, and avoids overwriting
1874 the auxiliary and dump outputs by using the executable name minus
1875 @var{auxdropsuf} as a prefix, creating auxiliary outputs named
1876 @file{main-foo.*} and @file{main-bar.*} and dump outputs named
1877 @file{main-foo.c.*} and @file{main-bar.c.*}.
1880 @item -dumpdir @var{dumppfx}
1882 When forming the name of an auxiliary or dump output file, use
1883 @var{dumppfx} as a prefix:
1886 gcc -dumpdir pfx- -c foo.c ...
1889 creates @file{foo.o} as the primary output, and auxiliary outputs named
1890 @file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1891 @var{dumpbase} derived from the default primary output, derived in turn
1892 from the input name. Dump outputs also take the input name suffix:
1895 If @var{dumppfx} is to be used as a directory name, it must end with a
1896 directory separator:
1899 gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1902 creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1903 named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1904 default @var{dumpbase} derived from the primary output name. Dump
1905 outputs also take the input name suffix: @file{dir/bar.c.*}.
1907 It defaults to the location of the output file, unless the output
1908 file is a special file like @code{/dev/null}. Options
1909 @option{-save-temps=cwd} and @option{-save-temps=obj} override this
1910 default, just like an explicit @option{-dumpdir} option. In case
1911 multiple such options are given, the last one prevails:
1914 gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1917 outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1918 @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1919 @option{-dumpdir} option. It does not matter that @option{=obj} is the
1920 default for @option{-save-temps}, nor that the output directory is
1921 implicitly the current directory. Dump outputs are named
1924 When compiling from multiple input files, if @option{-dumpbase} is
1925 specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1926 are appended to (or override, if containing any directory components) an
1927 explicit or defaulted @var{dumppfx}, so that each of the multiple
1928 compilations gets differently-named aux and dump outputs.
1931 gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1934 outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1935 @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1936 Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1937 and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1938 single-input compilation:
1941 gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1944 that, applying @option{-dumpbase} to a single source, does not compute
1945 and append a separate @var{dumpbase} per input file. Its auxiliary and
1946 dump outputs go in @file{dir/pfx-main.*}.
1948 When compiling and then linking from multiple input files, a defaulted
1949 or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1950 transformation above (e.g. the compilation of @file{foo.c} and
1951 @file{bar.c} above, but without @option{-c}). If neither
1952 @option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1953 base name, minus @var{auxdropsuf}, if specified, or the executable
1954 suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1955 instead. Note, however, that unlike earlier cases of linking:
1958 gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1961 does not append the output name @file{main} to @var{dumppfx}, because
1962 @option{-dumpdir} is explicitly specified. The goal is that the
1963 explicitly-specified @var{dumppfx} may contain the specified output name
1964 as part of the prefix, if desired; only an explicitly-specified
1965 @option{-dumpbase} would be combined with it, in order to avoid simply
1966 discarding a meaningful option.
1968 When compiling and then linking from a single input file, the linker
1969 output base name will only be appended to the default @var{dumppfx} as
1970 above if it does not share the base name with the single input file
1971 name. This has been covered in single-input linking cases above, but
1972 not with an explicit @option{-dumpdir} that inhibits the combination,
1973 even if overridden by @option{-save-temps=*}:
1976 gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
1979 Auxiliary outputs are named @file{foo.*}, and dump outputs
1980 @file{foo.c.*}, in the current working directory as ultimately requested
1981 by @option{-save-temps=cwd}.
1983 Summing it all up for an intuitive though slightly imprecise data flow:
1984 the primary output name is broken into a directory part and a basename
1985 part; @var{dumppfx} is set to the former, unless overridden by
1986 @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
1987 to the latter, unless overriden by @option{-dumpbase}. If there are
1988 multiple inputs or linking, this @var{dumpbase} may be combined with
1989 @var{dumppfx} and taken from each input file. Auxiliary output names
1990 for each input are formed by combining @var{dumppfx}, @var{dumpbase}
1991 minus suffix, and the auxiliary output suffix; dump output names are
1992 only different in that the suffix from @var{dumpbase} is retained.
1994 When it comes to auxiliary and dump outputs created during LTO
1995 recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
1996 given or as derived from the linker output name but not from inputs,
1997 even in cases in which this combination would not otherwise be used as
1998 such, is passed down with a trailing period replacing the compiler-added
1999 dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2000 being involved in linking, this program does not normally get any
2001 @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2003 When running sub-compilers, @command{lto-wrapper} appends LTO stage
2004 names to the received @var{dumppfx}, ensures it contains a directory
2005 component so that it overrides any @option{-dumpdir}, and passes that as
2006 @option{-dumpbase} to sub-compilers.
2010 Print (on standard error output) the commands executed to run the stages
2011 of compilation. Also print the version number of the compiler driver
2012 program and of the preprocessor and the compiler proper.
2016 Like @option{-v} except the commands are not executed and arguments
2017 are quoted unless they contain only alphanumeric characters or @code{./-_}.
2018 This is useful for shell scripts to capture the driver-generated command lines.
2022 Print (on the standard output) a description of the command-line options
2023 understood by @command{gcc}. If the @option{-v} option is also specified
2024 then @option{--help} is also passed on to the various processes
2025 invoked by @command{gcc}, so that they can display the command-line options
2026 they accept. If the @option{-Wextra} option has also been specified
2027 (prior to the @option{--help} option), then command-line options that
2028 have no documentation associated with them are also displayed.
2031 @opindex target-help
2032 Print (on the standard output) a description of target-specific command-line
2033 options for each tool. For some targets extra target-specific
2034 information may also be printed.
2036 @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2037 Print (on the standard output) a description of the command-line
2038 options understood by the compiler that fit into all specified classes
2039 and qualifiers. These are the supported classes:
2042 @item @samp{optimizers}
2043 Display all of the optimization options supported by the
2046 @item @samp{warnings}
2047 Display all of the options controlling warning messages
2048 produced by the compiler.
2051 Display target-specific options. Unlike the
2052 @option{--target-help} option however, target-specific options of the
2053 linker and assembler are not displayed. This is because those
2054 tools do not currently support the extended @option{--help=} syntax.
2057 Display the values recognized by the @option{--param}
2060 @item @var{language}
2061 Display the options supported for @var{language}, where
2062 @var{language} is the name of one of the languages supported in this
2063 version of GCC@. If an option is supported by all languages, one needs
2064 to select @samp{common} class.
2067 Display the options that are common to all languages.
2070 These are the supported qualifiers:
2073 @item @samp{undocumented}
2074 Display only those options that are undocumented.
2077 Display options taking an argument that appears after an equal
2078 sign in the same continuous piece of text, such as:
2079 @samp{--help=target}.
2081 @item @samp{separate}
2082 Display options taking an argument that appears as a separate word
2083 following the original option, such as: @samp{-o output-file}.
2086 Thus for example to display all the undocumented target-specific
2087 switches supported by the compiler, use:
2090 --help=target,undocumented
2093 The sense of a qualifier can be inverted by prefixing it with the
2094 @samp{^} character, so for example to display all binary warning
2095 options (i.e., ones that are either on or off and that do not take an
2096 argument) that have a description, use:
2099 --help=warnings,^joined,^undocumented
2102 The argument to @option{--help=} should not consist solely of inverted
2105 Combining several classes is possible, although this usually
2106 restricts the output so much that there is nothing to display. One
2107 case where it does work, however, is when one of the classes is
2108 @var{target}. For example, to display all the target-specific
2109 optimization options, use:
2112 --help=target,optimizers
2115 The @option{--help=} option can be repeated on the command line. Each
2116 successive use displays its requested class of options, skipping
2117 those that have already been displayed. If @option{--help} is also
2118 specified anywhere on the command line then this takes precedence
2119 over any @option{--help=} option.
2121 If the @option{-Q} option appears on the command line before the
2122 @option{--help=} option, then the descriptive text displayed by
2123 @option{--help=} is changed. Instead of describing the displayed
2124 options, an indication is given as to whether the option is enabled,
2125 disabled or set to a specific value (assuming that the compiler
2126 knows this at the point where the @option{--help=} option is used).
2128 Here is a truncated example from the ARM port of @command{gcc}:
2131 % gcc -Q -mabi=2 --help=target -c
2132 The following options are target specific:
2134 -mabort-on-noreturn [disabled]
2138 The output is sensitive to the effects of previous command-line
2139 options, so for example it is possible to find out which optimizations
2140 are enabled at @option{-O2} by using:
2143 -Q -O2 --help=optimizers
2146 Alternatively you can discover which binary optimizations are enabled
2147 by @option{-O3} by using:
2150 gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2151 gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2152 diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2157 Display the version number and copyrights of the invoked GCC@.
2159 @item -pass-exit-codes
2160 @opindex pass-exit-codes
2161 Normally the @command{gcc} program exits with the code of 1 if any
2162 phase of the compiler returns a non-success return code. If you specify
2163 @option{-pass-exit-codes}, the @command{gcc} program instead returns with
2164 the numerically highest error produced by any phase returning an error
2165 indication. The C, C++, and Fortran front ends return 4 if an internal
2166 compiler error is encountered.
2170 Use pipes rather than temporary files for communication between the
2171 various stages of compilation. This fails to work on some systems where
2172 the assembler is unable to read from a pipe; but the GNU assembler has
2175 @item -specs=@var{file}
2177 Process @var{file} after the compiler reads in the standard @file{specs}
2178 file, in order to override the defaults which the @command{gcc} driver
2179 program uses when determining what switches to pass to @command{cc1},
2180 @command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2181 @option{-specs=@var{file}} can be specified on the command line, and they
2182 are processed in order, from left to right. @xref{Spec Files}, for
2183 information about the format of the @var{file}.
2187 Invoke all subcommands under a wrapper program. The name of the
2188 wrapper program and its parameters are passed as a comma separated
2192 gcc -c t.c -wrapper gdb,--args
2196 This invokes all subprograms of @command{gcc} under
2197 @samp{gdb --args}, thus the invocation of @command{cc1} is
2198 @samp{gdb --args cc1 @dots{}}.
2200 @item -ffile-prefix-map=@var{old}=@var{new}
2201 @opindex ffile-prefix-map
2202 When compiling files residing in directory @file{@var{old}}, record
2203 any references to them in the result of the compilation as if the
2204 files resided in directory @file{@var{new}} instead. Specifying this
2205 option is equivalent to specifying all the individual
2206 @option{-f*-prefix-map} options. This can be used to make reproducible
2207 builds that are location independent. Directories referenced by
2208 directives are not affected by these options. See also
2209 @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map} and
2210 @option{-fprofile-prefix-map}.
2212 @item -fplugin=@var{name}.so
2214 Load the plugin code in file @var{name}.so, assumed to be a
2215 shared object to be dlopen'd by the compiler. The base name of
2216 the shared object file is used to identify the plugin for the
2217 purposes of argument parsing (See
2218 @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2219 Each plugin should define the callback functions specified in the
2222 @item -fplugin-arg-@var{name}-@var{key}=@var{value}
2223 @opindex fplugin-arg
2224 Define an argument called @var{key} with a value of @var{value}
2225 for the plugin called @var{name}.
2227 @item -fdump-ada-spec@r{[}-slim@r{]}
2228 @opindex fdump-ada-spec
2229 For C and C++ source and include files, generate corresponding Ada specs.
2230 @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2231 GNAT User's Guide}, which provides detailed documentation on this feature.
2233 @item -fada-spec-parent=@var{unit}
2234 @opindex fada-spec-parent
2235 In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2236 Ada specs as child units of parent @var{unit}.
2238 @item -fdump-go-spec=@var{file}
2239 @opindex fdump-go-spec
2240 For input files in any language, generate corresponding Go
2241 declarations in @var{file}. This generates Go @code{const},
2242 @code{type}, @code{var}, and @code{func} declarations which may be a
2243 useful way to start writing a Go interface to code written in some
2246 @include @value{srcdir}/../libiberty/at-file.texi
2250 @section Compiling C++ Programs
2252 @cindex suffixes for C++ source
2253 @cindex C++ source file suffixes
2254 C++ source files conventionally use one of the suffixes @samp{.C},
2255 @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2256 @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2257 @samp{.H}, or (for shared template code) @samp{.tcc}; and
2258 preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2259 files with these names and compiles them as C++ programs even if you
2260 call the compiler the same way as for compiling C programs (usually
2261 with the name @command{gcc}).
2265 However, the use of @command{gcc} does not add the C++ library.
2266 @command{g++} is a program that calls GCC and automatically specifies linking
2267 against the C++ library. It treats @samp{.c},
2268 @samp{.h} and @samp{.i} files as C++ source files instead of C source
2269 files unless @option{-x} is used. This program is also useful when
2270 precompiling a C header file with a @samp{.h} extension for use in C++
2271 compilations. On many systems, @command{g++} is also installed with
2272 the name @command{c++}.
2274 @cindex invoking @command{g++}
2275 When you compile C++ programs, you may specify many of the same
2276 command-line options that you use for compiling programs in any
2277 language; or command-line options meaningful for C and related
2278 languages; or options that are meaningful only for C++ programs.
2279 @xref{C Dialect Options,,Options Controlling C Dialect}, for
2280 explanations of options for languages related to C@.
2281 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2282 explanations of options that are meaningful only for C++ programs.
2284 @node C Dialect Options
2285 @section Options Controlling C Dialect
2286 @cindex dialect options
2287 @cindex language dialect options
2288 @cindex options, dialect
2290 The following options control the dialect of C (or languages derived
2291 from C, such as C++, Objective-C and Objective-C++) that the compiler
2295 @cindex ANSI support
2299 In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2300 equivalent to @option{-std=c++98}.
2302 This turns off certain features of GCC that are incompatible with ISO
2303 C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2304 such as the @code{asm} and @code{typeof} keywords, and
2305 predefined macros such as @code{unix} and @code{vax} that identify the
2306 type of system you are using. It also enables the undesirable and
2307 rarely used ISO trigraph feature. For the C compiler,
2308 it disables recognition of C++ style @samp{//} comments as well as
2309 the @code{inline} keyword.
2311 The alternate keywords @code{__asm__}, @code{__extension__},
2312 @code{__inline__} and @code{__typeof__} continue to work despite
2313 @option{-ansi}. You would not want to use them in an ISO C program, of
2314 course, but it is useful to put them in header files that might be included
2315 in compilations done with @option{-ansi}. Alternate predefined macros
2316 such as @code{__unix__} and @code{__vax__} are also available, with or
2317 without @option{-ansi}.
2319 The @option{-ansi} option does not cause non-ISO programs to be
2320 rejected gratuitously. For that, @option{-Wpedantic} is required in
2321 addition to @option{-ansi}. @xref{Warning Options}.
2323 The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2324 option is used. Some header files may notice this macro and refrain
2325 from declaring certain functions or defining certain macros that the
2326 ISO standard doesn't call for; this is to avoid interfering with any
2327 programs that might use these names for other things.
2329 Functions that are normally built in but do not have semantics
2330 defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2331 functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2332 built-in functions provided by GCC}, for details of the functions
2337 Determine the language standard. @xref{Standards,,Language Standards
2338 Supported by GCC}, for details of these standard versions. This option
2339 is currently only supported when compiling C or C++.
2341 The compiler can accept several base standards, such as @samp{c90} or
2342 @samp{c++98}, and GNU dialects of those standards, such as
2343 @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2344 compiler accepts all programs following that standard plus those
2345 using GNU extensions that do not contradict it. For example,
2346 @option{-std=c90} turns off certain features of GCC that are
2347 incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2348 keywords, but not other GNU extensions that do not have a meaning in
2349 ISO C90, such as omitting the middle term of a @code{?:}
2350 expression. On the other hand, when a GNU dialect of a standard is
2351 specified, all features supported by the compiler are enabled, even when
2352 those features change the meaning of the base standard. As a result, some
2353 strict-conforming programs may be rejected. The particular standard
2354 is used by @option{-Wpedantic} to identify which features are GNU
2355 extensions given that version of the standard. For example
2356 @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2357 comments, while @option{-std=gnu99 -Wpedantic} does not.
2359 A value for this option must be provided; possible values are
2365 Support all ISO C90 programs (certain GNU extensions that conflict
2366 with ISO C90 are disabled). Same as @option{-ansi} for C code.
2368 @item iso9899:199409
2369 ISO C90 as modified in amendment 1.
2375 ISO C99. This standard is substantially completely supported, modulo
2376 bugs and floating-point issues
2377 (mainly but not entirely relating to optional C99 features from
2378 Annexes F and G). See
2379 @w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2380 names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2385 ISO C11, the 2011 revision of the ISO C standard. This standard is
2386 substantially completely supported, modulo bugs, floating-point issues
2387 (mainly but not entirely relating to optional C11 features from
2388 Annexes F and G) and the optional Annexes K (Bounds-checking
2389 interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2395 ISO C17, the 2017 revision of the ISO C standard
2396 (published in 2018). This standard is
2397 same as C11 except for corrections of defects (all of which are also
2398 applied with @option{-std=c11}) and a new value of
2399 @code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2402 The next version of the ISO C standard, still under development. The
2403 support for this version is experimental and incomplete.
2407 GNU dialect of ISO C90 (including some C99 features).
2411 GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2415 GNU dialect of ISO C11.
2416 The name @samp{gnu1x} is deprecated.
2420 GNU dialect of ISO C17. This is the default for C code.
2423 The next version of the ISO C standard, still under development, plus
2424 GNU extensions. The support for this version is experimental and
2429 The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2430 additional defect reports. Same as @option{-ansi} for C++ code.
2434 GNU dialect of @option{-std=c++98}.
2438 The 2011 ISO C++ standard plus amendments.
2439 The name @samp{c++0x} is deprecated.
2443 GNU dialect of @option{-std=c++11}.
2444 The name @samp{gnu++0x} is deprecated.
2448 The 2014 ISO C++ standard plus amendments.
2449 The name @samp{c++1y} is deprecated.
2453 GNU dialect of @option{-std=c++14}.
2454 The name @samp{gnu++1y} is deprecated.
2458 The 2017 ISO C++ standard plus amendments.
2459 The name @samp{c++1z} is deprecated.
2463 GNU dialect of @option{-std=c++17}.
2464 This is the default for C++ code.
2465 The name @samp{gnu++1z} is deprecated.
2469 The 2020 ISO C++ standard plus amendments.
2470 Support is experimental, and could change in incompatible ways in
2472 The name @samp{c++2a} is deprecated.
2476 GNU dialect of @option{-std=c++20}.
2477 Support is experimental, and could change in incompatible ways in
2479 The name @samp{gnu++2a} is deprecated.
2483 The next revision of the ISO C++ standard, planned for
2484 2023. Support is highly experimental, and will almost certainly
2485 change in incompatible ways in future releases.
2489 GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2490 and will almost certainly change in incompatible ways in future
2494 @item -aux-info @var{filename}
2496 Output to the given filename prototyped declarations for all functions
2497 declared and/or defined in a translation unit, including those in header
2498 files. This option is silently ignored in any language other than C@.
2500 Besides declarations, the file indicates, in comments, the origin of
2501 each declaration (source file and line), whether the declaration was
2502 implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2503 @samp{O} for old, respectively, in the first character after the line
2504 number and the colon), and whether it came from a declaration or a
2505 definition (@samp{C} or @samp{F}, respectively, in the following
2506 character). In the case of function definitions, a K&R-style list of
2507 arguments followed by their declarations is also provided, inside
2508 comments, after the declaration.
2513 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2514 keyword, so that code can use these words as identifiers. You can use
2515 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2516 instead. In C, @option{-ansi} implies @option{-fno-asm}.
2518 In C++, @code{inline} is a standard keyword and is not affected by
2519 this switch. You may want to use the @option{-fno-gnu-keywords} flag
2520 instead, which disables @code{typeof} but not @code{asm} and
2521 @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2522 this switch only affects the @code{asm} and @code{typeof} keywords,
2523 since @code{inline} is a standard keyword in ISO C99. In C2X mode
2524 (@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects
2525 the @code{asm} keyword, since @code{typeof} is a standard keyword in
2529 @itemx -fno-builtin-@var{function}
2530 @opindex fno-builtin
2532 @cindex built-in functions
2533 Don't recognize built-in functions that do not begin with
2534 @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2535 functions provided by GCC}, for details of the functions affected,
2536 including those which are not built-in functions when @option{-ansi} or
2537 @option{-std} options for strict ISO C conformance are used because they
2538 do not have an ISO standard meaning.
2540 GCC normally generates special code to handle certain built-in functions
2541 more efficiently; for instance, calls to @code{alloca} may become single
2542 instructions which adjust the stack directly, and calls to @code{memcpy}
2543 may become inline copy loops. The resulting code is often both smaller
2544 and faster, but since the function calls no longer appear as such, you
2545 cannot set a breakpoint on those calls, nor can you change the behavior
2546 of the functions by linking with a different library. In addition,
2547 when a function is recognized as a built-in function, GCC may use
2548 information about that function to warn about problems with calls to
2549 that function, or to generate more efficient code, even if the
2550 resulting code still contains calls to that function. For example,
2551 warnings are given with @option{-Wformat} for bad calls to
2552 @code{printf} when @code{printf} is built in and @code{strlen} is
2553 known not to modify global memory.
2555 With the @option{-fno-builtin-@var{function}} option
2556 only the built-in function @var{function} is
2557 disabled. @var{function} must not begin with @samp{__builtin_}. If a
2558 function is named that is not built-in in this version of GCC, this
2559 option is ignored. There is no corresponding
2560 @option{-fbuiltin-@var{function}} option; if you wish to enable
2561 built-in functions selectively when using @option{-fno-builtin} or
2562 @option{-ffreestanding}, you may define macros such as:
2565 #define abs(n) __builtin_abs ((n))
2566 #define strcpy(d, s) __builtin_strcpy ((d), (s))
2569 @item -fcond-mismatch
2570 @opindex fcond-mismatch
2571 Allow conditional expressions with mismatched types in the second and
2572 third arguments. The value of such an expression is void. This option
2573 is not supported for C++.
2575 @item -ffreestanding
2576 @opindex ffreestanding
2577 @cindex hosted environment
2579 Assert that compilation targets a freestanding environment. This
2580 implies @option{-fno-builtin}. A freestanding environment
2581 is one in which the standard library may not exist, and program startup may
2582 not necessarily be at @code{main}. The most obvious example is an OS kernel.
2583 This is equivalent to @option{-fno-hosted}.
2585 @xref{Standards,,Language Standards Supported by GCC}, for details of
2586 freestanding and hosted environments.
2591 Enable parsing of function definitions marked with @code{__GIMPLE}.
2592 This is an experimental feature that allows unit testing of GIMPLE
2597 When the option @option{-fgnu-tm} is specified, the compiler
2598 generates code for the Linux variant of Intel's current Transactional
2599 Memory ABI specification document (Revision 1.1, May 6 2009). This is
2600 an experimental feature whose interface may change in future versions
2601 of GCC, as the official specification changes. Please note that not
2602 all architectures are supported for this feature.
2604 For more information on GCC's support for transactional memory,
2605 @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2606 Transactional Memory Library}.
2608 Note that the transactional memory feature is not supported with
2609 non-call exceptions (@option{-fnon-call-exceptions}).
2611 @item -fgnu89-inline
2612 @opindex fgnu89-inline
2613 The option @option{-fgnu89-inline} tells GCC to use the traditional
2614 GNU semantics for @code{inline} functions when in C99 mode.
2615 @xref{Inline,,An Inline Function is As Fast As a Macro}.
2616 Using this option is roughly equivalent to adding the
2617 @code{gnu_inline} function attribute to all inline functions
2618 (@pxref{Function Attributes}).
2620 The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2621 C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2622 specifies the default behavior).
2623 This option is not supported in @option{-std=c90} or
2624 @option{-std=gnu90} mode.
2626 The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2627 @code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2628 in effect for @code{inline} functions. @xref{Common Predefined
2629 Macros,,,cpp,The C Preprocessor}.
2633 @cindex hosted environment
2635 Assert that compilation targets a hosted environment. This implies
2636 @option{-fbuiltin}. A hosted environment is one in which the
2637 entire standard library is available, and in which @code{main} has a return
2638 type of @code{int}. Examples are nearly everything except a kernel.
2639 This is equivalent to @option{-fno-freestanding}.
2641 @item -flax-vector-conversions
2642 @opindex flax-vector-conversions
2643 Allow implicit conversions between vectors with differing numbers of
2644 elements and/or incompatible element types. This option should not be
2647 @item -fms-extensions
2648 @opindex fms-extensions
2649 Accept some non-standard constructs used in Microsoft header files.
2651 In C++ code, this allows member names in structures to be similar
2652 to previous types declarations.
2661 Some cases of unnamed fields in structures and unions are only
2662 accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2663 fields within structs/unions}, for details.
2665 Note that this option is off for all targets except for x86
2666 targets using ms-abi.
2668 @item -foffload=disable
2669 @itemx -foffload=default
2670 @itemx -foffload=@var{target-list}
2672 @cindex Offloading targets
2673 @cindex OpenACC offloading targets
2674 @cindex OpenMP offloading targets
2675 Specify for which OpenMP and OpenACC offload targets code should be generated.
2676 The default behavior, equivalent to @option{-foffload=default}, is to generate
2677 code for all supported offload targets. The @option{-foffload=disable} form
2678 generates code only for the host fallback, while
2679 @option{-foffload=@var{target-list}} generates code only for the specified
2680 comma-separated list of offload targets.
2682 Offload targets are specified in GCC's internal target-triplet format. You can
2683 run the compiler with @option{-v} to show the list of configured offload targets
2684 under @code{OFFLOAD_TARGET_NAMES}.
2686 @item -foffload-options=@var{options}
2687 @itemx -foffload-options=@var{target-triplet-list}=@var{options}
2688 @opindex foffload-options
2689 @cindex Offloading options
2690 @cindex OpenACC offloading options
2691 @cindex OpenMP offloading options
2693 With @option{-foffload-options=@var{options}}, GCC passes the specified
2694 @var{options} to the compilers for all enabled offloading targets. You can
2695 specify options that apply only to a specific target or targets by using
2696 the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2697 @var{target-list} is a comma-separated list in the same format as for the
2698 @option{-foffload=} option.
2700 Typical command lines are
2703 -foffload-options=-lgfortran -foffload-options=-lm
2704 -foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic
2705 -foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm
2710 @cindex OpenACC accelerator programming
2711 Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and
2712 @code{!$acc} in Fortran. When @option{-fopenacc} is specified, the
2713 compiler generates accelerated code according to the OpenACC Application
2714 Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2715 implies @option{-pthread}, and thus is only supported on targets that
2716 have support for @option{-pthread}.
2718 @item -fopenacc-dim=@var{geom}
2719 @opindex fopenacc-dim
2720 @cindex OpenACC accelerator programming
2721 Specify default compute dimensions for parallel offload regions that do
2722 not explicitly specify. The @var{geom} value is a triple of
2723 ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2724 can be omitted, to use a target-specific default value.
2728 @cindex OpenMP parallel
2729 Enable handling of OpenMP directives @code{#pragma omp} in C/C++,
2730 @code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ and
2731 @code{!$omp} in Fortran. When @option{-fopenmp} is specified, the
2732 compiler generates parallel code according to the OpenMP Application
2733 Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2734 implies @option{-pthread}, and thus is only supported on targets that
2735 have support for @option{-pthread}. @option{-fopenmp} implies
2736 @option{-fopenmp-simd}.
2739 @opindex fopenmp-simd
2742 Enable handling of OpenMP's @code{simd}, @code{declare simd},
2743 @code{declare reduction}, @code{assume}, @code{ordered}, @code{scan},
2744 @code{loop} directives and combined or composite directives with
2745 @code{simd} as constituent with @code{#pragma omp} in C/C++,
2746 @code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++
2747 and @code{!$omp} in Fortran. Other OpenMP directives are ignored.
2749 @item -fopenmp-target-simd-clone
2750 @item -fopenmp-target-simd-clone=@var{device-type}
2751 @opindex fopenmp-target-simd-clone
2752 @cindex OpenMP target SIMD clone
2753 In addition to generating SIMD clones for functions marked with the
2754 @code{declare simd} directive, GCC also generates clones
2755 for functions marked with the OpenMP @code{declare target} directive
2756 that are suitable for vectorization when this option is in effect. The
2757 @var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2758 and @code{any}, which correspond to keywords for the @code{device_type}
2759 clause of the @code{declare target} directive; clones are generated for
2760 the intersection of devices specified.
2761 @option{-fopenmp-target-simd-clone} is equivalent to
2762 @option{-fopenmp-target-simd-clone=any} and
2763 @option{-fno-openmp-target-simd-clone} is equivalent to
2764 @option{-fopenmp-target-simd-clone=none}.
2766 At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2767 optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2768 it is disabled by default.
2770 @item -fpermitted-flt-eval-methods=@var{style}
2771 @opindex fpermitted-flt-eval-methods
2772 @opindex fpermitted-flt-eval-methods=c11
2773 @opindex fpermitted-flt-eval-methods=ts-18661-3
2774 ISO/IEC TS 18661-3 defines new permissible values for
2775 @code{FLT_EVAL_METHOD} that indicate that operations and constants with
2776 a semantic type that is an interchange or extended format should be
2777 evaluated to the precision and range of that type. These new values are
2778 a superset of those permitted under C99/C11, which does not specify the
2779 meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2780 conforming to C11 may not have been written expecting the possibility of
2783 @option{-fpermitted-flt-eval-methods} specifies whether the compiler
2784 should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2785 or the extended set of values specified in ISO/IEC TS 18661-3.
2787 @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2789 The default when in a standards compliant mode (@option{-std=c11} or similar)
2790 is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2791 dialect (@option{-std=gnu11} or similar) is
2792 @option{-fpermitted-flt-eval-methods=ts-18661-3}.
2794 @item -fplan9-extensions
2795 @opindex fplan9-extensions
2796 Accept some non-standard constructs used in Plan 9 code.
2798 This enables @option{-fms-extensions}, permits passing pointers to
2799 structures with anonymous fields to functions that expect pointers to
2800 elements of the type of the field, and permits referring to anonymous
2801 fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2802 struct/union fields within structs/unions}, for details. This is only
2803 supported for C, not C++.
2805 @item -fsigned-bitfields
2806 @itemx -funsigned-bitfields
2807 @itemx -fno-signed-bitfields
2808 @itemx -fno-unsigned-bitfields
2809 @opindex fsigned-bitfields
2810 @opindex funsigned-bitfields
2811 @opindex fno-signed-bitfields
2812 @opindex fno-unsigned-bitfields
2813 These options control whether a bit-field is signed or unsigned, when the
2814 declaration does not use either @code{signed} or @code{unsigned}. By
2815 default, such a bit-field is signed, because this is consistent: the
2816 basic integer types such as @code{int} are signed types.
2819 @opindex fsigned-char
2820 Let the type @code{char} be signed, like @code{signed char}.
2822 Note that this is equivalent to @option{-fno-unsigned-char}, which is
2823 the negative form of @option{-funsigned-char}. Likewise, the option
2824 @option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2826 @item -funsigned-char
2827 @opindex funsigned-char
2828 Let the type @code{char} be unsigned, like @code{unsigned char}.
2830 Each kind of machine has a default for what @code{char} should
2831 be. It is either like @code{unsigned char} by default or like
2832 @code{signed char} by default.
2834 Ideally, a portable program should always use @code{signed char} or
2835 @code{unsigned char} when it depends on the signedness of an object.
2836 But many programs have been written to use plain @code{char} and
2837 expect it to be signed, or expect it to be unsigned, depending on the
2838 machines they were written for. This option, and its inverse, let you
2839 make such a program work with the opposite default.
2841 The type @code{char} is always a distinct type from each of
2842 @code{signed char} or @code{unsigned char}, even though its behavior
2843 is always just like one of those two.
2845 @item -fstrict-flex-arrays
2846 @opindex fstrict-flex-arrays
2847 @opindex fno-strict-flex-arrays
2848 Control when to treat the trailing array of a structure as a flexible array
2849 member for the purpose of accessing the elements of such an array.
2850 The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2851 strictest. A trailing array is treated as a flexible array member only when it
2852 is declared as a flexible array member per C99 standard onwards.
2853 The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2854 least strict. All trailing arrays of structures are treated as flexible array
2857 @item -fstrict-flex-arrays=@var{level}
2858 @opindex fstrict-flex-arrays=@var{level}
2859 Control when to treat the trailing array of a structure as a flexible array
2860 member for the purpose of accessing the elements of such an array. The value
2861 of @var{level} controls the level of strictness.
2863 The possible values of @var{level} are the same as for the
2864 @code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2866 You can control this behavior for a specific trailing array field of a
2867 structure by using the variable attribute @code{strict_flex_array} attribute
2868 (@pxref{Variable Attributes}).
2870 @item -fsso-struct=@var{endianness}
2871 @opindex fsso-struct
2872 Set the default scalar storage order of structures and unions to the
2873 specified endianness. The accepted values are @samp{big-endian},
2874 @samp{little-endian} and @samp{native} for the native endianness of
2875 the target (the default). This option is not supported for C++.
2877 @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2878 code that is not binary compatible with code generated without it if the
2879 specified endianness is not the native endianness of the target.
2882 @node C++ Dialect Options
2883 @section Options Controlling C++ Dialect
2885 @cindex compiler options, C++
2886 @cindex C++ options, command-line
2887 @cindex options, C++
2888 This section describes the command-line options that are only meaningful
2889 for C++ programs. You can also use most of the GNU compiler options
2890 regardless of what language your program is in. For example, you
2891 might compile a file @file{firstClass.C} like this:
2894 g++ -g -fstrict-enums -O -c firstClass.C
2898 In this example, only @option{-fstrict-enums} is an option meant
2899 only for C++ programs; you can use the other options with any
2900 language supported by GCC@.
2902 Some options for compiling C programs, such as @option{-std}, are also
2903 relevant for C++ programs.
2904 @xref{C Dialect Options,,Options Controlling C Dialect}.
2906 Here is a list of options that are @emph{only} for compiling C++ programs:
2910 @item -fabi-version=@var{n}
2911 @opindex fabi-version
2912 Use version @var{n} of the C++ ABI@. The default is version 0.
2914 Version 0 refers to the version conforming most closely to
2915 the C++ ABI specification. Therefore, the ABI obtained using version 0
2916 will change in different versions of G++ as ABI bugs are fixed.
2918 Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2920 Version 2 is the version of the C++ ABI that first appeared in G++
2921 3.4, and was the default through G++ 4.9.
2923 Version 3 corrects an error in mangling a constant address as a
2926 Version 4, which first appeared in G++ 4.5, implements a standard
2927 mangling for vector types.
2929 Version 5, which first appeared in G++ 4.6, corrects the mangling of
2930 attribute const/volatile on function pointer types, decltype of a
2931 plain decl, and use of a function parameter in the declaration of
2934 Version 6, which first appeared in G++ 4.7, corrects the promotion
2935 behavior of C++11 scoped enums and the mangling of template argument
2936 packs, const/static_cast, prefix ++ and --, and a class scope function
2937 used as a template argument.
2939 Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2940 builtin type and corrects the mangling of lambdas in default argument
2943 Version 8, which first appeared in G++ 4.9, corrects the substitution
2944 behavior of function types with function-cv-qualifiers.
2946 Version 9, which first appeared in G++ 5.2, corrects the alignment of
2949 Version 10, which first appeared in G++ 6.1, adds mangling of
2950 attributes that affect type identity, such as ia32 calling convention
2951 attributes (e.g.@: @samp{stdcall}).
2953 Version 11, which first appeared in G++ 7, corrects the mangling of
2954 sizeof... expressions and operator names. For multiple entities with
2955 the same name within a function, that are declared in different scopes,
2956 the mangling now changes starting with the twelfth occurrence. It also
2957 implies @option{-fnew-inheriting-ctors}.
2959 Version 12, which first appeared in G++ 8, corrects the calling
2960 conventions for empty classes on the x86_64 target and for classes
2961 with only deleted copy/move constructors. It accidentally changes the
2962 calling convention for classes with a deleted copy constructor and a
2963 trivial move constructor.
2965 Version 13, which first appeared in G++ 8.2, fixes the accidental
2966 change in version 12.
2968 Version 14, which first appeared in G++ 10, corrects the mangling of
2969 the nullptr expression.
2971 Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
2974 Version 16, which first appeared in G++ 11, changes the mangling of
2975 @code{__alignof__} to be distinct from that of @code{alignof}, and
2976 dependent operator names.
2978 Version 17, which first appeared in G++ 12, fixes layout of classes
2979 that inherit from aggregate classes with default member initializers
2982 Version 18, which first appeard in G++ 13, fixes manglings of lambdas
2983 that have additional context.
2985 See also @option{-Wabi}.
2987 @item -fabi-compat-version=@var{n}
2988 @opindex fabi-compat-version
2989 On targets that support strong aliases, G++
2990 works around mangling changes by creating an alias with the correct
2991 mangled name when defining a symbol with an incorrect mangled name.
2992 This switch specifies which ABI version to use for the alias.
2994 With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
2995 compatibility). If another ABI version is explicitly selected, this
2996 defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
2997 use @option{-fabi-compat-version=2}.
2999 If this option is not provided but @option{-Wabi=@var{n}} is, that
3000 version is used for compatibility aliases. If this option is provided
3001 along with @option{-Wabi} (without the version), the version from this
3002 option is used for the warning.
3004 @item -fno-access-control
3005 @opindex fno-access-control
3006 @opindex faccess-control
3007 Turn off all access checking. This switch is mainly useful for working
3008 around bugs in the access control code.
3011 @opindex faligned-new
3012 Enable support for C++17 @code{new} of types that require more
3013 alignment than @code{void* ::operator new(std::size_t)} provides. A
3014 numeric argument such as @code{-faligned-new=32} can be used to
3015 specify how much alignment (in bytes) is provided by that function,
3016 but few users will need to override the default of
3017 @code{alignof(std::max_align_t)}.
3019 This flag is enabled by default for @option{-std=c++17}.
3024 @opindex fno-char8_t
3025 Enable support for @code{char8_t} as adopted for C++20. This includes
3026 the addition of a new @code{char8_t} fundamental type, changes to the
3027 types of UTF-8 string and character literals, new signatures for
3028 user-defined literals, associated standard library updates, and new
3029 @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3031 This option enables functions to be overloaded for ordinary and UTF-8
3035 int f(const char *); // #1
3036 int f(const char8_t *); // #2
3037 int v1 = f("text"); // Calls #1
3038 int v2 = f(u8"text"); // Calls #2
3042 and introduces new signatures for user-defined literals:
3045 int operator""_udl1(char8_t);
3046 int v3 = u8'x'_udl1;
3047 int operator""_udl2(const char8_t*, std::size_t);
3048 int v4 = u8"text"_udl2;
3049 template<typename T, T...> int operator""_udl3();
3050 int v5 = u8"text"_udl3;
3054 The change to the types of UTF-8 string and character literals introduces
3055 incompatibilities with ISO C++11 and later standards. For example, the
3056 following code is well-formed under ISO C++11, but is ill-formed when
3057 @option{-fchar8_t} is specified.
3060 const char *cp = u8"xx";// error: invalid conversion from
3061 // `const char8_t*' to `const char*'
3063 auto v = f(u8"xx"); // error: invalid conversion from
3064 // `const char8_t*' to `const char*'
3065 std::string s@{u8"xx"@}; // error: no matching function for call to
3066 // `std::basic_string<char>::basic_string()'
3067 using namespace std::literals;
3068 s = u8"xx"s; // error: conversion from
3069 // `basic_string<char8_t>' to non-scalar
3070 // type `basic_string<char>' requested
3075 Check that the pointer returned by @code{operator new} is non-null
3076 before attempting to modify the storage allocated. This check is
3077 normally unnecessary because the C++ standard specifies that
3078 @code{operator new} only returns @code{0} if it is declared
3079 @code{throw()}, in which case the compiler always checks the
3080 return value even without this option. In all other cases, when
3081 @code{operator new} has a non-empty exception specification, memory
3082 exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3083 @samp{new (nothrow)}.
3086 @itemx -fconcepts-ts
3088 @opindex fconcepts-ts
3089 Enable support for the C++ Concepts feature for constraining template
3090 arguments. With @option{-std=c++20} and above, Concepts are part of
3091 the language standard, so @option{-fconcepts} defaults to on.
3093 Some constructs that were allowed by the earlier C++ Extensions for
3094 Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3095 into the standard, can additionally be enabled by
3096 @option{-fconcepts-ts}.
3098 @item -fconstexpr-depth=@var{n}
3099 @opindex fconstexpr-depth
3100 Set the maximum nested evaluation depth for C++11 constexpr functions
3101 to @var{n}. A limit is needed to detect endless recursion during
3102 constant expression evaluation. The minimum specified by the standard
3105 @item -fconstexpr-cache-depth=@var{n}
3106 @opindex fconstexpr-cache-depth
3107 Set the maximum level of nested evaluation depth for C++11 constexpr
3108 functions that will be cached to @var{n}. This is a heuristic that
3109 trades off compilation speed (when the cache avoids repeated
3110 calculations) against memory consumption (when the cache grows very
3111 large from highly recursive evaluations). The default is 8. Very few
3112 users are likely to want to adjust it, but if your code does heavy
3113 constexpr calculations you might want to experiment to find which
3114 value works best for you.
3116 @item -fconstexpr-fp-except
3117 @opindex fconstexpr-fp-except
3118 Annex F of the C standard specifies that IEC559 floating point
3119 exceptions encountered at compile time should not stop compilation.
3120 C++ compilers have historically not followed this guidance, instead
3121 treating floating point division by zero as non-constant even though
3122 it has a well defined value. This flag tells the compiler to give
3123 Annex F priority over other rules saying that a particular operation
3127 constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3130 @item -fconstexpr-loop-limit=@var{n}
3131 @opindex fconstexpr-loop-limit
3132 Set the maximum number of iterations for a loop in C++14 constexpr functions
3133 to @var{n}. A limit is needed to detect infinite loops during
3134 constant expression evaluation. The default is 262144 (1<<18).
3136 @item -fconstexpr-ops-limit=@var{n}
3137 @opindex fconstexpr-ops-limit
3138 Set the maximum number of operations during a single constexpr evaluation.
3139 Even when number of iterations of a single loop is limited with the above limit,
3140 if there are several nested loops and each of them has many iterations but still
3141 smaller than the above limit, or if in a body of some loop or even outside
3142 of a loop too many expressions need to be evaluated, the resulting constexpr
3143 evaluation might take too long.
3144 The default is 33554432 (1<<25).
3148 Enable experimental support for the C++ Contracts feature, as briefly
3149 added to and then removed from the C++20 working paper (N4820). The
3150 implementation also includes proposed enhancements from papers P1290,
3151 P1332, and P1429. This functionality is intended mostly for those
3152 interested in experimentation towards refining the feature to get it
3153 into shape for a future C++ standard.
3155 On violation of a checked contract, the violation handler is called.
3156 Users can replace the violation handler by defining
3158 void handle_contract_violation (const std::experimental::contract_violation&);
3161 There are different sets of additional flags that can be used together
3162 to specify which contracts will be checked and how, for N4820
3163 contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3167 @item -fcontract-mode=[on|off]
3168 @opindex fcontract-mode
3169 Control whether any contracts have any semantics at all. Defaults to on.
3171 @item -fcontract-assumption-mode=[on|off]
3172 @opindex fcontract-assumption-mode
3173 [N4820] Control whether contracts with level @samp{axiom}
3174 should have the assume semantic. Defaults to on.
3176 @item -fcontract-build-level=[off|default|audit]
3177 @opindex fcontract-build-level
3178 [N4820] Specify which level of contracts to generate checks
3179 for. Defaults to @samp{default}.
3181 @item -fcontract-continuation-mode=[on|off]
3182 @opindex fcontract-continuation-mode
3183 [N4820] Control whether to allow the program to continue executing
3184 after a contract violation. That is, do checked contracts have the
3185 @samp{maybe} semantic described below rather than the @samp{never}
3186 semantic. Defaults to off.
3188 @item -fcontract-role=<name>:<default>,<audit>,<axiom>
3189 @opindex fcontract-role
3190 [P1332] Specify the concrete semantics for each contract level
3191 of a particular contract role.
3193 @item -fcontract-semantic=[default|audit|axiom]:<semantic>
3194 [P1429] Specify the concrete semantic for a particular
3197 @item -fcontract-strict-declarations=[on|off]
3198 @opindex fcontract-strict-declarations
3199 Control whether to reject adding contracts to a function after its
3200 first declaration. Defaults to off.
3203 The possible concrete semantics for that can be specified with
3204 @samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3208 This contract has no effect.
3211 This contract is treated like C++23 @code{[[assume]]}.
3213 @item check_never_continue
3216 This contract is checked. If it fails, the violation handler is
3217 called. If the handler returns, @code{std::terminate} is called.
3219 @item check_maybe_continue
3221 This contract is checked. If it fails, the violation handler is
3222 called. If the handler returns, execution continues normally.
3226 @opindex fcoroutines
3227 Enable support for the C++ coroutines extension (experimental).
3229 @item -fno-elide-constructors
3230 @opindex fno-elide-constructors
3231 @opindex felide-constructors
3232 The C++ standard allows an implementation to omit creating a temporary
3233 that is only used to initialize another object of the same type.
3234 Specifying this option disables that optimization, and forces G++ to
3235 call the copy constructor in all cases. This option also causes G++
3236 to call trivial member functions which otherwise would be expanded inline.
3238 In C++17, the compiler is required to omit these temporaries, but this
3239 option still affects trivial member functions.
3241 @item -fno-enforce-eh-specs
3242 @opindex fno-enforce-eh-specs
3243 @opindex fenforce-eh-specs
3244 Don't generate code to check for violation of exception specifications
3245 at run time. This option violates the C++ standard, but may be useful
3246 for reducing code size in production builds, much like defining
3247 @code{NDEBUG}. This does not give user code permission to throw
3248 exceptions in violation of the exception specifications; the compiler
3249 still optimizes based on the specifications, so throwing an
3250 unexpected exception results in undefined behavior at run time.
3252 @item -fextern-tls-init
3253 @itemx -fno-extern-tls-init
3254 @opindex fextern-tls-init
3255 @opindex fno-extern-tls-init
3256 The C++11 and OpenMP standards allow @code{thread_local} and
3257 @code{threadprivate} variables to have dynamic (runtime)
3258 initialization. To support this, any use of such a variable goes
3259 through a wrapper function that performs any necessary initialization.
3260 When the use and definition of the variable are in the same
3261 translation unit, this overhead can be optimized away, but when the
3262 use is in a different translation unit there is significant overhead
3263 even if the variable doesn't actually need dynamic initialization. If
3264 the programmer can be sure that no use of the variable in a
3265 non-defining TU needs to trigger dynamic initialization (either
3266 because the variable is statically initialized, or a use of the
3267 variable in the defining TU will be executed before any uses in
3268 another TU), they can avoid this overhead with the
3269 @option{-fno-extern-tls-init} option.
3271 On targets that support symbol aliases, the default is
3272 @option{-fextern-tls-init}. On targets that do not support symbol
3273 aliases, the default is @option{-fno-extern-tls-init}.
3275 @item -ffold-simple-inlines
3276 @itemx -fno-fold-simple-inlines
3277 @opindex ffold-simple-inlines
3278 @opindex fno-fold-simple-inlines
3279 Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3280 @code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3281 means no debug information will be generated for such calls. Since these
3282 functions are rarely interesting to debug, this flag is enabled by default
3283 unless @option{-fno-inline} is active.
3285 @item -fno-gnu-keywords
3286 @opindex fno-gnu-keywords
3287 @opindex fgnu-keywords
3288 Do not recognize @code{typeof} as a keyword, so that code can use this
3289 word as an identifier. You can use the keyword @code{__typeof__} instead.
3290 This option is implied by the strict ISO C++ dialects: @option{-ansi},
3291 @option{-std=c++98}, @option{-std=c++11}, etc.
3293 @item -fimplicit-constexpr
3294 @opindex fimplicit-constexpr
3295 Make inline functions implicitly constexpr, if they satisfy the
3296 requirements for a constexpr function. This option can be used in
3297 C++14 mode or later. This can result in initialization changing from
3298 dynamic to static and other optimizations.
3300 @item -fno-implicit-templates
3301 @opindex fno-implicit-templates
3302 @opindex fimplicit-templates
3303 Never emit code for non-inline templates that are instantiated
3304 implicitly (i.e.@: by use); only emit code for explicit instantiations.
3305 If you use this option, you must take care to structure your code to
3306 include all the necessary explicit instantiations to avoid getting
3307 undefined symbols at link time.
3308 @xref{Template Instantiation}, for more information.
3310 @item -fno-implicit-inline-templates
3311 @opindex fno-implicit-inline-templates
3312 @opindex fimplicit-inline-templates
3313 Don't emit code for implicit instantiations of inline templates, either.
3314 The default is to handle inlines differently so that compiles with and
3315 without optimization need the same set of explicit instantiations.
3317 @item -fno-implement-inlines
3318 @opindex fno-implement-inlines
3319 @opindex fimplement-inlines
3320 To save space, do not emit out-of-line copies of inline functions
3321 controlled by @code{#pragma implementation}. This causes linker
3322 errors if these functions are not inlined everywhere they are called.
3325 @itemx -fno-modules-ts
3326 @opindex fmodules-ts
3327 @opindex fno-modules-ts
3328 Enable support for C++20 modules (@pxref{C++ Modules}). The
3329 @option{-fno-modules-ts} is usually not needed, as that is the
3330 default. Even though this is a C++20 feature, it is not currently
3331 implicitly enabled by selecting that standard version.
3333 @item -fmodule-header
3334 @itemx -fmodule-header=user
3335 @itemx -fmodule-header=system
3336 @opindex fmodule-header
3337 Compile a header file to create an importable header unit.
3339 @item -fmodule-implicit-inline
3340 @opindex fmodule-implicit-inline
3341 Member functions defined in their class definitions are not implicitly
3342 inline for modular code. This is different to traditional C++
3343 behavior, for good reasons. However, it may result in a difficulty
3344 during code porting. This option makes such function definitions
3345 implicitly inline. It does however generate an ABI incompatibility,
3346 so you must use it everywhere or nowhere. (Such definitions outside
3347 of a named module remain implicitly inline, regardless.)
3349 @item -fno-module-lazy
3350 @opindex fno-module-lazy
3351 @opindex fmodule-lazy
3352 Disable lazy module importing and module mapper creation.
3354 @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3355 @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3356 @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3357 @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3358 @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3359 @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
3360 @vindex CXX_MODULE_MAPPER @r{environment variable}
3361 @opindex fmodule-mapper
3362 An oracle to query for module name to filename mappings. If
3363 unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3364 and if that is unset, an in-process default is provided.
3367 @opindex fmodule-only
3368 Only emit the Compiled Module Interface, inhibiting any object file.
3370 @item -fms-extensions
3371 @opindex fms-extensions
3372 Disable Wpedantic warnings about constructs used in MFC, such as implicit
3373 int and getting a pointer to member function via non-standard syntax.
3375 @item -fnew-inheriting-ctors
3376 @opindex fnew-inheriting-ctors
3377 Enable the P0136 adjustment to the semantics of C++11 constructor
3378 inheritance. This is part of C++17 but also considered to be a Defect
3379 Report against C++11 and C++14. This flag is enabled by default
3380 unless @option{-fabi-version=10} or lower is specified.
3382 @item -fnew-ttp-matching
3383 @opindex fnew-ttp-matching
3384 Enable the P0522 resolution to Core issue 150, template template
3385 parameters and default arguments: this allows a template with default
3386 template arguments as an argument for a template template parameter
3387 with fewer template parameters. This flag is enabled by default for
3388 @option{-std=c++17}.
3390 @item -fno-nonansi-builtins
3391 @opindex fno-nonansi-builtins
3392 @opindex fnonansi-builtins
3393 Disable built-in declarations of functions that are not mandated by
3394 ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3395 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
3398 @opindex fnothrow-opt
3399 Treat a @code{throw()} exception specification as if it were a
3400 @code{noexcept} specification to reduce or eliminate the text size
3401 overhead relative to a function with no exception specification. If
3402 the function has local variables of types with non-trivial
3403 destructors, the exception specification actually makes the
3404 function smaller because the EH cleanups for those variables can be
3405 optimized away. The semantic effect is that an exception thrown out of
3406 a function with such an exception specification results in a call
3407 to @code{terminate} rather than @code{unexpected}.
3409 @item -fno-operator-names
3410 @opindex fno-operator-names
3411 @opindex foperator-names
3412 Do not treat the operator name keywords @code{and}, @code{bitand},
3413 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3414 synonyms as keywords.
3416 @item -fno-optional-diags
3417 @opindex fno-optional-diags
3418 @opindex foptional-diags
3419 Disable diagnostics that the standard says a compiler does not need to
3420 issue. Currently, the only such diagnostic issued by G++ is the one for
3421 a name having multiple meanings within a class.
3424 @opindex fpermissive
3425 Downgrade some diagnostics about nonconformant code from errors to
3426 warnings. Thus, using @option{-fpermissive} allows some
3427 nonconforming code to compile.
3429 @item -fno-pretty-templates
3430 @opindex fno-pretty-templates
3431 @opindex fpretty-templates
3432 When an error message refers to a specialization of a function
3433 template, the compiler normally prints the signature of the
3434 template followed by the template arguments and any typedefs or
3435 typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3436 rather than @code{void f(int)}) so that it's clear which template is
3437 involved. When an error message refers to a specialization of a class
3438 template, the compiler omits any template arguments that match
3439 the default template arguments for that template. If either of these
3440 behaviors make it harder to understand the error message rather than
3441 easier, you can use @option{-fno-pretty-templates} to disable them.
3446 Disable generation of information about every class with virtual
3447 functions for use by the C++ run-time type identification features
3448 (@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3449 of the language, you can save some space by using this flag. Note that
3450 exception handling uses the same information, but G++ generates it as
3451 needed. The @code{dynamic_cast} operator can still be used for casts that
3452 do not require run-time type information, i.e.@: casts to @code{void *} or to
3453 unambiguous base classes.
3455 Mixing code compiled with @option{-frtti} with that compiled with
3456 @option{-fno-rtti} may not work. For example, programs may
3457 fail to link if a class compiled with @option{-fno-rtti} is used as a base
3458 for a class compiled with @option{-frtti}.
3460 @item -fsized-deallocation
3461 @opindex fsized-deallocation
3462 Enable the built-in global declarations
3464 void operator delete (void *, std::size_t) noexcept;
3465 void operator delete[] (void *, std::size_t) noexcept;
3467 as introduced in C++14. This is useful for user-defined replacement
3468 deallocation functions that, for example, use the size of the object
3469 to make deallocation faster. Enabled by default under
3470 @option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3471 warns about places that might want to add a definition.
3473 @item -fstrict-enums
3474 @opindex fstrict-enums
3475 Allow the compiler to optimize using the assumption that a value of
3476 enumerated type can only be one of the values of the enumeration (as
3477 defined in the C++ standard; basically, a value that can be
3478 represented in the minimum number of bits needed to represent all the
3479 enumerators). This assumption may not be valid if the program uses a
3480 cast to convert an arbitrary integer value to the enumerated type.
3482 @item -fstrong-eval-order
3483 @opindex fstrong-eval-order
3484 Evaluate member access, array subscripting, and shift expressions in
3485 left-to-right order, and evaluate assignment in right-to-left order,
3486 as adopted for C++17. Enabled by default with @option{-std=c++17}.
3487 @option{-fstrong-eval-order=some} enables just the ordering of member
3488 access and shift expressions, and is the default without
3489 @option{-std=c++17}.
3491 @item -ftemplate-backtrace-limit=@var{n}
3492 @opindex ftemplate-backtrace-limit
3493 Set the maximum number of template instantiation notes for a single
3494 warning or error to @var{n}. The default value is 10.
3496 @item -ftemplate-depth=@var{n}
3497 @opindex ftemplate-depth
3498 Set the maximum instantiation depth for template classes to @var{n}.
3499 A limit on the template instantiation depth is needed to detect
3500 endless recursions during template class instantiation. ANSI/ISO C++
3501 conforming programs must not rely on a maximum depth greater than 17
3502 (changed to 1024 in C++11). The default value is 900, as the compiler
3503 can run out of stack space before hitting 1024 in some situations.
3505 @item -fno-threadsafe-statics
3506 @opindex fno-threadsafe-statics
3507 @opindex fthreadsafe-statics
3508 Do not emit the extra code to use the routines specified in the C++
3509 ABI for thread-safe initialization of local statics. You can use this
3510 option to reduce code size slightly in code that doesn't need to be
3513 @item -fuse-cxa-atexit
3514 @opindex fuse-cxa-atexit
3515 Register destructors for objects with static storage duration with the
3516 @code{__cxa_atexit} function rather than the @code{atexit} function.
3517 This option is required for fully standards-compliant handling of static
3518 destructors, but only works if your C library supports
3519 @code{__cxa_atexit}.
3521 @item -fno-use-cxa-get-exception-ptr
3522 @opindex fno-use-cxa-get-exception-ptr
3523 @opindex fuse-cxa-get-exception-ptr
3524 Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3525 causes @code{std::uncaught_exception} to be incorrect, but is necessary
3526 if the runtime routine is not available.
3528 @item -fvisibility-inlines-hidden
3529 @opindex fvisibility-inlines-hidden
3530 This switch declares that the user does not attempt to compare
3531 pointers to inline functions or methods where the addresses of the two functions
3532 are taken in different shared objects.
3534 The effect of this is that GCC may, effectively, mark inline methods with
3535 @code{__attribute__ ((visibility ("hidden")))} so that they do not
3536 appear in the export table of a DSO and do not require a PLT indirection
3537 when used within the DSO@. Enabling this option can have a dramatic effect
3538 on load and link times of a DSO as it massively reduces the size of the
3539 dynamic export table when the library makes heavy use of templates.
3541 The behavior of this switch is not quite the same as marking the
3542 methods as hidden directly, because it does not affect static variables
3543 local to the function or cause the compiler to deduce that
3544 the function is defined in only one shared object.
3546 You may mark a method as having a visibility explicitly to negate the
3547 effect of the switch for that method. For example, if you do want to
3548 compare pointers to a particular inline method, you might mark it as
3549 having default visibility. Marking the enclosing class with explicit
3550 visibility has no effect.
3552 Explicitly instantiated inline methods are unaffected by this option
3553 as their linkage might otherwise cross a shared library boundary.
3554 @xref{Template Instantiation}.
3556 @item -fvisibility-ms-compat
3557 @opindex fvisibility-ms-compat
3558 This flag attempts to use visibility settings to make GCC's C++
3559 linkage model compatible with that of Microsoft Visual Studio.
3561 The flag makes these changes to GCC's linkage model:
3565 It sets the default visibility to @code{hidden}, like
3566 @option{-fvisibility=hidden}.
3569 Types, but not their members, are not hidden by default.
3572 The One Definition Rule is relaxed for types without explicit
3573 visibility specifications that are defined in more than one
3574 shared object: those declarations are permitted if they are
3575 permitted when this option is not used.
3578 In new code it is better to use @option{-fvisibility=hidden} and
3579 export those classes that are intended to be externally visible.
3580 Unfortunately it is possible for code to rely, perhaps accidentally,
3581 on the Visual Studio behavior.
3583 Among the consequences of these changes are that static data members
3584 of the same type with the same name but defined in different shared
3585 objects are different, so changing one does not change the other;
3586 and that pointers to function members defined in different shared
3587 objects may not compare equal. When this flag is given, it is a
3588 violation of the ODR to define types with the same name differently.
3593 Do not use weak symbol support, even if it is provided by the linker.
3594 By default, G++ uses weak symbols if they are available. This
3595 option exists only for testing, and should not be used by end-users;
3596 it results in inferior code and has no benefits. This option may
3597 be removed in a future release of G++.
3599 @item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
3600 @opindex fext-numeric-literals
3601 @opindex fno-ext-numeric-literals
3602 Accept imaginary, fixed-point, or machine-defined
3603 literal number suffixes as GNU extensions.
3604 When this option is turned off these suffixes are treated
3605 as C++11 user-defined literal numeric suffixes.
3606 This is on by default for all pre-C++11 dialects and all GNU dialects:
3607 @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3608 @option{-std=gnu++14}.
3609 This option is off by default
3610 for ISO C++11 onwards (@option{-std=c++11}, ...).
3614 Do not search for header files in the standard directories specific to
3615 C++, but do still search the other standard directories. (This option
3616 is used when building the C++ library.)
3618 @item -flang-info-include-translate
3619 @itemx -flang-info-include-translate-not
3620 @itemx -flang-info-include-translate=@var{header}
3621 @opindex flang-info-include-translate
3622 @opindex flang-info-include-translate-not
3623 Inform of include translation events. The first will note accepted
3624 include translations, the second will note declined include
3625 translations. The @var{header} form will inform of include
3626 translations relating to that specific header. If @var{header} is of
3627 the form @code{"user"} or @code{<system>} it will be resolved to a
3628 specific user or system header using the include path.
3630 @item -flang-info-module-cmi
3631 @itemx -flang-info-module-cmi=@var{module}
3632 @opindex flang-info-module-cmi
3633 Inform of Compiled Module Interface pathnames. The first will note
3634 all read CMI pathnames. The @var{module} form will not reading a
3635 specific module's CMI. @var{module} may be a named module or a
3636 header-unit (the latter indicated by either being a pathname containing
3637 directory separators or enclosed in @code{<>} or @code{""}).
3639 @item -stdlib=@var{libstdc++,libc++}
3641 When G++ is configured to support this option, it allows specification of
3642 alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3643 (the default, native C++ runtime for G++) and @var{libc++} which is the
3644 C++ runtime installed on some operating systems (e.g. Darwin versions from
3645 Darwin11 onwards). The option switches G++ to use the headers from the
3646 specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3647 when a C++ runtime is required for linking.
3650 In addition, these warning options have meanings only for C++ programs:
3653 @item -Wabi-tag @r{(C++ and Objective-C++ only)}
3655 Warn when a type with an ABI tag is used in a context that does not
3656 have that ABI tag. See @ref{C++ Attributes} for more information
3659 @item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
3660 @opindex Wcomma-subscript
3661 @opindex Wno-comma-subscript
3662 Warn about uses of a comma expression within a subscripting expression.
3663 This usage was deprecated in C++20 and is going to be removed in C++23.
3664 However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3668 void f(int *a, int b, int c) @{
3669 a[b,c]; // deprecated in C++20, invalid in C++23
3675 In C++23 it is valid to have comma separated expressions in a subscript
3676 when an overloaded subscript operator is found and supports the right
3677 number and types of arguments. G++ will accept the formerly valid syntax
3678 for code that is not valid in C++23 but used to be valid but deprecated
3679 in C++20 with a pedantic warning that can be disabled with
3680 @option{-Wno-comma-subscript}.
3682 Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3683 and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3685 @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
3686 @opindex Wctad-maybe-unsupported
3687 @opindex Wno-ctad-maybe-unsupported
3688 Warn when performing class template argument deduction (CTAD) on a type with
3689 no explicitly written deduction guides. This warning will point out cases
3690 where CTAD succeeded only because the compiler synthesized the implicit
3691 deduction guides, which might not be what the programmer intended. Certain
3692 style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3693 types that are designed to support CTAD. This warning can be suppressed with
3694 the following pattern:
3697 struct allow_ctad_t; // any name works
3698 template <typename T> struct S @{
3701 S(allow_ctad_t) -> S<void>; // guide with incomplete parameter type will never be considered
3704 @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
3705 @opindex Wctor-dtor-privacy
3706 @opindex Wno-ctor-dtor-privacy
3707 Warn when a class seems unusable because all the constructors or
3708 destructors in that class are private, and it has neither friends nor
3709 public static member functions. Also warn if there are no non-private
3710 methods, and there's at least one private member function that isn't
3711 a constructor or destructor.
3713 @item -Wdangling-reference @r{(C++ and Objective-C++ only)}
3714 @opindex Wdangling-reference
3715 @opindex Wno-dangling-reference
3716 Warn when a reference is bound to a temporary whose lifetime has ended.
3721 const int& r = std::max(n - 1, n + 1); // r is dangling
3724 In the example above, two temporaries are created, one for each
3725 argument, and a reference to one of the temporaries is returned.
3726 However, both temporaries are destroyed at the end of the full
3727 expression, so the reference @code{r} is dangling. This warning
3728 also detects dangling references in member initializer lists:
3731 const int& f(const int& i) @{ return i; @}
3733 const int &r; // r is dangling
3734 S() : r(f(10)) @{ @}
3738 Member functions are checked as well, but only their object argument:
3742 const S& self () @{ return *this; @}
3744 const S& s = S().self(); // s is dangling
3747 Certain functions are safe in this respect, for example @code{std::use_facet}:
3748 they take and return a reference, but they don't return one of its arguments,
3749 which can fool the warning. Such functions can be excluded from the warning
3750 by wrapping them in a @code{#pragma}:
3753 #pragma GCC diagnostic push
3754 #pragma GCC diagnostic ignored "-Wdangling-reference"
3755 const T& foo (const T&) @{ @dots{} @}
3756 #pragma GCC diagnostic pop
3759 @option{-Wdangling-reference} also warns about code like
3762 auto p = std::minmax(1, 2);
3765 where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3766 both references dangle after the end of the full expression that contains
3767 the call to @code{std::minmax}.
3769 This warning is enabled by @option{-Wall}.
3771 @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
3772 @opindex Wdelete-non-virtual-dtor
3773 @opindex Wno-delete-non-virtual-dtor
3774 Warn when @code{delete} is used to destroy an instance of a class that
3775 has virtual functions and non-virtual destructor. It is unsafe to delete
3776 an instance of a derived class through a pointer to a base class if the
3777 base class does not have a virtual destructor. This warning is enabled
3780 @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
3781 @opindex Wdeprecated-copy
3782 @opindex Wno-deprecated-copy
3783 Warn that the implicit declaration of a copy constructor or copy
3784 assignment operator is deprecated if the class has a user-provided
3785 copy constructor or copy assignment operator, in C++11 and up. This
3786 warning is enabled by @option{-Wextra}. With
3787 @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3788 user-provided destructor.
3790 @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
3791 @opindex Wdeprecated-enum-enum-conversion
3792 @opindex Wno-deprecated-enum-enum-conversion
3793 Disable the warning about the case when the usual arithmetic conversions
3794 are applied on operands where one is of enumeration type and the other is
3795 of a different enumeration type. This conversion was deprecated in C++20.
3804 @option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3805 @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3806 by @option{-Wenum-conversion}.
3808 @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
3809 @opindex Wdeprecated-enum-float-conversion
3810 @opindex Wno-deprecated-enum-float-conversion
3811 Disable the warning about the case when the usual arithmetic conversions
3812 are applied on operands where one is of enumeration type and the other is
3813 of a floating-point type. This conversion was deprecated in C++20. For
3822 @option{-Wdeprecated-enum-float-conversion} is enabled by default with
3823 @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3824 by @option{-Wenum-conversion}.
3826 @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
3827 @opindex Winit-list-lifetime
3828 @opindex Wno-init-list-lifetime
3829 Do not warn about uses of @code{std::initializer_list} that are likely
3830 to result in dangling pointers. Since the underlying array for an
3831 @code{initializer_list} is handled like a normal C++ temporary object,
3832 it is easy to inadvertently keep a pointer to the array past the end
3833 of the array's lifetime. For example:
3837 If a function returns a temporary @code{initializer_list}, or a local
3838 @code{initializer_list} variable, the array's lifetime ends at the end
3839 of the return statement, so the value returned has a dangling pointer.
3842 If a new-expression creates an @code{initializer_list}, the array only
3843 lives until the end of the enclosing full-expression, so the
3844 @code{initializer_list} in the heap has a dangling pointer.
3847 When an @code{initializer_list} variable is assigned from a
3848 brace-enclosed initializer list, the temporary array created for the
3849 right side of the assignment only lives until the end of the
3850 full-expression, so at the next statement the @code{initializer_list}
3851 variable has a dangling pointer.
3854 // li's initial underlying array lives as long as li
3855 std::initializer_list<int> li = @{ 1,2,3 @};
3856 // assignment changes li to point to a temporary array
3858 // now the temporary is gone and li has a dangling pointer
3859 int i = li.begin()[0] // undefined behavior
3863 When a list constructor stores the @code{begin} pointer from the
3864 @code{initializer_list} argument, this doesn't extend the lifetime of
3865 the array, so if a class variable is constructed from a temporary
3866 @code{initializer_list}, the pointer is left dangling by the end of
3867 the variable declaration statement.
3871 @item -Winvalid-constexpr
3872 @opindex Winvalid-constexpr
3873 @opindex Wno-invalid-constexpr
3875 Warn when a function never produces a constant expression. In C++20
3876 and earlier, for every @code{constexpr} function and function template,
3877 there must be at least one set of function arguments in at least one
3878 instantiation such that an invocation of the function or constructor
3879 could be an evaluated subexpression of a core constant expression.
3880 C++23 removed this restriction, so it's possible to have a function
3881 or a function template marked @code{constexpr} for which no invocation
3882 satisfies the requirements of a core constant expression.
3884 This warning is enabled as a pedantic warning by default in C++20 and
3885 earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3886 which case it will be an ordinary warning. For example:
3893 f(i); // warns by default in C++20, in C++23 only with -Winvalid-constexpr
3897 @item -Winvalid-imported-macros
3898 @opindex Winvalid-imported-macros
3899 @opindex Wno-invalid-imported-macros
3900 Verify all imported macro definitions are valid at the end of
3901 compilation. This is not enabled by default, as it requires
3902 additional processing to determine. It may be useful when preparing
3903 sets of header-units to ensure consistent macros.
3905 @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
3906 @opindex Wliteral-suffix
3907 @opindex Wno-literal-suffix
3908 Do not warn when a string or character literal is followed by a
3909 ud-suffix which does not begin with an underscore. As a conforming
3910 extension, GCC treats such suffixes as separate preprocessing tokens
3911 in order to maintain backwards compatibility with code that uses
3912 formatting macros from @code{<inttypes.h>}. For example:
3915 #define __STDC_FORMAT_MACROS
3916 #include <inttypes.h>
3921 printf("My int64: %" PRId64"\n", i64);
3925 In this case, @code{PRId64} is treated as a separate preprocessing token.
3927 This option also controls warnings when a user-defined literal
3928 operator is declared with a literal suffix identifier that doesn't
3929 begin with an underscore. Literal suffix identifiers that don't begin
3930 with an underscore are reserved for future standardization.
3932 These warnings are enabled by default.
3934 @item -Wno-narrowing @r{(C++ and Objective-C++ only)}
3936 @opindex Wno-narrowing
3937 For C++11 and later standards, narrowing conversions are diagnosed by default,
3938 as required by the standard. A narrowing conversion from a constant produces
3939 an error, and a narrowing conversion from a non-constant produces a warning,
3940 but @option{-Wno-narrowing} suppresses the diagnostic.
3941 Note that this does not affect the meaning of well-formed code;
3942 narrowing conversions are still considered ill-formed in SFINAE contexts.
3944 With @option{-Wnarrowing} in C++98, warn when a narrowing
3945 conversion prohibited by C++11 occurs within
3949 int i = @{ 2.2 @}; // error: narrowing from double to int
3952 This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
3954 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
3956 @opindex Wno-noexcept
3957 Warn when a noexcept-expression evaluates to false because of a call
3958 to a function that does not have a non-throwing exception
3959 specification (i.e. @code{throw()} or @code{noexcept}) but is known by
3960 the compiler to never throw an exception.
3962 @item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
3963 @opindex Wnoexcept-type
3964 @opindex Wno-noexcept-type
3965 Warn if the C++17 feature making @code{noexcept} part of a function
3966 type changes the mangled name of a symbol relative to C++14. Enabled
3967 by @option{-Wabi} and @option{-Wc++17-compat}.
3972 template <class T> void f(T t) @{ t(); @};
3974 void h() @{ f(g); @}
3978 In C++14, @code{f} calls @code{f<void(*)()>}, but in
3979 C++17 it calls @code{f<void(*)()noexcept>}.
3981 @item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
3982 @opindex Wclass-memaccess
3983 @opindex Wno-class-memaccess
3984 Warn when the destination of a call to a raw memory function such as
3985 @code{memset} or @code{memcpy} is an object of class type, and when writing
3986 into such an object might bypass the class non-trivial or deleted constructor
3987 or copy assignment, violate const-correctness or encapsulation, or corrupt
3988 virtual table pointers. Modifying the representation of such objects may
3989 violate invariants maintained by member functions of the class. For example,
3990 the call to @code{memset} below is undefined because it modifies a non-trivial
3991 class object and is, therefore, diagnosed. The safe way to either initialize
3992 or clear the storage of objects of such types is by using the appropriate
3993 constructor or assignment operator, if one is available.
3995 std::string str = "abc";
3996 memset (&str, 0, sizeof str);
3998 The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
3999 Explicitly casting the pointer to the class object to @code{void *} or
4000 to a type that can be safely accessed by the raw memory function suppresses
4003 @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
4004 @opindex Wnon-virtual-dtor
4005 @opindex Wno-non-virtual-dtor
4006 Warn when a class has virtual functions and an accessible non-virtual
4007 destructor itself or in an accessible polymorphic base class, in which
4008 case it is possible but unsafe to delete an instance of a derived
4009 class through a pointer to the class itself or base class. This
4010 warning is automatically enabled if @option{-Weffc++} is specified.
4011 The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4012 should be preferred because it warns about the unsafe cases without false
4015 @item -Wregister @r{(C++ and Objective-C++ only)}
4017 @opindex Wno-register
4018 Warn on uses of the @code{register} storage class specifier, except
4019 when it is part of the GNU @ref{Explicit Register Variables} extension.
4020 The use of the @code{register} keyword as storage class specifier has
4021 been deprecated in C++11 and removed in C++17.
4022 Enabled by default with @option{-std=c++17}.
4024 @item -Wreorder @r{(C++ and Objective-C++ only)}
4026 @opindex Wno-reorder
4027 @cindex reordering, warning
4028 @cindex warning for reordering of member initializers
4029 Warn when the order of member initializers given in the code does not
4030 match the order in which they must be executed. For instance:
4036 A(): j (0), i (1) @{ @}
4041 The compiler rearranges the member initializers for @code{i}
4042 and @code{j} to match the declaration order of the members, emitting
4043 a warning to that effect. This warning is enabled by @option{-Wall}.
4045 @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
4046 @opindex Wpessimizing-move
4047 @opindex Wno-pessimizing-move
4048 This warning warns when a call to @code{std::move} prevents copy
4049 elision. A typical scenario when copy elision can occur is when returning in
4050 a function with a class return type, when the expression being returned is the
4051 name of a non-volatile automatic object, and is not a function parameter, and
4052 has the same type as the function return type.
4062 return std::move (t);
4066 But in this example, the @code{std::move} call prevents copy elision.
4068 This warning is enabled by @option{-Wall}.
4070 @item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
4071 @opindex Wredundant-move
4072 @opindex Wno-redundant-move
4073 This warning warns about redundant calls to @code{std::move}; that is, when
4074 a move operation would have been performed even without the @code{std::move}
4075 call. This happens because the compiler is forced to treat the object as if
4076 it were an rvalue in certain situations such as returning a local variable,
4077 where copy elision isn't applicable. Consider:
4086 return std::move (t);
4090 Here, the @code{std::move} call is redundant. Because G++ implements Core
4091 Issue 1579, another example is:
4094 struct T @{ // convertible to U
4104 return std::move (t);
4107 In this example, copy elision isn't applicable because the type of the
4108 expression being returned and the function return type differ, yet G++
4109 treats the return value as if it were designated by an rvalue.
4111 This warning is enabled by @option{-Wextra}.
4113 @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
4114 @opindex Wrange-loop-construct
4115 @opindex Wno-range-loop-construct
4116 This warning warns when a C++ range-based for-loop is creating an unnecessary
4117 copy. This can happen when the range declaration is not a reference, but
4118 probably should be. For example:
4121 struct S @{ char arr[128]; @};
4124 for (const auto x : arr) @{ @dots{} @}
4128 It does not warn when the type being copied is a trivially-copyable type whose
4129 size is less than 64 bytes.
4131 This warning also warns when a loop variable in a range-based for-loop is
4132 initialized with a value of a different type resulting in a copy. For example:
4137 for (const double &x : arr) @{ @dots{} @}
4141 In the example above, in every iteration of the loop a temporary value of
4142 type @code{double} is created and destroyed, to which the reference
4143 @code{const double &} is bound.
4145 This warning is enabled by @option{-Wall}.
4147 @item -Wredundant-tags @r{(C++ and Objective-C++ only)}
4148 @opindex Wredundant-tags
4149 @opindex Wno-redundant-tags
4150 Warn about redundant class-key and enum-key in references to class types
4151 and enumerated types in contexts where the key can be eliminated without
4152 causing an ambiguity. For example:
4156 struct foo *p; // warn that keyword struct can be eliminated
4160 On the other hand, in this example there is no warning:
4164 void foo (); // "hides" struct foo
4165 void bar (struct foo&); // no warning, keyword struct is necessary
4168 @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
4169 @opindex Wsubobject-linkage
4170 @opindex Wno-subobject-linkage
4172 if a class type has a base or a field whose type uses the anonymous
4173 namespace or depends on a type with no linkage. If a type A depends on
4174 a type B with no or internal linkage, defining it in multiple
4175 translation units would be an ODR violation because the meaning of B
4176 is different in each translation unit. If A only appears in a single
4177 translation unit, the best way to silence the warning is to give it
4178 internal linkage by putting it in an anonymous namespace as well. The
4179 compiler doesn't give this warning for types defined in the main .C
4180 file, as those are unlikely to have multiple definitions.
4181 @option{-Wsubobject-linkage} is enabled by default.
4183 @item -Weffc++ @r{(C++ and Objective-C++ only)}
4186 Warn about violations of the following style guidelines from Scott Meyers'
4187 @cite{Effective C++} series of books:
4191 Define a copy constructor and an assignment operator for classes
4192 with dynamically-allocated memory.
4195 Prefer initialization to assignment in constructors.
4198 Have @code{operator=} return a reference to @code{*this}.
4201 Don't try to return a reference when you must return an object.
4204 Distinguish between prefix and postfix forms of increment and
4205 decrement operators.
4208 Never overload @code{&&}, @code{||}, or @code{,}.
4212 This option also enables @option{-Wnon-virtual-dtor}, which is also
4213 one of the effective C++ recommendations. However, the check is
4214 extended to warn about the lack of virtual destructor in accessible
4215 non-polymorphic bases classes too.
4217 When selecting this option, be aware that the standard library
4218 headers do not obey all of these guidelines; use @samp{grep -v}
4219 to filter out those warnings.
4221 @item -Wno-exceptions @r{(C++ and Objective-C++ only)}
4222 @opindex Wexceptions
4223 @opindex Wno-exceptions
4224 Disable the warning about the case when an exception handler is shadowed by
4225 another handler, which can point out a wrong ordering of exception handlers.
4227 @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
4228 @opindex Wstrict-null-sentinel
4229 @opindex Wno-strict-null-sentinel
4230 Warn about the use of an uncasted @code{NULL} as sentinel. When
4231 compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4232 to @code{__null}. Although it is a null pointer constant rather than a
4233 null pointer, it is guaranteed to be of the same size as a pointer.
4234 But this use is not portable across different compilers.
4236 @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
4237 @opindex Wno-non-template-friend
4238 @opindex Wnon-template-friend
4239 Disable warnings when non-template friend functions are declared
4240 within a template. In very old versions of GCC that predate implementation
4241 of the ISO standard, declarations such as
4242 @samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4243 could be interpreted as a particular specialization of a template
4244 function; the warning exists to diagnose compatibility problems,
4245 and is enabled by default.
4247 @item -Wold-style-cast @r{(C++ and Objective-C++ only)}
4248 @opindex Wold-style-cast
4249 @opindex Wno-old-style-cast
4250 Warn if an old-style (C-style) cast to a non-void type is used within
4251 a C++ program. The new-style casts (@code{dynamic_cast},
4252 @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4253 less vulnerable to unintended effects and much easier to search for.
4255 @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4256 @itemx -Woverloaded-virtual=@var{n}
4257 @opindex Woverloaded-virtual
4258 @opindex Wno-overloaded-virtual
4259 @cindex overloaded virtual function, warning
4260 @cindex warning for overloaded virtual function
4261 Warn when a function declaration hides virtual functions from a
4262 base class. For example, in:
4269 struct B: public A @{
4270 void f(int); // does not override
4274 the @code{A} class version of @code{f} is hidden in @code{B}, and code
4285 In cases where the different signatures are not an accident, the
4286 simplest solution is to add a using-declaration to the derived class
4287 to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4289 The optional level suffix controls the behavior when all the
4290 declarations in the derived class override virtual functions in the
4291 base class, even if not all of the base functions are overridden:
4296 virtual void f(int);
4299 struct D: public C @{
4300 void f(int); // does override
4304 This pattern is less likely to be a mistake; if D is only used
4305 virtually, the user might have decided that the base class semantics
4306 for some of the overloads are fine.
4308 At level 1, this case does not warn; at level 2, it does.
4309 @option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4310 included in @option{-Wall}.
4312 @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
4313 @opindex Wno-pmf-conversions
4314 @opindex Wpmf-conversions
4315 Disable the diagnostic for converting a bound pointer to member function
4318 @item -Wsign-promo @r{(C++ and Objective-C++ only)}
4319 @opindex Wsign-promo
4320 @opindex Wno-sign-promo
4321 Warn when overload resolution chooses a promotion from unsigned or
4322 enumerated type to a signed type, over a conversion to an unsigned type of
4323 the same size. Previous versions of G++ tried to preserve
4324 unsignedness, but the standard mandates the current behavior.
4326 @item -Wtemplates @r{(C++ and Objective-C++ only)}
4328 @opindex Wno-templates
4329 Warn when a primary template declaration is encountered. Some coding
4330 rules disallow templates, and this may be used to enforce that rule.
4331 The warning is inactive inside a system header file, such as the STL, so
4332 one can still use the STL. One may also instantiate or specialize
4335 @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
4336 @opindex Wmismatched-new-delete
4337 @opindex Wno-mismatched-new-delete
4338 Warn for mismatches between calls to @code{operator new} or @code{operator
4339 delete} and the corresponding call to the allocation or deallocation function.
4340 This includes invocations of C++ @code{operator delete} with pointers
4341 returned from either mismatched forms of @code{operator new}, or from other
4342 functions that allocate objects for which the @code{operator delete} isn't
4343 a suitable deallocator, as well as calls to other deallocation functions
4344 with pointers returned from @code{operator new} for which the deallocation
4345 function isn't suitable.
4347 For example, the @code{delete} expression in the function below is diagnosed
4348 because it doesn't match the array form of the @code{new} expression
4349 the pointer argument was returned from. Similarly, the call to @code{free}
4355 int *a = new int[n];
4356 delete a; // warning: mismatch in array forms of expressions
4358 char *p = new char[n];
4359 free (p); // warning: mismatch between new and free
4363 The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4364 involving allocation and deallocation functions other than @code{operator
4365 new} and @code{operator delete}.
4367 @option{-Wmismatched-new-delete} is included in @option{-Wall}.
4369 @item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
4370 @opindex Wmismatched-tags
4371 @opindex Wno-mismatched-tags
4372 Warn for declarations of structs, classes, and class templates and their
4373 specializations with a class-key that does not match either the definition
4374 or the first declaration if no definition is provided.
4376 For example, the declaration of @code{struct Object} in the argument list
4377 of @code{draw} triggers the warning. To avoid it, either remove the redundant
4378 class-key @code{struct} or replace it with @code{class} to match its definition.
4382 virtual ~Object () = 0;
4384 void draw (struct Object*);
4387 It is not wrong to declare a class with the class-key @code{struct} as
4388 the example above shows. The @option{-Wmismatched-tags} option is intended
4389 to help achieve a consistent style of class declarations. In code that is
4390 intended to be portable to Windows-based compilers the warning helps prevent
4391 unresolved references due to the difference in the mangling of symbols
4392 declared with different class-keys. The option can be used either on its
4393 own or in conjunction with @option{-Wredundant-tags}.
4395 @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
4396 @opindex Wmultiple-inheritance
4397 @opindex Wno-multiple-inheritance
4398 Warn when a class is defined with multiple direct base classes. Some
4399 coding rules disallow multiple inheritance, and this may be used to
4400 enforce that rule. The warning is inactive inside a system header file,
4401 such as the STL, so one can still use the STL. One may also define
4402 classes that indirectly use multiple inheritance.
4404 @item -Wvirtual-inheritance
4405 @opindex Wvirtual-inheritance
4406 @opindex Wno-virtual-inheritance
4407 Warn when a class is defined with a virtual direct base class. Some
4408 coding rules disallow multiple inheritance, and this may be used to
4409 enforce that rule. The warning is inactive inside a system header file,
4410 such as the STL, so one can still use the STL. One may also define
4411 classes that indirectly use virtual inheritance.
4413 @item -Wno-virtual-move-assign
4414 @opindex Wvirtual-move-assign
4415 @opindex Wno-virtual-move-assign
4416 Suppress warnings about inheriting from a virtual base with a
4417 non-trivial C++11 move assignment operator. This is dangerous because
4418 if the virtual base is reachable along more than one path, it is
4419 moved multiple times, which can mean both objects end up in the
4420 moved-from state. If the move assignment operator is written to avoid
4421 moving from a moved-from object, this warning can be disabled.
4424 @opindex Wnamespaces
4425 @opindex Wno-namespaces
4426 Warn when a namespace definition is opened. Some coding rules disallow
4427 namespaces, and this may be used to enforce that rule. The warning is
4428 inactive inside a system header file, such as the STL, so one can still
4429 use the STL. One may also use using directives and qualified names.
4431 @item -Wno-terminate @r{(C++ and Objective-C++ only)}
4433 @opindex Wno-terminate
4434 Disable the warning about a throw-expression that will immediately
4435 result in a call to @code{terminate}.
4437 @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
4438 @opindex Wvexing-parse
4439 @opindex Wno-vexing-parse
4440 Warn about the most vexing parse syntactic ambiguity. This warns about
4441 the cases when a declaration looks like a variable definition, but the
4442 C++ language requires it to be interpreted as a function declaration.
4447 int i(); // extern int i (void);
4448 int n(int(a)); // extern int n (int);
4455 struct S @{ S(int); @};
4457 S x(int(a)); // extern struct S x (int);
4458 S y(int()); // extern struct S y (int (*) (void));
4459 S z(); // extern struct S z (void);
4463 The warning will suggest options how to deal with such an ambiguity; e.g.,
4464 it can suggest removing the parentheses or using braces instead.
4466 This warning is enabled by default.
4468 @item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
4469 @opindex Wno-class-conversion
4470 @opindex Wclass-conversion
4471 Do not warn when a conversion function converts an
4472 object to the same type, to a base class of that type, or to void; such
4473 a conversion function will never be called.
4475 @item -Wvolatile @r{(C++ and Objective-C++ only)}
4477 @opindex Wno-volatile
4478 Warn about deprecated uses of the @code{volatile} qualifier. This includes
4479 postfix and prefix @code{++} and @code{--} expressions of
4480 @code{volatile}-qualified types, using simple assignments where the left
4481 operand is a @code{volatile}-qualified non-class type for their value,
4482 compound assignments where the left operand is a @code{volatile}-qualified
4483 non-class type, @code{volatile}-qualified function return type,
4484 @code{volatile}-qualified parameter type, and structured bindings of a
4485 @code{volatile}-qualified type. This usage was deprecated in C++20.
4487 Enabled by default with @option{-std=c++20}.
4489 @item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
4490 @opindex Wzero-as-null-pointer-constant
4491 @opindex Wno-zero-as-null-pointer-constant
4492 Warn when a literal @samp{0} is used as null pointer constant. This can
4493 be useful to facilitate the conversion to @code{nullptr} in C++11.
4496 @opindex Waligned-new
4497 @opindex Wno-aligned-new
4498 Warn about a new-expression of a type that requires greater alignment
4499 than the @code{alignof(std::max_align_t)} but uses an allocation
4500 function without an explicit alignment parameter. This option is
4501 enabled by @option{-Wall}.
4503 Normally this only warns about global allocation functions, but
4504 @option{-Waligned-new=all} also warns about class member allocation
4507 @item -Wno-placement-new
4508 @itemx -Wplacement-new=@var{n}
4509 @opindex Wplacement-new
4510 @opindex Wno-placement-new
4511 Warn about placement new expressions with undefined behavior, such as
4512 constructing an object in a buffer that is smaller than the type of
4513 the object. For example, the placement new expression below is diagnosed
4514 because it attempts to construct an array of 64 integers in a buffer only
4520 This warning is enabled by default.
4523 @item -Wplacement-new=1
4524 This is the default warning level of @option{-Wplacement-new}. At this
4525 level the warning is not issued for some strictly undefined constructs that
4526 GCC allows as extensions for compatibility with legacy code. For example,
4527 the following @code{new} expression is not diagnosed at this level even
4528 though it has undefined behavior according to the C++ standard because
4529 it writes past the end of the one-element array.
4531 struct S @{ int n, a[1]; @};
4532 S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4533 new (s->a)int [32]();
4536 @item -Wplacement-new=2
4537 At this level, in addition to diagnosing all the same constructs as at level
4538 1, a diagnostic is also issued for placement new expressions that construct
4539 an object in the last member of structure whose type is an array of a single
4540 element and whose size is less than the size of the object being constructed.
4541 While the previous example would be diagnosed, the following construct makes
4542 use of the flexible member array extension to avoid the warning at level 2.
4544 struct S @{ int n, a[]; @};
4545 S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4546 new (s->a)int [32]();
4552 @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
4553 @opindex Wcatch-value
4554 @opindex Wno-catch-value
4555 Warn about catch handlers that do not catch via reference.
4556 With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4557 warn about polymorphic class types that are caught by value.
4558 With @option{-Wcatch-value=2} warn about all class types that are caught
4559 by value. With @option{-Wcatch-value=3} warn about all types that are
4560 not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4562 @item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
4563 @opindex Wconditionally-supported
4564 @opindex Wno-conditionally-supported
4565 Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4567 @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
4568 @opindex Wdelete-incomplete
4569 @opindex Wno-delete-incomplete
4570 Do not warn when deleting a pointer to incomplete type, which may cause
4571 undefined behavior at runtime. This warning is enabled by default.
4573 @item -Wextra-semi @r{(C++, Objective-C++ only)}
4574 @opindex Wextra-semi
4575 @opindex Wno-extra-semi
4576 Warn about redundant semicolons after in-class function definitions.
4578 @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
4579 @opindex Winaccessible-base
4580 @opindex Wno-inaccessible-base
4581 This option controls warnings
4582 when a base class is inaccessible in a class derived from it due to
4583 ambiguity. The warning is enabled by default.
4584 Note that the warning for ambiguous virtual
4585 bases is enabled by the @option{-Wextra} option.
4588 struct A @{ int a; @};
4592 struct C : B, A @{ @};
4596 @item -Wno-inherited-variadic-ctor
4597 @opindex Winherited-variadic-ctor
4598 @opindex Wno-inherited-variadic-ctor
4599 Suppress warnings about use of C++11 inheriting constructors when the
4600 base class inherited from has a C variadic constructor; the warning is
4601 on by default because the ellipsis is not inherited.
4603 @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
4604 @opindex Wno-invalid-offsetof
4605 @opindex Winvalid-offsetof
4606 Suppress warnings from applying the @code{offsetof} macro to a non-POD
4607 type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4608 to a non-standard-layout type is undefined. In existing C++ implementations,
4609 however, @code{offsetof} typically gives meaningful results.
4610 This flag is for users who are aware that they are
4611 writing nonportable code and who have deliberately chosen to ignore the
4614 The restrictions on @code{offsetof} may be relaxed in a future version
4615 of the C++ standard.
4617 @item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
4618 @opindex Wsized-deallocation
4619 @opindex Wno-sized-deallocation
4620 Warn about a definition of an unsized deallocation function
4622 void operator delete (void *) noexcept;
4623 void operator delete[] (void *) noexcept;
4625 without a definition of the corresponding sized deallocation function
4627 void operator delete (void *, std::size_t) noexcept;
4628 void operator delete[] (void *, std::size_t) noexcept;
4630 or vice versa. Enabled by @option{-Wextra} along with
4631 @option{-fsized-deallocation}.
4633 @item -Wsuggest-final-types
4634 @opindex Wno-suggest-final-types
4635 @opindex Wsuggest-final-types
4636 Warn about types with virtual methods where code quality would be improved
4637 if the type were declared with the C++11 @code{final} specifier,
4639 declared in an anonymous namespace. This allows GCC to more aggressively
4640 devirtualize the polymorphic calls. This warning is more effective with
4641 link-time optimization,
4642 where the information about the class hierarchy graph is
4645 @item -Wsuggest-final-methods
4646 @opindex Wno-suggest-final-methods
4647 @opindex Wsuggest-final-methods
4648 Warn about virtual methods where code quality would be improved if the method
4649 were declared with the C++11 @code{final} specifier,
4650 or, if possible, its type were
4651 declared in an anonymous namespace or with the @code{final} specifier.
4653 more effective with link-time optimization, where the information about the
4654 class hierarchy graph is more complete. It is recommended to first consider
4655 suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4658 @item -Wsuggest-override
4659 @opindex Wsuggest-override
4660 @opindex Wno-suggest-override
4661 Warn about overriding virtual functions that are not marked with the
4662 @code{override} keyword.
4664 @item -Wuse-after-free
4665 @itemx -Wuse-after-free=@var{n}
4666 @opindex Wuse-after-free
4667 @opindex Wno-use-after-free
4668 Warn about uses of pointers to dynamically allocated objects that have
4669 been rendered indeterminate by a call to a deallocation function.
4670 The warning is enabled at all optimization levels but may yield different
4671 results with optimization than without.
4674 @item -Wuse-after-free=1
4675 At level 1 the warning attempts to diagnose only unconditional uses
4676 of pointers made indeterminate by a deallocation call or a successful
4677 call to @code{realloc}, regardless of whether or not the call resulted
4678 in an actual reallocatio of memory. This includes double-@code{free}
4679 calls as well as uses in arithmetic and relational expressions. Although
4680 undefined, uses of indeterminate pointers in equality (or inequality)
4681 expressions are not diagnosed at this level.
4682 @item -Wuse-after-free=2
4683 At level 2, in addition to unconditional uses, the warning also diagnoses
4684 conditional uses of pointers made indeterminate by a deallocation call.
4685 As at level 2, uses in equality (or inequality) expressions are not
4686 diagnosed. For example, the second call to @code{free} in the following
4687 function is diagnosed at this level:
4689 struct A @{ int refcount; void *data; @};
4691 void release (struct A *p)
4693 int refcount = --p->refcount;
4696 free (p->data); // warning: p may be used after free
4699 @item -Wuse-after-free=3
4700 At level 3, the warning also diagnoses uses of indeterminate pointers in
4701 equality expressions. All uses of indeterminate pointers are undefined
4702 but equality tests sometimes appear after calls to @code{realloc} as
4703 an attempt to determine whether the call resulted in relocating the object
4704 to a different address. They are diagnosed at a separate level to aid
4705 legacy code gradually transition to safe alternatives. For example,
4706 the equality test in the function below is diagnosed at this level:
4708 void adjust_pointers (int**, int);
4710 void grow (int **p, int n)
4712 int **q = (int**)realloc (p, n *= 2);
4715 adjust_pointers ((int**)q, n);
4718 To avoid the warning at this level, store offsets into allocated memory
4719 instead of pointers. This approach obviates needing to adjust the stored
4720 pointers after reallocation.
4723 @option{-Wuse-after-free=2} is included in @option{-Wall}.
4725 @item -Wuseless-cast @r{(C++ and Objective-C++ only)}
4726 @opindex Wuseless-cast
4727 @opindex Wno-useless-cast
4728 Warn when an expression is cast to its own type. This warning does not
4729 occur when a class object is converted to a non-reference type as that
4730 is a way to create a temporary:
4737 g (S(arg)); // make arg prvalue so that it can bind to S&&
4741 @item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
4742 @opindex Wconversion-null
4743 @opindex Wno-conversion-null
4744 Do not warn for conversions between @code{NULL} and non-pointer
4745 types. @option{-Wconversion-null} is enabled by default.
4749 @node Objective-C and Objective-C++ Dialect Options
4750 @section Options Controlling Objective-C and Objective-C++ Dialects
4752 @cindex compiler options, Objective-C and Objective-C++
4753 @cindex Objective-C and Objective-C++ options, command-line
4754 @cindex options, Objective-C and Objective-C++
4755 (NOTE: This manual does not describe the Objective-C and Objective-C++
4756 languages themselves. @xref{Standards,,Language Standards
4757 Supported by GCC}, for references.)
4759 This section describes the command-line options that are only meaningful
4760 for Objective-C and Objective-C++ programs. You can also use most of
4761 the language-independent GNU compiler options.
4762 For example, you might compile a file @file{some_class.m} like this:
4765 gcc -g -fgnu-runtime -O -c some_class.m
4769 In this example, @option{-fgnu-runtime} is an option meant only for
4770 Objective-C and Objective-C++ programs; you can use the other options with
4771 any language supported by GCC@.
4773 Note that since Objective-C is an extension of the C language, Objective-C
4774 compilations may also use options specific to the C front-end (e.g.,
4775 @option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4776 C++-specific options (e.g., @option{-Wabi}).
4778 Here is a list of options that are @emph{only} for compiling Objective-C
4779 and Objective-C++ programs:
4782 @item -fconstant-string-class=@var{class-name}
4783 @opindex fconstant-string-class
4784 Use @var{class-name} as the name of the class to instantiate for each
4785 literal string specified with the syntax @code{@@"@dots{}"}. The default
4786 class name is @code{NXConstantString} if the GNU runtime is being used, and
4787 @code{NSConstantString} if the NeXT runtime is being used (see below). The
4788 @option{-fconstant-cfstrings} option, if also present, overrides the
4789 @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
4790 to be laid out as constant CoreFoundation strings.
4793 @opindex fgnu-runtime
4794 Generate object code compatible with the standard GNU Objective-C
4795 runtime. This is the default for most types of systems.
4797 @item -fnext-runtime
4798 @opindex fnext-runtime
4799 Generate output compatible with the NeXT runtime. This is the default
4800 for NeXT-based systems, including Darwin and Mac OS X@. The macro
4801 @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4804 @item -fno-nil-receivers
4805 @opindex fno-nil-receivers
4806 @opindex fnil-receivers
4807 Assume that all Objective-C message dispatches (@code{[receiver
4808 message:arg]}) in this translation unit ensure that the receiver is
4809 not @code{nil}. This allows for more efficient entry points in the
4810 runtime to be used. This option is only available in conjunction with
4811 the NeXT runtime and ABI version 0 or 1.
4813 @item -fobjc-abi-version=@var{n}
4814 @opindex fobjc-abi-version
4815 Use version @var{n} of the Objective-C ABI for the selected runtime.
4816 This option is currently supported only for the NeXT runtime. In that
4817 case, Version 0 is the traditional (32-bit) ABI without support for
4818 properties and other Objective-C 2.0 additions. Version 1 is the
4819 traditional (32-bit) ABI with support for properties and other
4820 Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4821 nothing is specified, the default is Version 0 on 32-bit target
4822 machines, and Version 2 on 64-bit target machines.
4824 @item -fobjc-call-cxx-cdtors
4825 @opindex fobjc-call-cxx-cdtors
4826 For each Objective-C class, check if any of its instance variables is a
4827 C++ object with a non-trivial default constructor. If so, synthesize a
4828 special @code{- (id) .cxx_construct} instance method which runs
4829 non-trivial default constructors on any such instance variables, in order,
4830 and then return @code{self}. Similarly, check if any instance variable
4831 is a C++ object with a non-trivial destructor, and if so, synthesize a
4832 special @code{- (void) .cxx_destruct} method which runs
4833 all such default destructors, in reverse order.
4835 The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4836 methods thusly generated only operate on instance variables
4837 declared in the current Objective-C class, and not those inherited
4838 from superclasses. It is the responsibility of the Objective-C
4839 runtime to invoke all such methods in an object's inheritance
4840 hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4841 by the runtime immediately after a new object instance is allocated;
4842 the @code{- (void) .cxx_destruct} methods are invoked immediately
4843 before the runtime deallocates an object instance.
4845 As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4846 support for invoking the @code{- (id) .cxx_construct} and
4847 @code{- (void) .cxx_destruct} methods.
4849 @item -fobjc-direct-dispatch
4850 @opindex fobjc-direct-dispatch
4851 Allow fast jumps to the message dispatcher. On Darwin this is
4852 accomplished via the comm page.
4854 @item -fobjc-exceptions
4855 @opindex fobjc-exceptions
4856 Enable syntactic support for structured exception handling in
4857 Objective-C, similar to what is offered by C++. This option
4858 is required to use the Objective-C keywords @code{@@try},
4859 @code{@@throw}, @code{@@catch}, @code{@@finally} and
4860 @code{@@synchronized}. This option is available with both the GNU
4861 runtime and the NeXT runtime (but not available in conjunction with
4862 the NeXT runtime on Mac OS X 10.2 and earlier).
4866 Enable garbage collection (GC) in Objective-C and Objective-C++
4867 programs. This option is only available with the NeXT runtime; the
4868 GNU runtime has a different garbage collection implementation that
4869 does not require special compiler flags.
4871 @item -fobjc-nilcheck
4872 @opindex fobjc-nilcheck
4873 For the NeXT runtime with version 2 of the ABI, check for a nil
4874 receiver in method invocations before doing the actual method call.
4875 This is the default and can be disabled using
4876 @option{-fno-objc-nilcheck}. Class methods and super calls are never
4877 checked for nil in this way no matter what this flag is set to.
4878 Currently this flag does nothing when the GNU runtime, or an older
4879 version of the NeXT runtime ABI, is used.
4881 @item -fobjc-std=objc1
4883 Conform to the language syntax of Objective-C 1.0, the language
4884 recognized by GCC 4.0. This only affects the Objective-C additions to
4885 the C/C++ language; it does not affect conformance to C/C++ standards,
4886 which is controlled by the separate C/C++ dialect option flags. When
4887 this option is used with the Objective-C or Objective-C++ compiler,
4888 any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4889 This is useful if you need to make sure that your Objective-C code can
4890 be compiled with older versions of GCC@.
4892 @item -freplace-objc-classes
4893 @opindex freplace-objc-classes
4894 Emit a special marker instructing @command{ld(1)} not to statically link in
4895 the resulting object file, and allow @command{dyld(1)} to load it in at
4896 run time instead. This is used in conjunction with the Fix-and-Continue
4897 debugging mode, where the object file in question may be recompiled and
4898 dynamically reloaded in the course of program execution, without the need
4899 to restart the program itself. Currently, Fix-and-Continue functionality
4900 is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4905 When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4906 to @code{objc_getClass("@dots{}")} (when the name of the class is known at
4907 compile time) with static class references that get initialized at load time,
4908 which improves run-time performance. Specifying the @option{-fzero-link} flag
4909 suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
4910 to be retained. This is useful in Zero-Link debugging mode, since it allows
4911 for individual class implementations to be modified during program execution.
4912 The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
4913 regardless of command-line options.
4915 @item -fno-local-ivars
4916 @opindex fno-local-ivars
4917 @opindex flocal-ivars
4918 By default instance variables in Objective-C can be accessed as if
4919 they were local variables from within the methods of the class they're
4920 declared in. This can lead to shadowing between instance variables
4921 and other variables declared either locally inside a class method or
4922 globally with the same name. Specifying the @option{-fno-local-ivars}
4923 flag disables this behavior thus avoiding variable shadowing issues.
4925 @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
4926 @opindex fivar-visibility
4927 Set the default instance variable visibility to the specified option
4928 so that instance variables declared outside the scope of any access
4929 modifier directives default to the specified visibility.
4933 Dump interface declarations for all classes seen in the source file to a
4934 file named @file{@var{sourcename}.decl}.
4936 @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
4937 @opindex Wassign-intercept
4938 @opindex Wno-assign-intercept
4939 Warn whenever an Objective-C assignment is being intercepted by the
4942 @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
4943 @opindex Wproperty-assign-default
4944 @opindex Wno-property-assign-default
4945 Do not warn if a property for an Objective-C object has no assign
4946 semantics specified.
4948 @item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
4949 @opindex Wno-protocol
4951 If a class is declared to implement a protocol, a warning is issued for
4952 every method in the protocol that is not implemented by the class. The
4953 default behavior is to issue a warning for every method not explicitly
4954 implemented in the class, even if a method implementation is inherited
4955 from the superclass. If you use the @option{-Wno-protocol} option, then
4956 methods inherited from the superclass are considered to be implemented,
4957 and no warning is issued for them.
4959 @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
4960 @opindex Wobjc-root-class
4961 Warn if a class interface lacks a superclass. Most classes will inherit
4962 from @code{NSObject} (or @code{Object}) for example. When declaring
4963 classes intended to be root classes, the warning can be suppressed by
4964 marking their interfaces with @code{__attribute__((objc_root_class))}.
4966 @item -Wselector @r{(Objective-C and Objective-C++ only)}
4968 @opindex Wno-selector
4969 Warn if multiple methods of different types for the same selector are
4970 found during compilation. The check is performed on the list of methods
4971 in the final stage of compilation. Additionally, a check is performed
4972 for each selector appearing in a @code{@@selector(@dots{})}
4973 expression, and a corresponding method for that selector has been found
4974 during compilation. Because these checks scan the method table only at
4975 the end of compilation, these warnings are not produced if the final
4976 stage of compilation is not reached, for example because an error is
4977 found during compilation, or because the @option{-fsyntax-only} option is
4980 @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
4981 @opindex Wstrict-selector-match
4982 @opindex Wno-strict-selector-match
4983 Warn if multiple methods with differing argument and/or return types are
4984 found for a given selector when attempting to send a message using this
4985 selector to a receiver of type @code{id} or @code{Class}. When this flag
4986 is off (which is the default behavior), the compiler omits such warnings
4987 if any differences found are confined to types that share the same size
4990 @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
4991 @opindex Wundeclared-selector
4992 @opindex Wno-undeclared-selector
4993 Warn if a @code{@@selector(@dots{})} expression referring to an
4994 undeclared selector is found. A selector is considered undeclared if no
4995 method with that name has been declared before the
4996 @code{@@selector(@dots{})} expression, either explicitly in an
4997 @code{@@interface} or @code{@@protocol} declaration, or implicitly in
4998 an @code{@@implementation} section. This option always performs its
4999 checks as soon as a @code{@@selector(@dots{})} expression is found,
5000 while @option{-Wselector} only performs its checks in the final stage of
5001 compilation. This also enforces the coding style convention
5002 that methods and selectors must be declared before being used.
5004 @item -print-objc-runtime-info
5005 @opindex print-objc-runtime-info
5006 Generate C header describing the largest structure that is passed by
5011 @node Diagnostic Message Formatting Options
5012 @section Options to Control Diagnostic Messages Formatting
5013 @cindex options to control diagnostics formatting
5014 @cindex diagnostic messages
5015 @cindex message formatting
5017 Traditionally, diagnostic messages have been formatted irrespective of
5018 the output device's aspect (e.g.@: its width, @dots{}). You can use the
5019 options described below
5020 to control the formatting algorithm for diagnostic messages,
5021 e.g.@: how many characters per line, how often source location
5022 information should be reported. Note that some language front ends may not
5023 honor these options.
5026 @item -fmessage-length=@var{n}
5027 @opindex fmessage-length
5028 Try to format error messages so that they fit on lines of about
5029 @var{n} characters. If @var{n} is zero, then no line-wrapping is
5030 done; each error message appears on a single line. This is the
5031 default for all front ends.
5033 Note - this option also affects the display of the @samp{#error} and
5034 @samp{#warning} pre-processor directives, and the @samp{deprecated}
5035 function/type/variable attribute. It does not however affect the
5036 @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5038 @item -fdiagnostics-plain-output
5039 This option requests that diagnostic output look as plain as possible, which
5040 may be useful when running @command{dejagnu} or other utilities that need to
5041 parse diagnostics output and prefer that it remain more stable over time.
5042 @option{-fdiagnostics-plain-output} is currently equivalent to the following
5044 @gccoptlist{-fno-diagnostics-show-caret @gol
5045 -fno-diagnostics-show-line-numbers @gol
5046 -fdiagnostics-color=never @gol
5047 -fdiagnostics-urls=never @gol
5048 -fdiagnostics-path-format=separate-events}
5049 In the future, if GCC changes the default appearance of its diagnostics, the
5050 corresponding option to disable the new behavior will be added to this list.
5052 @item -fdiagnostics-show-location=once
5053 @opindex fdiagnostics-show-location
5054 Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5055 reporter to emit source location information @emph{once}; that is, in
5056 case the message is too long to fit on a single physical line and has to
5057 be wrapped, the source location won't be emitted (as prefix) again,
5058 over and over, in subsequent continuation lines. This is the default
5061 @item -fdiagnostics-show-location=every-line
5062 Only meaningful in line-wrapping mode. Instructs the diagnostic
5063 messages reporter to emit the same source location information (as
5064 prefix) for physical lines that result from the process of breaking
5065 a message which is too long to fit on a single line.
5067 @item -fdiagnostics-color[=@var{WHEN}]
5068 @itemx -fno-diagnostics-color
5069 @opindex fdiagnostics-color
5070 @cindex highlight, color
5071 @vindex GCC_COLORS @r{environment variable}
5072 Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5073 or @samp{auto}. The default depends on how the compiler has been configured,
5074 it can be any of the above @var{WHEN} options or also @samp{never}
5075 if @env{GCC_COLORS} environment variable isn't present in the environment,
5076 and @samp{auto} otherwise.
5077 @samp{auto} makes GCC use color only when the standard error is a terminal,
5078 and when not executing in an emacs shell.
5079 The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5080 aliases for @option{-fdiagnostics-color=always} and
5081 @option{-fdiagnostics-color=never}, respectively.
5083 The colors are defined by the environment variable @env{GCC_COLORS}.
5084 Its value is a colon-separated list of capabilities and Select Graphic
5085 Rendition (SGR) substrings. SGR commands are interpreted by the
5086 terminal or terminal emulator. (See the section in the documentation
5087 of your text terminal for permitted values and their meanings as
5088 character attributes.) These substring values are integers in decimal
5089 representation and can be concatenated with semicolons.
5090 Common values to concatenate include
5092 @samp{4} for underline,
5094 @samp{7} for inverse,
5095 @samp{39} for default foreground color,
5096 @samp{30} to @samp{37} for foreground colors,
5097 @samp{90} to @samp{97} for 16-color mode foreground colors,
5098 @samp{38;5;0} to @samp{38;5;255}
5099 for 88-color and 256-color modes foreground colors,
5100 @samp{49} for default background color,
5101 @samp{40} to @samp{47} for background colors,
5102 @samp{100} to @samp{107} for 16-color mode background colors,
5103 and @samp{48;5;0} to @samp{48;5;255}
5104 for 88-color and 256-color modes background colors.
5106 The default @env{GCC_COLORS} is
5108 error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5109 quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5110 diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5111 type-diff=01;32:fnname=01;32:targs=35
5114 where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5115 @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5116 @samp{01} is bold, and @samp{31} is red.
5117 Setting @env{GCC_COLORS} to the empty string disables colors.
5118 Supported capabilities are as follows.
5122 @vindex error GCC_COLORS @r{capability}
5123 SGR substring for error: markers.
5126 @vindex warning GCC_COLORS @r{capability}
5127 SGR substring for warning: markers.
5130 @vindex note GCC_COLORS @r{capability}
5131 SGR substring for note: markers.
5134 @vindex path GCC_COLORS @r{capability}
5135 SGR substring for colorizing paths of control-flow events as printed
5136 via @option{-fdiagnostics-path-format=}, such as the identifiers of
5137 individual events and lines indicating interprocedural calls and returns.
5140 @vindex range1 GCC_COLORS @r{capability}
5141 SGR substring for first additional range.
5144 @vindex range2 GCC_COLORS @r{capability}
5145 SGR substring for second additional range.
5148 @vindex locus GCC_COLORS @r{capability}
5149 SGR substring for location information, @samp{file:line} or
5150 @samp{file:line:column} etc.
5153 @vindex quote GCC_COLORS @r{capability}
5154 SGR substring for information printed within quotes.
5157 @vindex fnname GCC_COLORS @r{capability}
5158 SGR substring for names of C++ functions.
5161 @vindex targs GCC_COLORS @r{capability}
5162 SGR substring for C++ function template parameter bindings.
5165 @vindex fixit-insert GCC_COLORS @r{capability}
5166 SGR substring for fix-it hints suggesting text to
5167 be inserted or replaced.
5170 @vindex fixit-delete GCC_COLORS @r{capability}
5171 SGR substring for fix-it hints suggesting text to
5174 @item diff-filename=
5175 @vindex diff-filename GCC_COLORS @r{capability}
5176 SGR substring for filename headers within generated patches.
5179 @vindex diff-hunk GCC_COLORS @r{capability}
5180 SGR substring for the starts of hunks within generated patches.
5183 @vindex diff-delete GCC_COLORS @r{capability}
5184 SGR substring for deleted lines within generated patches.
5187 @vindex diff-insert GCC_COLORS @r{capability}
5188 SGR substring for inserted lines within generated patches.
5191 @vindex type-diff GCC_COLORS @r{capability}
5192 SGR substring for highlighting mismatching types within template
5193 arguments in the C++ frontend.
5196 @item -fdiagnostics-urls[=@var{WHEN}]
5197 @opindex fdiagnostics-urls
5199 @vindex GCC_URLS @r{environment variable}
5200 @vindex TERM_URLS @r{environment variable}
5201 Use escape sequences to embed URLs in diagnostics. For example, when
5202 @option{-fdiagnostics-show-option} emits text showing the command-line
5203 option controlling a diagnostic, embed a URL for documentation of that
5206 @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5207 @samp{auto} makes GCC use URL escape sequences only when the standard error
5208 is a terminal, and when not executing in an emacs shell or any graphical
5209 terminal which is known to be incompatible with this feature, see below.
5211 The default depends on how the compiler has been configured.
5212 It can be any of the above @var{WHEN} options.
5214 GCC can also be configured (via the
5215 @option{--with-diagnostics-urls=auto-if-env} configure-time option)
5216 so that the default is affected by environment variables.
5217 Under such a configuration, GCC defaults to using @samp{auto}
5218 if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5219 present and non-empty in the environment of the compiler, or @samp{never}
5222 However, even with @option{-fdiagnostics-urls=always} the behavior is
5223 dependent on those environment variables:
5224 If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5225 diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5226 If set to @samp{bel}, the default, URLs use BEL escape sequences.
5227 Any other non-empty value enables the feature.
5228 If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5229 Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5230 BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5232 At this time GCC tries to detect also a few terminals that are known to
5233 not implement the URL feature, and have bugs or at least had bugs in
5234 some versions that are still in use, where the URL escapes are likely
5235 to misbehave, i.e. print garbage on the screen.
5236 That list is currently xfce4-terminal, certain known to be buggy
5237 gnome-terminal versions, the linux console, and mingw.
5238 This check can be skipped with the @option{-fdiagnostics-urls=always}.
5240 @item -fno-diagnostics-show-option
5241 @opindex fno-diagnostics-show-option
5242 @opindex fdiagnostics-show-option
5243 By default, each diagnostic emitted includes text indicating the
5244 command-line option that directly controls the diagnostic (if such an
5245 option is known to the diagnostic machinery). Specifying the
5246 @option{-fno-diagnostics-show-option} flag suppresses that behavior.
5248 @item -fno-diagnostics-show-caret
5249 @opindex fno-diagnostics-show-caret
5250 @opindex fdiagnostics-show-caret
5251 By default, each diagnostic emitted includes the original source line
5252 and a caret @samp{^} indicating the column. This option suppresses this
5253 information. The source line is truncated to @var{n} characters, if
5254 the @option{-fmessage-length=n} option is given. When the output is done
5255 to the terminal, the width is limited to the width given by the
5256 @env{COLUMNS} environment variable or, if not set, to the terminal width.
5258 @item -fno-diagnostics-show-labels
5259 @opindex fno-diagnostics-show-labels
5260 @opindex fdiagnostics-show-labels
5261 By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5262 diagnostics can label ranges of source code with pertinent information, such
5263 as the types of expressions:
5266 printf ("foo %s bar", long_i + long_j);
5272 This option suppresses the printing of these labels (in the example above,
5273 the vertical bars and the ``char *'' and ``long int'' text).
5275 @item -fno-diagnostics-show-cwe
5276 @opindex fno-diagnostics-show-cwe
5277 @opindex fdiagnostics-show-cwe
5278 Diagnostic messages can optionally have an associated
5279 @uref{https://cwe.mitre.org/index.html, CWE} identifier.
5280 GCC itself only provides such metadata for some of the @option{-fanalyzer}
5281 diagnostics. GCC plugins may also provide diagnostics with such metadata.
5282 By default, if this information is present, it will be printed with
5283 the diagnostic. This option suppresses the printing of this metadata.
5285 @item -fno-diagnostics-show-rules
5286 @opindex fno-diagnostics-show-rules
5287 @opindex fdiagnostics-show-rules
5288 Diagnostic messages can optionally have rules associated with them, such
5289 as from a coding standard, or a specification.
5290 GCC itself does not do this for any of its diagnostics, but plugins may do so.
5291 By default, if this information is present, it will be printed with
5292 the diagnostic. This option suppresses the printing of this metadata.
5294 @item -fno-diagnostics-show-line-numbers
5295 @opindex fno-diagnostics-show-line-numbers
5296 @opindex fdiagnostics-show-line-numbers
5297 By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5298 a left margin is printed, showing line numbers. This option suppresses this
5301 @item -fdiagnostics-minimum-margin-width=@var{width}
5302 @opindex fdiagnostics-minimum-margin-width
5303 This option controls the minimum width of the left margin printed by
5304 @option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5306 @item -fdiagnostics-parseable-fixits
5307 @opindex fdiagnostics-parseable-fixits
5308 Emit fix-it hints in a machine-parseable format, suitable for consumption
5309 by IDEs. For each fix-it, a line will be printed after the relevant
5310 diagnostic, starting with the string ``fix-it:''. For example:
5313 fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5316 The location is expressed as a half-open range, expressed as a count of
5317 bytes, starting at byte 1 for the initial column. In the above example,
5318 bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5322 00000000011111111112222222222
5323 12345678901234567890123456789
5324 gtk_widget_showall (dlg);
5329 The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5330 newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5331 (e.g. vertical tab as ``\013'').
5333 An empty replacement string indicates that the given range is to be removed.
5334 An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5335 be inserted at the given position.
5337 @item -fdiagnostics-generate-patch
5338 @opindex fdiagnostics-generate-patch
5339 Print fix-it hints to stderr in unified diff format, after any diagnostics
5340 are printed. For example:
5347 void show_cb(GtkDialog *dlg)
5349 - gtk_widget_showall(dlg);
5350 + gtk_widget_show_all(dlg);
5355 The diff may or may not be colorized, following the same rules
5356 as for diagnostics (see @option{-fdiagnostics-color}).
5358 @item -fdiagnostics-show-template-tree
5359 @opindex fdiagnostics-show-template-tree
5361 In the C++ frontend, when printing diagnostics showing mismatching
5362 template types, such as:
5365 could not convert 'std::map<int, std::vector<double> >()'
5366 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5369 the @option{-fdiagnostics-show-template-tree} flag enables printing a
5370 tree-like structure showing the common and differing parts of the types,
5380 The parts that differ are highlighted with color (``double'' and
5381 ``float'' in this case).
5383 @item -fno-elide-type
5384 @opindex fno-elide-type
5385 @opindex felide-type
5386 By default when the C++ frontend prints diagnostics showing mismatching
5387 template types, common parts of the types are printed as ``[...]'' to
5388 simplify the error message. For example:
5391 could not convert 'std::map<int, std::vector<double> >()'
5392 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5395 Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5396 This flag also affects the output of the
5397 @option{-fdiagnostics-show-template-tree} flag.
5399 @item -fdiagnostics-path-format=@var{KIND}
5400 @opindex fdiagnostics-path-format
5401 Specify how to print paths of control-flow events for diagnostics that
5402 have such a path associated with them.
5404 @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5407 @samp{none} means to not print diagnostic paths.
5409 @samp{separate-events} means to print a separate ``note'' diagnostic for
5410 each event within the diagnostic. For example:
5413 test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5414 test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5415 test.c:27:3: note: (2) when 'i < count'
5416 test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5419 @samp{inline-events} means to print the events ``inline'' within the source
5420 code. This view attempts to consolidate the events into runs of
5421 sufficiently-close events, printing them as labelled ranges within the source.
5423 For example, the same events as above might be printed as:
5428 | 25 | list = PyList_New(0);
5431 | | (1) when 'PyList_New' fails, returning NULL
5433 | 27 | for (i = 0; i < count; i++) @{
5436 | | (2) when 'i < count'
5437 | 28 | item = PyLong_FromLong(random());
5438 | 29 | PyList_Append(list, item);
5439 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5441 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5445 Interprocedural control flow is shown by grouping the events by stack frame,
5446 and using indentation to show how stack frames are nested, pushed, and popped.
5456 | | (1) entering 'test'
5457 | 134 | boxed_int *obj = make_boxed_int (i);
5458 | | ~~~~~~~~~~~~~~~~~~
5460 | | (2) calling 'make_boxed_int'
5462 +--> 'make_boxed_int': events 3-4
5467 | | (3) entering 'make_boxed_int'
5468 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5469 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5471 | | (4) calling 'wrapped_malloc'
5473 +--> 'wrapped_malloc': events 5-6
5478 | | (5) entering 'wrapped_malloc'
5479 | 8 | return malloc (size);
5482 | | (6) calling 'malloc'
5488 | 138 | free_boxed_int (obj);
5489 | | ^~~~~~~~~~~~~~~~~~~~
5491 | | (7) calling 'free_boxed_int'
5496 @item -fdiagnostics-show-path-depths
5497 @opindex fdiagnostics-show-path-depths
5498 This option provides additional information when printing control-flow paths
5499 associated with a diagnostic.
5501 If this is option is provided then the stack depth will be printed for
5502 each run of events within @option{-fdiagnostics-path-format=inline-events}.
5503 If provided with @option{-fdiagnostics-path-format=separate-events}, then
5504 the stack depth and function declaration will be appended when printing
5507 This is intended for use by GCC developers and plugin developers when
5508 debugging diagnostics that report interprocedural control flow.
5510 @item -fno-show-column
5511 @opindex fno-show-column
5512 @opindex fshow-column
5513 Do not print column numbers in diagnostics. This may be necessary if
5514 diagnostics are being scanned by a program that does not understand the
5515 column numbers, such as @command{dejagnu}.
5517 @item -fdiagnostics-column-unit=@var{UNIT}
5518 @opindex fdiagnostics-column-unit
5519 Select the units for the column number. This affects traditional diagnostics
5520 (in the absence of @option{-fno-show-column}), as well as JSON format
5521 diagnostics if requested.
5523 The default @var{UNIT}, @samp{display}, considers the number of display
5524 columns occupied by each character. This may be larger than the number
5525 of bytes required to encode the character, in the case of tab
5526 characters, or it may be smaller, in the case of multibyte characters.
5527 For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5528 display column, and its UTF-8 encoding requires two bytes; the character
5529 ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5530 its UTF-8 encoding requires four bytes.
5532 Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5533 count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5535 @item -fdiagnostics-column-origin=@var{ORIGIN}
5536 @opindex fdiagnostics-column-origin
5537 Select the origin for column numbers, i.e. the column number assigned to the
5538 first column. The default value of 1 corresponds to traditional GCC
5539 behavior and to the GNU style guide. Some utilities may perform better with an
5540 origin of 0; any non-negative value may be specified.
5542 @item -fdiagnostics-escape-format=@var{FORMAT}
5543 @opindex fdiagnostics-escape-format
5544 When GCC prints pertinent source lines for a diagnostic it normally attempts
5545 to print the source bytes directly. However, some diagnostics relate to encoding
5546 issues in the source file, such as malformed UTF-8, or issues with Unicode
5547 normalization. These diagnostics are flagged so that GCC will escape bytes
5548 that are not printable ASCII when printing their pertinent source lines.
5550 This option controls how such bytes should be escaped.
5552 The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5553 are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5554 correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5555 displayed as hexadecimal in the form @samp{<XX>}.
5557 For example, a source line containing the string @samp{before} followed by the
5558 Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
5559 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5560 the string @samp{after} will be printed for such a diagnostic as:
5563 before<U+03C0><BF>after
5566 Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5567 in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5568 Unicode characters. For the example above, the following will be printed:
5571 before<CF><80><BF>after
5574 @item -fdiagnostics-format=@var{FORMAT}
5575 @opindex fdiagnostics-format
5576 Select a different format for printing diagnostics.
5577 @var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5578 @samp{json}, @samp{json-stderr}, or @samp{json-file}.
5580 The default is @samp{text}.
5582 The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5583 diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5584 named @file{@var{source}.sarif}, respectively.
5586 The @samp{json} format is a synonym for @samp{json-stderr}.
5587 The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5588 where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5589 whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5591 The emitted JSON consists of a top-level JSON array containing JSON objects
5592 representing the diagnostics. The JSON is emitted as one line, without
5593 formatting; the examples below have been formatted for clarity.
5595 Diagnostics can have child diagnostics. For example, this error and note:
5598 misleading-indentation.c:15:3: warning: this 'if' clause does not
5599 guard... [-Wmisleading-indentation]
5602 misleading-indentation.c:17:5: note: ...this statement, but the latter
5603 is misleadingly indented as if it were guarded by the 'if'
5609 might be printed in JSON form (after formatting) like this:
5618 "display-column": 3,
5621 "file": "misleading-indentation.c",
5625 "display-column": 4,
5628 "file": "misleading-indentation.c",
5633 "message": "this \u2018if\u2019 clause does not guard...",
5634 "option": "-Wmisleading-indentation",
5635 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5642 "display-column": 5,
5645 "file": "misleading-indentation.c",
5650 "escape-source": false,
5651 "message": "...this statement, but the latter is @dots{}"
5654 "escape-source": false,
5661 where the @code{note} is a child of the @code{warning}.
5663 A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5664 an @code{option} key describing the command-line option controlling the
5667 A diagnostic can contain zero or more locations. Each location has an
5668 optional @code{label} string and up to three positions within it: a
5669 @code{caret} position and optional @code{start} and @code{finish} positions.
5670 A position is described by a @code{file} name, a @code{line} number, and
5671 three numbers indicating a column position:
5675 @code{display-column} counts display columns, accounting for tabs and
5676 multibyte characters.
5679 @code{byte-column} counts raw bytes.
5682 @code{column} is equal to one of
5683 the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5687 All three columns are relative to the origin specified by
5688 @option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5689 be set, for instance, to 0 for compatibility with other utilities that
5690 number columns from 0. The column origin is recorded in the JSON output in
5691 the @code{column-origin} tag. In the remaining examples below, the extra
5692 column number outputs have been omitted for brevity.
5694 For example, this error:
5697 bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5698 'struct s'@} and 'T' @{aka 'struct t'@})
5699 64 | return callee_4a () + callee_4b ();
5700 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5702 | | T @{aka struct t@}
5703 | S @{aka struct s@}
5707 has three locations. Its primary location is at the ``+'' token at column
5708 23. It has two secondary locations, describing the left and right-hand sides
5709 of the expression, which have labels. It might be printed in JSON form as:
5718 "column": 23, "file": "bad-binary-ops.c", "line": 64
5723 "column": 10, "file": "bad-binary-ops.c", "line": 64
5726 "column": 21, "file": "bad-binary-ops.c", "line": 64
5728 "label": "S @{aka struct s@}"
5732 "column": 25, "file": "bad-binary-ops.c", "line": 64
5735 "column": 36, "file": "bad-binary-ops.c", "line": 64
5737 "label": "T @{aka struct t@}"
5740 "escape-source": false,
5741 "message": "invalid operands to binary + @dots{}"
5745 If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5746 consisting of half-open intervals, similar to the output of
5747 @option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5748 with a replacement fix-it hint:
5751 demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5753 8 | return ptr->colour;
5759 might be printed in JSON form as:
5794 "escape-source": false,
5795 "message": "\u2018struct s\u2019 has no member named @dots{}"
5800 where the fix-it hint suggests replacing the text from @code{start} up
5801 to but not including @code{next} with @code{string}'s value. Deletions
5802 are expressed via an empty value for @code{string}, insertions by
5803 having @code{start} equal @code{next}.
5805 If the diagnostic has a path of control-flow events associated with it,
5806 it has a @code{path} array of objects representing the events. Each
5807 event object has a @code{description} string, a @code{location} object,
5808 along with a @code{function} string and a @code{depth} number for
5809 representing interprocedural paths. The @code{function} represents the
5810 current function at that event, and the @code{depth} represents the
5811 stack depth relative to some baseline: the higher, the more frames are
5814 For example, the intraprocedural example shown for
5815 @option{-fdiagnostics-path-format=} might have this JSON for its path:
5821 "description": "when 'PyList_New' fails, returning NULL",
5831 "description": "when 'i < count'",
5841 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5852 Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5853 non-ASCII bytes should be escaped when printing the pertinent lines of
5854 source code (@code{true} for diagnostics involving source encoding issues).
5858 @node Warning Options
5859 @section Options to Request or Suppress Warnings
5860 @cindex options to control warnings
5861 @cindex warning messages
5862 @cindex messages, warning
5863 @cindex suppressing warnings
5865 Warnings are diagnostic messages that report constructions that
5866 are not inherently erroneous but that are risky or suggest there
5867 may have been an error.
5869 The following language-independent options do not enable specific
5870 warnings but control the kinds of diagnostics produced by GCC@.
5873 @cindex syntax checking
5875 @opindex fsyntax-only
5876 Check the code for syntax errors, but don't do anything beyond that.
5878 @item -fmax-errors=@var{n}
5879 @opindex fmax-errors
5880 Limits the maximum number of error messages to @var{n}, at which point
5881 GCC bails out rather than attempting to continue processing the source
5882 code. If @var{n} is 0 (the default), there is no limit on the number
5883 of error messages produced. If @option{-Wfatal-errors} is also
5884 specified, then @option{-Wfatal-errors} takes precedence over this
5889 Inhibit all warning messages.
5894 Make all warnings into errors.
5899 Make the specified warning into an error. The specifier for a warning
5900 is appended; for example @option{-Werror=switch} turns the warnings
5901 controlled by @option{-Wswitch} into errors. This switch takes a
5902 negative form, to be used to negate @option{-Werror} for specific
5903 warnings; for example @option{-Wno-error=switch} makes
5904 @option{-Wswitch} warnings not be errors, even when @option{-Werror}
5907 The warning message for each controllable warning includes the
5908 option that controls the warning. That option can then be used with
5909 @option{-Werror=} and @option{-Wno-error=} as described above.
5910 (Printing of the option in the warning message can be disabled using the
5911 @option{-fno-diagnostics-show-option} flag.)
5913 Note that specifying @option{-Werror=}@var{foo} automatically implies
5914 @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
5917 @item -Wfatal-errors
5918 @opindex Wfatal-errors
5919 @opindex Wno-fatal-errors
5920 This option causes the compiler to abort compilation on the first error
5921 occurred rather than trying to keep going and printing further error
5926 You can request many specific warnings with options beginning with
5927 @samp{-W}, for example @option{-Wimplicit} to request warnings on
5928 implicit declarations. Each of these specific warning options also
5929 has a negative form beginning @samp{-Wno-} to turn off warnings; for
5930 example, @option{-Wno-implicit}. This manual lists only one of the
5931 two forms, whichever is not the default. For further
5932 language-specific options also refer to @ref{C++ Dialect Options} and
5933 @ref{Objective-C and Objective-C++ Dialect Options}.
5934 Additional warnings can be produced by enabling the static analyzer;
5935 @xref{Static Analyzer Options}.
5937 Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
5938 options, such as @option{-Wunused}, which may turn on further options,
5939 such as @option{-Wunused-value}. The combined effect of positive and
5940 negative forms is that more specific options have priority over less
5941 specific ones, independently of their position in the command-line. For
5942 options of the same specificity, the last one takes effect. Options
5943 enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5944 as if they appeared at the end of the command-line.
5946 When an unrecognized warning option is requested (e.g.,
5947 @option{-Wunknown-warning}), GCC emits a diagnostic stating
5948 that the option is not recognized. However, if the @option{-Wno-} form
5949 is used, the behavior is slightly different: no diagnostic is
5950 produced for @option{-Wno-unknown-warning} unless other diagnostics
5951 are being produced. This allows the use of new @option{-Wno-} options
5952 with old compilers, but if something goes wrong, the compiler
5953 warns that an unrecognized option is present.
5955 The effectiveness of some warnings depends on optimizations also being
5956 enabled. For example @option{-Wsuggest-final-types} is more effective
5957 with link-time optimization and some instances of other warnings may
5958 not be issued at all unless optimization is enabled. While optimization
5959 in general improves the efficacy of control and data flow sensitive
5960 warnings, in some cases it may also cause false positives.
5967 @opindex Wno-pedantic
5968 Issue all the warnings demanded by strict ISO C and ISO C++;
5969 reject all programs that use forbidden extensions, and some other
5970 programs that do not follow ISO C and ISO C++. For ISO C, follows the
5971 version of the ISO C standard specified by any @option{-std} option used.
5973 Valid ISO C and ISO C++ programs should compile properly with or without
5974 this option (though a rare few require @option{-ansi} or a
5975 @option{-std} option specifying the required version of ISO C)@. However,
5976 without this option, certain GNU extensions and traditional C and C++
5977 features are supported as well. With this option, they are rejected.
5979 @option{-Wpedantic} does not cause warning messages for use of the
5980 alternate keywords whose names begin and end with @samp{__}. This alternate
5981 format can also be used to disable warnings for non-ISO @samp{__intN} types,
5982 i.e. @samp{__intN__}.
5983 Pedantic warnings are also disabled in the expression that follows
5984 @code{__extension__}. However, only system header files should use
5985 these escape routes; application programs should avoid them.
5986 @xref{Alternate Keywords}.
5988 Some users try to use @option{-Wpedantic} to check programs for strict ISO
5989 C conformance. They soon find that it does not do quite what they want:
5990 it finds some non-ISO practices, but not all---only those for which
5991 ISO C @emph{requires} a diagnostic, and some others for which
5992 diagnostics have been added.
5994 A feature to report any failure to conform to ISO C might be useful in
5995 some instances, but would require considerable additional work and would
5996 be quite different from @option{-Wpedantic}. We don't have plans to
5997 support such a feature in the near future.
5999 Where the standard specified with @option{-std} represents a GNU
6000 extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6001 corresponding @dfn{base standard}, the version of ISO C on which the GNU
6002 extended dialect is based. Warnings from @option{-Wpedantic} are given
6003 where they are required by the base standard. (It does not make sense
6004 for such warnings to be given only for features not in the specified GNU
6005 C dialect, since by definition the GNU dialects of C include all
6006 features the compiler supports with the given option, and there would be
6007 nothing to warn about.)
6009 @item -pedantic-errors
6010 @opindex pedantic-errors
6011 Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6012 requires a diagnostic, in some cases where there is undefined behavior
6013 at compile-time and in some other cases that do not prevent compilation
6014 of programs that are valid according to the standard. This is not
6015 equivalent to @option{-Werror=pedantic}, since there are errors enabled
6016 by this option and not enabled by the latter and vice versa.
6021 This enables all the warnings about constructions that some users
6022 consider questionable, and that are easy to avoid (or modify to
6023 prevent the warning), even in conjunction with macros. This also
6024 enables some language-specific warnings described in @ref{C++ Dialect
6025 Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6027 @option{-Wall} turns on the following warning flags:
6029 @gccoptlist{-Waddress @gol
6030 -Warray-bounds=1 @r{(only with} @option{-O2}@r{)} @gol
6031 -Warray-compare @gol
6032 -Warray-parameter=2 @r{(C and Objective-C only)} @gol
6034 -Wbool-operation @gol
6035 -Wc++11-compat -Wc++14-compat @gol
6036 -Wcatch-value @r{(C++ and Objective-C++ only)} @gol
6037 -Wchar-subscripts @gol
6039 -Wdangling-pointer=2 @gol
6040 -Wduplicate-decl-specifier @r{(C and Objective-C only)} @gol
6041 -Wenum-compare @r{(in C/ObjC; this is on by default in C++)} @gol
6042 -Wenum-int-mismatch @r{(C and Objective-C only)} @gol
6044 -Wformat-overflow @gol
6045 -Wformat-truncation @gol
6046 -Wint-in-bool-context @gol
6047 -Wimplicit @r{(C and Objective-C only)} @gol
6048 -Wimplicit-int @r{(C and Objective-C only)} @gol
6049 -Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
6050 -Winit-self @r{(only for C++)} @gol
6051 -Wlogical-not-parentheses @gol
6052 -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol
6053 -Wmaybe-uninitialized @gol
6054 -Wmemset-elt-size @gol
6055 -Wmemset-transposed-args @gol
6056 -Wmisleading-indentation @r{(only for C/C++)} @gol
6057 -Wmismatched-dealloc @gol
6058 -Wmismatched-new-delete @r{(only for C/C++)} @gol
6059 -Wmissing-attributes @gol
6060 -Wmissing-braces @r{(only for C/ObjC)} @gol
6061 -Wmultistatement-macros @gol
6062 -Wnarrowing @r{(only for C++)} @gol
6064 -Wnonnull-compare @gol
6067 -Wpessimizing-move @r{(only for C++)} @gol
6069 -Wrange-loop-construct @r{(only for C++)} @gol
6073 -Wself-move @r{(only for C++)} @gol
6074 -Wsequence-point @gol
6075 -Wsign-compare @r{(only in C++)} @gol
6076 -Wsizeof-array-div @gol
6077 -Wsizeof-pointer-div @gol
6078 -Wsizeof-pointer-memaccess @gol
6079 -Wstrict-aliasing @gol
6080 -Wstrict-overflow=1 @gol
6082 -Wtautological-compare @gol
6084 -Wuninitialized @gol
6085 -Wunknown-pragmas @gol
6086 -Wunused-function @gol
6089 -Wunused-variable @gol
6090 -Wuse-after-free=2 @gol
6091 -Wvla-parameter @r{(C and Objective-C only)} @gol
6092 -Wvolatile-register-var @gol
6093 -Wzero-length-bounds}
6095 Note that some warning flags are not implied by @option{-Wall}. Some of
6096 them warn about constructions that users generally do not consider
6097 questionable, but which occasionally you might wish to check for;
6098 others warn about constructions that are necessary or hard to avoid in
6099 some cases, and there is no simple way to modify the code to suppress
6100 the warning. Some of them are enabled by @option{-Wextra} but many of
6101 them must be enabled individually.
6107 This enables some extra warning flags that are not enabled by
6108 @option{-Wall}. (This option used to be called @option{-W}. The older
6109 name is still supported, but the newer name is more descriptive.)
6111 @gccoptlist{-Wclobbered @gol
6112 -Wcast-function-type @gol
6113 -Wdeprecated-copy @r{(C++ only)} @gol
6115 -Wenum-conversion @r{(C only)} @gol
6116 -Wignored-qualifiers @gol
6117 -Wimplicit-fallthrough=3 @gol
6118 -Wmissing-field-initializers @gol
6119 -Wmissing-parameter-type @r{(C only)} @gol
6120 -Wold-style-declaration @r{(C only)} @gol
6121 -Woverride-init @gol
6122 -Wsign-compare @r{(C only)} @gol
6123 -Wstring-compare @gol
6124 -Wredundant-move @r{(only for C++)} @gol
6126 -Wuninitialized @gol
6127 -Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} @gol
6128 -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} @gol
6129 -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6132 The option @option{-Wextra} also prints warning messages for the
6138 A pointer is compared against integer zero with @code{<}, @code{<=},
6139 @code{>}, or @code{>=}.
6142 (C++ only) An enumerator and a non-enumerator both appear in a
6143 conditional expression.
6146 (C++ only) Ambiguous virtual bases.
6149 (C++ only) Subscripting an array that has been declared @code{register}.
6152 (C++ only) Taking the address of a variable that has been declared
6156 (C++ only) A base class is not initialized in the copy constructor
6161 @item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
6165 Warn about code affected by ABI changes. This includes code that may
6166 not be compatible with the vendor-neutral C++ ABI as well as the psABI
6167 for the particular target.
6169 Since G++ now defaults to updating the ABI with each major release,
6170 normally @option{-Wabi} warns only about C++ ABI compatibility
6171 problems if there is a check added later in a release series for an
6172 ABI issue discovered since the initial release. @option{-Wabi} warns
6173 about more things if an older ABI version is selected (with
6174 @option{-fabi-version=@var{n}}).
6176 @option{-Wabi} can also be used with an explicit version number to
6177 warn about C++ ABI compatibility with a particular @option{-fabi-version}
6178 level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6179 @option{-fabi-version=2}.
6181 If an explicit version number is provided and
6182 @option{-fabi-compat-version} is not specified, the version number
6183 from this option is used for compatibility aliases. If no explicit
6184 version number is provided with this option, but
6185 @option{-fabi-compat-version} is specified, that version number is
6186 used for C++ ABI warnings.
6188 Although an effort has been made to warn about
6189 all such cases, there are probably some cases that are not warned about,
6190 even though G++ is generating incompatible code. There may also be
6191 cases where warnings are emitted even though the code that is generated
6194 You should rewrite your code to avoid these warnings if you are
6195 concerned about the fact that code generated by G++ may not be binary
6196 compatible with code generated by other compilers.
6198 Known incompatibilities in @option{-fabi-version=2} (which was the
6199 default from GCC 3.4 to 4.9) include:
6204 A template with a non-type template parameter of reference type was
6205 mangled incorrectly:
6208 template <int &> struct S @{@};
6212 This was fixed in @option{-fabi-version=3}.
6215 SIMD vector types declared using @code{__attribute ((vector_size))} were
6216 mangled in a non-standard way that does not allow for overloading of
6217 functions taking vectors of different sizes.
6219 The mangling was changed in @option{-fabi-version=4}.
6222 @code{__attribute ((const))} and @code{noreturn} were mangled as type
6223 qualifiers, and @code{decltype} of a plain declaration was folded away.
6225 These mangling issues were fixed in @option{-fabi-version=5}.
6228 Scoped enumerators passed as arguments to a variadic function are
6229 promoted like unscoped enumerators, causing @code{va_arg} to complain.
6230 On most targets this does not actually affect the parameter passing
6231 ABI, as there is no way to pass an argument smaller than @code{int}.
6233 Also, the ABI changed the mangling of template argument packs,
6234 @code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6235 a class scope function used as a template argument.
6237 These issues were corrected in @option{-fabi-version=6}.
6240 Lambdas in default argument scope were mangled incorrectly, and the
6241 ABI changed the mangling of @code{nullptr_t}.
6243 These issues were corrected in @option{-fabi-version=7}.
6246 When mangling a function type with function-cv-qualifiers, the
6247 un-qualified function type was incorrectly treated as a substitution
6250 This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6253 @code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6254 unaligned accesses. Note that this did not affect the ABI of a
6255 function with a @code{nullptr_t} parameter, as parameters have a
6258 This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6261 Target-specific attributes that affect the identity of a type, such as
6262 ia32 calling conventions on a function type (stdcall, regparm, etc.),
6263 did not affect the mangled name, leading to name collisions when
6264 function pointers were used as template arguments.
6266 This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6270 This option also enables warnings about psABI-related changes.
6271 The known psABI changes at this point include:
6276 For SysV/x86-64, unions with @code{long double} members are
6277 passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6278 the case. For example:
6288 @code{union U} is now always passed in memory.
6292 @item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6293 C++ requires that unqualified uses of a name within a class have the
6294 same meaning in the complete scope of the class, so declaring the name
6295 after using it is ill-formed:
6298 struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6299 struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6301 By default, the B1 case is only a warning because the two declarations
6302 have the same type, while the B2 case is an error. Both diagnostics
6303 can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6304 error case can be reduced to a warning with
6305 @option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6307 Both diagnostics are also suppressed by @option{-fms-extensions}.
6309 @item -Wchar-subscripts
6310 @opindex Wchar-subscripts
6311 @opindex Wno-char-subscripts
6312 Warn if an array subscript has type @code{char}. This is a common cause
6313 of error, as programmers often forget that this type is signed on some
6315 This warning is enabled by @option{-Wall}.
6317 @item -Wno-coverage-mismatch
6318 @opindex Wno-coverage-mismatch
6319 @opindex Wcoverage-mismatch
6320 Warn if feedback profiles do not match when using the
6321 @option{-fprofile-use} option.
6322 If a source file is changed between compiling with @option{-fprofile-generate}
6323 and with @option{-fprofile-use}, the files with the profile feedback can fail
6324 to match the source file and GCC cannot use the profile feedback
6325 information. By default, this warning is enabled and is treated as an
6326 error. @option{-Wno-coverage-mismatch} can be used to disable the
6327 warning or @option{-Wno-error=coverage-mismatch} can be used to
6328 disable the error. Disabling the error for this warning can result in
6329 poorly optimized code and is useful only in the
6330 case of very minor changes such as bug fixes to an existing code-base.
6331 Completely disabling the warning is not recommended.
6333 @item -Wno-coverage-invalid-line-number
6334 @opindex Wno-coverage-invalid-line-number
6335 @opindex Wcoverage-invalid-line-number
6336 Warn in case a function ends earlier than it begins due
6337 to an invalid linenum macros. The warning is emitted only
6338 with @option{--coverage} enabled.
6340 By default, this warning is enabled and is treated as an
6341 error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6342 warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6345 @item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
6348 Suppress warning messages emitted by @code{#warning} directives.
6350 @item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
6351 @opindex Wdouble-promotion
6352 @opindex Wno-double-promotion
6353 Give a warning when a value of type @code{float} is implicitly
6354 promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6355 floating-point unit implement @code{float} in hardware, but emulate
6356 @code{double} in software. On such a machine, doing computations
6357 using @code{double} values is much more expensive because of the
6358 overhead required for software emulation.
6360 It is easy to accidentally do computations with @code{double} because
6361 floating-point literals are implicitly of type @code{double}. For
6365 float area(float radius)
6367 return 3.14159 * radius * radius;
6371 the compiler performs the entire computation with @code{double}
6372 because the floating-point literal is a @code{double}.
6374 @item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
6375 @opindex Wduplicate-decl-specifier
6376 @opindex Wno-duplicate-decl-specifier
6377 Warn if a declaration has duplicate @code{const}, @code{volatile},
6378 @code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6382 @itemx -Wformat=@var{n}
6385 @opindex ffreestanding
6386 @opindex fno-builtin
6388 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6389 the arguments supplied have types appropriate to the format string
6390 specified, and that the conversions specified in the format string make
6391 sense. This includes standard functions, and others specified by format
6392 attributes (@pxref{Function Attributes}), in the @code{printf},
6393 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6394 not in the C standard) families (or other target-specific families).
6395 Which functions are checked without format attributes having been
6396 specified depends on the standard version selected, and such checks of
6397 functions without the attribute specified are disabled by
6398 @option{-ffreestanding} or @option{-fno-builtin}.
6400 The formats are checked against the format features supported by GNU
6401 libc version 2.2. These include all ISO C90 and C99 features, as well
6402 as features from the Single Unix Specification and some BSD and GNU
6403 extensions. Other library implementations may not support all these
6404 features; GCC does not support warning about features that go beyond a
6405 particular library's limitations. However, if @option{-Wpedantic} is used
6406 with @option{-Wformat}, warnings are given about format features not
6407 in the selected standard version (but not for @code{strfmon} formats,
6408 since those are not in any version of the C standard). @xref{C Dialect
6409 Options,,Options Controlling C Dialect}.
6416 Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6417 @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6418 @option{-Wformat} also checks for null format arguments for several
6419 functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6420 aspects of this level of format checking can be disabled by the
6421 options: @option{-Wno-format-contains-nul},
6422 @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6423 @option{-Wformat} is enabled by @option{-Wall}.
6427 Enable @option{-Wformat} plus additional format checks. Currently
6428 equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6432 @item -Wno-format-contains-nul
6433 @opindex Wno-format-contains-nul
6434 @opindex Wformat-contains-nul
6435 If @option{-Wformat} is specified, do not warn about format strings that
6438 @item -Wno-format-extra-args
6439 @opindex Wno-format-extra-args
6440 @opindex Wformat-extra-args
6441 If @option{-Wformat} is specified, do not warn about excess arguments to a
6442 @code{printf} or @code{scanf} format function. The C standard specifies
6443 that such arguments are ignored.
6445 Where the unused arguments lie between used arguments that are
6446 specified with @samp{$} operand number specifications, normally
6447 warnings are still given, since the implementation could not know what
6448 type to pass to @code{va_arg} to skip the unused arguments. However,
6449 in the case of @code{scanf} formats, this option suppresses the
6450 warning if the unused arguments are all pointers, since the Single
6451 Unix Specification says that such unused arguments are allowed.
6453 @item -Wformat-overflow
6454 @itemx -Wformat-overflow=@var{level}
6455 @opindex Wformat-overflow
6456 @opindex Wno-format-overflow
6457 Warn about calls to formatted input/output functions such as @code{sprintf}
6458 and @code{vsprintf} that might overflow the destination buffer. When the
6459 exact number of bytes written by a format directive cannot be determined
6460 at compile-time it is estimated based on heuristics that depend on the
6461 @var{level} argument and on optimization. While enabling optimization
6462 will in most cases improve the accuracy of the warning, it may also
6463 result in false positives.
6466 @item -Wformat-overflow
6467 @itemx -Wformat-overflow=1
6468 @opindex Wformat-overflow
6469 @opindex Wno-format-overflow
6470 Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6471 employs a conservative approach that warns only about calls that most
6472 likely overflow the buffer. At this level, numeric arguments to format
6473 directives with unknown values are assumed to have the value of one, and
6474 strings of unknown length to be empty. Numeric arguments that are known
6475 to be bounded to a subrange of their type, or string arguments whose output
6476 is bounded either by their directive's precision or by a finite set of
6477 string literals, are assumed to take on the value within the range that
6478 results in the most bytes on output. For example, the call to @code{sprintf}
6479 below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6480 the terminating NUL character (@code{'\0'}) appended by the function
6481 to the destination buffer will be written past its end. Increasing
6482 the size of the buffer by a single byte is sufficient to avoid the
6483 warning, though it may not be sufficient to avoid the overflow.
6486 void f (int a, int b)
6489 sprintf (buf, "a = %i, b = %i\n", a, b);
6493 @item -Wformat-overflow=2
6494 Level @var{2} warns also about calls that might overflow the destination
6495 buffer given an argument of sufficient length or magnitude. At level
6496 @var{2}, unknown numeric arguments are assumed to have the minimum
6497 representable value for signed types with a precision greater than 1, and
6498 the maximum representable value otherwise. Unknown string arguments whose
6499 length cannot be assumed to be bounded either by the directive's precision,
6500 or by a finite set of string literals they may evaluate to, or the character
6501 array they may point to, are assumed to be 1 character long.
6503 At level @var{2}, the call in the example above is again diagnosed, but
6504 this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6505 @code{%i} directive will write some of its digits beyond the end of
6506 the destination buffer. To make the call safe regardless of the values
6507 of the two variables, the size of the destination buffer must be increased
6508 to at least 34 bytes. GCC includes the minimum size of the buffer in
6509 an informational note following the warning.
6511 An alternative to increasing the size of the destination buffer is to
6512 constrain the range of formatted values. The maximum length of string
6513 arguments can be bounded by specifying the precision in the format
6514 directive. When numeric arguments of format directives can be assumed
6515 to be bounded by less than the precision of their type, choosing
6516 an appropriate length modifier to the format specifier will reduce
6517 the required buffer size. For example, if @var{a} and @var{b} in the
6518 example above can be assumed to be within the precision of
6519 the @code{short int} type then using either the @code{%hi} format
6520 directive or casting the argument to @code{short} reduces the maximum
6521 required size of the buffer to 24 bytes.
6524 void f (int a, int b)
6527 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6532 @item -Wno-format-zero-length
6533 @opindex Wno-format-zero-length
6534 @opindex Wformat-zero-length
6535 If @option{-Wformat} is specified, do not warn about zero-length formats.
6536 The C standard specifies that zero-length formats are allowed.
6538 @item -Wformat-nonliteral
6539 @opindex Wformat-nonliteral
6540 @opindex Wno-format-nonliteral
6541 If @option{-Wformat} is specified, also warn if the format string is not a
6542 string literal and so cannot be checked, unless the format function
6543 takes its format arguments as a @code{va_list}.
6545 @item -Wformat-security
6546 @opindex Wformat-security
6547 @opindex Wno-format-security
6548 If @option{-Wformat} is specified, also warn about uses of format
6549 functions that represent possible security problems. At present, this
6550 warns about calls to @code{printf} and @code{scanf} functions where the
6551 format string is not a string literal and there are no format arguments,
6552 as in @code{printf (foo);}. This may be a security hole if the format
6553 string came from untrusted input and contains @samp{%n}. (This is
6554 currently a subset of what @option{-Wformat-nonliteral} warns about, but
6555 in future warnings may be added to @option{-Wformat-security} that are not
6556 included in @option{-Wformat-nonliteral}.)
6558 @item -Wformat-signedness
6559 @opindex Wformat-signedness
6560 @opindex Wno-format-signedness
6561 If @option{-Wformat} is specified, also warn if the format string
6562 requires an unsigned argument and the argument is signed and vice versa.
6564 @item -Wformat-truncation
6565 @itemx -Wformat-truncation=@var{level}
6566 @opindex Wformat-truncation
6567 @opindex Wno-format-truncation
6568 Warn about calls to formatted input/output functions such as @code{snprintf}
6569 and @code{vsnprintf} that might result in output truncation. When the exact
6570 number of bytes written by a format directive cannot be determined at
6571 compile-time it is estimated based on heuristics that depend on
6572 the @var{level} argument and on optimization. While enabling optimization
6573 will in most cases improve the accuracy of the warning, it may also result
6574 in false positives. Except as noted otherwise, the option uses the same
6575 logic @option{-Wformat-overflow}.
6578 @item -Wformat-truncation
6579 @itemx -Wformat-truncation=1
6580 @opindex Wformat-truncation
6581 @opindex Wno-format-truncation
6582 Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6583 employs a conservative approach that warns only about calls to bounded
6584 functions whose return value is unused and that will most likely result
6585 in output truncation.
6587 @item -Wformat-truncation=2
6588 Level @var{2} warns also about calls to bounded functions whose return
6589 value is used and that might result in truncation given an argument of
6590 sufficient length or magnitude.
6594 @opindex Wformat-y2k
6595 @opindex Wno-format-y2k
6596 If @option{-Wformat} is specified, also warn about @code{strftime}
6597 formats that may yield only a two-digit year.
6601 @opindex Wno-nonnull
6602 Warn about passing a null pointer for arguments marked as
6603 requiring a non-null value by the @code{nonnull} function attribute.
6605 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6606 can be disabled with the @option{-Wno-nonnull} option.
6608 @item -Wnonnull-compare
6609 @opindex Wnonnull-compare
6610 @opindex Wno-nonnull-compare
6611 Warn when comparing an argument marked with the @code{nonnull}
6612 function attribute against null inside the function.
6614 @option{-Wnonnull-compare} is included in @option{-Wall}. It
6615 can be disabled with the @option{-Wno-nonnull-compare} option.
6617 @item -Wnull-dereference
6618 @opindex Wnull-dereference
6619 @opindex Wno-null-dereference
6620 Warn if the compiler detects paths that trigger erroneous or
6621 undefined behavior due to dereferencing a null pointer. This option
6622 is only active when @option{-fdelete-null-pointer-checks} is active,
6623 which is enabled by optimizations in most targets. The precision of
6624 the warnings depends on the optimization options used.
6626 @item -Winfinite-recursion
6627 @opindex Winfinite-recursion
6628 @opindex Wno-infinite-recursion
6629 Warn about infinitely recursive calls. The warning is effective at all
6630 optimization levels but requires optimization in order to detect infinite
6631 recursion in calls between two or more functions.
6632 @option{-Winfinite-recursion} is included in @option{-Wall}.
6634 Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6635 similar diagnostic, but is implemented in a different way (as part of
6636 @option{-fanalyzer}).
6638 @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
6640 @opindex Wno-init-self
6641 Warn about uninitialized variables that are initialized with themselves.
6642 Note this option can only be used with the @option{-Wuninitialized} option.
6644 For example, GCC warns about @code{i} being uninitialized in the
6645 following snippet only when @option{-Winit-self} has been specified:
6656 This warning is enabled by @option{-Wall} in C++.
6658 @item -Wno-implicit-int @r{(C and Objective-C only)}
6659 @opindex Wimplicit-int
6660 @opindex Wno-implicit-int
6661 This option controls warnings when a declaration does not specify a type.
6662 This warning is enabled by default in C99 and later dialects of C,
6663 and also by @option{-Wall}.
6665 @item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
6666 @opindex Wimplicit-function-declaration
6667 @opindex Wno-implicit-function-declaration
6668 This option controls warnings when a function is used before being declared.
6669 This warning is enabled by default in C99 and later dialects of C,
6670 and also by @option{-Wall}.
6671 The warning is made into an error by @option{-pedantic-errors}.
6673 @item -Wimplicit @r{(C and Objective-C only)}
6675 @opindex Wno-implicit
6676 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6677 This warning is enabled by @option{-Wall}.
6679 @item -Wimplicit-fallthrough
6680 @opindex Wimplicit-fallthrough
6681 @opindex Wno-implicit-fallthrough
6682 @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6683 and @option{-Wno-implicit-fallthrough} is the same as
6684 @option{-Wimplicit-fallthrough=0}.
6686 @item -Wimplicit-fallthrough=@var{n}
6687 @opindex Wimplicit-fallthrough=
6688 Warn when a switch case falls through. For example:
6706 This warning does not warn when the last statement of a case cannot
6707 fall through, e.g. when there is a return statement or a call to function
6708 declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6709 also takes into account control flow statements, such as ifs, and only
6710 warns when appropriate. E.g.@:
6720 @} else if (i < 1) @{
6730 Since there are occasions where a switch case fall through is desirable,
6731 GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6732 to be used along with a null statement to suppress this warning that
6733 would normally occur:
6741 __attribute__ ((fallthrough));
6748 C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6749 warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6750 or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6751 Instead of these attributes, it is also possible to add a fallthrough comment
6752 to silence the warning. The whole body of the C or C++ style comment should
6753 match the given regular expressions listed below. The option argument @var{n}
6754 specifies what kind of comments are accepted:
6758 @item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6760 @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6761 expression, any comment is used as fallthrough comment.
6763 @item @option{-Wimplicit-fallthrough=2} case insensitively matches
6764 @code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6766 @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6767 following regular expressions:
6771 @item @code{-fallthrough}
6773 @item @code{@@fallthrough@@}
6775 @item @code{lint -fallthrough[ \t]*}
6777 @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6779 @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6781 @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6785 @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6786 following regular expressions:
6790 @item @code{-fallthrough}
6792 @item @code{@@fallthrough@@}
6794 @item @code{lint -fallthrough[ \t]*}
6796 @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6800 @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6801 fallthrough comments, only attributes disable the warning.
6805 The comment needs to be followed after optional whitespace and other comments
6806 by @code{case} or @code{default} keywords or by a user label that precedes some
6807 @code{case} or @code{default} label.
6822 The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
6824 @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
6825 @opindex Wif-not-aligned
6826 @opindex Wno-if-not-aligned
6827 Control if warnings triggered by the @code{warn_if_not_aligned} attribute
6828 should be issued. These warnings are enabled by default.
6830 @item -Wignored-qualifiers @r{(C and C++ only)}
6831 @opindex Wignored-qualifiers
6832 @opindex Wno-ignored-qualifiers
6833 Warn if the return type of a function has a type qualifier
6834 such as @code{const}. For ISO C such a type qualifier has no effect,
6835 since the value returned by a function is not an lvalue.
6836 For C++, the warning is only emitted for scalar types or @code{void}.
6837 ISO C prohibits qualified @code{void} return types on function
6838 definitions, so such return types always receive a warning
6839 even without this option.
6841 This warning is also enabled by @option{-Wextra}.
6843 @item -Wno-ignored-attributes @r{(C and C++ only)}
6844 @opindex Wignored-attributes
6845 @opindex Wno-ignored-attributes
6846 This option controls warnings when an attribute is ignored.
6847 This is different from the
6848 @option{-Wattributes} option in that it warns whenever the compiler decides
6849 to drop an attribute, not that the attribute is either unknown, used in a
6850 wrong place, etc. This warning is enabled by default.
6855 Warn if the type of @code{main} is suspicious. @code{main} should be
6856 a function with external linkage, returning int, taking either zero
6857 arguments, two, or three arguments of appropriate types. This warning
6858 is enabled by default in C++ and is enabled by either @option{-Wall}
6859 or @option{-Wpedantic}.
6861 @item -Wmisleading-indentation @r{(C and C++ only)}
6862 @opindex Wmisleading-indentation
6863 @opindex Wno-misleading-indentation
6864 Warn when the indentation of the code does not reflect the block structure.
6865 Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
6866 @code{for} clauses with a guarded statement that does not use braces,
6867 followed by an unguarded statement with the same indentation.
6869 In the following example, the call to ``bar'' is misleadingly indented as
6870 if it were guarded by the ``if'' conditional.
6873 if (some_condition ())
6875 bar (); /* Gotcha: this is not guarded by the "if". */
6878 In the case of mixed tabs and spaces, the warning uses the
6879 @option{-ftabstop=} option to determine if the statements line up
6882 The warning is not issued for code involving multiline preprocessor logic
6883 such as the following example.
6888 #if SOME_CONDITION_THAT_DOES_NOT_HOLD
6894 The warning is not issued after a @code{#line} directive, since this
6895 typically indicates autogenerated code, and no assumptions can be made
6896 about the layout of the file that the directive references.
6898 This warning is enabled by @option{-Wall} in C and C++.
6900 @item -Wmissing-attributes
6901 @opindex Wmissing-attributes
6902 @opindex Wno-missing-attributes
6903 Warn when a declaration of a function is missing one or more attributes
6904 that a related function is declared with and whose absence may adversely
6905 affect the correctness or efficiency of generated code. For example,
6906 the warning is issued for declarations of aliases that use attributes
6907 to specify less restrictive requirements than those of their targets.
6908 This typically represents a potential optimization opportunity.
6909 By contrast, the @option{-Wattribute-alias=2} option controls warnings
6910 issued when the alias is more restrictive than the target, which could
6911 lead to incorrect code generation.
6912 Attributes considered include @code{alloc_align}, @code{alloc_size},
6913 @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
6914 @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
6915 @code{returns_nonnull}, and @code{returns_twice}.
6917 In C++, the warning is issued when an explicit specialization of a primary
6918 template declared with attribute @code{alloc_align}, @code{alloc_size},
6919 @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
6920 or @code{nonnull} is declared without it. Attributes @code{deprecated},
6921 @code{error}, and @code{warning} suppress the warning.
6922 (@pxref{Function Attributes}).
6924 You can use the @code{copy} attribute to apply the same
6925 set of attributes to a declaration as that on another declaration without
6926 explicitly enumerating the attributes. This attribute can be applied
6927 to declarations of functions (@pxref{Common Function Attributes}),
6928 variables (@pxref{Common Variable Attributes}), or types
6929 (@pxref{Common Type Attributes}).
6931 @option{-Wmissing-attributes} is enabled by @option{-Wall}.
6933 For example, since the declaration of the primary function template
6934 below makes use of both attribute @code{malloc} and @code{alloc_size}
6935 the declaration of the explicit specialization of the template is
6936 diagnosed because it is missing one of the attributes.
6940 T* __attribute__ ((malloc, alloc_size (1)))
6944 void* __attribute__ ((malloc)) // missing alloc_size
6945 allocate<void> (size_t);
6948 @item -Wmissing-braces
6949 @opindex Wmissing-braces
6950 @opindex Wno-missing-braces
6951 Warn if an aggregate or union initializer is not fully bracketed. In
6952 the following example, the initializer for @code{a} is not fully
6953 bracketed, but that for @code{b} is fully bracketed.
6956 int a[2][2] = @{ 0, 1, 2, 3 @};
6957 int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
6960 This warning is enabled by @option{-Wall}.
6962 @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
6963 @opindex Wmissing-include-dirs
6964 @opindex Wno-missing-include-dirs
6965 Warn if a user-supplied include directory does not exist. This opions is disabled
6966 by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
6967 enabled by default by warning for -I and -J, only.
6969 @item -Wno-missing-profile
6970 @opindex Wmissing-profile
6971 @opindex Wno-missing-profile
6972 This option controls warnings if feedback profiles are missing when using the
6973 @option{-fprofile-use} option.
6974 This option diagnoses those cases where a new function or a new file is added
6975 between compiling with @option{-fprofile-generate} and with
6976 @option{-fprofile-use}, without regenerating the profiles.
6977 In these cases, the profile feedback data files do not contain any
6978 profile feedback information for
6979 the newly added function or file respectively. Also, in the case when profile
6980 count data (.gcda) files are removed, GCC cannot use any profile feedback
6981 information. In all these cases, warnings are issued to inform you that a
6982 profile generation step is due.
6983 Ignoring the warning can result in poorly optimized code.
6984 @option{-Wno-missing-profile} can be used to
6985 disable the warning, but this is not recommended and should be done only
6986 when non-existent profile data is justified.
6988 @item -Wmismatched-dealloc
6989 @opindex Wmismatched-dealloc
6990 @opindex Wno-mismatched-dealloc
6992 Warn for calls to deallocation functions with pointer arguments returned
6993 from from allocations functions for which the former isn't a suitable
6994 deallocator. A pair of functions can be associated as matching allocators
6995 and deallocators by use of attribute @code{malloc}. Unless disabled by
6996 the @option{-fno-builtin} option the standard functions @code{calloc},
6997 @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
6998 forms of C++ @code{operator new} and @code{operator delete} are implicitly
6999 associated as matching allocators and deallocators. In the following
7000 example @code{mydealloc} is the deallocator for pointers returned from
7004 void mydealloc (void*);
7006 __attribute__ ((malloc (mydealloc, 1))) void*
7011 void *p = myalloc (32);
7012 // @dots{}use p@dots{}
7013 free (p); // warning: not a matching deallocator for myalloc
7014 mydealloc (p); // ok
7018 In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7019 mismatches involving either @code{operator new} or @code{operator delete}.
7021 Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7023 @item -Wmultistatement-macros
7024 @opindex Wmultistatement-macros
7025 @opindex Wno-multistatement-macros
7026 Warn about unsafe multiple statement macros that appear to be guarded
7027 by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7028 @code{while}, in which only the first statement is actually guarded after
7029 the macro is expanded.
7034 #define DOIT x++; y++
7039 will increment @code{y} unconditionally, not just when @code{c} holds.
7040 The can usually be fixed by wrapping the macro in a do-while loop:
7042 #define DOIT do @{ x++; y++; @} while (0)
7047 This warning is enabled by @option{-Wall} in C and C++.
7050 @opindex Wparentheses
7051 @opindex Wno-parentheses
7052 Warn if parentheses are omitted in certain contexts, such
7053 as when there is an assignment in a context where a truth value
7054 is expected, or when operators are nested whose precedence people
7055 often get confused about.
7057 Also warn if a comparison like @code{x<=y<=z} appears; this is
7058 equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7059 interpretation from that of ordinary mathematical notation.
7061 Also warn for dangerous uses of the GNU extension to
7062 @code{?:} with omitted middle operand. When the condition
7063 in the @code{?}: operator is a boolean expression, the omitted value is
7064 always 1. Often programmers expect it to be a value computed
7065 inside the conditional expression instead.
7067 For C++ this also warns for some cases of unnecessary parentheses in
7068 declarations, which can indicate an attempt at a function call instead
7072 // Declares a local variable called mymutex.
7073 std::unique_lock<std::mutex> (mymutex);
7074 // User meant std::unique_lock<std::mutex> lock (mymutex);
7078 This warning is enabled by @option{-Wall}.
7080 @item -Wno-self-move @r{(C++ and Objective-C++ only)}
7082 @opindex Wno-self-move
7083 This warning warns when a value is moved to itself with @code{std::move}.
7084 Such a @code{std::move} typically has no effect.
7098 This warning is enabled by @option{-Wall}.
7100 @item -Wsequence-point
7101 @opindex Wsequence-point
7102 @opindex Wno-sequence-point
7103 Warn about code that may have undefined semantics because of violations
7104 of sequence point rules in the C and C++ standards.
7106 The C and C++ standards define the order in which expressions in a C/C++
7107 program are evaluated in terms of @dfn{sequence points}, which represent
7108 a partial ordering between the execution of parts of the program: those
7109 executed before the sequence point, and those executed after it. These
7110 occur after the evaluation of a full expression (one which is not part
7111 of a larger expression), after the evaluation of the first operand of a
7112 @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7113 function is called (but after the evaluation of its arguments and the
7114 expression denoting the called function), and in certain other places.
7115 Other than as expressed by the sequence point rules, the order of
7116 evaluation of subexpressions of an expression is not specified. All
7117 these rules describe only a partial order rather than a total order,
7118 since, for example, if two functions are called within one expression
7119 with no sequence point between them, the order in which the functions
7120 are called is not specified. However, the standards committee have
7121 ruled that function calls do not overlap.
7123 It is not specified when between sequence points modifications to the
7124 values of objects take effect. Programs whose behavior depends on this
7125 have undefined behavior; the C and C++ standards specify that ``Between
7126 the previous and next sequence point an object shall have its stored
7127 value modified at most once by the evaluation of an expression.
7128 Furthermore, the prior value shall be read only to determine the value
7129 to be stored.''. If a program breaks these rules, the results on any
7130 particular implementation are entirely unpredictable.
7132 Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7133 = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7134 diagnosed by this option, and it may give an occasional false positive
7135 result, but in general it has been found fairly effective at detecting
7136 this sort of problem in programs.
7138 The C++17 standard will define the order of evaluation of operands in
7139 more cases: in particular it requires that the right-hand side of an
7140 assignment be evaluated before the left-hand side, so the above
7141 examples are no longer undefined. But this option will still warn
7142 about them, to help people avoid writing code that is undefined in C
7143 and earlier revisions of C++.
7145 The standard is worded confusingly, therefore there is some debate
7146 over the precise meaning of the sequence point rules in subtle cases.
7147 Links to discussions of the problem, including proposed formal
7148 definitions, may be found on the GCC readings page, at
7149 @uref{https://gcc.gnu.org/@/readings.html}.
7151 This warning is enabled by @option{-Wall} for C and C++.
7153 @item -Wno-return-local-addr
7154 @opindex Wno-return-local-addr
7155 @opindex Wreturn-local-addr
7156 Do not warn about returning a pointer (or in C++, a reference) to a
7157 variable that goes out of scope after the function returns.
7160 @opindex Wreturn-type
7161 @opindex Wno-return-type
7162 Warn whenever a function is defined with a return type that defaults
7163 to @code{int}. Also warn about any @code{return} statement with no
7164 return value in a function whose return type is not @code{void}
7165 (falling off the end of the function body is considered returning
7168 For C only, warn about a @code{return} statement with an expression in a
7169 function whose return type is @code{void}, unless the expression type is
7170 also @code{void}. As a GNU extension, the latter case is accepted
7171 without a warning unless @option{-Wpedantic} is used. Attempting
7172 to use the return value of a non-@code{void} function other than @code{main}
7173 that flows off the end by reaching the closing curly brace that terminates
7174 the function is undefined.
7176 Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7177 than @code{main} results in undefined behavior even when the value of
7178 the function is not used.
7180 This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7182 @item -Wno-shift-count-negative
7183 @opindex Wshift-count-negative
7184 @opindex Wno-shift-count-negative
7185 Controls warnings if a shift count is negative.
7186 This warning is enabled by default.
7188 @item -Wno-shift-count-overflow
7189 @opindex Wshift-count-overflow
7190 @opindex Wno-shift-count-overflow
7191 Controls warnings if a shift count is greater than or equal to the bit width
7192 of the type. This warning is enabled by default.
7194 @item -Wshift-negative-value
7195 @opindex Wshift-negative-value
7196 @opindex Wno-shift-negative-value
7197 Warn if left shifting a negative value. This warning is enabled by
7198 @option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7200 @item -Wno-shift-overflow
7201 @itemx -Wshift-overflow=@var{n}
7202 @opindex Wshift-overflow
7203 @opindex Wno-shift-overflow
7204 These options control warnings about left shift overflows.
7207 @item -Wshift-overflow=1
7208 This is the warning level of @option{-Wshift-overflow} and is enabled
7209 by default in C99 and C++11 modes (and newer). This warning level does
7210 not warn about left-shifting 1 into the sign bit. (However, in C, such
7211 an overflow is still rejected in contexts where an integer constant expression
7212 is required.) No warning is emitted in C++20 mode (and newer), as signed left
7215 @item -Wshift-overflow=2
7216 This warning level also warns about left-shifting 1 into the sign bit,
7217 unless C++14 mode (or newer) is active.
7223 Warn whenever a @code{switch} statement has an index of enumerated type
7224 and lacks a @code{case} for one or more of the named codes of that
7225 enumeration. (The presence of a @code{default} label prevents this
7226 warning.) @code{case} labels outside the enumeration range also
7227 provoke warnings when this option is used (even if there is a
7228 @code{default} label).
7229 This warning is enabled by @option{-Wall}.
7231 @item -Wswitch-default
7232 @opindex Wswitch-default
7233 @opindex Wno-switch-default
7234 Warn whenever a @code{switch} statement does not have a @code{default}
7238 @opindex Wswitch-enum
7239 @opindex Wno-switch-enum
7240 Warn whenever a @code{switch} statement has an index of enumerated type
7241 and lacks a @code{case} for one or more of the named codes of that
7242 enumeration. @code{case} labels outside the enumeration range also
7243 provoke warnings when this option is used. The only difference
7244 between @option{-Wswitch} and this option is that this option gives a
7245 warning about an omitted enumeration code even if there is a
7246 @code{default} label.
7248 @item -Wno-switch-bool
7249 @opindex Wswitch-bool
7250 @opindex Wno-switch-bool
7251 Do not warn when a @code{switch} statement has an index of boolean type
7252 and the case values are outside the range of a boolean type.
7253 It is possible to suppress this warning by casting the controlling
7254 expression to a type other than @code{bool}. For example:
7257 switch ((int) (a == 4))
7263 This warning is enabled by default for C and C++ programs.
7265 @item -Wno-switch-outside-range
7266 @opindex Wswitch-outside-range
7267 @opindex Wno-switch-outside-range
7268 This option controls warnings when a @code{switch} case has a value
7269 that is outside of its
7270 respective type range. This warning is enabled by default for
7273 @item -Wno-switch-unreachable
7274 @opindex Wswitch-unreachable
7275 @opindex Wno-switch-unreachable
7276 Do not warn when a @code{switch} statement contains statements between the
7277 controlling expression and the first case label, which will never be
7278 executed. For example:
7290 @option{-Wswitch-unreachable} does not warn if the statement between the
7291 controlling expression and the first case label is just a declaration:
7304 This warning is enabled by default for C and C++ programs.
7306 @item -Wsync-nand @r{(C and C++ only)}
7308 @opindex Wno-sync-nand
7309 Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7310 built-in functions are used. These functions changed semantics in GCC 4.4.
7312 @item -Wtrivial-auto-var-init
7313 @opindex Wtrivial-auto-var-init
7314 @opindex Wno-trivial-auto-var-init
7315 Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7316 variable. A common situation is an automatic variable that is declared
7317 between the controlling expression and the first case label of a @code{switch}
7320 @item -Wunused-but-set-parameter
7321 @opindex Wunused-but-set-parameter
7322 @opindex Wno-unused-but-set-parameter
7323 Warn whenever a function parameter is assigned to, but otherwise unused
7324 (aside from its declaration).
7326 To suppress this warning use the @code{unused} attribute
7327 (@pxref{Variable Attributes}).
7329 This warning is also enabled by @option{-Wunused} together with
7332 @item -Wunused-but-set-variable
7333 @opindex Wunused-but-set-variable
7334 @opindex Wno-unused-but-set-variable
7335 Warn whenever a local variable is assigned to, but otherwise unused
7336 (aside from its declaration).
7337 This warning is enabled by @option{-Wall}.
7339 To suppress this warning use the @code{unused} attribute
7340 (@pxref{Variable Attributes}).
7342 This warning is also enabled by @option{-Wunused}, which is enabled
7345 @item -Wunused-function
7346 @opindex Wunused-function
7347 @opindex Wno-unused-function
7348 Warn whenever a static function is declared but not defined or a
7349 non-inline static function is unused.
7350 This warning is enabled by @option{-Wall}.
7352 @item -Wunused-label
7353 @opindex Wunused-label
7354 @opindex Wno-unused-label
7355 Warn whenever a label is declared but not used.
7356 This warning is enabled by @option{-Wall}.
7358 To suppress this warning use the @code{unused} attribute
7359 (@pxref{Variable Attributes}).
7361 @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
7362 @opindex Wunused-local-typedefs
7363 @opindex Wno-unused-local-typedefs
7364 Warn when a typedef locally defined in a function is not used.
7365 This warning is enabled by @option{-Wall}.
7367 @item -Wunused-parameter
7368 @opindex Wunused-parameter
7369 @opindex Wno-unused-parameter
7370 Warn whenever a function parameter is unused aside from its declaration.
7372 To suppress this warning use the @code{unused} attribute
7373 (@pxref{Variable Attributes}).
7375 @item -Wno-unused-result
7376 @opindex Wunused-result
7377 @opindex Wno-unused-result
7378 Do not warn if a caller of a function marked with attribute
7379 @code{warn_unused_result} (@pxref{Function Attributes}) does not use
7380 its return value. The default is @option{-Wunused-result}.
7382 @item -Wunused-variable
7383 @opindex Wunused-variable
7384 @opindex Wno-unused-variable
7385 Warn whenever a local or static variable is unused aside from its
7386 declaration. This option implies @option{-Wunused-const-variable=1} for C,
7387 but not for C++. This warning is enabled by @option{-Wall}.
7389 To suppress this warning use the @code{unused} attribute
7390 (@pxref{Variable Attributes}).
7392 @item -Wunused-const-variable
7393 @itemx -Wunused-const-variable=@var{n}
7394 @opindex Wunused-const-variable
7395 @opindex Wno-unused-const-variable
7396 Warn whenever a constant static variable is unused aside from its declaration.
7397 @option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7398 for C, but not for C++. In C this declares variable storage, but in C++ this
7399 is not an error since const variables take the place of @code{#define}s.
7401 To suppress this warning use the @code{unused} attribute
7402 (@pxref{Variable Attributes}).
7405 @item -Wunused-const-variable=1
7406 This is the warning level that is enabled by @option{-Wunused-variable} for
7407 C. It warns only about unused static const variables defined in the main
7408 compilation unit, but not about static const variables declared in any
7411 @item -Wunused-const-variable=2
7412 This warning level also warns for unused constant static variables in
7413 headers (excluding system headers). This is the warning level of
7414 @option{-Wunused-const-variable} and must be explicitly requested since
7415 in C++ this isn't an error and in C it might be harder to clean up all
7419 @item -Wunused-value
7420 @opindex Wunused-value
7421 @opindex Wno-unused-value
7422 Warn whenever a statement computes a result that is explicitly not
7423 used. To suppress this warning cast the unused expression to
7424 @code{void}. This includes an expression-statement or the left-hand
7425 side of a comma expression that contains no side effects. For example,
7426 an expression such as @code{x[i,j]} causes a warning, while
7427 @code{x[(void)i,j]} does not.
7429 This warning is enabled by @option{-Wall}.
7434 All the above @option{-Wunused} options combined.
7436 In order to get a warning about an unused function parameter, you must
7437 either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7438 @option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7440 @item -Wuninitialized
7441 @opindex Wuninitialized
7442 @opindex Wno-uninitialized
7443 Warn if an object with automatic or allocated storage duration is used
7444 without having been initialized. In C++, also warn if a non-static
7445 reference or non-static @code{const} member appears in a class without
7448 In addition, passing a pointer (or in C++, a reference) to an uninitialized
7449 object to a @code{const}-qualified argument of a built-in function known to
7450 read the object is also diagnosed by this warning.
7451 (@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7453 If you want to warn about code that uses the uninitialized value of the
7454 variable in its own initializer, use the @option{-Winit-self} option.
7456 These warnings occur for individual uninitialized elements of
7457 structure, union or array variables as well as for variables that are
7458 uninitialized as a whole. They do not occur for variables or elements
7459 declared @code{volatile}. Because these warnings depend on
7460 optimization, the exact variables or elements for which there are
7461 warnings depend on the precise optimization options and version of GCC
7464 Note that there may be no warning about a variable that is used only
7465 to compute a value that itself is never used, because such
7466 computations may be deleted by data flow analysis before the warnings
7469 In C++, this warning also warns about using uninitialized objects in
7470 member-initializer-lists. For example, GCC warns about @code{b} being
7471 uninitialized in the following snippet:
7481 @item -Wno-invalid-memory-model
7482 @opindex Winvalid-memory-model
7483 @opindex Wno-invalid-memory-model
7484 This option controls warnings
7485 for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7486 and the C11 atomic generic functions with a memory consistency argument
7487 that is either invalid for the operation or outside the range of values
7488 of the @code{memory_order} enumeration. For example, since the
7489 @code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7490 defined for the relaxed, release, and sequentially consistent memory
7491 orders the following code is diagnosed:
7496 __atomic_store_n (i, 0, memory_order_consume);
7500 @option{-Winvalid-memory-model} is enabled by default.
7502 @item -Wmaybe-uninitialized
7503 @opindex Wmaybe-uninitialized
7504 @opindex Wno-maybe-uninitialized
7505 For an object with automatic or allocated storage duration, if there exists
7506 a path from the function entry to a use of the object that is initialized,
7507 but there exist some other paths for which the object is not initialized,
7508 the compiler emits a warning if it cannot prove the uninitialized paths
7509 are not executed at run time.
7511 In addition, passing a pointer (or in C++, a reference) to an uninitialized
7512 object to a @code{const}-qualified function argument is also diagnosed by
7513 this warning. (@option{-Wuninitialized} is issued for built-in functions
7514 known to read the object.) Annotating the function with attribute
7515 @code{access (none)} indicates that the argument isn't used to access
7516 the object and avoids the warning (@pxref{Common Function Attributes}).
7518 These warnings are only possible in optimizing compilation, because otherwise
7519 GCC does not keep track of the state of variables.
7521 These warnings are made optional because GCC may not be able to determine when
7522 the code is correct in spite of appearing to have an error. Here is one
7523 example of how this can happen:
7543 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7544 always initialized, but GCC doesn't know this. To suppress the
7545 warning, you need to provide a default case with assert(0) or
7548 @cindex @code{longjmp} warnings
7549 This option also warns when a non-volatile automatic variable might be
7550 changed by a call to @code{longjmp}.
7551 The compiler sees only the calls to @code{setjmp}. It cannot know
7552 where @code{longjmp} will be called; in fact, a signal handler could
7553 call it at any point in the code. As a result, you may get a warning
7554 even when there is in fact no problem because @code{longjmp} cannot
7555 in fact be called at the place that would cause a problem.
7557 Some spurious warnings can be avoided if you declare all the functions
7558 you use that never return as @code{noreturn}. @xref{Function
7561 This warning is enabled by @option{-Wall} or @option{-Wextra}.
7563 @item -Wunknown-pragmas
7564 @opindex Wunknown-pragmas
7565 @opindex Wno-unknown-pragmas
7566 @cindex warning for unknown pragmas
7567 @cindex unknown pragmas, warning
7568 @cindex pragmas, warning of unknown
7569 Warn when a @code{#pragma} directive is encountered that is not understood by
7570 GCC@. If this command-line option is used, warnings are even issued
7571 for unknown pragmas in system header files. This is not the case if
7572 the warnings are only enabled by the @option{-Wall} command-line option.
7575 @opindex Wno-pragmas
7577 Do not warn about misuses of pragmas, such as incorrect parameters,
7578 invalid syntax, or conflicts between pragmas. See also
7579 @option{-Wunknown-pragmas}.
7581 @item -Wno-prio-ctor-dtor
7582 @opindex Wno-prio-ctor-dtor
7583 @opindex Wprio-ctor-dtor
7584 Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7585 The use of constructor and destructor attributes allow you to assign a
7586 priority to the constructor/destructor to control its order of execution
7587 before @code{main} is called or after it returns. The priority values must be
7588 greater than 100 as the compiler reserves priority values between 0--100 for
7591 @item -Wstrict-aliasing
7592 @opindex Wstrict-aliasing
7593 @opindex Wno-strict-aliasing
7594 This option is only active when @option{-fstrict-aliasing} is active.
7595 It warns about code that might break the strict aliasing rules that the
7596 compiler is using for optimization. The warning does not catch all
7597 cases, but does attempt to catch the more common pitfalls. It is
7598 included in @option{-Wall}.
7599 It is equivalent to @option{-Wstrict-aliasing=3}
7601 @item -Wstrict-aliasing=n
7602 @opindex Wstrict-aliasing=n
7603 This option is only active when @option{-fstrict-aliasing} is active.
7604 It warns about code that might break the strict aliasing rules that the
7605 compiler is using for optimization.
7606 Higher levels correspond to higher accuracy (fewer false positives).
7607 Higher levels also correspond to more effort, similar to the way @option{-O}
7609 @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7611 Level 1: Most aggressive, quick, least accurate.
7612 Possibly useful when higher levels
7613 do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7614 false negatives. However, it has many false positives.
7615 Warns for all pointer conversions between possibly incompatible types,
7616 even if never dereferenced. Runs in the front end only.
7618 Level 2: Aggressive, quick, not too precise.
7619 May still have many false positives (not as many as level 1 though),
7620 and few false negatives (but possibly more than level 1).
7621 Unlike level 1, it only warns when an address is taken. Warns about
7622 incomplete types. Runs in the front end only.
7624 Level 3 (default for @option{-Wstrict-aliasing}):
7625 Should have very few false positives and few false
7626 negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7627 Takes care of the common pun+dereference pattern in the front end:
7628 @code{*(int*)&some_float}.
7629 If optimization is enabled, it also runs in the back end, where it deals
7630 with multiple statement cases using flow-sensitive points-to information.
7631 Only warns when the converted pointer is dereferenced.
7632 Does not warn about incomplete types.
7634 @item -Wstrict-overflow
7635 @itemx -Wstrict-overflow=@var{n}
7636 @opindex Wstrict-overflow
7637 @opindex Wno-strict-overflow
7638 This option is only active when signed overflow is undefined.
7639 It warns about cases where the compiler optimizes based on the
7640 assumption that signed overflow does not occur. Note that it does not
7641 warn about all cases where the code might overflow: it only warns
7642 about cases where the compiler implements some optimization. Thus
7643 this warning depends on the optimization level.
7645 An optimization that assumes that signed overflow does not occur is
7646 perfectly safe if the values of the variables involved are such that
7647 overflow never does, in fact, occur. Therefore this warning can
7648 easily give a false positive: a warning about code that is not
7649 actually a problem. To help focus on important issues, several
7650 warning levels are defined. No warnings are issued for the use of
7651 undefined signed overflow when estimating how many iterations a loop
7652 requires, in particular when determining whether a loop will be
7656 @item -Wstrict-overflow=1
7657 Warn about cases that are both questionable and easy to avoid. For
7658 example the compiler simplifies
7659 @code{x + 1 > x} to @code{1}. This level of
7660 @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7661 are not, and must be explicitly requested.
7663 @item -Wstrict-overflow=2
7664 Also warn about other cases where a comparison is simplified to a
7665 constant. For example: @code{abs (x) >= 0}. This can only be
7666 simplified when signed integer overflow is undefined, because
7667 @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7668 zero. @option{-Wstrict-overflow} (with no level) is the same as
7669 @option{-Wstrict-overflow=2}.
7671 @item -Wstrict-overflow=3
7672 Also warn about other cases where a comparison is simplified. For
7673 example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7675 @item -Wstrict-overflow=4
7676 Also warn about other simplifications not covered by the above cases.
7677 For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7679 @item -Wstrict-overflow=5
7680 Also warn about cases where the compiler reduces the magnitude of a
7681 constant involved in a comparison. For example: @code{x + 2 > y} is
7682 simplified to @code{x + 1 >= y}. This is reported only at the
7683 highest warning level because this simplification applies to many
7684 comparisons, so this warning level gives a very large number of
7688 @item -Wstring-compare
7689 @opindex Wstring-compare
7690 @opindex Wno-string-compare
7691 Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7692 determined to be either zero or non-zero in tests for such equality
7693 owing to the length of one argument being greater than the size of
7694 the array the other argument is stored in (or the bound in the case
7695 of @code{strncmp}). Such calls could be mistakes. For example,
7696 the call to @code{strcmp} below is diagnosed because its result is
7697 necessarily non-zero irrespective of the contents of the array @code{a}.
7703 strcpy (d, "string");
7705 if (0 == strcmp (a, d)) // cannot be true
7706 puts ("a and d are the same");
7710 @option{-Wstring-compare} is enabled by @option{-Wextra}.
7712 @item -Wno-stringop-overflow
7713 @item -Wstringop-overflow
7714 @itemx -Wstringop-overflow=@var{type}
7715 @opindex Wstringop-overflow
7716 @opindex Wno-stringop-overflow
7717 Warn for calls to string manipulation functions such as @code{memcpy} and
7718 @code{strcpy} that are determined to overflow the destination buffer. The
7719 optional argument is one greater than the type of Object Size Checking to
7720 perform to determine the size of the destination. @xref{Object Size Checking}.
7721 The argument is meaningful only for functions that operate on character arrays
7722 but not for raw memory functions like @code{memcpy} which always make use
7723 of Object Size type-0. The option also warns for calls that specify a size
7724 in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7725 The option produces the best results with optimization enabled but can detect
7726 a small subset of simple buffer overflows even without optimization in
7727 calls to the GCC built-in functions like @code{__builtin_memcpy} that
7728 correspond to the standard functions. In any case, the option warns about
7729 just a subset of buffer overflows detected by the corresponding overflow
7730 checking built-ins. For example, the option issues a warning for
7731 the @code{strcpy} call below because it copies at least 5 characters
7732 (the string @code{"blue"} including the terminating NUL) into the buffer
7736 enum Color @{ blue, purple, yellow @};
7737 const char* f (enum Color clr)
7739 static char buf [4];
7743 case blue: str = "blue"; break;
7744 case purple: str = "purple"; break;
7745 case yellow: str = "yellow"; break;
7748 return strcpy (buf, str); // warning here
7752 Option @option{-Wstringop-overflow=2} is enabled by default.
7755 @item -Wstringop-overflow
7756 @itemx -Wstringop-overflow=1
7757 @opindex Wstringop-overflow
7758 @opindex Wno-stringop-overflow
7759 The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7760 to determine the sizes of destination objects. At this setting the option
7761 does not warn for writes past the end of subobjects of larger objects accessed
7762 by pointers unless the size of the largest surrounding object is known. When
7763 the destination may be one of several objects it is assumed to be the largest
7764 one of them. On Linux systems, when optimization is enabled at this setting
7765 the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7766 is defined to a non-zero value.
7768 @item -Wstringop-overflow=2
7769 The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7770 to determine the sizes of destination objects. At this setting the option
7771 warns about overflows when writing to members of the largest complete
7772 objects whose exact size is known. However, it does not warn for excessive
7773 writes to the same members of unknown objects referenced by pointers since
7774 they may point to arrays containing unknown numbers of elements. This is
7775 the default setting of the option.
7777 @item -Wstringop-overflow=3
7778 The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7779 to determine the sizes of destination objects. At this setting the option
7780 warns about overflowing the smallest object or data member. This is the
7781 most restrictive setting of the option that may result in warnings for safe
7784 @item -Wstringop-overflow=4
7785 The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7786 to determine the sizes of destination objects. At this setting the option
7787 warns about overflowing any data members, and when the destination is
7788 one of several objects it uses the size of the largest of them to decide
7789 whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7790 setting of the option may result in warnings for benign code.
7793 @item -Wno-stringop-overread
7794 @opindex Wstringop-overread
7795 @opindex Wno-stringop-overread
7796 Warn for calls to string manipulation functions such as @code{memchr}, or
7797 @code{strcpy} that are determined to read past the end of the source
7800 Option @option{-Wstringop-overread} is enabled by default.
7802 @item -Wno-stringop-truncation
7803 @opindex Wstringop-truncation
7804 @opindex Wno-stringop-truncation
7805 Do not warn for calls to bounded string manipulation functions
7806 such as @code{strncat},
7807 @code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7808 or leave the destination unchanged.
7810 In the following example, the call to @code{strncat} specifies a bound that
7811 is less than the length of the source string. As a result, the copy of
7812 the source will be truncated and so the call is diagnosed. To avoid the
7813 warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7816 void append (char *buf, size_t bufsize)
7818 strncat (buf, ".txt", 3);
7822 As another example, the following call to @code{strncpy} results in copying
7823 to @code{d} just the characters preceding the terminating NUL, without
7824 appending the NUL to the end. Assuming the result of @code{strncpy} is
7825 necessarily a NUL-terminated string is a common mistake, and so the call
7826 is diagnosed. To avoid the warning when the result is not expected to be
7827 NUL-terminated, call @code{memcpy} instead.
7830 void copy (char *d, const char *s)
7832 strncpy (d, s, strlen (s));
7836 In the following example, the call to @code{strncpy} specifies the size
7837 of the destination buffer as the bound. If the length of the source
7838 string is equal to or greater than this size the result of the copy will
7839 not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
7840 the warning, specify @code{sizeof buf - 1} as the bound and set the last
7841 element of the buffer to @code{NUL}.
7844 void copy (const char *s)
7847 strncpy (buf, s, sizeof buf);
7852 In situations where a character array is intended to store a sequence
7853 of bytes with no terminating @code{NUL} such an array may be annotated
7854 with attribute @code{nonstring} to avoid this warning. Such arrays,
7855 however, are not suitable arguments to functions that expect
7856 @code{NUL}-terminated strings. To help detect accidental misuses of
7857 such arrays GCC issues warnings unless it can prove that the use is
7858 safe. @xref{Common Variable Attributes}.
7860 @item -Wstrict-flex-arrays
7861 @opindex Wstrict-flex-arrays
7862 @opindex Wno-strict-flex-arrays
7863 Warn about inproper usages of flexible array members
7864 according to the @var{level} of the @code{strict_flex_array (@var{level})}
7865 attribute attached to the trailing array field of a structure if it's
7866 available, otherwise according to the @var{level} of the option
7867 @option{-fstrict-flex-arrays=@var{level}}.
7869 This option is effective only when @var{level} is bigger than 0. Otherwise,
7870 it will be ignored with a warning.
7872 when @var{level}=1, warnings will be issued for a trailing array reference
7873 of a structure that have 2 or more elements if the trailing array is referenced
7874 as a flexible array member.
7876 when @var{level}=2, in addition to @var{level}=1, additional warnings will be
7877 issued for a trailing one-element array reference of a structure
7878 if the array is referenced as a flexible array member.
7880 when @var{level}=3, in addition to @var{level}=2, additional warnings will be
7881 issued for a trailing zero-length array reference of a structure
7882 if the array is referenced as a flexible array member.
7885 @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
7886 @opindex Wsuggest-attribute=
7887 @opindex Wno-suggest-attribute=
7888 Warn for cases where adding an attribute may be beneficial. The
7889 attributes currently supported are listed below.
7892 @item -Wsuggest-attribute=pure
7893 @itemx -Wsuggest-attribute=const
7894 @itemx -Wsuggest-attribute=noreturn
7895 @itemx -Wmissing-noreturn
7896 @itemx -Wsuggest-attribute=malloc
7897 @opindex Wsuggest-attribute=pure
7898 @opindex Wno-suggest-attribute=pure
7899 @opindex Wsuggest-attribute=const
7900 @opindex Wno-suggest-attribute=const
7901 @opindex Wsuggest-attribute=noreturn
7902 @opindex Wno-suggest-attribute=noreturn
7903 @opindex Wmissing-noreturn
7904 @opindex Wno-missing-noreturn
7905 @opindex Wsuggest-attribute=malloc
7906 @opindex Wno-suggest-attribute=malloc
7908 Warn about functions that might be candidates for attributes
7909 @code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
7910 only warns for functions visible in other compilation units or (in the case of
7911 @code{pure} and @code{const}) if it cannot prove that the function returns
7912 normally. A function returns normally if it doesn't contain an infinite loop or
7913 return abnormally by throwing, calling @code{abort} or trapping. This analysis
7914 requires option @option{-fipa-pure-const}, which is enabled by default at
7915 @option{-O} and higher. Higher optimization levels improve the accuracy
7918 @item -Wsuggest-attribute=format
7919 @itemx -Wmissing-format-attribute
7920 @opindex Wsuggest-attribute=format
7921 @opindex Wmissing-format-attribute
7922 @opindex Wno-suggest-attribute=format
7923 @opindex Wno-missing-format-attribute
7927 Warn about function pointers that might be candidates for @code{format}
7928 attributes. Note these are only possible candidates, not absolute ones.
7929 GCC guesses that function pointers with @code{format} attributes that
7930 are used in assignment, initialization, parameter passing or return
7931 statements should have a corresponding @code{format} attribute in the
7932 resulting type. I.e.@: the left-hand side of the assignment or
7933 initialization, the type of the parameter variable, or the return type
7934 of the containing function respectively should also have a @code{format}
7935 attribute to avoid the warning.
7937 GCC also warns about function definitions that might be
7938 candidates for @code{format} attributes. Again, these are only
7939 possible candidates. GCC guesses that @code{format} attributes
7940 might be appropriate for any function that calls a function like
7941 @code{vprintf} or @code{vscanf}, but this might not always be the
7942 case, and some functions for which @code{format} attributes are
7943 appropriate may not be detected.
7945 @item -Wsuggest-attribute=cold
7946 @opindex Wsuggest-attribute=cold
7947 @opindex Wno-suggest-attribute=cold
7949 Warn about functions that might be candidates for @code{cold} attribute. This
7950 is based on static detection and generally only warns about functions which
7951 always leads to a call to another @code{cold} function such as wrappers of
7952 C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
7956 @opindex Wno-alloc-zero
7957 @opindex Walloc-zero
7958 Warn about calls to allocation functions decorated with attribute
7959 @code{alloc_size} that specify zero bytes, including those to the built-in
7960 forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
7961 @code{malloc}, and @code{realloc}. Because the behavior of these functions
7962 when called with a zero size differs among implementations (and in the case
7963 of @code{realloc} has been deprecated) relying on it may result in subtle
7964 portability bugs and should be avoided.
7966 @item -Walloc-size-larger-than=@var{byte-size}
7967 @opindex Walloc-size-larger-than=
7968 @opindex Wno-alloc-size-larger-than
7969 Warn about calls to functions decorated with attribute @code{alloc_size}
7970 that attempt to allocate objects larger than the specified number of bytes,
7971 or where the result of the size computation in an integer type with infinite
7972 precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
7973 @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
7974 Warnings controlled by the option can be disabled either by specifying
7975 @var{byte-size} of @samp{SIZE_MAX} or more or by
7976 @option{-Wno-alloc-size-larger-than}.
7977 @xref{Function Attributes}.
7979 @item -Wno-alloc-size-larger-than
7980 @opindex Wno-alloc-size-larger-than
7981 Disable @option{-Walloc-size-larger-than=} warnings. The option is
7982 equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
7988 This option warns on all uses of @code{alloca} in the source.
7990 @item -Walloca-larger-than=@var{byte-size}
7991 @opindex Walloca-larger-than=
7992 @opindex Wno-alloca-larger-than
7993 This option warns on calls to @code{alloca} with an integer argument whose
7994 value is either zero, or that is not bounded by a controlling predicate
7995 that limits its value to at most @var{byte-size}. It also warns for calls
7996 to @code{alloca} where the bound value is unknown. Arguments of non-integer
7997 types are considered unbounded even if they appear to be constrained to
8000 For example, a bounded case of @code{alloca} could be:
8003 void func (size_t n)
8014 In the above example, passing @code{-Walloca-larger-than=1000} would not
8015 issue a warning because the call to @code{alloca} is known to be at most
8016 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8017 the compiler would emit a warning.
8019 Unbounded uses, on the other hand, are uses of @code{alloca} with no
8020 controlling predicate constraining its integer argument. For example:
8025 void *p = alloca (n);
8030 If @code{-Walloca-larger-than=500} were passed, the above would trigger
8031 a warning, but this time because of the lack of bounds checking.
8033 Note, that even seemingly correct code involving signed integers could
8037 void func (signed int n)
8047 In the above example, @var{n} could be negative, causing a larger than
8048 expected argument to be implicitly cast into the @code{alloca} call.
8050 This option also warns when @code{alloca} is used in a loop.
8052 @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8053 but is usually only effective when @option{-ftree-vrp} is active (default
8054 for @option{-O2} and above).
8056 See also @option{-Wvla-larger-than=}@samp{byte-size}.
8058 @item -Wno-alloca-larger-than
8059 @opindex Wno-alloca-larger-than
8060 Disable @option{-Walloca-larger-than=} warnings. The option is
8061 equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8063 @item -Warith-conversion
8064 @opindex Warith-conversion
8065 @opindex Wno-arith-conversion
8066 Do warn about implicit conversions from arithmetic operations even
8067 when conversion of the operands to the same type cannot change their
8068 values. This affects warnings from @option{-Wconversion},
8069 @option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8073 void f (char c, int i)
8075 c = c + i; // warns with @option{-Wconversion}
8076 c = c + 1; // only warns with @option{-Warith-conversion}
8081 @item -Warray-bounds
8082 @itemx -Warray-bounds=@var{n}
8083 @opindex Wno-array-bounds
8084 @opindex Warray-bounds
8085 Warn about out of bounds subscripts or offsets into arrays. This warning
8086 is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8087 is active (the default for @option{-O2} and above) but a subset of instances
8088 are issued even without optimization.
8090 By default, the trailing array of a structure will be treated as a flexible
8091 array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8092 if it is declared as either a flexible array member per C99 standard onwards
8093 (@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8094 array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8095 zero-length arrays or one-element arrays are not warned by default.
8097 You can add the option @option{-fstrict-flex-arrays} or
8098 @option{-fstrict-flex-arrays=@var{level}} to control how this
8099 option treat trailing array of a structure as a flexible array member:
8101 when @var{level}<=1, no change to the default behavior.
8103 when @var{level}=2, additional warnings will be issued for out of bounds
8104 subscripts or offsets into one-element arrays;
8106 when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8107 issued for out of bounds subscripts or offsets into zero-length arrays.
8110 @item -Warray-bounds=1
8111 This is the default warning level of @option{-Warray-bounds} and is enabled
8112 by @option{-Wall}; higher levels are not, and must be explicitly requested.
8114 @item -Warray-bounds=2
8115 This warning level also warns about the intermediate results of pointer
8116 arithmetic that may yield out of bounds values. This warning level may
8117 give a larger number of false positives and is deactivated by default.
8120 @item -Warray-compare
8121 @opindex Warray-compare
8122 @opindex Wno-array-compare
8123 Warn about equality and relational comparisons between two operands of array
8124 type. This comparison was deprecated in C++20. For example:
8129 bool same = arr1 == arr2;
8132 @option{-Warray-compare} is enabled by @option{-Wall}.
8134 @item -Warray-parameter
8135 @itemx -Warray-parameter=@var{n}
8136 @opindex Wno-array-parameter
8137 Warn about redeclarations of functions involving arguments of array or
8138 pointer types of inconsistent kinds or forms, and enable the detection
8139 of out-of-bounds accesses to such parameters by warnings such as
8140 @option{-Warray-bounds}.
8142 If the first function declaration uses the array form the bound specified
8143 in the array is assumed to be the minimum number of elements expected to
8144 be provided in calls to the function and the maximum number of elements
8145 accessed by it. Failing to provide arguments of sufficient size or accessing
8146 more than the maximum number of elements may be diagnosed by warnings such
8147 as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8148 involving array parameters declared using the @code{T[static N]} form.
8150 For example, the warning triggers for the following redeclarations because
8151 the first one allows an array of any size to be passed to @code{f} while
8152 the second one with the keyword @code{static} specifies that the array
8153 argument must have at least four elements.
8156 void f (int[static 4]);
8157 void f (int[]); // warning (inconsistent array form)
8161 int *p = (int *)malloc (4);
8162 f (p); // warning (array too small)
8167 At level 2 the warning also triggers for redeclarations involving any other
8168 inconsistency in array or pointer argument forms denoting array sizes.
8169 Pointers and arrays of unspecified bound are considered equivalent and do
8170 not trigger a warning.
8174 void g (int[]); // no warning
8175 void g (int[8]); // warning (inconsistent array bound)
8178 @option{-Warray-parameter=2} is included in @option{-Wall}. The
8179 @option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8180 involving Variable Length Array arguments.
8182 @item -Wattribute-alias=@var{n}
8183 @itemx -Wno-attribute-alias
8184 @opindex Wattribute-alias
8185 @opindex Wno-attribute-alias
8186 Warn about declarations using the @code{alias} and similar attributes whose
8187 target is incompatible with the type of the alias.
8188 @xref{Function Attributes,,Declaring Attributes of Functions}.
8191 @item -Wattribute-alias=1
8192 The default warning level of the @option{-Wattribute-alias} option diagnoses
8193 incompatibilities between the type of the alias declaration and that of its
8194 target. Such incompatibilities are typically indicative of bugs.
8196 @item -Wattribute-alias=2
8198 At this level @option{-Wattribute-alias} also diagnoses cases where
8199 the attributes of the alias declaration are more restrictive than the
8200 attributes applied to its target. These mismatches can potentially
8201 result in incorrect code generation. In other cases they may be
8202 benign and could be resolved simply by adding the missing attribute to
8203 the target. For comparison, see the @option{-Wmissing-attributes}
8204 option, which controls diagnostics when the alias declaration is less
8205 restrictive than the target, rather than more restrictive.
8207 Attributes considered include @code{alloc_align}, @code{alloc_size},
8208 @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8209 @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8210 @code{returns_nonnull}, and @code{returns_twice}.
8213 @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8214 This is the default. You can disable these warnings with either
8215 @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8217 @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
8218 @opindex Wbidi-chars=
8219 @opindex Wbidi-chars
8220 @opindex Wno-bidi-chars
8221 Warn about possibly misleading UTF-8 bidirectional control characters in
8222 comments, string literals, character constants, and identifiers. Such
8223 characters can change left-to-right writing direction into right-to-left
8224 (and vice versa), which can cause confusion between the logical order and
8225 visual order. This may be dangerous; for instance, it may seem that a piece
8226 of code is not commented out, whereas it in fact is.
8228 There are three levels of warning supported by GCC@. The default is
8229 @option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8230 bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8231 @option{-Wbidi-chars=any} warns about any use of bidirectional control
8234 By default, this warning does not warn about UCNs. It is, however, possible
8235 to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8236 @option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8237 and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8238 @option{-Wbidi-chars=any} was specified.
8240 @item -Wbool-compare
8241 @opindex Wno-bool-compare
8242 @opindex Wbool-compare
8243 Warn about boolean expression compared with an integer value different from
8244 @code{true}/@code{false}. For instance, the following comparison is
8249 if ((n > 1) == 2) @{ @dots{} @}
8251 This warning is enabled by @option{-Wall}.
8253 @item -Wbool-operation
8254 @opindex Wno-bool-operation
8255 @opindex Wbool-operation
8256 Warn about suspicious operations on expressions of a boolean type. For
8257 instance, bitwise negation of a boolean is very likely a bug in the program.
8258 For C, this warning also warns about incrementing or decrementing a boolean,
8259 which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8260 Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8262 This warning is enabled by @option{-Wall}.
8264 @item -Wduplicated-branches
8265 @opindex Wno-duplicated-branches
8266 @opindex Wduplicated-branches
8267 Warn when an if-else has identical branches. This warning detects cases like
8274 It doesn't warn when both branches contain just a null statement. This warning
8275 also warn for conditional operators:
8277 int i = x ? *p : *p;
8280 @item -Wduplicated-cond
8281 @opindex Wno-duplicated-cond
8282 @opindex Wduplicated-cond
8283 Warn about duplicated conditions in an if-else-if chain. For instance,
8284 warn for the following code:
8286 if (p->q != NULL) @{ @dots{} @}
8287 else if (p->q != NULL) @{ @dots{} @}
8290 @item -Wframe-address
8291 @opindex Wno-frame-address
8292 @opindex Wframe-address
8293 Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8294 is called with an argument greater than 0. Such calls may return indeterminate
8295 values or crash the program. The warning is included in @option{-Wall}.
8297 @item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
8298 @opindex Wno-discarded-qualifiers
8299 @opindex Wdiscarded-qualifiers
8300 Do not warn if type qualifiers on pointers are being discarded.
8301 Typically, the compiler warns if a @code{const char *} variable is
8302 passed to a function that takes a @code{char *} parameter. This option
8303 can be used to suppress such a warning.
8305 @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
8306 @opindex Wno-discarded-array-qualifiers
8307 @opindex Wdiscarded-array-qualifiers
8308 Do not warn if type qualifiers on arrays which are pointer targets
8309 are being discarded. Typically, the compiler warns if a
8310 @code{const int (*)[]} variable is passed to a function that
8311 takes a @code{int (*)[]} parameter. This option can be used to
8312 suppress such a warning.
8314 @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
8315 @opindex Wno-incompatible-pointer-types
8316 @opindex Wincompatible-pointer-types
8317 Do not warn when there is a conversion between pointers that have incompatible
8318 types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8319 which warns for pointer argument passing or assignment with different
8322 @item -Wno-int-conversion @r{(C and Objective-C only)}
8323 @opindex Wno-int-conversion
8324 @opindex Wint-conversion
8325 Do not warn about incompatible integer to pointer and pointer to integer
8326 conversions. This warning is about implicit conversions; for explicit
8327 conversions the warnings @option{-Wno-int-to-pointer-cast} and
8328 @option{-Wno-pointer-to-int-cast} may be used.
8330 @item -Wzero-length-bounds
8331 @opindex Wzero-length-bounds
8332 @opindex Wzero-length-bounds
8333 Warn about accesses to elements of zero-length array members that might
8334 overlap other members of the same object. Declaring interior zero-length
8335 arrays is discouraged because accesses to them are undefined. See
8338 For example, the first two stores in function @code{bad} are diagnosed
8339 because the array elements overlap the subsequent members @code{b} and
8340 @code{c}. The third store is diagnosed by @option{-Warray-bounds}
8341 because it is beyond the bounds of the enclosing object.
8344 struct X @{ int a[0]; int b, c; @};
8349 x.a[0] = 0; // -Wzero-length-bounds
8350 x.a[1] = 1; // -Wzero-length-bounds
8351 x.a[2] = 2; // -Warray-bounds
8355 Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8357 @item -Wno-div-by-zero
8358 @opindex Wno-div-by-zero
8359 @opindex Wdiv-by-zero
8360 Do not warn about compile-time integer division by zero. Floating-point
8361 division by zero is not warned about, as it can be a legitimate way of
8362 obtaining infinities and NaNs.
8364 @item -Wsystem-headers
8365 @opindex Wsystem-headers
8366 @opindex Wno-system-headers
8367 @cindex warnings from system headers
8368 @cindex system headers, warnings from
8369 Print warning messages for constructs found in system header files.
8370 Warnings from system headers are normally suppressed, on the assumption
8371 that they usually do not indicate real problems and would only make the
8372 compiler output harder to read. Using this command-line option tells
8373 GCC to emit warnings from system headers as if they occurred in user
8374 code. However, note that using @option{-Wall} in conjunction with this
8375 option does @emph{not} warn about unknown pragmas in system
8376 headers---for that, @option{-Wunknown-pragmas} must also be used.
8378 @item -Wtautological-compare
8379 @opindex Wtautological-compare
8380 @opindex Wno-tautological-compare
8381 Warn if a self-comparison always evaluates to true or false. This
8382 warning detects various mistakes such as:
8386 if (i > i) @{ @dots{} @}
8389 This warning also warns about bitwise comparisons that always evaluate
8390 to true or false, for instance:
8392 if ((a & 16) == 10) @{ @dots{} @}
8394 will always be false.
8396 This warning is enabled by @option{-Wall}.
8399 @opindex Wtrampolines
8400 @opindex Wno-trampolines
8401 Warn about trampolines generated for pointers to nested functions.
8402 A trampoline is a small piece of data or code that is created at run
8403 time on the stack when the address of a nested function is taken, and is
8404 used to call the nested function indirectly. For some targets, it is
8405 made up of data only and thus requires no special treatment. But, for
8406 most targets, it is made up of code and thus requires the stack to be
8407 made executable in order for the program to work properly.
8410 @opindex Wfloat-equal
8411 @opindex Wno-float-equal
8412 Warn if floating-point values are used in equality comparisons.
8414 The idea behind this is that sometimes it is convenient (for the
8415 programmer) to consider floating-point values as approximations to
8416 infinitely precise real numbers. If you are doing this, then you need
8417 to compute (by analyzing the code, or in some other way) the maximum or
8418 likely maximum error that the computation introduces, and allow for it
8419 when performing comparisons (and when producing output, but that's a
8420 different problem). In particular, instead of testing for equality, you
8421 should check to see whether the two values have ranges that overlap; and
8422 this is done with the relational operators, so equality comparisons are
8425 @item -Wtraditional @r{(C and Objective-C only)}
8426 @opindex Wtraditional
8427 @opindex Wno-traditional
8428 Warn about certain constructs that behave differently in traditional and
8429 ISO C@. Also warn about ISO C constructs that have no traditional C
8430 equivalent, and/or problematic constructs that should be avoided.
8434 Macro parameters that appear within string literals in the macro body.
8435 In traditional C macro replacement takes place within string literals,
8436 but in ISO C it does not.
8439 In traditional C, some preprocessor directives did not exist.
8440 Traditional preprocessors only considered a line to be a directive
8441 if the @samp{#} appeared in column 1 on the line. Therefore
8442 @option{-Wtraditional} warns about directives that traditional C
8443 understands but ignores because the @samp{#} does not appear as the
8444 first character on the line. It also suggests you hide directives like
8445 @code{#pragma} not understood by traditional C by indenting them. Some
8446 traditional implementations do not recognize @code{#elif}, so this option
8447 suggests avoiding it altogether.
8450 A function-like macro that appears without arguments.
8453 The unary plus operator.
8456 The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8457 constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8458 constants.) Note, these suffixes appear in macros defined in the system
8459 headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8460 Use of these macros in user code might normally lead to spurious
8461 warnings, however GCC's integrated preprocessor has enough context to
8462 avoid warning in these cases.
8465 A function declared external in one block and then used after the end of
8469 A @code{switch} statement has an operand of type @code{long}.
8472 A non-@code{static} function declaration follows a @code{static} one.
8473 This construct is not accepted by some traditional C compilers.
8476 The ISO type of an integer constant has a different width or
8477 signedness from its traditional type. This warning is only issued if
8478 the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8479 typically represent bit patterns, are not warned about.
8482 Usage of ISO string concatenation is detected.
8485 Initialization of automatic aggregates.
8488 Identifier conflicts with labels. Traditional C lacks a separate
8489 namespace for labels.
8492 Initialization of unions. If the initializer is zero, the warning is
8493 omitted. This is done under the assumption that the zero initializer in
8494 user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8495 initializer warnings and relies on default initialization to zero in the
8499 Conversions by prototypes between fixed/floating-point values and vice
8500 versa. The absence of these prototypes when compiling with traditional
8501 C causes serious problems. This is a subset of the possible
8502 conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8505 Use of ISO C style function definitions. This warning intentionally is
8506 @emph{not} issued for prototype declarations or variadic functions
8507 because these ISO C features appear in your code when using
8508 libiberty's traditional C compatibility macros, @code{PARAMS} and
8509 @code{VPARAMS}. This warning is also bypassed for nested functions
8510 because that feature is already a GCC extension and thus not relevant to
8511 traditional C compatibility.
8514 @item -Wtraditional-conversion @r{(C and Objective-C only)}
8515 @opindex Wtraditional-conversion
8516 @opindex Wno-traditional-conversion
8517 Warn if a prototype causes a type conversion that is different from what
8518 would happen to the same argument in the absence of a prototype. This
8519 includes conversions of fixed point to floating and vice versa, and
8520 conversions changing the width or signedness of a fixed-point argument
8521 except when the same as the default promotion.
8523 @item -Wdeclaration-after-statement @r{(C and Objective-C only)}
8524 @opindex Wdeclaration-after-statement
8525 @opindex Wno-declaration-after-statement
8526 Warn when a declaration is found after a statement in a block. This
8527 construct, known from C++, was introduced with ISO C99 and is by default
8528 allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8533 Warn whenever a local variable or type declaration shadows another
8534 variable, parameter, type, class member (in C++), or instance variable
8535 (in Objective-C) or whenever a built-in function is shadowed. Note
8536 that in C++, the compiler warns if a local variable shadows an
8537 explicit typedef, but not if it shadows a struct/class/enum.
8538 If this warning is enabled, it includes also all instances of
8539 local shadowing. This means that @option{-Wno-shadow=local}
8540 and @option{-Wno-shadow=compatible-local} are ignored when
8541 @option{-Wshadow} is used.
8542 Same as @option{-Wshadow=global}.
8544 @item -Wno-shadow-ivar @r{(Objective-C only)}
8545 @opindex Wno-shadow-ivar
8546 @opindex Wshadow-ivar
8547 Do not warn whenever a local variable shadows an instance variable in an
8550 @item -Wshadow=global
8551 @opindex Wshadow=global
8552 Warn for any shadowing.
8553 Same as @option{-Wshadow}.
8555 @item -Wshadow=local
8556 @opindex Wshadow=local
8557 Warn when a local variable shadows another local variable or parameter.
8559 @item -Wshadow=compatible-local
8560 @opindex Wshadow=compatible-local
8561 Warn when a local variable shadows another local variable or parameter
8562 whose type is compatible with that of the shadowing variable. In C++,
8563 type compatibility here means the type of the shadowing variable can be
8564 converted to that of the shadowed variable. The creation of this flag
8565 (in addition to @option{-Wshadow=local}) is based on the idea that when
8566 a local variable shadows another one of incompatible type, it is most
8567 likely intentional, not a bug or typo, as shown in the following example:
8571 for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8573 for (int i = 0; i < N; ++i)
8582 Since the two variable @code{i} in the example above have incompatible types,
8583 enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8584 Because their types are incompatible, if a programmer accidentally uses one
8585 in place of the other, type checking is expected to catch that and emit an
8586 error or warning. Use of this flag instead of @option{-Wshadow=local} can
8587 possibly reduce the number of warnings triggered by intentional shadowing.
8588 Note that this also means that shadowing @code{const char *i} by
8589 @code{char *i} does not emit a warning.
8591 This warning is also enabled by @option{-Wshadow=local}.
8593 @item -Wlarger-than=@var{byte-size}
8594 @opindex Wlarger-than=
8595 @opindex Wlarger-than-@var{byte-size}
8596 Warn whenever an object is defined whose size exceeds @var{byte-size}.
8597 @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8598 Warnings controlled by the option can be disabled either by specifying
8599 @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8601 Also warn for calls to bounded functions such as @code{memchr} or
8602 @code{strnlen} that specify a bound greater than the largest possible
8603 object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8604 can only be disabled by @option{-Wno-larger-than}.
8606 @item -Wno-larger-than
8607 @opindex Wno-larger-than
8608 Disable @option{-Wlarger-than=} warnings. The option is equivalent
8609 to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8611 @item -Wframe-larger-than=@var{byte-size}
8612 @opindex Wframe-larger-than=
8613 @opindex Wno-frame-larger-than
8614 Warn if the size of a function frame exceeds @var{byte-size}.
8615 The computation done to determine the stack frame size is approximate
8616 and not conservative.
8617 The actual requirements may be somewhat greater than @var{byte-size}
8618 even if you do not get a warning. In addition, any space allocated
8619 via @code{alloca}, variable-length arrays, or related constructs
8620 is not included by the compiler when determining
8621 whether or not to issue a warning.
8622 @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8623 Warnings controlled by the option can be disabled either by specifying
8624 @var{byte-size} of @samp{SIZE_MAX} or more or by
8625 @option{-Wno-frame-larger-than}.
8627 @item -Wno-frame-larger-than
8628 @opindex Wno-frame-larger-than
8629 Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8630 to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8632 @item -Wfree-nonheap-object
8633 @opindex Wfree-nonheap-object
8634 @opindex Wno-free-nonheap-object
8635 Warn when attempting to deallocate an object that was either not allocated
8636 on the heap, or by using a pointer that was not returned from a prior call
8637 to the corresponding allocation function. For example, because the call
8638 to @code{stpcpy} returns a pointer to the terminating nul character and
8639 not to the beginning of the object, the call to @code{free} below is
8645 p = stpcpy (p, "abc");
8647 free (p); // warning
8651 @option{-Wfree-nonheap-object} is included in @option{-Wall}.
8653 @item -Wstack-usage=@var{byte-size}
8654 @opindex Wstack-usage
8655 @opindex Wno-stack-usage
8656 Warn if the stack usage of a function might exceed @var{byte-size}.
8657 The computation done to determine the stack usage is conservative.
8658 Any space allocated via @code{alloca}, variable-length arrays, or related
8659 constructs is included by the compiler when determining whether or not to
8662 The message is in keeping with the output of @option{-fstack-usage}.
8666 If the stack usage is fully static but exceeds the specified amount, it's:
8669 warning: stack usage is 1120 bytes
8672 If the stack usage is (partly) dynamic but bounded, it's:
8675 warning: stack usage might be 1648 bytes
8678 If the stack usage is (partly) dynamic and not bounded, it's:
8681 warning: stack usage might be unbounded
8685 @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8686 Warnings controlled by the option can be disabled either by specifying
8687 @var{byte-size} of @samp{SIZE_MAX} or more or by
8688 @option{-Wno-stack-usage}.
8690 @item -Wno-stack-usage
8691 @opindex Wno-stack-usage
8692 Disable @option{-Wstack-usage=} warnings. The option is equivalent
8693 to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8695 @item -Wunsafe-loop-optimizations
8696 @opindex Wunsafe-loop-optimizations
8697 @opindex Wno-unsafe-loop-optimizations
8698 Warn if the loop cannot be optimized because the compiler cannot
8699 assume anything on the bounds of the loop indices. With
8700 @option{-funsafe-loop-optimizations} warn if the compiler makes
8703 @item -Wno-pedantic-ms-format @r{(MinGW targets only)}
8704 @opindex Wno-pedantic-ms-format
8705 @opindex Wpedantic-ms-format
8706 When used in combination with @option{-Wformat}
8707 and @option{-pedantic} without GNU extensions, this option
8708 disables the warnings about non-ISO @code{printf} / @code{scanf} format
8709 width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8710 which depend on the MS runtime.
8712 @item -Wpointer-arith
8713 @opindex Wpointer-arith
8714 @opindex Wno-pointer-arith
8715 Warn about anything that depends on the ``size of'' a function type or
8716 of @code{void}. GNU C assigns these types a size of 1, for
8717 convenience in calculations with @code{void *} pointers and pointers
8718 to functions. In C++, warn also when an arithmetic operation involves
8719 @code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8721 @item -Wno-pointer-compare
8722 @opindex Wpointer-compare
8723 @opindex Wno-pointer-compare
8724 Do not warn if a pointer is compared with a zero character constant.
8726 means that the pointer was meant to be dereferenced. For example:
8729 const char *p = foo ();
8734 Note that the code above is invalid in C++11.
8736 This warning is enabled by default.
8741 Warn about unsupported features in ThreadSanitizer.
8743 ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8744 can report false positives.
8746 This warning is enabled by default.
8749 @opindex Wtype-limits
8750 @opindex Wno-type-limits
8751 Warn if a comparison is always true or always false due to the limited
8752 range of the data type, but do not warn for constant expressions. For
8753 example, warn if an unsigned variable is compared against zero with
8754 @code{<} or @code{>=}. This warning is also enabled by
8757 @item -Wabsolute-value @r{(C and Objective-C only)}
8758 @opindex Wabsolute-value
8759 @opindex Wno-absolute-value
8760 Warn for calls to standard functions that compute the absolute value
8761 of an argument when a more appropriate standard function is available.
8762 For example, calling @code{abs(3.14)} triggers the warning because the
8763 appropriate function to call to compute the absolute value of a double
8764 argument is @code{fabs}. The option also triggers warnings when the
8765 argument in a call to such a function has an unsigned type. This
8766 warning can be suppressed with an explicit type cast and it is also
8767 enabled by @option{-Wextra}.
8769 @include cppwarnopts.texi
8771 @item -Wbad-function-cast @r{(C and Objective-C only)}
8772 @opindex Wbad-function-cast
8773 @opindex Wno-bad-function-cast
8774 Warn when a function call is cast to a non-matching type.
8775 For example, warn if a call to a function returning an integer type
8776 is cast to a pointer type.
8778 @item -Wc90-c99-compat @r{(C and Objective-C only)}
8779 @opindex Wc90-c99-compat
8780 @opindex Wno-c90-c99-compat
8781 Warn about features not present in ISO C90, but present in ISO C99.
8782 For instance, warn about use of variable length arrays, @code{long long}
8783 type, @code{bool} type, compound literals, designated initializers, and so
8784 on. This option is independent of the standards mode. Warnings are disabled
8785 in the expression that follows @code{__extension__}.
8787 @item -Wc99-c11-compat @r{(C and Objective-C only)}
8788 @opindex Wc99-c11-compat
8789 @opindex Wno-c99-c11-compat
8790 Warn about features not present in ISO C99, but present in ISO C11.
8791 For instance, warn about use of anonymous structures and unions,
8792 @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8793 @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8794 and so on. This option is independent of the standards mode. Warnings are
8795 disabled in the expression that follows @code{__extension__}.
8797 @item -Wc11-c2x-compat @r{(C and Objective-C only)}
8798 @opindex Wc11-c2x-compat
8799 @opindex Wno-c11-c2x-compat
8800 Warn about features not present in ISO C11, but present in ISO C2X.
8801 For instance, warn about omitting the string in @code{_Static_assert},
8802 use of @samp{[[]]} syntax for attributes, use of decimal
8803 floating-point types, and so on. This option is independent of the
8804 standards mode. Warnings are disabled in the expression that follows
8805 @code{__extension__}.
8807 @item -Wc++-compat @r{(C and Objective-C only)}
8808 @opindex Wc++-compat
8809 @opindex Wno-c++-compat
8810 Warn about ISO C constructs that are outside of the common subset of
8811 ISO C and ISO C++, e.g.@: request for implicit conversion from
8812 @code{void *} to a pointer to non-@code{void} type.
8814 @item -Wc++11-compat @r{(C++ and Objective-C++ only)}
8815 @opindex Wc++11-compat
8816 @opindex Wno-c++11-compat
8817 Warn about C++ constructs whose meaning differs between ISO C++ 1998
8818 and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
8819 in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
8820 enabled by @option{-Wall}.
8822 @item -Wc++14-compat @r{(C++ and Objective-C++ only)}
8823 @opindex Wc++14-compat
8824 @opindex Wno-c++14-compat
8825 Warn about C++ constructs whose meaning differs between ISO C++ 2011
8826 and ISO C++ 2014. This warning is enabled by @option{-Wall}.
8828 @item -Wc++17-compat @r{(C++ and Objective-C++ only)}
8829 @opindex Wc++17-compat
8830 @opindex Wno-c++17-compat
8831 Warn about C++ constructs whose meaning differs between ISO C++ 2014
8832 and ISO C++ 2017. This warning is enabled by @option{-Wall}.
8834 @item -Wc++20-compat @r{(C++ and Objective-C++ only)}
8835 @opindex Wc++20-compat
8836 @opindex Wno-c++20-compat
8837 Warn about C++ constructs whose meaning differs between ISO C++ 2017
8838 and ISO C++ 2020. This warning is enabled by @option{-Wall}.
8840 @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
8841 @opindex Wc++11-extensions
8842 @opindex Wno-c++11-extensions
8843 Do not warn about C++11 constructs in code being compiled using
8844 an older C++ standard. Even without this option, some C++11 constructs
8845 will only be diagnosed if @option{-Wpedantic} is used.
8847 @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
8848 @opindex Wc++14-extensions
8849 @opindex Wno-c++14-extensions
8850 Do not warn about C++14 constructs in code being compiled using
8851 an older C++ standard. Even without this option, some C++14 constructs
8852 will only be diagnosed if @option{-Wpedantic} is used.
8854 @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
8855 @opindex Wc++17-extensions
8856 @opindex Wno-c++17-extensions
8857 Do not warn about C++17 constructs in code being compiled using
8858 an older C++ standard. Even without this option, some C++17 constructs
8859 will only be diagnosed if @option{-Wpedantic} is used.
8861 @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
8862 @opindex Wc++20-extensions
8863 @opindex Wno-c++20-extensions
8864 Do not warn about C++20 constructs in code being compiled using
8865 an older C++ standard. Even without this option, some C++20 constructs
8866 will only be diagnosed if @option{-Wpedantic} is used.
8868 @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
8869 @opindex Wc++23-extensions
8870 @opindex Wno-c++23-extensions
8871 Do not warn about C++23 constructs in code being compiled using
8872 an older C++ standard. Even without this option, some C++23 constructs
8873 will only be diagnosed if @option{-Wpedantic} is used.
8877 @opindex Wno-cast-qual
8878 Warn whenever a pointer is cast so as to remove a type qualifier from
8879 the target type. For example, warn if a @code{const char *} is cast
8880 to an ordinary @code{char *}.
8882 Also warn when making a cast that introduces a type qualifier in an
8883 unsafe way. For example, casting @code{char **} to @code{const char **}
8884 is unsafe, as in this example:
8887 /* p is char ** value. */
8888 const char **q = (const char **) p;
8889 /* Assignment of readonly string to const char * is OK. */
8891 /* Now char** pointer points to read-only memory. */
8896 @opindex Wcast-align
8897 @opindex Wno-cast-align
8898 Warn whenever a pointer is cast such that the required alignment of the
8899 target is increased. For example, warn if a @code{char *} is cast to
8900 an @code{int *} on machines where integers can only be accessed at
8901 two- or four-byte boundaries.
8903 @item -Wcast-align=strict
8904 @opindex Wcast-align=strict
8905 Warn whenever a pointer is cast such that the required alignment of the
8906 target is increased. For example, warn if a @code{char *} is cast to
8907 an @code{int *} regardless of the target machine.
8909 @item -Wcast-function-type
8910 @opindex Wcast-function-type
8911 @opindex Wno-cast-function-type
8912 Warn when a function pointer is cast to an incompatible function pointer.
8913 In a cast involving function types with a variable argument list only
8914 the types of initial arguments that are provided are considered.
8915 Any parameter of pointer-type matches any other pointer-type. Any benign
8916 differences in integral types are ignored, like @code{int} vs.@: @code{long}
8917 on ILP32 targets. Likewise type qualifiers are ignored. The function
8918 type @code{void (*) (void)} is special and matches everything, which can
8919 be used to suppress this warning.
8920 In a cast involving pointer to member types this warning warns whenever
8921 the type cast is changing the pointer to member type.
8922 This warning is enabled by @option{-Wextra}.
8924 @item -Wwrite-strings
8925 @opindex Wwrite-strings
8926 @opindex Wno-write-strings
8927 When compiling C, give string constants the type @code{const
8928 char[@var{length}]} so that copying the address of one into a
8929 non-@code{const} @code{char *} pointer produces a warning. These
8930 warnings help you find at compile time code that can try to write
8931 into a string constant, but only if you have been very careful about
8932 using @code{const} in declarations and prototypes. Otherwise, it is
8933 just a nuisance. This is why we did not make @option{-Wall} request
8936 When compiling C++, warn about the deprecated conversion from string
8937 literals to @code{char *}. This warning is enabled by default for C++
8942 @opindex Wno-clobbered
8943 Warn for variables that might be changed by @code{longjmp} or
8944 @code{vfork}. This warning is also enabled by @option{-Wextra}.
8947 @opindex Wconversion
8948 @opindex Wno-conversion
8949 Warn for implicit conversions that may alter a value. This includes
8950 conversions between real and integer, like @code{abs (x)} when
8951 @code{x} is @code{double}; conversions between signed and unsigned,
8952 like @code{unsigned ui = -1}; and conversions to smaller types, like
8953 @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
8954 ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
8955 changed by the conversion like in @code{abs (2.0)}. Warnings about
8956 conversions between signed and unsigned integers can be disabled by
8957 using @option{-Wno-sign-conversion}.
8959 For C++, also warn for confusing overload resolution for user-defined
8960 conversions; and conversions that never use a type conversion
8961 operator: conversions to @code{void}, the same type, a base class or a
8962 reference to them. Warnings about conversions between signed and
8963 unsigned integers are disabled by default in C++ unless
8964 @option{-Wsign-conversion} is explicitly enabled.
8966 Warnings about conversion from arithmetic on a small type back to that
8967 type are only given with @option{-Warith-conversion}.
8969 @item -Wdangling-else
8970 @opindex Wdangling-else
8971 @opindex Wno-dangling-else
8972 Warn about constructions where there may be confusion to which
8973 @code{if} statement an @code{else} branch belongs. Here is an example of
8988 In C/C++, every @code{else} branch belongs to the innermost possible
8989 @code{if} statement, which in this example is @code{if (b)}. This is
8990 often not what the programmer expected, as illustrated in the above
8991 example by indentation the programmer chose. When there is the
8992 potential for this confusion, GCC issues a warning when this flag
8993 is specified. To eliminate the warning, add explicit braces around
8994 the innermost @code{if} statement so there is no way the @code{else}
8995 can belong to the enclosing @code{if}. The resulting code
9012 This warning is enabled by @option{-Wparentheses}.
9014 @item -Wdangling-pointer
9015 @itemx -Wdangling-pointer=@var{n}
9016 @opindex Wdangling-pointer
9017 @opindex Wno-dangling-pointer
9018 Warn about uses of pointers (or C++ references) to objects with automatic
9019 storage duration after their lifetime has ended. This includes local
9020 variables declared in nested blocks, compound literals and other unnamed
9021 temporary objects. In addition, warn about storing the address of such
9022 objects in escaped pointers. The warning is enabled at all optimization
9023 levels but may yield different results with optimization than without.
9026 @item -Wdangling-pointer=1
9027 At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9030 int f (int c1, int c2, x)
9032 char *p = strchr ((char[])@{ c1, c2 @}, c3);
9033 return p ? *p : 'x'; // warning: dangling pointer to a compound literal
9036 In the following function the store of the address of the local variable
9037 @code{x} in the escaped pointer @code{*p} also triggers the warning.
9042 *p = &x; // warning: storing the address of a local variable in *p
9046 @item -Wdangling-pointer=2
9047 At level 2, in addition to unconditional uses the warning also diagnoses
9048 conditional uses of dangling pointers.
9050 For example, because the array @var{a} in the following function is out of
9051 scope when the pointer @var{s} that was set to point is used, the warning
9052 triggers at this level.
9059 char a[12] = "tmpname";
9062 strcat (s, ".tmp"); // warning: dangling pointer to a may be used
9068 @option{-Wdangling-pointer=2} is included in @option{-Wall}.
9072 @opindex Wno-date-time
9073 Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9074 are encountered as they might prevent bit-wise-identical reproducible
9078 @opindex Wempty-body
9079 @opindex Wno-empty-body
9080 Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9081 while} statement. This warning is also enabled by @option{-Wextra}.
9083 @item -Wno-endif-labels
9084 @opindex Wendif-labels
9085 @opindex Wno-endif-labels
9086 Do not warn about stray tokens after @code{#else} and @code{#endif}.
9088 @item -Wenum-compare
9089 @opindex Wenum-compare
9090 @opindex Wno-enum-compare
9091 Warn about a comparison between values of different enumerated types.
9092 In C++ enumerated type mismatches in conditional expressions are also
9093 diagnosed and the warning is enabled by default. In C this warning is
9094 enabled by @option{-Wall}.
9096 @item -Wenum-conversion
9097 @opindex Wenum-conversion
9098 @opindex Wno-enum-conversion
9099 Warn when a value of enumerated type is implicitly converted to a
9100 different enumerated type. This warning is enabled by @option{-Wextra}
9103 @item -Wenum-int-mismatch @r{(C and Objective-C only)}
9104 @opindex Wenum-int-mismatch
9105 @opindex Wno-enum-int-mismatch
9106 Warn about mismatches between an enumerated type and an integer type in
9107 declarations. For example:
9110 enum E @{ l = -1, z = 0, g = 1 @};
9115 In C, an enumerated type is compatible with @code{char}, a signed
9116 integer type, or an unsigned integer type. However, since the choice
9117 of the underlying type of an enumerated type is implementation-defined,
9118 such mismatches may cause portability issues. In C++, such mismatches
9119 are an error. In C, this warning is enabled by @option{-Wall} and
9120 @option{-Wc++-compat}.
9122 @item -Wjump-misses-init @r{(C, Objective-C only)}
9123 @opindex Wjump-misses-init
9124 @opindex Wno-jump-misses-init
9125 Warn if a @code{goto} statement or a @code{switch} statement jumps
9126 forward across the initialization of a variable, or jumps backward to a
9127 label after the variable has been initialized. This only warns about
9128 variables that are initialized when they are declared. This warning is
9129 only supported for C and Objective-C; in C++ this sort of branch is an
9132 @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9133 can be disabled with the @option{-Wno-jump-misses-init} option.
9135 @item -Wsign-compare
9136 @opindex Wsign-compare
9137 @opindex Wno-sign-compare
9138 @cindex warning for comparison of signed and unsigned values
9139 @cindex comparison of signed and unsigned values, warning
9140 @cindex signed and unsigned values, comparison warning
9141 Warn when a comparison between signed and unsigned values could produce
9142 an incorrect result when the signed value is converted to unsigned.
9143 In C++, this warning is also enabled by @option{-Wall}. In C, it is
9144 also enabled by @option{-Wextra}.
9146 @item -Wsign-conversion
9147 @opindex Wsign-conversion
9148 @opindex Wno-sign-conversion
9149 Warn for implicit conversions that may change the sign of an integer
9150 value, like assigning a signed integer expression to an unsigned
9151 integer variable. An explicit cast silences the warning. In C, this
9152 option is enabled also by @option{-Wconversion}.
9154 @item -Wfloat-conversion
9155 @opindex Wfloat-conversion
9156 @opindex Wno-float-conversion
9157 Warn for implicit conversions that reduce the precision of a real value.
9158 This includes conversions from real to integer, and from higher precision
9159 real to lower precision real values. This option is also enabled by
9160 @option{-Wconversion}.
9162 @item -Wno-scalar-storage-order
9163 @opindex Wno-scalar-storage-order
9164 @opindex Wscalar-storage-order
9165 Do not warn on suspicious constructs involving reverse scalar storage order.
9167 @item -Wsizeof-array-div
9168 @opindex Wsizeof-array-div
9169 @opindex Wno-sizeof-array-div
9170 Warn about divisions of two sizeof operators when the first one is applied
9171 to an array and the divisor does not equal the size of the array element.
9172 In such a case, the computation will not yield the number of elements in the
9173 array, which is likely what the user intended. This warning warns e.g. about
9178 return sizeof (arr) / sizeof (short);
9182 This warning is enabled by @option{-Wall}.
9184 @item -Wsizeof-pointer-div
9185 @opindex Wsizeof-pointer-div
9186 @opindex Wno-sizeof-pointer-div
9187 Warn for suspicious divisions of two sizeof expressions that divide
9188 the pointer size by the element size, which is the usual way to compute
9189 the array size but won't work out correctly with pointers. This warning
9190 warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9191 not an array, but a pointer. This warning is enabled by @option{-Wall}.
9193 @item -Wsizeof-pointer-memaccess
9194 @opindex Wsizeof-pointer-memaccess
9195 @opindex Wno-sizeof-pointer-memaccess
9196 Warn for suspicious length parameters to certain string and memory built-in
9197 functions if the argument uses @code{sizeof}. This warning triggers for
9198 example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9199 an array, but a pointer, and suggests a possible fix, or about
9200 @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9201 also warns about calls to bounded string copy functions like @code{strncat}
9202 or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9203 the source array. For example, in the following function the call to
9204 @code{strncat} specifies the size of the source string as the bound. That
9205 is almost certainly a mistake and so the call is diagnosed.
9207 void make_file (const char *name)
9209 char path[PATH_MAX];
9210 strncpy (path, name, sizeof path - 1);
9211 strncat (path, ".text", sizeof ".text");
9216 The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9218 @item -Wno-sizeof-array-argument
9219 @opindex Wsizeof-array-argument
9220 @opindex Wno-sizeof-array-argument
9221 Do not warn when the @code{sizeof} operator is applied to a parameter that is
9222 declared as an array in a function definition. This warning is enabled by
9223 default for C and C++ programs.
9225 @item -Wmemset-elt-size
9226 @opindex Wmemset-elt-size
9227 @opindex Wno-memset-elt-size
9228 Warn for suspicious calls to the @code{memset} built-in function, if the
9229 first argument references an array, and the third argument is a number
9230 equal to the number of elements, but not equal to the size of the array
9231 in memory. This indicates that the user has omitted a multiplication by
9232 the element size. This warning is enabled by @option{-Wall}.
9234 @item -Wmemset-transposed-args
9235 @opindex Wmemset-transposed-args
9236 @opindex Wno-memset-transposed-args
9237 Warn for suspicious calls to the @code{memset} built-in function where
9238 the second argument is not zero and the third argument is zero. For
9239 example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9240 @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9241 is only emitted if the third argument is a literal zero. Otherwise, if
9242 it is an expression that is folded to zero, or a cast of zero to some
9243 type, it is far less likely that the arguments have been mistakenly
9244 transposed and no warning is emitted. This warning is enabled
9249 @opindex Wno-address
9250 Warn about suspicious uses of address expressions. These include comparing
9251 the address of a function or a declared object to the null pointer constant
9257 if (!f) // warning: expression evaluates to false
9261 comparisons of a pointer to a string literal, such as in
9263 void f (const char *x)
9265 if (x == "abc") // warning: expression evaluates to false
9269 and tests of the results of pointer addition or subtraction for equality
9272 void f (const int *p, int i)
9274 return p + i == NULL;
9277 Such uses typically indicate a programmer error: the address of most
9278 functions and objects necessarily evaluates to true (the exception are
9279 weak symbols), so their use in a conditional might indicate missing
9280 parentheses in a function call or a missing dereference in an array
9281 expression. The subset of the warning for object pointers can be
9282 suppressed by casting the pointer operand to an integer type such
9283 as @code{intptr_t} or @code{uintptr_t}.
9284 Comparisons against string literals result in unspecified behavior
9285 and are not portable, and suggest the intent was to call @code{strcmp}.
9286 The warning is suppressed if the suspicious expression is the result
9288 @option{-Waddress} warning is enabled by @option{-Wall}.
9290 @item -Wno-address-of-packed-member
9291 @opindex Waddress-of-packed-member
9292 @opindex Wno-address-of-packed-member
9293 Do not warn when the address of packed member of struct or union is taken,
9294 which usually results in an unaligned pointer value. This is
9298 @opindex Wlogical-op
9299 @opindex Wno-logical-op
9300 Warn about suspicious uses of logical operators in expressions.
9301 This includes using logical operators in contexts where a
9302 bit-wise operator is likely to be expected. Also warns when
9303 the operands of a logical operator are the same:
9306 if (a < 0 && a < 0) @{ @dots{} @}
9309 @item -Wlogical-not-parentheses
9310 @opindex Wlogical-not-parentheses
9311 @opindex Wno-logical-not-parentheses
9312 Warn about logical not used on the left hand side operand of a comparison.
9313 This option does not warn if the right operand is considered to be a boolean
9314 expression. Its purpose is to detect suspicious code like the following:
9318 if (!a > 1) @{ @dots{} @}
9321 It is possible to suppress the warning by wrapping the LHS into
9324 if ((!a) > 1) @{ @dots{} @}
9327 This warning is enabled by @option{-Wall}.
9329 @item -Waggregate-return
9330 @opindex Waggregate-return
9331 @opindex Wno-aggregate-return
9332 Warn if any functions that return structures or unions are defined or
9333 called. (In languages where you can return an array, this also elicits
9336 @item -Wno-aggressive-loop-optimizations
9337 @opindex Wno-aggressive-loop-optimizations
9338 @opindex Waggressive-loop-optimizations
9339 Warn if in a loop with constant number of iterations the compiler detects
9340 undefined behavior in some statement during one or more of the iterations.
9342 @item -Wno-attributes
9343 @opindex Wno-attributes
9344 @opindex Wattributes
9345 Do not warn if an unexpected @code{__attribute__} is used, such as
9346 unrecognized attributes, function attributes applied to variables,
9347 etc. This does not stop errors for incorrect use of supported
9350 Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9351 warnings about unknown scoped attributes (in C++11 and C2X). For example,
9352 @option{-Wno-attributes=vendor::attr} disables warning about the following
9356 [[vendor::attr]] void f();
9359 It is also possible to disable warning about all attributes in a namespace
9360 using @option{-Wno-attributes=vendor::} which prevents warning about both
9361 of these declarations:
9364 [[vendor::safe]] void f();
9365 [[vendor::unsafe]] void f2();
9368 Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9370 @item -Wno-builtin-declaration-mismatch
9371 @opindex Wno-builtin-declaration-mismatch
9372 @opindex Wbuiltin-declaration-mismatch
9373 Warn if a built-in function is declared with an incompatible signature
9374 or as a non-function, or when a built-in function declared with a type
9375 that does not include a prototype is called with arguments whose promoted
9376 types do not match those expected by the function. When @option{-Wextra}
9377 is specified, also warn when a built-in function that takes arguments is
9378 declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9379 warning is enabled by default. To avoid the warning include the appropriate
9380 header to bring the prototypes of built-in functions into scope.
9382 For example, the call to @code{memset} below is diagnosed by the warning
9383 because the function expects a value of type @code{size_t} as its argument
9384 but the type of @code{32} is @code{int}. With @option{-Wextra},
9385 the declaration of the function is diagnosed as well.
9387 extern void* memset ();
9390 memset (d, '\0', 32);
9394 @item -Wno-builtin-macro-redefined
9395 @opindex Wno-builtin-macro-redefined
9396 @opindex Wbuiltin-macro-redefined
9397 Do not warn if certain built-in macros are redefined. This suppresses
9398 warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9399 @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9401 @item -Wstrict-prototypes @r{(C and Objective-C only)}
9402 @opindex Wstrict-prototypes
9403 @opindex Wno-strict-prototypes
9404 Warn if a function is declared or defined without specifying the
9405 argument types. (An old-style function definition is permitted without
9406 a warning if preceded by a declaration that specifies the argument
9409 @item -Wold-style-declaration @r{(C and Objective-C only)}
9410 @opindex Wold-style-declaration
9411 @opindex Wno-old-style-declaration
9412 Warn for obsolescent usages, according to the C Standard, in a
9413 declaration. For example, warn if storage-class specifiers like
9414 @code{static} are not the first things in a declaration. This warning
9415 is also enabled by @option{-Wextra}.
9417 @item -Wold-style-definition @r{(C and Objective-C only)}
9418 @opindex Wold-style-definition
9419 @opindex Wno-old-style-definition
9420 Warn if an old-style function definition is used. A warning is given
9421 even if there is a previous prototype. A definition using @samp{()}
9422 is not considered an old-style definition in C2X mode, because it is
9423 equivalent to @samp{(void)} in that case, but is considered an
9424 old-style definition for older standards.
9426 @item -Wmissing-parameter-type @r{(C and Objective-C only)}
9427 @opindex Wmissing-parameter-type
9428 @opindex Wno-missing-parameter-type
9429 A function parameter is declared without a type specifier in K&R-style
9436 This warning is also enabled by @option{-Wextra}.
9438 @item -Wmissing-prototypes @r{(C and Objective-C only)}
9439 @opindex Wmissing-prototypes
9440 @opindex Wno-missing-prototypes
9441 Warn if a global function is defined without a previous prototype
9442 declaration. This warning is issued even if the definition itself
9443 provides a prototype. Use this option to detect global functions
9444 that do not have a matching prototype declaration in a header file.
9445 This option is not valid for C++ because all function declarations
9446 provide prototypes and a non-matching declaration declares an
9447 overload rather than conflict with an earlier declaration.
9448 Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9450 @item -Wmissing-declarations
9451 @opindex Wmissing-declarations
9452 @opindex Wno-missing-declarations
9453 Warn if a global function is defined without a previous declaration.
9454 Do so even if the definition itself provides a prototype.
9455 Use this option to detect global functions that are not declared in
9456 header files. In C, no warnings are issued for functions with previous
9457 non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9458 missing prototypes. In C++, no warnings are issued for function templates,
9459 or for inline functions, or for functions in anonymous namespaces.
9461 @item -Wmissing-field-initializers
9462 @opindex Wmissing-field-initializers
9463 @opindex Wno-missing-field-initializers
9467 Warn if a structure's initializer has some fields missing. For
9468 example, the following code causes such a warning, because
9469 @code{x.h} is implicitly zero:
9472 struct s @{ int f, g, h; @};
9473 struct s x = @{ 3, 4 @};
9476 This option does not warn about designated initializers, so the following
9477 modification does not trigger a warning:
9480 struct s @{ int f, g, h; @};
9481 struct s x = @{ .f = 3, .g = 4 @};
9484 In C this option does not warn about the universal zero initializer
9488 struct s @{ int f, g, h; @};
9489 struct s x = @{ 0 @};
9492 Likewise, in C++ this option does not warn about the empty @{ @}
9493 initializer, for example:
9496 struct s @{ int f, g, h; @};
9500 This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9501 warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9503 @item -Wno-missing-requires
9504 @opindex Wmissing-requires
9505 @opindex Wno-missing-requires
9507 By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9510 bool satisfied = requires @{ C<T> @};
9513 Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9514 expression, which it is for all T. Presumably the user meant to write
9517 bool satisfied = requires @{ requires C<T> @};
9520 so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9523 This warning can be disabled with @option{-Wno-missing-requires}.
9525 @item -Wno-missing-template-keyword
9526 @opindex Wmissing-template-keyword
9527 @opindex Wno-missing-template-keyword
9529 The member access tokens ., -> and :: must be followed by the @code{template}
9530 keyword if the parent object is dependent and the member being named is a
9537 x.template DoSomeOtherStuff<X>(); // Good.
9538 x.DoMoreStuff<X>(); // Warning, x is dependent.
9542 In rare cases it is possible to get false positives. To silence this, wrap
9543 the expression in parentheses. For example, the following is treated as a
9544 template, even where m and N are integers:
9547 void NotATemplate (my_class t)
9551 bool test = t.m < N > (0); // Treated as a template.
9552 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9556 This warning can be disabled with @option{-Wno-missing-template-keyword}.
9558 @item -Wno-multichar
9559 @opindex Wno-multichar
9561 Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9562 Usually they indicate a typo in the user's code, as they have
9563 implementation-defined values, and should not be used in portable code.
9565 @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
9566 @opindex Wnormalized=
9567 @opindex Wnormalized
9568 @opindex Wno-normalized
9571 @cindex character set, input normalization
9572 In ISO C and ISO C++, two identifiers are different if they are
9573 different sequences of characters. However, sometimes when characters
9574 outside the basic ASCII character set are used, you can have two
9575 different character sequences that look the same. To avoid confusion,
9576 the ISO 10646 standard sets out some @dfn{normalization rules} which
9577 when applied ensure that two sequences that look the same are turned into
9578 the same sequence. GCC can warn you if you are using identifiers that
9579 have not been normalized; this option controls that warning.
9581 There are four levels of warning supported by GCC@. The default is
9582 @option{-Wnormalized=nfc}, which warns about any identifier that is
9583 not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9584 recommended form for most uses. It is equivalent to
9585 @option{-Wnormalized}.
9587 Unfortunately, there are some characters allowed in identifiers by
9588 ISO C and ISO C++ that, when turned into NFC, are not allowed in
9589 identifiers. That is, there's no way to use these symbols in portable
9590 ISO C or C++ and have all your identifiers in NFC@.
9591 @option{-Wnormalized=id} suppresses the warning for these characters.
9592 It is hoped that future versions of the standards involved will correct
9593 this, which is why this option is not the default.
9595 You can switch the warning off for all characters by writing
9596 @option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9597 only do this if you are using some other normalization scheme (like
9598 ``D''), because otherwise you can easily create bugs that are
9599 literally impossible to see.
9601 Some characters in ISO 10646 have distinct meanings but look identical
9602 in some fonts or display methodologies, especially once formatting has
9603 been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9604 LETTER N'', displays just like a regular @code{n} that has been
9605 placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9606 normalization scheme to convert all these into a standard form as
9607 well, and GCC warns if your code is not in NFKC if you use
9608 @option{-Wnormalized=nfkc}. This warning is comparable to warning
9609 about every identifier that contains the letter O because it might be
9610 confused with the digit 0, and so is not the default, but may be
9611 useful as a local coding convention if the programming environment
9612 cannot be fixed to display these characters distinctly.
9614 @item -Wno-attribute-warning
9615 @opindex Wno-attribute-warning
9616 @opindex Wattribute-warning
9617 Do not warn about usage of functions (@pxref{Function Attributes})
9618 declared with @code{warning} attribute. By default, this warning is
9619 enabled. @option{-Wno-attribute-warning} can be used to disable the
9620 warning or @option{-Wno-error=attribute-warning} can be used to
9621 disable the error when compiled with @option{-Werror} flag.
9623 @item -Wno-deprecated
9624 @opindex Wno-deprecated
9625 @opindex Wdeprecated
9626 Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9628 @item -Wno-deprecated-declarations
9629 @opindex Wno-deprecated-declarations
9630 @opindex Wdeprecated-declarations
9631 Do not warn about uses of functions (@pxref{Function Attributes}),
9632 variables (@pxref{Variable Attributes}), and types (@pxref{Type
9633 Attributes}) marked as deprecated by using the @code{deprecated}
9637 @opindex Wno-overflow
9639 Do not warn about compile-time overflow in constant expressions.
9644 Warn about One Definition Rule violations during link-time optimization.
9647 @item -Wopenacc-parallelism
9648 @opindex Wopenacc-parallelism
9649 @opindex Wno-openacc-parallelism
9650 @cindex OpenACC accelerator programming
9651 Warn about potentially suboptimal choices related to OpenACC parallelism.
9654 @opindex Wopenmp-simd
9655 @opindex Wno-openmp-simd
9656 Warn if the vectorizer cost model overrides the OpenMP
9657 simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9658 option can be used to relax the cost model.
9660 @item -Woverride-init @r{(C and Objective-C only)}
9661 @opindex Woverride-init
9662 @opindex Wno-override-init
9666 Warn if an initialized field without side effects is overridden when
9667 using designated initializers (@pxref{Designated Inits, , Designated
9670 This warning is included in @option{-Wextra}. To get other
9671 @option{-Wextra} warnings without this one, use @option{-Wextra
9672 -Wno-override-init}.
9674 @item -Wno-override-init-side-effects @r{(C and Objective-C only)}
9675 @opindex Woverride-init-side-effects
9676 @opindex Wno-override-init-side-effects
9677 Do not warn if an initialized field with side effects is overridden when
9678 using designated initializers (@pxref{Designated Inits, , Designated
9679 Initializers}). This warning is enabled by default.
9684 Warn if a structure is given the packed attribute, but the packed
9685 attribute has no effect on the layout or size of the structure.
9686 Such structures may be mis-aligned for little benefit. For
9687 instance, in this code, the variable @code{f.x} in @code{struct bar}
9688 is misaligned even though @code{struct bar} does not itself
9689 have the packed attribute:
9696 @} __attribute__((packed));
9704 @item -Wnopacked-bitfield-compat
9705 @opindex Wpacked-bitfield-compat
9706 @opindex Wno-packed-bitfield-compat
9707 The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9708 on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9709 the change can lead to differences in the structure layout. GCC
9710 informs you when the offset of such a field has changed in GCC 4.4.
9711 For example there is no longer a 4-bit padding between field @code{a}
9712 and @code{b} in this structure:
9719 @} __attribute__ ((packed));
9722 This warning is enabled by default. Use
9723 @option{-Wno-packed-bitfield-compat} to disable this warning.
9725 @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
9726 @opindex Wpacked-not-aligned
9727 @opindex Wno-packed-not-aligned
9728 Warn if a structure field with explicitly specified alignment in a
9729 packed struct or union is misaligned. For example, a warning will
9730 be issued on @code{struct S}, like, @code{warning: alignment 1 of
9731 'struct S' is less than 8}, in this code:
9735 struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9736 struct __attribute__ ((packed)) S @{
9742 This warning is enabled by @option{-Wall}.
9747 Warn if padding is included in a structure, either to align an element
9748 of the structure or to align the whole structure. Sometimes when this
9749 happens it is possible to rearrange the fields of the structure to
9750 reduce the padding and so make the structure smaller.
9752 @item -Wredundant-decls
9753 @opindex Wredundant-decls
9754 @opindex Wno-redundant-decls
9755 Warn if anything is declared more than once in the same scope, even in
9756 cases where multiple declaration is valid and changes nothing.
9760 @opindex Wno-restrict
9761 Warn when an object referenced by a @code{restrict}-qualified parameter
9762 (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
9763 argument, or when copies between such objects overlap. For example,
9764 the call to the @code{strcpy} function below attempts to truncate the string
9765 by replacing its initial characters with the last four. However, because
9766 the call writes the terminating NUL into @code{a[4]}, the copies overlap and
9767 the call is diagnosed.
9772 char a[] = "abcd1234";
9777 The @option{-Wrestrict} option detects some instances of simple overlap
9778 even without optimization but works best at @option{-O2} and above. It
9779 is included in @option{-Wall}.
9781 @item -Wnested-externs @r{(C and Objective-C only)}
9782 @opindex Wnested-externs
9783 @opindex Wno-nested-externs
9784 Warn if an @code{extern} declaration is encountered within a function.
9789 Warn if a function that is declared as inline cannot be inlined.
9790 Even with this option, the compiler does not warn about failures to
9791 inline functions declared in system headers.
9793 The compiler uses a variety of heuristics to determine whether or not
9794 to inline a function. For example, the compiler takes into account
9795 the size of the function being inlined and the amount of inlining
9796 that has already been done in the current function. Therefore,
9797 seemingly insignificant changes in the source program can cause the
9798 warnings produced by @option{-Winline} to appear or disappear.
9800 @item -Winterference-size
9801 @opindex Winterference-size
9802 Warn about use of C++17 @code{std::hardware_destructive_interference_size}
9803 without specifying its value with @option{--param destructive-interference-size}.
9804 Also warn about questionable values for that option.
9806 This variable is intended to be used for controlling class layout, to
9807 avoid false sharing in concurrent code:
9810 struct independent_fields @{
9811 alignas(std::hardware_destructive_interference_size) std::atomic<int> one;
9812 alignas(std::hardware_destructive_interference_size) std::atomic<int> two;
9816 Here @samp{one} and @samp{two} are intended to be far enough apart
9817 that stores to one won't require accesses to the other to reload the
9820 By default, @option{--param destructive-interference-size} and
9821 @option{--param constructive-interference-size} are set based on the
9822 current @option{-mtune} option, typically to the L1 cache line size
9823 for the particular target CPU, sometimes to a range if tuning for a
9824 generic target. So all translation units that depend on ABI
9825 compatibility for the use of these variables must be compiled with
9826 the same @option{-mtune} (or @option{-mcpu}).
9828 If ABI stability is important, such as if the use is in a header for a
9829 library, you should probably not use the hardware interference size
9830 variables at all. Alternatively, you can force a particular value
9831 with @option{--param}.
9833 If you are confident that your use of the variable does not affect ABI
9834 outside a single build of your project, you can turn off the warning
9835 with @option{-Wno-interference-size}.
9837 @item -Wint-in-bool-context
9838 @opindex Wint-in-bool-context
9839 @opindex Wno-int-in-bool-context
9840 Warn for suspicious use of integer values where boolean values are expected,
9841 such as conditional expressions (?:) using non-boolean integer constants in
9842 boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
9843 integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
9844 for all kinds of multiplications regardless of the data type.
9845 This warning is enabled by @option{-Wall}.
9847 @item -Wno-int-to-pointer-cast
9848 @opindex Wno-int-to-pointer-cast
9849 @opindex Wint-to-pointer-cast
9850 Suppress warnings from casts to pointer type of an integer of a
9851 different size. In C++, casting to a pointer type of smaller size is
9852 an error. @option{Wint-to-pointer-cast} is enabled by default.
9855 @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
9856 @opindex Wno-pointer-to-int-cast
9857 @opindex Wpointer-to-int-cast
9858 Suppress warnings from casts from a pointer to an integer type of a
9862 @opindex Winvalid-pch
9863 @opindex Wno-invalid-pch
9864 Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
9865 the search path but cannot be used.
9867 @item -Winvalid-utf8
9868 @opindex Winvalid-utf8
9869 @opindex Wno-invalid-utf8
9870 Warn if an invalid UTF-8 character is found.
9871 This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
9872 is used and turned into error with @option{-pedantic-errors}.
9876 @opindex Wno-unicode
9877 Don't diagnose invalid forms of delimited or named escape sequences which are
9878 treated as separate tokens. @option{Wunicode} is enabled by default.
9882 @opindex Wno-long-long
9883 Warn if @code{long long} type is used. This is enabled by either
9884 @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
9885 modes. To inhibit the warning messages, use @option{-Wno-long-long}.
9887 @item -Wvariadic-macros
9888 @opindex Wvariadic-macros
9889 @opindex Wno-variadic-macros
9890 Warn if variadic macros are used in ISO C90 mode, or if the GNU
9891 alternate syntax is used in ISO C99 mode. This is enabled by either
9892 @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
9893 messages, use @option{-Wno-variadic-macros}.
9897 @opindex Wno-varargs
9898 Do not warn upon questionable usage of the macros used to handle variable
9899 arguments like @code{va_start}. These warnings are enabled by default.
9901 @item -Wvector-operation-performance
9902 @opindex Wvector-operation-performance
9903 @opindex Wno-vector-operation-performance
9904 Warn if vector operation is not implemented via SIMD capabilities of the
9905 architecture. Mainly useful for the performance tuning.
9906 Vector operation can be implemented @code{piecewise}, which means that the
9907 scalar operation is performed on every vector element;
9908 @code{in parallel}, which means that the vector operation is implemented
9909 using scalars of wider type, which normally is more performance efficient;
9910 and @code{as a single scalar}, which means that vector fits into a
9916 Warn if a variable-length array is used in the code.
9917 @option{-Wno-vla} prevents the @option{-Wpedantic} warning of
9918 the variable-length array.
9920 @item -Wvla-larger-than=@var{byte-size}
9921 @opindex Wvla-larger-than=
9922 @opindex Wno-vla-larger-than
9923 If this option is used, the compiler warns for declarations of
9924 variable-length arrays whose size is either unbounded, or bounded
9925 by an argument that allows the array size to exceed @var{byte-size}
9926 bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
9927 works, but with variable-length arrays.
9929 Note that GCC may optimize small variable-length arrays of a known
9930 value into plain arrays, so this warning may not get triggered for
9933 @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
9934 is typically only effective when @option{-ftree-vrp} is active (default
9935 for @option{-O2} and above).
9937 See also @option{-Walloca-larger-than=@var{byte-size}}.
9939 @item -Wno-vla-larger-than
9940 @opindex Wno-vla-larger-than
9941 Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
9942 to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
9944 @item -Wvla-parameter
9945 @opindex Wno-vla-parameter
9946 Warn about redeclarations of functions involving arguments of Variable
9947 Length Array types of inconsistent kinds or forms, and enable the detection
9948 of out-of-bounds accesses to such parameters by warnings such as
9949 @option{-Warray-bounds}.
9951 If the first function declaration uses the VLA form the bound specified
9952 in the array is assumed to be the minimum number of elements expected to
9953 be provided in calls to the function and the maximum number of elements
9954 accessed by it. Failing to provide arguments of sufficient size or
9955 accessing more than the maximum number of elements may be diagnosed.
9957 For example, the warning triggers for the following redeclarations because
9958 the first one allows an array of any size to be passed to @code{f} while
9959 the second one specifies that the array argument must have at least @code{n}
9960 elements. In addition, calling @code{f} with the associated VLA bound
9961 parameter in excess of the actual VLA bound triggers a warning as well.
9964 void f (int n, int[n]);
9965 void f (int, int[]); // warning: argument 2 previously declared as a VLA
9972 f (sizeof a, a); // warning: access to a by f may be out of bounds
9978 @option{-Wvla-parameter} is included in @option{-Wall}. The
9979 @option{-Warray-parameter} option triggers warnings for similar problems
9980 involving ordinary array arguments.
9982 @item -Wvolatile-register-var
9983 @opindex Wvolatile-register-var
9984 @opindex Wno-volatile-register-var
9985 Warn if a register variable is declared volatile. The volatile
9986 modifier does not inhibit all optimizations that may eliminate reads
9987 and/or writes to register variables. This warning is enabled by
9990 @item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
9991 @opindex Wxor-used-as-pow
9992 @opindex Wno-xor-used-as-pow
9993 Warn about uses of @code{^}, the exclusive or operator, where it appears
9994 the user meant exponentiation. Specifically, the warning occurs when the
9995 left-hand side is the decimal constant 2 or 10 and the right-hand side
9996 is also a decimal constant.
9998 In C and C++, @code{^} means exclusive or, whereas in some other languages
9999 (e.g. TeX and some versions of BASIC) it means exponentiation.
10001 This warning is enabled by default. It can be silenced by converting one
10002 of the operands to hexadecimal.
10004 @item -Wdisabled-optimization
10005 @opindex Wdisabled-optimization
10006 @opindex Wno-disabled-optimization
10007 Warn if a requested optimization pass is disabled. This warning does
10008 not generally indicate that there is anything wrong with your code; it
10009 merely indicates that GCC's optimizers are unable to handle the code
10010 effectively. Often, the problem is that your code is too big or too
10011 complex; GCC refuses to optimize programs when the optimization
10012 itself is likely to take inordinate amounts of time.
10014 @item -Wpointer-sign @r{(C and Objective-C only)}
10015 @opindex Wpointer-sign
10016 @opindex Wno-pointer-sign
10017 Warn for pointer argument passing or assignment with different signedness.
10018 This option is only supported for C and Objective-C@. It is implied by
10019 @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10020 @option{-Wno-pointer-sign}.
10022 @item -Wstack-protector
10023 @opindex Wstack-protector
10024 @opindex Wno-stack-protector
10025 This option is only active when @option{-fstack-protector} is active. It
10026 warns about functions that are not protected against stack smashing.
10028 @item -Woverlength-strings
10029 @opindex Woverlength-strings
10030 @opindex Wno-overlength-strings
10031 Warn about string constants that are longer than the ``minimum
10032 maximum'' length specified in the C standard. Modern compilers
10033 generally allow string constants that are much longer than the
10034 standard's minimum limit, but very portable programs should avoid
10035 using longer strings.
10037 The limit applies @emph{after} string constant concatenation, and does
10038 not count the trailing NUL@. In C90, the limit was 509 characters; in
10039 C99, it was raised to 4095. C++98 does not specify a normative
10040 minimum maximum, so we do not diagnose overlength strings in C++@.
10042 This option is implied by @option{-Wpedantic}, and can be disabled with
10043 @option{-Wno-overlength-strings}.
10045 @item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
10046 @opindex Wunsuffixed-float-constants
10047 @opindex Wno-unsuffixed-float-constants
10049 Issue a warning for any floating constant that does not have
10050 a suffix. When used together with @option{-Wsystem-headers} it
10051 warns about such constants in system header files. This can be useful
10052 when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10053 from the decimal floating-point extension to C99.
10055 @item -Wno-lto-type-mismatch
10056 @opindex Wlto-type-mismatch
10057 @opindex Wno-lto-type-mismatch
10059 During the link-time optimization, do not warn about type mismatches in
10060 global declarations from different compilation units.
10061 Requires @option{-flto} to be enabled. Enabled by default.
10063 @item -Wno-designated-init @r{(C and Objective-C only)}
10064 @opindex Wdesignated-init
10065 @opindex Wno-designated-init
10066 Suppress warnings when a positional initializer is used to initialize
10067 a structure that has been marked with the @code{designated_init}
10072 @node Static Analyzer Options
10073 @section Options That Control Static Analysis
10079 @opindex fno-analyzer
10080 This option enables an static analysis of program flow which looks
10081 for ``interesting'' interprocedural paths through the
10082 code, and issues warnings for problems found on them.
10084 This analysis is much more expensive than other GCC warnings.
10086 In technical terms, it performs coverage-guided symbolic execution of
10087 the code being compiled. It is neither sound nor complete: it can
10088 have false positives and false negatives. It is a bug-finding tool,
10089 rather than a tool for proving program correctness.
10091 The analyzer is only suitable for use on C code in this release.
10093 Enabling this option effectively enables the following warnings:
10096 -Wanalyzer-allocation-size @gol
10097 -Wanalyzer-deref-before-check @gol
10098 -Wanalyzer-double-fclose @gol
10099 -Wanalyzer-double-free @gol
10100 -Wanalyzer-exposure-through-output-file @gol
10101 -Wanalyzer-exposure-through-uninit-copy @gol
10102 -Wanalyzer-fd-access-mode-mismatch @gol
10103 -Wanalyzer-fd-double-close @gol
10104 -Wanalyzer-fd-leak @gol
10105 -Wanalyzer-fd-phase-mismatch @gol
10106 -Wanalyzer-fd-type-mismatch @gol
10107 -Wanalyzer-fd-use-after-close @gol
10108 -Wanalyzer-fd-use-without-check @gol
10109 -Wanalyzer-file-leak @gol
10110 -Wanalyzer-free-of-non-heap @gol
10111 -Wanalyzer-imprecise-fp-arithmetic @gol
10112 -Wanalyzer-infinite-recursion @gol
10113 -Wanalyzer-jump-through-null @gol
10114 -Wanalyzer-malloc-leak @gol
10115 -Wanalyzer-mismatching-deallocation @gol
10116 -Wanalyzer-null-argument @gol
10117 -Wanalyzer-null-dereference @gol
10118 -Wanalyzer-out-of-bounds @gol
10119 -Wanalyzer-possible-null-argument @gol
10120 -Wanalyzer-possible-null-dereference @gol
10121 -Wanalyzer-putenv-of-auto-var @gol
10122 -Wanalyzer-shift-count-negative @gol
10123 -Wanalyzer-shift-count-overflow @gol
10124 -Wanalyzer-stale-setjmp-buffer @gol
10125 -Wanalyzer-unsafe-call-within-signal-handler @gol
10126 -Wanalyzer-use-after-free @gol
10127 -Wanalyzer-use-of-pointer-in-stale-stack-frame @gol
10128 -Wanalyzer-use-of-uninitialized-value @gol
10129 -Wanalyzer-va-arg-type-mismatch @gol
10130 -Wanalyzer-va-list-exhausted @gol
10131 -Wanalyzer-va-list-leak @gol
10132 -Wanalyzer-va-list-use-after-va-end @gol
10133 -Wanalyzer-write-to-const @gol
10134 -Wanalyzer-write-to-string-literal @gol
10137 -Wanalyzer-tainted-allocation-size @gol
10138 -Wanalyzer-tainted-array-index @gol
10139 -Wanalyzer-tainted-divisor @gol
10140 -Wanalyzer-tainted-offset @gol
10141 -Wanalyzer-tainted-size @gol
10144 This option is only available if GCC was configured with analyzer
10147 @item -Wanalyzer-too-complex
10148 @opindex Wanalyzer-too-complex
10149 @opindex Wno-analyzer-too-complex
10150 If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10151 to attempt to explore the control flow and data flow in the program,
10152 but these can be defeated by sufficiently complicated code.
10154 By default, the analysis silently stops if the code is too
10155 complicated for the analyzer to fully explore and it reaches an internal
10156 limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10158 @item -Wno-analyzer-allocation-size
10159 @opindex Wanalyzer-allocation-size
10160 @opindex Wno-analyzer-allocation-size
10161 This warning requires @option{-fanalyzer}, which enables it; use
10162 @option{-Wno-analyzer-allocation-size}
10165 This diagnostic warns for paths through the code in which a pointer to
10166 a buffer is assigned to point at a buffer with a size that is not a
10167 multiple of @code{sizeof (*pointer)}.
10169 See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10171 @item -Wno-analyzer-deref-before-check
10172 @opindex Wanalyzer-deref-before-check
10173 @opindex Wno-analyzer-deref-before-check
10174 This warning requires @option{-fanalyzer}, which enables it; use
10175 @option{-Wno-analyzer-deref-before-check}
10178 This diagnostic warns for paths through the code in which a pointer
10179 is checked for @code{NULL} *after* it has already been
10180 dereferenced, suggesting that the pointer could have been NULL.
10181 Such cases suggest that the check for NULL is either redundant,
10182 or that it needs to be moved to before the pointer is dereferenced.
10184 This diagnostic also considers values passed to a function argument
10185 marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10186 value, and thus will complain if such values are checked for @code{NULL}
10187 after returning from such a function call.
10189 This diagnostic is unlikely to be reported when any level of optimization
10190 is enabled, as GCC's optimization logic will typically consider such
10191 checks for NULL as being redundant, and optimize them away before the
10192 analyzer "sees" them. Hence optimization should be disabled when
10193 attempting to trigger this diagnostic.
10195 @item -Wno-analyzer-double-fclose
10196 @opindex Wanalyzer-double-fclose
10197 @opindex Wno-analyzer-double-fclose
10198 This warning requires @option{-fanalyzer}, which enables it; use
10199 @option{-Wno-analyzer-double-fclose} to disable it.
10201 This diagnostic warns for paths through the code in which a @code{FILE *}
10202 can have @code{fclose} called on it more than once.
10204 See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10206 @item -Wno-analyzer-double-free
10207 @opindex Wanalyzer-double-free
10208 @opindex Wno-analyzer-double-free
10209 This warning requires @option{-fanalyzer}, which enables it; use
10210 @option{-Wno-analyzer-double-free} to disable it.
10212 This diagnostic warns for paths through the code in which a pointer
10213 can have a deallocator called on it more than once, either @code{free},
10214 or a deallocator referenced by attribute @code{malloc}.
10216 See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10218 @item -Wno-analyzer-exposure-through-output-file
10219 @opindex Wanalyzer-exposure-through-output-file
10220 @opindex Wno-analyzer-exposure-through-output-file
10221 This warning requires @option{-fanalyzer}, which enables it; use
10222 @option{-Wno-analyzer-exposure-through-output-file}
10225 This diagnostic warns for paths through the code in which a
10226 security-sensitive value is written to an output file
10227 (such as writing a password to a log file).
10229 See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10231 @item -Wanalyzer-exposure-through-uninit-copy
10232 @opindex Wanalyzer-exposure-through-uninit-copy
10233 @opindex Wno-analyzer-exposure-through-uninit-copy
10234 This warning requires both @option{-fanalyzer} and the use of a plugin
10235 to specify a function that copies across a ``trust boundary''. Use
10236 @option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10238 This diagnostic warns for ``infoleaks'' - paths through the code in which
10239 uninitialized values are copied across a security boundary
10240 (such as code within an OS kernel that copies a partially-initialized
10241 struct on the stack to user space).
10243 See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10245 @item -Wno-analyzer-fd-access-mode-mismatch
10246 @opindex Wanalyzer-fd-access-mode-mismatch
10247 @opindex Wno-analyzer-fd-access-mode-mismatch
10248 This warning requires @option{-fanalyzer}, which enables it; use
10249 @option{-Wno-analyzer-fd-access-mode-mismatch}
10252 This diagnostic warns for paths through code in which a
10253 @code{read} on a write-only file descriptor is attempted, or vice versa.
10255 This diagnostic also warns for code paths in a which a function with attribute
10256 @code{fd_arg_read (N)} is called with a file descriptor opened with
10257 @code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10258 @code{fd_arg_write (N)} is called with a file descriptor opened with
10259 @code{O_RDONLY} at referenced argument @var{N}.
10261 @item -Wno-analyzer-fd-double-close
10262 @opindex Wanalyzer-fd-double-close
10263 @opindex Wno-analyzer-fd-double-close
10264 This warning requires @option{-fanalyzer}, which enables it; use
10265 @option{-Wno-analyzer-fd-double-close}
10268 This diagnostic warns for paths through code in which a
10269 file descriptor can be closed more than once.
10271 See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10273 @item -Wno-analyzer-fd-leak
10274 @opindex Wanalyzer-fd-leak
10275 @opindex Wno-analyzer-fd-leak
10276 This warning requires @option{-fanalyzer}, which enables it; use
10277 @option{-Wno-analyzer-fd-leak}
10280 This diagnostic warns for paths through code in which an
10281 open file descriptor is leaked.
10283 See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10285 @item -Wno-analyzer-fd-phase-mismatch
10286 @opindex Wanalyzer-fd-phase-mismatch
10287 @opindex Wno-analyzer-fd-phase-mismatch
10288 This warning requires @option{-fanalyzer}, which enables it; use
10289 @option{-Wno-analyzer-fd-phase-mismatch}
10292 This diagnostic warns for paths through code in which an operation is
10293 attempted in the wrong phase of a file descriptor's lifetime.
10294 For example, it will warn on attempts to call @code{accept} on a stream
10295 socket that has not yet had @code{listen} successfully called on it.
10297 See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10299 @item -Wno-analyzer-fd-type-mismatch
10300 @opindex Wanalyzer-fd-type-mismatch
10301 @opindex Wno-analyzer-fd-type-mismatch
10302 This warning requires @option{-fanalyzer}, which enables it; use
10303 @option{-Wno-analyzer-fd-type-mismatch}
10306 This diagnostic warns for paths through code in which an
10307 operation is attempted on the wrong type of file descriptor.
10308 For example, it will warn on attempts to use socket operations
10309 on a file descriptor obtained via @code{open}, or when attempting
10310 to use a stream socket operation on a datagram socket.
10312 @item -Wno-analyzer-fd-use-after-close
10313 @opindex Wanalyzer-fd-use-after-close
10314 @opindex Wno-analyzer-fd-use-after-close
10315 This warning requires @option{-fanalyzer}, which enables it; use
10316 @option{-Wno-analyzer-fd-use-after-close}
10319 This diagnostic warns for paths through code in which a
10320 read or write is called on a closed file descriptor.
10322 This diagnostic also warns for paths through code in which
10323 a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10324 or @code{fd_arg_write (N)} is called with a closed file descriptor at
10325 referenced argument @code{N}.
10327 @item -Wno-analyzer-fd-use-without-check
10328 @opindex Wanalyzer-fd-use-without-check
10329 @opindex Wno-analyzer-fd-use-without-check
10330 This warning requires @option{-fanalyzer}, which enables it; use
10331 @option{-Wno-analyzer-fd-use-without-check}
10334 This diagnostic warns for paths through code in which a
10335 file descriptor is used without being checked for validity.
10337 This diagnostic also warns for paths through code in which
10338 a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10339 or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10340 argument @code{N}, without being checked for validity.
10342 @item -Wno-analyzer-file-leak
10343 @opindex Wanalyzer-file-leak
10344 @opindex Wno-analyzer-file-leak
10345 This warning requires @option{-fanalyzer}, which enables it; use
10346 @option{-Wno-analyzer-file-leak}
10349 This diagnostic warns for paths through the code in which a
10350 @code{<stdio.h>} @code{FILE *} stream object is leaked.
10352 See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10354 @item -Wno-analyzer-free-of-non-heap
10355 @opindex Wanalyzer-free-of-non-heap
10356 @opindex Wno-analyzer-free-of-non-heap
10357 This warning requires @option{-fanalyzer}, which enables it; use
10358 @option{-Wno-analyzer-free-of-non-heap}
10361 This diagnostic warns for paths through the code in which @code{free}
10362 is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10364 See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10366 @item -Wno-analyzer-imprecise-fp-arithmetic
10367 @opindex Wanalyzer-imprecise-fp-arithmetic
10368 @opindex Wno-analyzer-imprecise-fp-arithmetic
10369 This warning requires @option{-fanalyzer}, which enables it; use
10370 @option{-Wno-analyzer-imprecise-fp-arithmetic}
10373 This diagnostic warns for paths through the code in which floating-point
10374 arithmetic is used in locations where precise computation is needed. This
10375 diagnostic only warns on use of floating-point operands inside the
10376 calculation of an allocation size at the moment.
10378 @item -Wno-analyzer-infinite-recursion
10379 @opindex Wanalyzer-infinite-recursion
10380 @opindex Wno-analyzer-infinite-recursion
10381 This warning requires @option{-fanalyzer}, which enables it; use
10382 @option{-Wno-analyzer-infinite-recursion} to disable it.
10384 This diagnostics warns for paths through the code which appear to
10385 lead to infinite recursion.
10387 Specifically, when the analyzer "sees" a recursive call, it will compare
10388 the state of memory at the entry to the new frame with that at the entry
10389 to the previous frame of that function on the stack. The warning is
10390 issued if nothing in memory appears to be changing; any changes observed
10391 to parameters or globals are assumed to lead to termination of the
10392 recursion and thus suppress the warning.
10394 This diagnostic is likely to miss cases of infinite recursion that
10395 are convered to iteration by the optimizer before the analyzer "sees"
10396 them. Hence optimization should be disabled when attempting to trigger
10399 Compare with @option{-Winfinite-recursion}, which provides a similar
10400 diagnostic, but is implemented in a different way.
10402 @item -Wno-analyzer-jump-through-null
10403 @opindex Wanalyzer-jump-through-null
10404 @opindex Wno-analyzer-jump-through-null
10405 This warning requires @option{-fanalyzer}, which enables it; use
10406 @option{-Wno-analyzer-jump-through-null}
10409 This diagnostic warns for paths through the code in which a @code{NULL}
10410 function pointer is called.
10412 @item -Wno-analyzer-malloc-leak
10413 @opindex Wanalyzer-malloc-leak
10414 @opindex Wno-analyzer-malloc-leak
10415 This warning requires @option{-fanalyzer}, which enables it; use
10416 @option{-Wno-analyzer-malloc-leak}
10419 This diagnostic warns for paths through the code in which a
10420 pointer allocated via an allocator is leaked: either @code{malloc},
10421 or a function marked with attribute @code{malloc}.
10423 See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10425 @item -Wno-analyzer-mismatching-deallocation
10426 @opindex Wanalyzer-mismatching-deallocation
10427 @opindex Wno-analyzer-mismatching-deallocation
10428 This warning requires @option{-fanalyzer}, which enables it; use
10429 @option{-Wno-analyzer-mismatching-deallocation}
10432 This diagnostic warns for paths through the code in which the
10433 wrong deallocation function is called on a pointer value, based on
10434 which function was used to allocate the pointer value. The diagnostic
10435 will warn about mismatches between @code{free}, scalar @code{delete}
10436 and vector @code{delete[]}, and those marked as allocator/deallocator
10437 pairs using attribute @code{malloc}.
10439 See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10441 @item -Wno-analyzer-out-of-bounds
10442 @opindex Wanalyzer-out-of-bounds
10443 @opindex Wno-analyzer-out-of-bounds
10444 This warning requires @option{-fanalyzer} to enable it; use
10445 @option{-Wno-analyzer-out-of-bounds} to disable it.
10447 This diagnostic warns for path through the code in which a buffer is
10448 definitely read or written out-of-bounds. The diagnostic applies for
10449 cases where the analyzer is able to determine a constant offset and for
10450 accesses past the end of a buffer, also a constant capacity. Further,
10451 the diagnostic does limited checking for accesses past the end when the
10452 offset as well as the capacity is symbolic.
10454 See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10456 @item -Wno-analyzer-possible-null-argument
10457 @opindex Wanalyzer-possible-null-argument
10458 @opindex Wno-analyzer-possible-null-argument
10459 This warning requires @option{-fanalyzer}, which enables it; use
10460 @option{-Wno-analyzer-possible-null-argument} to disable it.
10462 This diagnostic warns for paths through the code in which a
10463 possibly-NULL value is passed to a function argument marked
10464 with @code{__attribute__((nonnull))} as requiring a non-NULL
10467 See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10469 @item -Wno-analyzer-possible-null-dereference
10470 @opindex Wanalyzer-possible-null-dereference
10471 @opindex Wno-analyzer-possible-null-dereference
10472 This warning requires @option{-fanalyzer}, which enables it; use
10473 @option{-Wno-analyzer-possible-null-dereference} to disable it.
10475 This diagnostic warns for paths through the code in which a
10476 possibly-NULL value is dereferenced.
10478 See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10480 @item -Wno-analyzer-null-argument
10481 @opindex Wanalyzer-null-argument
10482 @opindex Wno-analyzer-null-argument
10483 This warning requires @option{-fanalyzer}, which enables it; use
10484 @option{-Wno-analyzer-null-argument} to disable it.
10486 This diagnostic warns for paths through the code in which a
10487 value known to be NULL is passed to a function argument marked
10488 with @code{__attribute__((nonnull))} as requiring a non-NULL
10491 See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10493 @item -Wno-analyzer-null-dereference
10494 @opindex Wanalyzer-null-dereference
10495 @opindex Wno-analyzer-null-dereference
10496 This warning requires @option{-fanalyzer}, which enables it; use
10497 @option{-Wno-analyzer-null-dereference} to disable it.
10499 This diagnostic warns for paths through the code in which a
10500 value known to be NULL is dereferenced.
10502 See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10504 @item -Wno-analyzer-putenv-of-auto-var
10505 @opindex Wanalyzer-putenv-of-auto-var
10506 @opindex Wno-analyzer-putenv-of-auto-var
10507 This warning requires @option{-fanalyzer}, which enables it; use
10508 @option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10510 This diagnostic warns for paths through the code in which a
10511 call to @code{putenv} is passed a pointer to an automatic variable
10512 or an on-stack buffer.
10514 See @uref{https://wiki.sei.cmu.edu/confluence/x/6NYxBQ, POS34-C. Do not call putenv() with a pointer to an automatic variable as the argument}.
10516 @item -Wno-analyzer-shift-count-negative
10517 @opindex Wanalyzer-shift-count-negative
10518 @opindex Wno-analyzer-shift-count-negative
10519 This warning requires @option{-fanalyzer}, which enables it; use
10520 @option{-Wno-analyzer-shift-count-negative} to disable it.
10522 This diagnostic warns for paths through the code in which a
10523 shift is attempted with a negative count. It is analogous to
10524 the @option{-Wshift-count-negative} diagnostic implemented in
10525 the C/C++ front ends, but is implemented based on analyzing
10526 interprocedural paths, rather than merely parsing the syntax tree.
10527 However, the analyzer does not prioritize detection of such paths, so
10528 false negatives are more likely relative to other warnings.
10530 @item -Wno-analyzer-shift-count-overflow
10531 @opindex Wanalyzer-shift-count-overflow
10532 @opindex Wno-analyzer-shift-count-overflow
10533 This warning requires @option{-fanalyzer}, which enables it; use
10534 @option{-Wno-analyzer-shift-count-overflow} to disable it.
10536 This diagnostic warns for paths through the code in which a
10537 shift is attempted with a count greater than or equal to the
10538 precision of the operand's type. It is analogous to
10539 the @option{-Wshift-count-overflow} diagnostic implemented in
10540 the C/C++ front ends, but is implemented based on analyzing
10541 interprocedural paths, rather than merely parsing the syntax tree.
10542 However, the analyzer does not prioritize detection of such paths, so
10543 false negatives are more likely relative to other warnings.
10545 @item -Wno-analyzer-stale-setjmp-buffer
10546 @opindex Wanalyzer-stale-setjmp-buffer
10547 @opindex Wno-analyzer-stale-setjmp-buffer
10548 This warning requires @option{-fanalyzer}, which enables it; use
10549 @option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10551 This diagnostic warns for paths through the code in which
10552 @code{longjmp} is called to rewind to a @code{jmp_buf} relating
10553 to a @code{setjmp} call in a function that has returned.
10555 When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10556 location, it records the stack frame. The stack frame becomes invalid
10557 when the function containing the @code{setjmp} call returns. Attempting
10558 to rewind to it via @code{longjmp} would reference a stack frame that
10559 no longer exists, and likely lead to a crash (or worse).
10561 @item -Wno-analyzer-tainted-allocation-size
10562 @opindex Wanalyzer-tainted-allocation-size
10563 @opindex Wno-analyzer-tainted-allocation-size
10564 This warning requires both @option{-fanalyzer} and
10565 @option{-fanalyzer-checker=taint} to enable it;
10566 use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10568 This diagnostic warns for paths through the code in which a value
10569 that could be under an attacker's control is used as the size
10570 of an allocation without being sanitized, so that an attacker could
10571 inject an excessively large allocation and potentially cause a denial
10574 See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10576 @item -Wno-analyzer-tainted-assertion
10577 @opindex Wanalyzer-tainted-assertion
10578 @opindex Wno-analyzer-tainted-assertion
10580 This warning requires both @option{-fanalyzer} and
10581 @option{-fanalyzer-checker=taint} to enable it;
10582 use @option{-Wno-analyzer-tainted-assertion} to disable it.
10584 This diagnostic warns for paths through the code in which a value
10585 that could be under an attacker's control is used as part of a
10586 condition without being first sanitized, and that condition guards a
10587 call to a function marked with attribute @code{noreturn}
10588 (such as the function @code{__builtin_unreachable}). Such functions
10589 typically indicate abnormal termination of the program, such as for
10590 assertion failure handlers. For example:
10593 assert (some_tainted_value < SOME_LIMIT);
10600 when assertion-checking is enabled: an attacker could trigger
10601 a denial of service by injecting an assertion failure
10604 when assertion-checking is disabled, such as by defining @code{NDEBUG},
10605 an attacker could inject data that subverts the process, since it
10606 presumably violates a precondition that is being assumed by the code.
10610 Note that when assertion-checking is disabled, the assertions are
10611 typically removed by the preprocessor before the analyzer has a chance
10612 to "see" them, so this diagnostic can only generate warnings on builds
10613 in which assertion-checking is enabled.
10615 For the purpose of this warning, any function marked with attribute
10616 @code{noreturn} is considered as a possible assertion failure
10617 handler, including @code{__builtin_unreachable}. Note that these functions
10618 are sometimes removed by the optimizer before the analyzer "sees" them.
10619 Hence optimization should be disabled when attempting to trigger this
10622 See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10624 The warning can also report problematic constructions such as
10627 switch (some_tainted_value) @{
10629 /* [...etc; various valid cases omitted...] */
10633 __builtin_unreachable (); /* BUG: attacker can trigger this */
10637 despite the above not being an assertion failure, strictly speaking.
10639 @item -Wno-analyzer-tainted-array-index
10640 @opindex Wanalyzer-tainted-array-index
10641 @opindex Wno-analyzer-tainted-array-index
10642 This warning requires both @option{-fanalyzer} and
10643 @option{-fanalyzer-checker=taint} to enable it;
10644 use @option{-Wno-analyzer-tainted-array-index} to disable it.
10646 This diagnostic warns for paths through the code in which a value
10647 that could be under an attacker's control is used as the index
10648 of an array access without being sanitized, so that an attacker
10649 could inject an out-of-bounds access.
10651 See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10653 @item -Wno-analyzer-tainted-divisor
10654 @opindex Wanalyzer-tainted-divisor
10655 @opindex Wno-analyzer-tainted-divisor
10656 This warning requires both @option{-fanalyzer} and
10657 @option{-fanalyzer-checker=taint} to enable it;
10658 use @option{-Wno-analyzer-tainted-divisor} to disable it.
10660 This diagnostic warns for paths through the code in which a value
10661 that could be under an attacker's control is used as the divisor
10662 in a division or modulus operation without being sanitized, so that
10663 an attacker could inject a division-by-zero.
10665 See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10667 @item -Wno-analyzer-tainted-offset
10668 @opindex Wanalyzer-tainted-offset
10669 @opindex Wno-analyzer-tainted-offset
10670 This warning requires both @option{-fanalyzer} and
10671 @option{-fanalyzer-checker=taint} to enable it;
10672 use @option{-Wno-analyzer-tainted-offset} to disable it.
10674 This diagnostic warns for paths through the code in which a value
10675 that could be under an attacker's control is used as a pointer offset
10676 without being sanitized, so that an attacker could inject an out-of-bounds
10679 See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10681 @item -Wno-analyzer-tainted-size
10682 @opindex Wanalyzer-tainted-size
10683 @opindex Wno-analyzer-tainted-size
10684 This warning requires both @option{-fanalyzer} and
10685 @option{-fanalyzer-checker=taint} to enable it;
10686 use @option{-Wno-analyzer-tainted-size} to disable it.
10688 This diagnostic warns for paths through the code in which a value
10689 that could be under an attacker's control is used as the size of
10690 an operation such as @code{memset} without being sanitized, so that an
10691 attacker could inject an out-of-bounds access.
10693 See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10695 @item -Wno-analyzer-unsafe-call-within-signal-handler
10696 @opindex Wanalyzer-unsafe-call-within-signal-handler
10697 @opindex Wno-analyzer-unsafe-call-within-signal-handler
10698 This warning requires @option{-fanalyzer}, which enables it; use
10699 @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
10701 This diagnostic warns for paths through the code in which a
10702 function known to be async-signal-unsafe (such as @code{fprintf}) is
10703 called from a signal handler.
10705 See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
10707 @item -Wno-analyzer-use-after-free
10708 @opindex Wanalyzer-use-after-free
10709 @opindex Wno-analyzer-use-after-free
10710 This warning requires @option{-fanalyzer}, which enables it; use
10711 @option{-Wno-analyzer-use-after-free} to disable it.
10713 This diagnostic warns for paths through the code in which a
10714 pointer is used after a deallocator is called on it: either @code{free},
10715 or a deallocator referenced by attribute @code{malloc}.
10717 See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
10719 @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
10720 @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
10721 @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
10722 This warning requires @option{-fanalyzer}, which enables it; use
10723 @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
10726 This diagnostic warns for paths through the code in which a pointer
10727 is dereferenced that points to a variable in a stale stack frame.
10729 @item -Wno-analyzer-va-arg-type-mismatch
10730 @opindex Wanalyzer-va-arg-type-mismatch
10731 @opindex Wno-analyzer-va-arg-type-mismatch
10732 This warning requires @option{-fanalyzer}, which enables it; use
10733 @option{-Wno-analyzer-va-arg-type-mismatch}
10736 This diagnostic warns for interprocedural paths through the code for which
10737 the analyzer detects an attempt to use @code{va_arg} to extract a value
10738 passed to a variadic call, but uses a type that does not match that of
10739 the expression passed to the call.
10741 See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
10743 @item -Wno-analyzer-va-list-exhausted
10744 @opindex Wanalyzer-va-list-exhausted
10745 @opindex Wno-analyzer-va-list-exhausted
10746 This warning requires @option{-fanalyzer}, which enables it; use
10747 @option{-Wno-analyzer-va-list-exhausted}
10750 This diagnostic warns for interprocedural paths through the code for which
10751 the analyzer detects an attempt to use @code{va_arg} to access the next
10752 value passed to a variadic call, but all of the values in the
10753 @code{va_list} have already been consumed.
10755 See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
10757 @item -Wno-analyzer-va-list-leak
10758 @opindex Wanalyzer-va-list-leak
10759 @opindex Wno-analyzer-va-list-leak
10760 This warning requires @option{-fanalyzer}, which enables it; use
10761 @option{-Wno-analyzer-va-list-leak}
10764 This diagnostic warns for interprocedural paths through the code for which
10765 the analyzer detects that @code{va_start} or @code{va_copy} has been called
10766 on a @code{va_list} without a corresponding call to @code{va_end}.
10768 @item -Wno-analyzer-va-list-use-after-va-end
10769 @opindex Wanalyzer-va-list-use-after-va-end
10770 @opindex Wno-analyzer-va-list-use-after-va-end
10771 This warning requires @option{-fanalyzer}, which enables it; use
10772 @option{-Wno-analyzer-va-list-use-after-va-end}
10775 This diagnostic warns for interprocedural paths through the code for which
10776 the analyzer detects an attempt to use a @code{va_list} after
10777 @code{va_end} has been called on it.
10780 @item -Wno-analyzer-write-to-const
10781 @opindex Wanalyzer-write-to-const
10782 @opindex Wno-analyzer-write-to-const
10783 This warning requires @option{-fanalyzer}, which enables it; use
10784 @option{-Wno-analyzer-write-to-const}
10787 This diagnostic warns for paths through the code in which the analyzer
10788 detects an attempt to write through a pointer to a @code{const} object.
10789 However, the analyzer does not prioritize detection of such paths, so
10790 false negatives are more likely relative to other warnings.
10792 @item -Wno-analyzer-write-to-string-literal
10793 @opindex Wanalyzer-write-to-string-literal
10794 @opindex Wno-analyzer-write-to-string-literal
10795 This warning requires @option{-fanalyzer}, which enables it; use
10796 @option{-Wno-analyzer-write-to-string-literal}
10799 This diagnostic warns for paths through the code in which the analyzer
10800 detects an attempt to write through a pointer to a string literal.
10801 However, the analyzer does not prioritize detection of such paths, so
10802 false negatives are more likely relative to other warnings.
10804 @item -Wno-analyzer-use-of-uninitialized-value
10805 @opindex Wanalyzer-use-of-uninitialized-value
10806 @opindex Wno-analyzer-use-of-uninitialized-value
10807 This warning requires @option{-fanalyzer}, which enables it; use
10808 @option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
10810 This diagnostic warns for paths through the code in which an uninitialized
10813 See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
10817 The analyzer has hardcoded knowledge about the behavior of the following
10818 memory-management functions:
10821 @item @code{alloca}
10822 @item The built-in functions @code{__builtin_alloc},
10823 @code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
10824 @code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
10825 @code{__builtin_memcpy_chk}, @code{__builtin_memset},
10826 @code{__builtin_memset_chk}, @code{__builtin_realloc},
10827 @code{__builtin_stack_restore}, and @code{__builtin_stack_save}
10828 @item @code{calloc}
10830 @item @code{malloc}
10831 @item @code{memset}
10832 @item @code{operator delete}
10833 @item @code{operator delete []}
10834 @item @code{operator new}
10835 @item @code{operator new []}
10836 @item @code{realloc}
10837 @item @code{strdup}
10838 @item @code{strndup}
10841 of the following functions for working with file descriptors:
10847 @item @code{dup}, @code{dup2} and @code{dup3}
10848 @item @code{isatty}
10849 @item @code{pipe}, and @code{pipe2}
10852 @item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
10855 of the following functions for working with @code{<stdio.h>} streams:
10857 @item The built-in functions @code{__builtin_fprintf},
10858 @code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
10859 @code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
10860 @code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
10861 @code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
10862 @code{__builtin_printf_unlocked}, @code{__builtin_putc},
10863 @code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
10864 @code{__builtin_putc_unlocked}, @code{__builtin_puts},
10865 @code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
10866 @code{__builtin_vprintf}
10868 @item @code{fclose}
10869 @item @code{ferror}
10871 @item @code{fgets_unlocked}
10872 @item @code{fileno}
10875 @item @code{getchar}
10876 @item @code{fprintf}
10877 @item @code{printf}
10878 @item @code{fwrite}
10881 and of the following functions:
10884 @item The built-in functions @code{__builtin_expect},
10885 @code{__builtin_expect_with_probability}, @code{__builtin_strchr},
10886 @code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
10887 @code{__builtin_strlen}, @code{__builtin_va_copy}, and
10888 @code{__builtin_va_start}
10889 @item The GNU extensions @code{error} and @code{error_at_line}
10890 @item @code{getpass}
10891 @item @code{longjmp}
10892 @item @code{putenv}
10893 @item @code{setjmp}
10894 @item @code{siglongjmp}
10895 @item @code{signal}
10896 @item @code{sigsetjmp}
10897 @item @code{strchr}
10898 @item @code{strlen}
10901 In addition, various functions with an @code{__analyzer_} prefix have
10902 special meaning to the analyzer, described in the GCC Internals manual.
10904 Pertinent parameters for controlling the exploration are:
10905 @option{--param analyzer-bb-explosion-factor=@var{value}},
10906 @option{--param analyzer-max-enodes-per-program-point=@var{value}},
10907 @option{--param analyzer-max-recursion-depth=@var{value}}, and
10908 @option{--param analyzer-min-snodes-for-call-summary=@var{value}}.
10910 The following options control the analyzer.
10914 @item -fanalyzer-call-summaries
10915 @opindex fanalyzer-call-summaries
10916 @opindex fno-analyzer-call-summaries
10917 Simplify interprocedural analysis by computing the effect of certain calls,
10918 rather than exploring all paths through the function from callsite to each
10921 If enabled, call summaries are only used for functions with more than one
10922 call site, and that are sufficiently complicated (as per
10923 @option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
10925 @item -fanalyzer-checker=@var{name}
10926 @opindex fanalyzer-checker
10927 Restrict the analyzer to run just the named checker, and enable it.
10929 Some checkers are disabled by default (even with @option{-fanalyzer}),
10930 such as the @code{taint} checker that implements
10931 @option{-Wanalyzer-tainted-array-index}, and this option is required
10934 @emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
10935 following warnings from @option{-fanalyzer}:
10938 -Wanalyzer-deref-before-check @gol
10939 -Wanalyzer-double-fclose @gol
10940 -Wanalyzer-double-free @gol
10941 -Wanalyzer-exposure-through-output-file @gol
10942 -Wanalyzer-fd-access-mode-mismatch @gol
10943 -Wanalyzer-fd-double-close @gol
10944 -Wanalyzer-fd-leak @gol
10945 -Wanalyzer-fd-use-after-close @gol
10946 -Wanalyzer-fd-use-without-check @gol
10947 -Wanalyzer-file-leak @gol
10948 -Wanalyzer-free-of-non-heap @gol
10949 -Wanalyzer-malloc-leak @gol
10950 -Wanalyzer-mismatching-deallocation @gol
10951 -Wanalyzer-null-argument @gol
10952 -Wanalyzer-null-dereference @gol
10953 -Wanalyzer-possible-null-argument @gol
10954 -Wanalyzer-possible-null-dereference @gol
10955 -Wanalyzer-unsafe-call-within-signal-handler @gol
10956 -Wanalyzer-use-after-free @gol
10957 -Wanalyzer-va-list-leak @gol
10958 -Wanalyzer-va-list-use-after-va-end @gol
10961 @item -fno-analyzer-feasibility
10962 @opindex fanalyzer-feasibility
10963 @opindex fno-analyzer-feasibility
10964 This option is intended for analyzer developers.
10966 By default the analyzer verifies that there is a feasible control flow path
10967 for each diagnostic it emits: that the conditions that hold are not mutually
10968 exclusive. Diagnostics for which no feasible path can be found are rejected.
10969 This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
10970 debugging issues in this code.
10972 @item -fanalyzer-fine-grained
10973 @opindex fanalyzer-fine-grained
10974 @opindex fno-analyzer-fine-grained
10975 This option is intended for analyzer developers.
10977 Internally the analyzer builds an ``exploded graph'' that combines
10978 control flow graphs with data flow information.
10980 By default, an edge in this graph can contain the effects of a run
10981 of multiple statements within a basic block. With
10982 @option{-fanalyzer-fine-grained}, each statement gets its own edge.
10984 @item -fanalyzer-show-duplicate-count
10985 @opindex fanalyzer-show-duplicate-count
10986 @opindex fno-analyzer-show-duplicate-count
10987 This option is intended for analyzer developers: if multiple diagnostics
10988 have been detected as being duplicates of each other, it emits a note when
10989 reporting the best diagnostic, giving the number of additional diagnostics
10990 that were suppressed by the deduplication logic.
10992 @item -fno-analyzer-state-merge
10993 @opindex fanalyzer-state-merge
10994 @opindex fno-analyzer-state-merge
10995 This option is intended for analyzer developers.
10997 By default the analyzer attempts to simplify analysis by merging
10998 sufficiently similar states at each program point as it builds its
10999 ``exploded graph''. With @option{-fno-analyzer-state-merge} this
11000 merging can be suppressed, for debugging state-handling issues.
11002 @item -fno-analyzer-state-purge
11003 @opindex fanalyzer-state-purge
11004 @opindex fno-analyzer-state-purge
11005 This option is intended for analyzer developers.
11007 By default the analyzer attempts to simplify analysis by purging
11008 aspects of state at a program point that appear to no longer be relevant
11009 e.g. the values of locals that aren't accessed later in the function
11010 and which aren't relevant to leak analysis.
11012 With @option{-fno-analyzer-state-purge} this purging of state can
11013 be suppressed, for debugging state-handling issues.
11015 @item -fanalyzer-transitivity
11016 @opindex fanalyzer-transitivity
11017 @opindex fno-analyzer-transitivity
11018 This option enables transitivity of constraints within the analyzer.
11020 @item -fno-analyzer-undo-inlining
11021 @opindex fanalyzer-undo-inlining
11022 @opindex fno-analyzer-undo-inlining
11023 This option is intended for analyzer developers.
11025 @option{-fanalyzer} runs relatively late compared to other code analysis
11026 tools, and some optimizations have already been applied to the code. In
11027 particular function inlining may have occurred, leading to the
11028 interprocedural execution paths emitted by the analyzer containing
11029 function frames that don't correspond to those in the original source
11032 By default the analyzer attempts to reconstruct the original function
11033 frames, and to emit events showing the inlined calls.
11035 With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11036 the original frame information can be be disabled, which may be of help
11037 when debugging issues in the analyzer.
11039 @item -fanalyzer-verbose-edges
11040 This option is intended for analyzer developers. It enables more
11041 verbose, lower-level detail in the descriptions of control flow
11042 within diagnostic paths.
11044 @item -fanalyzer-verbose-state-changes
11045 This option is intended for analyzer developers. It enables more
11046 verbose, lower-level detail in the descriptions of events relating
11047 to state machines within diagnostic paths.
11049 @item -fanalyzer-verbosity=@var{level}
11050 This option controls the complexity of the control flow paths that are
11051 emitted for analyzer diagnostics.
11053 The @var{level} can be one of:
11057 At this level, interprocedural call and return events are displayed,
11058 along with the most pertinent state-change events relating to
11059 a diagnostic. For example, for a double-@code{free} diagnostic,
11060 both calls to @code{free} will be shown.
11063 As per the previous level, but also show events for the entry
11067 As per the previous level, but also show events relating to
11068 control flow that are significant to triggering the issue
11069 (e.g. ``true path taken'' at a conditional).
11071 This level is the default.
11074 As per the previous level, but show all control flow events, not
11075 just significant ones.
11078 This level is intended for analyzer developers; it adds various
11079 other events intended for debugging the analyzer.
11083 @item -fdump-analyzer
11084 @opindex fdump-analyzer
11085 Dump internal details about what the analyzer is doing to
11086 @file{@var{file}.analyzer.txt}.
11087 This option is overridden by @option{-fdump-analyzer-stderr}.
11089 @item -fdump-analyzer-stderr
11090 @opindex fdump-analyzer-stderr
11091 Dump internal details about what the analyzer is doing to stderr.
11092 This option overrides @option{-fdump-analyzer}.
11094 @item -fdump-analyzer-callgraph
11095 @opindex fdump-analyzer-callgraph
11096 Dump a representation of the call graph suitable for viewing with
11097 GraphViz to @file{@var{file}.callgraph.dot}.
11099 @item -fdump-analyzer-exploded-graph
11100 @opindex fdump-analyzer-exploded-graph
11101 Dump a representation of the ``exploded graph'' suitable for viewing with
11102 GraphViz to @file{@var{file}.eg.dot}.
11103 Nodes are color-coded based on state-machine states to emphasize
11106 @item -fdump-analyzer-exploded-nodes
11107 @opindex dump-analyzer-exploded-nodes
11108 Emit diagnostics showing where nodes in the ``exploded graph'' are
11109 in relation to the program source.
11111 @item -fdump-analyzer-exploded-nodes-2
11112 @opindex dump-analyzer-exploded-nodes-2
11113 Dump a textual representation of the ``exploded graph'' to
11114 @file{@var{file}.eg.txt}.
11116 @item -fdump-analyzer-exploded-nodes-3
11117 @opindex dump-analyzer-exploded-nodes-3
11118 Dump a textual representation of the ``exploded graph'' to
11119 one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11120 This is typically a large number of dump files.
11122 @item -fdump-analyzer-exploded-paths
11123 @opindex fdump-analyzer-exploded-paths
11124 Dump a textual representation of the ``exploded path'' for each
11125 diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11127 @item -fdump-analyzer-feasibility
11128 @opindex dump-analyzer-feasibility
11129 Dump internal details about the analyzer's search for feasible paths.
11130 The details are written in a form suitable for viewing with GraphViz
11131 to filenames of the form @file{@var{file}.*.fg.dot},
11132 @file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11134 @item -fdump-analyzer-json
11135 @opindex fdump-analyzer-json
11136 Dump a compressed JSON representation of analyzer internals to
11137 @file{@var{file}.analyzer.json.gz}. The precise format is subject
11140 @item -fdump-analyzer-state-purge
11141 @opindex fdump-analyzer-state-purge
11142 As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11143 ``supergraph'' suitable for viewing with GraphViz, but annotate the
11144 graph with information on what state will be purged at each node.
11145 The graph is written to @file{@var{file}.state-purge.dot}.
11147 @item -fdump-analyzer-supergraph
11148 @opindex fdump-analyzer-supergraph
11149 Dump representations of the ``supergraph'' suitable for viewing with
11150 GraphViz to @file{@var{file}.supergraph.dot} and to
11151 @file{@var{file}.supergraph-eg.dot}. These show all of the
11152 control flow graphs in the program, with interprocedural edges for
11153 calls and returns. The second dump contains annotations showing nodes
11154 in the ``exploded graph'' and diagnostics associated with them.
11156 @item -fdump-analyzer-untracked
11157 @opindex fdump-analyzer-untracked
11158 Emit custom warnings with internal details intended for analyzer developers.
11162 @node Debugging Options
11163 @section Options for Debugging Your Program
11164 @cindex options, debugging
11165 @cindex debugging information options
11167 To tell GCC to emit extra information for use by a debugger, in almost
11168 all cases you need only to add @option{-g} to your other options. Some debug
11169 formats can co-exist (like DWARF with CTF) when each of them is enabled
11170 explicitly by adding the respective command line option to your other options.
11172 GCC allows you to use @option{-g} with
11173 @option{-O}. The shortcuts taken by optimized code may occasionally
11174 be surprising: some variables you declared may not exist
11175 at all; flow of control may briefly move where you did not expect it;
11176 some statements may not be executed because they compute constant
11177 results or their values are already at hand; some statements may
11178 execute in different places because they have been moved out of loops.
11179 Nevertheless it is possible to debug optimized output. This makes
11180 it reasonable to use the optimizer for programs that might have bugs.
11182 If you are not using some other optimization option, consider
11183 using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11184 With no @option{-O} option at all, some compiler passes that collect
11185 information useful for debugging do not run at all, so that
11186 @option{-Og} may result in a better debugging experience.
11191 Produce debugging information in the operating system's native format
11192 (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11195 On most systems that use stabs format, @option{-g} enables use of extra
11196 debugging information that only GDB can use; this extra information
11197 makes debugging work better in GDB but probably makes other debuggers
11198 crash or refuse to read the program. If you want to control for certain whether
11199 to generate the extra information, use @option{-gvms} (see below).
11203 Produce debugging information for use by GDB@. This means to use the
11204 most expressive format available (DWARF, stabs, or the native format
11205 if neither of those are supported), including GDB extensions if at all
11209 @itemx -gdwarf-@var{version}
11211 Produce debugging information in DWARF format (if that is supported).
11212 The value of @var{version} may be either 2, 3, 4 or 5; the default
11213 version for most targets is 5 (with the exception of VxWorks, TPF and
11214 Darwin/Mac OS X, which default to version 2, and AIX, which defaults
11217 Note that with DWARF Version 2, some ports require and always
11218 use some non-conflicting DWARF 3 extensions in the unwind tables.
11220 Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11221 for maximum benefit. Version 5 requires GDB 8.0 or higher.
11223 GCC no longer supports DWARF Version 1, which is substantially
11224 different than Version 2 and later. For historical reasons, some
11225 other DWARF-related options such as
11226 @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11227 in their names, but apply to all currently-supported versions of DWARF.
11231 Request BTF debug information. BTF is the default debugging format for the
11232 eBPF target. On other targets, like x86, BTF debug information can be
11233 generated along with DWARF debug information when both of the debug formats are
11234 enabled explicitly via their respective command line options.
11237 @itemx -gctf@var{level}
11239 Request CTF debug information and use level to specify how much CTF debug
11240 information should be produced. If @option{-gctf} is specified
11241 without a value for level, the default level of CTF debug information is 2.
11243 CTF debug information can be generated along with DWARF debug information when
11244 both of the debug formats are enabled explicitly via their respective command
11247 Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11248 negates @option{-gctf}.
11250 Level 1 produces CTF information for tracebacks only. This includes callsite
11251 information, but does not include type information.
11253 Level 2 produces type information for entities (functions, data objects etc.)
11254 at file-scope or global-scope only.
11258 Produce debugging information in Alpha/VMS debug format (if that is
11259 supported). This is the format used by DEBUG on Alpha/VMS systems.
11261 @item -g@var{level}
11262 @itemx -ggdb@var{level}
11263 @itemx -gvms@var{level}
11264 Request debugging information and also use @var{level} to specify how
11265 much information. The default level is 2.
11267 Level 0 produces no debug information at all. Thus, @option{-g0} negates
11270 Level 1 produces minimal information, enough for making backtraces in
11271 parts of the program that you don't plan to debug. This includes
11272 descriptions of functions and external variables, and line number
11273 tables, but no information about local variables.
11275 Level 3 includes extra information, such as all the macro definitions
11276 present in the program. Some debuggers support macro expansion when
11277 you use @option{-g3}.
11279 If you use multiple @option{-g} options, with or without level numbers,
11280 the last such option is the one that is effective.
11282 @option{-gdwarf} does not accept a concatenated debug level, to avoid
11283 confusion with @option{-gdwarf-@var{level}}.
11284 Instead use an additional @option{-g@var{level}} option to change the
11285 debug level for DWARF.
11287 @item -fno-eliminate-unused-debug-symbols
11288 @opindex feliminate-unused-debug-symbols
11289 @opindex fno-eliminate-unused-debug-symbols
11290 By default, no debug information is produced for symbols that are not actually
11291 used. Use this option if you want debug information for all symbols.
11293 @item -femit-class-debug-always
11294 @opindex femit-class-debug-always
11295 Instead of emitting debugging information for a C++ class in only one
11296 object file, emit it in all object files using the class. This option
11297 should be used only with debuggers that are unable to handle the way GCC
11298 normally emits debugging information for classes because using this
11299 option increases the size of debugging information by as much as a
11302 @item -fno-merge-debug-strings
11303 @opindex fmerge-debug-strings
11304 @opindex fno-merge-debug-strings
11305 Direct the linker to not merge together strings in the debugging
11306 information that are identical in different object files. Merging is
11307 not supported by all assemblers or linkers. Merging decreases the size
11308 of the debug information in the output file at the cost of increasing
11309 link processing time. Merging is enabled by default.
11311 @item -fdebug-prefix-map=@var{old}=@var{new}
11312 @opindex fdebug-prefix-map
11313 When compiling files residing in directory @file{@var{old}}, record
11314 debugging information describing them as if the files resided in
11315 directory @file{@var{new}} instead. This can be used to replace a
11316 build-time path with an install-time path in the debug info. It can
11317 also be used to change an absolute path to a relative path by using
11318 @file{.} for @var{new}. This can give more reproducible builds, which
11319 are location independent, but may require an extra command to tell GDB
11320 where to find the source files. See also @option{-ffile-prefix-map}.
11322 @item -fvar-tracking
11323 @opindex fvar-tracking
11324 Run variable tracking pass. It computes where variables are stored at each
11325 position in code. Better debugging information is then generated
11326 (if the debugging information format supports this information).
11328 It is enabled by default when compiling with optimization (@option{-Os},
11329 @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11330 the debug info format supports it.
11332 @item -fvar-tracking-assignments
11333 @opindex fvar-tracking-assignments
11334 @opindex fno-var-tracking-assignments
11335 Annotate assignments to user variables early in the compilation and
11336 attempt to carry the annotations over throughout the compilation all the
11337 way to the end, in an attempt to improve debug information while
11338 optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11340 It can be enabled even if var-tracking is disabled, in which case
11341 annotations are created and maintained, but discarded at the end.
11342 By default, this flag is enabled together with @option{-fvar-tracking},
11343 except when selective scheduling is enabled.
11345 @item -gsplit-dwarf
11346 @opindex gsplit-dwarf
11347 If DWARF debugging information is enabled, separate as much debugging
11348 information as possible into a separate output file with the extension
11349 @file{.dwo}. This option allows the build system to avoid linking files with
11350 debug information. To be useful, this option requires a debugger capable of
11351 reading @file{.dwo} files.
11357 If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11358 the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11359 DWARF format. The default is target specific, on most targets it is
11360 @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11361 can't support more than 2GiB of debug information in any of the DWARF
11362 debug information sections. The 64-bit DWARF format allows larger debug
11363 information and might not be well supported by all consumers yet.
11365 @item -gdescribe-dies
11366 @opindex gdescribe-dies
11367 Add description attributes to some DWARF DIEs that have no name attribute,
11368 such as artificial variables, external references and call site
11373 Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11375 @item -ggnu-pubnames
11376 @opindex ggnu-pubnames
11377 Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11378 suitable for conversion into a GDB@ index. This option is only useful
11379 with a linker that can produce GDB@ index version 7.
11381 @item -fdebug-types-section
11382 @opindex fdebug-types-section
11383 @opindex fno-debug-types-section
11384 When using DWARF Version 4 or higher, type DIEs can be put into
11385 their own @code{.debug_types} section instead of making them part of the
11386 @code{.debug_info} section. It is more efficient to put them in a separate
11387 comdat section since the linker can then remove duplicates.
11388 But not all DWARF consumers support @code{.debug_types} sections yet
11389 and on some objects @code{.debug_types} produces larger instead of smaller
11390 debugging information.
11392 @item -grecord-gcc-switches
11393 @itemx -gno-record-gcc-switches
11394 @opindex grecord-gcc-switches
11395 @opindex gno-record-gcc-switches
11396 This switch causes the command-line options used to invoke the
11397 compiler that may affect code generation to be appended to the
11398 DW_AT_producer attribute in DWARF debugging information. The options
11399 are concatenated with spaces separating them from each other and from
11400 the compiler version.
11401 It is enabled by default.
11402 See also @option{-frecord-gcc-switches} for another
11403 way of storing compiler options into the object file.
11405 @item -gstrict-dwarf
11406 @opindex gstrict-dwarf
11407 Disallow using extensions of later DWARF standard version than selected
11408 with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11409 DWARF extensions from later standard versions is allowed.
11411 @item -gno-strict-dwarf
11412 @opindex gno-strict-dwarf
11413 Allow using extensions of later DWARF standard version than selected with
11414 @option{-gdwarf-@var{version}}.
11416 @item -gas-loc-support
11417 @opindex gas-loc-support
11418 Inform the compiler that the assembler supports @code{.loc} directives.
11419 It may then use them for the assembler to generate DWARF2+ line number
11422 This is generally desirable, because assembler-generated line-number
11423 tables are a lot more compact than those the compiler can generate
11426 This option will be enabled by default if, at GCC configure time, the
11427 assembler was found to support such directives.
11429 @item -gno-as-loc-support
11430 @opindex gno-as-loc-support
11431 Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11432 line number tables are to be generated.
11434 @item -gas-locview-support
11435 @opindex gas-locview-support
11436 Inform the compiler that the assembler supports @code{view} assignment
11437 and reset assertion checking in @code{.loc} directives.
11439 This option will be enabled by default if, at GCC configure time, the
11440 assembler was found to support them.
11442 @item -gno-as-locview-support
11443 Force GCC to assign view numbers internally, if
11444 @option{-gvariable-location-views} are explicitly requested.
11446 @item -gcolumn-info
11447 @itemx -gno-column-info
11448 @opindex gcolumn-info
11449 @opindex gno-column-info
11450 Emit location column information into DWARF debugging information, rather
11451 than just file and line.
11452 This option is enabled by default.
11454 @item -gstatement-frontiers
11455 @itemx -gno-statement-frontiers
11456 @opindex gstatement-frontiers
11457 @opindex gno-statement-frontiers
11458 This option causes GCC to create markers in the internal representation
11459 at the beginning of statements, and to keep them roughly in place
11460 throughout compilation, using them to guide the output of @code{is_stmt}
11461 markers in the line number table. This is enabled by default when
11462 compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11463 @dots{}), and outputting DWARF 2 debug information at the normal level.
11465 @item -gvariable-location-views
11466 @itemx -gvariable-location-views=incompat5
11467 @itemx -gno-variable-location-views
11468 @opindex gvariable-location-views
11469 @opindex gvariable-location-views=incompat5
11470 @opindex gno-variable-location-views
11471 Augment variable location lists with progressive view numbers implied
11472 from the line number table. This enables debug information consumers to
11473 inspect state at certain points of the program, even if no instructions
11474 associated with the corresponding source locations are present at that
11475 point. If the assembler lacks support for view numbers in line number
11476 tables, this will cause the compiler to emit the line number table,
11477 which generally makes them somewhat less compact. The augmented line
11478 number tables and location lists are fully backward-compatible, so they
11479 can be consumed by debug information consumers that are not aware of
11480 these augmentations, but they won't derive any benefit from them either.
11482 This is enabled by default when outputting DWARF 2 debug information at
11483 the normal level, as long as there is assembler support,
11484 @option{-fvar-tracking-assignments} is enabled and
11485 @option{-gstrict-dwarf} is not. When assembler support is not
11486 available, this may still be enabled, but it will force GCC to output
11487 internal line number tables, and if
11488 @option{-ginternal-reset-location-views} is not enabled, that will most
11489 certainly lead to silently mismatching location views.
11491 There is a proposed representation for view numbers that is not backward
11492 compatible with the location list format introduced in DWARF 5, that can
11493 be enabled with @option{-gvariable-location-views=incompat5}. This
11494 option may be removed in the future, is only provided as a reference
11495 implementation of the proposed representation. Debug information
11496 consumers are not expected to support this extended format, and they
11497 would be rendered unable to decode location lists using it.
11499 @item -ginternal-reset-location-views
11500 @itemx -gno-internal-reset-location-views
11501 @opindex ginternal-reset-location-views
11502 @opindex gno-internal-reset-location-views
11503 Attempt to determine location views that can be omitted from location
11504 view lists. This requires the compiler to have very accurate insn
11505 length estimates, which isn't always the case, and it may cause
11506 incorrect view lists to be generated silently when using an assembler
11507 that does not support location view lists. The GNU assembler will flag
11508 any such error as a @code{view number mismatch}. This is only enabled
11509 on ports that define a reliable estimation function.
11511 @item -ginline-points
11512 @itemx -gno-inline-points
11513 @opindex ginline-points
11514 @opindex gno-inline-points
11515 Generate extended debug information for inlined functions. Location
11516 view tracking markers are inserted at inlined entry points, so that
11517 address and view numbers can be computed and output in debug
11518 information. This can be enabled independently of location views, in
11519 which case the view numbers won't be output, but it can only be enabled
11520 along with statement frontiers, and it is only enabled by default if
11521 location views are enabled.
11523 @item -gz@r{[}=@var{type}@r{]}
11525 Produce compressed debug sections in DWARF format, if that is supported.
11526 If @var{type} is not given, the default type depends on the capabilities
11527 of the assembler and linker used. @var{type} may be one of
11528 @samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11529 compression in ELF gABI format). If the linker doesn't support writing
11530 compressed debug sections, the option is rejected. Otherwise, if the
11531 assembler does not support them, @option{-gz} is silently ignored when
11532 producing object files.
11534 @item -femit-struct-debug-baseonly
11535 @opindex femit-struct-debug-baseonly
11536 Emit debug information for struct-like types
11537 only when the base name of the compilation source file
11538 matches the base name of file in which the struct is defined.
11540 This option substantially reduces the size of debugging information,
11541 but at significant potential loss in type information to the debugger.
11542 See @option{-femit-struct-debug-reduced} for a less aggressive option.
11543 See @option{-femit-struct-debug-detailed} for more detailed control.
11545 This option works only with DWARF debug output.
11547 @item -femit-struct-debug-reduced
11548 @opindex femit-struct-debug-reduced
11549 Emit debug information for struct-like types
11550 only when the base name of the compilation source file
11551 matches the base name of file in which the type is defined,
11552 unless the struct is a template or defined in a system header.
11554 This option significantly reduces the size of debugging information,
11555 with some potential loss in type information to the debugger.
11556 See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11557 See @option{-femit-struct-debug-detailed} for more detailed control.
11559 This option works only with DWARF debug output.
11561 @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
11562 @opindex femit-struct-debug-detailed
11563 Specify the struct-like types
11564 for which the compiler generates debug information.
11565 The intent is to reduce duplicate struct debug information
11566 between different object files within the same program.
11568 This option is a detailed version of
11569 @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11570 which serves for most needs.
11572 A specification has the syntax@*
11573 [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11575 The optional first word limits the specification to
11576 structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11577 A struct type is used directly when it is the type of a variable, member.
11578 Indirect uses arise through pointers to structs.
11579 That is, when use of an incomplete struct is valid, the use is indirect.
11581 @samp{struct one direct; struct two * indirect;}.
11583 The optional second word limits the specification to
11584 ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11585 Generic structs are a bit complicated to explain.
11586 For C++, these are non-explicit specializations of template classes,
11587 or non-template classes within the above.
11588 Other programming languages have generics,
11589 but @option{-femit-struct-debug-detailed} does not yet implement them.
11591 The third word specifies the source files for those
11592 structs for which the compiler should emit debug information.
11593 The values @samp{none} and @samp{any} have the normal meaning.
11594 The value @samp{base} means that
11595 the base of name of the file in which the type declaration appears
11596 must match the base of the name of the main compilation file.
11597 In practice, this means that when compiling @file{foo.c}, debug information
11598 is generated for types declared in that file and @file{foo.h},
11599 but not other header files.
11600 The value @samp{sys} means those types satisfying @samp{base}
11601 or declared in system or compiler headers.
11603 You may need to experiment to determine the best settings for your application.
11605 The default is @option{-femit-struct-debug-detailed=all}.
11607 This option works only with DWARF debug output.
11609 @item -fno-dwarf2-cfi-asm
11610 @opindex fdwarf2-cfi-asm
11611 @opindex fno-dwarf2-cfi-asm
11612 Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11613 instead of using GAS @code{.cfi_*} directives.
11615 @item -fno-eliminate-unused-debug-types
11616 @opindex feliminate-unused-debug-types
11617 @opindex fno-eliminate-unused-debug-types
11618 Normally, when producing DWARF output, GCC avoids producing debug symbol
11619 output for types that are nowhere used in the source file being compiled.
11620 Sometimes it is useful to have GCC emit debugging
11621 information for all types declared in a compilation
11622 unit, regardless of whether or not they are actually used
11623 in that compilation unit, for example
11624 if, in the debugger, you want to cast a value to a type that is
11625 not actually used in your program (but is declared). More often,
11626 however, this results in a significant amount of wasted space.
11629 @node Optimize Options
11630 @section Options That Control Optimization
11631 @cindex optimize options
11632 @cindex options, optimization
11634 These options control various sorts of optimizations.
11636 Without any optimization option, the compiler's goal is to reduce the
11637 cost of compilation and to make debugging produce the expected
11638 results. Statements are independent: if you stop the program with a
11639 breakpoint between statements, you can then assign a new value to any
11640 variable or change the program counter to any other statement in the
11641 function and get exactly the results you expect from the source
11644 Turning on optimization flags makes the compiler attempt to improve
11645 the performance and/or code size at the expense of compilation time
11646 and possibly the ability to debug the program.
11648 The compiler performs optimization based on the knowledge it has of the
11649 program. Compiling multiple files at once to a single output file mode allows
11650 the compiler to use information gained from all of the files when compiling
11653 Not all optimizations are controlled directly by a flag. Only
11654 optimizations that have a flag are listed in this section.
11656 Most optimizations are completely disabled at @option{-O0} or if an
11657 @option{-O} level is not set on the command line, even if individual
11658 optimization flags are specified. Similarly, @option{-Og} suppresses
11659 many optimization passes.
11661 Depending on the target and how GCC was configured, a slightly different
11662 set of optimizations may be enabled at each @option{-O} level than
11663 those listed here. You can invoke GCC with @option{-Q --help=optimizers}
11664 to find out the exact set of optimizations that are enabled at each level.
11665 @xref{Overall Options}, for examples.
11672 Optimize. Optimizing compilation takes somewhat more time, and a lot
11673 more memory for a large function.
11675 With @option{-O}, the compiler tries to reduce code size and execution
11676 time, without performing any optimizations that take a great deal of
11679 @c Note that in addition to the default_options_table list in opts.cc,
11680 @c several optimization flags default to true but control optimization
11681 @c passes that are explicitly disabled at -O0.
11683 @option{-O} turns on the following optimization flags:
11685 @c Please keep the following list alphabetized.
11686 @gccoptlist{-fauto-inc-dec @gol
11687 -fbranch-count-reg @gol
11688 -fcombine-stack-adjustments @gol
11689 -fcompare-elim @gol
11690 -fcprop-registers @gol
11693 -fdelayed-branch @gol
11695 -fforward-propagate @gol
11696 -fguess-branch-probability @gol
11697 -fif-conversion @gol
11698 -fif-conversion2 @gol
11699 -finline-functions-called-once @gol
11702 -fipa-pure-const @gol
11703 -fipa-reference @gol
11704 -fipa-reference-addressable @gol
11705 -fmerge-constants @gol
11706 -fmove-loop-invariants @gol
11707 -fmove-loop-stores@gol
11708 -fomit-frame-pointer @gol
11709 -freorder-blocks @gol
11711 -fshrink-wrap-separate @gol
11712 -fsplit-wide-types @gol
11713 -fssa-backprop @gol
11715 -ftree-bit-ccp @gol
11718 -ftree-coalesce-vars @gol
11719 -ftree-copy-prop @gol
11721 -ftree-dominator-opts @gol
11723 -ftree-forwprop @gol
11725 -ftree-phiprop @gol
11727 -ftree-scev-cprop @gol
11736 Optimize even more. GCC performs nearly all supported optimizations
11737 that do not involve a space-speed tradeoff.
11738 As compared to @option{-O}, this option increases both compilation time
11739 and the performance of the generated code.
11741 @option{-O2} turns on all optimization flags specified by @option{-O1}. It
11742 also turns on the following optimization flags:
11744 @c Please keep the following list alphabetized!
11745 @gccoptlist{-falign-functions -falign-jumps @gol
11746 -falign-labels -falign-loops @gol
11747 -fcaller-saves @gol
11748 -fcode-hoisting @gol
11749 -fcrossjumping @gol
11750 -fcse-follow-jumps -fcse-skip-blocks @gol
11751 -fdelete-null-pointer-checks @gol
11752 -fdevirtualize -fdevirtualize-speculatively @gol
11753 -fexpensive-optimizations @gol
11754 -ffinite-loops @gol
11755 -fgcse -fgcse-lm @gol
11756 -fhoist-adjacent-loads @gol
11757 -finline-functions @gol
11758 -finline-small-functions @gol
11759 -findirect-inlining @gol
11760 -fipa-bit-cp -fipa-cp -fipa-icf @gol
11761 -fipa-ra -fipa-sra -fipa-vrp @gol
11762 -fisolate-erroneous-paths-dereference @gol
11764 -foptimize-sibling-calls @gol
11765 -foptimize-strlen @gol
11766 -fpartial-inlining @gol
11768 -freorder-blocks-algorithm=stc @gol
11769 -freorder-blocks-and-partition -freorder-functions @gol
11770 -frerun-cse-after-loop @gol
11771 -fschedule-insns -fschedule-insns2 @gol
11772 -fsched-interblock -fsched-spec @gol
11773 -fstore-merging @gol
11774 -fstrict-aliasing @gol
11775 -fthread-jumps @gol
11776 -ftree-builtin-call-dce @gol
11777 -ftree-loop-vectorize @gol
11779 -ftree-slp-vectorize @gol
11780 -ftree-switch-conversion -ftree-tail-merge @gol
11782 -fvect-cost-model=very-cheap}
11784 Please note the warning under @option{-fgcse} about
11785 invoking @option{-O2} on programs that use computed gotos.
11789 Optimize yet more. @option{-O3} turns on all optimizations specified
11790 by @option{-O2} and also turns on the following optimization flags:
11792 @c Please keep the following list alphabetized!
11793 @gccoptlist{-fgcse-after-reload @gol
11795 -floop-interchange @gol
11796 -floop-unroll-and-jam @gol
11798 -fpredictive-commoning @gol
11801 -ftree-loop-distribution @gol
11802 -ftree-partial-pre @gol
11803 -funswitch-loops @gol
11804 -fvect-cost-model=dynamic @gol
11805 -fversion-loops-for-strides}
11809 Reduce compilation time and make debugging produce the expected
11810 results. This is the default.
11814 Optimize for size. @option{-Os} enables all @option{-O2} optimizations
11815 except those that often increase code size:
11817 @gccoptlist{-falign-functions -falign-jumps @gol
11818 -falign-labels -falign-loops @gol
11819 -fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
11821 It also enables @option{-finline-functions}, causes the compiler to tune for
11822 code size rather than execution speed, and performs further optimizations
11823 designed to reduce code size.
11827 Disregard strict standards compliance. @option{-Ofast} enables all
11828 @option{-O3} optimizations. It also enables optimizations that are not
11829 valid for all standard-compliant programs.
11830 It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
11831 and the Fortran-specific @option{-fstack-arrays}, unless
11832 @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
11833 It turns off @option{-fsemantic-interposition}.
11837 Optimize debugging experience. @option{-Og} should be the optimization
11838 level of choice for the standard edit-compile-debug cycle, offering
11839 a reasonable level of optimization while maintaining fast compilation
11840 and a good debugging experience. It is a better choice than @option{-O0}
11841 for producing debuggable code because some compiler passes
11842 that collect debug information are disabled at @option{-O0}.
11844 Like @option{-O0}, @option{-Og} completely disables a number of
11845 optimization passes so that individual options controlling them have
11846 no effect. Otherwise @option{-Og} enables all @option{-O1}
11847 optimization flags except for those that may interfere with debugging:
11849 @gccoptlist{-fbranch-count-reg -fdelayed-branch @gol
11850 -fdse -fif-conversion -fif-conversion2 @gol
11851 -finline-functions-called-once @gol
11852 -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt @gol
11853 -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
11857 Optimize aggressively for size rather than speed. This may increase
11858 the number of instructions executed if those instructions require
11859 fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
11860 including enabling most @option{-O2} optimizations.
11864 If you use multiple @option{-O} options, with or without level numbers,
11865 the last such option is the one that is effective.
11867 Options of the form @option{-f@var{flag}} specify machine-independent
11868 flags. Most flags have both positive and negative forms; the negative
11869 form of @option{-ffoo} is @option{-fno-foo}. In the table
11870 below, only one of the forms is listed---the one you typically
11871 use. You can figure out the other form by either removing @samp{no-}
11874 The following options control specific optimizations. They are either
11875 activated by @option{-O} options or are related to ones that are. You
11876 can use the following flags in the rare cases when ``fine-tuning'' of
11877 optimizations to be performed is desired.
11880 @item -fno-defer-pop
11881 @opindex fno-defer-pop
11882 @opindex fdefer-pop
11883 For machines that must pop arguments after a function call, always pop
11884 the arguments as soon as each function returns.
11885 At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
11886 this allows the compiler to let arguments accumulate on the stack for several
11887 function calls and pop them all at once.
11889 @item -fforward-propagate
11890 @opindex fforward-propagate
11891 Perform a forward propagation pass on RTL@. The pass tries to combine two
11892 instructions and checks if the result can be simplified. If loop unrolling
11893 is active, two passes are performed and the second is scheduled after
11896 This option is enabled by default at optimization levels @option{-O1},
11897 @option{-O2}, @option{-O3}, @option{-Os}.
11899 @item -ffp-contract=@var{style}
11900 @opindex ffp-contract
11901 @option{-ffp-contract=off} disables floating-point expression contraction.
11902 @option{-ffp-contract=fast} enables floating-point expression contraction
11903 such as forming of fused multiply-add operations if the target has
11904 native support for them.
11905 @option{-ffp-contract=on} enables floating-point expression contraction
11906 if allowed by the language standard. This is currently not implemented
11907 and treated equal to @option{-ffp-contract=off}.
11909 The default is @option{-ffp-contract=fast}.
11911 @item -fomit-frame-pointer
11912 @opindex fomit-frame-pointer
11913 Omit the frame pointer in functions that don't need one. This avoids the
11914 instructions to save, set up and restore the frame pointer; on many targets
11915 it also makes an extra register available.
11917 On some targets this flag has no effect because the standard calling sequence
11918 always uses a frame pointer, so it cannot be omitted.
11920 Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
11921 is used in all functions. Several targets always omit the frame pointer in
11924 Enabled by default at @option{-O1} and higher.
11926 @item -foptimize-sibling-calls
11927 @opindex foptimize-sibling-calls
11928 Optimize sibling and tail recursive calls.
11930 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11932 @item -foptimize-strlen
11933 @opindex foptimize-strlen
11934 Optimize various standard C string functions (e.g.@: @code{strlen},
11935 @code{strchr} or @code{strcpy}) and
11936 their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
11938 Enabled at levels @option{-O2}, @option{-O3}.
11941 @opindex fno-inline
11943 Do not expand any functions inline apart from those marked with
11944 the @code{always_inline} attribute. This is the default when not
11947 Single functions can be exempted from inlining by marking them
11948 with the @code{noinline} attribute.
11950 @item -finline-small-functions
11951 @opindex finline-small-functions
11952 Integrate functions into their callers when their body is smaller than expected
11953 function call code (so overall size of program gets smaller). The compiler
11954 heuristically decides which functions are simple enough to be worth integrating
11955 in this way. This inlining applies to all functions, even those not declared
11958 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11960 @item -findirect-inlining
11961 @opindex findirect-inlining
11962 Inline also indirect calls that are discovered to be known at compile
11963 time thanks to previous inlining. This option has any effect only
11964 when inlining itself is turned on by the @option{-finline-functions}
11965 or @option{-finline-small-functions} options.
11967 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11969 @item -finline-functions
11970 @opindex finline-functions
11971 Consider all functions for inlining, even if they are not declared inline.
11972 The compiler heuristically decides which functions are worth integrating
11975 If all calls to a given function are integrated, and the function is
11976 declared @code{static}, then the function is normally not output as
11977 assembler code in its own right.
11979 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
11980 by @option{-fprofile-use} and @option{-fauto-profile}.
11982 @item -finline-functions-called-once
11983 @opindex finline-functions-called-once
11984 Consider all @code{static} functions called once for inlining into their
11985 caller even if they are not marked @code{inline}. If a call to a given
11986 function is integrated, then the function is not output as assembler code
11989 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
11990 but not @option{-Og}.
11992 @item -fearly-inlining
11993 @opindex fearly-inlining
11994 Inline functions marked by @code{always_inline} and functions whose body seems
11995 smaller than the function call overhead early before doing
11996 @option{-fprofile-generate} instrumentation and real inlining pass. Doing so
11997 makes profiling significantly cheaper and usually inlining faster on programs
11998 having large chains of nested wrapper functions.
12000 Enabled by default.
12004 Perform interprocedural scalar replacement of aggregates, removal of
12005 unused parameters and replacement of parameters passed by reference
12006 by parameters passed by value.
12008 Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12010 @item -finline-limit=@var{n}
12011 @opindex finline-limit
12012 By default, GCC limits the size of functions that can be inlined. This flag
12013 allows coarse control of this limit. @var{n} is the size of functions that
12014 can be inlined in number of pseudo instructions.
12016 Inlining is actually controlled by a number of parameters, which may be
12017 specified individually by using @option{--param @var{name}=@var{value}}.
12018 The @option{-finline-limit=@var{n}} option sets some of these parameters
12022 @item max-inline-insns-single
12023 is set to @var{n}/2.
12024 @item max-inline-insns-auto
12025 is set to @var{n}/2.
12028 See below for a documentation of the individual
12029 parameters controlling inlining and for the defaults of these parameters.
12031 @emph{Note:} there may be no value to @option{-finline-limit} that results
12032 in default behavior.
12034 @emph{Note:} pseudo instruction represents, in this particular context, an
12035 abstract measurement of function's size. In no way does it represent a count
12036 of assembly instructions and as such its exact meaning might change from one
12037 release to an another.
12039 @item -fno-keep-inline-dllexport
12040 @opindex fno-keep-inline-dllexport
12041 @opindex fkeep-inline-dllexport
12042 This is a more fine-grained version of @option{-fkeep-inline-functions},
12043 which applies only to functions that are declared using the @code{dllexport}
12044 attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12047 @item -fkeep-inline-functions
12048 @opindex fkeep-inline-functions
12049 In C, emit @code{static} functions that are declared @code{inline}
12050 into the object file, even if the function has been inlined into all
12051 of its callers. This switch does not affect functions using the
12052 @code{extern inline} extension in GNU C90@. In C++, emit any and all
12053 inline functions into the object file.
12055 @item -fkeep-static-functions
12056 @opindex fkeep-static-functions
12057 Emit @code{static} functions into the object file, even if the function
12060 @item -fkeep-static-consts
12061 @opindex fkeep-static-consts
12062 Emit variables declared @code{static const} when optimization isn't turned
12063 on, even if the variables aren't referenced.
12065 GCC enables this option by default. If you want to force the compiler to
12066 check if a variable is referenced, regardless of whether or not
12067 optimization is turned on, use the @option{-fno-keep-static-consts} option.
12069 @item -fmerge-constants
12070 @opindex fmerge-constants
12071 Attempt to merge identical constants (string constants and floating-point
12072 constants) across compilation units.
12074 This option is the default for optimized compilation if the assembler and
12075 linker support it. Use @option{-fno-merge-constants} to inhibit this
12078 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12080 @item -fmerge-all-constants
12081 @opindex fmerge-all-constants
12082 Attempt to merge identical constants and identical variables.
12084 This option implies @option{-fmerge-constants}. In addition to
12085 @option{-fmerge-constants} this considers e.g.@: even constant initialized
12086 arrays or initialized constant variables with integral or floating-point
12087 types. Languages like C or C++ require each variable, including multiple
12088 instances of the same variable in recursive calls, to have distinct locations,
12089 so using this option results in non-conforming
12092 @item -fmodulo-sched
12093 @opindex fmodulo-sched
12094 Perform swing modulo scheduling immediately before the first scheduling
12095 pass. This pass looks at innermost loops and reorders their
12096 instructions by overlapping different iterations.
12098 @item -fmodulo-sched-allow-regmoves
12099 @opindex fmodulo-sched-allow-regmoves
12100 Perform more aggressive SMS-based modulo scheduling with register moves
12101 allowed. By setting this flag certain anti-dependences edges are
12102 deleted, which triggers the generation of reg-moves based on the
12103 life-range analysis. This option is effective only with
12104 @option{-fmodulo-sched} enabled.
12106 @item -fno-branch-count-reg
12107 @opindex fno-branch-count-reg
12108 @opindex fbranch-count-reg
12109 Disable the optimization pass that scans for opportunities to use
12110 ``decrement and branch'' instructions on a count register instead of
12111 instruction sequences that decrement a register, compare it against zero, and
12112 then branch based upon the result. This option is only meaningful on
12113 architectures that support such instructions, which include x86, PowerPC,
12114 IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12115 doesn't remove the decrement and branch instructions from the generated
12116 instruction stream introduced by other optimization passes.
12118 The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12119 except for @option{-Og}.
12121 @item -fno-function-cse
12122 @opindex fno-function-cse
12123 @opindex ffunction-cse
12124 Do not put function addresses in registers; make each instruction that
12125 calls a constant function contain the function's address explicitly.
12127 This option results in less efficient code, but some strange hacks
12128 that alter the assembler output may be confused by the optimizations
12129 performed when this option is not used.
12131 The default is @option{-ffunction-cse}
12133 @item -fno-zero-initialized-in-bss
12134 @opindex fno-zero-initialized-in-bss
12135 @opindex fzero-initialized-in-bss
12136 If the target supports a BSS section, GCC by default puts variables that
12137 are initialized to zero into BSS@. This can save space in the resulting
12140 This option turns off this behavior because some programs explicitly
12141 rely on variables going to the data section---e.g., so that the
12142 resulting executable can find the beginning of that section and/or make
12143 assumptions based on that.
12145 The default is @option{-fzero-initialized-in-bss}.
12147 @item -fthread-jumps
12148 @opindex fthread-jumps
12149 Perform optimizations that check to see if a jump branches to a
12150 location where another comparison subsumed by the first is found. If
12151 so, the first branch is redirected to either the destination of the
12152 second branch or a point immediately following it, depending on whether
12153 the condition is known to be true or false.
12155 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12157 @item -fsplit-wide-types
12158 @opindex fsplit-wide-types
12159 When using a type that occupies multiple registers, such as @code{long
12160 long} on a 32-bit system, split the registers apart and allocate them
12161 independently. This normally generates better code for those types,
12162 but may make debugging more difficult.
12164 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12167 @item -fsplit-wide-types-early
12168 @opindex fsplit-wide-types-early
12169 Fully split wide types early, instead of very late.
12170 This option has no effect unless @option{-fsplit-wide-types} is turned on.
12172 This is the default on some targets.
12174 @item -fcse-follow-jumps
12175 @opindex fcse-follow-jumps
12176 In common subexpression elimination (CSE), scan through jump instructions
12177 when the target of the jump is not reached by any other path. For
12178 example, when CSE encounters an @code{if} statement with an
12179 @code{else} clause, CSE follows the jump when the condition
12182 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12184 @item -fcse-skip-blocks
12185 @opindex fcse-skip-blocks
12186 This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12187 follow jumps that conditionally skip over blocks. When CSE
12188 encounters a simple @code{if} statement with no else clause,
12189 @option{-fcse-skip-blocks} causes CSE to follow the jump around the
12190 body of the @code{if}.
12192 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12194 @item -frerun-cse-after-loop
12195 @opindex frerun-cse-after-loop
12196 Re-run common subexpression elimination after loop optimizations are
12199 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12203 Perform a global common subexpression elimination pass.
12204 This pass also performs global constant and copy propagation.
12206 @emph{Note:} When compiling a program using computed gotos, a GCC
12207 extension, you may get better run-time performance if you disable
12208 the global common subexpression elimination pass by adding
12209 @option{-fno-gcse} to the command line.
12211 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12215 When @option{-fgcse-lm} is enabled, global common subexpression elimination
12216 attempts to move loads that are only killed by stores into themselves. This
12217 allows a loop containing a load/store sequence to be changed to a load outside
12218 the loop, and a copy/store within the loop.
12220 Enabled by default when @option{-fgcse} is enabled.
12224 When @option{-fgcse-sm} is enabled, a store motion pass is run after
12225 global common subexpression elimination. This pass attempts to move
12226 stores out of loops. When used in conjunction with @option{-fgcse-lm},
12227 loops containing a load/store sequence can be changed to a load before
12228 the loop and a store after the loop.
12230 Not enabled at any optimization level.
12234 When @option{-fgcse-las} is enabled, the global common subexpression
12235 elimination pass eliminates redundant loads that come after stores to the
12236 same memory location (both partial and full redundancies).
12238 Not enabled at any optimization level.
12240 @item -fgcse-after-reload
12241 @opindex fgcse-after-reload
12242 When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12243 pass is performed after reload. The purpose of this pass is to clean up
12244 redundant spilling.
12246 Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12248 @item -faggressive-loop-optimizations
12249 @opindex faggressive-loop-optimizations
12250 This option tells the loop optimizer to use language constraints to
12251 derive bounds for the number of iterations of a loop. This assumes that
12252 loop code does not invoke undefined behavior by for example causing signed
12253 integer overflows or out-of-bound array accesses. The bounds for the
12254 number of iterations of a loop are used to guide loop unrolling and peeling
12255 and loop exit test optimizations.
12256 This option is enabled by default.
12258 @item -funconstrained-commons
12259 @opindex funconstrained-commons
12260 This option tells the compiler that variables declared in common blocks
12261 (e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12262 prevents certain optimizations that depend on knowing the array bounds.
12264 @item -fcrossjumping
12265 @opindex fcrossjumping
12266 Perform cross-jumping transformation.
12267 This transformation unifies equivalent code and saves code size. The
12268 resulting code may or may not perform better than without cross-jumping.
12270 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12272 @item -fauto-inc-dec
12273 @opindex fauto-inc-dec
12274 Combine increments or decrements of addresses with memory accesses.
12275 This pass is always skipped on architectures that do not have
12276 instructions to support this. Enabled by default at @option{-O1} and
12277 higher on architectures that support this.
12281 Perform dead code elimination (DCE) on RTL@.
12282 Enabled by default at @option{-O1} and higher.
12286 Perform dead store elimination (DSE) on RTL@.
12287 Enabled by default at @option{-O1} and higher.
12289 @item -fif-conversion
12290 @opindex fif-conversion
12291 Attempt to transform conditional jumps into branch-less equivalents. This
12292 includes use of conditional moves, min, max, set flags and abs instructions, and
12293 some tricks doable by standard arithmetics. The use of conditional execution
12294 on chips where it is available is controlled by @option{-fif-conversion2}.
12296 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12297 not with @option{-Og}.
12299 @item -fif-conversion2
12300 @opindex fif-conversion2
12301 Use conditional execution (where available) to transform conditional jumps into
12302 branch-less equivalents.
12304 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12305 not with @option{-Og}.
12307 @item -fdeclone-ctor-dtor
12308 @opindex fdeclone-ctor-dtor
12309 The C++ ABI requires multiple entry points for constructors and
12310 destructors: one for a base subobject, one for a complete object, and
12311 one for a virtual destructor that calls operator delete afterwards.
12312 For a hierarchy with virtual bases, the base and complete variants are
12313 clones, which means two copies of the function. With this option, the
12314 base and complete variants are changed to be thunks that call a common
12317 Enabled by @option{-Os}.
12319 @item -fdelete-null-pointer-checks
12320 @opindex fdelete-null-pointer-checks
12321 Assume that programs cannot safely dereference null pointers, and that
12322 no code or data element resides at address zero.
12323 This option enables simple constant
12324 folding optimizations at all optimization levels. In addition, other
12325 optimization passes in GCC use this flag to control global dataflow
12326 analyses that eliminate useless checks for null pointers; these assume
12327 that a memory access to address zero always results in a trap, so
12328 that if a pointer is checked after it has already been dereferenced,
12331 Note however that in some environments this assumption is not true.
12332 Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12333 for programs that depend on that behavior.
12335 This option is enabled by default on most targets. On Nios II ELF, it
12336 defaults to off. On AVR and MSP430, this option is completely disabled.
12338 Passes that use the dataflow information
12339 are enabled independently at different optimization levels.
12341 @item -fdevirtualize
12342 @opindex fdevirtualize
12343 Attempt to convert calls to virtual functions to direct calls. This
12344 is done both within a procedure and interprocedurally as part of
12345 indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12346 propagation (@option{-fipa-cp}).
12347 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12349 @item -fdevirtualize-speculatively
12350 @opindex fdevirtualize-speculatively
12351 Attempt to convert calls to virtual functions to speculative direct calls.
12352 Based on the analysis of the type inheritance graph, determine for a given call
12353 the set of likely targets. If the set is small, preferably of size 1, change
12354 the call into a conditional deciding between direct and indirect calls. The
12355 speculative calls enable more optimizations, such as inlining. When they seem
12356 useless after further optimization, they are converted back into original form.
12358 @item -fdevirtualize-at-ltrans
12359 @opindex fdevirtualize-at-ltrans
12360 Stream extra information needed for aggressive devirtualization when running
12361 the link-time optimizer in local transformation mode.
12362 This option enables more devirtualization but
12363 significantly increases the size of streamed data. For this reason it is
12364 disabled by default.
12366 @item -fexpensive-optimizations
12367 @opindex fexpensive-optimizations
12368 Perform a number of minor optimizations that are relatively expensive.
12370 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12374 Attempt to remove redundant extension instructions. This is especially
12375 helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12376 registers after writing to their lower 32-bit half.
12378 Enabled for Alpha, AArch64 and x86 at levels @option{-O2},
12379 @option{-O3}, @option{-Os}.
12381 @item -fno-lifetime-dse
12382 @opindex fno-lifetime-dse
12383 @opindex flifetime-dse
12384 In C++ the value of an object is only affected by changes within its
12385 lifetime: when the constructor begins, the object has an indeterminate
12386 value, and any changes during the lifetime of the object are dead when
12387 the object is destroyed. Normally dead store elimination will take
12388 advantage of this; if your code relies on the value of the object
12389 storage persisting beyond the lifetime of the object, you can use this
12390 flag to disable this optimization. To preserve stores before the
12391 constructor starts (e.g.@: because your operator new clears the object
12392 storage) but still treat the object as dead after the destructor, you
12393 can use @option{-flifetime-dse=1}. The default behavior can be
12394 explicitly selected with @option{-flifetime-dse=2}.
12395 @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12397 @item -flive-range-shrinkage
12398 @opindex flive-range-shrinkage
12399 Attempt to decrease register pressure through register live range
12400 shrinkage. This is helpful for fast processors with small or moderate
12401 size register sets.
12403 @item -fira-algorithm=@var{algorithm}
12404 @opindex fira-algorithm
12405 Use the specified coloring algorithm for the integrated register
12406 allocator. The @var{algorithm} argument can be @samp{priority}, which
12407 specifies Chow's priority coloring, or @samp{CB}, which specifies
12408 Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12409 for all architectures, but for those targets that do support it, it is
12410 the default because it generates better code.
12412 @item -fira-region=@var{region}
12413 @opindex fira-region
12414 Use specified regions for the integrated register allocator. The
12415 @var{region} argument should be one of the following:
12420 Use all loops as register allocation regions.
12421 This can give the best results for machines with a small and/or
12422 irregular register set.
12425 Use all loops except for loops with small register pressure
12426 as the regions. This value usually gives
12427 the best results in most cases and for most architectures,
12428 and is enabled by default when compiling with optimization for speed
12429 (@option{-O}, @option{-O2}, @dots{}).
12432 Use all functions as a single region.
12433 This typically results in the smallest code size, and is enabled by default for
12434 @option{-Os} or @option{-O0}.
12438 @item -fira-hoist-pressure
12439 @opindex fira-hoist-pressure
12440 Use IRA to evaluate register pressure in the code hoisting pass for
12441 decisions to hoist expressions. This option usually results in smaller
12442 code, but it can slow the compiler down.
12444 This option is enabled at level @option{-Os} for all targets.
12446 @item -fira-loop-pressure
12447 @opindex fira-loop-pressure
12448 Use IRA to evaluate register pressure in loops for decisions to move
12449 loop invariants. This option usually results in generation
12450 of faster and smaller code on machines with large register files (>= 32
12451 registers), but it can slow the compiler down.
12453 This option is enabled at level @option{-O3} for some targets.
12455 @item -fno-ira-share-save-slots
12456 @opindex fno-ira-share-save-slots
12457 @opindex fira-share-save-slots
12458 Disable sharing of stack slots used for saving call-used hard
12459 registers living through a call. Each hard register gets a
12460 separate stack slot, and as a result function stack frames are
12463 @item -fno-ira-share-spill-slots
12464 @opindex fno-ira-share-spill-slots
12465 @opindex fira-share-spill-slots
12466 Disable sharing of stack slots allocated for pseudo-registers. Each
12467 pseudo-register that does not get a hard register gets a separate
12468 stack slot, and as a result function stack frames are larger.
12471 @opindex flra-remat
12472 Enable CFG-sensitive rematerialization in LRA. Instead of loading
12473 values of spilled pseudos, LRA tries to rematerialize (recalculate)
12474 values if it is profitable.
12476 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12478 @item -fdelayed-branch
12479 @opindex fdelayed-branch
12480 If supported for the target machine, attempt to reorder instructions
12481 to exploit instruction slots available after delayed branch
12484 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12485 but not at @option{-Og}.
12487 @item -fschedule-insns
12488 @opindex fschedule-insns
12489 If supported for the target machine, attempt to reorder instructions to
12490 eliminate execution stalls due to required data being unavailable. This
12491 helps machines that have slow floating point or memory load instructions
12492 by allowing other instructions to be issued until the result of the load
12493 or floating-point instruction is required.
12495 Enabled at levels @option{-O2}, @option{-O3}.
12497 @item -fschedule-insns2
12498 @opindex fschedule-insns2
12499 Similar to @option{-fschedule-insns}, but requests an additional pass of
12500 instruction scheduling after register allocation has been done. This is
12501 especially useful on machines with a relatively small number of
12502 registers and where memory load instructions take more than one cycle.
12504 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12506 @item -fno-sched-interblock
12507 @opindex fno-sched-interblock
12508 @opindex fsched-interblock
12509 Disable instruction scheduling across basic blocks, which
12510 is normally enabled when scheduling before register allocation, i.e.@:
12511 with @option{-fschedule-insns} or at @option{-O2} or higher.
12513 @item -fno-sched-spec
12514 @opindex fno-sched-spec
12515 @opindex fsched-spec
12516 Disable speculative motion of non-load instructions, which
12517 is normally enabled when scheduling before register allocation, i.e.@:
12518 with @option{-fschedule-insns} or at @option{-O2} or higher.
12520 @item -fsched-pressure
12521 @opindex fsched-pressure
12522 Enable register pressure sensitive insn scheduling before register
12523 allocation. This only makes sense when scheduling before register
12524 allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12525 @option{-O2} or higher. Usage of this option can improve the
12526 generated code and decrease its size by preventing register pressure
12527 increase above the number of available hard registers and subsequent
12528 spills in register allocation.
12530 @item -fsched-spec-load
12531 @opindex fsched-spec-load
12532 Allow speculative motion of some load instructions. This only makes
12533 sense when scheduling before register allocation, i.e.@: with
12534 @option{-fschedule-insns} or at @option{-O2} or higher.
12536 @item -fsched-spec-load-dangerous
12537 @opindex fsched-spec-load-dangerous
12538 Allow speculative motion of more load instructions. This only makes
12539 sense when scheduling before register allocation, i.e.@: with
12540 @option{-fschedule-insns} or at @option{-O2} or higher.
12542 @item -fsched-stalled-insns
12543 @itemx -fsched-stalled-insns=@var{n}
12544 @opindex fsched-stalled-insns
12545 Define how many insns (if any) can be moved prematurely from the queue
12546 of stalled insns into the ready list during the second scheduling pass.
12547 @option{-fno-sched-stalled-insns} means that no insns are moved
12548 prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12549 on how many queued insns can be moved prematurely.
12550 @option{-fsched-stalled-insns} without a value is equivalent to
12551 @option{-fsched-stalled-insns=1}.
12553 @item -fsched-stalled-insns-dep
12554 @itemx -fsched-stalled-insns-dep=@var{n}
12555 @opindex fsched-stalled-insns-dep
12556 Define how many insn groups (cycles) are examined for a dependency
12557 on a stalled insn that is a candidate for premature removal from the queue
12558 of stalled insns. This has an effect only during the second scheduling pass,
12559 and only if @option{-fsched-stalled-insns} is used.
12560 @option{-fno-sched-stalled-insns-dep} is equivalent to
12561 @option{-fsched-stalled-insns-dep=0}.
12562 @option{-fsched-stalled-insns-dep} without a value is equivalent to
12563 @option{-fsched-stalled-insns-dep=1}.
12565 @item -fsched2-use-superblocks
12566 @opindex fsched2-use-superblocks
12567 When scheduling after register allocation, use superblock scheduling.
12568 This allows motion across basic block boundaries,
12569 resulting in faster schedules. This option is experimental, as not all machine
12570 descriptions used by GCC model the CPU closely enough to avoid unreliable
12571 results from the algorithm.
12573 This only makes sense when scheduling after register allocation, i.e.@: with
12574 @option{-fschedule-insns2} or at @option{-O2} or higher.
12576 @item -fsched-group-heuristic
12577 @opindex fsched-group-heuristic
12578 Enable the group heuristic in the scheduler. This heuristic favors
12579 the instruction that belongs to a schedule group. This is enabled
12580 by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12581 or @option{-fschedule-insns2} or at @option{-O2} or higher.
12583 @item -fsched-critical-path-heuristic
12584 @opindex fsched-critical-path-heuristic
12585 Enable the critical-path heuristic in the scheduler. This heuristic favors
12586 instructions on the critical path. This is enabled by default when
12587 scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12588 or @option{-fschedule-insns2} or at @option{-O2} or higher.
12590 @item -fsched-spec-insn-heuristic
12591 @opindex fsched-spec-insn-heuristic
12592 Enable the speculative instruction heuristic in the scheduler. This
12593 heuristic favors speculative instructions with greater dependency weakness.
12594 This is enabled by default when scheduling is enabled, i.e.@:
12595 with @option{-fschedule-insns} or @option{-fschedule-insns2}
12596 or at @option{-O2} or higher.
12598 @item -fsched-rank-heuristic
12599 @opindex fsched-rank-heuristic
12600 Enable the rank heuristic in the scheduler. This heuristic favors
12601 the instruction belonging to a basic block with greater size or frequency.
12602 This is enabled by default when scheduling is enabled, i.e.@:
12603 with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12604 at @option{-O2} or higher.
12606 @item -fsched-last-insn-heuristic
12607 @opindex fsched-last-insn-heuristic
12608 Enable the last-instruction heuristic in the scheduler. This heuristic
12609 favors the instruction that is less dependent on the last instruction
12610 scheduled. This is enabled by default when scheduling is enabled,
12611 i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12612 at @option{-O2} or higher.
12614 @item -fsched-dep-count-heuristic
12615 @opindex fsched-dep-count-heuristic
12616 Enable the dependent-count heuristic in the scheduler. This heuristic
12617 favors the instruction that has more instructions depending on it.
12618 This is enabled by default when scheduling is enabled, i.e.@:
12619 with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12620 at @option{-O2} or higher.
12622 @item -freschedule-modulo-scheduled-loops
12623 @opindex freschedule-modulo-scheduled-loops
12624 Modulo scheduling is performed before traditional scheduling. If a loop
12625 is modulo scheduled, later scheduling passes may change its schedule.
12626 Use this option to control that behavior.
12628 @item -fselective-scheduling
12629 @opindex fselective-scheduling
12630 Schedule instructions using selective scheduling algorithm. Selective
12631 scheduling runs instead of the first scheduler pass.
12633 @item -fselective-scheduling2
12634 @opindex fselective-scheduling2
12635 Schedule instructions using selective scheduling algorithm. Selective
12636 scheduling runs instead of the second scheduler pass.
12638 @item -fsel-sched-pipelining
12639 @opindex fsel-sched-pipelining
12640 Enable software pipelining of innermost loops during selective scheduling.
12641 This option has no effect unless one of @option{-fselective-scheduling} or
12642 @option{-fselective-scheduling2} is turned on.
12644 @item -fsel-sched-pipelining-outer-loops
12645 @opindex fsel-sched-pipelining-outer-loops
12646 When pipelining loops during selective scheduling, also pipeline outer loops.
12647 This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
12649 @item -fsemantic-interposition
12650 @opindex fsemantic-interposition
12651 Some object formats, like ELF, allow interposing of symbols by the
12653 This means that for symbols exported from the DSO, the compiler cannot perform
12654 interprocedural propagation, inlining and other optimizations in anticipation
12655 that the function or variable in question may change. While this feature is
12656 useful, for example, to rewrite memory allocation functions by a debugging
12657 implementation, it is expensive in the terms of code quality.
12658 With @option{-fno-semantic-interposition} the compiler assumes that
12659 if interposition happens for functions the overwriting function will have
12660 precisely the same semantics (and side effects).
12661 Similarly if interposition happens
12662 for variables, the constructor of the variable will be the same. The flag
12663 has no effect for functions explicitly declared inline
12664 (where it is never allowed for interposition to change semantics)
12665 and for symbols explicitly declared weak.
12667 @item -fshrink-wrap
12668 @opindex fshrink-wrap
12669 Emit function prologues only before parts of the function that need it,
12670 rather than at the top of the function. This flag is enabled by default at
12671 @option{-O} and higher.
12673 @item -fshrink-wrap-separate
12674 @opindex fshrink-wrap-separate
12675 Shrink-wrap separate parts of the prologue and epilogue separately, so that
12676 those parts are only executed when needed.
12677 This option is on by default, but has no effect unless @option{-fshrink-wrap}
12678 is also turned on and the target supports this.
12680 @item -fcaller-saves
12681 @opindex fcaller-saves
12682 Enable allocation of values to registers that are clobbered by
12683 function calls, by emitting extra instructions to save and restore the
12684 registers around such calls. Such allocation is done only when it
12685 seems to result in better code.
12687 This option is always enabled by default on certain machines, usually
12688 those which have no call-preserved registers to use instead.
12690 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12692 @item -fcombine-stack-adjustments
12693 @opindex fcombine-stack-adjustments
12694 Tracks stack adjustments (pushes and pops) and stack memory references
12695 and then tries to find ways to combine them.
12697 Enabled by default at @option{-O1} and higher.
12701 Use caller save registers for allocation if those registers are not used by
12702 any called function. In that case it is not necessary to save and restore
12703 them around calls. This is only possible if called functions are part of
12704 same compilation unit as current function and they are compiled before it.
12706 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
12707 is disabled if generated code will be instrumented for profiling
12708 (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
12709 exactly (this happens on targets that do not expose prologues
12710 and epilogues in RTL).
12712 @item -fconserve-stack
12713 @opindex fconserve-stack
12714 Attempt to minimize stack usage. The compiler attempts to use less
12715 stack space, even if that makes the program slower. This option
12716 implies setting the @option{large-stack-frame} parameter to 100
12717 and the @option{large-stack-frame-growth} parameter to 400.
12719 @item -ftree-reassoc
12720 @opindex ftree-reassoc
12721 Perform reassociation on trees. This flag is enabled by default
12722 at @option{-O1} and higher.
12724 @item -fcode-hoisting
12725 @opindex fcode-hoisting
12726 Perform code hoisting. Code hoisting tries to move the
12727 evaluation of expressions executed on all paths to the function exit
12728 as early as possible. This is especially useful as a code size
12729 optimization, but it often helps for code speed as well.
12730 This flag is enabled by default at @option{-O2} and higher.
12734 Perform partial redundancy elimination (PRE) on trees. This flag is
12735 enabled by default at @option{-O2} and @option{-O3}.
12737 @item -ftree-partial-pre
12738 @opindex ftree-partial-pre
12739 Make partial redundancy elimination (PRE) more aggressive. This flag is
12740 enabled by default at @option{-O3}.
12742 @item -ftree-forwprop
12743 @opindex ftree-forwprop
12744 Perform forward propagation on trees. This flag is enabled by default
12745 at @option{-O1} and higher.
12749 Perform full redundancy elimination (FRE) on trees. The difference
12750 between FRE and PRE is that FRE only considers expressions
12751 that are computed on all paths leading to the redundant computation.
12752 This analysis is faster than PRE, though it exposes fewer redundancies.
12753 This flag is enabled by default at @option{-O1} and higher.
12755 @item -ftree-phiprop
12756 @opindex ftree-phiprop
12757 Perform hoisting of loads from conditional pointers on trees. This
12758 pass is enabled by default at @option{-O1} and higher.
12760 @item -fhoist-adjacent-loads
12761 @opindex fhoist-adjacent-loads
12762 Speculatively hoist loads from both branches of an if-then-else if the
12763 loads are from adjacent locations in the same structure and the target
12764 architecture has a conditional move instruction. This flag is enabled
12765 by default at @option{-O2} and higher.
12767 @item -ftree-copy-prop
12768 @opindex ftree-copy-prop
12769 Perform copy propagation on trees. This pass eliminates unnecessary
12770 copy operations. This flag is enabled by default at @option{-O1} and
12773 @item -fipa-pure-const
12774 @opindex fipa-pure-const
12775 Discover which functions are pure or constant.
12776 Enabled by default at @option{-O1} and higher.
12778 @item -fipa-reference
12779 @opindex fipa-reference
12780 Discover which static variables do not escape the
12782 Enabled by default at @option{-O1} and higher.
12784 @item -fipa-reference-addressable
12785 @opindex fipa-reference-addressable
12786 Discover read-only, write-only and non-addressable static variables.
12787 Enabled by default at @option{-O1} and higher.
12789 @item -fipa-stack-alignment
12790 @opindex fipa-stack-alignment
12791 Reduce stack alignment on call sites if possible.
12792 Enabled by default.
12796 Perform interprocedural pointer analysis and interprocedural modification
12797 and reference analysis. This option can cause excessive memory and
12798 compile-time usage on large compilation units. It is not enabled by
12799 default at any optimization level.
12801 @item -fipa-profile
12802 @opindex fipa-profile
12803 Perform interprocedural profile propagation. The functions called only from
12804 cold functions are marked as cold. Also functions executed once (such as
12805 @code{cold}, @code{noreturn}, static constructors or destructors) are
12806 identified. Cold functions and loop less parts of functions executed once are
12807 then optimized for size.
12808 Enabled by default at @option{-O1} and higher.
12811 @opindex fipa-modref
12812 Perform interprocedural mod/ref analysis. This optimization analyzes the side
12813 effects of functions (memory locations that are modified or referenced) and
12814 enables better optimization across the function call boundary. This flag is
12815 enabled by default at @option{-O1} and higher.
12819 Perform interprocedural constant propagation.
12820 This optimization analyzes the program to determine when values passed
12821 to functions are constants and then optimizes accordingly.
12822 This optimization can substantially increase performance
12823 if the application has constants passed to functions.
12824 This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
12825 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12827 @item -fipa-cp-clone
12828 @opindex fipa-cp-clone
12829 Perform function cloning to make interprocedural constant propagation stronger.
12830 When enabled, interprocedural constant propagation performs function cloning
12831 when externally visible function can be called with constant arguments.
12832 Because this optimization can create multiple copies of functions,
12833 it may significantly increase code size
12834 (see @option{--param ipa-cp-unit-growth=@var{value}}).
12835 This flag is enabled by default at @option{-O3}.
12836 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12839 @opindex fipa-bit-cp
12840 When enabled, perform interprocedural bitwise constant
12841 propagation. This flag is enabled by default at @option{-O2} and
12842 by @option{-fprofile-use} and @option{-fauto-profile}.
12843 It requires that @option{-fipa-cp} is enabled.
12847 When enabled, perform interprocedural propagation of value
12848 ranges. This flag is enabled by default at @option{-O2}. It requires
12849 that @option{-fipa-cp} is enabled.
12853 Perform Identical Code Folding for functions and read-only variables.
12854 The optimization reduces code size and may disturb unwind stacks by replacing
12855 a function by equivalent one with a different name. The optimization works
12856 more effectively with link-time optimization enabled.
12858 Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
12859 works on different levels and thus the optimizations are not same - there are
12860 equivalences that are found only by GCC and equivalences found only by Gold.
12862 This flag is enabled by default at @option{-O2} and @option{-Os}.
12864 @item -flive-patching=@var{level}
12865 @opindex flive-patching
12866 Control GCC's optimizations to produce output suitable for live-patching.
12868 If the compiler's optimization uses a function's body or information extracted
12869 from its body to optimize/change another function, the latter is called an
12870 impacted function of the former. If a function is patched, its impacted
12871 functions should be patched too.
12873 The impacted functions are determined by the compiler's interprocedural
12874 optimizations. For example, a caller is impacted when inlining a function
12876 cloning a function and changing its caller to call this new clone,
12877 or extracting a function's pureness/constness information to optimize
12878 its direct or indirect callers, etc.
12880 Usually, the more IPA optimizations enabled, the larger the number of
12881 impacted functions for each function. In order to control the number of
12882 impacted functions and more easily compute the list of impacted function,
12883 IPA optimizations can be partially enabled at two different levels.
12885 The @var{level} argument should be one of the following:
12891 Only enable inlining and cloning optimizations, which includes inlining,
12892 cloning, interprocedural scalar replacement of aggregates and partial inlining.
12893 As a result, when patching a function, all its callers and its clones'
12894 callers are impacted, therefore need to be patched as well.
12896 @option{-flive-patching=inline-clone} disables the following optimization flags:
12897 @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra @gol
12898 -fipa-icf -fipa-icf-functions -fipa-icf-variables @gol
12899 -fipa-bit-cp -fipa-vrp -fipa-pure-const -fipa-reference-addressable @gol
12900 -fipa-stack-alignment -fipa-modref}
12902 @item inline-only-static
12904 Only enable inlining of static functions.
12905 As a result, when patching a static function, all its callers are impacted
12906 and so need to be patched as well.
12908 In addition to all the flags that @option{-flive-patching=inline-clone}
12910 @option{-flive-patching=inline-only-static} disables the following additional
12911 optimization flags:
12912 @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
12916 When @option{-flive-patching} is specified without any value, the default value
12917 is @var{inline-clone}.
12919 This flag is disabled by default.
12921 Note that @option{-flive-patching} is not supported with link-time optimization
12924 @item -fisolate-erroneous-paths-dereference
12925 @opindex fisolate-erroneous-paths-dereference
12926 Detect paths that trigger erroneous or undefined behavior due to
12927 dereferencing a null pointer. Isolate those paths from the main control
12928 flow and turn the statement with erroneous or undefined behavior into a trap.
12929 This flag is enabled by default at @option{-O2} and higher and depends on
12930 @option{-fdelete-null-pointer-checks} also being enabled.
12932 @item -fisolate-erroneous-paths-attribute
12933 @opindex fisolate-erroneous-paths-attribute
12934 Detect paths that trigger erroneous or undefined behavior due to a null value
12935 being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
12936 attribute. Isolate those paths from the main control flow and turn the
12937 statement with erroneous or undefined behavior into a trap. This is not
12938 currently enabled, but may be enabled by @option{-O2} in the future.
12941 @opindex ftree-sink
12942 Perform forward store motion on trees. This flag is
12943 enabled by default at @option{-O1} and higher.
12945 @item -ftree-bit-ccp
12946 @opindex ftree-bit-ccp
12947 Perform sparse conditional bit constant propagation on trees and propagate
12948 pointer alignment information.
12949 This pass only operates on local scalar variables and is enabled by default
12950 at @option{-O1} and higher, except for @option{-Og}.
12951 It requires that @option{-ftree-ccp} is enabled.
12955 Perform sparse conditional constant propagation (CCP) on trees. This
12956 pass only operates on local scalar variables and is enabled by default
12957 at @option{-O1} and higher.
12959 @item -fssa-backprop
12960 @opindex fssa-backprop
12961 Propagate information about uses of a value up the definition chain
12962 in order to simplify the definitions. For example, this pass strips
12963 sign operations if the sign of a value never matters. The flag is
12964 enabled by default at @option{-O1} and higher.
12967 @opindex fssa-phiopt
12968 Perform pattern matching on SSA PHI nodes to optimize conditional
12969 code. This pass is enabled by default at @option{-O1} and higher,
12970 except for @option{-Og}.
12972 @item -ftree-switch-conversion
12973 @opindex ftree-switch-conversion
12974 Perform conversion of simple initializations in a switch to
12975 initializations from a scalar array. This flag is enabled by default
12976 at @option{-O2} and higher.
12978 @item -ftree-tail-merge
12979 @opindex ftree-tail-merge
12980 Look for identical code sequences. When found, replace one with a jump to the
12981 other. This optimization is known as tail merging or cross jumping. This flag
12982 is enabled by default at @option{-O2} and higher. The compilation time
12984 be limited using @option{max-tail-merge-comparisons} parameter and
12985 @option{max-tail-merge-iterations} parameter.
12989 Perform dead code elimination (DCE) on trees. This flag is enabled by
12990 default at @option{-O1} and higher.
12992 @item -ftree-builtin-call-dce
12993 @opindex ftree-builtin-call-dce
12994 Perform conditional dead code elimination (DCE) for calls to built-in functions
12995 that may set @code{errno} but are otherwise free of side effects. This flag is
12996 enabled by default at @option{-O2} and higher if @option{-Os} is not also
12999 @item -ffinite-loops
13000 @opindex ffinite-loops
13001 @opindex fno-finite-loops
13002 Assume that a loop with an exit will eventually take the exit and not loop
13003 indefinitely. This allows the compiler to remove loops that otherwise have
13004 no side-effects, not considering eventual endless looping as such.
13006 This option is enabled by default at @option{-O2} for C++ with -std=c++11
13009 @item -ftree-dominator-opts
13010 @opindex ftree-dominator-opts
13011 Perform a variety of simple scalar cleanups (constant/copy
13012 propagation, redundancy elimination, range propagation and expression
13013 simplification) based on a dominator tree traversal. This also
13014 performs jump threading (to reduce jumps to jumps). This flag is
13015 enabled by default at @option{-O1} and higher.
13019 Perform dead store elimination (DSE) on trees. A dead store is a store into
13020 a memory location that is later overwritten by another store without
13021 any intervening loads. In this case the earlier store can be deleted. This
13022 flag is enabled by default at @option{-O1} and higher.
13026 Perform loop header copying on trees. This is beneficial since it increases
13027 effectiveness of code motion optimizations. It also saves one jump. This flag
13028 is enabled by default at @option{-O1} and higher. It is not enabled
13029 for @option{-Os}, since it usually increases code size.
13031 @item -ftree-loop-optimize
13032 @opindex ftree-loop-optimize
13033 Perform loop optimizations on trees. This flag is enabled by default
13034 at @option{-O1} and higher.
13036 @item -ftree-loop-linear
13037 @itemx -floop-strip-mine
13038 @itemx -floop-block
13039 @opindex ftree-loop-linear
13040 @opindex floop-strip-mine
13041 @opindex floop-block
13042 Perform loop nest optimizations. Same as
13043 @option{-floop-nest-optimize}. To use this code transformation, GCC has
13044 to be configured with @option{--with-isl} to enable the Graphite loop
13045 transformation infrastructure.
13047 @item -fgraphite-identity
13048 @opindex fgraphite-identity
13049 Enable the identity transformation for graphite. For every SCoP we generate
13050 the polyhedral representation and transform it back to gimple. Using
13051 @option{-fgraphite-identity} we can check the costs or benefits of the
13052 GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13053 are also performed by the code generator isl, like index splitting and
13054 dead code elimination in loops.
13056 @item -floop-nest-optimize
13057 @opindex floop-nest-optimize
13058 Enable the isl based loop nest optimizer. This is a generic loop nest
13059 optimizer based on the Pluto optimization algorithms. It calculates a loop
13060 structure optimized for data-locality and parallelism. This option
13063 @item -floop-parallelize-all
13064 @opindex floop-parallelize-all
13065 Use the Graphite data dependence analysis to identify loops that can
13066 be parallelized. Parallelize all the loops that can be analyzed to
13067 not contain loop carried dependences without checking that it is
13068 profitable to parallelize the loops.
13070 @item -ftree-coalesce-vars
13071 @opindex ftree-coalesce-vars
13072 While transforming the program out of the SSA representation, attempt to
13073 reduce copying by coalescing versions of different user-defined
13074 variables, instead of just compiler temporaries. This may severely
13075 limit the ability to debug an optimized program compiled with
13076 @option{-fno-var-tracking-assignments}. In the negated form, this flag
13077 prevents SSA coalescing of user variables. This option is enabled by
13078 default if optimization is enabled, and it does very little otherwise.
13080 @item -ftree-loop-if-convert
13081 @opindex ftree-loop-if-convert
13082 Attempt to transform conditional jumps in the innermost loops to
13083 branch-less equivalents. The intent is to remove control-flow from
13084 the innermost loops in order to improve the ability of the
13085 vectorization pass to handle these loops. This is enabled by default
13086 if vectorization is enabled.
13088 @item -ftree-loop-distribution
13089 @opindex ftree-loop-distribution
13090 Perform loop distribution. This flag can improve cache performance on
13091 big loop bodies and allow further loop optimizations, like
13092 parallelization or vectorization, to take place. For example, the loop
13108 This flag is enabled by default at @option{-O3}.
13109 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13111 @item -ftree-loop-distribute-patterns
13112 @opindex ftree-loop-distribute-patterns
13113 Perform loop distribution of patterns that can be code generated with
13114 calls to a library. This flag is enabled by default at @option{-O2} and
13115 higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13117 This pass distributes the initialization loops and generates a call to
13118 memset zero. For example, the loop
13134 and the initialization loop is transformed into a call to memset zero.
13135 This flag is enabled by default at @option{-O3}.
13136 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13138 @item -floop-interchange
13139 @opindex floop-interchange
13140 Perform loop interchange outside of graphite. This flag can improve cache
13141 performance on loop nest and allow further loop optimizations, like
13142 vectorization, to take place. For example, the loop
13144 for (int i = 0; i < N; i++)
13145 for (int j = 0; j < N; j++)
13146 for (int k = 0; k < N; k++)
13147 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13151 for (int i = 0; i < N; i++)
13152 for (int k = 0; k < N; k++)
13153 for (int j = 0; j < N; j++)
13154 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13156 This flag is enabled by default at @option{-O3}.
13157 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13159 @item -floop-unroll-and-jam
13160 @opindex floop-unroll-and-jam
13161 Apply unroll and jam transformations on feasible loops. In a loop
13162 nest this unrolls the outer loop by some factor and fuses the resulting
13163 multiple inner loops. This flag is enabled by default at @option{-O3}.
13164 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13166 @item -ftree-loop-im
13167 @opindex ftree-loop-im
13168 Perform loop invariant motion on trees. This pass moves only invariants that
13169 are hard to handle at RTL level (function calls, operations that expand to
13170 nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13171 operands of conditions that are invariant out of the loop, so that we can use
13172 just trivial invariantness analysis in loop unswitching. The pass also includes
13175 @item -ftree-loop-ivcanon
13176 @opindex ftree-loop-ivcanon
13177 Create a canonical counter for number of iterations in loops for which
13178 determining number of iterations requires complicated analysis. Later
13179 optimizations then may determine the number easily. Useful especially
13180 in connection with unrolling.
13182 @item -ftree-scev-cprop
13183 @opindex ftree-scev-cprop
13184 Perform final value replacement. If a variable is modified in a loop
13185 in such a way that its value when exiting the loop can be determined using
13186 only its initial value and the number of loop iterations, replace uses of
13187 the final value by such a computation, provided it is sufficiently cheap.
13188 This reduces data dependencies and may allow further simplifications.
13189 Enabled by default at @option{-O1} and higher.
13193 Perform induction variable optimizations (strength reduction, induction
13194 variable merging and induction variable elimination) on trees.
13196 @item -ftree-parallelize-loops=n
13197 @opindex ftree-parallelize-loops
13198 Parallelize loops, i.e., split their iteration space to run in n threads.
13199 This is only possible for loops whose iterations are independent
13200 and can be arbitrarily reordered. The optimization is only
13201 profitable on multiprocessor machines, for loops that are CPU-intensive,
13202 rather than constrained e.g.@: by memory bandwidth. This option
13203 implies @option{-pthread}, and thus is only supported on targets
13204 that have support for @option{-pthread}.
13208 Perform function-local points-to analysis on trees. This flag is
13209 enabled by default at @option{-O1} and higher, except for @option{-Og}.
13213 Perform scalar replacement of aggregates. This pass replaces structure
13214 references with scalars to prevent committing structures to memory too
13215 early. This flag is enabled by default at @option{-O1} and higher,
13216 except for @option{-Og}.
13218 @item -fstore-merging
13219 @opindex fstore-merging
13220 Perform merging of narrow stores to consecutive memory addresses. This pass
13221 merges contiguous stores of immediate values narrower than a word into fewer
13222 wider stores to reduce the number of instructions. This is enabled by default
13223 at @option{-O2} and higher as well as @option{-Os}.
13227 Perform temporary expression replacement during the SSA->normal phase. Single
13228 use/single def temporaries are replaced at their use location with their
13229 defining expression. This results in non-GIMPLE code, but gives the expanders
13230 much more complex trees to work on resulting in better RTL generation. This is
13231 enabled by default at @option{-O1} and higher.
13234 @opindex ftree-slsr
13235 Perform straight-line strength reduction on trees. This recognizes related
13236 expressions involving multiplications and replaces them by less expensive
13237 calculations when possible. This is enabled by default at @option{-O1} and
13240 @item -ftree-vectorize
13241 @opindex ftree-vectorize
13242 Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13243 and @option{-ftree-slp-vectorize} if not explicitly specified.
13245 @item -ftree-loop-vectorize
13246 @opindex ftree-loop-vectorize
13247 Perform loop vectorization on trees. This flag is enabled by default at
13248 @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13249 and @option{-fauto-profile}.
13251 @item -ftree-slp-vectorize
13252 @opindex ftree-slp-vectorize
13253 Perform basic block vectorization on trees. This flag is enabled by default at
13254 @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13255 and @option{-fauto-profile}.
13257 @item -ftrivial-auto-var-init=@var{choice}
13258 @opindex ftrivial-auto-var-init
13259 Initialize automatic variables with either a pattern or with zeroes to increase
13260 the security and predictability of a program by preventing uninitialized memory
13261 disclosure and use.
13262 GCC still considers an automatic variable that doesn't have an explicit
13263 initializer as uninitialized, @option{-Wuninitialized} and
13264 @option{-Wanalyzer-use-of-uninitialized-value} will still report
13265 warning messages on such automatic variables and the compiler will
13266 perform optimization as if the variable were uninitialized.
13267 With this option, GCC will also initialize any padding of automatic variables
13268 that have structure or union types to zeroes.
13269 However, the current implementation cannot initialize automatic variables that
13270 are declared between the controlling expression and the first case of a
13271 @code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13274 The three values of @var{choice} are:
13278 @samp{uninitialized} doesn't initialize any automatic variables.
13279 This is C and C++'s default.
13282 @samp{pattern} Initialize automatic variables with values which will likely
13283 transform logic bugs into crashes down the line, are easily recognized in a
13284 crash dump and without being values that programmers can rely on for useful
13286 The current value is byte-repeatable pattern with byte "0xFE".
13287 The values used for pattern initialization might be changed in the future.
13290 @samp{zero} Initialize automatic variables with zeroes.
13293 The default is @samp{uninitialized}.
13295 You can control this behavior for a specific variable by using the variable
13296 attribute @code{uninitialized} (@pxref{Variable Attributes}).
13298 @item -fvect-cost-model=@var{model}
13299 @opindex fvect-cost-model
13300 Alter the cost model used for vectorization. The @var{model} argument
13301 should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13303 With the @samp{unlimited} model the vectorized code-path is assumed
13304 to be profitable while with the @samp{dynamic} model a runtime check
13305 guards the vectorized code-path to enable it only for iteration
13306 counts that will likely execute faster than when executing the original
13307 scalar loop. The @samp{cheap} model disables vectorization of
13308 loops where doing so would be cost prohibitive for example due to
13309 required runtime checks for data dependence or alignment but otherwise
13310 is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13311 allows vectorization if the vector code would entirely replace the
13312 scalar code that is being vectorized. For example, if each iteration
13313 of a vectorized loop would only be able to handle exactly four iterations
13314 of the scalar loop, the @samp{very-cheap} model would only allow
13315 vectorization if the scalar iteration count is known to be a multiple
13318 The default cost model depends on other optimization flags and is
13319 either @samp{dynamic} or @samp{cheap}.
13321 @item -fsimd-cost-model=@var{model}
13322 @opindex fsimd-cost-model
13323 Alter the cost model used for vectorization of loops marked with the OpenMP
13324 simd directive. The @var{model} argument should be one of
13325 @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13326 have the same meaning as described in @option{-fvect-cost-model} and by
13327 default a cost model defined with @option{-fvect-cost-model} is used.
13331 Perform Value Range Propagation on trees. This is similar to the
13332 constant propagation pass, but instead of values, ranges of values are
13333 propagated. This allows the optimizers to remove unnecessary range
13334 checks like array bound checks and null pointer checks. This is
13335 enabled by default at @option{-O2} and higher. Null pointer check
13336 elimination is only done if @option{-fdelete-null-pointer-checks} is
13339 @item -fsplit-paths
13340 @opindex fsplit-paths
13341 Split paths leading to loop backedges. This can improve dead code
13342 elimination and common subexpression elimination. This is enabled by
13343 default at @option{-O3} and above.
13345 @item -fsplit-ivs-in-unroller
13346 @opindex fsplit-ivs-in-unroller
13347 Enables expression of values of induction variables in later iterations
13348 of the unrolled loop using the value in the first iteration. This breaks
13349 long dependency chains, thus improving efficiency of the scheduling passes.
13351 A combination of @option{-fweb} and CSE is often sufficient to obtain the
13352 same effect. However, that is not reliable in cases where the loop body
13353 is more complicated than a single basic block. It also does not work at all
13354 on some architectures due to restrictions in the CSE pass.
13356 This optimization is enabled by default.
13358 @item -fvariable-expansion-in-unroller
13359 @opindex fvariable-expansion-in-unroller
13360 With this option, the compiler creates multiple copies of some
13361 local variables when unrolling a loop, which can result in superior code.
13363 This optimization is enabled by default for PowerPC targets, but disabled
13364 by default otherwise.
13366 @item -fpartial-inlining
13367 @opindex fpartial-inlining
13368 Inline parts of functions. This option has any effect only
13369 when inlining itself is turned on by the @option{-finline-functions}
13370 or @option{-finline-small-functions} options.
13372 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13374 @item -fpredictive-commoning
13375 @opindex fpredictive-commoning
13376 Perform predictive commoning optimization, i.e., reusing computations
13377 (especially memory loads and stores) performed in previous
13378 iterations of loops.
13380 This option is enabled at level @option{-O3}.
13381 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13383 @item -fprefetch-loop-arrays
13384 @opindex fprefetch-loop-arrays
13385 If supported by the target machine, generate instructions to prefetch
13386 memory to improve the performance of loops that access large arrays.
13388 This option may generate better or worse code; results are highly
13389 dependent on the structure of loops within the source code.
13391 Disabled at level @option{-Os}.
13393 @item -fno-printf-return-value
13394 @opindex fno-printf-return-value
13395 @opindex fprintf-return-value
13396 Do not substitute constants for known return value of formatted output
13397 functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13398 @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13399 transformation allows GCC to optimize or even eliminate branches based
13400 on the known return value of these functions called with arguments that
13401 are either constant, or whose values are known to be in a range that
13402 makes determining the exact return value possible. For example, when
13403 @option{-fprintf-return-value} is in effect, both the branch and the
13404 body of the @code{if} statement (but not the call to @code{snprint})
13405 can be optimized away when @code{i} is a 32-bit or smaller integer
13406 because the return value is guaranteed to be at most 8.
13410 if (snprintf (buf, "%08x", i) >= sizeof buf)
13414 The @option{-fprintf-return-value} option relies on other optimizations
13415 and yields best results with @option{-O2} and above. It works in tandem
13416 with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13417 options. The @option{-fprintf-return-value} option is enabled by default.
13419 @item -fno-peephole
13420 @itemx -fno-peephole2
13421 @opindex fno-peephole
13423 @opindex fno-peephole2
13424 @opindex fpeephole2
13425 Disable any machine-specific peephole optimizations. The difference
13426 between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13427 are implemented in the compiler; some targets use one, some use the
13428 other, a few use both.
13430 @option{-fpeephole} is enabled by default.
13431 @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13433 @item -fno-guess-branch-probability
13434 @opindex fno-guess-branch-probability
13435 @opindex fguess-branch-probability
13436 Do not guess branch probabilities using heuristics.
13438 GCC uses heuristics to guess branch probabilities if they are
13439 not provided by profiling feedback (@option{-fprofile-arcs}). These
13440 heuristics are based on the control flow graph. If some branch probabilities
13441 are specified by @code{__builtin_expect}, then the heuristics are
13442 used to guess branch probabilities for the rest of the control flow graph,
13443 taking the @code{__builtin_expect} info into account. The interactions
13444 between the heuristics and @code{__builtin_expect} can be complex, and in
13445 some cases, it may be useful to disable the heuristics so that the effects
13446 of @code{__builtin_expect} are easier to understand.
13448 It is also possible to specify expected probability of the expression
13449 with @code{__builtin_expect_with_probability} built-in function.
13451 The default is @option{-fguess-branch-probability} at levels
13452 @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13454 @item -freorder-blocks
13455 @opindex freorder-blocks
13456 Reorder basic blocks in the compiled function in order to reduce number of
13457 taken branches and improve code locality.
13459 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13461 @item -freorder-blocks-algorithm=@var{algorithm}
13462 @opindex freorder-blocks-algorithm
13463 Use the specified algorithm for basic block reordering. The
13464 @var{algorithm} argument can be @samp{simple}, which does not increase
13465 code size (except sometimes due to secondary effects like alignment),
13466 or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13467 put all often executed code together, minimizing the number of branches
13468 executed by making extra copies of code.
13470 The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13471 @samp{stc} at levels @option{-O2}, @option{-O3}.
13473 @item -freorder-blocks-and-partition
13474 @opindex freorder-blocks-and-partition
13475 In addition to reordering basic blocks in the compiled function, in order
13476 to reduce number of taken branches, partitions hot and cold basic blocks
13477 into separate sections of the assembly and @file{.o} files, to improve
13478 paging and cache locality performance.
13480 This optimization is automatically turned off in the presence of
13481 exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13482 section attribute and on any architecture that does not support named
13483 sections. When @option{-fsplit-stack} is used this option is not
13484 enabled by default (to avoid linker errors), but may be enabled
13485 explicitly (if using a working linker).
13487 Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13489 @item -freorder-functions
13490 @opindex freorder-functions
13491 Reorder functions in the object file in order to
13492 improve code locality. This is implemented by using special
13493 subsections @code{.text.hot} for most frequently executed functions and
13494 @code{.text.unlikely} for unlikely executed functions. Reordering is done by
13495 the linker so object file format must support named sections and linker must
13496 place them in a reasonable way.
13498 This option isn't effective unless you either provide profile feedback
13499 (see @option{-fprofile-arcs} for details) or manually annotate functions with
13500 @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13502 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13504 @item -fstrict-aliasing
13505 @opindex fstrict-aliasing
13506 Allow the compiler to assume the strictest aliasing rules applicable to
13507 the language being compiled. For C (and C++), this activates
13508 optimizations based on the type of expressions. In particular, an
13509 object of one type is assumed never to reside at the same address as an
13510 object of a different type, unless the types are almost the same. For
13511 example, an @code{unsigned int} can alias an @code{int}, but not a
13512 @code{void*} or a @code{double}. A character type may alias any other
13515 @anchor{Type-punning}Pay special attention to code like this:
13528 The practice of reading from a different union member than the one most
13529 recently written to (called ``type-punning'') is common. Even with
13530 @option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13531 is accessed through the union type. So, the code above works as
13532 expected. @xref{Structures unions enumerations and bit-fields
13533 implementation}. However, this code might not:
13544 Similarly, access by taking the address, casting the resulting pointer
13545 and dereferencing the result has undefined behavior, even if the cast
13546 uses a union type, e.g.:
13550 return ((union a_union *) &d)->i;
13554 The @option{-fstrict-aliasing} option is enabled at levels
13555 @option{-O2}, @option{-O3}, @option{-Os}.
13557 @item -fipa-strict-aliasing
13558 @opindex fipa-strict-aliasing
13559 Controls whether rules of @option{-fstrict-aliasing} are applied across
13560 function boundaries. Note that if multiple functions gets inlined into a
13561 single function the memory accesses are no longer considered to be crossing a
13564 The @option{-fipa-strict-aliasing} option is enabled by default and is
13565 effective only in combination with @option{-fstrict-aliasing}.
13567 @item -falign-functions
13568 @itemx -falign-functions=@var{n}
13569 @itemx -falign-functions=@var{n}:@var{m}
13570 @itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13571 @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
13572 @opindex falign-functions
13573 Align the start of functions to the next power-of-two greater than or
13574 equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13575 least the first @var{m} bytes of the function can be fetched by the CPU
13576 without crossing an @var{n}-byte alignment boundary.
13578 If @var{m} is not specified, it defaults to @var{n}.
13580 Examples: @option{-falign-functions=32} aligns functions to the next
13581 32-byte boundary, @option{-falign-functions=24} aligns to the next
13582 32-byte boundary only if this can be done by skipping 23 bytes or less,
13583 @option{-falign-functions=32:7} aligns to the next
13584 32-byte boundary only if this can be done by skipping 6 bytes or less.
13586 The second pair of @var{n2}:@var{m2} values allows you to specify
13587 a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13588 the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13589 otherwise aligns to the next 32-byte boundary if this can be done
13590 by skipping 2 bytes or less.
13591 If @var{m2} is not specified, it defaults to @var{n2}.
13593 Some assemblers only support this flag when @var{n} is a power of two;
13594 in that case, it is rounded up.
13596 @option{-fno-align-functions} and @option{-falign-functions=1} are
13597 equivalent and mean that functions are not aligned.
13599 If @var{n} is not specified or is zero, use a machine-dependent default.
13600 The maximum allowed @var{n} option value is 65536.
13602 Enabled at levels @option{-O2}, @option{-O3}.
13604 @item -flimit-function-alignment
13605 If this option is enabled, the compiler tries to avoid unnecessarily
13606 overaligning functions. It attempts to instruct the assembler to align
13607 by the amount specified by @option{-falign-functions}, but not to
13608 skip more bytes than the size of the function.
13610 @item -falign-labels
13611 @itemx -falign-labels=@var{n}
13612 @itemx -falign-labels=@var{n}:@var{m}
13613 @itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13614 @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
13615 @opindex falign-labels
13616 Align all branch targets to a power-of-two boundary.
13618 Parameters of this option are analogous to the @option{-falign-functions} option.
13619 @option{-fno-align-labels} and @option{-falign-labels=1} are
13620 equivalent and mean that labels are not aligned.
13622 If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13623 are greater than this value, then their values are used instead.
13625 If @var{n} is not specified or is zero, use a machine-dependent default
13626 which is very likely to be @samp{1}, meaning no alignment.
13627 The maximum allowed @var{n} option value is 65536.
13629 Enabled at levels @option{-O2}, @option{-O3}.
13631 @item -falign-loops
13632 @itemx -falign-loops=@var{n}
13633 @itemx -falign-loops=@var{n}:@var{m}
13634 @itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13635 @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
13636 @opindex falign-loops
13637 Align loops to a power-of-two boundary. If the loops are executed
13638 many times, this makes up for any execution of the dummy padding
13641 If @option{-falign-labels} is greater than this value, then its value
13644 Parameters of this option are analogous to the @option{-falign-functions} option.
13645 @option{-fno-align-loops} and @option{-falign-loops=1} are
13646 equivalent and mean that loops are not aligned.
13647 The maximum allowed @var{n} option value is 65536.
13649 If @var{n} is not specified or is zero, use a machine-dependent default.
13651 Enabled at levels @option{-O2}, @option{-O3}.
13653 @item -falign-jumps
13654 @itemx -falign-jumps=@var{n}
13655 @itemx -falign-jumps=@var{n}:@var{m}
13656 @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
13657 @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
13658 @opindex falign-jumps
13659 Align branch targets to a power-of-two boundary, for branch targets
13660 where the targets can only be reached by jumping. In this case,
13661 no dummy operations need be executed.
13663 If @option{-falign-labels} is greater than this value, then its value
13666 Parameters of this option are analogous to the @option{-falign-functions} option.
13667 @option{-fno-align-jumps} and @option{-falign-jumps=1} are
13668 equivalent and mean that loops are not aligned.
13670 If @var{n} is not specified or is zero, use a machine-dependent default.
13671 The maximum allowed @var{n} option value is 65536.
13673 Enabled at levels @option{-O2}, @option{-O3}.
13675 @item -fno-allocation-dce
13676 @opindex fno-allocation-dce
13677 Do not remove unused C++ allocations in dead code elimination.
13679 @item -fallow-store-data-races
13680 @opindex fallow-store-data-races
13681 Allow the compiler to perform optimizations that may introduce new data races
13682 on stores, without proving that the variable cannot be concurrently accessed
13683 by other threads. Does not affect optimization of local data. It is safe to
13684 use this option if it is known that global data will not be accessed by
13687 Examples of optimizations enabled by @option{-fallow-store-data-races} include
13688 hoisting or if-conversions that may cause a value that was already in memory
13689 to be re-written with that same value. Such re-writing is safe in a single
13690 threaded context but may be unsafe in a multi-threaded context. Note that on
13691 some processors, if-conversions may be required in order to enable
13694 Enabled at level @option{-Ofast}.
13696 @item -funit-at-a-time
13697 @opindex funit-at-a-time
13698 This option is left for compatibility reasons. @option{-funit-at-a-time}
13699 has no effect, while @option{-fno-unit-at-a-time} implies
13700 @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
13702 Enabled by default.
13704 @item -fno-toplevel-reorder
13705 @opindex fno-toplevel-reorder
13706 @opindex ftoplevel-reorder
13707 Do not reorder top-level functions, variables, and @code{asm}
13708 statements. Output them in the same order that they appear in the
13709 input file. When this option is used, unreferenced static variables
13710 are not removed. This option is intended to support existing code
13711 that relies on a particular ordering. For new code, it is better to
13712 use attributes when possible.
13714 @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
13715 also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
13716 Additionally @option{-fno-toplevel-reorder} implies
13717 @option{-fno-section-anchors}.
13719 @item -funreachable-traps
13720 @opindex funreachable-traps
13721 With this option, the compiler turns calls to
13722 @code{__builtin_unreachable} into traps, instead of using them for
13723 optimization. This also affects any such calls implicitly generated
13726 This option has the same effect as @option{-fsanitize=unreachable
13727 -fsanitize-trap=unreachable}, but does not affect the values of those
13728 options. If @option{-fsanitize=unreachable} is enabled, that option
13729 takes priority over this one.
13731 This option is enabled by default at @option{-O0} and @option{-Og}.
13735 Constructs webs as commonly used for register allocation purposes and assign
13736 each web individual pseudo register. This allows the register allocation pass
13737 to operate on pseudos directly, but also strengthens several other optimization
13738 passes, such as CSE, loop optimizer and trivial dead code remover. It can,
13739 however, make debugging impossible, since variables no longer stay in a
13742 Enabled by default with @option{-funroll-loops}.
13744 @item -fwhole-program
13745 @opindex fwhole-program
13746 Assume that the current compilation unit represents the whole program being
13747 compiled. All public functions and variables with the exception of @code{main}
13748 and those merged by attribute @code{externally_visible} become static functions
13749 and in effect are optimized more aggressively by interprocedural optimizers.
13751 With @option{-flto} this option has a limited use. In most cases the
13752 precise list of symbols used or exported from the binary is known the
13753 resolution info passed to the link-time optimizer by the linker plugin. It is
13754 still useful if no linker plugin is used or during incremental link step when
13755 final code is produced (with @option{-flto}
13756 @option{-flinker-output=nolto-rel}).
13758 @item -flto[=@var{n}]
13760 This option runs the standard link-time optimizer. When invoked
13761 with source code, it generates GIMPLE (one of GCC's internal
13762 representations) and writes it to special ELF sections in the object
13763 file. When the object files are linked together, all the function
13764 bodies are read from these ELF sections and instantiated as if they
13765 had been part of the same translation unit.
13767 To use the link-time optimizer, @option{-flto} and optimization
13768 options should be specified at compile time and during the final link.
13769 It is recommended that you compile all the files participating in the
13770 same link with the same options and also specify those options at
13775 gcc -c -O2 -flto foo.c
13776 gcc -c -O2 -flto bar.c
13777 gcc -o myprog -flto -O2 foo.o bar.o
13780 The first two invocations to GCC save a bytecode representation
13781 of GIMPLE into special ELF sections inside @file{foo.o} and
13782 @file{bar.o}. The final invocation reads the GIMPLE bytecode from
13783 @file{foo.o} and @file{bar.o}, merges the two files into a single
13784 internal image, and compiles the result as usual. Since both
13785 @file{foo.o} and @file{bar.o} are merged into a single image, this
13786 causes all the interprocedural analyses and optimizations in GCC to
13787 work across the two files as if they were a single one. This means,
13788 for example, that the inliner is able to inline functions in
13789 @file{bar.o} into functions in @file{foo.o} and vice-versa.
13791 Another (simpler) way to enable link-time optimization is:
13794 gcc -o myprog -flto -O2 foo.c bar.c
13797 The above generates bytecode for @file{foo.c} and @file{bar.c},
13798 merges them together into a single GIMPLE representation and optimizes
13799 them as usual to produce @file{myprog}.
13801 The important thing to keep in mind is that to enable link-time
13802 optimizations you need to use the GCC driver to perform the link step.
13803 GCC automatically performs link-time optimization if any of the
13804 objects involved were compiled with the @option{-flto} command-line option.
13805 You can always override
13806 the automatic decision to do link-time optimization
13807 by passing @option{-fno-lto} to the link command.
13809 To make whole program optimization effective, it is necessary to make
13810 certain whole program assumptions. The compiler needs to know
13811 what functions and variables can be accessed by libraries and runtime
13812 outside of the link-time optimized unit. When supported by the linker,
13813 the linker plugin (see @option{-fuse-linker-plugin}) passes information
13814 to the compiler about used and externally visible symbols. When
13815 the linker plugin is not available, @option{-fwhole-program} should be
13816 used to allow the compiler to make these assumptions, which leads
13817 to more aggressive optimization decisions.
13819 When a file is compiled with @option{-flto} without
13820 @option{-fuse-linker-plugin}, the generated object file is larger than
13821 a regular object file because it contains GIMPLE bytecodes and the usual
13822 final code (see @option{-ffat-lto-objects}). This means that
13823 object files with LTO information can be linked as normal object
13824 files; if @option{-fno-lto} is passed to the linker, no
13825 interprocedural optimizations are applied. Note that when
13826 @option{-fno-fat-lto-objects} is enabled the compile stage is faster
13827 but you cannot perform a regular, non-LTO link on them.
13829 When producing the final binary, GCC only
13830 applies link-time optimizations to those files that contain bytecode.
13831 Therefore, you can mix and match object files and libraries with
13832 GIMPLE bytecodes and final object code. GCC automatically selects
13833 which files to optimize in LTO mode and which files to link without
13834 further processing.
13836 Generally, options specified at link time override those
13837 specified at compile time, although in some cases GCC attempts to infer
13838 link-time options from the settings used to compile the input files.
13840 If you do not specify an optimization level option @option{-O} at
13841 link time, then GCC uses the highest optimization level
13842 used when compiling the object files. Note that it is generally
13843 ineffective to specify an optimization level option only at link time and
13844 not at compile time, for two reasons. First, compiling without
13845 optimization suppresses compiler passes that gather information
13846 needed for effective optimization at link time. Second, some early
13847 optimization passes can be performed only at compile time and
13850 There are some code generation flags preserved by GCC when
13851 generating bytecodes, as they need to be used during the final link.
13852 Currently, the following options and their settings are taken from
13853 the first object file that explicitly specifies them:
13854 @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
13855 @option{-fgnu-tm} and all the @option{-m} target flags.
13857 The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
13858 @option{-fPIE} are combined based on the following scheme:
13861 @option{-fPIC} + @option{-fpic} = @option{-fpic}
13862 @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
13863 @option{-fpic/-fPIC} + (no option) = (no option)
13864 @option{-fPIC} + @option{-fPIE} = @option{-fPIE}
13865 @option{-fpic} + @option{-fPIE} = @option{-fpie}
13866 @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
13869 Certain ABI-changing flags are required to match in all compilation units,
13870 and trying to override this at link time with a conflicting value
13871 is ignored. This includes options such as @option{-freg-struct-return}
13872 and @option{-fpcc-struct-return}.
13874 Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
13875 @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
13876 are passed through to the link stage and merged conservatively for
13877 conflicting translation units. Specifically
13878 @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
13879 precedence; and for example @option{-ffp-contract=off} takes precedence
13880 over @option{-ffp-contract=fast}. You can override them at link time.
13882 Diagnostic options such as @option{-Wstringop-overflow} are passed
13883 through to the link stage and their setting matches that of the
13884 compile-step at function granularity. Note that this matters only
13885 for diagnostics emitted during optimization. Note that code
13886 transforms such as inlining can lead to warnings being enabled
13887 or disabled for regions if code not consistent with the setting
13890 When you need to pass options to the assembler via @option{-Wa} or
13891 @option{-Xassembler} make sure to either compile such translation
13892 units with @option{-fno-lto} or consistently use the same assembler
13893 options on all translation units. You can alternatively also
13894 specify assembler options at LTO link time.
13896 To enable debug info generation you need to supply @option{-g} at
13897 compile time. If any of the input files at link time were built
13898 with debug info generation enabled the link will enable debug info
13899 generation as well. Any elaborate debug info settings
13900 like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
13901 at the linker command line and mixing different settings in different
13902 translation units is discouraged.
13904 If LTO encounters objects with C linkage declared with incompatible
13905 types in separate translation units to be linked together (undefined
13906 behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
13907 issued. The behavior is still undefined at run time. Similar
13908 diagnostics may be raised for other languages.
13910 Another feature of LTO is that it is possible to apply interprocedural
13911 optimizations on files written in different languages:
13915 g++ -c -flto bar.cc
13916 gfortran -c -flto baz.f90
13917 g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
13920 Notice that the final link is done with @command{g++} to get the C++
13921 runtime libraries and @option{-lgfortran} is added to get the Fortran
13922 runtime libraries. In general, when mixing languages in LTO mode, you
13923 should use the same link command options as when mixing languages in a
13924 regular (non-LTO) compilation.
13926 If object files containing GIMPLE bytecode are stored in a library archive, say
13927 @file{libfoo.a}, it is possible to extract and use them in an LTO link if you
13928 are using a linker with plugin support. To create static libraries suitable
13929 for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
13930 and @command{ranlib};
13931 to show the symbols of object files with GIMPLE bytecode, use
13932 @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
13933 and @command{nm} have been compiled with plugin support. At link time, use the
13934 flag @option{-fuse-linker-plugin} to ensure that the library participates in
13935 the LTO optimization process:
13938 gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
13941 With the linker plugin enabled, the linker extracts the needed
13942 GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
13943 to make them part of the aggregated GIMPLE image to be optimized.
13945 If you are not using a linker with plugin support and/or do not
13946 enable the linker plugin, then the objects inside @file{libfoo.a}
13947 are extracted and linked as usual, but they do not participate
13948 in the LTO optimization process. In order to make a static library suitable
13949 for both LTO optimization and usual linkage, compile its object files with
13950 @option{-flto} @option{-ffat-lto-objects}.
13952 Link-time optimizations do not require the presence of the whole program to
13953 operate. If the program does not require any symbols to be exported, it is
13954 possible to combine @option{-flto} and @option{-fwhole-program} to allow
13955 the interprocedural optimizers to use more aggressive assumptions which may
13956 lead to improved optimization opportunities.
13957 Use of @option{-fwhole-program} is not needed when linker plugin is
13958 active (see @option{-fuse-linker-plugin}).
13960 The current implementation of LTO makes no
13961 attempt to generate bytecode that is portable between different
13962 types of hosts. The bytecode files are versioned and there is a
13963 strict version check, so bytecode files generated in one version of
13964 GCC do not work with an older or newer version of GCC.
13966 Link-time optimization does not work well with generation of debugging
13967 information on systems other than those using a combination of ELF and
13970 If you specify the optional @var{n}, the optimization and code
13971 generation done at link time is executed in parallel using @var{n}
13972 parallel jobs by utilizing an installed @command{make} program. The
13973 environment variable @env{MAKE} may be used to override the program
13976 You can also specify @option{-flto=jobserver} to use GNU make's
13977 job server mode to determine the number of parallel jobs. This
13978 is useful when the Makefile calling GCC is already executing in parallel.
13979 You must prepend a @samp{+} to the command recipe in the parent Makefile
13980 for this to work. This option likely only works if @env{MAKE} is
13981 GNU make. Even without the option value, GCC tries to automatically
13982 detect a running GNU make's job server.
13984 Use @option{-flto=auto} to use GNU make's job server, if available,
13985 or otherwise fall back to autodetection of the number of CPU threads
13986 present in your system.
13988 @item -flto-partition=@var{alg}
13989 @opindex flto-partition
13990 Specify the partitioning algorithm used by the link-time optimizer.
13991 The value is either @samp{1to1} to specify a partitioning mirroring
13992 the original source files or @samp{balanced} to specify partitioning
13993 into equally sized chunks (whenever possible) or @samp{max} to create
13994 new partition for every symbol where possible. Specifying @samp{none}
13995 as an algorithm disables partitioning and streaming completely.
13996 The default value is @samp{balanced}. While @samp{1to1} can be used
13997 as an workaround for various code ordering issues, the @samp{max}
13998 partitioning is intended for internal testing only.
13999 The value @samp{one} specifies that exactly one partition should be
14000 used while the value @samp{none} bypasses partitioning and executes
14001 the link-time optimization step directly from the WPA phase.
14003 @item -flto-compression-level=@var{n}
14004 @opindex flto-compression-level
14005 This option specifies the level of compression used for intermediate
14006 language written to LTO object files, and is only meaningful in
14007 conjunction with LTO mode (@option{-flto}). GCC currently supports two
14008 LTO compression algorithms. For zstd, valid values are 0 (no compression)
14009 to 19 (maximum compression), while zlib supports values from 0 to 9.
14010 Values outside this range are clamped to either minimum or maximum
14011 of the supported values. If the option is not given,
14012 a default balanced compression setting is used.
14014 @item -fuse-linker-plugin
14015 @opindex fuse-linker-plugin
14016 Enables the use of a linker plugin during link-time optimization. This
14017 option relies on plugin support in the linker, which is available in gold
14018 or in GNU ld 2.21 or newer.
14020 This option enables the extraction of object files with GIMPLE bytecode out
14021 of library archives. This improves the quality of optimization by exposing
14022 more code to the link-time optimizer. This information specifies what
14023 symbols can be accessed externally (by non-LTO object or during dynamic
14024 linking). Resulting code quality improvements on binaries (and shared
14025 libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14026 See @option{-flto} for a description of the effect of this flag and how to
14029 This option is enabled by default when LTO support in GCC is enabled
14030 and GCC was configured for use with
14031 a linker supporting plugins (GNU ld 2.21 or newer or gold).
14033 @item -ffat-lto-objects
14034 @opindex ffat-lto-objects
14035 Fat LTO objects are object files that contain both the intermediate language
14036 and the object code. This makes them usable for both LTO linking and normal
14037 linking. This option is effective only when compiling with @option{-flto}
14038 and is ignored at link time.
14040 @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14041 requires the complete toolchain to be aware of LTO. It requires a linker with
14042 linker plugin support for basic functionality. Additionally,
14043 @command{nm}, @command{ar} and @command{ranlib}
14044 need to support linker plugins to allow a full-featured build environment
14045 (capable of building static libraries etc). GCC provides the @command{gcc-ar},
14046 @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14047 to these tools. With non fat LTO makefiles need to be modified to use them.
14049 Note that modern binutils provide plugin auto-load mechanism.
14050 Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14051 effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14052 @command{gcc-ranlib}).
14054 The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14057 @item -fcompare-elim
14058 @opindex fcompare-elim
14059 After register allocation and post-register allocation instruction splitting,
14060 identify arithmetic instructions that compute processor flags similar to a
14061 comparison operation based on that arithmetic. If possible, eliminate the
14062 explicit comparison operation.
14064 This pass only applies to certain targets that cannot explicitly represent
14065 the comparison operation before register allocation is complete.
14067 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14069 @item -fcprop-registers
14070 @opindex fcprop-registers
14071 After register allocation and post-register allocation instruction splitting,
14072 perform a copy-propagation pass to try to reduce scheduling dependencies
14073 and occasionally eliminate the copy.
14075 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14077 @item -fprofile-correction
14078 @opindex fprofile-correction
14079 Profiles collected using an instrumented binary for multi-threaded programs may
14080 be inconsistent due to missed counter updates. When this option is specified,
14081 GCC uses heuristics to correct or smooth out such inconsistencies. By
14082 default, GCC emits an error message when an inconsistent profile is detected.
14084 This option is enabled by @option{-fauto-profile}.
14086 @item -fprofile-partial-training
14087 @opindex fprofile-partial-training
14088 With @code{-fprofile-use} all portions of programs not executed during train
14089 run are optimized agressively for size rather than speed. In some cases it is
14090 not practical to train all possible hot paths in the program. (For
14091 example, program may contain functions specific for a given hardware and
14092 trianing may not cover all hardware configurations program is run on.) With
14093 @code{-fprofile-partial-training} profile feedback will be ignored for all
14094 functions not executed during the train run leading them to be optimized as if
14095 they were compiled without profile feedback. This leads to better performance
14096 when train run is not representative but also leads to significantly bigger
14099 @item -fprofile-use
14100 @itemx -fprofile-use=@var{path}
14101 @opindex fprofile-use
14102 Enable profile feedback-directed optimizations,
14103 and the following optimizations, many of which
14104 are generally profitable only with profile feedback available:
14106 @gccoptlist{-fbranch-probabilities -fprofile-values @gol
14107 -funroll-loops -fpeel-loops -ftracer -fvpt @gol
14108 -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14109 -fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14110 -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14111 -fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14112 -fprofile-reorder-functions}
14114 Before you can use this option, you must first generate profiling information.
14115 @xref{Instrumentation Options}, for information about the
14116 @option{-fprofile-generate} option.
14118 By default, GCC emits an error message if the feedback profiles do not
14119 match the source code. This error can be turned into a warning by using
14120 @option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14121 optimized code. Additionally, by default, GCC also emits a warning message if
14122 the feedback profiles do not exist (see @option{-Wmissing-profile}).
14124 If @var{path} is specified, GCC looks at the @var{path} to find
14125 the profile feedback data files. See @option{-fprofile-dir}.
14127 @item -fauto-profile
14128 @itemx -fauto-profile=@var{path}
14129 @opindex fauto-profile
14130 Enable sampling-based feedback-directed optimizations,
14131 and the following optimizations,
14132 many of which are generally profitable only with profile feedback available:
14134 @gccoptlist{-fbranch-probabilities -fprofile-values @gol
14135 -funroll-loops -fpeel-loops -ftracer -fvpt @gol
14136 -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14137 -fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14138 -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14139 -fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14140 -fprofile-correction}
14142 @var{path} is the name of a file containing AutoFDO profile information.
14143 If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14145 Producing an AutoFDO profile data file requires running your program
14146 with the @command{perf} utility on a supported GNU/Linux target system.
14147 For more information, see @uref{https://perf.wiki.kernel.org/}.
14151 perf record -e br_inst_retired:near_taken -b -o perf.data \
14155 Then use the @command{create_gcov} tool to convert the raw profile data
14156 to a format that can be used by GCC.@ You must also supply the
14157 unstripped binary for your program to this tool.
14158 See @uref{https://github.com/google/autofdo}.
14162 create_gcov --binary=your_program.unstripped --profile=perf.data \
14163 --gcov=profile.afdo
14167 The following options control compiler behavior regarding floating-point
14168 arithmetic. These options trade off between speed and
14169 correctness. All must be specifically enabled.
14172 @item -ffloat-store
14173 @opindex ffloat-store
14174 Do not store floating-point variables in registers, and inhibit other
14175 options that might change whether a floating-point value is taken from a
14176 register or memory.
14178 @cindex floating-point precision
14179 This option prevents undesirable excess precision on machines such as
14180 the 68000 where the floating registers (of the 68881) keep more
14181 precision than a @code{double} is supposed to have. Similarly for the
14182 x86 architecture. For most programs, the excess precision does only
14183 good, but a few programs rely on the precise definition of IEEE floating
14184 point. Use @option{-ffloat-store} for such programs, after modifying
14185 them to store all pertinent intermediate computations into variables.
14187 @item -fexcess-precision=@var{style}
14188 @opindex fexcess-precision
14189 This option allows further control over excess precision on machines
14190 where floating-point operations occur in a format with more precision or
14191 range than the IEEE standard and interchange floating-point types. By
14192 default, @option{-fexcess-precision=fast} is in effect; this means that
14193 operations may be carried out in a wider precision than the types specified
14194 in the source if that would result in faster code, and it is unpredictable
14195 when rounding to the types specified in the source code takes place.
14196 When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14197 then excess precision follows the rules specified in ISO C99 or C++; in particular,
14198 both casts and assignments cause values to be rounded to their
14199 semantic types (whereas @option{-ffloat-store} only affects
14200 assignments). This option is enabled by default for C or C++ if a strict
14201 conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14202 @option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14203 regardless of whether a strict conformance option is used.
14206 @option{-fexcess-precision=standard} is not implemented for languages
14207 other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14208 or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14209 semantics apply without excess precision, and in the latter, rounding
14213 @opindex ffast-math
14214 Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14215 @option{-ffinite-math-only}, @option{-fno-rounding-math},
14216 @option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14217 @option{-fexcess-precision=fast}.
14219 This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14221 This option is not turned on by any @option{-O} option besides
14222 @option{-Ofast} since it can result in incorrect output for programs
14223 that depend on an exact implementation of IEEE or ISO rules/specifications
14224 for math functions. It may, however, yield faster code for programs
14225 that do not require the guarantees of these specifications.
14227 @item -fno-math-errno
14228 @opindex fno-math-errno
14229 @opindex fmath-errno
14230 Do not set @code{errno} after calling math functions that are executed
14231 with a single instruction, e.g., @code{sqrt}. A program that relies on
14232 IEEE exceptions for math error handling may want to use this flag
14233 for speed while maintaining IEEE arithmetic compatibility.
14235 This option is not turned on by any @option{-O} option since
14236 it can result in incorrect output for programs that depend on
14237 an exact implementation of IEEE or ISO rules/specifications for
14238 math functions. It may, however, yield faster code for programs
14239 that do not require the guarantees of these specifications.
14241 The default is @option{-fmath-errno}.
14243 On Darwin systems, the math library never sets @code{errno}. There is
14244 therefore no reason for the compiler to consider the possibility that
14245 it might, and @option{-fno-math-errno} is the default.
14247 @item -funsafe-math-optimizations
14248 @opindex funsafe-math-optimizations
14250 Allow optimizations for floating-point arithmetic that (a) assume
14251 that arguments and results are valid and (b) may violate IEEE or
14252 ANSI standards. When used at link time, it may include libraries
14253 or startup files that change the default FPU control word or other
14254 similar optimizations.
14256 This option is not turned on by any @option{-O} option since
14257 it can result in incorrect output for programs that depend on
14258 an exact implementation of IEEE or ISO rules/specifications for
14259 math functions. It may, however, yield faster code for programs
14260 that do not require the guarantees of these specifications.
14261 Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14262 @option{-fassociative-math} and @option{-freciprocal-math}.
14264 The default is @option{-fno-unsafe-math-optimizations}.
14266 @item -fassociative-math
14267 @opindex fassociative-math
14269 Allow re-association of operands in series of floating-point operations.
14270 This violates the ISO C and C++ language standard by possibly changing
14271 computation result. NOTE: re-ordering may change the sign of zero as
14272 well as ignore NaNs and inhibit or create underflow or overflow (and
14273 thus cannot be used on code that relies on rounding behavior like
14274 @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14275 and thus may not be used when ordered comparisons are required.
14276 This option requires that both @option{-fno-signed-zeros} and
14277 @option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14278 much sense with @option{-frounding-math}. For Fortran the option
14279 is automatically enabled when both @option{-fno-signed-zeros} and
14280 @option{-fno-trapping-math} are in effect.
14282 The default is @option{-fno-associative-math}.
14284 @item -freciprocal-math
14285 @opindex freciprocal-math
14287 Allow the reciprocal of a value to be used instead of dividing by
14288 the value if this enables optimizations. For example @code{x / y}
14289 can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14290 is subject to common subexpression elimination. Note that this loses
14291 precision and increases the number of flops operating on the value.
14293 The default is @option{-fno-reciprocal-math}.
14295 @item -ffinite-math-only
14296 @opindex ffinite-math-only
14297 Allow optimizations for floating-point arithmetic that assume
14298 that arguments and results are not NaNs or +-Infs.
14300 This option is not turned on by any @option{-O} option since
14301 it can result in incorrect output for programs that depend on
14302 an exact implementation of IEEE or ISO rules/specifications for
14303 math functions. It may, however, yield faster code for programs
14304 that do not require the guarantees of these specifications.
14306 The default is @option{-fno-finite-math-only}.
14308 @item -fno-signed-zeros
14309 @opindex fno-signed-zeros
14310 @opindex fsigned-zeros
14311 Allow optimizations for floating-point arithmetic that ignore the
14312 signedness of zero. IEEE arithmetic specifies the behavior of
14313 distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14314 of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14315 This option implies that the sign of a zero result isn't significant.
14317 The default is @option{-fsigned-zeros}.
14319 @item -fno-trapping-math
14320 @opindex fno-trapping-math
14321 @opindex ftrapping-math
14322 Compile code assuming that floating-point operations cannot generate
14323 user-visible traps. These traps include division by zero, overflow,
14324 underflow, inexact result and invalid operation. This option requires
14325 that @option{-fno-signaling-nans} be in effect. Setting this option may
14326 allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14328 This option should never be turned on by any @option{-O} option since
14329 it can result in incorrect output for programs that depend on
14330 an exact implementation of IEEE or ISO rules/specifications for
14333 The default is @option{-ftrapping-math}.
14335 Future versions of GCC may provide finer control of this setting
14336 using C99's @code{FENV_ACCESS} pragma. This command-line option
14337 will be used along with @option{-frounding-math} to specify the
14338 default state for @code{FENV_ACCESS}.
14340 @item -frounding-math
14341 @opindex frounding-math
14342 Disable transformations and optimizations that assume default floating-point
14343 rounding behavior. This is round-to-zero for all floating point
14344 to integer conversions, and round-to-nearest for all other arithmetic
14345 truncations. This option should be specified for programs that change
14346 the FP rounding mode dynamically, or that may be executed with a
14347 non-default rounding mode. This option disables constant folding of
14348 floating-point expressions at compile time (which may be affected by
14349 rounding mode) and arithmetic transformations that are unsafe in the
14350 presence of sign-dependent rounding modes.
14352 The default is @option{-fno-rounding-math}.
14354 This option is experimental and does not currently guarantee to
14355 disable all GCC optimizations that are affected by rounding mode.
14356 Future versions of GCC may provide finer control of this setting
14357 using C99's @code{FENV_ACCESS} pragma. This command-line option
14358 will be used along with @option{-ftrapping-math} to specify the
14359 default state for @code{FENV_ACCESS}.
14361 @item -fsignaling-nans
14362 @opindex fsignaling-nans
14363 Compile code assuming that IEEE signaling NaNs may generate user-visible
14364 traps during floating-point operations. Setting this option disables
14365 optimizations that may change the number of exceptions visible with
14366 signaling NaNs. This option implies @option{-ftrapping-math}.
14368 This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14371 The default is @option{-fno-signaling-nans}.
14373 This option is experimental and does not currently guarantee to
14374 disable all GCC optimizations that affect signaling NaN behavior.
14376 @item -fno-fp-int-builtin-inexact
14377 @opindex fno-fp-int-builtin-inexact
14378 @opindex ffp-int-builtin-inexact
14379 Do not allow the built-in functions @code{ceil}, @code{floor},
14380 @code{round} and @code{trunc}, and their @code{float} and @code{long
14381 double} variants, to generate code that raises the ``inexact''
14382 floating-point exception for noninteger arguments. ISO C99 and C11
14383 allow these functions to raise the ``inexact'' exception, but ISO/IEC
14384 TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
14385 ISO C2X, does not allow these functions to do so.
14387 The default is @option{-ffp-int-builtin-inexact}, allowing the
14388 exception to be raised, unless C2X or a later C standard is selected.
14389 This option does nothing unless @option{-ftrapping-math} is in effect.
14391 Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14392 generate a call to a library function then the ``inexact'' exception
14393 may be raised if the library implementation does not follow TS 18661.
14395 @item -fsingle-precision-constant
14396 @opindex fsingle-precision-constant
14397 Treat floating-point constants as single precision instead of
14398 implicitly converting them to double-precision constants.
14400 @item -fcx-limited-range
14401 @opindex fcx-limited-range
14402 When enabled, this option states that a range reduction step is not
14403 needed when performing complex division. Also, there is no checking
14404 whether the result of a complex multiplication or division is @code{NaN
14405 + I*NaN}, with an attempt to rescue the situation in that case. The
14406 default is @option{-fno-cx-limited-range}, but is enabled by
14407 @option{-ffast-math}.
14409 This option controls the default setting of the ISO C99
14410 @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14413 @item -fcx-fortran-rules
14414 @opindex fcx-fortran-rules
14415 Complex multiplication and division follow Fortran rules. Range
14416 reduction is done as part of complex division, but there is no checking
14417 whether the result of a complex multiplication or division is @code{NaN
14418 + I*NaN}, with an attempt to rescue the situation in that case.
14420 The default is @option{-fno-cx-fortran-rules}.
14424 The following options control optimizations that may improve
14425 performance, but are not enabled by any @option{-O} options. This
14426 section includes experimental options that may produce broken code.
14429 @item -fbranch-probabilities
14430 @opindex fbranch-probabilities
14431 After running a program compiled with @option{-fprofile-arcs}
14432 (@pxref{Instrumentation Options}),
14433 you can compile it a second time using
14434 @option{-fbranch-probabilities}, to improve optimizations based on
14435 the number of times each branch was taken. When a program
14436 compiled with @option{-fprofile-arcs} exits, it saves arc execution
14437 counts to a file called @file{@var{sourcename}.gcda} for each source
14438 file. The information in this data file is very dependent on the
14439 structure of the generated code, so you must use the same source code
14440 and the same optimization options for both compilations.
14441 See details about the file naming in @option{-fprofile-arcs}.
14443 With @option{-fbranch-probabilities}, GCC puts a
14444 @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14445 These can be used to improve optimization. Currently, they are only
14446 used in one place: in @file{reorg.cc}, instead of guessing which path a
14447 branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14448 exactly determine which path is taken more often.
14450 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14452 @item -fprofile-values
14453 @opindex fprofile-values
14454 If combined with @option{-fprofile-arcs}, it adds code so that some
14455 data about values of expressions in the program is gathered.
14457 With @option{-fbranch-probabilities}, it reads back the data gathered
14458 from profiling values of expressions for usage in optimizations.
14460 Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14461 @option{-fauto-profile}.
14463 @item -fprofile-reorder-functions
14464 @opindex fprofile-reorder-functions
14465 Function reordering based on profile instrumentation collects
14466 first time of execution of a function and orders these functions
14467 in ascending order.
14469 Enabled with @option{-fprofile-use}.
14473 If combined with @option{-fprofile-arcs}, this option instructs the compiler
14474 to add code to gather information about values of expressions.
14476 With @option{-fbranch-probabilities}, it reads back the data gathered
14477 and actually performs the optimizations based on them.
14478 Currently the optimizations include specialization of division operations
14479 using the knowledge about the value of the denominator.
14481 Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14483 @item -frename-registers
14484 @opindex frename-registers
14485 Attempt to avoid false dependencies in scheduled code by making use
14486 of registers left over after register allocation. This optimization
14487 most benefits processors with lots of registers. Depending on the
14488 debug information format adopted by the target, however, it can
14489 make debugging impossible, since variables no longer stay in
14490 a ``home register''.
14492 Enabled by default with @option{-funroll-loops}.
14494 @item -fschedule-fusion
14495 @opindex fschedule-fusion
14496 Performs a target dependent pass over the instruction stream to schedule
14497 instructions of same type together because target machine can execute them
14498 more efficiently if they are adjacent to each other in the instruction flow.
14500 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14504 Perform tail duplication to enlarge superblock size. This transformation
14505 simplifies the control flow of the function allowing other optimizations to do
14508 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14510 @item -funroll-loops
14511 @opindex funroll-loops
14512 Unroll loops whose number of iterations can be determined at compile time or
14513 upon entry to the loop. @option{-funroll-loops} implies
14514 @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14515 It also turns on complete loop peeling (i.e.@: complete removal of loops with
14516 a small constant number of iterations). This option makes code larger, and may
14517 or may not make it run faster.
14519 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14521 @item -funroll-all-loops
14522 @opindex funroll-all-loops
14523 Unroll all loops, even if their number of iterations is uncertain when
14524 the loop is entered. This usually makes programs run more slowly.
14525 @option{-funroll-all-loops} implies the same options as
14526 @option{-funroll-loops}.
14529 @opindex fpeel-loops
14530 Peels loops for which there is enough information that they do not
14531 roll much (from profile feedback or static analysis). It also turns on
14532 complete loop peeling (i.e.@: complete removal of loops with small constant
14533 number of iterations).
14535 Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14537 @item -fmove-loop-invariants
14538 @opindex fmove-loop-invariants
14539 Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14540 at level @option{-O1} and higher, except for @option{-Og}.
14542 @item -fmove-loop-stores
14543 @opindex fmove-loop-stores
14544 Enables the loop store motion pass in the GIMPLE loop optimizer. This
14545 moves invariant stores to after the end of the loop in exchange for
14546 carrying the stored value in a register across the iteration.
14547 Note for this option to have an effect @option{-ftree-loop-im} has to
14548 be enabled as well. Enabled at level @option{-O1} and higher, except
14551 @item -fsplit-loops
14552 @opindex fsplit-loops
14553 Split a loop into two if it contains a condition that's always true
14554 for one side of the iteration space and false for the other.
14556 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14558 @item -funswitch-loops
14559 @opindex funswitch-loops
14560 Move branches with loop invariant conditions out of the loop, with duplicates
14561 of the loop on both branches (modified according to result of the condition).
14563 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14565 @item -fversion-loops-for-strides
14566 @opindex fversion-loops-for-strides
14567 If a loop iterates over an array with a variable stride, create another
14568 version of the loop that assumes the stride is always one. For example:
14571 for (int i = 0; i < n; ++i)
14572 x[i * stride] = @dots{};
14579 for (int i = 0; i < n; ++i)
14582 for (int i = 0; i < n; ++i)
14583 x[i * stride] = @dots{};
14586 This is particularly useful for assumed-shape arrays in Fortran where
14587 (for example) it allows better vectorization assuming contiguous accesses.
14588 This flag is enabled by default at @option{-O3}.
14589 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14591 @item -ffunction-sections
14592 @itemx -fdata-sections
14593 @opindex ffunction-sections
14594 @opindex fdata-sections
14595 Place each function or data item into its own section in the output
14596 file if the target supports arbitrary sections. The name of the
14597 function or the name of the data item determines the section's name
14598 in the output file.
14600 Use these options on systems where the linker can perform optimizations to
14601 improve locality of reference in the instruction space. Most systems using the
14602 ELF object format have linkers with such optimizations. On AIX, the linker
14603 rearranges sections (CSECTs) based on the call graph. The performance impact
14606 Together with a linker garbage collection (linker @option{--gc-sections}
14607 option) these options may lead to smaller statically-linked executables (after
14610 On ELF/DWARF systems these options do not degenerate the quality of the debug
14611 information. There could be issues with other object files/debug info formats.
14613 Only use these options when there are significant benefits from doing so. When
14614 you specify these options, the assembler and linker create larger object and
14615 executable files and are also slower. These options affect code generation.
14616 They prevent optimizations by the compiler and assembler using relative
14617 locations inside a translation unit since the locations are unknown until
14618 link time. An example of such an optimization is relaxing calls to short call
14622 @opindex fstdarg-opt
14623 Optimize the prologue of variadic argument functions with respect to usage of
14626 @item -fsection-anchors
14627 @opindex fsection-anchors
14628 Try to reduce the number of symbolic address calculations by using
14629 shared ``anchor'' symbols to address nearby objects. This transformation
14630 can help to reduce the number of GOT entries and GOT accesses on some
14633 For example, the implementation of the following function @code{foo}:
14636 static int a, b, c;
14637 int foo (void) @{ return a + b + c; @}
14641 usually calculates the addresses of all three variables, but if you
14642 compile it with @option{-fsection-anchors}, it accesses the variables
14643 from a common anchor point instead. The effect is similar to the
14644 following pseudocode (which isn't valid C):
14649 register int *xr = &x;
14650 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
14654 Not all targets support this option.
14656 @item -fzero-call-used-regs=@var{choice}
14657 @opindex fzero-call-used-regs
14658 Zero call-used registers at function return to increase program
14659 security by either mitigating Return-Oriented Programming (ROP)
14660 attacks or preventing information leakage through registers.
14662 The possible values of @var{choice} are the same as for the
14663 @code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
14664 The default is @samp{skip}.
14666 You can control this behavior for a specific function by using the function
14667 attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
14669 @item --param @var{name}=@var{value}
14671 In some places, GCC uses various constants to control the amount of
14672 optimization that is done. For example, GCC does not inline functions
14673 that contain more than a certain number of instructions. You can
14674 control some of these constants on the command line using the
14675 @option{--param} option.
14677 The names of specific parameters, and the meaning of the values, are
14678 tied to the internals of the compiler, and are subject to change
14679 without notice in future releases.
14681 In order to get the minimal, maximal and default values of a parameter,
14682 use the @option{--help=param -Q} options.
14684 In each case, the @var{value} is an integer. The following choices
14685 of @var{name} are recognized for all targets:
14688 @item predictable-branch-outcome
14689 When branch is predicted to be taken with probability lower than this threshold
14690 (in percent), then it is considered well predictable.
14692 @item max-rtl-if-conversion-insns
14693 RTL if-conversion tries to remove conditional branches around a block and
14694 replace them with conditionally executed instructions. This parameter
14695 gives the maximum number of instructions in a block which should be
14696 considered for if-conversion. The compiler will
14697 also use other heuristics to decide whether if-conversion is likely to be
14700 @item max-rtl-if-conversion-predictable-cost
14701 RTL if-conversion will try to remove conditional branches around a block
14702 and replace them with conditionally executed instructions. These parameters
14703 give the maximum permissible cost for the sequence that would be generated
14704 by if-conversion depending on whether the branch is statically determined
14705 to be predictable or not. The units for this parameter are the same as
14706 those for the GCC internal seq_cost metric. The compiler will try to
14707 provide a reasonable default for this parameter using the BRANCH_COST
14710 @item max-crossjump-edges
14711 The maximum number of incoming edges to consider for cross-jumping.
14712 The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
14713 the number of edges incoming to each block. Increasing values mean
14714 more aggressive optimization, making the compilation time increase with
14715 probably small improvement in executable size.
14717 @item min-crossjump-insns
14718 The minimum number of instructions that must be matched at the end
14719 of two blocks before cross-jumping is performed on them. This
14720 value is ignored in the case where all instructions in the block being
14721 cross-jumped from are matched.
14723 @item max-grow-copy-bb-insns
14724 The maximum code size expansion factor when copying basic blocks
14725 instead of jumping. The expansion is relative to a jump instruction.
14727 @item max-goto-duplication-insns
14728 The maximum number of instructions to duplicate to a block that jumps
14729 to a computed goto. To avoid @math{O(N^2)} behavior in a number of
14730 passes, GCC factors computed gotos early in the compilation process,
14731 and unfactors them as late as possible. Only computed jumps at the
14732 end of a basic blocks with no more than max-goto-duplication-insns are
14735 @item max-delay-slot-insn-search
14736 The maximum number of instructions to consider when looking for an
14737 instruction to fill a delay slot. If more than this arbitrary number of
14738 instructions are searched, the time savings from filling the delay slot
14739 are minimal, so stop searching. Increasing values mean more
14740 aggressive optimization, making the compilation time increase with probably
14741 small improvement in execution time.
14743 @item max-delay-slot-live-search
14744 When trying to fill delay slots, the maximum number of instructions to
14745 consider when searching for a block with valid live register
14746 information. Increasing this arbitrarily chosen value means more
14747 aggressive optimization, increasing the compilation time. This parameter
14748 should be removed when the delay slot code is rewritten to maintain the
14749 control-flow graph.
14751 @item max-gcse-memory
14752 The approximate maximum amount of memory in @code{kB} that can be allocated in
14753 order to perform the global common subexpression elimination
14754 optimization. If more memory than specified is required, the
14755 optimization is not done.
14757 @item max-gcse-insertion-ratio
14758 If the ratio of expression insertions to deletions is larger than this value
14759 for any expression, then RTL PRE inserts or removes the expression and thus
14760 leaves partially redundant computations in the instruction stream.
14762 @item max-pending-list-length
14763 The maximum number of pending dependencies scheduling allows
14764 before flushing the current state and starting over. Large functions
14765 with few branches or calls can create excessively large lists which
14766 needlessly consume memory and resources.
14768 @item max-modulo-backtrack-attempts
14769 The maximum number of backtrack attempts the scheduler should make
14770 when modulo scheduling a loop. Larger values can exponentially increase
14773 @item max-inline-functions-called-once-loop-depth
14774 Maximal loop depth of a call considered by inline heuristics that tries to
14775 inline all functions called once.
14777 @item max-inline-functions-called-once-insns
14778 Maximal estimated size of functions produced while inlining functions called
14781 @item max-inline-insns-single
14782 Several parameters control the tree inliner used in GCC@. This number sets the
14783 maximum number of instructions (counted in GCC's internal representation) in a
14784 single function that the tree inliner considers for inlining. This only
14785 affects functions declared inline and methods implemented in a class
14789 @item max-inline-insns-auto
14790 When you use @option{-finline-functions} (included in @option{-O3}),
14791 a lot of functions that would otherwise not be considered for inlining
14792 by the compiler are investigated. To those functions, a different
14793 (more restrictive) limit compared to functions declared inline can
14794 be applied (@option{--param max-inline-insns-auto}).
14796 @item max-inline-insns-small
14797 This is bound applied to calls which are considered relevant with
14798 @option{-finline-small-functions}.
14800 @item max-inline-insns-size
14801 This is bound applied to calls which are optimized for size. Small growth
14802 may be desirable to anticipate optimization oppurtunities exposed by inlining.
14804 @item uninlined-function-insns
14805 Number of instructions accounted by inliner for function overhead such as
14806 function prologue and epilogue.
14808 @item uninlined-function-time
14809 Extra time accounted by inliner for function overhead such as time needed to
14810 execute function prologue and epilogue.
14812 @item inline-heuristics-hint-percent
14813 The scale (in percents) applied to @option{inline-insns-single},
14814 @option{inline-insns-single-O2}, @option{inline-insns-auto}
14815 when inline heuristics hints that inlining is
14816 very profitable (will enable later optimizations).
14818 @item uninlined-thunk-insns
14819 @item uninlined-thunk-time
14820 Same as @option{--param uninlined-function-insns} and
14821 @option{--param uninlined-function-time} but applied to function thunks.
14823 @item inline-min-speedup
14824 When estimated performance improvement of caller + callee runtime exceeds this
14825 threshold (in percent), the function can be inlined regardless of the limit on
14826 @option{--param max-inline-insns-single} and @option{--param
14827 max-inline-insns-auto}.
14829 @item large-function-insns
14830 The limit specifying really large functions. For functions larger than this
14831 limit after inlining, inlining is constrained by
14832 @option{--param large-function-growth}. This parameter is useful primarily
14833 to avoid extreme compilation time caused by non-linear algorithms used by the
14836 @item large-function-growth
14837 Specifies maximal growth of large function caused by inlining in percents.
14838 For example, parameter value 100 limits large function growth to 2.0 times
14841 @item large-unit-insns
14842 The limit specifying large translation unit. Growth caused by inlining of
14843 units larger than this limit is limited by @option{--param inline-unit-growth}.
14844 For small units this might be too tight.
14845 For example, consider a unit consisting of function A
14846 that is inline and B that just calls A three times. If B is small relative to
14847 A, the growth of unit is 300\% and yet such inlining is very sane. For very
14848 large units consisting of small inlineable functions, however, the overall unit
14849 growth limit is needed to avoid exponential explosion of code size. Thus for
14850 smaller units, the size is increased to @option{--param large-unit-insns}
14851 before applying @option{--param inline-unit-growth}.
14854 Maximum number of concurrently open C++ module files when lazy loading.
14856 @item inline-unit-growth
14857 Specifies maximal overall growth of the compilation unit caused by inlining.
14858 For example, parameter value 20 limits unit growth to 1.2 times the original
14859 size. Cold functions (either marked cold via an attribute or by profile
14860 feedback) are not accounted into the unit size.
14862 @item ipa-cp-unit-growth
14863 Specifies maximal overall growth of the compilation unit caused by
14864 interprocedural constant propagation. For example, parameter value 10 limits
14865 unit growth to 1.1 times the original size.
14867 @item ipa-cp-large-unit-insns
14868 The size of translation unit that IPA-CP pass considers large.
14870 @item large-stack-frame
14871 The limit specifying large stack frames. While inlining the algorithm is trying
14872 to not grow past this limit too much.
14874 @item large-stack-frame-growth
14875 Specifies maximal growth of large stack frames caused by inlining in percents.
14876 For example, parameter value 1000 limits large stack frame growth to 11 times
14879 @item max-inline-insns-recursive
14880 @itemx max-inline-insns-recursive-auto
14881 Specifies the maximum number of instructions an out-of-line copy of a
14882 self-recursive inline
14883 function can grow into by performing recursive inlining.
14885 @option{--param max-inline-insns-recursive} applies to functions
14887 For functions not declared inline, recursive inlining
14888 happens only when @option{-finline-functions} (included in @option{-O3}) is
14889 enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
14891 @item max-inline-recursive-depth
14892 @itemx max-inline-recursive-depth-auto
14893 Specifies the maximum recursion depth used for recursive inlining.
14895 @option{--param max-inline-recursive-depth} applies to functions
14896 declared inline. For functions not declared inline, recursive inlining
14897 happens only when @option{-finline-functions} (included in @option{-O3}) is
14898 enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
14900 @item min-inline-recursive-probability
14901 Recursive inlining is profitable only for function having deep recursion
14902 in average and can hurt for function having little recursion depth by
14903 increasing the prologue size or complexity of function body to other
14906 When profile feedback is available (see @option{-fprofile-generate}) the actual
14907 recursion depth can be guessed from the probability that function recurses
14908 via a given call expression. This parameter limits inlining only to call
14909 expressions whose probability exceeds the given threshold (in percents).
14911 @item early-inlining-insns
14912 Specify growth that the early inliner can make. In effect it increases
14913 the amount of inlining for code having a large abstraction penalty.
14915 @item max-early-inliner-iterations
14916 Limit of iterations of the early inliner. This basically bounds
14917 the number of nested indirect calls the early inliner can resolve.
14918 Deeper chains are still handled by late inlining.
14920 @item comdat-sharing-probability
14921 Probability (in percent) that C++ inline function with comdat visibility
14922 are shared across multiple compilation units.
14924 @item modref-max-bases
14925 @item modref-max-refs
14926 @item modref-max-accesses
14927 Specifies the maximal number of base pointers, references and accesses stored
14928 for a single function by mod/ref analysis.
14930 @item modref-max-tests
14931 Specifies the maxmal number of tests alias oracle can perform to disambiguate
14932 memory locations using the mod/ref information. This parameter ought to be
14933 bigger than @option{--param modref-max-bases} and @option{--param
14936 @item modref-max-depth
14937 Specifies the maximum depth of DFS walk used by modref escape analysis.
14938 Setting to 0 disables the analysis completely.
14940 @item modref-max-escape-points
14941 Specifies the maximum number of escape points tracked by modref per SSA-name.
14943 @item modref-max-adjustments
14944 Specifies the maximum number the access range is enlarged during modref dataflow
14947 @item profile-func-internal-id
14948 A parameter to control whether to use function internal id in profile
14949 database lookup. If the value is 0, the compiler uses an id that
14950 is based on function assembler name and filename, which makes old profile
14951 data more tolerant to source changes such as function reordering etc.
14953 @item min-vect-loop-bound
14954 The minimum number of iterations under which loops are not vectorized
14955 when @option{-ftree-vectorize} is used. The number of iterations after
14956 vectorization needs to be greater than the value specified by this option
14957 to allow vectorization.
14959 @item gcse-cost-distance-ratio
14960 Scaling factor in calculation of maximum distance an expression
14961 can be moved by GCSE optimizations. This is currently supported only in the
14962 code hoisting pass. The bigger the ratio, the more aggressive code hoisting
14963 is with simple expressions, i.e., the expressions that have cost
14964 less than @option{gcse-unrestricted-cost}. Specifying 0 disables
14965 hoisting of simple expressions.
14967 @item gcse-unrestricted-cost
14968 Cost, roughly measured as the cost of a single typical machine
14969 instruction, at which GCSE optimizations do not constrain
14970 the distance an expression can travel. This is currently
14971 supported only in the code hoisting pass. The lesser the cost,
14972 the more aggressive code hoisting is. Specifying 0
14973 allows all expressions to travel unrestricted distances.
14975 @item max-hoist-depth
14976 The depth of search in the dominator tree for expressions to hoist.
14977 This is used to avoid quadratic behavior in hoisting algorithm.
14978 The value of 0 does not limit on the search, but may slow down compilation
14981 @item max-tail-merge-comparisons
14982 The maximum amount of similar bbs to compare a bb with. This is used to
14983 avoid quadratic behavior in tree tail merging.
14985 @item max-tail-merge-iterations
14986 The maximum amount of iterations of the pass over the function. This is used to
14987 limit compilation time in tree tail merging.
14989 @item store-merging-allow-unaligned
14990 Allow the store merging pass to introduce unaligned stores if it is legal to
14993 @item max-stores-to-merge
14994 The maximum number of stores to attempt to merge into wider stores in the store
14997 @item max-store-chains-to-track
14998 The maximum number of store chains to track at the same time in the attempt
14999 to merge them into wider stores in the store merging pass.
15001 @item max-stores-to-track
15002 The maximum number of stores to track at the same time in the attemt to
15003 to merge them into wider stores in the store merging pass.
15005 @item max-unrolled-insns
15006 The maximum number of instructions that a loop may have to be unrolled.
15007 If a loop is unrolled, this parameter also determines how many times
15008 the loop code is unrolled.
15010 @item max-average-unrolled-insns
15011 The maximum number of instructions biased by probabilities of their execution
15012 that a loop may have to be unrolled. If a loop is unrolled,
15013 this parameter also determines how many times the loop code is unrolled.
15015 @item max-unroll-times
15016 The maximum number of unrollings of a single loop.
15018 @item max-peeled-insns
15019 The maximum number of instructions that a loop may have to be peeled.
15020 If a loop is peeled, this parameter also determines how many times
15021 the loop code is peeled.
15023 @item max-peel-times
15024 The maximum number of peelings of a single loop.
15026 @item max-peel-branches
15027 The maximum number of branches on the hot path through the peeled sequence.
15029 @item max-completely-peeled-insns
15030 The maximum number of insns of a completely peeled loop.
15032 @item max-completely-peel-times
15033 The maximum number of iterations of a loop to be suitable for complete peeling.
15035 @item max-completely-peel-loop-nest-depth
15036 The maximum depth of a loop nest suitable for complete peeling.
15038 @item max-unswitch-insns
15039 The maximum number of insns of an unswitched loop.
15041 @item max-unswitch-depth
15042 The maximum depth of a loop nest to be unswitched.
15044 @item lim-expensive
15045 The minimum cost of an expensive expression in the loop invariant motion.
15047 @item min-loop-cond-split-prob
15048 When FDO profile information is available, @option{min-loop-cond-split-prob}
15049 specifies minimum threshold for probability of semi-invariant condition
15050 statement to trigger loop split.
15052 @item iv-consider-all-candidates-bound
15053 Bound on number of candidates for induction variables, below which
15054 all candidates are considered for each use in induction variable
15055 optimizations. If there are more candidates than this,
15056 only the most relevant ones are considered to avoid quadratic time complexity.
15058 @item iv-max-considered-uses
15059 The induction variable optimizations give up on loops that contain more
15060 induction variable uses.
15062 @item iv-always-prune-cand-set-bound
15063 If the number of candidates in the set is smaller than this value,
15064 always try to remove unnecessary ivs from the set
15065 when adding a new one.
15067 @item avg-loop-niter
15068 Average number of iterations of a loop.
15070 @item dse-max-object-size
15071 Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15072 Larger values may result in larger compilation times.
15074 @item dse-max-alias-queries-per-store
15075 Maximum number of queries into the alias oracle per store.
15076 Larger values result in larger compilation times and may result in more
15077 removed dead stores.
15079 @item scev-max-expr-size
15080 Bound on size of expressions used in the scalar evolutions analyzer.
15081 Large expressions slow the analyzer.
15083 @item scev-max-expr-complexity
15084 Bound on the complexity of the expressions in the scalar evolutions analyzer.
15085 Complex expressions slow the analyzer.
15087 @item max-tree-if-conversion-phi-args
15088 Maximum number of arguments in a PHI supported by TREE if conversion
15089 unless the loop is marked with simd pragma.
15091 @item vect-max-layout-candidates
15092 The maximum number of possible vector layouts (such as permutations)
15093 to consider when optimizing to-be-vectorized code.
15095 @item vect-max-version-for-alignment-checks
15096 The maximum number of run-time checks that can be performed when
15097 doing loop versioning for alignment in the vectorizer.
15099 @item vect-max-version-for-alias-checks
15100 The maximum number of run-time checks that can be performed when
15101 doing loop versioning for alias in the vectorizer.
15103 @item vect-max-peeling-for-alignment
15104 The maximum number of loop peels to enhance access alignment
15105 for vectorizer. Value -1 means no limit.
15107 @item max-iterations-to-track
15108 The maximum number of iterations of a loop the brute-force algorithm
15109 for analysis of the number of iterations of the loop tries to evaluate.
15111 @item hot-bb-count-fraction
15112 The denominator n of fraction 1/n of the maximal execution count of a
15113 basic block in the entire program that a basic block needs to at least
15114 have in order to be considered hot. The default is 10000, which means
15115 that a basic block is considered hot if its execution count is greater
15116 than 1/10000 of the maximal execution count. 0 means that it is never
15117 considered hot. Used in non-LTO mode.
15119 @item hot-bb-count-ws-permille
15120 The number of most executed permilles, ranging from 0 to 1000, of the
15121 profiled execution of the entire program to which the execution count
15122 of a basic block must be part of in order to be considered hot. The
15123 default is 990, which means that a basic block is considered hot if
15124 its execution count contributes to the upper 990 permilles, or 99.0%,
15125 of the profiled execution of the entire program. 0 means that it is
15126 never considered hot. Used in LTO mode.
15128 @item hot-bb-frequency-fraction
15129 The denominator n of fraction 1/n of the execution frequency of the
15130 entry block of a function that a basic block of this function needs
15131 to at least have in order to be considered hot. The default is 1000,
15132 which means that a basic block is considered hot in a function if it
15133 is executed more frequently than 1/1000 of the frequency of the entry
15134 block of the function. 0 means that it is never considered hot.
15136 @item unlikely-bb-count-fraction
15137 The denominator n of fraction 1/n of the number of profiled runs of
15138 the entire program below which the execution count of a basic block
15139 must be in order for the basic block to be considered unlikely executed.
15140 The default is 20, which means that a basic block is considered unlikely
15141 executed if it is executed in fewer than 1/20, or 5%, of the runs of
15142 the program. 0 means that it is always considered unlikely executed.
15144 @item max-predicted-iterations
15145 The maximum number of loop iterations we predict statically. This is useful
15146 in cases where a function contains a single loop with known bound and
15147 another loop with unknown bound.
15148 The known number of iterations is predicted correctly, while
15149 the unknown number of iterations average to roughly 10. This means that the
15150 loop without bounds appears artificially cold relative to the other one.
15152 @item builtin-expect-probability
15153 Control the probability of the expression having the specified value. This
15154 parameter takes a percentage (i.e.@: 0 ... 100) as input.
15156 @item builtin-string-cmp-inline-length
15157 The maximum length of a constant string for a builtin string cmp call
15158 eligible for inlining.
15160 @item align-threshold
15162 Select fraction of the maximal frequency of executions of a basic block in
15163 a function to align the basic block.
15165 @item align-loop-iterations
15167 A loop expected to iterate at least the selected number of iterations is
15170 @item tracer-dynamic-coverage
15171 @itemx tracer-dynamic-coverage-feedback
15173 This value is used to limit superblock formation once the given percentage of
15174 executed instructions is covered. This limits unnecessary code size
15177 The @option{tracer-dynamic-coverage-feedback} parameter
15178 is used only when profile
15179 feedback is available. The real profiles (as opposed to statically estimated
15180 ones) are much less balanced allowing the threshold to be larger value.
15182 @item tracer-max-code-growth
15183 Stop tail duplication once code growth has reached given percentage. This is
15184 a rather artificial limit, as most of the duplicates are eliminated later in
15185 cross jumping, so it may be set to much higher values than is the desired code
15188 @item tracer-min-branch-ratio
15190 Stop reverse growth when the reverse probability of best edge is less than this
15191 threshold (in percent).
15193 @item tracer-min-branch-probability
15194 @itemx tracer-min-branch-probability-feedback
15196 Stop forward growth if the best edge has probability lower than this
15199 Similarly to @option{tracer-dynamic-coverage} two parameters are
15200 provided. @option{tracer-min-branch-probability-feedback} is used for
15201 compilation with profile feedback and @option{tracer-min-branch-probability}
15202 compilation without. The value for compilation with profile feedback
15203 needs to be more conservative (higher) in order to make tracer
15206 @item stack-clash-protection-guard-size
15207 Specify the size of the operating system provided stack guard as
15208 2 raised to @var{num} bytes. Higher values may reduce the
15209 number of explicit probes, but a value larger than the operating system
15210 provided guard will leave code vulnerable to stack clash style attacks.
15212 @item stack-clash-protection-probe-interval
15213 Stack clash protection involves probing stack space as it is allocated. This
15214 param controls the maximum distance between probes into the stack as 2 raised
15215 to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15216 larger than the operating system provided guard will leave code vulnerable to
15217 stack clash style attacks.
15219 @item max-cse-path-length
15221 The maximum number of basic blocks on path that CSE considers.
15223 @item max-cse-insns
15224 The maximum number of instructions CSE processes before flushing.
15226 @item ggc-min-expand
15228 GCC uses a garbage collector to manage its own memory allocation. This
15229 parameter specifies the minimum percentage by which the garbage
15230 collector's heap should be allowed to expand between collections.
15231 Tuning this may improve compilation speed; it has no effect on code
15234 The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15235 RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15236 the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15237 GCC is not able to calculate RAM on a particular platform, the lower
15238 bound of 30% is used. Setting this parameter and
15239 @option{ggc-min-heapsize} to zero causes a full collection to occur at
15240 every opportunity. This is extremely slow, but can be useful for
15243 @item ggc-min-heapsize
15245 Minimum size of the garbage collector's heap before it begins bothering
15246 to collect garbage. The first collection occurs after the heap expands
15247 by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15248 tuning this may improve compilation speed, and has no effect on code
15251 The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15252 tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15253 with a lower bound of 4096 (four megabytes) and an upper bound of
15254 131072 (128 megabytes). If GCC is not able to calculate RAM on a
15255 particular platform, the lower bound is used. Setting this parameter
15256 very large effectively disables garbage collection. Setting this
15257 parameter and @option{ggc-min-expand} to zero causes a full collection
15258 to occur at every opportunity.
15260 @item max-reload-search-insns
15261 The maximum number of instruction reload should look backward for equivalent
15262 register. Increasing values mean more aggressive optimization, making the
15263 compilation time increase with probably slightly better performance.
15265 @item max-cselib-memory-locations
15266 The maximum number of memory locations cselib should take into account.
15267 Increasing values mean more aggressive optimization, making the compilation time
15268 increase with probably slightly better performance.
15270 @item max-sched-ready-insns
15271 The maximum number of instructions ready to be issued the scheduler should
15272 consider at any given time during the first scheduling pass. Increasing
15273 values mean more thorough searches, making the compilation time increase
15274 with probably little benefit.
15276 @item max-sched-region-blocks
15277 The maximum number of blocks in a region to be considered for
15278 interblock scheduling.
15280 @item max-pipeline-region-blocks
15281 The maximum number of blocks in a region to be considered for
15282 pipelining in the selective scheduler.
15284 @item max-sched-region-insns
15285 The maximum number of insns in a region to be considered for
15286 interblock scheduling.
15288 @item max-pipeline-region-insns
15289 The maximum number of insns in a region to be considered for
15290 pipelining in the selective scheduler.
15292 @item min-spec-prob
15293 The minimum probability (in percents) of reaching a source block
15294 for interblock speculative scheduling.
15296 @item max-sched-extend-regions-iters
15297 The maximum number of iterations through CFG to extend regions.
15298 A value of 0 disables region extensions.
15300 @item max-sched-insn-conflict-delay
15301 The maximum conflict delay for an insn to be considered for speculative motion.
15303 @item sched-spec-prob-cutoff
15304 The minimal probability of speculation success (in percents), so that
15305 speculative insns are scheduled.
15307 @item sched-state-edge-prob-cutoff
15308 The minimum probability an edge must have for the scheduler to save its
15311 @item sched-mem-true-dep-cost
15312 Minimal distance (in CPU cycles) between store and load targeting same
15315 @item selsched-max-lookahead
15316 The maximum size of the lookahead window of selective scheduling. It is a
15317 depth of search for available instructions.
15319 @item selsched-max-sched-times
15320 The maximum number of times that an instruction is scheduled during
15321 selective scheduling. This is the limit on the number of iterations
15322 through which the instruction may be pipelined.
15324 @item selsched-insns-to-rename
15325 The maximum number of best instructions in the ready list that are considered
15326 for renaming in the selective scheduler.
15329 The minimum value of stage count that swing modulo scheduler
15332 @item max-last-value-rtl
15333 The maximum size measured as number of RTLs that can be recorded in an expression
15334 in combiner for a pseudo register as last known value of that register.
15336 @item max-combine-insns
15337 The maximum number of instructions the RTL combiner tries to combine.
15339 @item integer-share-limit
15340 Small integer constants can use a shared data structure, reducing the
15341 compiler's memory usage and increasing its speed. This sets the maximum
15342 value of a shared integer constant.
15344 @item ssp-buffer-size
15345 The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15346 protection when @option{-fstack-protector} is used.
15348 @item min-size-for-stack-sharing
15349 The minimum size of variables taking part in stack slot sharing when not
15352 @item max-jump-thread-duplication-stmts
15353 Maximum number of statements allowed in a block that needs to be
15354 duplicated when threading jumps.
15356 @item max-jump-thread-paths
15357 The maximum number of paths to consider when searching for jump threading
15358 opportunities. When arriving at a block, incoming edges are only considered
15359 if the number of paths to be searched so far multiplied by the number of
15360 incoming edges does not exhaust the specified maximum number of paths to
15363 @item max-fields-for-field-sensitive
15364 Maximum number of fields in a structure treated in
15365 a field sensitive manner during pointer analysis.
15367 @item prefetch-latency
15368 Estimate on average number of instructions that are executed before
15369 prefetch finishes. The distance prefetched ahead is proportional
15370 to this constant. Increasing this number may also lead to less
15371 streams being prefetched (see @option{simultaneous-prefetches}).
15373 @item simultaneous-prefetches
15374 Maximum number of prefetches that can run at the same time.
15376 @item l1-cache-line-size
15377 The size of cache line in L1 data cache, in bytes.
15379 @item l1-cache-size
15380 The size of L1 data cache, in kilobytes.
15382 @item l2-cache-size
15383 The size of L2 data cache, in kilobytes.
15385 @item prefetch-dynamic-strides
15386 Whether the loop array prefetch pass should issue software prefetch hints
15387 for strides that are non-constant. In some cases this may be
15388 beneficial, though the fact the stride is non-constant may make it
15389 hard to predict when there is clear benefit to issuing these hints.
15391 Set to 1 if the prefetch hints should be issued for non-constant
15392 strides. Set to 0 if prefetch hints should be issued only for strides that
15393 are known to be constant and below @option{prefetch-minimum-stride}.
15395 @item prefetch-minimum-stride
15396 Minimum constant stride, in bytes, to start using prefetch hints for. If
15397 the stride is less than this threshold, prefetch hints will not be issued.
15399 This setting is useful for processors that have hardware prefetchers, in
15400 which case there may be conflicts between the hardware prefetchers and
15401 the software prefetchers. If the hardware prefetchers have a maximum
15402 stride they can handle, it should be used here to improve the use of
15403 software prefetchers.
15405 A value of -1 means we don't have a threshold and therefore
15406 prefetch hints can be issued for any constant stride.
15408 This setting is only useful for strides that are known and constant.
15410 @item destructive-interference-size
15411 @item constructive-interference-size
15412 The values for the C++17 variables
15413 @code{std::hardware_destructive_interference_size} and
15414 @code{std::hardware_constructive_interference_size}. The destructive
15415 interference size is the minimum recommended offset between two
15416 independent concurrently-accessed objects; the constructive
15417 interference size is the maximum recommended size of contiguous memory
15418 accessed together. Typically both will be the size of an L1 cache
15419 line for the target, in bytes. For a generic target covering a range of L1
15420 cache line sizes, typically the constructive interference size will be
15421 the small end of the range and the destructive size will be the large
15424 The destructive interference size is intended to be used for layout,
15425 and thus has ABI impact. The default value is not expected to be
15426 stable, and on some targets varies with @option{-mtune}, so use of
15427 this variable in a context where ABI stability is important, such as
15428 the public interface of a library, is strongly discouraged; if it is
15429 used in that context, users can stabilize the value using this
15432 The constructive interference size is less sensitive, as it is
15433 typically only used in a @samp{static_assert} to make sure that a type
15434 fits within a cache line.
15436 See also @option{-Winterference-size}.
15438 @item loop-interchange-max-num-stmts
15439 The maximum number of stmts in a loop to be interchanged.
15441 @item loop-interchange-stride-ratio
15442 The minimum ratio between stride of two loops for interchange to be profitable.
15444 @item min-insn-to-prefetch-ratio
15445 The minimum ratio between the number of instructions and the
15446 number of prefetches to enable prefetching in a loop.
15448 @item prefetch-min-insn-to-mem-ratio
15449 The minimum ratio between the number of instructions and the
15450 number of memory references to enable prefetching in a loop.
15452 @item use-canonical-types
15453 Whether the compiler should use the ``canonical'' type system.
15454 Should always be 1, which uses a more efficient internal
15455 mechanism for comparing types in C++ and Objective-C++. However, if
15456 bugs in the canonical type system are causing compilation failures,
15457 set this value to 0 to disable canonical types.
15459 @item switch-conversion-max-branch-ratio
15460 Switch initialization conversion refuses to create arrays that are
15461 bigger than @option{switch-conversion-max-branch-ratio} times the number of
15462 branches in the switch.
15464 @item max-partial-antic-length
15465 Maximum length of the partial antic set computed during the tree
15466 partial redundancy elimination optimization (@option{-ftree-pre}) when
15467 optimizing at @option{-O3} and above. For some sorts of source code
15468 the enhanced partial redundancy elimination optimization can run away,
15469 consuming all of the memory available on the host machine. This
15470 parameter sets a limit on the length of the sets that are computed,
15471 which prevents the runaway behavior. Setting a value of 0 for
15472 this parameter allows an unlimited set length.
15474 @item rpo-vn-max-loop-depth
15475 Maximum loop depth that is value-numbered optimistically.
15476 When the limit hits the innermost
15477 @var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15478 loop nest are value-numbered optimistically and the remaining ones not.
15480 @item sccvn-max-alias-queries-per-access
15481 Maximum number of alias-oracle queries we perform when looking for
15482 redundancies for loads and stores. If this limit is hit the search
15483 is aborted and the load or store is not considered redundant. The
15484 number of queries is algorithmically limited to the number of
15485 stores on all paths from the load to the function entry.
15487 @item ira-max-loops-num
15488 IRA uses regional register allocation by default. If a function
15489 contains more loops than the number given by this parameter, only at most
15490 the given number of the most frequently-executed loops form regions
15491 for regional register allocation.
15493 @item ira-max-conflict-table-size
15494 Although IRA uses a sophisticated algorithm to compress the conflict
15495 table, the table can still require excessive amounts of memory for
15496 huge functions. If the conflict table for a function could be more
15497 than the size in MB given by this parameter, the register allocator
15498 instead uses a faster, simpler, and lower-quality
15499 algorithm that does not require building a pseudo-register conflict table.
15501 @item ira-loop-reserved-regs
15502 IRA can be used to evaluate more accurate register pressure in loops
15503 for decisions to move loop invariants (see @option{-O3}). The number
15504 of available registers reserved for some other purposes is given
15505 by this parameter. Default of the parameter
15506 is the best found from numerous experiments.
15508 @item ira-consider-dup-in-all-alts
15509 Make IRA to consider matching constraint (duplicated operand number)
15510 heavily in all available alternatives for preferred register class.
15511 If it is set as zero, it means IRA only respects the matching
15512 constraint when it's in the only available alternative with an
15513 appropriate register class. Otherwise, it means IRA will check all
15514 available alternatives for preferred register class even if it has
15515 found some choice with an appropriate register class and respect the
15516 found qualified matching constraint.
15518 @item ira-simple-lra-insn-threshold
15519 Approximate function insn number in 1K units triggering simple local RA.
15521 @item lra-inheritance-ebb-probability-cutoff
15522 LRA tries to reuse values reloaded in registers in subsequent insns.
15523 This optimization is called inheritance. EBB is used as a region to
15524 do this optimization. The parameter defines a minimal fall-through
15525 edge probability in percentage used to add BB to inheritance EBB in
15526 LRA. The default value was chosen
15527 from numerous runs of SPEC2000 on x86-64.
15529 @item loop-invariant-max-bbs-in-loop
15530 Loop invariant motion can be very expensive, both in compilation time and
15531 in amount of needed compile-time memory, with very large loops. Loops
15532 with more basic blocks than this parameter won't have loop invariant
15533 motion optimization performed on them.
15535 @item loop-max-datarefs-for-datadeps
15536 Building data dependencies is expensive for very large loops. This
15537 parameter limits the number of data references in loops that are
15538 considered for data dependence analysis. These large loops are no
15539 handled by the optimizations using loop data dependencies.
15541 @item max-vartrack-size
15542 Sets a maximum number of hash table slots to use during variable
15543 tracking dataflow analysis of any function. If this limit is exceeded
15544 with variable tracking at assignments enabled, analysis for that
15545 function is retried without it, after removing all debug insns from
15546 the function. If the limit is exceeded even without debug insns, var
15547 tracking analysis is completely disabled for the function. Setting
15548 the parameter to zero makes it unlimited.
15550 @item max-vartrack-expr-depth
15551 Sets a maximum number of recursion levels when attempting to map
15552 variable names or debug temporaries to value expressions. This trades
15553 compilation time for more complete debug information. If this is set too
15554 low, value expressions that are available and could be represented in
15555 debug information may end up not being used; setting this higher may
15556 enable the compiler to find more complex debug expressions, but compile
15557 time and memory use may grow.
15559 @item max-debug-marker-count
15560 Sets a threshold on the number of debug markers (e.g.@: begin stmt
15561 markers) to avoid complexity explosion at inlining or expanding to RTL.
15562 If a function has more such gimple stmts than the set limit, such stmts
15563 will be dropped from the inlined copy of a function, and from its RTL
15566 @item min-nondebug-insn-uid
15567 Use uids starting at this parameter for nondebug insns. The range below
15568 the parameter is reserved exclusively for debug insns created by
15569 @option{-fvar-tracking-assignments}, but debug insns may get
15570 (non-overlapping) uids above it if the reserved range is exhausted.
15572 @item ipa-sra-deref-prob-threshold
15573 IPA-SRA replaces a pointer which is known not be NULL with one or more
15574 new parameters only when the probability (in percent, relative to
15575 function entry) of it being dereferenced is higher than this parameter.
15577 @item ipa-sra-ptr-growth-factor
15578 IPA-SRA replaces a pointer to an aggregate with one or more new
15579 parameters only when their cumulative size is less or equal to
15580 @option{ipa-sra-ptr-growth-factor} times the size of the original
15583 @item ipa-sra-ptrwrap-growth-factor
15584 Additional maximum allowed growth of total size of new parameters
15585 that ipa-sra replaces a pointer to an aggregate with,
15586 if it points to a local variable that the caller only writes to and
15587 passes it as an argument to other functions.
15589 @item ipa-sra-max-replacements
15590 Maximum pieces of an aggregate that IPA-SRA tracks. As a
15591 consequence, it is also the maximum number of replacements of a formal
15594 @item sra-max-scalarization-size-Ospeed
15595 @itemx sra-max-scalarization-size-Osize
15596 The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15597 replace scalar parts of aggregates with uses of independent scalar
15598 variables. These parameters control the maximum size, in storage units,
15599 of aggregate which is considered for replacement when compiling for
15601 (@option{sra-max-scalarization-size-Ospeed}) or size
15602 (@option{sra-max-scalarization-size-Osize}) respectively.
15604 @item sra-max-propagations
15605 The maximum number of artificial accesses that Scalar Replacement of
15606 Aggregates (SRA) will track, per one local variable, in order to
15607 facilitate copy propagation.
15609 @item tm-max-aggregate-size
15610 When making copies of thread-local variables in a transaction, this
15611 parameter specifies the size in bytes after which variables are
15612 saved with the logging functions as opposed to save/restore code
15613 sequence pairs. This option only applies when using
15616 @item graphite-max-nb-scop-params
15617 To avoid exponential effects in the Graphite loop transforms, the
15618 number of parameters in a Static Control Part (SCoP) is bounded.
15619 A value of zero can be used to lift
15620 the bound. A variable whose value is unknown at compilation time and
15621 defined outside a SCoP is a parameter of the SCoP.
15623 @item loop-block-tile-size
15624 Loop blocking or strip mining transforms, enabled with
15625 @option{-floop-block} or @option{-floop-strip-mine}, strip mine each
15626 loop in the loop nest by a given number of iterations. The strip
15627 length can be changed using the @option{loop-block-tile-size}
15630 @item ipa-jump-function-lookups
15631 Specifies number of statements visited during jump function offset discovery.
15633 @item ipa-cp-value-list-size
15634 IPA-CP attempts to track all possible values and types passed to a function's
15635 parameter in order to propagate them and perform devirtualization.
15636 @option{ipa-cp-value-list-size} is the maximum number of values and types it
15637 stores per one formal parameter of a function.
15639 @item ipa-cp-eval-threshold
15640 IPA-CP calculates its own score of cloning profitability heuristics
15641 and performs those cloning opportunities with scores that exceed
15642 @option{ipa-cp-eval-threshold}.
15644 @item ipa-cp-max-recursive-depth
15645 Maximum depth of recursive cloning for self-recursive function.
15647 @item ipa-cp-min-recursive-probability
15648 Recursive cloning only when the probability of call being executed exceeds
15651 @item ipa-cp-profile-count-base
15652 When using @option{-fprofile-use} option, IPA-CP will consider the measured
15653 execution count of a call graph edge at this percentage position in their
15654 histogram as the basis for its heuristics calculation.
15656 @item ipa-cp-recursive-freq-factor
15657 The number of times interprocedural copy propagation expects recursive
15658 functions to call themselves.
15660 @item ipa-cp-recursion-penalty
15661 Percentage penalty the recursive functions will receive when they
15662 are evaluated for cloning.
15664 @item ipa-cp-single-call-penalty
15665 Percentage penalty functions containing a single call to another
15666 function will receive when they are evaluated for cloning.
15668 @item ipa-max-agg-items
15669 IPA-CP is also capable to propagate a number of scalar values passed
15670 in an aggregate. @option{ipa-max-agg-items} controls the maximum
15671 number of such values per one parameter.
15673 @item ipa-cp-loop-hint-bonus
15674 When IPA-CP determines that a cloning candidate would make the number
15675 of iterations of a loop known, it adds a bonus of
15676 @option{ipa-cp-loop-hint-bonus} to the profitability score of
15679 @item ipa-max-loop-predicates
15680 The maximum number of different predicates IPA will use to describe when
15681 loops in a function have known properties.
15683 @item ipa-max-aa-steps
15684 During its analysis of function bodies, IPA-CP employs alias analysis
15685 in order to track values pointed to by function parameters. In order
15686 not spend too much time analyzing huge functions, it gives up and
15687 consider all memory clobbered after examining
15688 @option{ipa-max-aa-steps} statements modifying memory.
15690 @item ipa-max-switch-predicate-bounds
15691 Maximal number of boundary endpoints of case ranges of switch statement.
15692 For switch exceeding this limit, IPA-CP will not construct cloning cost
15693 predicate, which is used to estimate cloning benefit, for default case
15694 of the switch statement.
15696 @item ipa-max-param-expr-ops
15697 IPA-CP will analyze conditional statement that references some function
15698 parameter to estimate benefit for cloning upon certain constant value.
15699 But if number of operations in a parameter expression exceeds
15700 @option{ipa-max-param-expr-ops}, the expression is treated as complicated
15701 one, and is not handled by IPA analysis.
15703 @item lto-partitions
15704 Specify desired number of partitions produced during WHOPR compilation.
15705 The number of partitions should exceed the number of CPUs used for compilation.
15707 @item lto-min-partition
15708 Size of minimal partition for WHOPR (in estimated instructions).
15709 This prevents expenses of splitting very small programs into too many
15712 @item lto-max-partition
15713 Size of max partition for WHOPR (in estimated instructions).
15714 to provide an upper bound for individual size of partition.
15715 Meant to be used only with balanced partitioning.
15717 @item lto-max-streaming-parallelism
15718 Maximal number of parallel processes used for LTO streaming.
15720 @item cxx-max-namespaces-for-diagnostic-help
15721 The maximum number of namespaces to consult for suggestions when C++
15722 name lookup fails for an identifier.
15724 @item sink-frequency-threshold
15725 The maximum relative execution frequency (in percents) of the target block
15726 relative to a statement's original block to allow statement sinking of a
15727 statement. Larger numbers result in more aggressive statement sinking.
15728 A small positive adjustment is applied for
15729 statements with memory operands as those are even more profitable so sink.
15731 @item max-stores-to-sink
15732 The maximum number of conditional store pairs that can be sunk. Set to 0
15733 if either vectorization (@option{-ftree-vectorize}) or if-conversion
15734 (@option{-ftree-loop-if-convert}) is disabled.
15736 @item case-values-threshold
15737 The smallest number of different values for which it is best to use a
15738 jump-table instead of a tree of conditional branches. If the value is
15739 0, use the default for the machine.
15741 @item jump-table-max-growth-ratio-for-size
15742 The maximum code size growth ratio when expanding
15743 into a jump table (in percent). The parameter is used when
15744 optimizing for size.
15746 @item jump-table-max-growth-ratio-for-speed
15747 The maximum code size growth ratio when expanding
15748 into a jump table (in percent). The parameter is used when
15749 optimizing for speed.
15751 @item tree-reassoc-width
15752 Set the maximum number of instructions executed in parallel in
15753 reassociated tree. This parameter overrides target dependent
15754 heuristics used by default if has non zero value.
15756 @item sched-pressure-algorithm
15757 Choose between the two available implementations of
15758 @option{-fsched-pressure}. Algorithm 1 is the original implementation
15759 and is the more likely to prevent instructions from being reordered.
15760 Algorithm 2 was designed to be a compromise between the relatively
15761 conservative approach taken by algorithm 1 and the rather aggressive
15762 approach taken by the default scheduler. It relies more heavily on
15763 having a regular register file and accurate register pressure classes.
15764 See @file{haifa-sched.cc} in the GCC sources for more details.
15766 The default choice depends on the target.
15768 @item max-slsr-cand-scan
15769 Set the maximum number of existing candidates that are considered when
15770 seeking a basis for a new straight-line strength reduction candidate.
15773 Enable buffer overflow detection for global objects. This kind
15774 of protection is enabled by default if you are using
15775 @option{-fsanitize=address} option.
15776 To disable global objects protection use @option{--param asan-globals=0}.
15779 Enable buffer overflow detection for stack objects. This kind of
15780 protection is enabled by default when using @option{-fsanitize=address}.
15781 To disable stack protection use @option{--param asan-stack=0} option.
15783 @item asan-instrument-reads
15784 Enable buffer overflow detection for memory reads. This kind of
15785 protection is enabled by default when using @option{-fsanitize=address}.
15786 To disable memory reads protection use
15787 @option{--param asan-instrument-reads=0}.
15789 @item asan-instrument-writes
15790 Enable buffer overflow detection for memory writes. This kind of
15791 protection is enabled by default when using @option{-fsanitize=address}.
15792 To disable memory writes protection use
15793 @option{--param asan-instrument-writes=0} option.
15795 @item asan-memintrin
15796 Enable detection for built-in functions. This kind of protection
15797 is enabled by default when using @option{-fsanitize=address}.
15798 To disable built-in functions protection use
15799 @option{--param asan-memintrin=0}.
15801 @item asan-use-after-return
15802 Enable detection of use-after-return. This kind of protection
15803 is enabled by default when using the @option{-fsanitize=address} option.
15804 To disable it use @option{--param asan-use-after-return=0}.
15806 Note: By default the check is disabled at run time. To enable it,
15807 add @code{detect_stack_use_after_return=1} to the environment variable
15808 @env{ASAN_OPTIONS}.
15810 @item asan-instrumentation-with-call-threshold
15811 If number of memory accesses in function being instrumented
15812 is greater or equal to this number, use callbacks instead of inline checks.
15813 E.g. to disable inline code use
15814 @option{--param asan-instrumentation-with-call-threshold=0}.
15816 @item asan-kernel-mem-intrinsic-prefix
15817 Prefix calls to memcpy, memset and memmove with __asan_ or __hwasan_
15818 for -fsanitize=kernel-address or -fsanitize=kernel-hwaddress.
15820 @item hwasan-instrument-stack
15821 Enable hwasan instrumentation of statically sized stack-allocated variables.
15822 This kind of instrumentation is enabled by default when using
15823 @option{-fsanitize=hwaddress} and disabled by default when using
15824 @option{-fsanitize=kernel-hwaddress}.
15825 To disable stack instrumentation use
15826 @option{--param hwasan-instrument-stack=0}, and to enable it use
15827 @option{--param hwasan-instrument-stack=1}.
15829 @item hwasan-random-frame-tag
15830 When using stack instrumentation, decide tags for stack variables using a
15831 deterministic sequence beginning at a random tag for each frame. With this
15832 parameter unset tags are chosen using the same sequence but beginning from 1.
15833 This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
15834 for @option{-fsanitize=kernel-hwaddress}.
15835 To disable it use @option{--param hwasan-random-frame-tag=0}.
15837 @item hwasan-instrument-allocas
15838 Enable hwasan instrumentation of dynamically sized stack-allocated variables.
15839 This kind of instrumentation is enabled by default when using
15840 @option{-fsanitize=hwaddress} and disabled by default when using
15841 @option{-fsanitize=kernel-hwaddress}.
15842 To disable instrumentation of such variables use
15843 @option{--param hwasan-instrument-allocas=0}, and to enable it use
15844 @option{--param hwasan-instrument-allocas=1}.
15846 @item hwasan-instrument-reads
15847 Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
15848 default for both @option{-fsanitize=hwaddress} and
15849 @option{-fsanitize=kernel-hwaddress}.
15850 To disable checking memory reads use
15851 @option{--param hwasan-instrument-reads=0}.
15853 @item hwasan-instrument-writes
15854 Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
15855 default for both @option{-fsanitize=hwaddress} and
15856 @option{-fsanitize=kernel-hwaddress}.
15857 To disable checking memory writes use
15858 @option{--param hwasan-instrument-writes=0}.
15860 @item hwasan-instrument-mem-intrinsics
15861 Enable hwasan instrumentation of builtin functions. Instrumentation of these
15862 builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
15863 and @option{-fsanitize=kernel-hwaddress}.
15864 To disable instrumentation of builtin functions use
15865 @option{--param hwasan-instrument-mem-intrinsics=0}.
15867 @item use-after-scope-direct-emission-threshold
15868 If the size of a local variable in bytes is smaller or equal to this
15869 number, directly poison (or unpoison) shadow memory instead of using
15870 run-time callbacks.
15872 @item tsan-distinguish-volatile
15873 Emit special instrumentation for accesses to volatiles.
15875 @item tsan-instrument-func-entry-exit
15876 Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
15878 @item max-fsm-thread-path-insns
15879 Maximum number of instructions to copy when duplicating blocks on a
15880 finite state automaton jump thread path.
15882 @item threader-debug
15883 threader-debug=[none|all] Enables verbose dumping of the threader solver.
15885 @item parloops-chunk-size
15886 Chunk size of omp schedule for loops parallelized by parloops.
15888 @item parloops-schedule
15889 Schedule type of omp schedule for loops parallelized by parloops (static,
15890 dynamic, guided, auto, runtime).
15892 @item parloops-min-per-thread
15893 The minimum number of iterations per thread of an innermost parallelized
15894 loop for which the parallelized variant is preferred over the single threaded
15895 one. Note that for a parallelized loop nest the
15896 minimum number of iterations of the outermost loop per thread is two.
15898 @item max-ssa-name-query-depth
15899 Maximum depth of recursion when querying properties of SSA names in things
15900 like fold routines. One level of recursion corresponds to following a
15903 @item max-speculative-devirt-maydefs
15904 The maximum number of may-defs we analyze when looking for a must-def
15905 specifying the dynamic type of an object that invokes a virtual call
15906 we may be able to devirtualize speculatively.
15908 @item evrp-sparse-threshold
15909 Maximum number of basic blocks before EVRP uses a sparse cache.
15912 Specifies the type of debug output to be issued for ranges.
15914 @item evrp-switch-limit
15915 Specifies the maximum number of switch cases before EVRP ignores a switch.
15917 @item unroll-jam-min-percent
15918 The minimum percentage of memory references that must be optimized
15919 away for the unroll-and-jam transformation to be considered profitable.
15921 @item unroll-jam-max-unroll
15922 The maximum number of times the outer loop should be unrolled by
15923 the unroll-and-jam transformation.
15925 @item max-rtl-if-conversion-unpredictable-cost
15926 Maximum permissible cost for the sequence that would be generated
15927 by the RTL if-conversion pass for a branch that is considered unpredictable.
15929 @item max-variable-expansions-in-unroller
15930 If @option{-fvariable-expansion-in-unroller} is used, the maximum number
15931 of times that an individual variable will be expanded during loop unrolling.
15933 @item partial-inlining-entry-probability
15934 Maximum probability of the entry BB of split region
15935 (in percent relative to entry BB of the function)
15936 to make partial inlining happen.
15938 @item max-tracked-strlens
15939 Maximum number of strings for which strlen optimization pass will
15940 track string lengths.
15942 @item gcse-after-reload-partial-fraction
15943 The threshold ratio for performing partial redundancy
15944 elimination after reload.
15946 @item gcse-after-reload-critical-fraction
15947 The threshold ratio of critical edges execution count that
15948 permit performing redundancy elimination after reload.
15950 @item max-loop-header-insns
15951 The maximum number of insns in loop header duplicated
15952 by the copy loop headers pass.
15954 @item vect-epilogues-nomask
15955 Enable loop epilogue vectorization using smaller vector size.
15957 @item vect-partial-vector-usage
15958 Controls when the loop vectorizer considers using partial vector loads
15959 and stores as an alternative to falling back to scalar code. 0 stops
15960 the vectorizer from ever using partial vector loads and stores. 1 allows
15961 partial vector loads and stores if vectorization removes the need for the
15962 code to iterate. 2 allows partial vector loads and stores in all loops.
15963 The parameter only has an effect on targets that support partial
15964 vector loads and stores.
15966 @item vect-inner-loop-cost-factor
15967 The maximum factor which the loop vectorizer applies to the cost of statements
15968 in an inner loop relative to the loop being vectorized. The factor applied
15969 is the maximum of the estimated number of iterations of the inner loop and
15970 this parameter. The default value of this parameter is 50.
15972 @item vect-induction-float
15973 Enable loop vectorization of floating point inductions.
15975 @item avoid-fma-max-bits
15976 Maximum number of bits for which we avoid creating FMAs.
15978 @item sms-loop-average-count-threshold
15979 A threshold on the average loop count considered by the swing modulo scheduler.
15981 @item sms-dfa-history
15982 The number of cycles the swing modulo scheduler considers when checking
15983 conflicts using DFA.
15985 @item graphite-allow-codegen-errors
15986 Whether codegen errors should be ICEs when @option{-fchecking}.
15988 @item sms-max-ii-factor
15989 A factor for tuning the upper bound that swing modulo scheduler
15990 uses for scheduling a loop.
15992 @item lra-max-considered-reload-pseudos
15993 The max number of reload pseudos which are considered during
15994 spilling a non-reload pseudo.
15996 @item max-pow-sqrt-depth
15997 Maximum depth of sqrt chains to use when synthesizing exponentiation
15998 by a real constant.
16000 @item max-dse-active-local-stores
16001 Maximum number of active local stores in RTL dead store elimination.
16003 @item asan-instrument-allocas
16004 Enable asan allocas/VLAs protection.
16006 @item max-iterations-computation-cost
16007 Bound on the cost of an expression to compute the number of iterations.
16009 @item max-isl-operations
16010 Maximum number of isl operations, 0 means unlimited.
16012 @item graphite-max-arrays-per-scop
16013 Maximum number of arrays per scop.
16015 @item max-vartrack-reverse-op-size
16016 Max. size of loc list for which reverse ops should be added.
16018 @item fsm-scale-path-stmts
16019 Scale factor to apply to the number of statements in a threading path
16020 crossing a loop backedge when comparing to
16021 @option{--param=max-jump-thread-duplication-stmts}.
16023 @item uninit-control-dep-attempts
16024 Maximum number of nested calls to search for control dependencies
16025 during uninitialized variable analysis.
16027 @item sched-autopref-queue-depth
16028 Hardware autoprefetcher scheduler model control flag.
16029 Number of lookahead cycles the model looks into; at '
16030 ' only enable instruction sorting heuristic.
16032 @item loop-versioning-max-inner-insns
16033 The maximum number of instructions that an inner loop can have
16034 before the loop versioning pass considers it too big to copy.
16036 @item loop-versioning-max-outer-insns
16037 The maximum number of instructions that an outer loop can have
16038 before the loop versioning pass considers it too big to copy,
16039 discounting any instructions in inner loops that directly benefit
16042 @item ssa-name-def-chain-limit
16043 The maximum number of SSA_NAME assignments to follow in determining
16044 a property of a variable such as its value. This limits the number
16045 of iterations or recursive calls GCC performs when optimizing certain
16046 statements or when determining their validity prior to issuing
16049 @item store-merging-max-size
16050 Maximum size of a single store merging region in bytes.
16052 @item hash-table-verification-limit
16053 The number of elements for which hash table verification is done
16054 for each searched element.
16056 @item max-find-base-term-values
16057 Maximum number of VALUEs handled during a single find_base_term call.
16059 @item analyzer-max-enodes-per-program-point
16060 The maximum number of exploded nodes per program point within
16061 the analyzer, before terminating analysis of that point.
16063 @item analyzer-max-constraints
16064 The maximum number of constraints per state.
16066 @item analyzer-min-snodes-for-call-summary
16067 The minimum number of supernodes within a function for the
16068 analyzer to consider summarizing its effects at call sites.
16070 @item analyzer-max-enodes-for-full-dump
16071 The maximum depth of exploded nodes that should appear in a dot dump
16072 before switching to a less verbose format.
16074 @item analyzer-max-recursion-depth
16075 The maximum number of times a callsite can appear in a call stack
16076 within the analyzer, before terminating analysis of a call that would
16079 @item analyzer-max-svalue-depth
16080 The maximum depth of a symbolic value, before approximating
16081 the value as unknown.
16083 @item analyzer-max-infeasible-edges
16084 The maximum number of infeasible edges to reject before declaring
16085 a diagnostic as infeasible.
16087 @item gimple-fe-computed-hot-bb-threshold
16088 The number of executions of a basic block which is considered hot.
16089 The parameter is used only in GIMPLE FE.
16091 @item analyzer-bb-explosion-factor
16092 The maximum number of 'after supernode' exploded nodes within the analyzer
16093 per supernode, before terminating analysis.
16095 @item ranger-logical-depth
16096 Maximum depth of logical expression evaluation ranger will look through
16097 when evaluating outgoing edge ranges.
16099 @item relation-block-limit
16100 Maximum number of relations the oracle will register in a basic block.
16103 Minimum page size for warning purposes.
16105 @item openacc-kernels
16106 Specify mode of OpenACC `kernels' constructs handling.
16107 With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16108 constructs are decomposed into parts, a sequence of compute
16109 constructs, each then handled individually.
16110 This is work in progress.
16111 With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16112 constructs are handled by the @samp{parloops} pass, en bloc.
16113 This is the current default.
16115 @item openacc-privatization
16116 Specify mode of OpenACC privatization diagnostics for
16117 @option{-fopt-info-omp-note} and applicable
16118 @option{-fdump-tree-*-details}.
16119 With @option{--param=openacc-privatization=quiet}, don't diagnose.
16120 This is the current default.
16121 With @option{--param=openacc-privatization=noisy}, do diagnose.
16125 The following choices of @var{name} are available on AArch64 targets:
16128 @item aarch64-sve-compare-costs
16129 When vectorizing for SVE, consider using ``unpacked'' vectors for
16130 smaller elements and use the cost model to pick the cheapest approach.
16131 Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16133 Using unpacked vectors includes storing smaller elements in larger
16134 containers and accessing elements with extending loads and truncating
16137 @item aarch64-float-recp-precision
16138 The number of Newton iterations for calculating the reciprocal for float type.
16139 The precision of division is proportional to this param when division
16140 approximation is enabled. The default value is 1.
16142 @item aarch64-double-recp-precision
16143 The number of Newton iterations for calculating the reciprocal for double type.
16144 The precision of division is propotional to this param when division
16145 approximation is enabled. The default value is 2.
16147 @item aarch64-autovec-preference
16148 Force an ISA selection strategy for auto-vectorization. Accepts values from
16152 Use the default heuristics.
16154 Use only Advanced SIMD for auto-vectorization.
16156 Use only SVE for auto-vectorization.
16158 Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16161 Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16163 The default value is 0.
16165 @item aarch64-loop-vect-issue-rate-niters
16166 The tuning for some AArch64 CPUs tries to take both latencies and issue
16167 rates into account when deciding whether a loop should be vectorized
16168 using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16169 If this parameter is set to @var{n}, GCC will not use this heuristic
16170 for loops that are known to execute in fewer than @var{n} Advanced
16173 @item aarch64-vect-unroll-limit
16174 The vectorizer will use available tuning information to determine whether it
16175 would be beneficial to unroll the main vectorized loop and by how much. This
16176 parameter set's the upper bound of how much the vectorizer will unroll the main
16177 loop. The default value is four.
16181 The following choices of @var{name} are available on i386 and x86_64 targets:
16184 @item x86-stlf-window-ninsns
16185 Instructions number above which STFL stall penalty can be compensated.
16191 @node Instrumentation Options
16192 @section Program Instrumentation Options
16193 @cindex instrumentation options
16194 @cindex program instrumentation options
16195 @cindex run-time error checking options
16196 @cindex profiling options
16197 @cindex options, program instrumentation
16198 @cindex options, run-time error checking
16199 @cindex options, profiling
16201 GCC supports a number of command-line options that control adding
16202 run-time instrumentation to the code it normally generates.
16203 For example, one purpose of instrumentation is collect profiling
16204 statistics for use in finding program hot spots, code coverage
16205 analysis, or profile-guided optimizations.
16206 Another class of program instrumentation is adding run-time checking
16207 to detect programming errors like invalid pointer
16208 dereferences or out-of-bounds array accesses, as well as deliberately
16209 hostile attacks such as stack smashing or C++ vtable hijacking.
16210 There is also a general hook which can be used to implement other
16211 forms of tracing or function-level instrumentation for debug or
16212 program analysis purposes.
16215 @cindex @command{prof}
16216 @cindex @command{gprof}
16221 Generate extra code to write profile information suitable for the
16222 analysis program @command{prof} (for @option{-p}) or @command{gprof}
16223 (for @option{-pg}). You must use this option when compiling
16224 the source files you want data about, and you must also use it when
16227 You can use the function attribute @code{no_instrument_function} to
16228 suppress profiling of individual functions when compiling with these options.
16229 @xref{Common Function Attributes}.
16231 @item -fprofile-arcs
16232 @opindex fprofile-arcs
16233 Add code so that program flow @dfn{arcs} are instrumented. During
16234 execution the program records how many times each branch and call is
16235 executed and how many times it is taken or returns. On targets that support
16236 constructors with priority support, profiling properly handles constructors,
16237 destructors and C++ constructors (and destructors) of classes which are used
16238 as a type of a global variable.
16241 program exits it saves this data to a file called
16242 @file{@var{auxname}.gcda} for each source file. The data may be used for
16243 profile-directed optimizations (@option{-fbranch-probabilities}), or for
16244 test coverage analysis (@option{-ftest-coverage}). Each object file's
16245 @var{auxname} is generated from the name of the output file, if
16246 explicitly specified and it is not the final executable, otherwise it is
16247 the basename of the source file. In both cases any suffix is removed
16248 (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16249 @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16251 Note that if a command line directly links source files, the corresponding
16252 @var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16253 E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16254 @file{binary-b.gcda} files.
16256 @xref{Cross-profiling}.
16258 @cindex @command{gcov}
16262 This option is used to compile and link code instrumented for coverage
16263 analysis. The option is a synonym for @option{-fprofile-arcs}
16264 @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16265 linking). See the documentation for those options for more details.
16270 Compile the source files with @option{-fprofile-arcs} plus optimization
16271 and code generation options. For test coverage analysis, use the
16272 additional @option{-ftest-coverage} option. You do not need to profile
16273 every source file in a program.
16276 Compile the source files additionally with @option{-fprofile-abs-path}
16277 to create absolute path names in the @file{.gcno} files. This allows
16278 @command{gcov} to find the correct sources in projects where compilations
16279 occur with different working directories.
16282 Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16283 (the latter implies the former).
16286 Run the program on a representative workload to generate the arc profile
16287 information. This may be repeated any number of times. You can run
16288 concurrent instances of your program, and provided that the file system
16289 supports locking, the data files will be correctly updated. Unless
16290 a strict ISO C dialect option is in effect, @code{fork} calls are
16291 detected and correctly handled without double counting.
16293 Moreover, an object file can be recompiled multiple times
16294 and the corresponding @file{.gcda} file merges as long as
16295 the source file and the compiler options are unchanged.
16298 For profile-directed optimizations, compile the source files again with
16299 the same optimization and code generation options plus
16300 @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16301 Control Optimization}).
16304 For test coverage analysis, use @command{gcov} to produce human readable
16305 information from the @file{.gcno} and @file{.gcda} files. Refer to the
16306 @command{gcov} documentation for further information.
16310 With @option{-fprofile-arcs}, for each function of your program GCC
16311 creates a program flow graph, then finds a spanning tree for the graph.
16312 Only arcs that are not on the spanning tree have to be instrumented: the
16313 compiler adds code to count the number of times that these arcs are
16314 executed. When an arc is the only exit or only entrance to a block, the
16315 instrumentation code can be added to the block; otherwise, a new basic
16316 block must be created to hold the instrumentation code.
16319 @item -ftest-coverage
16320 @opindex ftest-coverage
16321 Produce a notes file that the @command{gcov} code-coverage utility
16322 (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16323 show program coverage. Each source file's note file is called
16324 @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16325 above for a description of @var{auxname} and instructions on how to
16326 generate test coverage data. Coverage data matches the source files
16327 more closely if you do not optimize.
16329 @item -fprofile-abs-path
16330 @opindex fprofile-abs-path
16331 Automatically convert relative source file names to absolute path names
16332 in the @file{.gcno} files. This allows @command{gcov} to find the correct
16333 sources in projects where compilations occur with different working
16336 @item -fprofile-dir=@var{path}
16337 @opindex fprofile-dir
16339 Set the directory to search for the profile data files in to @var{path}.
16340 This option affects only the profile data generated by
16341 @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16342 and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16343 and its related options. Both absolute and relative paths can be used.
16344 By default, GCC uses the current directory as @var{path}, thus the
16345 profile data file appears in the same directory as the object file.
16346 In order to prevent the file name clashing, if the object file name is
16347 not an absolute path, we mangle the absolute path of the
16348 @file{@var{sourcename}.gcda} file and use it as the file name of a
16349 @file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16350 See similar option @option{-fprofile-note}.
16352 When an executable is run in a massive parallel environment, it is recommended
16353 to save profile to different folders. That can be done with variables
16354 in @var{path} that are exported during run-time:
16362 value of environment variable @var{VAR}
16366 @item -fprofile-generate
16367 @itemx -fprofile-generate=@var{path}
16368 @opindex fprofile-generate
16370 Enable options usually used for instrumenting application to produce
16371 profile useful for later recompilation with profile feedback based
16372 optimization. You must use @option{-fprofile-generate} both when
16373 compiling and when linking your program.
16375 The following options are enabled:
16376 @option{-fprofile-arcs}, @option{-fprofile-values},
16377 @option{-finline-functions}, and @option{-fipa-bit-cp}.
16379 If @var{path} is specified, GCC looks at the @var{path} to find
16380 the profile feedback data files. See @option{-fprofile-dir}.
16382 To optimize the program based on the collected profile information, use
16383 @option{-fprofile-use}. @xref{Optimize Options}, for more information.
16385 @item -fprofile-info-section
16386 @itemx -fprofile-info-section=@var{name}
16387 @opindex fprofile-info-section
16389 Register the profile information in the specified section instead of using a
16390 constructor/destructor. The section name is @var{name} if it is specified,
16391 otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16392 profile information generated by @option{-fprofile-arcs} is placed in the
16393 specified section for each translation unit. This option disables the profile
16394 information registration through a constructor and it disables the profile
16395 information processing through a destructor. This option is not intended to be
16396 used in hosted environments such as GNU/Linux. It targets freestanding
16397 environments (for example embedded systems) with limited resources which do not
16398 support constructors/destructors or the C library file I/O.
16400 The linker could collect the input sections in a continuous memory block and
16401 define start and end symbols. A GNU linker script example which defines a
16402 linker output section follows:
16407 PROVIDE (__gcov_info_start = .);
16408 KEEP (*(.gcov_info))
16409 PROVIDE (__gcov_info_end = .);
16413 The program could dump the profiling information registered in this linker set
16414 for example like this:
16419 #include <stdlib.h>
16421 extern const struct gcov_info *const __gcov_info_start[];
16422 extern const struct gcov_info *const __gcov_info_end[];
16425 dump (const void *d, unsigned n, void *arg)
16427 const unsigned char *c = d;
16429 for (unsigned i = 0; i < n; ++i)
16430 printf ("%02x", c[i]);
16434 filename (const char *f, void *arg)
16436 __gcov_filename_to_gcfn (f, dump, arg );
16440 allocate (unsigned length, void *arg)
16442 return malloc (length);
16446 dump_gcov_info (void)
16448 const struct gcov_info *const *info = __gcov_info_start;
16449 const struct gcov_info *const *end = __gcov_info_end;
16451 /* Obfuscate variable to prevent compiler optimizations. */
16452 __asm__ ("" : "+r" (info));
16454 while (info != end)
16457 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16471 The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16472 deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16473 @code{__gcov_info_to_gcda} functions and merge the profile information into
16474 @file{.gcda} files on the host filesystem.
16476 @item -fprofile-note=@var{path}
16477 @opindex fprofile-note
16479 If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16480 location. If you combine the option with multiple source files,
16481 the @file{.gcno} file will be overwritten.
16483 @item -fprofile-prefix-path=@var{path}
16484 @opindex fprofile-prefix-path
16486 This option can be used in combination with
16487 @option{profile-generate=}@var{profile_dir} and
16488 @option{profile-use=}@var{profile_dir} to inform GCC where is the base
16489 directory of built source tree. By default @var{profile_dir} will contain
16490 files with mangled absolute paths of all object files in the built project.
16491 This is not desirable when directory used to build the instrumented binary
16492 differs from the directory used to build the binary optimized with profile
16493 feedback because the profile data will not be found during the optimized build.
16494 In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16495 pointing to the base directory of the build can be used to strip the irrelevant
16496 part of the path and keep all file names relative to the main build directory.
16498 @item -fprofile-prefix-map=@var{old}=@var{new}
16499 @opindex fprofile-prefix-map
16500 When compiling files residing in directory @file{@var{old}}, record
16501 profiling information (with @option{--coverage})
16502 describing them as if the files resided in
16503 directory @file{@var{new}} instead.
16504 See also @option{-ffile-prefix-map}.
16506 @item -fprofile-update=@var{method}
16507 @opindex fprofile-update
16509 Alter the update method for an application instrumented for profile
16510 feedback based optimization. The @var{method} argument should be one of
16511 @samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16512 The first one is useful for single-threaded applications,
16513 while the second one prevents profile corruption by emitting thread-safe code.
16515 @strong{Warning:} When an application does not properly join all threads
16516 (or creates an detached thread), a profile file can be still corrupted.
16518 Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16519 when supported by a target, or to @samp{single} otherwise. The GCC driver
16520 automatically selects @samp{prefer-atomic} when @option{-pthread}
16521 is present in the command line.
16523 @item -fprofile-filter-files=@var{regex}
16524 @opindex fprofile-filter-files
16526 Instrument only functions from files whose name matches
16527 any of the regular expressions (separated by semi-colons).
16529 For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16530 only @file{main.c} and all C files starting with 'module'.
16532 @item -fprofile-exclude-files=@var{regex}
16533 @opindex fprofile-exclude-files
16535 Instrument only functions from files whose name does not match
16536 any of the regular expressions (separated by semi-colons).
16538 For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16539 of all files that are located in the @file{/usr/} folder.
16541 @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
16542 @opindex fprofile-reproducible
16543 Control level of reproducibility of profile gathered by
16544 @code{-fprofile-generate}. This makes it possible to rebuild program
16545 with same outcome which is useful, for example, for distribution
16548 With @option{-fprofile-reproducible=serial} the profile gathered by
16549 @option{-fprofile-generate} is reproducible provided the trained program
16550 behaves the same at each invocation of the train run, it is not
16551 multi-threaded and profile data streaming is always done in the same
16552 order. Note that profile streaming happens at the end of program run but
16553 also before @code{fork} function is invoked.
16555 Note that it is quite common that execution counts of some part of
16556 programs depends, for example, on length of temporary file names or
16557 memory space randomization (that may affect hash-table collision rate).
16558 Such non-reproducible part of programs may be annotated by
16559 @code{no_instrument_function} function attribute. @command{gcov-dump} with
16560 @option{-l} can be used to dump gathered data and verify that they are
16561 indeed reproducible.
16563 With @option{-fprofile-reproducible=parallel-runs} collected profile
16564 stays reproducible regardless the order of streaming of the data into
16565 gcda files. This setting makes it possible to run multiple instances of
16566 instrumented program in parallel (such as with @code{make -j}). This
16567 reduces quality of gathered data, in particular of indirect call
16570 @item -fsanitize=address
16571 @opindex fsanitize=address
16572 Enable AddressSanitizer, a fast memory error detector.
16573 Memory access instructions are instrumented to detect
16574 out-of-bounds and use-after-free bugs.
16575 The option enables @option{-fsanitize-address-use-after-scope}.
16576 See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
16577 more details. The run-time behavior can be influenced using the
16578 @env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
16579 the available options are shown at startup of the instrumented program. See
16580 @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
16581 for a list of supported options.
16582 The option cannot be combined with @option{-fsanitize=thread} or
16583 @option{-fsanitize=hwaddress}. Note that the only target
16584 @option{-fsanitize=hwaddress} is currently supported on is AArch64.
16586 To get more accurate stack traces, it is possible to use options such as
16587 @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
16588 most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
16589 optimizing sibling and tail recursive calls; this option is implicit for
16590 @option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
16591 disables Identical Code Folding for functions). Since multiple runs of the
16592 program may yield backtraces with different addresses due to ASLR (Address
16593 Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
16594 this can be achieved with @samp{setarch `uname -m` -R ./prog}.
16596 @item -fsanitize=kernel-address
16597 @opindex fsanitize=kernel-address
16598 Enable AddressSanitizer for Linux kernel.
16599 See @uref{https://github.com/google/kernel-sanitizers} for more details.
16601 @item -fsanitize=hwaddress
16602 @opindex fsanitize=hwaddress
16603 Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
16604 ignore the top byte of a pointer to allow the detection of memory errors with
16605 a low memory overhead.
16606 Memory access instructions are instrumented to detect out-of-bounds and
16607 use-after-free bugs.
16608 The option enables @option{-fsanitize-address-use-after-scope}.
16610 @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
16611 for more details. The run-time behavior can be influenced using the
16612 @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
16613 the available options are shown at startup of the instrumented program.
16614 The option cannot be combined with @option{-fsanitize=thread} or
16615 @option{-fsanitize=address}, and is currently only available on AArch64.
16617 @item -fsanitize=kernel-hwaddress
16618 @opindex fsanitize=kernel-hwaddress
16619 Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
16620 Similar to @option{-fsanitize=kernel-address} but using an alternate
16621 instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
16622 instrumentation differences necessary for compiling the Linux kernel.
16623 These differences are to avoid hwasan library initialization calls and to
16624 account for the stack pointer having a different value in its top byte.
16626 @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
16627 Instrumenting the stack and alloca calls are not on by default but are still
16628 possible by specifying the command-line options
16629 @option{--param hwasan-instrument-stack=1} and
16630 @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
16631 tag is not implemented for kernel instrumentation.
16633 @item -fsanitize=pointer-compare
16634 @opindex fsanitize=pointer-compare
16635 Instrument comparison operation (<, <=, >, >=) with pointer operands.
16636 The option must be combined with either @option{-fsanitize=kernel-address} or
16637 @option{-fsanitize=address}
16638 The option cannot be combined with @option{-fsanitize=thread}.
16639 Note: By default the check is disabled at run time. To enable it,
16640 add @code{detect_invalid_pointer_pairs=2} to the environment variable
16641 @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16642 invalid operation only when both pointers are non-null.
16644 @item -fsanitize=pointer-subtract
16645 @opindex fsanitize=pointer-subtract
16646 Instrument subtraction with pointer operands.
16647 The option must be combined with either @option{-fsanitize=kernel-address} or
16648 @option{-fsanitize=address}
16649 The option cannot be combined with @option{-fsanitize=thread}.
16650 Note: By default the check is disabled at run time. To enable it,
16651 add @code{detect_invalid_pointer_pairs=2} to the environment variable
16652 @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16653 invalid operation only when both pointers are non-null.
16655 @item -fsanitize=shadow-call-stack
16656 @opindex fsanitize=shadow-call-stack
16657 Enable ShadowCallStack, a security enhancement mechanism used to protect
16658 programs against return address overwrites (e.g. stack buffer overflows.)
16659 It works by saving a function's return address to a separately allocated
16660 shadow call stack in the function prologue and restoring the return address
16661 from the shadow call stack in the function epilogue. Instrumentation only
16662 occurs in functions that need to save the return address to the stack.
16664 Currently it only supports the aarch64 platform. It is specifically
16665 designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
16666 For the user space programs, runtime support is not currently provided
16667 in libc and libgcc. Users who want to use this feature in user space need
16668 to provide their own support for the runtime. It should be noted that
16669 this may cause the ABI rules to be broken.
16671 On aarch64, the instrumentation makes use of the platform register @code{x18}.
16672 This generally means that any code that may run on the same thread as code
16673 compiled with ShadowCallStack must be compiled with the flag
16674 @option{-ffixed-x18}, otherwise functions compiled without
16675 @option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
16678 Also, because there is no userspace runtime support, code compiled with
16679 ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
16680 to turn off exceptions.
16682 See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
16685 @item -fsanitize=thread
16686 @opindex fsanitize=thread
16687 Enable ThreadSanitizer, a fast data race detector.
16688 Memory access instructions are instrumented to detect
16689 data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
16690 details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
16691 environment variable; see
16692 @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
16694 The option cannot be combined with @option{-fsanitize=address},
16695 @option{-fsanitize=leak}.
16697 Note that sanitized atomic builtins cannot throw exceptions when
16698 operating on invalid memory addresses with non-call exceptions
16699 (@option{-fnon-call-exceptions}).
16701 @item -fsanitize=leak
16702 @opindex fsanitize=leak
16703 Enable LeakSanitizer, a memory leak detector.
16704 This option only matters for linking of executables and
16705 the executable is linked against a library that overrides @code{malloc}
16706 and other allocator functions. See
16707 @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
16708 details. The run-time behavior can be influenced using the
16709 @env{LSAN_OPTIONS} environment variable.
16710 The option cannot be combined with @option{-fsanitize=thread}.
16712 @item -fsanitize=undefined
16713 @opindex fsanitize=undefined
16714 Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
16715 Various computations are instrumented to detect undefined behavior
16716 at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
16717 @env{UBSAN_OPTIONS} environment variable. Current suboptions are:
16721 @item -fsanitize=shift
16722 @opindex fsanitize=shift
16723 This option enables checking that the result of a shift operation is
16724 not undefined. Note that what exactly is considered undefined differs
16725 slightly between C and C++, as well as between ISO C90 and C99, etc.
16726 This option has two suboptions, @option{-fsanitize=shift-base} and
16727 @option{-fsanitize=shift-exponent}.
16729 @item -fsanitize=shift-exponent
16730 @opindex fsanitize=shift-exponent
16731 This option enables checking that the second argument of a shift operation
16732 is not negative and is smaller than the precision of the promoted first
16735 @item -fsanitize=shift-base
16736 @opindex fsanitize=shift-base
16737 If the second argument of a shift operation is within range, check that the
16738 result of a shift operation is not undefined. Note that what exactly is
16739 considered undefined differs slightly between C and C++, as well as between
16740 ISO C90 and C99, etc.
16742 @item -fsanitize=integer-divide-by-zero
16743 @opindex fsanitize=integer-divide-by-zero
16744 Detect integer division by zero.
16746 @item -fsanitize=unreachable
16747 @opindex fsanitize=unreachable
16748 With this option, the compiler turns the @code{__builtin_unreachable}
16749 call into a diagnostics message call instead. When reaching the
16750 @code{__builtin_unreachable} call, the behavior is undefined.
16752 @item -fsanitize=vla-bound
16753 @opindex fsanitize=vla-bound
16754 This option instructs the compiler to check that the size of a variable
16755 length array is positive.
16757 @item -fsanitize=null
16758 @opindex fsanitize=null
16759 This option enables pointer checking. Particularly, the application
16760 built with this option turned on will issue an error message when it
16761 tries to dereference a NULL pointer, or if a reference (possibly an
16762 rvalue reference) is bound to a NULL pointer, or if a method is invoked
16763 on an object pointed by a NULL pointer.
16765 @item -fsanitize=return
16766 @opindex fsanitize=return
16767 This option enables return statement checking. Programs
16768 built with this option turned on will issue an error message
16769 when the end of a non-void function is reached without actually
16770 returning a value. This option works in C++ only.
16772 @item -fsanitize=signed-integer-overflow
16773 @opindex fsanitize=signed-integer-overflow
16774 This option enables signed integer overflow checking. We check that
16775 the result of @code{+}, @code{*}, and both unary and binary @code{-}
16776 does not overflow in the signed arithmetics. This also detects
16777 @code{INT_MIN / -1} signed division. Note, integer promotion
16778 rules must be taken into account. That is, the following is not an
16781 signed char a = SCHAR_MAX;
16785 @item -fsanitize=bounds
16786 @opindex fsanitize=bounds
16787 This option enables instrumentation of array bounds. Various out of bounds
16788 accesses are detected. Flexible array members, flexible array member-like
16789 arrays, and initializers of variables with static storage are not instrumented.
16791 @item -fsanitize=bounds-strict
16792 @opindex fsanitize=bounds-strict
16793 This option enables strict instrumentation of array bounds. Most out of bounds
16794 accesses are detected, including flexible array members and flexible array
16795 member-like arrays. Initializers of variables with static storage are not
16798 @item -fsanitize=alignment
16799 @opindex fsanitize=alignment
16801 This option enables checking of alignment of pointers when they are
16802 dereferenced, or when a reference is bound to insufficiently aligned target,
16803 or when a method or constructor is invoked on insufficiently aligned object.
16805 @item -fsanitize=object-size
16806 @opindex fsanitize=object-size
16807 This option enables instrumentation of memory references using the
16808 @code{__builtin_dynamic_object_size} function. Various out of bounds
16809 pointer accesses are detected.
16811 @item -fsanitize=float-divide-by-zero
16812 @opindex fsanitize=float-divide-by-zero
16813 Detect floating-point division by zero. Unlike other similar options,
16814 @option{-fsanitize=float-divide-by-zero} is not enabled by
16815 @option{-fsanitize=undefined}, since floating-point division by zero can
16816 be a legitimate way of obtaining infinities and NaNs.
16818 @item -fsanitize=float-cast-overflow
16819 @opindex fsanitize=float-cast-overflow
16820 This option enables floating-point type to integer conversion checking.
16821 We check that the result of the conversion does not overflow.
16822 Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
16823 not enabled by @option{-fsanitize=undefined}.
16824 This option does not work well with @code{FE_INVALID} exceptions enabled.
16826 @item -fsanitize=nonnull-attribute
16827 @opindex fsanitize=nonnull-attribute
16829 This option enables instrumentation of calls, checking whether null values
16830 are not passed to arguments marked as requiring a non-null value by the
16831 @code{nonnull} function attribute.
16833 @item -fsanitize=returns-nonnull-attribute
16834 @opindex fsanitize=returns-nonnull-attribute
16836 This option enables instrumentation of return statements in functions
16837 marked with @code{returns_nonnull} function attribute, to detect returning
16838 of null values from such functions.
16840 @item -fsanitize=bool
16841 @opindex fsanitize=bool
16843 This option enables instrumentation of loads from bool. If a value other
16844 than 0/1 is loaded, a run-time error is issued.
16846 @item -fsanitize=enum
16847 @opindex fsanitize=enum
16849 This option enables instrumentation of loads from an enum type. If
16850 a value outside the range of values for the enum type is loaded,
16851 a run-time error is issued.
16853 @item -fsanitize=vptr
16854 @opindex fsanitize=vptr
16856 This option enables instrumentation of C++ member function calls, member
16857 accesses and some conversions between pointers to base and derived classes,
16858 to verify the referenced object has the correct dynamic type.
16860 @item -fsanitize=pointer-overflow
16861 @opindex fsanitize=pointer-overflow
16863 This option enables instrumentation of pointer arithmetics. If the pointer
16864 arithmetics overflows, a run-time error is issued.
16866 @item -fsanitize=builtin
16867 @opindex fsanitize=builtin
16869 This option enables instrumentation of arguments to selected builtin
16870 functions. If an invalid value is passed to such arguments, a run-time
16871 error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
16872 or @code{__builtin_clz} invokes undefined behavior and is diagnosed
16877 Note that sanitizers tend to increase the rate of false positive
16878 warnings, most notably those around @option{-Wmaybe-uninitialized}.
16879 We recommend against combining @option{-Werror} and [the use of]
16882 While @option{-ftrapv} causes traps for signed overflows to be emitted,
16883 @option{-fsanitize=undefined} gives a diagnostic message.
16884 This currently works only for the C family of languages.
16886 @item -fno-sanitize=all
16887 @opindex fno-sanitize=all
16889 This option disables all previously enabled sanitizers.
16890 @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
16893 @item -fasan-shadow-offset=@var{number}
16894 @opindex fasan-shadow-offset
16895 This option forces GCC to use custom shadow offset in AddressSanitizer checks.
16896 It is useful for experimenting with different shadow memory layouts in
16897 Kernel AddressSanitizer.
16899 @item -fsanitize-sections=@var{s1},@var{s2},...
16900 @opindex fsanitize-sections
16901 Sanitize global variables in selected user-defined sections. @var{si} may
16904 @item -fsanitize-recover@r{[}=@var{opts}@r{]}
16905 @opindex fsanitize-recover
16906 @opindex fno-sanitize-recover
16907 @option{-fsanitize-recover=} controls error recovery mode for sanitizers
16908 mentioned in comma-separated list of @var{opts}. Enabling this option
16909 for a sanitizer component causes it to attempt to continue
16910 running the program as if no error happened. This means multiple
16911 runtime errors can be reported in a single program run, and the exit
16912 code of the program may indicate success even when errors
16913 have been reported. The @option{-fno-sanitize-recover=} option
16914 can be used to alter
16915 this behavior: only the first detected error is reported
16916 and program then exits with a non-zero exit code.
16918 Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
16919 except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
16920 @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
16921 @option{-fsanitize=bounds-strict},
16922 @option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
16923 For these sanitizers error recovery is turned on by default,
16924 except @option{-fsanitize=address}, for which this feature is experimental.
16925 @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
16926 accepted, the former enables recovery for all sanitizers that support it,
16927 the latter disables recovery for all sanitizers that support it.
16929 Even if a recovery mode is turned on the compiler side, it needs to be also
16930 enabled on the runtime library side, otherwise the failures are still fatal.
16931 The runtime library defaults to @code{halt_on_error=0} for
16932 ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
16933 AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
16934 setting the @code{halt_on_error} flag in the corresponding environment variable.
16936 Syntax without an explicit @var{opts} parameter is deprecated. It is
16937 equivalent to specifying an @var{opts} list of:
16940 undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
16943 @item -fsanitize-address-use-after-scope
16944 @opindex fsanitize-address-use-after-scope
16945 Enable sanitization of local variables to detect use-after-scope bugs.
16946 The option sets @option{-fstack-reuse} to @samp{none}.
16948 @item -fsanitize-trap@r{[}=@var{opts}@r{]}
16949 @opindex fsanitize-trap
16950 @opindex fno-sanitize-trap
16951 The @option{-fsanitize-trap=} option instructs the compiler to
16952 report for sanitizers mentioned in comma-separated list of @var{opts}
16953 undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
16954 library routine. If this option is enabled for certain sanitizer,
16955 it takes precedence over the @option{-fsanitizer-recover=} for that
16956 sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
16957 of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
16959 The advantage of this is that the @code{libubsan} library is not needed
16960 and is not linked in, so this is usable even in freestanding environments.
16962 Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
16963 except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
16964 @option{-fsanitize=float-divide-by-zero} and
16965 @option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
16966 specified, which enables it for @code{undefined} suboptions,
16967 @option{-fsanitize=float-cast-overflow},
16968 @option{-fsanitize=float-divide-by-zero} and
16969 @option{-fsanitize=bounds-strict}.
16970 If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
16971 and @code{-fsanitize=vptr} is enabled on the command line, the
16972 instrumentation is silently ignored as the instrumentation always needs
16973 @code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
16975 @item -fsanitize-undefined-trap-on-error
16976 @opindex fsanitize-undefined-trap-on-error
16977 The @option{-fsanitize-undefined-trap-on-error} option is deprecated
16978 equivalent of @option{-fsanitize-trap=all}.
16980 @item -fsanitize-coverage=trace-pc
16981 @opindex fsanitize-coverage=trace-pc
16982 Enable coverage-guided fuzzing code instrumentation.
16983 Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
16985 @item -fsanitize-coverage=trace-cmp
16986 @opindex fsanitize-coverage=trace-cmp
16987 Enable dataflow guided fuzzing code instrumentation.
16988 Inserts a call to @code{__sanitizer_cov_trace_cmp1},
16989 @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
16990 @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
16991 variable or @code{__sanitizer_cov_trace_const_cmp1},
16992 @code{__sanitizer_cov_trace_const_cmp2},
16993 @code{__sanitizer_cov_trace_const_cmp4} or
16994 @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
16995 operand constant, @code{__sanitizer_cov_trace_cmpf} or
16996 @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
16997 @code{__sanitizer_cov_trace_switch} for switch statements.
16999 @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
17000 @opindex fcf-protection
17001 Enable code instrumentation of control-flow transfers to increase
17002 program security by checking that target addresses of control-flow
17003 transfer instructions (such as indirect function call, function return,
17004 indirect jump) are valid. This prevents diverting the flow of control
17005 to an unexpected target. This is intended to protect against such
17006 threats as Return-oriented Programming (ROP), and similarly
17007 call/jmp-oriented programming (COP/JOP).
17009 The value @code{branch} tells the compiler to implement checking of
17010 validity of control-flow transfer at the point of indirect branch
17011 instructions, i.e.@: call/jmp instructions. The value @code{return}
17012 implements checking of validity at the point of returning from a
17013 function. The value @code{full} is an alias for specifying both
17014 @code{branch} and @code{return}. The value @code{none} turns off
17017 The value @code{check} is used for the final link with link-time
17018 optimization (LTO). An error is issued if LTO object files are
17019 compiled with different @option{-fcf-protection} values. The
17020 value @code{check} is ignored at the compile time.
17022 The macro @code{__CET__} is defined when @option{-fcf-protection} is
17023 used. The first bit of @code{__CET__} is set to 1 for the value
17024 @code{branch} and the second bit of @code{__CET__} is set to 1 for
17027 You can also use the @code{nocf_check} attribute to identify
17028 which functions and calls should be skipped from instrumentation
17029 (@pxref{Function Attributes}).
17031 Currently the x86 GNU/Linux target provides an implementation based
17032 on Intel Control-flow Enforcement Technology (CET) which works for
17033 i686 processor or newer.
17035 @item -fharden-compares
17036 @opindex fharden-compares
17037 For every logical test that survives gimple optimizations and is
17038 @emph{not} the condition in a conditional branch (for example,
17039 conditions tested for conditional moves, or to store in boolean
17040 variables), emit extra code to compute and verify the reversed
17041 condition, and to call @code{__builtin_trap} if the results do not
17042 match. Use with @samp{-fharden-conditional-branches} to cover all
17045 @item -fharden-conditional-branches
17046 @opindex fharden-conditional-branches
17047 For every non-vectorized conditional branch that survives gimple
17048 optimizations, emit extra code to compute and verify the reversed
17049 condition, and to call @code{__builtin_trap} if the result is
17050 unexpected. Use with @samp{-fharden-compares} to cover all
17053 @item -fstack-protector
17054 @opindex fstack-protector
17055 Emit extra code to check for buffer overflows, such as stack smashing
17056 attacks. This is done by adding a guard variable to functions with
17057 vulnerable objects. This includes functions that call @code{alloca}, and
17058 functions with buffers larger than or equal to 8 bytes. The guards are
17059 initialized when a function is entered and then checked when the function
17060 exits. If a guard check fails, an error message is printed and the program
17061 exits. Only variables that are actually allocated on the stack are
17062 considered, optimized away variables or variables allocated in registers
17065 @item -fstack-protector-all
17066 @opindex fstack-protector-all
17067 Like @option{-fstack-protector} except that all functions are protected.
17069 @item -fstack-protector-strong
17070 @opindex fstack-protector-strong
17071 Like @option{-fstack-protector} but includes additional functions to
17072 be protected --- those that have local array definitions, or have
17073 references to local frame addresses. Only variables that are actually
17074 allocated on the stack are considered, optimized away variables or variables
17075 allocated in registers don't count.
17077 @item -fstack-protector-explicit
17078 @opindex fstack-protector-explicit
17079 Like @option{-fstack-protector} but only protects those functions which
17080 have the @code{stack_protect} attribute.
17082 @item -fstack-check
17083 @opindex fstack-check
17084 Generate code to verify that you do not go beyond the boundary of the
17085 stack. You should specify this flag if you are running in an
17086 environment with multiple threads, but you only rarely need to specify it in
17087 a single-threaded environment since stack overflow is automatically
17088 detected on nearly all systems if there is only one stack.
17090 Note that this switch does not actually cause checking to be done; the
17091 operating system or the language runtime must do that. The switch causes
17092 generation of code to ensure that they see the stack being extended.
17094 You can additionally specify a string parameter: @samp{no} means no
17095 checking, @samp{generic} means force the use of old-style checking,
17096 @samp{specific} means use the best checking method and is equivalent
17097 to bare @option{-fstack-check}.
17099 Old-style checking is a generic mechanism that requires no specific
17100 target support in the compiler but comes with the following drawbacks:
17104 Modified allocation strategy for large objects: they are always
17105 allocated dynamically if their size exceeds a fixed threshold. Note this
17106 may change the semantics of some code.
17109 Fixed limit on the size of the static frame of functions: when it is
17110 topped by a particular function, stack checking is not reliable and
17111 a warning is issued by the compiler.
17114 Inefficiency: because of both the modified allocation strategy and the
17115 generic implementation, code performance is hampered.
17118 Note that old-style stack checking is also the fallback method for
17119 @samp{specific} if no target support has been added in the compiler.
17121 @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17122 and stack overflows. @samp{specific} is an excellent choice when compiling
17123 Ada code. It is not generally sufficient to protect against stack-clash
17124 attacks. To protect against those you want @samp{-fstack-clash-protection}.
17126 @item -fstack-clash-protection
17127 @opindex fstack-clash-protection
17128 Generate code to prevent stack clash style attacks. When this option is
17129 enabled, the compiler will only allocate one page of stack space at a time
17130 and each page is accessed immediately after allocation. Thus, it prevents
17131 allocations from jumping over any stack guard page provided by the
17134 Most targets do not fully support stack clash protection. However, on
17135 those targets @option{-fstack-clash-protection} will protect dynamic stack
17136 allocations. @option{-fstack-clash-protection} may also provide limited
17137 protection for static stack allocations if the target supports
17138 @option{-fstack-check=specific}.
17140 @item -fstack-limit-register=@var{reg}
17141 @itemx -fstack-limit-symbol=@var{sym}
17142 @itemx -fno-stack-limit
17143 @opindex fstack-limit-register
17144 @opindex fstack-limit-symbol
17145 @opindex fno-stack-limit
17146 Generate code to ensure that the stack does not grow beyond a certain value,
17147 either the value of a register or the address of a symbol. If a larger
17148 stack is required, a signal is raised at run time. For most targets,
17149 the signal is raised before the stack overruns the boundary, so
17150 it is possible to catch the signal without taking special precautions.
17152 For instance, if the stack starts at absolute address @samp{0x80000000}
17153 and grows downwards, you can use the flags
17154 @option{-fstack-limit-symbol=__stack_limit} and
17155 @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17156 of 128KB@. Note that this may only work with the GNU linker.
17158 You can locally override stack limit checking by using the
17159 @code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17161 @item -fsplit-stack
17162 @opindex fsplit-stack
17163 Generate code to automatically split the stack before it overflows.
17164 The resulting program has a discontiguous stack which can only
17165 overflow if the program is unable to allocate any more memory. This
17166 is most useful when running threaded programs, as it is no longer
17167 necessary to calculate a good stack size to use for each thread. This
17168 is currently only implemented for the x86 targets running
17171 When code compiled with @option{-fsplit-stack} calls code compiled
17172 without @option{-fsplit-stack}, there may not be much stack space
17173 available for the latter code to run. If compiling all code,
17174 including library code, with @option{-fsplit-stack} is not an option,
17175 then the linker can fix up these calls so that the code compiled
17176 without @option{-fsplit-stack} always has a large stack. Support for
17177 this is implemented in the gold linker in GNU binutils release 2.21
17180 @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
17181 @opindex fvtable-verify
17182 This option is only available when compiling C++ code.
17183 It turns on (or off, if using @option{-fvtable-verify=none}) the security
17184 feature that verifies at run time, for every virtual call, that
17185 the vtable pointer through which the call is made is valid for the type of
17186 the object, and has not been corrupted or overwritten. If an invalid vtable
17187 pointer is detected at run time, an error is reported and execution of the
17188 program is immediately halted.
17190 This option causes run-time data structures to be built at program startup,
17191 which are used for verifying the vtable pointers.
17192 The options @samp{std} and @samp{preinit}
17193 control the timing of when these data structures are built. In both cases the
17194 data structures are built before execution reaches @code{main}. Using
17195 @option{-fvtable-verify=std} causes the data structures to be built after
17196 shared libraries have been loaded and initialized.
17197 @option{-fvtable-verify=preinit} causes them to be built before shared
17198 libraries have been loaded and initialized.
17200 If this option appears multiple times in the command line with different
17201 values specified, @samp{none} takes highest priority over both @samp{std} and
17202 @samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17205 @opindex fvtv-debug
17206 When used in conjunction with @option{-fvtable-verify=std} or
17207 @option{-fvtable-verify=preinit}, causes debug versions of the
17208 runtime functions for the vtable verification feature to be called.
17209 This flag also causes the compiler to log information about which
17210 vtable pointers it finds for each class.
17211 This information is written to a file named @file{vtv_set_ptr_data.log}
17212 in the directory named by the environment variable @env{VTV_LOGS_DIR}
17213 if that is defined or the current working directory otherwise.
17215 Note: This feature @emph{appends} data to the log file. If you want a fresh log
17216 file, be sure to delete any existing one.
17219 @opindex fvtv-counts
17220 This is a debugging flag. When used in conjunction with
17221 @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17222 causes the compiler to keep track of the total number of virtual calls
17223 it encounters and the number of verifications it inserts. It also
17224 counts the number of calls to certain run-time library functions
17225 that it inserts and logs this information for each compilation unit.
17226 The compiler writes this information to a file named
17227 @file{vtv_count_data.log} in the directory named by the environment
17228 variable @env{VTV_LOGS_DIR} if that is defined or the current working
17229 directory otherwise. It also counts the size of the vtable pointer sets
17230 for each class, and writes this information to @file{vtv_class_set_sizes.log}
17231 in the same directory.
17233 Note: This feature @emph{appends} data to the log files. To get fresh log
17234 files, be sure to delete any existing ones.
17236 @item -finstrument-functions
17237 @opindex finstrument-functions
17238 Generate instrumentation calls for entry and exit to functions. Just
17239 after function entry and just before function exit, the following
17240 profiling functions are called with the address of the current
17241 function and its call site. (On some platforms,
17242 @code{__builtin_return_address} does not work beyond the current
17243 function, so the call site information may not be available to the
17244 profiling functions otherwise.)
17247 void __cyg_profile_func_enter (void *this_fn,
17249 void __cyg_profile_func_exit (void *this_fn,
17253 The first argument is the address of the start of the current function,
17254 which may be looked up exactly in the symbol table.
17256 This instrumentation is also done for functions expanded inline in other
17257 functions. The profiling calls indicate where, conceptually, the
17258 inline function is entered and exited. This means that addressable
17259 versions of such functions must be available. If all your uses of a
17260 function are expanded inline, this may mean an additional expansion of
17261 code size. If you use @code{extern inline} in your C code, an
17262 addressable version of such functions must be provided. (This is
17263 normally the case anyway, but if you get lucky and the optimizer always
17264 expands the functions inline, you might have gotten away without
17265 providing static copies.)
17267 A function may be given the attribute @code{no_instrument_function}, in
17268 which case this instrumentation is not done. This can be used, for
17269 example, for the profiling functions listed above, high-priority
17270 interrupt routines, and any functions from which the profiling functions
17271 cannot safely be called (perhaps signal handlers, if the profiling
17272 routines generate output or allocate memory).
17273 @xref{Common Function Attributes}.
17275 @item -finstrument-functions-once
17276 @opindex finstrument-functions-once
17277 This is similar to @option{-finstrument-functions}, but the profiling
17278 functions are called only once per instrumented function, i.e. the first
17279 profiling function is called after the first entry into the instrumented
17280 function and the second profiling function is called before the exit
17281 corresponding to this first entry.
17283 The definition of @code{once} for the purpose of this option is a little
17284 vague because the implementation is not protected against data races.
17285 As a result, the implementation only guarantees that the profiling
17286 functions are called at @emph{least} once per process and at @emph{most}
17287 once per thread, but the calls are always paired, that is to say, if a
17288 thread calls the first function, then it will call the second function,
17289 unless it never reaches the exit of the instrumented function.
17291 @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
17292 @opindex finstrument-functions-exclude-file-list
17294 Set the list of functions that are excluded from instrumentation (see
17295 the description of @option{-finstrument-functions}). If the file that
17296 contains a function definition matches with one of @var{file}, then
17297 that function is not instrumented. The match is done on substrings:
17298 if the @var{file} parameter is a substring of the file name, it is
17299 considered to be a match.
17304 -finstrument-functions-exclude-file-list=/bits/stl,include/sys
17308 excludes any inline function defined in files whose pathnames
17309 contain @file{/bits/stl} or @file{include/sys}.
17311 If, for some reason, you want to include letter @samp{,} in one of
17312 @var{sym}, write @samp{\,}. For example,
17313 @option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17314 (note the single quote surrounding the option).
17316 @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
17317 @opindex finstrument-functions-exclude-function-list
17319 This is similar to @option{-finstrument-functions-exclude-file-list},
17320 but this option sets the list of function names to be excluded from
17321 instrumentation. The function name to be matched is its user-visible
17322 name, such as @code{vector<int> blah(const vector<int> &)}, not the
17323 internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17324 match is done on substrings: if the @var{sym} parameter is a substring
17325 of the function name, it is considered to be a match. For C99 and C++
17326 extended identifiers, the function name must be given in UTF-8, not
17327 using universal character names.
17329 @item -fpatchable-function-entry=@var{N}[,@var{M}]
17330 @opindex fpatchable-function-entry
17331 Generate @var{N} NOPs right at the beginning
17332 of each function, with the function entry point before the @var{M}th NOP.
17333 If @var{M} is omitted, it defaults to @code{0} so the
17334 function entry points to the address just at the first NOP.
17335 The NOP instructions reserve extra space which can be used to patch in
17336 any desired instrumentation at run time, provided that the code segment
17337 is writable. The amount of space is controllable indirectly via
17338 the number of NOPs; the NOP instruction used corresponds to the instruction
17339 emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17340 is target-specific and may also depend on the architecture variant and/or
17341 other compilation options.
17343 For run-time identification, the starting addresses of these areas,
17344 which correspond to their respective function entries minus @var{M},
17345 are additionally collected in the @code{__patchable_function_entries}
17346 section of the resulting binary.
17348 Note that the value of @code{__attribute__ ((patchable_function_entry
17349 (N,M)))} takes precedence over command-line option
17350 @option{-fpatchable-function-entry=N,M}. This can be used to increase
17351 the area size or to remove it completely on a single function.
17352 If @code{N=0}, no pad location is recorded.
17354 The NOP instructions are inserted at---and maybe before, depending on
17355 @var{M}---the function entry address, even before the prologue. On
17356 PowerPC with the ELFv2 ABI, for a function with dual entry points,
17357 the local entry point is this function entry address.
17359 The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17360 ELFv2 ABI, for a function with dual entry points, the supported values
17361 for @var{M} are 0, 2, 6 and 14.
17365 @node Preprocessor Options
17366 @section Options Controlling the Preprocessor
17367 @cindex preprocessor options
17368 @cindex options, preprocessor
17370 These options control the C preprocessor, which is run on each C source
17371 file before actual compilation.
17373 If you use the @option{-E} option, nothing is done except preprocessing.
17374 Some of these options make sense only together with @option{-E} because
17375 they cause the preprocessor output to be unsuitable for actual
17378 In addition to the options listed here, there are a number of options
17379 to control search paths for include files documented in
17380 @ref{Directory Options}.
17381 Options to control preprocessor diagnostics are listed in
17382 @ref{Warning Options}.
17385 @include cppopts.texi
17387 @item -Wp,@var{option}
17389 You can use @option{-Wp,@var{option}} to bypass the compiler driver
17390 and pass @var{option} directly through to the preprocessor. If
17391 @var{option} contains commas, it is split into multiple options at the
17392 commas. However, many options are modified, translated or interpreted
17393 by the compiler driver before being passed to the preprocessor, and
17394 @option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17395 interface is undocumented and subject to change, so whenever possible
17396 you should avoid using @option{-Wp} and let the driver handle the
17399 @item -Xpreprocessor @var{option}
17400 @opindex Xpreprocessor
17401 Pass @var{option} as an option to the preprocessor. You can use this to
17402 supply system-specific preprocessor options that GCC does not
17405 If you want to pass an option that takes an argument, you must use
17406 @option{-Xpreprocessor} twice, once for the option and once for the argument.
17408 @item -no-integrated-cpp
17409 @opindex no-integrated-cpp
17410 Perform preprocessing as a separate pass before compilation.
17411 By default, GCC performs preprocessing as an integrated part of
17412 input tokenization and parsing.
17413 If this option is provided, the appropriate language front end
17414 (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17415 and Objective-C, respectively) is instead invoked twice,
17416 once for preprocessing only and once for actual compilation
17417 of the preprocessed input.
17418 This option may be useful in conjunction with the @option{-B} or
17419 @option{-wrapper} options to specify an alternate preprocessor or
17420 perform additional processing of the program source between
17421 normal preprocessing and compilation.
17423 @item -flarge-source-files
17424 @opindex flarge-source-files
17425 Adjust GCC to expect large source files, at the expense of slower
17426 compilation and higher memory usage.
17428 Specifically, GCC normally tracks both column numbers and line numbers
17429 within source files and it normally prints both of these numbers in
17430 diagnostics. However, once it has processed a certain number of source
17431 lines, it stops tracking column numbers and only tracks line numbers.
17432 This means that diagnostics for later lines do not include column numbers.
17433 It also means that options like @option{-Wmisleading-indentation} cease to work
17434 at that point, although the compiler prints a note if this happens.
17435 Passing @option{-flarge-source-files} significantly increases the number
17436 of source lines that GCC can process before it stops tracking columns.
17440 @node Assembler Options
17441 @section Passing Options to the Assembler
17443 @c prevent bad page break with this line
17444 You can pass options to the assembler.
17447 @item -Wa,@var{option}
17449 Pass @var{option} as an option to the assembler. If @var{option}
17450 contains commas, it is split into multiple options at the commas.
17452 @item -Xassembler @var{option}
17453 @opindex Xassembler
17454 Pass @var{option} as an option to the assembler. You can use this to
17455 supply system-specific assembler options that GCC does not
17458 If you want to pass an option that takes an argument, you must use
17459 @option{-Xassembler} twice, once for the option and once for the argument.
17464 @section Options for Linking
17465 @cindex link options
17466 @cindex options, linking
17468 These options come into play when the compiler links object files into
17469 an executable output file. They are meaningless if the compiler is
17470 not doing a link step.
17474 @item @var{object-file-name}
17475 A file name that does not end in a special recognized suffix is
17476 considered to name an object file or library. (Object files are
17477 distinguished from libraries by the linker according to the file
17478 contents.) If linking is done, these object files are used as input
17487 If any of these options is used, then the linker is not run, and
17488 object file names should not be used as arguments. @xref{Overall
17491 @item -flinker-output=@var{type}
17492 @opindex flinker-output
17493 This option controls code generation of the link-time optimizer. By
17494 default the linker output is automatically determined by the linker
17495 plugin. For debugging the compiler and if incremental linking with a
17496 non-LTO object file is desired, it may be useful to control the type
17499 If @var{type} is @samp{exec}, code generation produces a static
17500 binary. In this case @option{-fpic} and @option{-fpie} are both
17503 If @var{type} is @samp{dyn}, code generation produces a shared
17504 library. In this case @option{-fpic} or @option{-fPIC} is preserved,
17505 but not enabled automatically. This allows to build shared libraries
17506 without position-independent code on architectures where this is
17507 possible, i.e.@: on x86.
17509 If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
17510 executable. This results in similar optimizations as @samp{exec}
17511 except that @option{-fpie} is not disabled if specified at compilation
17514 If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
17515 done. The sections containing intermediate code for link-time optimization are
17516 merged, pre-optimized, and output to the resulting object file. In addition, if
17517 @option{-ffat-lto-objects} is specified, binary code is produced for future
17518 non-LTO linking. The object file produced by incremental linking is smaller
17519 than a static library produced from the same object files. At link time the
17520 result of incremental linking also loads faster than a static
17521 library assuming that the majority of objects in the library are used.
17523 Finally @samp{nolto-rel} configures the compiler for incremental linking where
17524 code generation is forced, a final binary is produced, and the intermediate
17525 code for later link-time optimization is stripped. When multiple object files
17526 are linked together the resulting code is better optimized than with
17527 link-time optimizations disabled (for example, cross-module inlining
17528 happens), but most of benefits of whole program optimizations are lost.
17530 During the incremental link (by @option{-r}) the linker plugin defaults to
17531 @option{rel}. With current interfaces to GNU Binutils it is however not
17532 possible to incrementally link LTO objects and non-LTO objects into a single
17533 mixed object file. If any of object files in incremental link cannot
17534 be used for link-time optimization, the linker plugin issues a warning and
17535 uses @samp{nolto-rel}. To maintain whole program optimization, it is
17536 recommended to link such objects into static library instead. Alternatively it
17537 is possible to use H.J. Lu's binutils with support for mixed objects.
17540 @opindex fuse-ld=bfd
17541 Use the @command{bfd} linker instead of the default linker.
17543 @item -fuse-ld=gold
17544 @opindex fuse-ld=gold
17545 Use the @command{gold} linker instead of the default linker.
17548 @opindex fuse-ld=lld
17549 Use the LLVM @command{lld} linker instead of the default linker.
17551 @item -fuse-ld=mold
17552 @opindex fuse-ld=mold
17553 Use the Modern Linker (@command{mold}) instead of the default linker.
17556 @item -l@var{library}
17557 @itemx -l @var{library}
17559 Search the library named @var{library} when linking. (The second
17560 alternative with the library as a separate argument is only for
17561 POSIX compliance and is not recommended.)
17563 The @option{-l} option is passed directly to the linker by GCC. Refer
17564 to your linker documentation for exact details. The general
17565 description below applies to the GNU linker.
17567 The linker searches a standard list of directories for the library.
17568 The directories searched include several standard system directories
17569 plus any that you specify with @option{-L}.
17571 Static libraries are archives of object files, and have file names
17572 like @file{lib@var{library}.a}. Some targets also support shared
17573 libraries, which typically have names like @file{lib@var{library}.so}.
17574 If both static and shared libraries are found, the linker gives
17575 preference to linking with the shared library unless the
17576 @option{-static} option is used.
17578 It makes a difference where in the command you write this option; the
17579 linker searches and processes libraries and object files in the order they
17580 are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
17581 after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
17582 to functions in @samp{z}, those functions may not be loaded.
17586 You need this special case of the @option{-l} option in order to
17587 link an Objective-C or Objective-C++ program.
17589 @item -nostartfiles
17590 @opindex nostartfiles
17591 Do not use the standard system startup files when linking.
17592 The standard system libraries are used normally, unless @option{-nostdlib},
17593 @option{-nolibc}, or @option{-nodefaultlibs} is used.
17595 @item -nodefaultlibs
17596 @opindex nodefaultlibs
17597 Do not use the standard system libraries when linking.
17598 Only the libraries you specify are passed to the linker, and options
17599 specifying linkage of the system libraries, such as @option{-static-libgcc}
17600 or @option{-shared-libgcc}, are ignored.
17601 The standard startup files are used normally, unless @option{-nostartfiles}
17604 The compiler may generate calls to @code{memcmp},
17605 @code{memset}, @code{memcpy} and @code{memmove}.
17606 These entries are usually resolved by entries in
17607 libc. These entry points should be supplied through some other
17608 mechanism when this option is specified.
17612 Do not use the C library or system libraries tightly coupled with it when
17613 linking. Still link with the startup files, @file{libgcc} or toolchain
17614 provided language support libraries such as @file{libgnat}, @file{libgfortran}
17615 or @file{libstdc++} unless options preventing their inclusion are used as
17616 well. This typically removes @option{-lc} from the link command line, as well
17617 as system libraries that normally go with it and become meaningless when
17618 absence of a C library is assumed, for example @option{-lpthread} or
17619 @option{-lm} in some configurations. This is intended for bare-board
17620 targets when there is indeed no C library available.
17624 Do not use the standard system startup files or libraries when linking.
17625 No startup files and only the libraries you specify are passed to
17626 the linker, and options specifying linkage of the system libraries, such as
17627 @option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
17629 The compiler may generate calls to @code{memcmp}, @code{memset},
17630 @code{memcpy} and @code{memmove}.
17631 These entries are usually resolved by entries in
17632 libc. These entry points should be supplied through some other
17633 mechanism when this option is specified.
17635 @cindex @option{-lgcc}, use with @option{-nostdlib}
17636 @cindex @option{-nostdlib} and unresolved references
17637 @cindex unresolved references and @option{-nostdlib}
17638 @cindex @option{-lgcc}, use with @option{-nodefaultlibs}
17639 @cindex @option{-nodefaultlibs} and unresolved references
17640 @cindex unresolved references and @option{-nodefaultlibs}
17641 One of the standard libraries bypassed by @option{-nostdlib} and
17642 @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
17643 which GCC uses to overcome shortcomings of particular machines, or special
17644 needs for some languages.
17645 (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
17646 Collection (GCC) Internals},
17647 for more discussion of @file{libgcc.a}.)
17648 In most cases, you need @file{libgcc.a} even when you want to avoid
17649 other standard libraries. In other words, when you specify @option{-nostdlib}
17650 or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
17651 This ensures that you have no unresolved references to internal GCC
17652 library subroutines.
17653 (An example of such an internal subroutine is @code{__main}, used to ensure C++
17654 constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
17655 GNU Compiler Collection (GCC) Internals}.)
17658 @opindex nostdlib++
17659 Do not implicitly link with standard C++ libraries.
17661 @item -e @var{entry}
17662 @itemx --entry=@var{entry}
17666 Specify that the program entry point is @var{entry}. The argument is
17667 interpreted by the linker; the GNU linker accepts either a symbol name
17672 Produce a dynamically linked position independent executable on targets
17673 that support it. For predictable results, you must also specify the same
17674 set of options used for compilation (@option{-fpie}, @option{-fPIE},
17675 or model suboptions) when you specify this linker option.
17679 Don't produce a dynamically linked position independent executable.
17682 @opindex static-pie
17683 Produce a static position independent executable on targets that support
17684 it. A static position independent executable is similar to a static
17685 executable, but can be loaded at any address without a dynamic linker.
17686 For predictable results, you must also specify the same set of options
17687 used for compilation (@option{-fpie}, @option{-fPIE}, or model
17688 suboptions) when you specify this linker option.
17692 Link with the POSIX threads library. This option is supported on
17693 GNU/Linux targets, most other Unix derivatives, and also on
17694 x86 Cygwin and MinGW targets. On some targets this option also sets
17695 flags for the preprocessor, so it should be used consistently for both
17696 compilation and linking.
17700 Produce a relocatable object as output. This is also known as partial
17705 Pass the flag @option{-export-dynamic} to the ELF linker, on targets
17706 that support it. This instructs the linker to add all symbols, not
17707 only used ones, to the dynamic symbol table. This option is needed
17708 for some uses of @code{dlopen} or to allow obtaining backtraces
17709 from within a program.
17713 Remove all symbol table and relocation information from the executable.
17717 On systems that support dynamic linking, this overrides @option{-pie}
17718 and prevents linking with the shared libraries. On other systems, this
17719 option has no effect.
17723 Produce a shared object which can then be linked with other objects to
17724 form an executable. Not all systems support this option. For predictable
17725 results, you must also specify the same set of options used for compilation
17726 (@option{-fpic}, @option{-fPIC}, or model suboptions) when
17727 you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
17728 needs to build supplementary stub code for constructors to work. On
17729 multi-libbed systems, @samp{gcc -shared} must select the correct support
17730 libraries to link against. Failing to supply the correct flags may lead
17731 to subtle defects. Supplying them in cases where they are not necessary
17732 is innocuous. @option{-shared} suppresses the addition of startup code
17733 to alter the floating-point environment as done with @option{-ffast-math},
17734 @option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
17736 @item -shared-libgcc
17737 @itemx -static-libgcc
17738 @opindex shared-libgcc
17739 @opindex static-libgcc
17740 On systems that provide @file{libgcc} as a shared library, these options
17741 force the use of either the shared or static version, respectively.
17742 If no shared version of @file{libgcc} was built when the compiler was
17743 configured, these options have no effect.
17745 There are several situations in which an application should use the
17746 shared @file{libgcc} instead of the static version. The most common
17747 of these is when the application wishes to throw and catch exceptions
17748 across different shared libraries. In that case, each of the libraries
17749 as well as the application itself should use the shared @file{libgcc}.
17751 Therefore, the G++ driver automatically adds @option{-shared-libgcc}
17752 whenever you build a shared library or a main executable, because C++
17753 programs typically use exceptions, so this is the right thing to do.
17755 If, instead, you use the GCC driver to create shared libraries, you may
17756 find that they are not always linked with the shared @file{libgcc}.
17757 If GCC finds, at its configuration time, that you have a non-GNU linker
17758 or a GNU linker that does not support option @option{--eh-frame-hdr},
17759 it links the shared version of @file{libgcc} into shared libraries
17760 by default. Otherwise, it takes advantage of the linker and optimizes
17761 away the linking with the shared version of @file{libgcc}, linking with
17762 the static version of libgcc by default. This allows exceptions to
17763 propagate through such shared libraries, without incurring relocation
17764 costs at library load time.
17766 However, if a library or main executable is supposed to throw or catch
17767 exceptions, you must link it using the G++ driver, or using the option
17768 @option{-shared-libgcc}, such that it is linked with the shared
17771 @item -static-libasan
17772 @opindex static-libasan
17773 When the @option{-fsanitize=address} option is used to link a program,
17774 the GCC driver automatically links against @option{libasan}. If
17775 @file{libasan} is available as a shared library, and the @option{-static}
17776 option is not used, then this links against the shared version of
17777 @file{libasan}. The @option{-static-libasan} option directs the GCC
17778 driver to link @file{libasan} statically, without necessarily linking
17779 other libraries statically.
17781 @item -static-libtsan
17782 @opindex static-libtsan
17783 When the @option{-fsanitize=thread} option is used to link a program,
17784 the GCC driver automatically links against @option{libtsan}. If
17785 @file{libtsan} is available as a shared library, and the @option{-static}
17786 option is not used, then this links against the shared version of
17787 @file{libtsan}. The @option{-static-libtsan} option directs the GCC
17788 driver to link @file{libtsan} statically, without necessarily linking
17789 other libraries statically.
17791 @item -static-liblsan
17792 @opindex static-liblsan
17793 When the @option{-fsanitize=leak} option is used to link a program,
17794 the GCC driver automatically links against @option{liblsan}. If
17795 @file{liblsan} is available as a shared library, and the @option{-static}
17796 option is not used, then this links against the shared version of
17797 @file{liblsan}. The @option{-static-liblsan} option directs the GCC
17798 driver to link @file{liblsan} statically, without necessarily linking
17799 other libraries statically.
17801 @item -static-libubsan
17802 @opindex static-libubsan
17803 When the @option{-fsanitize=undefined} option is used to link a program,
17804 the GCC driver automatically links against @option{libubsan}. If
17805 @file{libubsan} is available as a shared library, and the @option{-static}
17806 option is not used, then this links against the shared version of
17807 @file{libubsan}. The @option{-static-libubsan} option directs the GCC
17808 driver to link @file{libubsan} statically, without necessarily linking
17809 other libraries statically.
17811 @item -static-libstdc++
17812 @opindex static-libstdc++
17813 When the @command{g++} program is used to link a C++ program, it
17814 normally automatically links against @option{libstdc++}. If
17815 @file{libstdc++} is available as a shared library, and the
17816 @option{-static} option is not used, then this links against the
17817 shared version of @file{libstdc++}. That is normally fine. However, it
17818 is sometimes useful to freeze the version of @file{libstdc++} used by
17819 the program without going all the way to a fully static link. The
17820 @option{-static-libstdc++} option directs the @command{g++} driver to
17821 link @file{libstdc++} statically, without necessarily linking other
17822 libraries statically.
17826 Bind references to global symbols when building a shared object. Warn
17827 about any unresolved references (unless overridden by the link editor
17828 option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
17831 @item -T @var{script}
17833 @cindex linker script
17834 Use @var{script} as the linker script. This option is supported by most
17835 systems using the GNU linker. On some targets, such as bare-board
17836 targets without an operating system, the @option{-T} option may be required
17837 when linking to avoid references to undefined symbols.
17839 @item -Xlinker @var{option}
17841 Pass @var{option} as an option to the linker. You can use this to
17842 supply system-specific linker options that GCC does not recognize.
17844 If you want to pass an option that takes a separate argument, you must use
17845 @option{-Xlinker} twice, once for the option and once for the argument.
17846 For example, to pass @option{-assert definitions}, you must write
17847 @option{-Xlinker -assert -Xlinker definitions}. It does not work to write
17848 @option{-Xlinker "-assert definitions"}, because this passes the entire
17849 string as a single argument, which is not what the linker expects.
17851 When using the GNU linker, it is usually more convenient to pass
17852 arguments to linker options using the @option{@var{option}=@var{value}}
17853 syntax than as separate arguments. For example, you can specify
17854 @option{-Xlinker -Map=output.map} rather than
17855 @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
17856 this syntax for command-line options.
17858 @item -Wl,@var{option}
17860 Pass @var{option} as an option to the linker. If @var{option} contains
17861 commas, it is split into multiple options at the commas. You can use this
17862 syntax to pass an argument to the option.
17863 For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
17864 linker. When using the GNU linker, you can also get the same effect with
17865 @option{-Wl,-Map=output.map}.
17867 @item -u @var{symbol}
17869 Pretend the symbol @var{symbol} is undefined, to force linking of
17870 library modules to define it. You can use @option{-u} multiple times with
17871 different symbols to force loading of additional library modules.
17873 @item -z @var{keyword}
17875 @option{-z} is passed directly on to the linker along with the keyword
17876 @var{keyword}. See the section in the documentation of your linker for
17877 permitted values and their meanings.
17880 @node Directory Options
17881 @section Options for Directory Search
17882 @cindex directory options
17883 @cindex options, directory search
17884 @cindex search path
17886 These options specify directories to search for header files, for
17887 libraries and for parts of the compiler:
17890 @include cppdiropts.texi
17892 @item -iplugindir=@var{dir}
17893 @opindex iplugindir=
17894 Set the directory to search for plugins that are passed
17895 by @option{-fplugin=@var{name}} instead of
17896 @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
17897 to be used by the user, but only passed by the driver.
17901 Add directory @var{dir} to the list of directories to be searched
17904 @item -B@var{prefix}
17906 This option specifies where to find the executables, libraries,
17907 include files, and data files of the compiler itself.
17909 The compiler driver program runs one or more of the subprograms
17910 @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
17911 @var{prefix} as a prefix for each program it tries to run, both with and
17912 without @samp{@var{machine}/@var{version}/} for the corresponding target
17913 machine and compiler version.
17915 For each subprogram to be run, the compiler driver first tries the
17916 @option{-B} prefix, if any. If that name is not found, or if @option{-B}
17917 is not specified, the driver tries two standard prefixes,
17918 @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
17919 those results in a file name that is found, the unmodified program
17920 name is searched for using the directories specified in your
17921 @env{PATH} environment variable.
17923 The compiler checks to see if the path provided by @option{-B}
17924 refers to a directory, and if necessary it adds a directory
17925 separator character at the end of the path.
17927 @option{-B} prefixes that effectively specify directory names also apply
17928 to libraries in the linker, because the compiler translates these
17929 options into @option{-L} options for the linker. They also apply to
17930 include files in the preprocessor, because the compiler translates these
17931 options into @option{-isystem} options for the preprocessor. In this case,
17932 the compiler appends @samp{include} to the prefix.
17934 The runtime support file @file{libgcc.a} can also be searched for using
17935 the @option{-B} prefix, if needed. If it is not found there, the two
17936 standard prefixes above are tried, and that is all. The file is left
17937 out of the link if it is not found by those means.
17939 Another way to specify a prefix much like the @option{-B} prefix is to use
17940 the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
17943 As a special kludge, if the path provided by @option{-B} is
17944 @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
17945 9, then it is replaced by @file{[dir/]include}. This is to help
17946 with boot-strapping the compiler.
17948 @item -no-canonical-prefixes
17949 @opindex no-canonical-prefixes
17950 Do not expand any symbolic links, resolve references to @samp{/../}
17951 or @samp{/./}, or make the path absolute when generating a relative
17954 @item --sysroot=@var{dir}
17956 Use @var{dir} as the logical root directory for headers and libraries.
17957 For example, if the compiler normally searches for headers in
17958 @file{/usr/include} and libraries in @file{/usr/lib}, it instead
17959 searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
17961 If you use both this option and the @option{-isysroot} option, then
17962 the @option{--sysroot} option applies to libraries, but the
17963 @option{-isysroot} option applies to header files.
17965 The GNU linker (beginning with version 2.16) has the necessary support
17966 for this option. If your linker does not support this option, the
17967 header file aspect of @option{--sysroot} still works, but the
17968 library aspect does not.
17970 @item --no-sysroot-suffix
17971 @opindex no-sysroot-suffix
17972 For some targets, a suffix is added to the root directory specified
17973 with @option{--sysroot}, depending on the other options used, so that
17974 headers may for example be found in
17975 @file{@var{dir}/@var{suffix}/usr/include} instead of
17976 @file{@var{dir}/usr/include}. This option disables the addition of
17981 @node Code Gen Options
17982 @section Options for Code Generation Conventions
17983 @cindex code generation conventions
17984 @cindex options, code generation
17985 @cindex run-time options
17987 These machine-independent options control the interface conventions
17988 used in code generation.
17990 Most of them have both positive and negative forms; the negative form
17991 of @option{-ffoo} is @option{-fno-foo}. In the table below, only
17992 one of the forms is listed---the one that is not the default. You
17993 can figure out the other form by either removing @samp{no-} or adding
17997 @item -fstack-reuse=@var{reuse-level}
17998 @opindex fstack_reuse
17999 This option controls stack space reuse for user declared local/auto variables
18000 and compiler generated temporaries. @var{reuse_level} can be @samp{all},
18001 @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
18002 local variables and temporaries, @samp{named_vars} enables the reuse only for
18003 user defined local variables with names, and @samp{none} disables stack reuse
18004 completely. The default value is @samp{all}. The option is needed when the
18005 program extends the lifetime of a scoped local variable or a compiler generated
18006 temporary beyond the end point defined by the language. When a lifetime of
18007 a variable ends, and if the variable lives in memory, the optimizing compiler
18008 has the freedom to reuse its stack space with other temporaries or scoped
18009 local variables whose live range does not overlap with it. Legacy code extending
18010 local lifetime is likely to break with the stack reuse optimization.
18029 if (*p == 10) // out of scope use of local1
18040 A(int k) : i(k), j(k) @{ @}
18047 void foo(const A& ar)
18054 foo(A(10)); // temp object's lifetime ends when foo returns
18060 ap->i+= 10; // ap references out of scope temp whose space
18061 // is reused with a. What is the value of ap->i?
18066 The lifetime of a compiler generated temporary is well defined by the C++
18067 standard. When a lifetime of a temporary ends, and if the temporary lives
18068 in memory, the optimizing compiler has the freedom to reuse its stack
18069 space with other temporaries or scoped local variables whose live range
18070 does not overlap with it. However some of the legacy code relies on
18071 the behavior of older compilers in which temporaries' stack space is
18072 not reused, the aggressive stack reuse can lead to runtime errors. This
18073 option is used to control the temporary stack reuse optimization.
18077 This option generates traps for signed overflow on addition, subtraction,
18078 multiplication operations.
18079 The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18080 @option{-ftrapv} @option{-fwrapv} on the command-line results in
18081 @option{-fwrapv} being effective. Note that only active options override, so
18082 using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18083 results in @option{-ftrapv} being effective.
18087 This option instructs the compiler to assume that signed arithmetic
18088 overflow of addition, subtraction and multiplication wraps around
18089 using twos-complement representation. This flag enables some optimizations
18090 and disables others.
18091 The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18092 @option{-ftrapv} @option{-fwrapv} on the command-line results in
18093 @option{-fwrapv} being effective. Note that only active options override, so
18094 using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18095 results in @option{-ftrapv} being effective.
18097 @item -fwrapv-pointer
18098 @opindex fwrapv-pointer
18099 This option instructs the compiler to assume that pointer arithmetic
18100 overflow on addition and subtraction wraps around using twos-complement
18101 representation. This flag disables some optimizations which assume
18102 pointer overflow is invalid.
18104 @item -fstrict-overflow
18105 @opindex fstrict-overflow
18106 This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18107 negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18110 @opindex fexceptions
18111 Enable exception handling. Generates extra code needed to propagate
18112 exceptions. For some targets, this implies GCC generates frame
18113 unwind information for all functions, which can produce significant data
18114 size overhead, although it does not affect execution. If you do not
18115 specify this option, GCC enables it by default for languages like
18116 C++ that normally require exception handling, and disables it for
18117 languages like C that do not normally require it. However, you may need
18118 to enable this option when compiling C code that needs to interoperate
18119 properly with exception handlers written in C++. You may also wish to
18120 disable this option if you are compiling older C++ programs that don't
18121 use exception handling.
18123 @item -fnon-call-exceptions
18124 @opindex fnon-call-exceptions
18125 Generate code that allows trapping instructions to throw exceptions.
18126 Note that this requires platform-specific runtime support that does
18127 not exist everywhere. Moreover, it only allows @emph{trapping}
18128 instructions to throw exceptions, i.e.@: memory references or floating-point
18129 instructions. It does not allow exceptions to be thrown from
18130 arbitrary signal handlers such as @code{SIGALRM}. This enables
18131 @option{-fexceptions}.
18133 @item -fdelete-dead-exceptions
18134 @opindex fdelete-dead-exceptions
18135 Consider that instructions that may throw exceptions but don't otherwise
18136 contribute to the execution of the program can be optimized away.
18137 This does not affect calls to functions except those with the
18138 @code{pure} or @code{const} attributes.
18139 This option is enabled by default for the Ada and C++ compilers, as permitted by
18140 the language specifications.
18141 Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18143 @item -funwind-tables
18144 @opindex funwind-tables
18145 Similar to @option{-fexceptions}, except that it just generates any needed
18146 static data, but does not affect the generated code in any other way.
18147 You normally do not need to enable this option; instead, a language processor
18148 that needs this handling enables it on your behalf.
18150 @item -fasynchronous-unwind-tables
18151 @opindex fasynchronous-unwind-tables
18152 Generate unwind table in DWARF format, if supported by target machine. The
18153 table is exact at each instruction boundary, so it can be used for stack
18154 unwinding from asynchronous events (such as debugger or garbage collector).
18156 @item -fno-gnu-unique
18157 @opindex fno-gnu-unique
18158 @opindex fgnu-unique
18159 On systems with recent GNU assembler and C library, the C++ compiler
18160 uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18161 of template static data members and static local variables in inline
18162 functions are unique even in the presence of @code{RTLD_LOCAL}; this
18163 is necessary to avoid problems with a library used by two different
18164 @code{RTLD_LOCAL} plugins depending on a definition in one of them and
18165 therefore disagreeing with the other one about the binding of the
18166 symbol. But this causes @code{dlclose} to be ignored for affected
18167 DSOs; if your program relies on reinitialization of a DSO via
18168 @code{dlclose} and @code{dlopen}, you can use
18169 @option{-fno-gnu-unique}.
18171 @item -fpcc-struct-return
18172 @opindex fpcc-struct-return
18173 Return ``short'' @code{struct} and @code{union} values in memory like
18174 longer ones, rather than in registers. This convention is less
18175 efficient, but it has the advantage of allowing intercallability between
18176 GCC-compiled files and files compiled with other compilers, particularly
18177 the Portable C Compiler (pcc).
18179 The precise convention for returning structures in memory depends
18180 on the target configuration macros.
18182 Short structures and unions are those whose size and alignment match
18183 that of some integer type.
18185 @strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18186 switch is not binary compatible with code compiled with the
18187 @option{-freg-struct-return} switch.
18188 Use it to conform to a non-default application binary interface.
18190 @item -freg-struct-return
18191 @opindex freg-struct-return
18192 Return @code{struct} and @code{union} values in registers when possible.
18193 This is more efficient for small structures than
18194 @option{-fpcc-struct-return}.
18196 If you specify neither @option{-fpcc-struct-return} nor
18197 @option{-freg-struct-return}, GCC defaults to whichever convention is
18198 standard for the target. If there is no standard convention, GCC
18199 defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18200 the principal compiler. In those cases, we can choose the standard, and
18201 we chose the more efficient register return alternative.
18203 @strong{Warning:} code compiled with the @option{-freg-struct-return}
18204 switch is not binary compatible with code compiled with the
18205 @option{-fpcc-struct-return} switch.
18206 Use it to conform to a non-default application binary interface.
18208 @item -fshort-enums
18209 @opindex fshort-enums
18210 Allocate to an @code{enum} type only as many bytes as it needs for the
18211 declared range of possible values. Specifically, the @code{enum} type
18212 is equivalent to the smallest integer type that has enough room.
18214 @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18215 code that is not binary compatible with code generated without that switch.
18216 Use it to conform to a non-default application binary interface.
18218 @item -fshort-wchar
18219 @opindex fshort-wchar
18220 Override the underlying type for @code{wchar_t} to be @code{short
18221 unsigned int} instead of the default for the target. This option is
18222 useful for building programs to run under WINE@.
18224 @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18225 code that is not binary compatible with code generated without that switch.
18226 Use it to conform to a non-default application binary interface.
18230 @opindex fno-common
18231 @cindex tentative definitions
18232 In C code, this option controls the placement of global variables
18233 defined without an initializer, known as @dfn{tentative definitions}
18234 in the C standard. Tentative definitions are distinct from declarations
18235 of a variable with the @code{extern} keyword, which do not allocate storage.
18237 The default is @option{-fno-common}, which specifies that the compiler places
18238 uninitialized global variables in the BSS section of the object file.
18239 This inhibits the merging of tentative definitions by the linker so you get a
18240 multiple-definition error if the same variable is accidentally defined in more
18241 than one compilation unit.
18243 The @option{-fcommon} places uninitialized global variables in a common block.
18244 This allows the linker to resolve all tentative definitions of the same variable
18245 in different compilation units to the same object, or to a non-tentative
18246 definition. This behavior is inconsistent with C++, and on many targets implies
18247 a speed and code size penalty on global variable references. It is mainly
18248 useful to enable legacy code to link without errors.
18253 Ignore the @code{#ident} directive.
18255 @item -finhibit-size-directive
18256 @opindex finhibit-size-directive
18257 Don't output a @code{.size} assembler directive, or anything else that
18258 would cause trouble if the function is split in the middle, and the
18259 two halves are placed at locations far apart in memory. This option is
18260 used when compiling @file{crtstuff.c}; you should not need to use it
18263 @item -fverbose-asm
18264 @opindex fverbose-asm
18265 Put extra commentary information in the generated assembly code to
18266 make it more readable. This option is generally only of use to those
18267 who actually need to read the generated assembly code (perhaps while
18268 debugging the compiler itself).
18270 @option{-fno-verbose-asm}, the default, causes the
18271 extra information to be omitted and is useful when comparing two assembler
18274 The added comments include:
18279 information on the compiler version and command-line options,
18282 the source code lines associated with the assembly instructions,
18283 in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18286 hints on which high-level expressions correspond to
18287 the various assembly instruction operands.
18291 For example, given this C source file:
18299 for (i = 0; i < n; i++)
18306 compiling to (x86_64) assembly via @option{-S} and emitting the result
18307 direct to stdout via @option{-o} @option{-}
18310 gcc -S test.c -fverbose-asm -Os -o -
18313 gives output similar to this:
18317 # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18324 .type test, @@function
18328 # test.c:4: int total = 0;
18329 xorl %eax, %eax # <retval>
18330 # test.c:6: for (i = 0; i < n; i++)
18331 xorl %edx, %edx # i
18333 # test.c:6: for (i = 0; i < n; i++)
18334 cmpl %edi, %edx # n, i
18336 # test.c:7: total += i * i;
18337 movl %edx, %ecx # i, tmp92
18338 imull %edx, %ecx # i, tmp92
18339 # test.c:6: for (i = 0; i < n; i++)
18341 # test.c:7: total += i * i;
18342 addl %ecx, %eax # tmp92, <retval>
18350 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18351 .section .note.GNU-stack,"",@@progbits
18354 The comments are intended for humans rather than machines and hence the
18355 precise format of the comments is subject to change.
18357 @item -frecord-gcc-switches
18358 @opindex frecord-gcc-switches
18359 This switch causes the command line used to invoke the
18360 compiler to be recorded into the object file that is being created.
18361 This switch is only implemented on some targets and the exact format
18362 of the recording is target and binary file format dependent, but it
18363 usually takes the form of a section containing ASCII text. This
18364 switch is related to the @option{-fverbose-asm} switch, but that
18365 switch only records information in the assembler output file as
18366 comments, so it never reaches the object file.
18367 See also @option{-grecord-gcc-switches} for another
18368 way of storing compiler options into the object file.
18372 @cindex global offset table
18374 Generate position-independent code (PIC) suitable for use in a shared
18375 library, if supported for the target machine. Such code accesses all
18376 constant addresses through a global offset table (GOT)@. The dynamic
18377 loader resolves the GOT entries when the program starts (the dynamic
18378 loader is not part of GCC; it is part of the operating system). If
18379 the GOT size for the linked executable exceeds a machine-specific
18380 maximum size, you get an error message from the linker indicating that
18381 @option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18382 instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18383 on the m68k and RS/6000. The x86 has no such limit.)
18385 Position-independent code requires special support, and therefore works
18386 only on certain machines. For the x86, GCC supports PIC for System V
18387 but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18388 position-independent.
18390 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18395 If supported for the target machine, emit position-independent code,
18396 suitable for dynamic linking and avoiding any limit on the size of the
18397 global offset table. This option makes a difference on AArch64, m68k,
18398 PowerPC and SPARC@.
18400 Position-independent code requires special support, and therefore works
18401 only on certain machines.
18403 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18410 These options are similar to @option{-fpic} and @option{-fPIC}, but the
18411 generated position-independent code can be only linked into executables.
18412 Usually these options are used to compile code that will be linked using
18413 the @option{-pie} GCC option.
18415 @option{-fpie} and @option{-fPIE} both define the macros
18416 @code{__pie__} and @code{__PIE__}. The macros have the value 1
18417 for @option{-fpie} and 2 for @option{-fPIE}.
18422 Do not use the PLT for external function calls in position-independent code.
18423 Instead, load the callee address at call sites from the GOT and branch to it.
18424 This leads to more efficient code by eliminating PLT stubs and exposing
18425 GOT loads to optimizations. On architectures such as 32-bit x86 where
18426 PLT stubs expect the GOT pointer in a specific register, this gives more
18427 register allocation freedom to the compiler.
18428 Lazy binding requires use of the PLT;
18429 with @option{-fno-plt} all external symbols are resolved at load time.
18431 Alternatively, the function attribute @code{noplt} can be used to avoid calls
18432 through the PLT for specific external functions.
18434 In position-dependent code, a few targets also convert calls to
18435 functions that are marked to not use the PLT to use the GOT instead.
18437 @item -fno-jump-tables
18438 @opindex fno-jump-tables
18439 @opindex fjump-tables
18440 Do not use jump tables for switch statements even where it would be
18441 more efficient than other code generation strategies. This option is
18442 of use in conjunction with @option{-fpic} or @option{-fPIC} for
18443 building code that forms part of a dynamic linker and cannot
18444 reference the address of a jump table. On some targets, jump tables
18445 do not require a GOT and this option is not needed.
18447 @item -fno-bit-tests
18448 @opindex fno-bit-tests
18449 @opindex fbit-tests
18450 Do not use bit tests for switch statements even where it would be
18451 more efficient than other code generation strategies.
18453 @item -ffixed-@var{reg}
18455 Treat the register named @var{reg} as a fixed register; generated code
18456 should never refer to it (except perhaps as a stack pointer, frame
18457 pointer or in some other fixed role).
18459 @var{reg} must be the name of a register. The register names accepted
18460 are machine-specific and are defined in the @code{REGISTER_NAMES}
18461 macro in the machine description macro file.
18463 This flag does not have a negative form, because it specifies a
18466 @item -fcall-used-@var{reg}
18467 @opindex fcall-used
18468 Treat the register named @var{reg} as an allocable register that is
18469 clobbered by function calls. It may be allocated for temporaries or
18470 variables that do not live across a call. Functions compiled this way
18471 do not save and restore the register @var{reg}.
18473 It is an error to use this flag with the frame pointer or stack pointer.
18474 Use of this flag for other registers that have fixed pervasive roles in
18475 the machine's execution model produces disastrous results.
18477 This flag does not have a negative form, because it specifies a
18480 @item -fcall-saved-@var{reg}
18481 @opindex fcall-saved
18482 Treat the register named @var{reg} as an allocable register saved by
18483 functions. It may be allocated even for temporaries or variables that
18484 live across a call. Functions compiled this way save and restore
18485 the register @var{reg} if they use it.
18487 It is an error to use this flag with the frame pointer or stack pointer.
18488 Use of this flag for other registers that have fixed pervasive roles in
18489 the machine's execution model produces disastrous results.
18491 A different sort of disaster results from the use of this flag for
18492 a register in which function values may be returned.
18494 This flag does not have a negative form, because it specifies a
18497 @item -fpack-struct[=@var{n}]
18498 @opindex fpack-struct
18499 Without a value specified, pack all structure members together without
18500 holes. When a value is specified (which must be a small power of two), pack
18501 structure members according to this value, representing the maximum
18502 alignment (that is, objects with default alignment requirements larger than
18503 this are output potentially unaligned at the next fitting location.
18505 @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
18506 code that is not binary compatible with code generated without that switch.
18507 Additionally, it makes the code suboptimal.
18508 Use it to conform to a non-default application binary interface.
18510 @item -fleading-underscore
18511 @opindex fleading-underscore
18512 This option and its counterpart, @option{-fno-leading-underscore}, forcibly
18513 change the way C symbols are represented in the object file. One use
18514 is to help link with legacy assembly code.
18516 @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
18517 generate code that is not binary compatible with code generated without that
18518 switch. Use it to conform to a non-default application binary interface.
18519 Not all targets provide complete support for this switch.
18521 @item -ftls-model=@var{model}
18522 @opindex ftls-model
18523 Alter the thread-local storage model to be used (@pxref{Thread-Local}).
18524 The @var{model} argument should be one of @samp{global-dynamic},
18525 @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
18526 Note that the choice is subject to optimization: the compiler may use
18527 a more efficient model for symbols not visible outside of the translation
18528 unit, or if @option{-fpic} is not given on the command line.
18530 The default without @option{-fpic} is @samp{initial-exec}; with
18531 @option{-fpic} the default is @samp{global-dynamic}.
18533 @item -ftrampolines
18534 @opindex ftrampolines
18535 For targets that normally need trampolines for nested functions, always
18536 generate them instead of using descriptors. Otherwise, for targets that
18537 do not need them, like for example HP-PA or IA-64, do nothing.
18539 A trampoline is a small piece of code that is created at run time on the
18540 stack when the address of a nested function is taken, and is used to call
18541 the nested function indirectly. Therefore, it requires the stack to be
18542 made executable in order for the program to work properly.
18544 @option{-fno-trampolines} is enabled by default on a language by language
18545 basis to let the compiler avoid generating them, if it computes that this
18546 is safe, and replace them with descriptors. Descriptors are made up of data
18547 only, but the generated code must be prepared to deal with them. As of this
18548 writing, @option{-fno-trampolines} is enabled by default only for Ada.
18550 Moreover, code compiled with @option{-ftrampolines} and code compiled with
18551 @option{-fno-trampolines} are not binary compatible if nested functions are
18552 present. This option must therefore be used on a program-wide basis and be
18553 manipulated with extreme care.
18555 For languages other than Ada, the @code{-ftrampolines} and
18556 @code{-fno-trampolines} options currently have no effect, and
18557 trampolines are always generated on platforms that need them
18558 for nested functions.
18560 @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
18561 @opindex fvisibility
18562 Set the default ELF image symbol visibility to the specified option---all
18563 symbols are marked with this unless overridden within the code.
18564 Using this feature can very substantially improve linking and
18565 load times of shared object libraries, produce more optimized
18566 code, provide near-perfect API export and prevent symbol clashes.
18567 It is @strong{strongly} recommended that you use this in any shared objects
18570 Despite the nomenclature, @samp{default} always means public; i.e.,
18571 available to be linked against from outside the shared object.
18572 @samp{protected} and @samp{internal} are pretty useless in real-world
18573 usage so the only other commonly used option is @samp{hidden}.
18574 The default if @option{-fvisibility} isn't specified is
18575 @samp{default}, i.e., make every symbol public.
18577 A good explanation of the benefits offered by ensuring ELF
18578 symbols have the correct visibility is given by ``How To Write
18579 Shared Libraries'' by Ulrich Drepper (which can be found at
18580 @w{@uref{https://www.akkadia.org/drepper/}})---however a superior
18581 solution made possible by this option to marking things hidden when
18582 the default is public is to make the default hidden and mark things
18583 public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
18584 and @code{__attribute__ ((visibility("default")))} instead of
18585 @code{__declspec(dllexport)} you get almost identical semantics with
18586 identical syntax. This is a great boon to those working with
18587 cross-platform projects.
18589 For those adding visibility support to existing code, you may find
18590 @code{#pragma GCC visibility} of use. This works by you enclosing
18591 the declarations you wish to set visibility for with (for example)
18592 @code{#pragma GCC visibility push(hidden)} and
18593 @code{#pragma GCC visibility pop}.
18594 Bear in mind that symbol visibility should be viewed @strong{as
18595 part of the API interface contract} and thus all new code should
18596 always specify visibility when it is not the default; i.e., declarations
18597 only for use within the local DSO should @strong{always} be marked explicitly
18598 as hidden as so to avoid PLT indirection overheads---making this
18599 abundantly clear also aids readability and self-documentation of the code.
18600 Note that due to ISO C++ specification requirements, @code{operator new} and
18601 @code{operator delete} must always be of default visibility.
18603 Be aware that headers from outside your project, in particular system
18604 headers and headers from any other library you use, may not be
18605 expecting to be compiled with visibility other than the default. You
18606 may need to explicitly say @code{#pragma GCC visibility push(default)}
18607 before including any such headers.
18609 @code{extern} declarations are not affected by @option{-fvisibility}, so
18610 a lot of code can be recompiled with @option{-fvisibility=hidden} with
18611 no modifications. However, this means that calls to @code{extern}
18612 functions with no explicit visibility use the PLT, so it is more
18613 effective to use @code{__attribute ((visibility))} and/or
18614 @code{#pragma GCC visibility} to tell the compiler which @code{extern}
18615 declarations should be treated as hidden.
18617 Note that @option{-fvisibility} does affect C++ vague linkage
18618 entities. This means that, for instance, an exception class that is
18619 be thrown between DSOs must be explicitly marked with default
18620 visibility so that the @samp{type_info} nodes are unified between
18623 An overview of these techniques, their benefits and how to use them
18624 is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
18626 @item -fstrict-volatile-bitfields
18627 @opindex fstrict-volatile-bitfields
18628 This option should be used if accesses to volatile bit-fields (or other
18629 structure fields, although the compiler usually honors those types
18630 anyway) should use a single access of the width of the
18631 field's type, aligned to a natural alignment if possible. For
18632 example, targets with memory-mapped peripheral registers might require
18633 all such accesses to be 16 bits wide; with this flag you can
18634 declare all peripheral bit-fields as @code{unsigned short} (assuming short
18635 is 16 bits on these targets) to force GCC to use 16-bit accesses
18636 instead of, perhaps, a more efficient 32-bit access.
18638 If this option is disabled, the compiler uses the most efficient
18639 instruction. In the previous example, that might be a 32-bit load
18640 instruction, even though that accesses bytes that do not contain
18641 any portion of the bit-field, or memory-mapped registers unrelated to
18642 the one being updated.
18644 In some cases, such as when the @code{packed} attribute is applied to a
18645 structure field, it may not be possible to access the field with a single
18646 read or write that is correctly aligned for the target machine. In this
18647 case GCC falls back to generating multiple accesses rather than code that
18648 will fault or truncate the result at run time.
18650 Note: Due to restrictions of the C/C++11 memory model, write accesses are
18651 not allowed to touch non bit-field members. It is therefore recommended
18652 to define all bits of the field's type as bit-field members.
18654 The default value of this option is determined by the application binary
18655 interface for the target processor.
18657 @item -fsync-libcalls
18658 @opindex fsync-libcalls
18659 This option controls whether any out-of-line instance of the @code{__sync}
18660 family of functions may be used to implement the C++11 @code{__atomic}
18661 family of functions.
18663 The default value of this option is enabled, thus the only useful form
18664 of the option is @option{-fno-sync-libcalls}. This option is used in
18665 the implementation of the @file{libatomic} runtime library.
18669 @node Developer Options
18670 @section GCC Developer Options
18671 @cindex developer options
18672 @cindex debugging GCC
18673 @cindex debug dump options
18674 @cindex dump options
18675 @cindex compilation statistics
18677 This section describes command-line options that are primarily of
18678 interest to GCC developers, including options to support compiler
18679 testing and investigation of compiler bugs and compile-time
18680 performance problems. This includes options that produce debug dumps
18681 at various points in the compilation; that print statistics such as
18682 memory use and execution time; and that print information about GCC's
18683 configuration, such as where it searches for libraries. You should
18684 rarely need to use any of these options for ordinary compilation and
18687 Many developer options that cause GCC to dump output to a file take an
18688 optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
18689 or @samp{-} to dump to standard output, and @samp{stderr} for standard
18692 If @samp{=@var{filename}} is omitted, a default dump file name is
18693 constructed by concatenating the base dump file name, a pass number,
18694 phase letter, and pass name. The base dump file name is the name of
18695 output file produced by the compiler if explicitly specified and not
18696 an executable; otherwise it is the source file name.
18697 The pass number is determined by the order passes are registered with
18698 the compiler's pass manager.
18699 This is generally the same as the order of execution, but passes
18700 registered by plugins, target-specific passes, or passes that are
18701 otherwise registered late are numbered higher than the pass named
18702 @samp{final}, even if they are executed earlier. The phase letter is
18703 one of @samp{i} (inter-procedural analysis), @samp{l}
18704 (language-specific), @samp{r} (RTL), or @samp{t} (tree).
18705 The files are created in the directory of the output file.
18709 @item -fcallgraph-info
18710 @itemx -fcallgraph-info=@var{MARKERS}
18711 @opindex fcallgraph-info
18712 Makes the compiler output callgraph information for the program, on a
18713 per-object-file basis. The information is generated in the common VCG
18714 format. It can be decorated with additional, per-node and/or per-edge
18715 information, if a list of comma-separated markers is additionally
18716 specified. When the @code{su} marker is specified, the callgraph is
18717 decorated with stack usage information; it is equivalent to
18718 @option{-fstack-usage}. When the @code{da} marker is specified, the
18719 callgraph is decorated with information about dynamically allocated
18722 When compiling with @option{-flto}, no callgraph information is output
18723 along with the object file. At LTO link time, @option{-fcallgraph-info}
18724 may generate multiple callgraph information files next to intermediate
18727 @item -d@var{letters}
18728 @itemx -fdump-rtl-@var{pass}
18729 @itemx -fdump-rtl-@var{pass}=@var{filename}
18731 @opindex fdump-rtl-@var{pass}
18732 Says to make debugging dumps during compilation at times specified by
18733 @var{letters}. This is used for debugging the RTL-based passes of the
18736 Some @option{-d@var{letters}} switches have different meaning when
18737 @option{-E} is used for preprocessing. @xref{Preprocessor Options},
18738 for information about preprocessor-specific dump options.
18740 Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
18741 @option{-d} option @var{letters}. Here are the possible
18742 letters for use in @var{pass} and @var{letters}, and their meanings:
18746 @item -fdump-rtl-alignments
18747 @opindex fdump-rtl-alignments
18748 Dump after branch alignments have been computed.
18750 @item -fdump-rtl-asmcons
18751 @opindex fdump-rtl-asmcons
18752 Dump after fixing rtl statements that have unsatisfied in/out constraints.
18754 @item -fdump-rtl-auto_inc_dec
18755 @opindex fdump-rtl-auto_inc_dec
18756 Dump after auto-inc-dec discovery. This pass is only run on
18757 architectures that have auto inc or auto dec instructions.
18759 @item -fdump-rtl-barriers
18760 @opindex fdump-rtl-barriers
18761 Dump after cleaning up the barrier instructions.
18763 @item -fdump-rtl-bbpart
18764 @opindex fdump-rtl-bbpart
18765 Dump after partitioning hot and cold basic blocks.
18767 @item -fdump-rtl-bbro
18768 @opindex fdump-rtl-bbro
18769 Dump after block reordering.
18771 @item -fdump-rtl-btl1
18772 @itemx -fdump-rtl-btl2
18773 @opindex fdump-rtl-btl2
18774 @opindex fdump-rtl-btl2
18775 @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
18776 after the two branch
18777 target load optimization passes.
18779 @item -fdump-rtl-bypass
18780 @opindex fdump-rtl-bypass
18781 Dump after jump bypassing and control flow optimizations.
18783 @item -fdump-rtl-combine
18784 @opindex fdump-rtl-combine
18785 Dump after the RTL instruction combination pass.
18787 @item -fdump-rtl-compgotos
18788 @opindex fdump-rtl-compgotos
18789 Dump after duplicating the computed gotos.
18791 @item -fdump-rtl-ce1
18792 @itemx -fdump-rtl-ce2
18793 @itemx -fdump-rtl-ce3
18794 @opindex fdump-rtl-ce1
18795 @opindex fdump-rtl-ce2
18796 @opindex fdump-rtl-ce3
18797 @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
18798 @option{-fdump-rtl-ce3} enable dumping after the three
18799 if conversion passes.
18801 @item -fdump-rtl-cprop_hardreg
18802 @opindex fdump-rtl-cprop_hardreg
18803 Dump after hard register copy propagation.
18805 @item -fdump-rtl-csa
18806 @opindex fdump-rtl-csa
18807 Dump after combining stack adjustments.
18809 @item -fdump-rtl-cse1
18810 @itemx -fdump-rtl-cse2
18811 @opindex fdump-rtl-cse1
18812 @opindex fdump-rtl-cse2
18813 @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
18814 the two common subexpression elimination passes.
18816 @item -fdump-rtl-dce
18817 @opindex fdump-rtl-dce
18818 Dump after the standalone dead code elimination passes.
18820 @item -fdump-rtl-dbr
18821 @opindex fdump-rtl-dbr
18822 Dump after delayed branch scheduling.
18824 @item -fdump-rtl-dce1
18825 @itemx -fdump-rtl-dce2
18826 @opindex fdump-rtl-dce1
18827 @opindex fdump-rtl-dce2
18828 @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
18829 the two dead store elimination passes.
18831 @item -fdump-rtl-eh
18832 @opindex fdump-rtl-eh
18833 Dump after finalization of EH handling code.
18835 @item -fdump-rtl-eh_ranges
18836 @opindex fdump-rtl-eh_ranges
18837 Dump after conversion of EH handling range regions.
18839 @item -fdump-rtl-expand
18840 @opindex fdump-rtl-expand
18841 Dump after RTL generation.
18843 @item -fdump-rtl-fwprop1
18844 @itemx -fdump-rtl-fwprop2
18845 @opindex fdump-rtl-fwprop1
18846 @opindex fdump-rtl-fwprop2
18847 @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
18848 dumping after the two forward propagation passes.
18850 @item -fdump-rtl-gcse1
18851 @itemx -fdump-rtl-gcse2
18852 @opindex fdump-rtl-gcse1
18853 @opindex fdump-rtl-gcse2
18854 @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
18855 after global common subexpression elimination.
18857 @item -fdump-rtl-init-regs
18858 @opindex fdump-rtl-init-regs
18859 Dump after the initialization of the registers.
18861 @item -fdump-rtl-initvals
18862 @opindex fdump-rtl-initvals
18863 Dump after the computation of the initial value sets.
18865 @item -fdump-rtl-into_cfglayout
18866 @opindex fdump-rtl-into_cfglayout
18867 Dump after converting to cfglayout mode.
18869 @item -fdump-rtl-ira
18870 @opindex fdump-rtl-ira
18871 Dump after iterated register allocation.
18873 @item -fdump-rtl-jump
18874 @opindex fdump-rtl-jump
18875 Dump after the second jump optimization.
18877 @item -fdump-rtl-loop2
18878 @opindex fdump-rtl-loop2
18879 @option{-fdump-rtl-loop2} enables dumping after the rtl
18880 loop optimization passes.
18882 @item -fdump-rtl-mach
18883 @opindex fdump-rtl-mach
18884 Dump after performing the machine dependent reorganization pass, if that
18887 @item -fdump-rtl-mode_sw
18888 @opindex fdump-rtl-mode_sw
18889 Dump after removing redundant mode switches.
18891 @item -fdump-rtl-rnreg
18892 @opindex fdump-rtl-rnreg
18893 Dump after register renumbering.
18895 @item -fdump-rtl-outof_cfglayout
18896 @opindex fdump-rtl-outof_cfglayout
18897 Dump after converting from cfglayout mode.
18899 @item -fdump-rtl-peephole2
18900 @opindex fdump-rtl-peephole2
18901 Dump after the peephole pass.
18903 @item -fdump-rtl-postreload
18904 @opindex fdump-rtl-postreload
18905 Dump after post-reload optimizations.
18907 @item -fdump-rtl-pro_and_epilogue
18908 @opindex fdump-rtl-pro_and_epilogue
18909 Dump after generating the function prologues and epilogues.
18911 @item -fdump-rtl-sched1
18912 @itemx -fdump-rtl-sched2
18913 @opindex fdump-rtl-sched1
18914 @opindex fdump-rtl-sched2
18915 @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
18916 after the basic block scheduling passes.
18918 @item -fdump-rtl-ree
18919 @opindex fdump-rtl-ree
18920 Dump after sign/zero extension elimination.
18922 @item -fdump-rtl-seqabstr
18923 @opindex fdump-rtl-seqabstr
18924 Dump after common sequence discovery.
18926 @item -fdump-rtl-shorten
18927 @opindex fdump-rtl-shorten
18928 Dump after shortening branches.
18930 @item -fdump-rtl-sibling
18931 @opindex fdump-rtl-sibling
18932 Dump after sibling call optimizations.
18934 @item -fdump-rtl-split1
18935 @itemx -fdump-rtl-split2
18936 @itemx -fdump-rtl-split3
18937 @itemx -fdump-rtl-split4
18938 @itemx -fdump-rtl-split5
18939 @opindex fdump-rtl-split1
18940 @opindex fdump-rtl-split2
18941 @opindex fdump-rtl-split3
18942 @opindex fdump-rtl-split4
18943 @opindex fdump-rtl-split5
18944 These options enable dumping after five rounds of
18945 instruction splitting.
18947 @item -fdump-rtl-sms
18948 @opindex fdump-rtl-sms
18949 Dump after modulo scheduling. This pass is only run on some
18952 @item -fdump-rtl-stack
18953 @opindex fdump-rtl-stack
18954 Dump after conversion from GCC's ``flat register file'' registers to the
18955 x87's stack-like registers. This pass is only run on x86 variants.
18957 @item -fdump-rtl-subreg1
18958 @itemx -fdump-rtl-subreg2
18959 @opindex fdump-rtl-subreg1
18960 @opindex fdump-rtl-subreg2
18961 @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
18962 the two subreg expansion passes.
18964 @item -fdump-rtl-unshare
18965 @opindex fdump-rtl-unshare
18966 Dump after all rtl has been unshared.
18968 @item -fdump-rtl-vartrack
18969 @opindex fdump-rtl-vartrack
18970 Dump after variable tracking.
18972 @item -fdump-rtl-vregs
18973 @opindex fdump-rtl-vregs
18974 Dump after converting virtual registers to hard registers.
18976 @item -fdump-rtl-web
18977 @opindex fdump-rtl-web
18978 Dump after live range splitting.
18980 @item -fdump-rtl-regclass
18981 @itemx -fdump-rtl-subregs_of_mode_init
18982 @itemx -fdump-rtl-subregs_of_mode_finish
18983 @itemx -fdump-rtl-dfinit
18984 @itemx -fdump-rtl-dfinish
18985 @opindex fdump-rtl-regclass
18986 @opindex fdump-rtl-subregs_of_mode_init
18987 @opindex fdump-rtl-subregs_of_mode_finish
18988 @opindex fdump-rtl-dfinit
18989 @opindex fdump-rtl-dfinish
18990 These dumps are defined but always produce empty files.
18993 @itemx -fdump-rtl-all
18995 @opindex fdump-rtl-all
18996 Produce all the dumps listed above.
19000 Annotate the assembler output with miscellaneous debugging information.
19004 Dump all macro definitions, at the end of preprocessing, in addition to
19009 Produce a core dump whenever an error occurs.
19013 Annotate the assembler output with a comment indicating which
19014 pattern and alternative is used. The length and cost of each instruction are
19019 Dump the RTL in the assembler output as a comment before each instruction.
19020 Also turns on @option{-dp} annotation.
19024 Just generate RTL for a function instead of compiling it. Usually used
19025 with @option{-fdump-rtl-expand}.
19029 @opindex fdump-debug
19030 Dump debugging information generated during the debug
19033 @item -fdump-earlydebug
19034 @opindex fdump-earlydebug
19035 Dump debugging information generated during the early debug
19038 @item -fdump-noaddr
19039 @opindex fdump-noaddr
19040 When doing debugging dumps, suppress address output. This makes it more
19041 feasible to use diff on debugging dumps for compiler invocations with
19042 different compiler binaries and/or different
19043 text / bss / data / heap / stack / dso start locations.
19046 @opindex freport-bug
19047 Collect and dump debug information into a temporary file if an
19048 internal compiler error (ICE) occurs.
19050 @item -fdump-unnumbered
19051 @opindex fdump-unnumbered
19052 When doing debugging dumps, suppress instruction numbers and address output.
19053 This makes it more feasible to use diff on debugging dumps for compiler
19054 invocations with different options, in particular with and without
19057 @item -fdump-unnumbered-links
19058 @opindex fdump-unnumbered-links
19059 When doing debugging dumps (see @option{-d} option above), suppress
19060 instruction numbers for the links to the previous and next instructions
19063 @item -fdump-ipa-@var{switch}
19064 @itemx -fdump-ipa-@var{switch}-@var{options}
19066 Control the dumping at various stages of inter-procedural analysis
19067 language tree to a file. The file name is generated by appending a
19068 switch specific suffix to the source file name, and the file is created
19069 in the same directory as the output file. The following dumps are
19074 Enables all inter-procedural analysis dumps.
19077 Dumps information about call-graph optimization, unused function removal,
19078 and inlining decisions.
19081 Dump after function inlining.
19085 Additionally, the options @option{-optimized}, @option{-missed},
19086 @option{-note}, and @option{-all} can be provided, with the same meaning
19087 as for @option{-fopt-info}, defaulting to @option{-optimized}.
19089 For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19090 information on callsites that were inlined, along with callsites
19091 that were not inlined.
19093 By default, the dump will contain messages about successful
19094 optimizations (equivalent to @option{-optimized}) together with
19095 low-level details about the analysis.
19098 @opindex fdump-lang
19099 Dump language-specific information. The file name is made by appending
19100 @file{.lang} to the source file name.
19102 @item -fdump-lang-all
19103 @itemx -fdump-lang-@var{switch}
19104 @itemx -fdump-lang-@var{switch}-@var{options}
19105 @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
19106 @opindex fdump-lang-all
19107 @opindex fdump-lang
19108 Control the dumping of language-specific information. The @var{options}
19109 and @var{filename} portions behave as described in the
19110 @option{-fdump-tree} option. The following @var{switch} values are
19116 Enable all language-specific dumps.
19119 Dump class hierarchy information. Virtual table information is emitted
19120 unless '@option{slim}' is specified. This option is applicable to C++ only.
19123 Dump module information. Options @option{lineno} (locations),
19124 @option{graph} (reachability), @option{blocks} (clusters),
19125 @option{uid} (serialization), @option{alias} (mergeable),
19126 @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19127 (macros) may provide additional information. This option is
19128 applicable to C++ only.
19131 Dump the raw internal tree data. This option is applicable to C++ only.
19135 @item -fdump-passes
19136 @opindex fdump-passes
19137 Print on @file{stderr} the list of optimization passes that are turned
19138 on and off by the current command-line options.
19140 @item -fdump-statistics-@var{option}
19141 @opindex fdump-statistics
19142 Enable and control dumping of pass statistics in a separate file. The
19143 file name is generated by appending a suffix ending in
19144 @samp{.statistics} to the source file name, and the file is created in
19145 the same directory as the output file. If the @samp{-@var{option}}
19146 form is used, @samp{-stats} causes counters to be summed over the
19147 whole compilation unit while @samp{-details} dumps every event as
19148 the passes generate them. The default with no option is to sum
19149 counters for each function compiled.
19151 @item -fdump-tree-all
19152 @itemx -fdump-tree-@var{switch}
19153 @itemx -fdump-tree-@var{switch}-@var{options}
19154 @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
19155 @opindex fdump-tree-all
19156 @opindex fdump-tree
19157 Control the dumping at various stages of processing the intermediate
19158 language tree to a file. If the @samp{-@var{options}}
19159 form is used, @var{options} is a list of @samp{-} separated options
19160 which control the details of the dump. Not all options are applicable
19161 to all dumps; those that are not meaningful are ignored. The
19162 following options are available
19166 Print the address of each node. Usually this is not meaningful as it
19167 changes according to the environment and source file. Its primary use
19168 is for tying up a dump file with a debug environment.
19170 If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19171 in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19172 use working backward from mangled names in the assembly file.
19174 When dumping front-end intermediate representations, inhibit dumping
19175 of members of a scope or body of a function merely because that scope
19176 has been reached. Only dump such items when they are directly reachable
19177 by some other path.
19179 When dumping pretty-printed trees, this option inhibits dumping the
19180 bodies of control structures.
19182 When dumping RTL, print the RTL in slim (condensed) form instead of
19183 the default LISP-like representation.
19185 Print a raw representation of the tree. By default, trees are
19186 pretty-printed into a C-like representation.
19188 Enable more detailed dumps (not honored by every dump option). Also
19189 include information from the optimization passes.
19191 Enable dumping various statistics about the pass (not honored by every dump
19194 Enable showing basic block boundaries (disabled in raw dumps).
19196 For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19197 dump a representation of the control flow graph suitable for viewing with
19198 GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19199 the file is pretty-printed as a subgraph, so that GraphViz can render them
19200 all in a single plot.
19202 This option currently only works for RTL dumps, and the RTL is always
19203 dumped in slim form.
19205 Enable showing virtual operands for every statement.
19207 Enable showing line numbers for statements.
19209 Enable showing the unique ID (@code{DECL_UID}) for each variable.
19211 Enable showing the tree dump for each statement.
19213 Enable showing the EH region number holding each statement.
19215 Enable showing scalar evolution analysis details.
19217 Enable showing optimization information (only available in certain
19220 Enable showing missed optimization information (only available in certain
19223 Enable other detailed optimization information (only available in
19226 Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19227 and @option{lineno}.
19229 Turn on all optimization options, i.e., @option{optimized},
19230 @option{missed}, and @option{note}.
19233 To determine what tree dumps are available or find the dump for a pass
19234 of interest follow the steps below.
19238 Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19239 look for a code that corresponds to the pass you are interested in.
19240 For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19241 @code{tree-vrp2} correspond to the three Value Range Propagation passes.
19242 The number at the end distinguishes distinct invocations of the same pass.
19244 To enable the creation of the dump file, append the pass code to
19245 the @option{-fdump-} option prefix and invoke GCC with it. For example,
19246 to enable the dump from the Early Value Range Propagation pass, invoke
19247 GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19248 specify the name of the dump file. If you don't specify one, GCC
19249 creates as described below.
19251 Find the pass dump in a file whose name is composed of three components
19252 separated by a period: the name of the source file GCC was invoked to
19253 compile, a numeric suffix indicating the pass number followed by the
19254 letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19255 and finally the pass code. For example, the Early VRP pass dump might
19256 be in a file named @file{myfile.c.038t.evrp} in the current working
19257 directory. Note that the numeric codes are not stable and may change
19258 from one version of GCC to another.
19262 @itemx -fopt-info-@var{options}
19263 @itemx -fopt-info-@var{options}=@var{filename}
19265 Controls optimization dumps from various optimization passes. If the
19266 @samp{-@var{options}} form is used, @var{options} is a list of
19267 @samp{-} separated option keywords to select the dump details and
19270 The @var{options} can be divided into three groups:
19273 options describing what kinds of messages should be emitted,
19275 options describing the verbosity of the dump, and
19277 options describing which optimizations should be included.
19279 The options from each group can be freely mixed as they are
19280 non-overlapping. However, in case of any conflicts,
19281 the later options override the earlier options on the command
19284 The following options control which kinds of messages should be emitted:
19288 Print information when an optimization is successfully applied. It is
19289 up to a pass to decide which information is relevant. For example, the
19290 vectorizer passes print the source location of loops which are
19291 successfully vectorized.
19293 Print information about missed optimizations. Individual passes
19294 control which information to include in the output.
19296 Print verbose information about optimizations, such as certain
19297 transformations, more detailed messages about decisions etc.
19299 Print detailed optimization information. This includes
19300 @samp{optimized}, @samp{missed}, and @samp{note}.
19303 The following option controls the dump verbosity:
19307 By default, only ``high-level'' messages are emitted. This option enables
19308 additional, more detailed, messages, which are likely to only be of interest
19312 One or more of the following option keywords can be used to describe a
19313 group of optimizations:
19317 Enable dumps from all interprocedural optimizations.
19319 Enable dumps from all loop optimizations.
19321 Enable dumps from all inlining optimizations.
19323 Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19325 Enable dumps from all vectorization optimizations.
19327 Enable dumps from all optimizations. This is a superset of
19328 the optimization groups listed above.
19331 If @var{options} is
19332 omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19333 about successful optimizations from all the passes, omitting messages
19334 that are treated as ``internals''.
19336 If the @var{filename} is provided, then the dumps from all the
19337 applicable optimizations are concatenated into the @var{filename}.
19338 Otherwise the dump is output onto @file{stderr}. Though multiple
19339 @option{-fopt-info} options are accepted, only one of them can include
19340 a @var{filename}. If other filenames are provided then all but the
19341 first such option are ignored.
19343 Note that the output @var{filename} is overwritten
19344 in case of multiple translation units. If a combined output from
19345 multiple translation units is desired, @file{stderr} should be used
19348 In the following example, the optimization info is output to
19357 gcc -O3 -fopt-info-missed=missed.all
19361 outputs missed optimization report from all the passes into
19362 @file{missed.all}, and this one:
19365 gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19369 prints information about missed optimization opportunities from
19370 vectorization passes on @file{stderr}.
19371 Note that @option{-fopt-info-vec-missed} is equivalent to
19372 @option{-fopt-info-missed-vec}. The order of the optimization group
19373 names and message types listed after @option{-fopt-info} does not matter.
19375 As another example,
19377 gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19381 outputs information about missed optimizations as well as
19382 optimized locations from all the inlining passes into
19388 gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19392 Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19393 in conflict since only one output file is allowed. In this case, only
19394 the first option takes effect and the subsequent options are
19395 ignored. Thus only @file{vec.miss} is produced which contains
19396 dumps from the vectorizer about missed opportunities.
19398 @item -fsave-optimization-record
19399 @opindex fsave-optimization-record
19400 Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19401 were performed, for those optimizations that support @option{-fopt-info}.
19403 This option is experimental and the format of the data within the
19404 compressed JSON file is subject to change.
19406 It is roughly equivalent to a machine-readable version of
19407 @option{-fopt-info-all}, as a collection of messages with source file,
19408 line number and column number, with the following additional data for
19414 the execution count of the code being optimized, along with metadata about
19415 whether this was from actual profile data, or just an estimate, allowing
19416 consumers to prioritize messages by code hotness,
19419 the function name of the code being optimized, where applicable,
19422 the ``inlining chain'' for the code being optimized, so that when
19423 a function is inlined into several different places (which might
19424 themselves be inlined), the reader can distinguish between the copies,
19427 objects identifying those parts of the message that refer to expressions,
19428 statements or symbol-table nodes, which of these categories they are, and,
19429 when available, their source code location,
19432 the GCC pass that emitted the message, and
19435 the location in GCC's own code from which the message was emitted
19439 Additionally, some messages are logically nested within other
19440 messages, reflecting implementation details of the optimization
19443 @item -fsched-verbose=@var{n}
19444 @opindex fsched-verbose
19445 On targets that use instruction scheduling, this option controls the
19446 amount of debugging output the scheduler prints to the dump files.
19448 For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19449 same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19450 For @var{n} greater than one, it also output basic block probabilities,
19451 detailed ready list information and unit/insn info. For @var{n} greater
19452 than two, it includes RTL at abort point, control-flow and regions info.
19453 And for @var{n} over four, @option{-fsched-verbose} also includes
19458 @item -fenable-@var{kind}-@var{pass}
19459 @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
19463 This is a set of options that are used to explicitly disable/enable
19464 optimization passes. These options are intended for use for debugging GCC.
19465 Compiler users should use regular options for enabling/disabling
19470 @item -fdisable-ipa-@var{pass}
19471 Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19472 statically invoked in the compiler multiple times, the pass name should be
19473 appended with a sequential number starting from 1.
19475 @item -fdisable-rtl-@var{pass}
19476 @itemx -fdisable-rtl-@var{pass}=@var{range-list}
19477 Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
19478 statically invoked in the compiler multiple times, the pass name should be
19479 appended with a sequential number starting from 1. @var{range-list} is a
19480 comma-separated list of function ranges or assembler names. Each range is a number
19481 pair separated by a colon. The range is inclusive in both ends. If the range
19482 is trivial, the number pair can be simplified as a single number. If the
19483 function's call graph node's @var{uid} falls within one of the specified ranges,
19484 the @var{pass} is disabled for that function. The @var{uid} is shown in the
19485 function header of a dump file, and the pass names can be dumped by using
19486 option @option{-fdump-passes}.
19488 @item -fdisable-tree-@var{pass}
19489 @itemx -fdisable-tree-@var{pass}=@var{range-list}
19490 Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
19493 @item -fenable-ipa-@var{pass}
19494 Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19495 statically invoked in the compiler multiple times, the pass name should be
19496 appended with a sequential number starting from 1.
19498 @item -fenable-rtl-@var{pass}
19499 @itemx -fenable-rtl-@var{pass}=@var{range-list}
19500 Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
19501 description and examples.
19503 @item -fenable-tree-@var{pass}
19504 @itemx -fenable-tree-@var{pass}=@var{range-list}
19505 Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
19506 of option arguments.
19510 Here are some examples showing uses of these options.
19514 # disable ccp1 for all functions
19515 -fdisable-tree-ccp1
19516 # disable complete unroll for function whose cgraph node uid is 1
19517 -fenable-tree-cunroll=1
19518 # disable gcse2 for functions at the following ranges [1,1],
19519 # [300,400], and [400,1000]
19520 # disable gcse2 for functions foo and foo2
19521 -fdisable-rtl-gcse2=foo,foo2
19522 # disable early inlining
19523 -fdisable-tree-einline
19524 # disable ipa inlining
19525 -fdisable-ipa-inline
19526 # enable tree full unroll
19527 -fenable-tree-unroll
19532 @itemx -fchecking=@var{n}
19534 @opindex fno-checking
19535 Enable internal consistency checking. The default depends on
19536 the compiler configuration. @option{-fchecking=2} enables further
19537 internal consistency checking that might affect code generation.
19539 @item -frandom-seed=@var{string}
19540 @opindex frandom-seed
19541 This option provides a seed that GCC uses in place of
19542 random numbers in generating certain symbol names
19543 that have to be different in every compiled file. It is also used to
19544 place unique stamps in coverage data files and the object files that
19545 produce them. You can use the @option{-frandom-seed} option to produce
19546 reproducibly identical object files.
19548 The @var{string} can either be a number (decimal, octal or hex) or an
19549 arbitrary string (in which case it's converted to a number by
19552 The @var{string} should be different for every file you compile.
19555 @opindex save-temps
19556 Store the usual ``temporary'' intermediate files permanently; name them
19557 as auxiliary output files, as specified described under
19558 @option{-dumpbase} and @option{-dumpdir}.
19560 When used in combination with the @option{-x} command-line option,
19561 @option{-save-temps} is sensible enough to avoid overwriting an
19562 input source file with the same extension as an intermediate file.
19563 The corresponding intermediate file may be obtained by renaming the
19564 source file before using @option{-save-temps}.
19566 @item -save-temps=cwd
19567 @opindex save-temps=cwd
19568 Equivalent to @option{-save-temps -dumpdir ./}.
19570 @item -save-temps=obj
19571 @opindex save-temps=obj
19572 Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
19573 @file{outdir/} is the directory of the output file specified after the
19574 @option{-o} option, including any directory separators. If the
19575 @option{-o} option is not used, the @option{-save-temps=obj} switch
19576 behaves like @option{-save-temps=cwd}.
19578 @item -time@r{[}=@var{file}@r{]}
19580 Report the CPU time taken by each subprocess in the compilation
19581 sequence. For C source files, this is the compiler proper and assembler
19582 (plus the linker if linking is done).
19584 Without the specification of an output file, the output looks like this:
19591 The first number on each line is the ``user time'', that is time spent
19592 executing the program itself. The second number is ``system time'',
19593 time spent executing operating system routines on behalf of the program.
19594 Both numbers are in seconds.
19596 With the specification of an output file, the output is appended to the
19597 named file, and it looks like this:
19600 0.12 0.01 cc1 @var{options}
19601 0.00 0.01 as @var{options}
19604 The ``user time'' and the ``system time'' are moved before the program
19605 name, and the options passed to the program are displayed, so that one
19606 can later tell what file was being compiled, and with which options.
19608 @item -fdump-final-insns@r{[}=@var{file}@r{]}
19609 @opindex fdump-final-insns
19610 Dump the final internal representation (RTL) to @var{file}. If the
19611 optional argument is omitted (or if @var{file} is @code{.}), the name
19612 of the dump file is determined by appending @code{.gkd} to the
19613 dump base name, see @option{-dumpbase}.
19615 @item -fcompare-debug@r{[}=@var{opts}@r{]}
19616 @opindex fcompare-debug
19617 @opindex fno-compare-debug
19618 If no error occurs during compilation, run the compiler a second time,
19619 adding @var{opts} and @option{-fcompare-debug-second} to the arguments
19620 passed to the second compilation. Dump the final internal
19621 representation in both compilations, and print an error if they differ.
19623 If the equal sign is omitted, the default @option{-gtoggle} is used.
19625 The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
19626 and nonzero, implicitly enables @option{-fcompare-debug}. If
19627 @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
19628 then it is used for @var{opts}, otherwise the default @option{-gtoggle}
19631 @option{-fcompare-debug=}, with the equal sign but without @var{opts},
19632 is equivalent to @option{-fno-compare-debug}, which disables the dumping
19633 of the final representation and the second compilation, preventing even
19634 @env{GCC_COMPARE_DEBUG} from taking effect.
19636 To verify full coverage during @option{-fcompare-debug} testing, set
19637 @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
19638 which GCC rejects as an invalid option in any actual compilation
19639 (rather than preprocessing, assembly or linking). To get just a
19640 warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
19641 not overridden} will do.
19643 @item -fcompare-debug-second
19644 @opindex fcompare-debug-second
19645 This option is implicitly passed to the compiler for the second
19646 compilation requested by @option{-fcompare-debug}, along with options to
19647 silence warnings, and omitting other options that would cause the compiler
19648 to produce output to files or to standard output as a side effect. Dump
19649 files and preserved temporary files are renamed so as to contain the
19650 @code{.gk} additional extension during the second compilation, to avoid
19651 overwriting those generated by the first.
19653 When this option is passed to the compiler driver, it causes the
19654 @emph{first} compilation to be skipped, which makes it useful for little
19655 other than debugging the compiler proper.
19659 Turn off generation of debug info, if leaving out this option
19660 generates it, or turn it on at level 2 otherwise. The position of this
19661 argument in the command line does not matter; it takes effect after all
19662 other options are processed, and it does so only once, no matter how
19663 many times it is given. This is mainly intended to be used with
19664 @option{-fcompare-debug}.
19666 @item -fvar-tracking-assignments-toggle
19667 @opindex fvar-tracking-assignments-toggle
19668 @opindex fno-var-tracking-assignments-toggle
19669 Toggle @option{-fvar-tracking-assignments}, in the same way that
19670 @option{-gtoggle} toggles @option{-g}.
19674 Makes the compiler print out each function name as it is compiled, and
19675 print some statistics about each pass when it finishes.
19677 @item -ftime-report
19678 @opindex ftime-report
19679 Makes the compiler print some statistics about the time consumed by each
19680 pass when it finishes.
19682 @item -ftime-report-details
19683 @opindex ftime-report-details
19684 Record the time consumed by infrastructure parts separately for each pass.
19686 @item -fira-verbose=@var{n}
19687 @opindex fira-verbose
19688 Control the verbosity of the dump file for the integrated register allocator.
19689 The default value is 5. If the value @var{n} is greater or equal to 10,
19690 the dump output is sent to stderr using the same format as @var{n} minus 10.
19693 @opindex flto-report
19694 Prints a report with internal details on the workings of the link-time
19695 optimizer. The contents of this report vary from version to version.
19696 It is meant to be useful to GCC developers when processing object
19697 files in LTO mode (via @option{-flto}).
19699 Disabled by default.
19701 @item -flto-report-wpa
19702 @opindex flto-report-wpa
19703 Like @option{-flto-report}, but only print for the WPA phase of link-time
19707 @opindex fmem-report
19708 Makes the compiler print some statistics about permanent memory
19709 allocation when it finishes.
19711 @item -fmem-report-wpa
19712 @opindex fmem-report-wpa
19713 Makes the compiler print some statistics about permanent memory
19714 allocation for the WPA phase only.
19716 @item -fpre-ipa-mem-report
19717 @opindex fpre-ipa-mem-report
19718 @item -fpost-ipa-mem-report
19719 @opindex fpost-ipa-mem-report
19720 Makes the compiler print some statistics about permanent memory
19721 allocation before or after interprocedural optimization.
19724 @opindex fmultiflags
19725 This option enables multilib-aware @code{TFLAGS} to be used to build
19726 target libraries with options different from those the compiler is
19727 configured to use by default, through the use of specs (@xref{Spec
19728 Files}) set up by compiler internals, by the target, or by builders at
19731 Like @code{TFLAGS}, this allows the target libraries to be built for
19732 portable baseline environments, while the compiler defaults to more
19733 demanding ones. That's useful because users can easily override the
19734 defaults the compiler is configured to use to build their own programs,
19735 if the defaults are not ideal for their target environment, whereas
19736 rebuilding the runtime libraries is usually not as easy or desirable.
19738 Unlike @code{TFLAGS}, the use of specs enables different flags to be
19739 selected for different multilibs. The way to accomplish that is to
19740 build with @samp{make TFLAGS=-fmultiflags}, after configuring
19741 @samp{--with-specs=%@{fmultiflags:...@}}.
19743 This option is discarded by the driver once it's done processing driver
19746 It is also useful to check that @code{TFLAGS} are being used to build
19747 all target libraries, by configuring a non-bootstrap compiler
19748 @samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
19749 the compiler and target libraries.
19751 @item -fprofile-report
19752 @opindex fprofile-report
19753 Makes the compiler print some statistics about consistency of the
19754 (estimated) profile and effect of individual passes.
19756 @item -fstack-usage
19757 @opindex fstack-usage
19758 Makes the compiler output stack usage information for the program, on a
19759 per-function basis. The filename for the dump is made by appending
19760 @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
19761 the output file, if explicitly specified and it is not an executable,
19762 otherwise it is the basename of the source file. An entry is made up
19767 The name of the function.
19771 One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
19774 The qualifier @code{static} means that the function manipulates the stack
19775 statically: a fixed number of bytes are allocated for the frame on function
19776 entry and released on function exit; no stack adjustments are otherwise made
19777 in the function. The second field is this fixed number of bytes.
19779 The qualifier @code{dynamic} means that the function manipulates the stack
19780 dynamically: in addition to the static allocation described above, stack
19781 adjustments are made in the body of the function, for example to push/pop
19782 arguments around function calls. If the qualifier @code{bounded} is also
19783 present, the amount of these adjustments is bounded at compile time and
19784 the second field is an upper bound of the total amount of stack used by
19785 the function. If it is not present, the amount of these adjustments is
19786 not bounded at compile time and the second field only represents the
19791 Emit statistics about front-end processing at the end of the compilation.
19792 This option is supported only by the C++ front end, and
19793 the information is generally only useful to the G++ development team.
19795 @item -fdbg-cnt-list
19796 @opindex fdbg-cnt-list
19797 Print the name and the counter upper bound for all debug counters.
19800 @item -fdbg-cnt=@var{counter-value-list}
19802 Set the internal debug counter lower and upper bound. @var{counter-value-list}
19803 is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
19804 [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
19805 the name of the counter and list of closed intervals.
19806 The @var{lower_bound} is optional and is zero
19807 initialized if not set.
19808 For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
19809 @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
19810 eleventh invocation.
19811 For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
19813 @item -print-file-name=@var{library}
19814 @opindex print-file-name
19815 Print the full absolute name of the library file @var{library} that
19816 would be used when linking---and don't do anything else. With this
19817 option, GCC does not compile or link anything; it just prints the
19820 @item -print-multi-directory
19821 @opindex print-multi-directory
19822 Print the directory name corresponding to the multilib selected by any
19823 other switches present in the command line. This directory is supposed
19824 to exist in @env{GCC_EXEC_PREFIX}.
19826 @item -print-multi-lib
19827 @opindex print-multi-lib
19828 Print the mapping from multilib directory names to compiler switches
19829 that enable them. The directory name is separated from the switches by
19830 @samp{;}, and each switch starts with an @samp{@@} instead of the
19831 @samp{-}, without spaces between multiple switches. This is supposed to
19832 ease shell processing.
19834 @item -print-multi-os-directory
19835 @opindex print-multi-os-directory
19836 Print the path to OS libraries for the selected
19837 multilib, relative to some @file{lib} subdirectory. If OS libraries are
19838 present in the @file{lib} subdirectory and no multilibs are used, this is
19839 usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
19840 sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
19841 @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
19842 subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
19844 @item -print-multiarch
19845 @opindex print-multiarch
19846 Print the path to OS libraries for the selected multiarch,
19847 relative to some @file{lib} subdirectory.
19849 @item -print-prog-name=@var{program}
19850 @opindex print-prog-name
19851 Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
19853 @item -print-libgcc-file-name
19854 @opindex print-libgcc-file-name
19855 Same as @option{-print-file-name=libgcc.a}.
19857 This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
19858 but you do want to link with @file{libgcc.a}. You can do:
19861 gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
19864 @item -print-search-dirs
19865 @opindex print-search-dirs
19866 Print the name of the configured installation directory and a list of
19867 program and library directories @command{gcc} searches---and don't do anything else.
19869 This is useful when @command{gcc} prints the error message
19870 @samp{installation problem, cannot exec cpp0: No such file or directory}.
19871 To resolve this you either need to put @file{cpp0} and the other compiler
19872 components where @command{gcc} expects to find them, or you can set the environment
19873 variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
19874 Don't forget the trailing @samp{/}.
19875 @xref{Environment Variables}.
19877 @item -print-sysroot
19878 @opindex print-sysroot
19879 Print the target sysroot directory that is used during
19880 compilation. This is the target sysroot specified either at configure
19881 time or using the @option{--sysroot} option, possibly with an extra
19882 suffix that depends on compilation options. If no target sysroot is
19883 specified, the option prints nothing.
19885 @item -print-sysroot-headers-suffix
19886 @opindex print-sysroot-headers-suffix
19887 Print the suffix added to the target sysroot when searching for
19888 headers, or give an error if the compiler is not configured with such
19889 a suffix---and don't do anything else.
19892 @opindex dumpmachine
19893 Print the compiler's target machine (for example,
19894 @samp{i686-pc-linux-gnu})---and don't do anything else.
19897 @opindex dumpversion
19898 Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
19899 anything else. This is the compiler version used in filesystem paths and
19900 specs. Depending on how the compiler has been configured it can be just
19901 a single number (major version), two numbers separated by a dot (major and
19902 minor version) or three numbers separated by dots (major, minor and patchlevel
19905 @item -dumpfullversion
19906 @opindex dumpfullversion
19907 Print the full compiler version---and don't do anything else. The output is
19908 always three numbers separated by dots, major, minor and patchlevel version.
19912 Print the compiler's built-in specs---and don't do anything else. (This
19913 is used when GCC itself is being built.) @xref{Spec Files}.
19916 @node Submodel Options
19917 @section Machine-Dependent Options
19918 @cindex submodel options
19919 @cindex specifying hardware config
19920 @cindex hardware models and configurations, specifying
19921 @cindex target-dependent options
19922 @cindex machine-dependent options
19924 Each target machine supported by GCC can have its own options---for
19925 example, to allow you to compile for a particular processor variant or
19926 ABI, or to control optimizations specific to that machine. By
19927 convention, the names of machine-specific options start with
19930 Some configurations of the compiler also support additional target-specific
19931 options, usually for compatibility with other compilers on the same
19934 @c This list is ordered alphanumerically by subsection name.
19935 @c It should be the same order and spelling as these options are listed
19936 @c in Machine Dependent Options
19939 * AArch64 Options::
19940 * Adapteva Epiphany Options::
19941 * AMD GCN Options::
19945 * Blackfin Options::
19950 * DEC Alpha Options::
19955 * GNU/Linux Options::
19960 * LoongArch Options::
19965 * MicroBlaze Options::
19968 * MN10300 Options::
19972 * Nios II Options::
19973 * Nvidia PTX Options::
19974 * OpenRISC Options::
19976 * PowerPC Options::
19980 * RS/6000 and PowerPC Options::
19982 * S/390 and zSeries Options::
19984 * Solaris 2 Options::
19986 * System V Options::
19991 * VxWorks Options::
19993 * x86 Windows Options::
19994 * Xstormy16 Options::
19996 * zSeries Options::
19999 @node AArch64 Options
20000 @subsection AArch64 Options
20001 @cindex AArch64 Options
20003 These options are defined for AArch64 implementations:
20007 @item -mabi=@var{name}
20009 Generate code for the specified data model. Permissible values
20010 are @samp{ilp32} for SysV-like data model where int, long int and pointers
20011 are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
20012 but long int and pointers are 64 bits.
20014 The default depends on the specific target configuration. Note that
20015 the LP64 and ILP32 ABIs are not link-compatible; you must compile your
20016 entire program with the same ABI, and link with a compatible set of libraries.
20019 @opindex mbig-endian
20020 Generate big-endian code. This is the default when GCC is configured for an
20021 @samp{aarch64_be-*-*} target.
20023 @item -mgeneral-regs-only
20024 @opindex mgeneral-regs-only
20025 Generate code which uses only the general-purpose registers. This will prevent
20026 the compiler from using floating-point and Advanced SIMD registers but will not
20027 impose any restrictions on the assembler.
20029 @item -mlittle-endian
20030 @opindex mlittle-endian
20031 Generate little-endian code. This is the default when GCC is configured for an
20032 @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
20034 @item -mcmodel=tiny
20035 @opindex mcmodel=tiny
20036 Generate code for the tiny code model. The program and its statically defined
20037 symbols must be within 1MB of each other. Programs can be statically or
20038 dynamically linked.
20040 @item -mcmodel=small
20041 @opindex mcmodel=small
20042 Generate code for the small code model. The program and its statically defined
20043 symbols must be within 4GB of each other. Programs can be statically or
20044 dynamically linked. This is the default code model.
20046 @item -mcmodel=large
20047 @opindex mcmodel=large
20048 Generate code for the large code model. This makes no assumptions about
20049 addresses and sizes of sections. Programs can be statically linked only. The
20050 @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20051 @option{-fpic} and @option{-fPIC}.
20053 @item -mstrict-align
20054 @itemx -mno-strict-align
20055 @opindex mstrict-align
20056 @opindex mno-strict-align
20057 Avoid or allow generating memory accesses that may not be aligned on a natural
20058 object boundary as described in the architecture specification.
20060 @item -momit-leaf-frame-pointer
20061 @itemx -mno-omit-leaf-frame-pointer
20062 @opindex momit-leaf-frame-pointer
20063 @opindex mno-omit-leaf-frame-pointer
20064 Omit or keep the frame pointer in leaf functions. The former behavior is the
20067 @item -mstack-protector-guard=@var{guard}
20068 @itemx -mstack-protector-guard-reg=@var{reg}
20069 @itemx -mstack-protector-guard-offset=@var{offset}
20070 @opindex mstack-protector-guard
20071 @opindex mstack-protector-guard-reg
20072 @opindex mstack-protector-guard-offset
20073 Generate stack protection code using canary at @var{guard}. Supported
20074 locations are @samp{global} for a global canary or @samp{sysreg} for a
20075 canary in an appropriate system register.
20077 With the latter choice the options
20078 @option{-mstack-protector-guard-reg=@var{reg}} and
20079 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20080 which system register to use as base register for reading the canary,
20081 and from what offset from that base register. There is no default
20082 register or offset as this is entirely for use within the Linux
20085 @item -mtls-dialect=desc
20086 @opindex mtls-dialect=desc
20087 Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20088 of TLS variables. This is the default.
20090 @item -mtls-dialect=traditional
20091 @opindex mtls-dialect=traditional
20092 Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20095 @item -mtls-size=@var{size}
20097 Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20098 This option requires binutils 2.26 or newer.
20100 @item -mfix-cortex-a53-835769
20101 @itemx -mno-fix-cortex-a53-835769
20102 @opindex mfix-cortex-a53-835769
20103 @opindex mno-fix-cortex-a53-835769
20104 Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20105 This involves inserting a NOP instruction between memory instructions and
20106 64-bit integer multiply-accumulate instructions.
20108 @item -mfix-cortex-a53-843419
20109 @itemx -mno-fix-cortex-a53-843419
20110 @opindex mfix-cortex-a53-843419
20111 @opindex mno-fix-cortex-a53-843419
20112 Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20113 This erratum workaround is made at link time and this will only pass the
20114 corresponding flag to the linker.
20116 @item -mlow-precision-recip-sqrt
20117 @itemx -mno-low-precision-recip-sqrt
20118 @opindex mlow-precision-recip-sqrt
20119 @opindex mno-low-precision-recip-sqrt
20120 Enable or disable the reciprocal square root approximation.
20121 This option only has an effect if @option{-ffast-math} or
20122 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20123 precision of reciprocal square root results to about 16 bits for
20124 single precision and to 32 bits for double precision.
20126 @item -mlow-precision-sqrt
20127 @itemx -mno-low-precision-sqrt
20128 @opindex mlow-precision-sqrt
20129 @opindex mno-low-precision-sqrt
20130 Enable or disable the square root approximation.
20131 This option only has an effect if @option{-ffast-math} or
20132 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20133 precision of square root results to about 16 bits for
20134 single precision and to 32 bits for double precision.
20135 If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20137 @item -mlow-precision-div
20138 @itemx -mno-low-precision-div
20139 @opindex mlow-precision-div
20140 @opindex mno-low-precision-div
20141 Enable or disable the division approximation.
20142 This option only has an effect if @option{-ffast-math} or
20143 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20144 precision of division results to about 16 bits for
20145 single precision and to 32 bits for double precision.
20147 @item -mtrack-speculation
20148 @itemx -mno-track-speculation
20149 Enable or disable generation of additional code to track speculative
20150 execution through conditional branches. The tracking state can then
20151 be used by the compiler when expanding calls to
20152 @code{__builtin_speculation_safe_copy} to permit a more efficient code
20153 sequence to be generated.
20155 @item -moutline-atomics
20156 @itemx -mno-outline-atomics
20157 Enable or disable calls to out-of-line helpers to implement atomic operations.
20158 These helpers will, at runtime, determine if the LSE instructions from
20159 ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20160 instructions that are present in the base ARMv8.0 ISA.
20162 This option is only applicable when compiling for the base ARMv8.0
20163 instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20164 or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20165 used directly. The same applies when using @option{-mcpu=} when the
20166 selected cpu supports the @samp{lse} feature.
20167 This option is on by default.
20169 @item -march=@var{name}
20171 Specify the name of the target architecture and, optionally, one or
20172 more feature modifiers. This option has the form
20173 @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20175 The table below summarizes the permissible values for @var{arch}
20176 and the features that they enable by default:
20178 @multitable @columnfractions 0.20 0.20 0.60
20179 @headitem @var{arch} value @tab Architecture @tab Includes by default
20180 @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20181 @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20182 @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20183 @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20184 @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20185 @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20186 @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20187 @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20188 @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20189 @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20190 @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20191 @item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20192 @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20193 @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20196 The value @samp{native} is available on native AArch64 GNU/Linux and
20197 causes the compiler to pick the architecture of the host system. This
20198 option has no effect if the compiler is unable to recognize the
20199 architecture of the host system,
20201 The permissible values for @var{feature} are listed in the sub-section
20202 on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20203 Feature Modifiers}. Where conflicting feature modifiers are
20204 specified, the right-most feature is used.
20206 GCC uses @var{name} to determine what kind of instructions it can emit
20207 when generating assembly code. If @option{-march} is specified
20208 without either of @option{-mtune} or @option{-mcpu} also being
20209 specified, the code is tuned to perform well across a range of target
20210 processors implementing the target architecture.
20212 @item -mtune=@var{name}
20214 Specify the name of the target processor for which GCC should tune the
20215 performance of the code. Permissible values for this option are:
20216 @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20217 @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20218 @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20219 @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20220 @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20221 @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20222 @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20223 @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20224 @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20225 @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20226 @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20227 @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20228 @samp{octeontx2f95mm},
20230 @samp{thunderx}, @samp{thunderxt88},
20231 @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20232 @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20233 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20234 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20235 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
20236 @samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
20237 @samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715},
20238 @samp{ampere1}, @samp{ampere1a}, and @samp{native}.
20240 The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20241 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20242 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20243 should tune for a big.LITTLE system.
20245 The value @samp{neoverse-512tvb} specifies that GCC should tune
20246 for Neoverse cores that (a) implement SVE and (b) have a total vector
20247 bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20248 tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20249 instructions a cycle and that can execute an equivalent number of SVE
20250 arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20251 This is more general than tuning for a specific core like Neoverse V1
20252 but is more specific than the default tuning described below.
20254 Additionally on native AArch64 GNU/Linux systems the value
20255 @samp{native} tunes performance to the host system. This option has no effect
20256 if the compiler is unable to recognize the processor of the host system.
20258 Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20259 are specified, the code is tuned to perform well across a range
20260 of target processors.
20262 This option cannot be suffixed by feature modifiers.
20264 @item -mcpu=@var{name}
20266 Specify the name of the target processor, optionally suffixed by one
20267 or more feature modifiers. This option has the form
20268 @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20269 the permissible values for @var{cpu} are the same as those available
20270 for @option{-mtune}. The permissible values for @var{feature} are
20271 documented in the sub-section on
20272 @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20273 Feature Modifiers}. Where conflicting feature modifiers are
20274 specified, the right-most feature is used.
20276 GCC uses @var{name} to determine what kind of instructions it can emit when
20277 generating assembly code (as if by @option{-march}) and to determine
20278 the target processor for which to tune for performance (as if
20279 by @option{-mtune}). Where this option is used in conjunction
20280 with @option{-march} or @option{-mtune}, those options take precedence
20281 over the appropriate part of this option.
20283 @option{-mcpu=neoverse-512tvb} is special in that it does not refer
20284 to a specific core, but instead refers to all Neoverse cores that
20285 (a) implement SVE and (b) have a total vector bandwidth of 512 bits
20286 a cycle. Unless overridden by @option{-march},
20287 @option{-mcpu=neoverse-512tvb} generates code that can run on a
20288 Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20289 these properties. Unless overridden by @option{-mtune},
20290 @option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20291 @option{-mtune=neoverse-512tvb}.
20293 @item -moverride=@var{string}
20295 Override tuning decisions made by the back-end in response to a
20296 @option{-mtune=} switch. The syntax, semantics, and accepted values
20297 for @var{string} in this option are not guaranteed to be consistent
20300 This option is only intended to be useful when developing GCC.
20302 @item -mverbose-cost-dump
20303 @opindex mverbose-cost-dump
20304 Enable verbose cost model dumping in the debug dump files. This option is
20305 provided for use in debugging the compiler.
20307 @item -mpc-relative-literal-loads
20308 @itemx -mno-pc-relative-literal-loads
20309 @opindex mpc-relative-literal-loads
20310 @opindex mno-pc-relative-literal-loads
20311 Enable or disable PC-relative literal loads. With this option literal pools are
20312 accessed using a single instruction and emitted after each function. This
20313 limits the maximum size of functions to 1MB. This is enabled by default for
20314 @option{-mcmodel=tiny}.
20316 @item -msign-return-address=@var{scope}
20317 @opindex msign-return-address
20318 Select the function scope on which return address signing will be applied.
20319 Permissible values are @samp{none}, which disables return address signing,
20320 @samp{non-leaf}, which enables pointer signing for functions which are not leaf
20321 functions, and @samp{all}, which enables pointer signing for all functions. The
20322 default value is @samp{none}. This option has been deprecated by
20323 -mbranch-protection.
20325 @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
20326 @opindex mbranch-protection
20327 Select the branch protection features to use.
20328 @samp{none} is the default and turns off all types of branch protection.
20329 @samp{standard} turns on all types of branch protection features. If a feature
20330 has additional tuning options, then @samp{standard} sets it to its standard
20332 @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20333 level: signing functions that save the return address to memory (non-leaf
20334 functions will practically always do this) using the a-key. The optional
20335 argument @samp{leaf} can be used to extend the signing to include leaf
20336 functions. The optional argument @samp{b-key} can be used to sign the functions
20337 with the B-key instead of the A-key.
20338 @samp{bti} turns on branch target identification mechanism.
20340 @item -mharden-sls=@var{opts}
20341 @opindex mharden-sls
20342 Enable compiler hardening against straight line speculation (SLS).
20343 @var{opts} is a comma-separated list of the following options:
20348 In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20349 @samp{-mharden-sls=none} disables all SLS hardening.
20351 @item -msve-vector-bits=@var{bits}
20352 @opindex msve-vector-bits
20353 Specify the number of bits in an SVE vector register. This option only has
20354 an effect when SVE is enabled.
20356 GCC supports two forms of SVE code generation: ``vector-length
20357 agnostic'' output that works with any size of vector register and
20358 ``vector-length specific'' output that allows GCC to make assumptions
20359 about the vector length when it is useful for optimization reasons.
20360 The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20361 @samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20362 Specifying @samp{scalable} selects vector-length agnostic
20363 output. At present @samp{-msve-vector-bits=128} also generates vector-length
20364 agnostic output for big-endian targets. All other values generate
20365 vector-length specific code. The behavior of these values may change
20366 in future releases and no value except @samp{scalable} should be
20367 relied on for producing code that is portable across different
20368 hardware SVE vector lengths.
20370 The default is @samp{-msve-vector-bits=scalable}, which produces
20371 vector-length agnostic code.
20374 @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20375 @anchor{aarch64-feature-modifiers}
20376 @cindex @option{-march} feature modifiers
20377 @cindex @option{-mcpu} feature modifiers
20378 Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20379 the following and their inverses @option{no@var{feature}}:
20383 Enable CRC extension. This is on by default for
20384 @option{-march=armv8.1-a}.
20386 Enable Crypto extension. This also enables Advanced SIMD and floating-point
20389 Enable floating-point instructions. This is on by default for all possible
20390 values for options @option{-march} and @option{-mcpu}.
20392 Enable Advanced SIMD instructions. This also enables floating-point
20393 instructions. This is on by default for all possible values for options
20394 @option{-march} and @option{-mcpu}.
20396 Enable Scalable Vector Extension instructions. This also enables Advanced
20397 SIMD and floating-point instructions.
20399 Enable Large System Extension instructions. This is on by default for
20400 @option{-march=armv8.1-a}.
20402 Enable Round Double Multiply Accumulate instructions. This is on by default
20403 for @option{-march=armv8.1-a}.
20405 Enable FP16 extension. This also enables floating-point instructions.
20407 Enable FP16 fmla extension. This also enables FP16 extensions and
20408 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.
20411 Enable the RCpc extension. This enables the use of the LDAPR instructions for
20412 load-acquire atomic semantics, and passes it on to the assembler, enabling
20413 inline asm statements to use instructions from the RCpc extension.
20415 Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20417 Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20420 Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20422 Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20423 instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20425 Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20426 Use of this option with architectures prior to Armv8.2-A is not supported.
20428 Enable the Statistical Profiling extension. This option is only to enable the
20429 extension at the assembler level and does not affect code generation.
20431 Enable the Armv8.5-a Random Number instructions. This option is only to
20432 enable the extension at the assembler level and does not affect code
20435 Enable the Armv8.5-a Memory Tagging Extensions.
20436 Use of this option with architectures prior to Armv8.5-A is not supported.
20438 Enable the Armv8-a Speculation Barrier instruction. This option is only to
20439 enable the extension at the assembler level and does not affect code
20440 generation. This option is enabled by default for @option{-march=armv8.5-a}.
20442 Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20443 is only to enable the extension at the assembler level and does not affect code
20444 generation. This option is enabled by default for @option{-march=armv8.5-a}.
20446 Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20447 This option is only to enable the extension at the assembler level and does
20448 not affect code generation. This option is enabled by default for
20449 @option{-march=armv8.5-a}.
20451 Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20454 Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
20456 Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
20458 Enable SVE2 aes instructions. This also enables SVE2 instructions.
20460 Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
20462 Enable the Transactional Memory Extension.
20464 Enable 8-bit Integer Matrix Multiply instructions. This also enables
20465 Advanced SIMD and floating-point instructions. This option is enabled by
20466 default for @option{-march=armv8.6-a}. Use of this option with architectures
20467 prior to Armv8.2-A is not supported.
20469 Enable 32-bit Floating point Matrix Multiply instructions. This also enables
20470 SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20473 Enable 64-bit Floating point Matrix Multiply instructions. This also enables
20474 SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20477 Enable brain half-precision floating-point instructions. This also enables
20478 Advanced SIMD and floating-point instructions. This option is enabled by
20479 default for @option{-march=armv8.6-a}. Use of this option with architectures
20480 prior to Armv8.2-A is not supported.
20482 Enable the 64-byte atomic load and store instructions for accelerators.
20483 This option is enabled by default for @option{-march=armv8.7-a}.
20485 Enable the instructions to accelerate memory operations like @code{memcpy},
20486 @code{memmove}, @code{memset}. This option is enabled by default for
20487 @option{-march=armv8.8-a}
20489 Enable the Flag Manipulation instructions Extension.
20491 Enable the Pointer Authentication Extension.
20493 Enable the Common Short Sequence Compression instructions.
20497 Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
20498 which implies @option{fp}.
20499 Conversely, @option{nofp} implies @option{nosimd}, which implies
20500 @option{nocrypto}, @option{noaes} and @option{nosha2}.
20502 @node Adapteva Epiphany Options
20503 @subsection Adapteva Epiphany Options
20505 These @samp{-m} options are defined for Adapteva Epiphany:
20508 @item -mhalf-reg-file
20509 @opindex mhalf-reg-file
20510 Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
20511 That allows code to run on hardware variants that lack these registers.
20513 @item -mprefer-short-insn-regs
20514 @opindex mprefer-short-insn-regs
20515 Preferentially allocate registers that allow short instruction generation.
20516 This can result in increased instruction count, so this may either reduce or
20517 increase overall code size.
20519 @item -mbranch-cost=@var{num}
20520 @opindex mbranch-cost
20521 Set the cost of branches to roughly @var{num} ``simple'' instructions.
20522 This cost is only a heuristic and is not guaranteed to produce
20523 consistent results across releases.
20527 Enable the generation of conditional moves.
20529 @item -mnops=@var{num}
20531 Emit @var{num} NOPs before every other generated instruction.
20533 @item -mno-soft-cmpsf
20534 @opindex mno-soft-cmpsf
20535 @opindex msoft-cmpsf
20536 For single-precision floating-point comparisons, emit an @code{fsub} instruction
20537 and test the flags. This is faster than a software comparison, but can
20538 get incorrect results in the presence of NaNs, or when two different small
20539 numbers are compared such that their difference is calculated as zero.
20540 The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
20541 software comparisons.
20543 @item -mstack-offset=@var{num}
20544 @opindex mstack-offset
20545 Set the offset between the top of the stack and the stack pointer.
20546 E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
20547 can be used by leaf functions without stack allocation.
20548 Values other than @samp{8} or @samp{16} are untested and unlikely to work.
20549 Note also that this option changes the ABI; compiling a program with a
20550 different stack offset than the libraries have been compiled with
20551 generally does not work.
20552 This option can be useful if you want to evaluate if a different stack
20553 offset would give you better code, but to actually use a different stack
20554 offset to build working programs, it is recommended to configure the
20555 toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
20557 @item -mno-round-nearest
20558 @opindex mno-round-nearest
20559 @opindex mround-nearest
20560 Make the scheduler assume that the rounding mode has been set to
20561 truncating. The default is @option{-mround-nearest}.
20564 @opindex mlong-calls
20565 If not otherwise specified by an attribute, assume all calls might be beyond
20566 the offset range of the @code{b} / @code{bl} instructions, and therefore load the
20567 function address into a register before performing a (otherwise direct) call.
20568 This is the default.
20570 @item -mshort-calls
20571 @opindex short-calls
20572 If not otherwise specified by an attribute, assume all direct calls are
20573 in the range of the @code{b} / @code{bl} instructions, so use these instructions
20574 for direct calls. The default is @option{-mlong-calls}.
20578 Assume addresses can be loaded as 16-bit unsigned values. This does not
20579 apply to function addresses for which @option{-mlong-calls} semantics
20582 @item -mfp-mode=@var{mode}
20584 Set the prevailing mode of the floating-point unit.
20585 This determines the floating-point mode that is provided and expected
20586 at function call and return time. Making this mode match the mode you
20587 predominantly need at function start can make your programs smaller and
20588 faster by avoiding unnecessary mode switches.
20590 @var{mode} can be set to one the following values:
20594 Any mode at function entry is valid, and retained or restored when
20595 the function returns, and when it calls other functions.
20596 This mode is useful for compiling libraries or other compilation units
20597 you might want to incorporate into different programs with different
20598 prevailing FPU modes, and the convenience of being able to use a single
20599 object file outweighs the size and speed overhead for any extra
20600 mode switching that might be needed, compared with what would be needed
20601 with a more specific choice of prevailing FPU mode.
20604 This is the mode used for floating-point calculations with
20605 truncating (i.e.@: round towards zero) rounding mode. That includes
20606 conversion from floating point to integer.
20608 @item round-nearest
20609 This is the mode used for floating-point calculations with
20610 round-to-nearest-or-even rounding mode.
20613 This is the mode used to perform integer calculations in the FPU, e.g.@:
20614 integer multiply, or integer multiply-and-accumulate.
20617 The default is @option{-mfp-mode=caller}
20619 @item -mno-split-lohi
20620 @itemx -mno-postinc
20621 @itemx -mno-postmodify
20622 @opindex mno-split-lohi
20623 @opindex msplit-lohi
20624 @opindex mno-postinc
20626 @opindex mno-postmodify
20627 @opindex mpostmodify
20628 Code generation tweaks that disable, respectively, splitting of 32-bit
20629 loads, generation of post-increment addresses, and generation of
20630 post-modify addresses. The defaults are @option{msplit-lohi},
20631 @option{-mpost-inc}, and @option{-mpost-modify}.
20633 @item -mnovect-double
20634 @opindex mno-vect-double
20635 @opindex mvect-double
20636 Change the preferred SIMD mode to SImode. The default is
20637 @option{-mvect-double}, which uses DImode as preferred SIMD mode.
20639 @item -max-vect-align=@var{num}
20640 @opindex max-vect-align
20641 The maximum alignment for SIMD vector mode types.
20642 @var{num} may be 4 or 8. The default is 8.
20643 Note that this is an ABI change, even though many library function
20644 interfaces are unaffected if they don't use SIMD vector modes
20645 in places that affect size and/or alignment of relevant types.
20647 @item -msplit-vecmove-early
20648 @opindex msplit-vecmove-early
20649 Split vector moves into single word moves before reload. In theory this
20650 can give better register allocation, but so far the reverse seems to be
20651 generally the case.
20653 @item -m1reg-@var{reg}
20655 Specify a register to hold the constant @minus{}1, which makes loading small negative
20656 constants and certain bitmasks faster.
20657 Allowable values for @var{reg} are @samp{r43} and @samp{r63},
20658 which specify use of that register as a fixed register,
20659 and @samp{none}, which means that no register is used for this
20660 purpose. The default is @option{-m1reg-none}.
20664 @node AMD GCN Options
20665 @subsection AMD GCN Options
20666 @cindex AMD GCN Options
20668 These options are defined specifically for the AMD GCN port.
20672 @item -march=@var{gpu}
20674 @itemx -mtune=@var{gpu}
20676 Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
20681 Compile for GCN3 Fiji devices (gfx803).
20684 Compile for GCN5 Vega 10 devices (gfx900).
20687 Compile for GCN5 Vega 20 devices (gfx906).
20690 Compile for CDNA1 Instinct MI100 series devices (gfx908).
20693 Compile for CDNA2 Instinct MI200 series devices (gfx90a).
20697 @item -msram-ecc=on
20698 @itemx -msram-ecc=off
20699 @itemx -msram-ecc=any
20701 Compile binaries suitable for devices with the SRAM-ECC feature enabled,
20702 disabled, or either mode. This feature can be enabled per-process on some
20703 devices. The compiled code must match the device mode. The default is
20704 @samp{any}, for devices that support it.
20706 @item -mstack-size=@var{bytes}
20707 @opindex mstack-size
20708 Specify how many @var{bytes} of stack space will be requested for each GPU
20709 thread (wave-front). Beware that there may be many threads and limited memory
20710 available. The size of the stack allocation may also have an impact on
20711 run-time performance. The default is 32KB when using OpenACC or OpenMP, and
20716 Compile binaries suitable for devices with the XNACK feature enabled. Some
20717 devices always require XNACK and some allow the user to configure XNACK. The
20718 compiled code must match the device mode. The default is @samp{-mno-xnack}.
20719 At present this option is a placeholder for support that is not yet
20725 @subsection ARC Options
20726 @cindex ARC options
20728 The following options control the architecture variant for which code
20731 @c architecture variants
20734 @item -mbarrel-shifter
20735 @opindex mbarrel-shifter
20736 Generate instructions supported by barrel shifter. This is the default
20737 unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
20740 @opindex mjli-always
20741 Force to call a function using jli_s instruction. This option is
20742 valid only for ARCv2 architecture.
20744 @item -mcpu=@var{cpu}
20746 Set architecture type, register usage, and instruction scheduling
20747 parameters for @var{cpu}. There are also shortcut alias options
20748 available for backward compatibility and convenience. Supported
20749 values for @var{cpu} are
20755 Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
20759 Compile for ARC601. Alias: @option{-mARC601}.
20764 Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
20765 This is the default when configured with @option{--with-cpu=arc700}@.
20768 Compile for ARC EM.
20771 Compile for ARC HS.
20774 Compile for ARC EM CPU with no hardware extensions.
20777 Compile for ARC EM4 CPU.
20780 Compile for ARC EM4 DMIPS CPU.
20783 Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
20787 Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
20788 double assist instructions.
20791 Compile for ARC HS CPU with no hardware extensions except the atomic
20795 Compile for ARC HS34 CPU.
20798 Compile for ARC HS38 CPU.
20801 Compile for ARC HS38 CPU with all hardware extensions on.
20804 Compile for ARC HS4x CPU.
20807 Compile for ARC HS4xD CPU.
20810 Compile for ARC HS4x CPU release 3.10a.
20813 Compile for ARC 600 CPU with @code{norm} instructions enabled.
20815 @item arc600_mul32x16
20816 Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
20817 instructions enabled.
20820 Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
20821 instructions enabled.
20824 Compile for ARC 601 CPU with @code{norm} instructions enabled.
20826 @item arc601_mul32x16
20827 Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
20828 instructions enabled.
20831 Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
20832 instructions enabled.
20835 Compile for ARC 700 on NPS400 chip.
20838 Compile for ARC EM minimalist configuration featuring reduced register
20845 @itemx -mdpfp-compact
20846 @opindex mdpfp-compact
20847 Generate double-precision FPX instructions, tuned for the compact
20851 @opindex mdpfp-fast
20852 Generate double-precision FPX instructions, tuned for the fast
20855 @item -mno-dpfp-lrsr
20856 @opindex mno-dpfp-lrsr
20857 Disable @code{lr} and @code{sr} instructions from using FPX extension
20862 Generate extended arithmetic instructions. Currently only
20863 @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
20864 supported. Only valid for @option{-mcpu=ARC700}.
20869 Do not generate @code{mpy}-family instructions for ARC700. This option is
20874 Generate 32x16-bit multiply and multiply-accumulate instructions.
20878 Generate @code{mul64} and @code{mulu64} instructions.
20879 Only valid for @option{-mcpu=ARC600}.
20883 Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
20888 @itemx -mspfp-compact
20889 @opindex mspfp-compact
20890 Generate single-precision FPX instructions, tuned for the compact
20894 @opindex mspfp-fast
20895 Generate single-precision FPX instructions, tuned for the fast
20900 Enable generation of ARC SIMD instructions via target-specific
20901 builtins. Only valid for @option{-mcpu=ARC700}.
20904 @opindex msoft-float
20905 This option ignored; it is provided for compatibility purposes only.
20906 Software floating-point code is emitted by default, and this default
20907 can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
20908 @option{-mspfp-fast} for single precision, and @option{-mdpfp},
20909 @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
20913 Generate @code{swap} instructions.
20917 This enables use of the locked load/store conditional extension to implement
20918 atomic memory built-in functions. Not available for ARC 6xx or ARC
20923 Enable @code{div} and @code{rem} instructions for ARCv2 cores.
20925 @item -mcode-density
20926 @opindex mcode-density
20927 Enable code density instructions for ARC EM.
20928 This option is on by default for ARC HS.
20932 Enable double load/store operations for ARC HS cores.
20934 @item -mtp-regno=@var{regno}
20936 Specify thread pointer register number.
20938 @item -mmpy-option=@var{multo}
20939 @opindex mmpy-option
20940 Compile ARCv2 code with a multiplier design option. You can specify
20941 the option using either a string or numeric value for @var{multo}.
20942 @samp{wlh1} is the default value. The recognized values are:
20947 No multiplier available.
20951 16x16 multiplier, fully pipelined.
20952 The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
20956 32x32 multiplier, fully
20957 pipelined (1 stage). The following instructions are additionally
20958 enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20962 32x32 multiplier, fully pipelined
20963 (2 stages). The following instructions are additionally enabled: @code{mpy},
20964 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20968 Two 16x16 multipliers, blocking,
20969 sequential. The following instructions are additionally enabled: @code{mpy},
20970 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20974 One 16x16 multiplier, blocking,
20975 sequential. The following instructions are additionally enabled: @code{mpy},
20976 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20980 One 32x4 multiplier, blocking,
20981 sequential. The following instructions are additionally enabled: @code{mpy},
20982 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20986 ARC HS SIMD support.
20990 ARC HS SIMD support.
20994 ARC HS SIMD support.
20998 This option is only available for ARCv2 cores@.
21000 @item -mfpu=@var{fpu}
21002 Enables support for specific floating-point hardware extensions for ARCv2
21003 cores. Supported values for @var{fpu} are:
21008 Enables support for single-precision floating-point hardware
21012 Enables support for double-precision floating-point hardware
21013 extensions. The single-precision floating-point extension is also
21014 enabled. Not available for ARC EM@.
21017 Enables support for double-precision floating-point hardware
21018 extensions using double-precision assist instructions. The single-precision
21019 floating-point extension is also enabled. This option is
21020 only available for ARC EM@.
21023 Enables support for double-precision floating-point hardware
21024 extensions using double-precision assist instructions.
21025 The single-precision floating-point, square-root, and divide
21026 extensions are also enabled. This option is
21027 only available for ARC EM@.
21030 Enables support for double-precision floating-point hardware
21031 extensions using double-precision assist instructions.
21032 The single-precision floating-point and fused multiply and add
21033 hardware extensions are also enabled. This option is
21034 only available for ARC EM@.
21037 Enables support for double-precision floating-point hardware
21038 extensions using double-precision assist instructions.
21039 All single-precision floating-point hardware extensions are also
21040 enabled. This option is only available for ARC EM@.
21043 Enables support for single-precision floating-point, square-root and divide
21044 hardware extensions@.
21047 Enables support for double-precision floating-point, square-root and divide
21048 hardware extensions. This option
21049 includes option @samp{fpus_div}. Not available for ARC EM@.
21052 Enables support for single-precision floating-point and
21053 fused multiply and add hardware extensions@.
21056 Enables support for double-precision floating-point and
21057 fused multiply and add hardware extensions. This option
21058 includes option @samp{fpus_fma}. Not available for ARC EM@.
21061 Enables support for all single-precision floating-point hardware
21065 Enables support for all single- and double-precision floating-point
21066 hardware extensions. Not available for ARC EM@.
21070 @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
21071 @opindex mirq-ctrl-saved
21072 Specifies general-purposes registers that the processor automatically
21073 saves/restores on interrupt entry and exit. @var{register-range} is
21074 specified as two registers separated by a dash. The register range
21075 always starts with @code{r0}, the upper limit is @code{fp} register.
21076 @var{blink} and @var{lp_count} are optional. This option is only
21077 valid for ARC EM and ARC HS cores.
21079 @item -mrgf-banked-regs=@var{number}
21080 @opindex mrgf-banked-regs
21081 Specifies the number of registers replicated in second register bank
21082 on entry to fast interrupt. Fast interrupts are interrupts with the
21083 highest priority level P0. These interrupts save only PC and STATUS32
21084 registers to avoid memory transactions during interrupt entry and exit
21085 sequences. Use this option when you are using fast interrupts in an
21086 ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21088 @item -mlpc-width=@var{width}
21089 @opindex mlpc-width
21090 Specify the width of the @code{lp_count} register. Valid values for
21091 @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21092 fixed to 32 bits. If the width is less than 32, the compiler does not
21093 attempt to transform loops in your program to use the zero-delay loop
21094 mechanism unless it is known that the @code{lp_count} register can
21095 hold the required loop-counter value. Depending on the width
21096 specified, the compiler and run-time library might continue to use the
21097 loop mechanism for various needs. This option defines macro
21098 @code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21102 This option instructs the compiler to generate code for a 16-entry
21103 register file. This option defines the @code{__ARC_RF16__}
21104 preprocessor macro.
21106 @item -mbranch-index
21107 @opindex mbranch-index
21108 Enable use of @code{bi} or @code{bih} instructions to implement jump
21113 The following options are passed through to the assembler, and also
21114 define preprocessor macro symbols.
21116 @c Flags used by the assembler, but for which we define preprocessor
21117 @c macro symbols as well.
21120 @opindex mdsp-packa
21121 Passed down to the assembler to enable the DSP Pack A extensions.
21122 Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21127 Passed down to the assembler to enable the dual Viterbi butterfly
21128 extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21129 option is deprecated.
21131 @c ARC700 4.10 extension instruction
21134 Passed down to the assembler to enable the locked load/store
21135 conditional extension. Also sets the preprocessor symbol
21140 Passed down to the assembler. Also sets the preprocessor symbol
21141 @code{__Xxmac_d16}. This option is deprecated.
21145 Passed down to the assembler. Also sets the preprocessor symbol
21146 @code{__Xxmac_24}. This option is deprecated.
21148 @c ARC700 4.10 extension instruction
21151 Passed down to the assembler to enable the 64-bit time-stamp counter
21152 extension instruction. Also sets the preprocessor symbol
21153 @code{__Xrtsc}. This option is deprecated.
21155 @c ARC700 4.10 extension instruction
21158 Passed down to the assembler to enable the swap byte ordering
21159 extension instruction. Also sets the preprocessor symbol
21163 @opindex mtelephony
21164 Passed down to the assembler to enable dual- and single-operand
21165 instructions for telephony. Also sets the preprocessor symbol
21166 @code{__Xtelephony}. This option is deprecated.
21170 Passed down to the assembler to enable the XY memory extension. Also
21171 sets the preprocessor symbol @code{__Xxy}.
21175 The following options control how the assembly code is annotated:
21177 @c Assembly annotation options
21181 Annotate assembler instructions with estimated addresses.
21183 @item -mannotate-align
21184 @opindex mannotate-align
21185 Explain what alignment considerations lead to the decision to make an
21186 instruction short or long.
21190 The following options are passed through to the linker:
21192 @c options passed through to the linker
21196 Passed through to the linker, to specify use of the @code{arclinux} emulation.
21197 This option is enabled by default in tool chains built for
21198 @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21199 when profiling is not requested.
21201 @item -marclinux_prof
21202 @opindex marclinux_prof
21203 Passed through to the linker, to specify use of the
21204 @code{arclinux_prof} emulation. This option is enabled by default in
21205 tool chains built for @w{@code{arc-linux-uclibc}} and
21206 @w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21210 The following options control the semantics of generated code:
21212 @c semantically relevant code generation options
21215 @opindex mlong-calls
21216 Generate calls as register indirect calls, thus providing access
21217 to the full 32-bit address range.
21219 @item -mmedium-calls
21220 @opindex mmedium-calls
21221 Don't use less than 25-bit addressing range for calls, which is the
21222 offset available for an unconditional branch-and-link
21223 instruction. Conditional execution of function calls is suppressed, to
21224 allow use of the 25-bit range, rather than the 21-bit range with
21225 conditional branch-and-link. This is the default for tool chains built
21226 for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21230 Put definitions of externally-visible data in a small data section if
21231 that data is no bigger than @var{num} bytes. The default value of
21232 @var{num} is 4 for any ARC configuration, or 8 when we have double
21233 load/store operations.
21238 Do not generate sdata references. This is the default for tool chains
21239 built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21242 @item -mvolatile-cache
21243 @opindex mvolatile-cache
21244 Use ordinarily cached memory accesses for volatile references. This is the
21247 @item -mno-volatile-cache
21248 @opindex mno-volatile-cache
21249 @opindex mvolatile-cache
21250 Enable cache bypass for volatile references.
21254 The following options fine tune code generation:
21255 @c code generation tuning options
21258 @opindex malign-call
21259 Does nothing. Preserved for backward compatibility.
21261 @item -mauto-modify-reg
21262 @opindex mauto-modify-reg
21263 Enable the use of pre/post modify with register displacement.
21265 @item -mbbit-peephole
21266 @opindex mbbit-peephole
21267 Enable bbit peephole2.
21271 This option disables a target-specific pass in @file{arc_reorg} to
21272 generate compare-and-branch (@code{br@var{cc}}) instructions.
21273 It has no effect on
21274 generation of these instructions driven by the combiner pass.
21276 @item -mcase-vector-pcrel
21277 @opindex mcase-vector-pcrel
21278 Use PC-relative switch case tables to enable case table shortening.
21279 This is the default for @option{-Os}.
21281 @item -mcompact-casesi
21282 @opindex mcompact-casesi
21283 Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21284 and only available for ARCv1 cores. This option is deprecated.
21286 @item -mno-cond-exec
21287 @opindex mno-cond-exec
21288 Disable the ARCompact-specific pass to generate conditional
21289 execution instructions.
21291 Due to delay slot scheduling and interactions between operand numbers,
21292 literal sizes, instruction lengths, and the support for conditional execution,
21293 the target-independent pass to generate conditional execution is often lacking,
21294 so the ARC port has kept a special pass around that tries to find more
21295 conditional execution generation opportunities after register allocation,
21296 branch shortening, and delay slot scheduling have been done. This pass
21297 generally, but not always, improves performance and code size, at the cost of
21298 extra compilation time, which is why there is an option to switch it off.
21299 If you have a problem with call instructions exceeding their allowable
21300 offset range because they are conditionalized, you should consider using
21301 @option{-mmedium-calls} instead.
21303 @item -mearly-cbranchsi
21304 @opindex mearly-cbranchsi
21305 Enable pre-reload use of the @code{cbranchsi} pattern.
21307 @item -mexpand-adddi
21308 @opindex mexpand-adddi
21309 Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21310 @code{add.f}, @code{adc} etc. This option is deprecated.
21312 @item -mindexed-loads
21313 @opindex mindexed-loads
21314 Enable the use of indexed loads. This can be problematic because some
21315 optimizers then assume that indexed stores exist, which is not
21320 Enable Local Register Allocation. This is still experimental for ARC,
21321 so by default the compiler uses standard reload
21322 (i.e.@: @option{-mno-lra}).
21324 @item -mlra-priority-none
21325 @opindex mlra-priority-none
21326 Don't indicate any priority for target registers.
21328 @item -mlra-priority-compact
21329 @opindex mlra-priority-compact
21330 Indicate target register priority for r0..r3 / r12..r15.
21332 @item -mlra-priority-noncompact
21333 @opindex mlra-priority-noncompact
21334 Reduce target register priority for r0..r3 / r12..r15.
21337 @opindex mmillicode
21338 When optimizing for size (using @option{-Os}), prologues and epilogues
21339 that have to save or restore a large number of registers are often
21340 shortened by using call to a special function in libgcc; this is
21341 referred to as a @emph{millicode} call. As these calls can pose
21342 performance issues, and/or cause linking issues when linking in a
21343 nonstandard way, this option is provided to turn on or off millicode
21346 @item -mcode-density-frame
21347 @opindex mcode-density-frame
21348 This option enable the compiler to emit @code{enter} and @code{leave}
21349 instructions. These instructions are only valid for CPUs with
21350 code-density feature.
21353 @opindex mmixed-code
21354 Does nothing. Preserved for backward compatibility.
21358 Ths option is deprecated. Enable @samp{q} instruction alternatives.
21359 This is the default for @option{-Os}.
21363 Does nothing. Preserved for backward compatibility.
21367 Does nothing. Preserved for backward compatibility.
21369 @item -msize-level=@var{level}
21370 @opindex msize-level
21371 Fine-tune size optimization with regards to instruction lengths and alignment.
21372 The recognized values for @var{level} are:
21375 No size optimization. This level is deprecated and treated like @samp{1}.
21378 Short instructions are used opportunistically.
21381 In addition, alignment of loops and of code after barriers are dropped.
21384 In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21388 This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21389 the behavior when this is not set is equivalent to level @samp{1}.
21391 @item -mtune=@var{cpu}
21393 Set instruction scheduling parameters for @var{cpu}, overriding any implied
21394 by @option{-mcpu=}.
21396 Supported values for @var{cpu} are
21400 Tune for ARC600 CPU.
21403 Tune for ARC601 CPU.
21406 Tune for ARC700 CPU with standard multiplier block.
21409 Tune for ARC700 CPU with XMAC block.
21412 Tune for ARC725D CPU.
21415 Tune for ARC750D CPU.
21418 Tune for ARCv2 core3 type CPU. This option enable usage of
21419 @code{dbnz} instruction.
21422 Tune for ARC4x release 3.10a.
21426 @item -mmultcost=@var{num}
21428 Cost to assume for a multiply instruction, with @samp{4} being equal to a
21429 normal instruction.
21431 @item -munalign-prob-threshold=@var{probability}
21432 @opindex munalign-prob-threshold
21433 Does nothing. Preserved for backward compatibility.
21437 The following options are maintained for backward compatibility, but
21438 are now deprecated and will be removed in a future release:
21440 @c Deprecated options
21448 @opindex mbig-endian
21451 Compile code for big-endian targets. Use of these options is now
21452 deprecated. Big-endian code is supported by configuring GCC to build
21453 @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
21454 for which big endian is the default.
21456 @item -mlittle-endian
21457 @opindex mlittle-endian
21460 Compile code for little-endian targets. Use of these options is now
21461 deprecated. Little-endian code is supported by configuring GCC to build
21462 @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
21463 for which little endian is the default.
21465 @item -mbarrel_shifter
21466 @opindex mbarrel_shifter
21467 Replaced by @option{-mbarrel-shifter}.
21469 @item -mdpfp_compact
21470 @opindex mdpfp_compact
21471 Replaced by @option{-mdpfp-compact}.
21474 @opindex mdpfp_fast
21475 Replaced by @option{-mdpfp-fast}.
21478 @opindex mdsp_packa
21479 Replaced by @option{-mdsp-packa}.
21483 Replaced by @option{-mea}.
21487 Replaced by @option{-mmac-24}.
21491 Replaced by @option{-mmac-d16}.
21493 @item -mspfp_compact
21494 @opindex mspfp_compact
21495 Replaced by @option{-mspfp-compact}.
21498 @opindex mspfp_fast
21499 Replaced by @option{-mspfp-fast}.
21501 @item -mtune=@var{cpu}
21503 Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
21504 @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
21505 @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
21507 @item -multcost=@var{num}
21509 Replaced by @option{-mmultcost}.
21514 @subsection ARM Options
21515 @cindex ARM options
21517 These @samp{-m} options are defined for the ARM port:
21520 @item -mabi=@var{name}
21522 Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
21523 @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
21526 @opindex mapcs-frame
21527 Generate a stack frame that is compliant with the ARM Procedure Call
21528 Standard for all functions, even if this is not strictly necessary for
21529 correct execution of the code. Specifying @option{-fomit-frame-pointer}
21530 with this option causes the stack frames not to be generated for
21531 leaf functions. The default is @option{-mno-apcs-frame}.
21532 This option is deprecated.
21536 This is a synonym for @option{-mapcs-frame} and is deprecated.
21539 @c not currently implemented
21540 @item -mapcs-stack-check
21541 @opindex mapcs-stack-check
21542 Generate code to check the amount of stack space available upon entry to
21543 every function (that actually uses some stack space). If there is
21544 insufficient space available then either the function
21545 @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
21546 called, depending upon the amount of stack space required. The runtime
21547 system is required to provide these functions. The default is
21548 @option{-mno-apcs-stack-check}, since this produces smaller code.
21550 @c not currently implemented
21551 @item -mapcs-reentrant
21552 @opindex mapcs-reentrant
21553 Generate reentrant, position-independent code. The default is
21554 @option{-mno-apcs-reentrant}.
21557 @item -mthumb-interwork
21558 @opindex mthumb-interwork
21559 Generate code that supports calling between the ARM and Thumb
21560 instruction sets. Without this option, on pre-v5 architectures, the
21561 two instruction sets cannot be reliably used inside one program. The
21562 default is @option{-mno-thumb-interwork}, since slightly larger code
21563 is generated when @option{-mthumb-interwork} is specified. In AAPCS
21564 configurations this option is meaningless.
21566 @item -mno-sched-prolog
21567 @opindex mno-sched-prolog
21568 @opindex msched-prolog
21569 Prevent the reordering of instructions in the function prologue, or the
21570 merging of those instruction with the instructions in the function's
21571 body. This means that all functions start with a recognizable set
21572 of instructions (or in fact one of a choice from a small set of
21573 different function prologues), and this information can be used to
21574 locate the start of functions inside an executable piece of code. The
21575 default is @option{-msched-prolog}.
21577 @item -mfloat-abi=@var{name}
21578 @opindex mfloat-abi
21579 Specifies which floating-point ABI to use. Permissible values
21580 are: @samp{soft}, @samp{softfp} and @samp{hard}.
21582 Specifying @samp{soft} causes GCC to generate output containing
21583 library calls for floating-point operations.
21584 @samp{softfp} allows the generation of code using hardware floating-point
21585 instructions, but still uses the soft-float calling conventions.
21586 @samp{hard} allows generation of floating-point instructions
21587 and uses FPU-specific calling conventions.
21589 The default depends on the specific target configuration. Note that
21590 the hard-float and soft-float ABIs are not link-compatible; you must
21591 compile your entire program with the same ABI, and link with a
21592 compatible set of libraries.
21594 @item -mgeneral-regs-only
21595 @opindex mgeneral-regs-only
21596 Generate code which uses only the general-purpose registers. This will prevent
21597 the compiler from using floating-point and Advanced SIMD registers but will not
21598 impose any restrictions on the assembler.
21600 @item -mlittle-endian
21601 @opindex mlittle-endian
21602 Generate code for a processor running in little-endian mode. This is
21603 the default for all standard configurations.
21606 @opindex mbig-endian
21607 Generate code for a processor running in big-endian mode; the default is
21608 to compile code for a little-endian processor.
21613 When linking a big-endian image select between BE8 and BE32 formats.
21614 The option has no effect for little-endian images and is ignored. The
21615 default is dependent on the selected target architecture. For ARMv6
21616 and later architectures the default is BE8, for older architectures
21617 the default is BE32. BE32 format has been deprecated by ARM.
21619 @item -march=@var{name}@r{[}+extension@dots{}@r{]}
21621 This specifies the name of the target ARM architecture. GCC uses this
21622 name to determine what kind of instructions it can emit when generating
21623 assembly code. This option can be used in conjunction with or instead
21624 of the @option{-mcpu=} option.
21626 Permissible names are:
21628 @samp{armv5t}, @samp{armv5te},
21629 @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
21630 @samp{armv6z}, @samp{armv6zk},
21631 @samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
21632 @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
21639 @samp{armv6-m}, @samp{armv6s-m},
21640 @samp{armv7-m}, @samp{armv7e-m},
21641 @samp{armv8-m.base}, @samp{armv8-m.main},
21642 @samp{armv8.1-m.main},
21644 @samp{iwmmxt} and @samp{iwmmxt2}.
21646 Additionally, the following architectures, which lack support for the
21647 Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
21649 Many of the architectures support extensions. These can be added by
21650 appending @samp{+@var{extension}} to the architecture name. Extension
21651 options are processed in order and capabilities accumulate. An extension
21652 will also enable any necessary base extensions
21653 upon which it depends. For example, the @samp{+crypto} extension
21654 will always enable the @samp{+simd} extension. The exception to the
21655 additive construction is for extensions that are prefixed with
21656 @samp{+no@dots{}}: these extensions disable the specified option and
21657 any other extensions that may depend on the presence of that
21660 For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
21661 writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
21662 entirely disabled by the @samp{+nofp} option that follows it.
21664 Most extension names are generically named, but have an effect that is
21665 dependent upon the architecture to which it is applied. For example,
21666 the @samp{+simd} option can be applied to both @samp{armv7-a} and
21667 @samp{armv8-a} architectures, but will enable the original ARMv7-A
21668 Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
21669 variant for @samp{armv8-a}.
21671 The table below lists the supported extensions for each architecture.
21672 Architectures not mentioned do not support any extensions.
21685 The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
21686 used as an alias for this extension.
21689 Disable the floating-point instructions.
21693 The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
21696 The VFPv3 floating-point instructions, with 16 double-precision
21697 registers. The extension @samp{+vfpv3-d16} can be used as an alias
21698 for this extension. Note that floating-point is not supported by the
21699 base ARMv7-M architecture, but is compatible with both the ARMv7-A and
21700 ARMv7-R architectures.
21703 Disable the floating-point instructions.
21709 The multiprocessing extension.
21712 The security extension.
21715 The VFPv3 floating-point instructions, with 16 double-precision
21716 registers. The extension @samp{+vfpv3-d16} can be used as an alias
21717 for this extension.
21720 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21721 The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
21722 for this extension.
21725 The VFPv3 floating-point instructions, with 32 double-precision
21728 @item +vfpv3-d16-fp16
21729 The VFPv3 floating-point instructions, with 16 double-precision
21730 registers and the half-precision floating-point conversion operations.
21733 The VFPv3 floating-point instructions, with 32 double-precision
21734 registers and the half-precision floating-point conversion operations.
21737 The VFPv4 floating-point instructions, with 16 double-precision
21741 The VFPv4 floating-point instructions, with 32 double-precision
21745 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21746 the half-precision floating-point conversion operations.
21749 The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
21752 Disable the Advanced SIMD instructions (does not disable floating point).
21755 Disable the floating-point and Advanced SIMD instructions.
21759 The extended version of the ARMv7-A architecture with support for
21763 The VFPv4 floating-point instructions, with 16 double-precision registers.
21764 The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
21767 The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
21768 extension @samp{+neon-vfpv4} can be used as an alias for this extension.
21771 The VFPv3 floating-point instructions, with 16 double-precision
21775 The VFPv3 floating-point instructions, with 32 double-precision
21778 @item +vfpv3-d16-fp16
21779 The VFPv3 floating-point instructions, with 16 double-precision
21780 registers and the half-precision floating-point conversion operations.
21783 The VFPv3 floating-point instructions, with 32 double-precision
21784 registers and the half-precision floating-point conversion operations.
21787 The VFPv4 floating-point instructions, with 16 double-precision
21791 The VFPv4 floating-point instructions, with 32 double-precision
21795 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21796 The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
21799 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21800 the half-precision floating-point conversion operations.
21803 Disable the Advanced SIMD instructions (does not disable floating point).
21806 Disable the floating-point and Advanced SIMD instructions.
21812 The Cyclic Redundancy Check (CRC) instructions.
21814 The ARMv8-A Advanced SIMD and floating-point instructions.
21816 The cryptographic instructions.
21818 Disable the cryptographic instructions.
21820 Disable the floating-point, Advanced SIMD and cryptographic instructions.
21822 Speculation Barrier Instruction.
21824 Execution and Data Prediction Restriction Instructions.
21830 The ARMv8.1-A Advanced SIMD and floating-point instructions.
21833 The cryptographic instructions. This also enables the Advanced SIMD and
21834 floating-point instructions.
21837 Disable the cryptographic instructions.
21840 Disable the floating-point, Advanced SIMD and cryptographic instructions.
21843 Speculation Barrier Instruction.
21846 Execution and Data Prediction Restriction Instructions.
21853 The half-precision floating-point data processing instructions.
21854 This also enables the Advanced SIMD and floating-point instructions.
21857 The half-precision floating-point fmla extension. This also enables
21858 the half-precision floating-point extension and Advanced SIMD and
21859 floating-point instructions.
21862 The ARMv8.1-A Advanced SIMD and floating-point instructions.
21865 The cryptographic instructions. This also enables the Advanced SIMD and
21866 floating-point instructions.
21869 Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21872 Disable the cryptographic extension.
21875 Disable the floating-point, Advanced SIMD and cryptographic instructions.
21878 Speculation Barrier Instruction.
21881 Execution and Data Prediction Restriction Instructions.
21884 8-bit Integer Matrix Multiply instructions.
21885 This also enables Advanced SIMD and floating-point instructions.
21888 Brain half-precision floating-point instructions.
21889 This also enables Advanced SIMD and floating-point instructions.
21895 The half-precision floating-point data processing instructions.
21896 This also enables the Advanced SIMD and floating-point instructions as well
21897 as the Dot Product extension and the half-precision floating-point fmla
21901 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21902 Dot Product extension.
21905 The cryptographic instructions. This also enables the Advanced SIMD and
21906 floating-point instructions as well as the Dot Product extension.
21909 Disable the cryptographic extension.
21912 Disable the floating-point, Advanced SIMD and cryptographic instructions.
21915 Speculation Barrier Instruction.
21918 Execution and Data Prediction Restriction Instructions.
21921 8-bit Integer Matrix Multiply instructions.
21922 This also enables Advanced SIMD and floating-point instructions.
21925 Brain half-precision floating-point instructions.
21926 This also enables Advanced SIMD and floating-point instructions.
21932 The half-precision floating-point data processing instructions.
21933 This also enables the Advanced SIMD and floating-point instructions as well
21934 as the Dot Product extension and the half-precision floating-point fmla
21938 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21939 Dot Product extension.
21942 The cryptographic instructions. This also enables the Advanced SIMD and
21943 floating-point instructions as well as the Dot Product extension.
21946 Disable the cryptographic extension.
21949 Disable the floating-point, Advanced SIMD and cryptographic instructions.
21952 8-bit Integer Matrix Multiply instructions.
21953 This also enables Advanced SIMD and floating-point instructions.
21956 Brain half-precision floating-point instructions.
21957 This also enables Advanced SIMD and floating-point instructions.
21963 The half-precision floating-point data processing instructions.
21964 This also enables the Advanced SIMD and floating-point instructions as well
21965 as the Dot Product extension and the half-precision floating-point fmla
21969 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21970 Dot Product extension.
21973 The cryptographic instructions. This also enables the Advanced SIMD and
21974 floating-point instructions as well as the Dot Product extension.
21977 Disable the cryptographic extension.
21980 Disable the floating-point, Advanced SIMD and cryptographic instructions.
21983 8-bit Integer Matrix Multiply instructions.
21984 This also enables Advanced SIMD and floating-point instructions.
21987 Brain half-precision floating-point instructions.
21988 This also enables Advanced SIMD and floating-point instructions.
21994 The single-precision VFPv3 floating-point instructions. The extension
21995 @samp{+vfpv3xd} can be used as an alias for this extension.
21998 The VFPv3 floating-point instructions with 16 double-precision registers.
21999 The extension +vfpv3-d16 can be used as an alias for this extension.
22001 @item +vfpv3xd-d16-fp16
22002 The single-precision VFPv3 floating-point instructions with 16 double-precision
22003 registers and the half-precision floating-point conversion operations.
22005 @item +vfpv3-d16-fp16
22006 The VFPv3 floating-point instructions with 16 double-precision
22007 registers and the half-precision floating-point conversion operations.
22010 Disable the floating-point extension.
22013 The ARM-state integer division instructions.
22016 Disable the ARM-state integer division extension.
22022 The single-precision VFPv4 floating-point instructions.
22025 The single-precision FPv5 floating-point instructions.
22028 The single- and double-precision FPv5 floating-point instructions.
22031 Disable the floating-point extensions.
22034 @item armv8.1-m.main
22038 The DSP instructions.
22041 The M-Profile Vector Extension (MVE) integer instructions.
22044 The M-Profile Vector Extension (MVE) integer and single precision
22045 floating-point instructions.
22048 The single-precision floating-point instructions.
22051 The single- and double-precision floating-point instructions.
22054 Disable the floating-point extension.
22056 @item +cdecp0, +cdecp1, ... , +cdecp7
22057 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22058 to the numbers given in the options in the range 0 to 7.
22061 Enable the Pointer Authentication and Branch Target Identification Extension.
22067 The DSP instructions.
22070 Disable the DSP extension.
22073 The single-precision floating-point instructions.
22076 The single- and double-precision floating-point instructions.
22079 Disable the floating-point extension.
22081 @item +cdecp0, +cdecp1, ... , +cdecp7
22082 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22083 to the numbers given in the options in the range 0 to 7.
22089 The Cyclic Redundancy Check (CRC) instructions.
22091 The single-precision FPv5 floating-point instructions.
22093 The ARMv8-A Advanced SIMD and floating-point instructions.
22095 The cryptographic instructions.
22097 Disable the cryptographic instructions.
22099 Disable the floating-point, Advanced SIMD and cryptographic instructions.
22104 @option{-march=native} causes the compiler to auto-detect the architecture
22105 of the build computer. At present, this feature is only supported on
22106 GNU/Linux, and not all architectures are recognized. If the auto-detect
22107 is unsuccessful the option has no effect.
22109 @item -mtune=@var{name}
22111 This option specifies the name of the target ARM processor for
22112 which GCC should tune the performance of the code.
22113 For some ARM implementations better performance can be obtained by using
22115 Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22116 @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22117 @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22118 @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22119 @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22120 @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22121 @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22122 @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22123 @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22124 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22125 @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22126 @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22127 @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22128 @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22129 @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22130 @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22131 @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22132 @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22133 @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
22134 @samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
22135 @samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
22136 @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22137 @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22138 @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22139 @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22142 Additionally, this option can specify that GCC should tune the performance
22143 of the code for a big.LITTLE system. Permissible names are:
22144 @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22145 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22146 @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22147 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22149 @option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22150 performance for a blend of processors within architecture @var{arch}.
22151 The aim is to generate code that run well on the current most popular
22152 processors, balancing between optimizations that benefit some CPUs in the
22153 range, and avoiding performance pitfalls of other CPUs. The effects of
22154 this option may change in future GCC versions as CPU models come and go.
22156 @option{-mtune} permits the same extension options as @option{-mcpu}, but
22157 the extension options do not affect the tuning of the generated code.
22159 @option{-mtune=native} causes the compiler to auto-detect the CPU
22160 of the build computer. At present, this feature is only supported on
22161 GNU/Linux, and not all architectures are recognized. If the auto-detect is
22162 unsuccessful the option has no effect.
22164 @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
22166 This specifies the name of the target ARM processor. GCC uses this name
22167 to derive the name of the target ARM architecture (as if specified
22168 by @option{-march}) and the ARM processor type for which to tune for
22169 performance (as if specified by @option{-mtune}). Where this option
22170 is used in conjunction with @option{-march} or @option{-mtune},
22171 those options take precedence over the appropriate part of this option.
22173 Many of the supported CPUs implement optional architectural
22174 extensions. Where this is so the architectural extensions are
22175 normally enabled by default. If implementations that lack the
22176 extension exist, then the extension syntax can be used to disable
22177 those extensions that have been omitted. For floating-point and
22178 Advanced SIMD (Neon) instructions, the settings of the options
22179 @option{-mfloat-abi} and @option{-mfpu} must also be considered:
22180 floating-point and Advanced SIMD instructions will only be used if
22181 @option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22182 @option{-mfpu} other than @samp{auto} will override the available
22183 floating-point and SIMD extension instructions.
22185 For example, @samp{cortex-a9} can be found in three major
22186 configurations: integer only, with just a floating-point unit or with
22187 floating-point and Advanced SIMD. The default is to enable all the
22188 instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22189 be used to disable just the SIMD or both the SIMD and floating-point
22190 instructions respectively.
22192 Permissible names for this option are the same as those for
22195 The following extension options are common to the listed CPUs:
22199 Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
22200 @samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector
22201 Extension (MVE) integer and single precision floating-point instructions on
22202 @samp{cortex-m55} and @samp{cortex-m85}.
22205 Disable the Pointer Authentication and Branch Target Identification Extension
22206 on @samp{cortex-m85}.
22209 Disable the M-Profile Vector Extension (MVE) integer and single precision
22210 floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}.
22213 Disable the M-Profile Vector Extension (MVE) single precision floating-point
22214 instructions on @samp{cortex-m55} and @samp{cortex-m85}.
22216 @item +cdecp0, +cdecp1, ... , +cdecp7
22217 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22218 to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}.
22221 Disables the floating-point instructions on @samp{arm9e},
22222 @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22223 @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22224 @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22225 @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
22226 @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
22227 @samp{cortex-m55} and @samp{cortex-m85}.
22228 Disables the floating-point and SIMD instructions on
22229 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22230 @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22231 @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22232 @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22233 @samp{cortex-a53} and @samp{cortex-a55}.
22236 Disables the double-precision component of the floating-point instructions
22237 on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22238 @samp{cortex-r52plus} and @samp{cortex-m7}.
22241 Disables the SIMD (but not floating-point) instructions on
22242 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22243 and @samp{cortex-a9}.
22246 Enables the cryptographic instructions on @samp{cortex-a32},
22247 @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22248 @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22249 @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22250 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22251 @samp{cortex-a75.cortex-a55}.
22254 Additionally the @samp{generic-armv7-a} pseudo target defaults to
22255 VFPv3 with 16 double-precision registers. It supports the following
22256 extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22257 @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22258 @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22259 @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22260 the extensions to @option{-march=armv7-a}.
22262 @option{-mcpu=generic-@var{arch}} is also permissible, and is
22263 equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22264 See @option{-mtune} for more information.
22266 @option{-mcpu=native} causes the compiler to auto-detect the CPU
22267 of the build computer. At present, this feature is only supported on
22268 GNU/Linux, and not all architectures are recognized. If the auto-detect
22269 is unsuccessful the option has no effect.
22271 @item -mfpu=@var{name}
22273 This specifies what floating-point hardware (or hardware emulation) is
22274 available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22276 @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22277 @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22278 @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22279 @samp{fpv5-d16}, @samp{fpv5-sp-d16},
22280 @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22281 Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22282 is an alias for @samp{vfpv2}.
22284 The setting @samp{auto} is the default and is special. It causes the
22285 compiler to select the floating-point and Advanced SIMD instructions
22286 based on the settings of @option{-mcpu} and @option{-march}.
22288 If the selected floating-point hardware includes the NEON extension
22289 (e.g.@: @option{-mfpu=neon}), note that floating-point
22290 operations are not generated by GCC's auto-vectorization pass unless
22291 @option{-funsafe-math-optimizations} is also specified. This is
22292 because NEON hardware does not fully implement the IEEE 754 standard for
22293 floating-point arithmetic (in particular denormal values are treated as
22294 zero), so the use of NEON instructions may lead to a loss of precision.
22296 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}).
22298 @item -mfp16-format=@var{name}
22299 @opindex mfp16-format
22300 Specify the format of the @code{__fp16} half-precision floating-point type.
22301 Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22302 the default is @samp{none}, in which case the @code{__fp16} type is not
22303 defined. @xref{Half-Precision}, for more information.
22305 @item -mstructure-size-boundary=@var{n}
22306 @opindex mstructure-size-boundary
22307 The sizes of all structures and unions are rounded up to a multiple
22308 of the number of bits set by this option. Permissible values are 8, 32
22309 and 64. The default value varies for different toolchains. For the COFF
22310 targeted toolchain the default value is 8. A value of 64 is only allowed
22311 if the underlying ABI supports it.
22313 Specifying a larger number can produce faster, more efficient code, but
22314 can also increase the size of the program. Different values are potentially
22315 incompatible. Code compiled with one value cannot necessarily expect to
22316 work with code or libraries compiled with another value, if they exchange
22317 information using structures or unions.
22319 This option is deprecated.
22321 @item -mabort-on-noreturn
22322 @opindex mabort-on-noreturn
22323 Generate a call to the function @code{abort} at the end of a
22324 @code{noreturn} function. It is executed if the function tries to
22328 @itemx -mno-long-calls
22329 @opindex mlong-calls
22330 @opindex mno-long-calls
22331 Tells the compiler to perform function calls by first loading the
22332 address of the function into a register and then performing a subroutine
22333 call on this register. This switch is needed if the target function
22334 lies outside of the 64-megabyte addressing range of the offset-based
22335 version of subroutine call instruction.
22337 Even if this switch is enabled, not all function calls are turned
22338 into long calls. The heuristic is that static functions, functions
22339 that have the @code{short_call} attribute, functions that are inside
22340 the scope of a @code{#pragma no_long_calls} directive, and functions whose
22341 definitions have already been compiled within the current compilation
22342 unit are not turned into long calls. The exceptions to this rule are
22343 that weak function definitions, functions with the @code{long_call}
22344 attribute or the @code{section} attribute, and functions that are within
22345 the scope of a @code{#pragma long_calls} directive are always
22346 turned into long calls.
22348 This feature is not enabled by default. Specifying
22349 @option{-mno-long-calls} restores the default behavior, as does
22350 placing the function calls within the scope of a @code{#pragma
22351 long_calls_off} directive. Note these switches have no effect on how
22352 the compiler generates code to handle function calls via function
22355 @item -msingle-pic-base
22356 @opindex msingle-pic-base
22357 Treat the register used for PIC addressing as read-only, rather than
22358 loading it in the prologue for each function. The runtime system is
22359 responsible for initializing this register with an appropriate value
22360 before execution begins.
22362 @item -mpic-register=@var{reg}
22363 @opindex mpic-register
22364 Specify the register to be used for PIC addressing.
22365 For standard PIC base case, the default is any suitable register
22366 determined by compiler. For single PIC base case, the default is
22367 @samp{R9} if target is EABI based or stack-checking is enabled,
22368 otherwise the default is @samp{R10}.
22370 @item -mpic-data-is-text-relative
22371 @opindex mpic-data-is-text-relative
22372 Assume that the displacement between the text and data segments is fixed
22373 at static link time. This permits using PC-relative addressing
22374 operations to access data known to be in the data segment. For
22375 non-VxWorks RTP targets, this option is enabled by default. When
22376 disabled on such targets, it will enable @option{-msingle-pic-base} by
22379 @item -mpoke-function-name
22380 @opindex mpoke-function-name
22381 Write the name of each function into the text section, directly
22382 preceding the function prologue. The generated code is similar to this:
22386 .ascii "arm_poke_function_name", 0
22389 .word 0xff000000 + (t1 - t0)
22390 arm_poke_function_name
22392 stmfd sp!, @{fp, ip, lr, pc@}
22396 When performing a stack backtrace, code can inspect the value of
22397 @code{pc} stored at @code{fp + 0}. If the trace function then looks at
22398 location @code{pc - 12} and the top 8 bits are set, then we know that
22399 there is a function name embedded immediately preceding this location
22400 and has length @code{((pc[-3]) & 0xff000000)}.
22407 Select between generating code that executes in ARM and Thumb
22408 states. The default for most configurations is to generate code
22409 that executes in ARM state, but the default can be changed by
22410 configuring GCC with the @option{--with-mode=}@var{state}
22413 You can also override the ARM and Thumb mode for each function
22414 by using the @code{target("thumb")} and @code{target("arm")} function attributes
22415 (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22418 @opindex mflip-thumb
22419 Switch ARM/Thumb modes on alternating functions.
22420 This option is provided for regression testing of mixed Thumb/ARM code
22421 generation, and is not intended for ordinary use in compiling code.
22424 @opindex mtpcs-frame
22425 Generate a stack frame that is compliant with the Thumb Procedure Call
22426 Standard for all non-leaf functions. (A leaf function is one that does
22427 not call any other functions.) The default is @option{-mno-tpcs-frame}.
22429 @item -mtpcs-leaf-frame
22430 @opindex mtpcs-leaf-frame
22431 Generate a stack frame that is compliant with the Thumb Procedure Call
22432 Standard for all leaf functions. (A leaf function is one that does
22433 not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22435 @item -mcallee-super-interworking
22436 @opindex mcallee-super-interworking
22437 Gives all externally visible functions in the file being compiled an ARM
22438 instruction set header which switches to Thumb mode before executing the
22439 rest of the function. This allows these functions to be called from
22440 non-interworking code. This option is not valid in AAPCS configurations
22441 because interworking is enabled by default.
22443 @item -mcaller-super-interworking
22444 @opindex mcaller-super-interworking
22445 Allows calls via function pointers (including virtual functions) to
22446 execute correctly regardless of whether the target code has been
22447 compiled for interworking or not. There is a small overhead in the cost
22448 of executing a function pointer if this option is enabled. This option
22449 is not valid in AAPCS configurations because interworking is enabled
22452 @item -mtp=@var{name}
22454 Specify the access model for the thread local storage pointer. The valid
22455 models are @samp{soft}, which generates calls to @code{__aeabi_read_tp},
22456 @samp{cp15}, which fetches the thread pointer from @code{cp15} directly
22457 (supported in the arm6k architecture), and @samp{auto}, which uses the
22458 best available method for the selected processor. The default setting is
22461 @item -mtls-dialect=@var{dialect}
22462 @opindex mtls-dialect
22463 Specify the dialect to use for accessing thread local storage. Two
22464 @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
22465 @samp{gnu} dialect selects the original GNU scheme for supporting
22466 local and global dynamic TLS models. The @samp{gnu2} dialect
22467 selects the GNU descriptor scheme, which provides better performance
22468 for shared libraries. The GNU descriptor scheme is compatible with
22469 the original scheme, but does require new assembler, linker and
22470 library support. Initial and local exec TLS models are unaffected by
22471 this option and always use the original scheme.
22473 @item -mword-relocations
22474 @opindex mword-relocations
22475 Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
22476 This is enabled by default on targets (uClinux, SymbianOS) where the runtime
22477 loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
22478 is specified. This option conflicts with @option{-mslow-flash-data}.
22480 @item -mfix-cortex-m3-ldrd
22481 @opindex mfix-cortex-m3-ldrd
22482 Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
22483 with overlapping destination and base registers are used. This option avoids
22484 generating these instructions. This option is enabled by default when
22485 @option{-mcpu=cortex-m3} is specified.
22487 @item -mfix-cortex-a57-aes-1742098
22488 @itemx -mno-fix-cortex-a57-aes-1742098
22489 @itemx -mfix-cortex-a72-aes-1655431
22490 @itemx -mno-fix-cortex-a72-aes-1655431
22491 Enable (disable) mitigation for an erratum on Cortex-A57 and
22492 Cortex-A72 that affects the AES cryptographic instructions. This
22493 option is enabled by default when either @option{-mcpu=cortex-a57} or
22494 @option{-mcpu=cortex-a72} is specified.
22496 @item -munaligned-access
22497 @itemx -mno-unaligned-access
22498 @opindex munaligned-access
22499 @opindex mno-unaligned-access
22500 Enables (or disables) reading and writing of 16- and 32- bit values
22501 from addresses that are not 16- or 32- bit aligned. By default
22502 unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
22503 ARMv8-M Baseline architectures, and enabled for all other
22504 architectures. If unaligned access is not enabled then words in packed
22505 data structures are accessed a byte at a time.
22507 The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
22508 generated object file to either true or false, depending upon the
22509 setting of this option. If unaligned access is enabled then the
22510 preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
22513 @item -mneon-for-64bits
22514 @opindex mneon-for-64bits
22515 This option is deprecated and has no effect.
22517 @item -mslow-flash-data
22518 @opindex mslow-flash-data
22519 Assume loading data from flash is slower than fetching instruction.
22520 Therefore literal load is minimized for better performance.
22521 This option is only supported when compiling for ARMv7 M-profile and
22522 off by default. It conflicts with @option{-mword-relocations}.
22524 @item -masm-syntax-unified
22525 @opindex masm-syntax-unified
22526 Assume inline assembler is using unified asm syntax. The default is
22527 currently off which implies divided syntax. This option has no impact
22528 on Thumb2. However, this may change in future releases of GCC.
22529 Divided syntax should be considered deprecated.
22531 @item -mrestrict-it
22532 @opindex mrestrict-it
22533 Restricts generation of IT blocks to conform to the rules of ARMv8-A.
22534 IT blocks can only contain a single 16-bit instruction from a select
22535 set of instructions. This option is on by default for ARMv8-A Thumb mode.
22537 @item -mprint-tune-info
22538 @opindex mprint-tune-info
22539 Print CPU tuning information as comment in assembler file. This is
22540 an option used only for regression testing of the compiler and not
22541 intended for ordinary use in compiling code. This option is disabled
22544 @item -mverbose-cost-dump
22545 @opindex mverbose-cost-dump
22546 Enable verbose cost model dumping in the debug dump files. This option is
22547 provided for use in debugging the compiler.
22550 @opindex mpure-code
22551 Do not allow constant data to be placed in code sections.
22552 Additionally, when compiling for ELF object format give all text sections the
22553 ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
22554 is only available when generating non-pic code for M-profile targets.
22558 Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
22559 Development Tools Engineering Specification", which can be found on
22560 @url{https://developer.arm.com/documentation/ecm0359818/latest/}.
22562 @item -mfix-cmse-cve-2021-35465
22563 @opindex mfix-cmse-cve-2021-35465
22564 Mitigate against a potential security issue with the @code{VLLDM} instruction
22565 in some M-profile devices when using CMSE (CVE-2021-365465). This option is
22566 enabled by default when the option @option{-mcpu=} is used with
22567 @code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85}
22568 or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used
22569 to disable the mitigation.
22571 @item -mstack-protector-guard=@var{guard}
22572 @itemx -mstack-protector-guard-offset=@var{offset}
22573 @opindex mstack-protector-guard
22574 @opindex mstack-protector-guard-offset
22575 Generate stack protection code using canary at @var{guard}. Supported
22576 locations are @samp{global} for a global canary or @samp{tls} for a
22577 canary accessible via the TLS register. The option
22578 @option{-mstack-protector-guard-offset=} is for use with
22579 @option{-fstack-protector-guard=tls} and not for use in user-land code.
22585 Select the FDPIC ABI, which uses 64-bit function descriptors to
22586 represent pointers to functions. When the compiler is configured for
22587 @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
22588 and implies @option{-fPIE} if none of the PIC/PIE-related options is
22589 provided. On other targets, it only enables the FDPIC-specific code
22590 generation features, and the user should explicitly provide the
22591 PIC/PIE-related options as needed.
22593 Note that static linking is not supported because it would still
22594 involve the dynamic linker when the program self-relocates. If such
22595 behavior is acceptable, use -static and -Wl,-dynamic-linker options.
22597 The opposite @option{-mno-fdpic} option is useful (and required) to
22598 build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
22599 toolchain as the one used to build the userland programs.
22601 @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
22602 @opindex mbranch-protection
22603 Enable branch protection features (armv8.1-m.main only).
22604 @samp{none} generate code without branch protection or return address
22606 @samp{standard[+@var{leaf}]} generate code with all branch protection
22607 features enabled at their standard level.
22608 @samp{pac-ret[+@var{leaf}]} generate code with return address signing
22609 set to its standard level, which is to sign all functions that save
22610 the return address to memory.
22611 @samp{leaf} When return address signing is enabled, also sign leaf
22612 functions even if they do not write the return address to memory.
22613 +@samp{bti} Add landing-pad instructions at the permitted targets of
22614 indirect branch instructions.
22616 If the @samp{+pacbti} architecture extension is not enabled, then all
22617 branch protection and return address signing operations are
22618 constrained to use only the instructions defined in the
22619 architectural-NOP space. The generated code will remain
22620 backwards-compatible with earlier versions of the architecture, but
22621 the additional security can be enabled at run time on processors that
22622 support the @samp{PACBTI} extension.
22624 Branch target enforcement using BTI can only be enabled at runtime if
22625 all code in the application has been compiled with at least
22626 @samp{-mbranch-protection=bti}.
22628 Any setting other than @samp{none} is supported only on armv8-m.main
22631 The default is to generate code without branch protection or return
22637 @subsection AVR Options
22638 @cindex AVR Options
22640 These options are defined for AVR implementations:
22643 @item -mmcu=@var{mcu}
22645 Specify Atmel AVR instruction set architectures (ISA) or MCU type.
22647 The default for this option is@tie{}@samp{avr2}.
22649 GCC supports the following AVR devices and ISAs:
22651 @include avr-mmcu.texi
22656 Assume that all data in static storage can be accessed by LDS / STS
22657 instructions. This option has only an effect on reduced Tiny devices like
22658 ATtiny40. See also the @code{absdata}
22659 @ref{AVR Variable Attributes,variable attribute}.
22661 @item -maccumulate-args
22662 @opindex maccumulate-args
22663 Accumulate outgoing function arguments and acquire/release the needed
22664 stack space for outgoing function arguments once in function
22665 prologue/epilogue. Without this option, outgoing arguments are pushed
22666 before calling a function and popped afterwards.
22668 Popping the arguments after the function call can be expensive on
22669 AVR so that accumulating the stack space might lead to smaller
22670 executables because arguments need not be removed from the
22671 stack after such a function call.
22673 This option can lead to reduced code size for functions that perform
22674 several calls to functions that get their arguments on the stack like
22675 calls to printf-like functions.
22677 @item -mbranch-cost=@var{cost}
22678 @opindex mbranch-cost
22679 Set the branch costs for conditional branch instructions to
22680 @var{cost}. Reasonable values for @var{cost} are small, non-negative
22681 integers. The default branch cost is 0.
22683 @item -mcall-prologues
22684 @opindex mcall-prologues
22685 Functions prologues/epilogues are expanded as calls to appropriate
22686 subroutines. Code size is smaller.
22688 @item -mdouble=@var{bits}
22689 @itemx -mlong-double=@var{bits}
22691 @opindex mlong-double
22692 Set the size (in bits) of the @code{double} or @code{long double} type,
22693 respectively. Possible values for @var{bits} are 32 and 64.
22694 Whether or not a specific value for @var{bits} is allowed depends on
22695 the @code{--with-double=} and @code{--with-long-double=}
22696 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
22697 and the same applies for the default values of the options.
22699 @item -mgas-isr-prologues
22700 @opindex mgas-isr-prologues
22701 Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
22702 instruction supported by GNU Binutils.
22703 If this option is on, the feature can still be disabled for individual
22704 ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
22705 function attribute. This feature is activated per default
22706 if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
22707 and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
22711 Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
22712 @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
22713 and @code{long long} is 4 bytes. Please note that this option does not
22714 conform to the C standards, but it results in smaller code
22717 @item -mmain-is-OS_task
22718 @opindex mmain-is-OS_task
22719 Do not save registers in @code{main}. The effect is the same like
22720 attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
22721 to @code{main}. It is activated per default if optimization is on.
22723 @item -mn-flash=@var{num}
22725 Assume that the flash memory has a size of
22726 @var{num} times 64@tie{}KiB.
22728 @item -mno-interrupts
22729 @opindex mno-interrupts
22730 Generated code is not compatible with hardware interrupts.
22731 Code size is smaller.
22735 Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
22736 @code{RCALL} resp.@: @code{RJMP} instruction if applicable.
22737 Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
22738 the assembler's command line and the @option{--relax} option to the
22739 linker's command line.
22741 Jump relaxing is performed by the linker because jump offsets are not
22742 known before code is located. Therefore, the assembler code generated by the
22743 compiler is the same, but the instructions in the executable may
22744 differ from instructions in the assembler code.
22746 Relaxing must be turned on if linker stubs are needed, see the
22747 section on @code{EIND} and linker stubs below.
22751 Assume that the device supports the Read-Modify-Write
22752 instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
22754 @item -mshort-calls
22755 @opindex mshort-calls
22757 Assume that @code{RJMP} and @code{RCALL} can target the whole
22760 This option is used internally for multilib selection. It is
22761 not an optimization option, and you don't need to set it by hand.
22765 Treat the stack pointer register as an 8-bit register,
22766 i.e.@: assume the high byte of the stack pointer is zero.
22767 In general, you don't need to set this option by hand.
22769 This option is used internally by the compiler to select and
22770 build multilibs for architectures @code{avr2} and @code{avr25}.
22771 These architectures mix devices with and without @code{SPH}.
22772 For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
22773 the compiler driver adds or removes this option from the compiler
22774 proper's command line, because the compiler then knows if the device
22775 or architecture has an 8-bit stack pointer and thus no @code{SPH}
22780 Use address register @code{X} in a way proposed by the hardware. This means
22781 that @code{X} is only used in indirect, post-increment or
22782 pre-decrement addressing.
22784 Without this option, the @code{X} register may be used in the same way
22785 as @code{Y} or @code{Z} which then is emulated by additional
22787 For example, loading a value with @code{X+const} addressing with a
22788 small non-negative @code{const < 64} to a register @var{Rn} is
22792 adiw r26, const ; X += const
22793 ld @var{Rn}, X ; @var{Rn} = *X
22794 sbiw r26, const ; X -= const
22798 @opindex mtiny-stack
22799 Only change the lower 8@tie{}bits of the stack pointer.
22801 @item -mfract-convert-truncate
22802 @opindex mfract-convert-truncate
22803 Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
22806 @opindex nodevicelib
22807 Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
22809 @item -nodevicespecs
22810 @opindex nodevicespecs
22811 Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
22812 command line. The user takes responsibility for supplying the sub-processes
22813 like compiler proper, assembler and linker with appropriate command line
22814 options. This means that the user has to supply her private device specs
22815 file by means of @option{-specs=@var{path-to-specs-file}}. There is no
22816 more need for option @option{-mmcu=@var{mcu}}.
22818 This option can also serve as a replacement for the older way of
22819 specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
22820 which contains a folder named @code{device-specs} which contains a specs file named
22821 @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
22823 @item -Waddr-space-convert
22824 @opindex Waddr-space-convert
22825 @opindex Wno-addr-space-convert
22826 Warn about conversions between address spaces in the case where the
22827 resulting address space is not contained in the incoming address space.
22829 @item -Wmisspelled-isr
22830 @opindex Wmisspelled-isr
22831 @opindex Wno-misspelled-isr
22832 Warn if the ISR is misspelled, i.e.@: without __vector prefix.
22833 Enabled by default.
22836 @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
22837 @cindex @code{EIND}
22838 Pointers in the implementation are 16@tie{}bits wide.
22839 The address of a function or label is represented as word address so
22840 that indirect jumps and calls can target any code address in the
22841 range of 64@tie{}Ki words.
22843 In order to facilitate indirect jump on devices with more than 128@tie{}Ki
22844 bytes of program memory space, there is a special function register called
22845 @code{EIND} that serves as most significant part of the target address
22846 when @code{EICALL} or @code{EIJMP} instructions are used.
22848 Indirect jumps and calls on these devices are handled as follows by
22849 the compiler and are subject to some limitations:
22854 The compiler never sets @code{EIND}.
22857 The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
22858 instructions or might read @code{EIND} directly in order to emulate an
22859 indirect call/jump by means of a @code{RET} instruction.
22862 The compiler assumes that @code{EIND} never changes during the startup
22863 code or during the application. In particular, @code{EIND} is not
22864 saved/restored in function or interrupt service routine
22868 For indirect calls to functions and computed goto, the linker
22869 generates @emph{stubs}. Stubs are jump pads sometimes also called
22870 @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
22871 The stub contains a direct jump to the desired address.
22874 Linker relaxation must be turned on so that the linker generates
22875 the stubs correctly in all situations. See the compiler option
22876 @option{-mrelax} and the linker option @option{--relax}.
22877 There are corner cases where the linker is supposed to generate stubs
22878 but aborts without relaxation and without a helpful error message.
22881 The default linker script is arranged for code with @code{EIND = 0}.
22882 If code is supposed to work for a setup with @code{EIND != 0}, a custom
22883 linker script has to be used in order to place the sections whose
22884 name start with @code{.trampolines} into the segment where @code{EIND}
22888 The startup code from libgcc never sets @code{EIND}.
22889 Notice that startup code is a blend of code from libgcc and AVR-LibC.
22890 For the impact of AVR-LibC on @code{EIND}, see the
22891 @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
22894 It is legitimate for user-specific startup code to set up @code{EIND}
22895 early, for example by means of initialization code located in
22896 section @code{.init3}. Such code runs prior to general startup code
22897 that initializes RAM and calls constructors, but after the bit
22898 of startup code from AVR-LibC that sets @code{EIND} to the segment
22899 where the vector table is located.
22901 #include <avr/io.h>
22904 __attribute__((section(".init3"),naked,used,no_instrument_function))
22905 init3_set_eind (void)
22907 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
22908 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
22913 The @code{__trampolines_start} symbol is defined in the linker script.
22916 Stubs are generated automatically by the linker if
22917 the following two conditions are met:
22920 @item The address of a label is taken by means of the @code{gs} modifier
22921 (short for @emph{generate stubs}) like so:
22923 LDI r24, lo8(gs(@var{func}))
22924 LDI r25, hi8(gs(@var{func}))
22926 @item The final location of that label is in a code segment
22927 @emph{outside} the segment where the stubs are located.
22931 The compiler emits such @code{gs} modifiers for code labels in the
22932 following situations:
22934 @item Taking address of a function or code label.
22935 @item Computed goto.
22936 @item If prologue-save function is used, see @option{-mcall-prologues}
22937 command-line option.
22938 @item Switch/case dispatch tables. If you do not want such dispatch
22939 tables you can specify the @option{-fno-jump-tables} command-line option.
22940 @item C and C++ constructors/destructors called during startup/shutdown.
22941 @item If the tools hit a @code{gs()} modifier explained above.
22945 Jumping to non-symbolic addresses like so is @emph{not} supported:
22950 /* Call function at word address 0x2 */
22951 return ((int(*)(void)) 0x2)();
22955 Instead, a stub has to be set up, i.e.@: the function has to be called
22956 through a symbol (@code{func_4} in the example):
22961 extern int func_4 (void);
22963 /* Call function at byte address 0x4 */
22968 and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
22969 Alternatively, @code{func_4} can be defined in the linker script.
22972 @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
22973 @cindex @code{RAMPD}
22974 @cindex @code{RAMPX}
22975 @cindex @code{RAMPY}
22976 @cindex @code{RAMPZ}
22977 Some AVR devices support memories larger than the 64@tie{}KiB range
22978 that can be accessed with 16-bit pointers. To access memory locations
22979 outside this 64@tie{}KiB range, the content of a @code{RAMP}
22980 register is used as high part of the address:
22981 The @code{X}, @code{Y}, @code{Z} address register is concatenated
22982 with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
22983 register, respectively, to get a wide address. Similarly,
22984 @code{RAMPD} is used together with direct addressing.
22988 The startup code initializes the @code{RAMP} special function
22989 registers with zero.
22992 If a @ref{AVR Named Address Spaces,named address space} other than
22993 generic or @code{__flash} is used, then @code{RAMPZ} is set
22994 as needed before the operation.
22997 If the device supports RAM larger than 64@tie{}KiB and the compiler
22998 needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
22999 is reset to zero after the operation.
23002 If the device comes with a specific @code{RAMP} register, the ISR
23003 prologue/epilogue saves/restores that SFR and initializes it with
23004 zero in case the ISR code might (implicitly) use it.
23007 RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
23008 If you use inline assembler to read from locations outside the
23009 16-bit address range and change one of the @code{RAMP} registers,
23010 you must reset it to zero after the access.
23014 @subsubsection AVR Built-in Macros
23016 GCC defines several built-in macros so that the user code can test
23017 for the presence or absence of features. Almost any of the following
23018 built-in macros are deduced from device capabilities and thus
23019 triggered by the @option{-mmcu=} command-line option.
23021 For even more AVR-specific built-in macros see
23022 @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
23027 Build-in macro that resolves to a decimal number that identifies the
23028 architecture and depends on the @option{-mmcu=@var{mcu}} option.
23029 Possible values are:
23031 @code{2}, @code{25}, @code{3}, @code{31}, @code{35},
23032 @code{4}, @code{5}, @code{51}, @code{6}
23034 for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
23035 @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
23040 @code{102}, @code{103}, @code{104},
23041 @code{105}, @code{106}, @code{107}
23043 for @var{mcu}=@code{avrtiny},
23044 @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
23045 @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
23046 If @var{mcu} specifies a device, this built-in macro is set
23047 accordingly. For example, with @option{-mmcu=atmega8} the macro is
23048 defined to @code{4}.
23050 @item __AVR_@var{Device}__
23051 Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
23052 the device's name. For example, @option{-mmcu=atmega8} defines the
23053 built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
23054 @code{__AVR_ATtiny261A__}, etc.
23056 The built-in macros' names follow
23057 the scheme @code{__AVR_@var{Device}__} where @var{Device} is
23058 the device name as from the AVR user manual. The difference between
23059 @var{Device} in the built-in macro and @var{device} in
23060 @option{-mmcu=@var{device}} is that the latter is always lowercase.
23062 If @var{device} is not a device but only a core architecture like
23063 @samp{avr51}, this macro is not defined.
23065 @item __AVR_DEVICE_NAME__
23066 Setting @option{-mmcu=@var{device}} defines this built-in macro to
23067 the device's name. For example, with @option{-mmcu=atmega8} the macro
23068 is defined to @code{atmega8}.
23070 If @var{device} is not a device but only a core architecture like
23071 @samp{avr51}, this macro is not defined.
23073 @item __AVR_XMEGA__
23074 The device / architecture belongs to the XMEGA family of devices.
23076 @item __AVR_HAVE_ELPM__
23077 The device has the @code{ELPM} instruction.
23079 @item __AVR_HAVE_ELPMX__
23080 The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23081 R@var{n},Z+} instructions.
23083 @item __AVR_HAVE_MOVW__
23084 The device has the @code{MOVW} instruction to perform 16-bit
23085 register-register moves.
23087 @item __AVR_HAVE_LPMX__
23088 The device has the @code{LPM R@var{n},Z} and
23089 @code{LPM R@var{n},Z+} instructions.
23091 @item __AVR_HAVE_MUL__
23092 The device has a hardware multiplier.
23094 @item __AVR_HAVE_JMP_CALL__
23095 The device has the @code{JMP} and @code{CALL} instructions.
23096 This is the case for devices with more than 8@tie{}KiB of program
23099 @item __AVR_HAVE_EIJMP_EICALL__
23100 @itemx __AVR_3_BYTE_PC__
23101 The device has the @code{EIJMP} and @code{EICALL} instructions.
23102 This is the case for devices with more than 128@tie{}KiB of program memory.
23103 This also means that the program counter
23104 (PC) is 3@tie{}bytes wide.
23106 @item __AVR_2_BYTE_PC__
23107 The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23108 with up to 128@tie{}KiB of program memory.
23110 @item __AVR_HAVE_8BIT_SP__
23111 @itemx __AVR_HAVE_16BIT_SP__
23112 The stack pointer (SP) register is treated as 8-bit respectively
23113 16-bit register by the compiler.
23114 The definition of these macros is affected by @option{-mtiny-stack}.
23116 @item __AVR_HAVE_SPH__
23118 The device has the SPH (high part of stack pointer) special function
23119 register or has an 8-bit stack pointer, respectively.
23120 The definition of these macros is affected by @option{-mmcu=} and
23121 in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23124 @item __AVR_HAVE_RAMPD__
23125 @itemx __AVR_HAVE_RAMPX__
23126 @itemx __AVR_HAVE_RAMPY__
23127 @itemx __AVR_HAVE_RAMPZ__
23128 The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23129 @code{RAMPZ} special function register, respectively.
23131 @item __NO_INTERRUPTS__
23132 This macro reflects the @option{-mno-interrupts} command-line option.
23134 @item __AVR_ERRATA_SKIP__
23135 @itemx __AVR_ERRATA_SKIP_JMP_CALL__
23136 Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23137 instructions because of a hardware erratum. Skip instructions are
23138 @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23139 The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23142 @item __AVR_ISA_RMW__
23143 The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23145 @item __AVR_SFR_OFFSET__=@var{offset}
23146 Instructions that can address I/O special function registers directly
23147 like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23148 address as if addressed by an instruction to access RAM like @code{LD}
23149 or @code{STS}. This offset depends on the device architecture and has
23150 to be subtracted from the RAM address in order to get the
23151 respective I/O@tie{}address.
23153 @item __AVR_SHORT_CALLS__
23154 The @option{-mshort-calls} command line option is set.
23156 @item __AVR_PM_BASE_ADDRESS__=@var{addr}
23157 Some devices support reading from flash memory by means of @code{LD*}
23158 instructions. The flash memory is seen in the data address space
23159 at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23160 is not defined, this feature is not available. If defined,
23161 the address space is linear and there is no need to put
23162 @code{.rodata} into RAM. This is handled by the default linker
23163 description file, and is currently available for
23164 @code{avrtiny} and @code{avrxmega3}. Even more convenient,
23165 there is no need to use address spaces like @code{__flash} or
23166 features like attribute @code{progmem} and @code{pgm_read_*}.
23168 @item __WITH_AVRLIBC__
23169 The compiler is configured to be used together with AVR-Libc.
23170 See the @option{--with-avrlibc} configure option.
23172 @item __HAVE_DOUBLE_MULTILIB__
23173 Defined if @option{-mdouble=} acts as a multilib option.
23175 @item __HAVE_DOUBLE32__
23176 @itemx __HAVE_DOUBLE64__
23177 Defined if the compiler supports 32-bit double resp. 64-bit double.
23178 The actual layout is specified by option @option{-mdouble=}.
23180 @item __DEFAULT_DOUBLE__
23181 The size in bits of @code{double} if @option{-mdouble=} is not set.
23182 To test the layout of @code{double} in a program, use the built-in
23183 macro @code{__SIZEOF_DOUBLE__}.
23185 @item __HAVE_LONG_DOUBLE32__
23186 @itemx __HAVE_LONG_DOUBLE64__
23187 @itemx __HAVE_LONG_DOUBLE_MULTILIB__
23188 @itemx __DEFAULT_LONG_DOUBLE__
23189 Same as above, but for @code{long double} instead of @code{double}.
23191 @item __WITH_DOUBLE_COMPARISON__
23192 Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23193 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23194 and is defined to @code{2} or @code{3}.
23196 @item __WITH_LIBF7_LIBGCC__
23197 @itemx __WITH_LIBF7_MATH__
23198 @itemx __WITH_LIBF7_MATH_SYMBOLS__
23199 Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23200 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23204 @node Blackfin Options
23205 @subsection Blackfin Options
23206 @cindex Blackfin Options
23209 @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
23211 Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23212 can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23213 @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23214 @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23215 @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23216 @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23217 @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23218 @samp{bf561}, @samp{bf592}.
23220 The optional @var{sirevision} specifies the silicon revision of the target
23221 Blackfin processor. Any workarounds available for the targeted silicon revision
23222 are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23223 If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23224 are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23225 hexadecimal digits representing the major and minor numbers in the silicon
23226 revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23227 is not defined. If @var{sirevision} is @samp{any}, the
23228 @code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23229 If this optional @var{sirevision} is not used, GCC assumes the latest known
23230 silicon revision of the targeted Blackfin processor.
23232 GCC defines a preprocessor macro for the specified @var{cpu}.
23233 For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23234 provided by libgloss to be linked in if @option{-msim} is not given.
23236 Without this option, @samp{bf532} is used as the processor by default.
23238 Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23239 only the preprocessor macro is defined.
23243 Specifies that the program will be run on the simulator. This causes
23244 the simulator BSP provided by libgloss to be linked in. This option
23245 has effect only for @samp{bfin-elf} toolchain.
23246 Certain other options, such as @option{-mid-shared-library} and
23247 @option{-mfdpic}, imply @option{-msim}.
23249 @item -momit-leaf-frame-pointer
23250 @opindex momit-leaf-frame-pointer
23251 Don't keep the frame pointer in a register for leaf functions. This
23252 avoids the instructions to save, set up and restore frame pointers and
23253 makes an extra register available in leaf functions.
23255 @item -mspecld-anomaly
23256 @opindex mspecld-anomaly
23257 When enabled, the compiler ensures that the generated code does not
23258 contain speculative loads after jump instructions. If this option is used,
23259 @code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23261 @item -mno-specld-anomaly
23262 @opindex mno-specld-anomaly
23263 @opindex mspecld-anomaly
23264 Don't generate extra code to prevent speculative loads from occurring.
23266 @item -mcsync-anomaly
23267 @opindex mcsync-anomaly
23268 When enabled, the compiler ensures that the generated code does not
23269 contain CSYNC or SSYNC instructions too soon after conditional branches.
23270 If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23272 @item -mno-csync-anomaly
23273 @opindex mno-csync-anomaly
23274 @opindex mcsync-anomaly
23275 Don't generate extra code to prevent CSYNC or SSYNC instructions from
23276 occurring too soon after a conditional branch.
23280 When enabled, the compiler is free to take advantage of the knowledge that
23281 the entire program fits into the low 64k of memory.
23284 @opindex mno-low64k
23285 Assume that the program is arbitrarily large. This is the default.
23287 @item -mstack-check-l1
23288 @opindex mstack-check-l1
23289 Do stack checking using information placed into L1 scratchpad memory by the
23292 @item -mid-shared-library
23293 @opindex mid-shared-library
23294 Generate code that supports shared libraries via the library ID method.
23295 This allows for execute in place and shared libraries in an environment
23296 without virtual memory management. This option implies @option{-fPIC}.
23297 With a @samp{bfin-elf} target, this option implies @option{-msim}.
23299 @item -mno-id-shared-library
23300 @opindex mno-id-shared-library
23301 @opindex mid-shared-library
23302 Generate code that doesn't assume ID-based shared libraries are being used.
23303 This is the default.
23305 @item -mleaf-id-shared-library
23306 @opindex mleaf-id-shared-library
23307 Generate code that supports shared libraries via the library ID method,
23308 but assumes that this library or executable won't link against any other
23309 ID shared libraries. That allows the compiler to use faster code for jumps
23312 @item -mno-leaf-id-shared-library
23313 @opindex mno-leaf-id-shared-library
23314 @opindex mleaf-id-shared-library
23315 Do not assume that the code being compiled won't link against any ID shared
23316 libraries. Slower code is generated for jump and call insns.
23318 @item -mshared-library-id=n
23319 @opindex mshared-library-id
23320 Specifies the identification number of the ID-based shared library being
23321 compiled. Specifying a value of 0 generates more compact code; specifying
23322 other values forces the allocation of that number to the current
23323 library but is no more space- or time-efficient than omitting this option.
23327 Generate code that allows the data segment to be located in a different
23328 area of memory from the text segment. This allows for execute in place in
23329 an environment without virtual memory management by eliminating relocations
23330 against the text section.
23332 @item -mno-sep-data
23333 @opindex mno-sep-data
23335 Generate code that assumes that the data segment follows the text segment.
23336 This is the default.
23339 @itemx -mno-long-calls
23340 @opindex mlong-calls
23341 @opindex mno-long-calls
23342 Tells the compiler to perform function calls by first loading the
23343 address of the function into a register and then performing a subroutine
23344 call on this register. This switch is needed if the target function
23345 lies outside of the 24-bit addressing range of the offset-based
23346 version of subroutine call instruction.
23348 This feature is not enabled by default. Specifying
23349 @option{-mno-long-calls} restores the default behavior. Note these
23350 switches have no effect on how the compiler generates code to handle
23351 function calls via function pointers.
23355 Link with the fast floating-point library. This library relaxes some of
23356 the IEEE floating-point standard's rules for checking inputs against
23357 Not-a-Number (NAN), in the interest of performance.
23360 @opindex minline-plt
23361 Enable inlining of PLT entries in function calls to functions that are
23362 not known to bind locally. It has no effect without @option{-mfdpic}.
23365 @opindex mmulticore
23366 Build a standalone application for multicore Blackfin processors.
23367 This option causes proper start files and link scripts supporting
23368 multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23369 It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23371 This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23372 selects the one-application-per-core programming model. Without
23373 @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23374 programming model is used. In this model, the main function of Core B
23375 should be named as @code{coreb_main}.
23377 If this option is not used, the single-core application programming
23382 Build a standalone application for Core A of BF561 when using
23383 the one-application-per-core programming model. Proper start files
23384 and link scripts are used to support Core A, and the macro
23385 @code{__BFIN_COREA} is defined.
23386 This option can only be used in conjunction with @option{-mmulticore}.
23390 Build a standalone application for Core B of BF561 when using
23391 the one-application-per-core programming model. Proper start files
23392 and link scripts are used to support Core B, and the macro
23393 @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23394 should be used instead of @code{main}.
23395 This option can only be used in conjunction with @option{-mmulticore}.
23399 Build a standalone application for SDRAM. Proper start files and
23400 link scripts are used to put the application into SDRAM, and the macro
23401 @code{__BFIN_SDRAM} is defined.
23402 The loader should initialize SDRAM before loading the application.
23406 Assume that ICPLBs are enabled at run time. This has an effect on certain
23407 anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23408 are enabled; for standalone applications the default is off.
23412 @subsection C6X Options
23413 @cindex C6X Options
23416 @item -march=@var{name}
23418 This specifies the name of the target architecture. GCC uses this
23419 name to determine what kind of instructions it can emit when generating
23420 assembly code. Permissible names are: @samp{c62x},
23421 @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23424 @opindex mbig-endian
23425 Generate code for a big-endian target.
23427 @item -mlittle-endian
23428 @opindex mlittle-endian
23429 Generate code for a little-endian target. This is the default.
23433 Choose startup files and linker script suitable for the simulator.
23435 @item -msdata=default
23436 @opindex msdata=default
23437 Put small global and static data in the @code{.neardata} section,
23438 which is pointed to by register @code{B14}. Put small uninitialized
23439 global and static data in the @code{.bss} section, which is adjacent
23440 to the @code{.neardata} section. Put small read-only data into the
23441 @code{.rodata} section. The corresponding sections used for large
23442 pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23445 @opindex msdata=all
23446 Put all data, not just small objects, into the sections reserved for
23447 small data, and use addressing relative to the @code{B14} register to
23451 @opindex msdata=none
23452 Make no use of the sections reserved for small data, and use absolute
23453 addresses to access all data. Put all initialized global and static
23454 data in the @code{.fardata} section, and all uninitialized data in the
23455 @code{.far} section. Put all constant data into the @code{.const}
23460 @subsection CRIS Options
23461 @cindex CRIS Options
23463 These options are defined specifically for the CRIS ports.
23466 @item -march=@var{architecture-type}
23467 @itemx -mcpu=@var{architecture-type}
23470 Generate code for the specified architecture. The choices for
23471 @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
23472 respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
23473 Default is @samp{v0}.
23475 @item -mtune=@var{architecture-type}
23477 Tune to @var{architecture-type} everything applicable about the generated
23478 code, except for the ABI and the set of available instructions. The
23479 choices for @var{architecture-type} are the same as for
23480 @option{-march=@var{architecture-type}}.
23482 @item -mmax-stack-frame=@var{n}
23483 @opindex mmax-stack-frame
23484 Warn when the stack frame of a function exceeds @var{n} bytes.
23490 The options @option{-metrax4} and @option{-metrax100} are synonyms for
23491 @option{-march=v3} and @option{-march=v8} respectively.
23493 @item -mmul-bug-workaround
23494 @itemx -mno-mul-bug-workaround
23495 @opindex mmul-bug-workaround
23496 @opindex mno-mul-bug-workaround
23497 Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
23498 models where it applies. This option is disabled by default.
23502 Enable CRIS-specific verbose debug-related information in the assembly
23503 code. This option also has the effect of turning off the @samp{#NO_APP}
23504 formatted-code indicator to the assembler at the beginning of the
23509 Do not use condition-code results from previous instruction; always emit
23510 compare and test instructions before use of condition codes.
23512 @item -mno-side-effects
23513 @opindex mno-side-effects
23514 @opindex mside-effects
23515 Do not emit instructions with side effects in addressing modes other than
23518 @item -mstack-align
23519 @itemx -mno-stack-align
23520 @itemx -mdata-align
23521 @itemx -mno-data-align
23522 @itemx -mconst-align
23523 @itemx -mno-const-align
23524 @opindex mstack-align
23525 @opindex mno-stack-align
23526 @opindex mdata-align
23527 @opindex mno-data-align
23528 @opindex mconst-align
23529 @opindex mno-const-align
23530 These options (@samp{no-} options) arrange (eliminate arrangements) for the
23531 stack frame, individual data and constants to be aligned for the maximum
23532 single data access size for the chosen CPU model. The default is to
23533 arrange for 32-bit alignment. ABI details such as structure layout are
23534 not affected by these options.
23542 Similar to the stack- data- and const-align options above, these options
23543 arrange for stack frame, writable data and constants to all be 32-bit,
23544 16-bit or 8-bit aligned. The default is 32-bit alignment.
23546 @item -mno-prologue-epilogue
23547 @itemx -mprologue-epilogue
23548 @opindex mno-prologue-epilogue
23549 @opindex mprologue-epilogue
23550 With @option{-mno-prologue-epilogue}, the normal function prologue and
23551 epilogue which set up the stack frame are omitted and no return
23552 instructions or return sequences are generated in the code. Use this
23553 option only together with visual inspection of the compiled code: no
23554 warnings or errors are generated when call-saved registers must be saved,
23555 or storage for local variables needs to be allocated.
23559 Legacy no-op option.
23563 This option arranges
23564 to link with input-output functions from a simulator library. Code,
23565 initialized data and zero-initialized data are allocated consecutively.
23569 Like @option{-sim}, but pass linker options to locate initialized data at
23570 0x40000000 and zero-initialized data at 0x80000000.
23573 @node C-SKY Options
23574 @subsection C-SKY Options
23575 @cindex C-SKY Options
23577 GCC supports these options when compiling for C-SKY V2 processors.
23581 @item -march=@var{arch}
23583 Specify the C-SKY target architecture. Valid values for @var{arch} are:
23584 @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
23585 The default is @samp{ck810}.
23587 @item -mcpu=@var{cpu}
23589 Specify the C-SKY target processor. Valid values for @var{cpu} are:
23590 @samp{ck801}, @samp{ck801t},
23591 @samp{ck802}, @samp{ck802t}, @samp{ck802j},
23592 @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
23593 @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
23594 @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
23595 @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
23596 @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
23597 @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
23598 @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
23599 @samp{ck803eftr1}, @samp{ck803efhtr1},
23600 @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
23601 @samp{ck803sef}, @samp{ck803seft},
23602 @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
23603 @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
23604 @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
23605 @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
23608 @opindex mbig-endian
23611 @itemx -mlittle-endian
23612 @opindex mlittle-endian
23616 Select big- or little-endian code. The default is little-endian.
23618 @item -mfloat-abi=@var{name}
23619 @opindex mfloat-abi
23620 Specifies which floating-point ABI to use. Permissible values
23621 are: @samp{soft}, @samp{softfp} and @samp{hard}.
23623 Specifying @samp{soft} causes GCC to generate output containing
23624 library calls for floating-point operations.
23625 @samp{softfp} allows the generation of code using hardware floating-point
23626 instructions, but still uses the soft-float calling conventions.
23627 @samp{hard} allows generation of floating-point instructions
23628 and uses FPU-specific calling conventions.
23630 The default depends on the specific target configuration. Note that
23631 the hard-float and soft-float ABIs are not link-compatible; you must
23632 compile your entire program with the same ABI, and link with a
23633 compatible set of libraries.
23636 @opindex mhard-float
23637 @itemx -msoft-float
23638 @opindex msoft-float
23640 Select hardware or software floating-point implementations.
23641 The default is soft float.
23643 @item -mdouble-float
23644 @itemx -mno-double-float
23645 @opindex mdouble-float
23646 When @option{-mhard-float} is in effect, enable generation of
23647 double-precision float instructions. This is the default except
23648 when compiling for CK803.
23653 When @option{-mhard-float} is in effect, enable generation of
23654 @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
23655 This is the default except when compiling for CK803.
23657 @item -mfpu=@var{fpu}
23659 Select the floating-point processor. This option can only be used with
23660 @option{-mhard-float}.
23661 Values for @var{fpu} are
23662 @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
23663 @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
23664 @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
23669 Enable the extended @code{lrw} instruction. This option defaults to on
23670 for CK801 and off otherwise.
23675 Enable interrupt stack instructions; the default is off.
23677 The @option{-mistack} option is required to handle the
23678 @code{interrupt} and @code{isr} function attributes
23679 (@pxref{C-SKY Function Attributes}).
23683 Enable multiprocessor instructions; the default is off.
23687 Enable coprocessor instructions; the default is off.
23691 Enable coprocessor instructions; the default is off.
23695 Enable C-SKY security instructions; the default is off.
23699 Enable C-SKY trust instructions; the default is off.
23707 Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
23708 All of these options default to off.
23713 Generate divide instructions. Default is off.
23718 Generate code for Smart Mode, using only registers numbered 0-7 to allow
23719 use of 16-bit instructions. This option is ignored for CK801 where this
23720 is the required behavior, and it defaults to on for CK802.
23721 For other targets, the default is off.
23723 @item -mhigh-registers
23724 @itemx -mno-high-registers
23725 @opindex mhigh-registers
23726 Generate code using the high registers numbered 16-31. This option
23727 is not supported on CK801, CK802, or CK803, and is enabled by default
23728 for other processors.
23733 Generate code using global anchor symbol addresses.
23736 @itemx -mno-pushpop
23738 Generate code using @code{push} and @code{pop} instructions. This option
23741 @item -mmultiple-stld
23743 @itemx -mno-multiple-stld
23745 @opindex mmultiple-stld
23746 Generate code using @code{stm} and @code{ldm} instructions. This option
23747 isn't supported on CK801 but is enabled by default on other processors.
23750 @itemx -mno-constpool
23751 @opindex mconstpool
23752 Create constant pools in the compiler instead of deferring it to the
23753 assembler. This option is the default and required for correct code
23754 generation on CK801 and CK802, and is optional on other processors.
23757 @item -mno-stack-size
23758 @opindex mstack-size
23759 Emit @code{.stack_size} directives for each function in the assembly
23760 output. This option defaults to off.
23765 Generate code for the C-SKY compiler runtime instead of libgcc. This
23766 option defaults to off.
23768 @item -mbranch-cost=@var{n}
23769 @opindex mbranch-cost=
23770 Set the branch costs to roughly @code{n} instructions. The default is 1.
23772 @item -msched-prolog
23773 @itemx -mno-sched-prolog
23774 @opindex msched-prolog
23775 Permit scheduling of function prologue and epilogue sequences. Using
23776 this option can result in code that is not compliant with the C-SKY V2 ABI
23777 prologue requirements and that cannot be debugged or backtraced.
23778 It is disabled by default.
23782 Links the library libsemi.a which is in compatible with simulator. Applicable
23783 to ELF compiler only.
23787 @node Darwin Options
23788 @subsection Darwin Options
23789 @cindex Darwin options
23791 These options are defined for all architectures running the Darwin operating
23794 FSF GCC on Darwin does not create ``fat'' object files; it creates
23795 an object file for the single architecture that GCC was built to
23796 target. Apple's GCC on Darwin does create ``fat'' files if multiple
23797 @option{-arch} options are used; it does so by running the compiler or
23798 linker multiple times and joining the results together with
23801 The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
23802 @samp{i686}) is determined by the flags that specify the ISA
23803 that GCC is targeting, like @option{-mcpu} or @option{-march}. The
23804 @option{-force_cpusubtype_ALL} option can be used to override this.
23806 The Darwin tools vary in their behavior when presented with an ISA
23807 mismatch. The assembler, @file{as}, only permits instructions to
23808 be used that are valid for the subtype of the file it is generating,
23809 so you cannot put 64-bit instructions in a @samp{ppc750} object file.
23810 The linker for shared libraries, @file{/usr/bin/libtool}, fails
23811 and prints an error if asked to create a shared library with a less
23812 restrictive subtype than its input files (for instance, trying to put
23813 a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
23814 for executables, @command{ld}, quietly gives the executable the most
23815 restrictive subtype of any of its input files.
23820 Add the framework directory @var{dir} to the head of the list of
23821 directories to be searched for header files. These directories are
23822 interleaved with those specified by @option{-I} options and are
23823 scanned in a left-to-right order.
23825 A framework directory is a directory with frameworks in it. A
23826 framework is a directory with a @file{Headers} and/or
23827 @file{PrivateHeaders} directory contained directly in it that ends
23828 in @file{.framework}. The name of a framework is the name of this
23829 directory excluding the @file{.framework}. Headers associated with
23830 the framework are found in one of those two directories, with
23831 @file{Headers} being searched first. A subframework is a framework
23832 directory that is in a framework's @file{Frameworks} directory.
23833 Includes of subframework headers can only appear in a header of a
23834 framework that contains the subframework, or in a sibling subframework
23835 header. Two subframeworks are siblings if they occur in the same
23836 framework. A subframework should not have the same name as a
23837 framework; a warning is issued if this is violated. Currently a
23838 subframework cannot have subframeworks; in the future, the mechanism
23839 may be extended to support this. The standard frameworks can be found
23840 in @file{/System/Library/Frameworks} and
23841 @file{/Library/Frameworks}. An example include looks like
23842 @code{#include <Framework/header.h>}, where @file{Framework} denotes
23843 the name of the framework and @file{header.h} is found in the
23844 @file{PrivateHeaders} or @file{Headers} directory.
23846 @item -iframework@var{dir}
23847 @opindex iframework
23848 Like @option{-F} except the directory is a treated as a system
23849 directory. The main difference between this @option{-iframework} and
23850 @option{-F} is that with @option{-iframework} the compiler does not
23851 warn about constructs contained within header files found via
23852 @var{dir}. This option is valid only for the C family of languages.
23856 Emit debugging information for symbols that are used. For stabs
23857 debugging format, this enables @option{-feliminate-unused-debug-symbols}.
23858 This is by default ON@.
23862 Emit debugging information for all symbols and types.
23864 @item -mmacosx-version-min=@var{version}
23865 The earliest version of MacOS X that this executable will run on
23866 is @var{version}. Typical values of @var{version} include @code{10.1},
23867 @code{10.2}, and @code{10.3.9}.
23869 If the compiler was built to use the system's headers by default,
23870 then the default for this option is the system version on which the
23871 compiler is running, otherwise the default is to make choices that
23872 are compatible with as many systems and code bases as possible.
23876 Enable kernel development mode. The @option{-mkernel} option sets
23877 @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
23878 @option{-fno-exceptions}, @option{-fno-non-call-exceptions},
23879 @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
23880 applicable. This mode also sets @option{-mno-altivec},
23881 @option{-msoft-float}, @option{-fno-builtin} and
23882 @option{-mlong-branch} for PowerPC targets.
23884 @item -mone-byte-bool
23885 @opindex mone-byte-bool
23886 Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
23887 By default @code{sizeof(bool)} is @code{4} when compiling for
23888 Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
23889 option has no effect on x86.
23891 @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
23892 to generate code that is not binary compatible with code generated
23893 without that switch. Using this switch may require recompiling all
23894 other modules in a program, including system libraries. Use this
23895 switch to conform to a non-default data model.
23897 @item -mfix-and-continue
23898 @itemx -ffix-and-continue
23899 @itemx -findirect-data
23900 @opindex mfix-and-continue
23901 @opindex ffix-and-continue
23902 @opindex findirect-data
23903 Generate code suitable for fast turnaround development, such as to
23904 allow GDB to dynamically load @file{.o} files into already-running
23905 programs. @option{-findirect-data} and @option{-ffix-and-continue}
23906 are provided for backwards compatibility.
23910 Loads all members of static archive libraries.
23911 See man ld(1) for more information.
23913 @item -arch_errors_fatal
23914 @opindex arch_errors_fatal
23915 Cause the errors having to do with files that have the wrong architecture
23918 @item -bind_at_load
23919 @opindex bind_at_load
23920 Causes the output file to be marked such that the dynamic linker will
23921 bind all undefined references when the file is loaded or launched.
23925 Produce a Mach-o bundle format file.
23926 See man ld(1) for more information.
23928 @item -bundle_loader @var{executable}
23929 @opindex bundle_loader
23930 This option specifies the @var{executable} that will load the build
23931 output file being linked. See man ld(1) for more information.
23934 @opindex dynamiclib
23935 When passed this option, GCC produces a dynamic library instead of
23936 an executable when linking, using the Darwin @file{libtool} command.
23938 @item -force_cpusubtype_ALL
23939 @opindex force_cpusubtype_ALL
23940 This causes GCC's output file to have the @samp{ALL} subtype, instead of
23941 one controlled by the @option{-mcpu} or @option{-march} option.
23943 @item -allowable_client @var{client_name}
23944 @itemx -client_name
23945 @itemx -compatibility_version
23946 @itemx -current_version
23948 @itemx -dependency-file
23950 @itemx -dylinker_install_name
23952 @itemx -exported_symbols_list
23955 @itemx -flat_namespace
23956 @itemx -force_flat_namespace
23957 @itemx -headerpad_max_install_names
23960 @itemx -install_name
23961 @itemx -keep_private_externs
23962 @itemx -multi_module
23963 @itemx -multiply_defined
23964 @itemx -multiply_defined_unused
23967 @itemx -no_dead_strip_inits_and_terms
23968 @itemx -nofixprebinding
23969 @itemx -nomultidefs
23971 @itemx -noseglinkedit
23972 @itemx -pagezero_size
23974 @itemx -prebind_all_twolevel_modules
23975 @itemx -private_bundle
23977 @itemx -read_only_relocs
23979 @itemx -sectobjectsymbols
23983 @itemx -sectobjectsymbols
23986 @itemx -segs_read_only_addr
23988 @itemx -segs_read_write_addr
23989 @itemx -seg_addr_table
23990 @itemx -seg_addr_table_filename
23991 @itemx -seglinkedit
23993 @itemx -segs_read_only_addr
23994 @itemx -segs_read_write_addr
23995 @itemx -single_module
23997 @itemx -sub_library
23999 @itemx -sub_umbrella
24000 @itemx -twolevel_namespace
24003 @itemx -unexported_symbols_list
24004 @itemx -weak_reference_mismatches
24005 @itemx -whatsloaded
24006 @opindex allowable_client
24007 @opindex client_name
24008 @opindex compatibility_version
24009 @opindex current_version
24010 @opindex dead_strip
24011 @opindex dependency-file
24012 @opindex dylib_file
24013 @opindex dylinker_install_name
24015 @opindex exported_symbols_list
24017 @opindex flat_namespace
24018 @opindex force_flat_namespace
24019 @opindex headerpad_max_install_names
24020 @opindex image_base
24022 @opindex install_name
24023 @opindex keep_private_externs
24024 @opindex multi_module
24025 @opindex multiply_defined
24026 @opindex multiply_defined_unused
24027 @opindex noall_load
24028 @opindex no_dead_strip_inits_and_terms
24029 @opindex nofixprebinding
24030 @opindex nomultidefs
24032 @opindex noseglinkedit
24033 @opindex pagezero_size
24035 @opindex prebind_all_twolevel_modules
24036 @opindex private_bundle
24037 @opindex read_only_relocs
24039 @opindex sectobjectsymbols
24042 @opindex sectcreate
24043 @opindex sectobjectsymbols
24046 @opindex segs_read_only_addr
24047 @opindex segs_read_write_addr
24048 @opindex seg_addr_table
24049 @opindex seg_addr_table_filename
24050 @opindex seglinkedit
24052 @opindex segs_read_only_addr
24053 @opindex segs_read_write_addr
24054 @opindex single_module
24056 @opindex sub_library
24057 @opindex sub_umbrella
24058 @opindex twolevel_namespace
24061 @opindex unexported_symbols_list
24062 @opindex weak_reference_mismatches
24063 @opindex whatsloaded
24064 These options are passed to the Darwin linker. The Darwin linker man page
24065 describes them in detail.
24068 @node DEC Alpha Options
24069 @subsection DEC Alpha Options
24071 These @samp{-m} options are defined for the DEC Alpha implementations:
24074 @item -mno-soft-float
24075 @itemx -msoft-float
24076 @opindex mno-soft-float
24077 @opindex msoft-float
24078 Use (do not use) the hardware floating-point instructions for
24079 floating-point operations. When @option{-msoft-float} is specified,
24080 functions in @file{libgcc.a} are used to perform floating-point
24081 operations. Unless they are replaced by routines that emulate the
24082 floating-point operations, or compiled in such a way as to call such
24083 emulations routines, these routines issue floating-point
24084 operations. If you are compiling for an Alpha without floating-point
24085 operations, you must ensure that the library is built so as not to call
24088 Note that Alpha implementations without floating-point operations are
24089 required to have floating-point registers.
24092 @itemx -mno-fp-regs
24094 @opindex mno-fp-regs
24095 Generate code that uses (does not use) the floating-point register set.
24096 @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24097 register set is not used, floating-point operands are passed in integer
24098 registers as if they were integers and floating-point results are passed
24099 in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24100 so any function with a floating-point argument or return value called by code
24101 compiled with @option{-mno-fp-regs} must also be compiled with that
24104 A typical use of this option is building a kernel that does not use,
24105 and hence need not save and restore, any floating-point registers.
24109 The Alpha architecture implements floating-point hardware optimized for
24110 maximum performance. It is mostly compliant with the IEEE floating-point
24111 standard. However, for full compliance, software assistance is
24112 required. This option generates code fully IEEE-compliant code
24113 @emph{except} that the @var{inexact-flag} is not maintained (see below).
24114 If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24115 defined during compilation. The resulting code is less efficient but is
24116 able to correctly support denormalized numbers and exceptional IEEE
24117 values such as not-a-number and plus/minus infinity. Other Alpha
24118 compilers call this option @option{-ieee_with_no_inexact}.
24120 @item -mieee-with-inexact
24121 @opindex mieee-with-inexact
24122 This is like @option{-mieee} except the generated code also maintains
24123 the IEEE @var{inexact-flag}. Turning on this option causes the
24124 generated code to implement fully-compliant IEEE math. In addition to
24125 @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24126 macro. On some Alpha implementations the resulting code may execute
24127 significantly slower than the code generated by default. Since there is
24128 very little code that depends on the @var{inexact-flag}, you should
24129 normally not specify this option. Other Alpha compilers call this
24130 option @option{-ieee_with_inexact}.
24132 @item -mfp-trap-mode=@var{trap-mode}
24133 @opindex mfp-trap-mode
24134 This option controls what floating-point related traps are enabled.
24135 Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24136 The trap mode can be set to one of four values:
24140 This is the default (normal) setting. The only traps that are enabled
24141 are the ones that cannot be disabled in software (e.g., division by zero
24145 In addition to the traps enabled by @samp{n}, underflow traps are enabled
24149 Like @samp{u}, but the instructions are marked to be safe for software
24150 completion (see Alpha architecture manual for details).
24153 Like @samp{su}, but inexact traps are enabled as well.
24156 @item -mfp-rounding-mode=@var{rounding-mode}
24157 @opindex mfp-rounding-mode
24158 Selects the IEEE rounding mode. Other Alpha compilers call this option
24159 @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24164 Normal IEEE rounding mode. Floating-point numbers are rounded towards
24165 the nearest machine number or towards the even machine number in case
24169 Round towards minus infinity.
24172 Chopped rounding mode. Floating-point numbers are rounded towards zero.
24175 Dynamic rounding mode. A field in the floating-point control register
24176 (@var{fpcr}, see Alpha architecture reference manual) controls the
24177 rounding mode in effect. The C library initializes this register for
24178 rounding towards plus infinity. Thus, unless your program modifies the
24179 @var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24182 @item -mtrap-precision=@var{trap-precision}
24183 @opindex mtrap-precision
24184 In the Alpha architecture, floating-point traps are imprecise. This
24185 means without software assistance it is impossible to recover from a
24186 floating trap and program execution normally needs to be terminated.
24187 GCC can generate code that can assist operating system trap handlers
24188 in determining the exact location that caused a floating-point trap.
24189 Depending on the requirements of an application, different levels of
24190 precisions can be selected:
24194 Program precision. This option is the default and means a trap handler
24195 can only identify which program caused a floating-point exception.
24198 Function precision. The trap handler can determine the function that
24199 caused a floating-point exception.
24202 Instruction precision. The trap handler can determine the exact
24203 instruction that caused a floating-point exception.
24206 Other Alpha compilers provide the equivalent options called
24207 @option{-scope_safe} and @option{-resumption_safe}.
24209 @item -mieee-conformant
24210 @opindex mieee-conformant
24211 This option marks the generated code as IEEE conformant. You must not
24212 use this option unless you also specify @option{-mtrap-precision=i} and either
24213 @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24214 is to emit the line @samp{.eflag 48} in the function prologue of the
24215 generated assembly file.
24217 @item -mbuild-constants
24218 @opindex mbuild-constants
24219 Normally GCC examines a 32- or 64-bit integer constant to
24220 see if it can construct it from smaller constants in two or three
24221 instructions. If it cannot, it outputs the constant as a literal and
24222 generates code to load it from the data segment at run time.
24224 Use this option to require GCC to construct @emph{all} integer constants
24225 using code, even if it takes more instructions (the maximum is six).
24227 You typically use this option to build a shared library dynamic
24228 loader. Itself a shared library, it must relocate itself in memory
24229 before it can find the variables and constants in its own data segment.
24247 Indicate whether GCC should generate code to use the optional BWX,
24248 CIX, FIX and MAX instruction sets. The default is to use the instruction
24249 sets supported by the CPU type specified via @option{-mcpu=} option or that
24250 of the CPU on which GCC was built if none is specified.
24253 @itemx -mfloat-ieee
24254 @opindex mfloat-vax
24255 @opindex mfloat-ieee
24256 Generate code that uses (does not use) VAX F and G floating-point
24257 arithmetic instead of IEEE single and double precision.
24259 @item -mexplicit-relocs
24260 @itemx -mno-explicit-relocs
24261 @opindex mexplicit-relocs
24262 @opindex mno-explicit-relocs
24263 Older Alpha assemblers provided no way to generate symbol relocations
24264 except via assembler macros. Use of these macros does not allow
24265 optimal instruction scheduling. GNU binutils as of version 2.12
24266 supports a new syntax that allows the compiler to explicitly mark
24267 which relocations should apply to which instructions. This option
24268 is mostly useful for debugging, as GCC detects the capabilities of
24269 the assembler when it is built and sets the default accordingly.
24272 @itemx -mlarge-data
24273 @opindex msmall-data
24274 @opindex mlarge-data
24275 When @option{-mexplicit-relocs} is in effect, static data is
24276 accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24277 is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24278 (the @code{.sdata} and @code{.sbss} sections) and are accessed via
24279 16-bit relocations off of the @code{$gp} register. This limits the
24280 size of the small data area to 64KB, but allows the variables to be
24281 directly accessed via a single instruction.
24283 The default is @option{-mlarge-data}. With this option the data area
24284 is limited to just below 2GB@. Programs that require more than 2GB of
24285 data must use @code{malloc} or @code{mmap} to allocate the data in the
24286 heap instead of in the program's data segment.
24288 When generating code for shared libraries, @option{-fpic} implies
24289 @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24292 @itemx -mlarge-text
24293 @opindex msmall-text
24294 @opindex mlarge-text
24295 When @option{-msmall-text} is used, the compiler assumes that the
24296 code of the entire program (or shared library) fits in 4MB, and is
24297 thus reachable with a branch instruction. When @option{-msmall-data}
24298 is used, the compiler can assume that all local symbols share the
24299 same @code{$gp} value, and thus reduce the number of instructions
24300 required for a function call from 4 to 1.
24302 The default is @option{-mlarge-text}.
24304 @item -mcpu=@var{cpu_type}
24306 Set the instruction set and instruction scheduling parameters for
24307 machine type @var{cpu_type}. You can specify either the @samp{EV}
24308 style name or the corresponding chip number. GCC supports scheduling
24309 parameters for the EV4, EV5 and EV6 family of processors and
24310 chooses the default values for the instruction set from the processor
24311 you specify. If you do not specify a processor type, GCC defaults
24312 to the processor on which the compiler was built.
24314 Supported values for @var{cpu_type} are
24320 Schedules as an EV4 and has no instruction set extensions.
24324 Schedules as an EV5 and has no instruction set extensions.
24328 Schedules as an EV5 and supports the BWX extension.
24333 Schedules as an EV5 and supports the BWX and MAX extensions.
24337 Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24341 Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24344 Native toolchains also support the value @samp{native},
24345 which selects the best architecture option for the host processor.
24346 @option{-mcpu=native} has no effect if GCC does not recognize
24349 @item -mtune=@var{cpu_type}
24351 Set only the instruction scheduling parameters for machine type
24352 @var{cpu_type}. The instruction set is not changed.
24354 Native toolchains also support the value @samp{native},
24355 which selects the best architecture option for the host processor.
24356 @option{-mtune=native} has no effect if GCC does not recognize
24359 @item -mmemory-latency=@var{time}
24360 @opindex mmemory-latency
24361 Sets the latency the scheduler should assume for typical memory
24362 references as seen by the application. This number is highly
24363 dependent on the memory access patterns used by the application
24364 and the size of the external cache on the machine.
24366 Valid options for @var{time} are
24370 A decimal number representing clock cycles.
24376 The compiler contains estimates of the number of clock cycles for
24377 ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24378 (also called Dcache, Scache, and Bcache), as well as to main memory.
24379 Note that L3 is only valid for EV5.
24385 @subsection eBPF Options
24386 @cindex eBPF Options
24389 @item -mframe-limit=@var{bytes}
24390 This specifies the hard limit for frame sizes, in bytes. Currently,
24391 the value that can be specified should be less than or equal to
24392 @samp{32767}. Defaults to whatever limit is imposed by the version of
24393 the Linux kernel targeted.
24395 @item -mkernel=@var{version}
24397 This specifies the minimum version of the kernel that will run the
24398 compiled program. GCC uses this version to determine which
24399 instructions to use, what kernel helpers to allow, etc. Currently,
24400 @var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
24401 @samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
24402 @samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
24403 @samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
24404 @samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
24405 @samp{5.2}, @samp{latest} and @samp{native}.
24408 @opindex mbig-endian
24409 Generate code for a big-endian target.
24411 @item -mlittle-endian
24412 @opindex mlittle-endian
24413 Generate code for a little-endian target. This is the default.
24417 Enable generation of extra conditional-branch instructions.
24418 Enabled for CPU v2 and above.
24422 Enable 32-bit jump instructions. Enabled for CPU v3 and above.
24426 Enable 32-bit ALU instructions. Enabled for CPU v3 and above.
24428 @item -mcpu=@var{version}
24430 This specifies which version of the eBPF ISA to target. Newer versions
24431 may not be supported by all kernels. The default is @samp{v3}.
24433 Supported values for @var{version} are:
24437 The first stable eBPF ISA with no special features or extensions.
24440 Supports the jump extensions, as in @option{-mjmpext}.
24443 All features of v2, plus:
24445 @item 32-bit jump operations, as in @option{-mjmp32}
24446 @item 32-bit ALU operations, as in @option{-malu32}
24453 Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
24454 is implied by @option{-gbtf}.
24458 Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
24459 support is enabled by default when generating BTF debug information for
24463 Generate code for an expanded version of BPF, which relaxes some of
24464 the restrictions imposed by the BPF architecture:
24466 @item Save and restore callee-saved registers at function entry and
24467 exit, respectively.
24472 @subsection FR30 Options
24473 @cindex FR30 Options
24475 These options are defined specifically for the FR30 port.
24479 @item -msmall-model
24480 @opindex msmall-model
24481 Use the small address space model. This can produce smaller code, but
24482 it does assume that all symbolic values and addresses fit into a
24487 Assume that runtime support has been provided and so there is no need
24488 to include the simulator library (@file{libsim.a}) on the linker
24494 @subsection FT32 Options
24495 @cindex FT32 Options
24497 These options are defined specifically for the FT32 port.
24503 Specifies that the program will be run on the simulator. This causes
24504 an alternate runtime startup and library to be linked.
24505 You must not use this option when generating programs that will run on
24506 real hardware; you must provide your own runtime library for whatever
24507 I/O functions are needed.
24511 Enable Local Register Allocation. This is still experimental for FT32,
24512 so by default the compiler uses standard reload.
24516 Do not use div and mod instructions.
24520 Enable use of the extended instructions of the FT32B processor.
24524 Compress all code using the Ft32B code compression scheme.
24528 Do not generate code that reads program memory.
24533 @subsection FRV Options
24534 @cindex FRV Options
24540 Only use the first 32 general-purpose registers.
24545 Use all 64 general-purpose registers.
24550 Use only the first 32 floating-point registers.
24555 Use all 64 floating-point registers.
24558 @opindex mhard-float
24560 Use hardware instructions for floating-point operations.
24563 @opindex msoft-float
24565 Use library routines for floating-point operations.
24570 Dynamically allocate condition code registers.
24575 Do not try to dynamically allocate condition code registers, only
24576 use @code{icc0} and @code{fcc0}.
24581 Change ABI to use double word insns.
24587 Do not use double word instructions.
24592 Use floating-point double instructions.
24595 @opindex mno-double
24597 Do not use floating-point double instructions.
24602 Use media instructions.
24607 Do not use media instructions.
24612 Use multiply and add/subtract instructions.
24615 @opindex mno-muladd
24617 Do not use multiply and add/subtract instructions.
24622 Select the FDPIC ABI, which uses function descriptors to represent
24623 pointers to functions. Without any PIC/PIE-related options, it
24624 implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
24625 assumes GOT entries and small data are within a 12-bit range from the
24626 GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
24627 are computed with 32 bits.
24628 With a @samp{bfin-elf} target, this option implies @option{-msim}.
24631 @opindex minline-plt
24633 Enable inlining of PLT entries in function calls to functions that are
24634 not known to bind locally. It has no effect without @option{-mfdpic}.
24635 It's enabled by default if optimizing for speed and compiling for
24636 shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
24637 optimization option such as @option{-O3} or above is present in the
24643 Assume a large TLS segment when generating thread-local code.
24648 Do not assume a large TLS segment when generating thread-local code.
24653 Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
24654 that is known to be in read-only sections. It's enabled by default,
24655 except for @option{-fpic} or @option{-fpie}: even though it may help
24656 make the global offset table smaller, it trades 1 instruction for 4.
24657 With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
24658 one of which may be shared by multiple symbols, and it avoids the need
24659 for a GOT entry for the referenced symbol, so it's more likely to be a
24660 win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
24662 @item -multilib-library-pic
24663 @opindex multilib-library-pic
24665 Link with the (library, not FD) pic libraries. It's implied by
24666 @option{-mlibrary-pic}, as well as by @option{-fPIC} and
24667 @option{-fpic} without @option{-mfdpic}. You should never have to use
24671 @opindex mlinked-fp
24673 Follow the EABI requirement of always creating a frame pointer whenever
24674 a stack frame is allocated. This option is enabled by default and can
24675 be disabled with @option{-mno-linked-fp}.
24678 @opindex mlong-calls
24680 Use indirect addressing to call functions outside the current
24681 compilation unit. This allows the functions to be placed anywhere
24682 within the 32-bit address space.
24684 @item -malign-labels
24685 @opindex malign-labels
24687 Try to align labels to an 8-byte boundary by inserting NOPs into the
24688 previous packet. This option only has an effect when VLIW packing
24689 is enabled. It doesn't create new packets; it merely adds NOPs to
24692 @item -mlibrary-pic
24693 @opindex mlibrary-pic
24695 Generate position-independent EABI code.
24700 Use only the first four media accumulator registers.
24705 Use all eight media accumulator registers.
24710 Pack VLIW instructions.
24715 Do not pack VLIW instructions.
24718 @opindex mno-eflags
24720 Do not mark ABI switches in e_flags.
24723 @opindex mcond-move
24725 Enable the use of conditional-move instructions (default).
24727 This switch is mainly for debugging the compiler and will likely be removed
24728 in a future version.
24730 @item -mno-cond-move
24731 @opindex mno-cond-move
24733 Disable the use of conditional-move instructions.
24735 This switch is mainly for debugging the compiler and will likely be removed
24736 in a future version.
24741 Enable the use of conditional set instructions (default).
24743 This switch is mainly for debugging the compiler and will likely be removed
24744 in a future version.
24749 Disable the use of conditional set instructions.
24751 This switch is mainly for debugging the compiler and will likely be removed
24752 in a future version.
24755 @opindex mcond-exec
24757 Enable the use of conditional execution (default).
24759 This switch is mainly for debugging the compiler and will likely be removed
24760 in a future version.
24762 @item -mno-cond-exec
24763 @opindex mno-cond-exec
24765 Disable the use of conditional execution.
24767 This switch is mainly for debugging the compiler and will likely be removed
24768 in a future version.
24770 @item -mvliw-branch
24771 @opindex mvliw-branch
24773 Run a pass to pack branches into VLIW instructions (default).
24775 This switch is mainly for debugging the compiler and will likely be removed
24776 in a future version.
24778 @item -mno-vliw-branch
24779 @opindex mno-vliw-branch
24781 Do not run a pass to pack branches into VLIW instructions.
24783 This switch is mainly for debugging the compiler and will likely be removed
24784 in a future version.
24786 @item -mmulti-cond-exec
24787 @opindex mmulti-cond-exec
24789 Enable optimization of @code{&&} and @code{||} in conditional execution
24792 This switch is mainly for debugging the compiler and will likely be removed
24793 in a future version.
24795 @item -mno-multi-cond-exec
24796 @opindex mno-multi-cond-exec
24798 Disable optimization of @code{&&} and @code{||} in conditional execution.
24800 This switch is mainly for debugging the compiler and will likely be removed
24801 in a future version.
24803 @item -mnested-cond-exec
24804 @opindex mnested-cond-exec
24806 Enable nested conditional execution optimizations (default).
24808 This switch is mainly for debugging the compiler and will likely be removed
24809 in a future version.
24811 @item -mno-nested-cond-exec
24812 @opindex mno-nested-cond-exec
24814 Disable nested conditional execution optimizations.
24816 This switch is mainly for debugging the compiler and will likely be removed
24817 in a future version.
24819 @item -moptimize-membar
24820 @opindex moptimize-membar
24822 This switch removes redundant @code{membar} instructions from the
24823 compiler-generated code. It is enabled by default.
24825 @item -mno-optimize-membar
24826 @opindex mno-optimize-membar
24827 @opindex moptimize-membar
24829 This switch disables the automatic removal of redundant @code{membar}
24830 instructions from the generated code.
24832 @item -mtomcat-stats
24833 @opindex mtomcat-stats
24835 Cause gas to print out tomcat statistics.
24837 @item -mcpu=@var{cpu}
24840 Select the processor type for which to generate code. Possible values are
24841 @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
24842 @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
24846 @node GNU/Linux Options
24847 @subsection GNU/Linux Options
24849 These @samp{-m} options are defined for GNU/Linux targets:
24854 Use the GNU C library. This is the default except
24855 on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
24856 @samp{*-*-linux-*android*} targets.
24860 Use uClibc C library. This is the default on
24861 @samp{*-*-linux-*uclibc*} targets.
24865 Use the musl C library. This is the default on
24866 @samp{*-*-linux-*musl*} targets.
24870 Use Bionic C library. This is the default on
24871 @samp{*-*-linux-*android*} targets.
24875 Compile code compatible with Android platform. This is the default on
24876 @samp{*-*-linux-*android*} targets.
24878 When compiling, this option enables @option{-mbionic}, @option{-fPIC},
24879 @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
24880 this option makes the GCC driver pass Android-specific options to the linker.
24881 Finally, this option causes the preprocessor macro @code{__ANDROID__}
24884 @item -tno-android-cc
24885 @opindex tno-android-cc
24886 Disable compilation effects of @option{-mandroid}, i.e., do not enable
24887 @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
24888 @option{-fno-rtti} by default.
24890 @item -tno-android-ld
24891 @opindex tno-android-ld
24892 Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
24893 linking options to the linker.
24897 @node H8/300 Options
24898 @subsection H8/300 Options
24900 These @samp{-m} options are defined for the H8/300 implementations:
24905 Shorten some address references at link time, when possible; uses the
24906 linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
24907 ld, Using ld}, for a fuller description.
24911 Generate code for the H8/300H@.
24915 Generate code for the H8S@.
24919 Generate code for the H8S and H8/300H in the normal mode. This switch
24920 must be used either with @option{-mh} or @option{-ms}.
24924 Generate code for the H8S/2600. This switch must be used with @option{-ms}.
24928 Extended registers are stored on stack before execution of function
24929 with monitor attribute. Default option is @option{-mexr}.
24930 This option is valid only for H8S targets.
24935 Extended registers are not stored on stack before execution of function
24936 with monitor attribute. Default option is @option{-mno-exr}.
24937 This option is valid only for H8S targets.
24941 Make @code{int} data 32 bits by default.
24944 @opindex malign-300
24945 On the H8/300H and H8S, use the same alignment rules as for the H8/300.
24946 The default for the H8/300H and H8S is to align longs and floats on
24948 @option{-malign-300} causes them to be aligned on 2-byte boundaries.
24949 This option has no effect on the H8/300.
24953 @subsection HPPA Options
24954 @cindex HPPA Options
24956 These @samp{-m} options are defined for the HPPA family of computers:
24959 @item -march=@var{architecture-type}
24961 Generate code for the specified architecture. The choices for
24962 @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
24963 1.1, and @samp{2.0} for PA 2.0 processors. Refer to
24964 @file{/usr/lib/sched.models} on an HP-UX system to determine the proper
24965 architecture option for your machine. Code compiled for lower numbered
24966 architectures runs on higher numbered architectures, but not the
24969 @item -mpa-risc-1-0
24970 @itemx -mpa-risc-1-1
24971 @itemx -mpa-risc-2-0
24972 @opindex mpa-risc-1-0
24973 @opindex mpa-risc-1-1
24974 @opindex mpa-risc-2-0
24975 Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
24977 @item -matomic-libcalls
24978 @opindex matomic-libcalls
24979 @opindex mno-atomic-libcalls
24980 Generate libcalls for atomic loads and stores when sync libcalls are disabled.
24981 This option is enabled by default. It only affects the generation of
24982 atomic libcalls by the HPPA backend.
24984 Both the sync and @file{libatomic} libcall implementations use locking.
24985 As a result, processor stores are not atomic with respect to other
24986 atomic operations. Processor loads up to DImode are atomic with
24987 respect to other atomic operations provided they are implemented as
24990 The PA-RISC architecture does not support any atomic operations in
24991 hardware except for the @code{ldcw} instruction. Thus, all atomic
24992 support is implemented using sync and atomic libcalls. Sync libcall
24993 support is in @file{libgcc.a}. Atomic libcall support is in
24996 This option generates @code{__atomic_exchange} calls for atomic stores.
24997 It also provides special handling for atomic DImode accesses on 32-bit
25001 @opindex mbig-switch
25002 Does nothing. Preserved for backward compatibility.
25004 @item -mcaller-copies
25005 @opindex mcaller-copies
25006 The caller copies function arguments passed by hidden reference. This
25007 option should be used with care as it is not compatible with the default
25008 32-bit runtime. However, only aggregates larger than eight bytes are
25009 passed by hidden reference and the option provides better compatibility
25012 @item -mcoherent-ldcw
25013 @opindex mcoherent-ldcw
25014 Use ldcw/ldcd coherent cache-control hint.
25016 @item -mdisable-fpregs
25017 @opindex mdisable-fpregs
25018 Disable floating-point registers. Equivalent to @code{-msoft-float}.
25020 @item -mdisable-indexing
25021 @opindex mdisable-indexing
25022 Prevent the compiler from using indexing address modes. This avoids some
25023 rather obscure problems when compiling MIG generated code under MACH@.
25025 @item -mfast-indirect-calls
25026 @opindex mfast-indirect-calls
25027 Generate code that assumes calls never cross space boundaries. This
25028 allows GCC to emit code that performs faster indirect calls.
25030 This option does not work in the presence of shared libraries or nested
25033 @item -mfixed-range=@var{register-range}
25034 @opindex mfixed-range
25035 Generate code treating the given register range as fixed registers.
25036 A fixed register is one that the register allocator cannot use. This is
25037 useful when compiling kernel code. A register range is specified as
25038 two registers separated by a dash. Multiple register ranges can be
25039 specified separated by a comma.
25043 Enable the use of assembler directives only GAS understands.
25047 Use options specific to GNU @command{ld}.
25048 This passes @option{-shared} to @command{ld} when
25049 building a shared library. It is the default when GCC is configured,
25050 explicitly or implicitly, with the GNU linker. This option does not
25051 affect which @command{ld} is called; it only changes what parameters
25052 are passed to that @command{ld}.
25053 The @command{ld} that is called is determined by the
25054 @option{--with-ld} configure option, GCC's program search path, and
25055 finally by the user's @env{PATH}. The linker used by GCC can be printed
25056 using @samp{which `gcc -print-prog-name=ld`}. This option is only available
25057 on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25061 Use options specific to HP @command{ld}.
25062 This passes @option{-b} to @command{ld} when building
25063 a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
25064 links. It is the default when GCC is configured, explicitly or
25065 implicitly, with the HP linker. This option does not affect
25066 which @command{ld} is called; it only changes what parameters are passed to that
25068 The @command{ld} that is called is determined by the @option{--with-ld}
25069 configure option, GCC's program search path, and finally by the user's
25070 @env{PATH}. The linker used by GCC can be printed using @samp{which
25071 `gcc -print-prog-name=ld`}. This option is only available on the 64-bit
25072 HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25075 @opindex mlinker-opt
25076 Enable the optimization pass in the HP-UX linker. Note this makes symbolic
25077 debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
25078 linkers in which they give bogus error messages when linking some programs.
25081 @opindex mno-long-calls
25082 @opindex mlong-calls
25083 Generate code that uses long call sequences. This ensures that a call
25084 is always able to reach linker generated stubs. The default is to generate
25085 long calls only when the distance from the call site to the beginning
25086 of the function or translation unit, as the case may be, exceeds a
25087 predefined limit set by the branch type being used. The limits for
25088 normal calls are 7,600,000 and 240,000 bytes, respectively for the
25089 PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25092 Distances are measured from the beginning of functions when using the
25093 @option{-ffunction-sections} option, or when using the @option{-mgas}
25094 and @option{-mno-portable-runtime} options together under HP-UX with
25097 It is normally not desirable to use this option as it degrades
25098 performance. However, it may be useful in large applications,
25099 particularly when partial linking is used to build the application.
25101 The types of long calls used depends on the capabilities of the
25102 assembler and linker, and the type of code being generated. The
25103 impact on systems that support long absolute calls, and long pic
25104 symbol-difference or pc-relative calls should be relatively small.
25105 However, an indirect call is used on 32-bit ELF systems in pic code
25106 and it is quite long.
25108 @item -mlong-load-store
25109 @opindex mlong-load-store
25110 Generate 3-instruction load and store sequences as sometimes required by
25111 the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
25114 @item -mjump-in-delay
25115 @opindex mjump-in-delay
25116 This option is ignored and provided for compatibility purposes only.
25118 @item -mno-space-regs
25119 @opindex mno-space-regs
25120 @opindex mspace-regs
25121 Generate code that assumes the target has no space registers. This allows
25122 GCC to generate faster indirect calls and use unscaled index address modes.
25124 Such code is suitable for level 0 PA systems and kernels.
25128 Assume memory references are ordered and barriers are not needed.
25130 @item -mportable-runtime
25131 @opindex mportable-runtime
25132 Use the portable calling conventions proposed by HP for ELF systems.
25134 @item -mschedule=@var{cpu-type}
25136 Schedule code according to the constraints for the machine type
25137 @var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
25138 @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
25139 to @file{/usr/lib/sched.models} on an HP-UX system to determine the
25140 proper scheduling option for your machine. The default scheduling is
25145 Generate the predefine, @code{_SIO}, for server IO@. The default is
25146 @option{-mwsio}. This generates the predefines, @code{__hp9000s700},
25147 @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
25148 options are available under HP-UX and HI-UX@.
25151 @opindex msoft-float
25152 Generate output containing library calls for floating point.
25153 @strong{Warning:} the requisite libraries are not available for all HPPA
25154 targets. Normally the facilities of the machine's usual C compiler are
25155 used, but this cannot be done directly in cross-compilation. You must make
25156 your own arrangements to provide suitable library functions for
25159 @option{-msoft-float} changes the calling convention in the output file;
25160 therefore, it is only useful if you compile @emph{all} of a program with
25161 this option. In particular, you need to compile @file{libgcc.a}, the
25162 library that comes with GCC, with @option{-msoft-float} in order for
25166 @opindex msoft-mult
25167 Use software integer multiplication.
25169 This disables the use of the @code{xmpyu} instruction.
25171 @item -munix=@var{unix-std}
25173 Generate compiler predefines and select a startfile for the specified
25174 UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25175 and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25176 is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
25177 11.11 and later. The default values are @samp{93} for HP-UX 10.00,
25178 @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25181 @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25182 @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25183 and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25184 @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25185 @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25186 @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25188 It is @emph{important} to note that this option changes the interfaces
25189 for various library routines. It also affects the operational behavior
25190 of the C library. Thus, @emph{extreme} care is needed in using this
25193 Library code that is intended to operate with more than one UNIX
25194 standard must test, set and restore the variable @code{__xpg4_extended_mask}
25195 as appropriate. Most GNU software doesn't provide this capability.
25199 Suppress the generation of link options to search libdld.sl when the
25200 @option{-static} option is specified on HP-UX 10 and later.
25204 The HP-UX implementation of setlocale in libc has a dependency on
25205 libdld.sl. There isn't an archive version of libdld.sl. Thus,
25206 when the @option{-static} option is specified, special link options
25207 are needed to resolve this dependency.
25209 On HP-UX 10 and later, the GCC driver adds the necessary options to
25210 link with libdld.sl when the @option{-static} option is specified.
25211 This causes the resulting binary to be dynamic. On the 64-bit port,
25212 the linkers generate dynamic binaries by default in any case. The
25213 @option{-nolibdld} option can be used to prevent the GCC driver from
25214 adding these link options.
25218 Add support for multithreading with the @dfn{dce thread} library
25219 under HP-UX@. This option sets flags for both the preprocessor and
25223 @node IA-64 Options
25224 @subsection IA-64 Options
25225 @cindex IA-64 Options
25227 These are the @samp{-m} options defined for the Intel IA-64 architecture.
25231 @opindex mbig-endian
25232 Generate code for a big-endian target. This is the default for HP-UX@.
25234 @item -mlittle-endian
25235 @opindex mlittle-endian
25236 Generate code for a little-endian target. This is the default for AIX5
25242 @opindex mno-gnu-as
25243 Generate (or don't) code for the GNU assembler. This is the default.
25244 @c Also, this is the default if the configure option @option{--with-gnu-as}
25250 @opindex mno-gnu-ld
25251 Generate (or don't) code for the GNU linker. This is the default.
25252 @c Also, this is the default if the configure option @option{--with-gnu-ld}
25257 Generate code that does not use a global pointer register. The result
25258 is not position independent code, and violates the IA-64 ABI@.
25260 @item -mvolatile-asm-stop
25261 @itemx -mno-volatile-asm-stop
25262 @opindex mvolatile-asm-stop
25263 @opindex mno-volatile-asm-stop
25264 Generate (or don't) a stop bit immediately before and after volatile asm
25267 @item -mregister-names
25268 @itemx -mno-register-names
25269 @opindex mregister-names
25270 @opindex mno-register-names
25271 Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25272 the stacked registers. This may make assembler output more readable.
25278 Disable (or enable) optimizations that use the small data section. This may
25279 be useful for working around optimizer bugs.
25281 @item -mconstant-gp
25282 @opindex mconstant-gp
25283 Generate code that uses a single constant global pointer value. This is
25284 useful when compiling kernel code.
25288 Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25289 This is useful when compiling firmware code.
25291 @item -minline-float-divide-min-latency
25292 @opindex minline-float-divide-min-latency
25293 Generate code for inline divides of floating-point values
25294 using the minimum latency algorithm.
25296 @item -minline-float-divide-max-throughput
25297 @opindex minline-float-divide-max-throughput
25298 Generate code for inline divides of floating-point values
25299 using the maximum throughput algorithm.
25301 @item -mno-inline-float-divide
25302 @opindex mno-inline-float-divide
25303 Do not generate inline code for divides of floating-point values.
25305 @item -minline-int-divide-min-latency
25306 @opindex minline-int-divide-min-latency
25307 Generate code for inline divides of integer values
25308 using the minimum latency algorithm.
25310 @item -minline-int-divide-max-throughput
25311 @opindex minline-int-divide-max-throughput
25312 Generate code for inline divides of integer values
25313 using the maximum throughput algorithm.
25315 @item -mno-inline-int-divide
25316 @opindex mno-inline-int-divide
25317 @opindex minline-int-divide
25318 Do not generate inline code for divides of integer values.
25320 @item -minline-sqrt-min-latency
25321 @opindex minline-sqrt-min-latency
25322 Generate code for inline square roots
25323 using the minimum latency algorithm.
25325 @item -minline-sqrt-max-throughput
25326 @opindex minline-sqrt-max-throughput
25327 Generate code for inline square roots
25328 using the maximum throughput algorithm.
25330 @item -mno-inline-sqrt
25331 @opindex mno-inline-sqrt
25332 Do not generate inline code for @code{sqrt}.
25335 @itemx -mno-fused-madd
25336 @opindex mfused-madd
25337 @opindex mno-fused-madd
25338 Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25339 instructions. The default is to use these instructions.
25341 @item -mno-dwarf2-asm
25342 @itemx -mdwarf2-asm
25343 @opindex mno-dwarf2-asm
25344 @opindex mdwarf2-asm
25345 Don't (or do) generate assembler code for the DWARF line number debugging
25346 info. This may be useful when not using the GNU assembler.
25348 @item -mearly-stop-bits
25349 @itemx -mno-early-stop-bits
25350 @opindex mearly-stop-bits
25351 @opindex mno-early-stop-bits
25352 Allow stop bits to be placed earlier than immediately preceding the
25353 instruction that triggered the stop bit. This can improve instruction
25354 scheduling, but does not always do so.
25356 @item -mfixed-range=@var{register-range}
25357 @opindex mfixed-range
25358 Generate code treating the given register range as fixed registers.
25359 A fixed register is one that the register allocator cannot use. This is
25360 useful when compiling kernel code. A register range is specified as
25361 two registers separated by a dash. Multiple register ranges can be
25362 specified separated by a comma.
25364 @item -mtls-size=@var{tls-size}
25366 Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
25369 @item -mtune=@var{cpu-type}
25371 Tune the instruction scheduling for a particular CPU, Valid values are
25372 @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25373 and @samp{mckinley}.
25379 Generate code for a 32-bit or 64-bit environment.
25380 The 32-bit environment sets int, long and pointer to 32 bits.
25381 The 64-bit environment sets int to 32 bits and long and pointer
25382 to 64 bits. These are HP-UX specific flags.
25384 @item -mno-sched-br-data-spec
25385 @itemx -msched-br-data-spec
25386 @opindex mno-sched-br-data-spec
25387 @opindex msched-br-data-spec
25388 (Dis/En)able data speculative scheduling before reload.
25389 This results in generation of @code{ld.a} instructions and
25390 the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25391 The default setting is disabled.
25393 @item -msched-ar-data-spec
25394 @itemx -mno-sched-ar-data-spec
25395 @opindex msched-ar-data-spec
25396 @opindex mno-sched-ar-data-spec
25397 (En/Dis)able data speculative scheduling after reload.
25398 This results in generation of @code{ld.a} instructions and
25399 the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25400 The default setting is enabled.
25402 @item -mno-sched-control-spec
25403 @itemx -msched-control-spec
25404 @opindex mno-sched-control-spec
25405 @opindex msched-control-spec
25406 (Dis/En)able control speculative scheduling. This feature is
25407 available only during region scheduling (i.e.@: before reload).
25408 This results in generation of the @code{ld.s} instructions and
25409 the corresponding check instructions @code{chk.s}.
25410 The default setting is disabled.
25412 @item -msched-br-in-data-spec
25413 @itemx -mno-sched-br-in-data-spec
25414 @opindex msched-br-in-data-spec
25415 @opindex mno-sched-br-in-data-spec
25416 (En/Dis)able speculative scheduling of the instructions that
25417 are dependent on the data speculative loads before reload.
25418 This is effective only with @option{-msched-br-data-spec} enabled.
25419 The default setting is enabled.
25421 @item -msched-ar-in-data-spec
25422 @itemx -mno-sched-ar-in-data-spec
25423 @opindex msched-ar-in-data-spec
25424 @opindex mno-sched-ar-in-data-spec
25425 (En/Dis)able speculative scheduling of the instructions that
25426 are dependent on the data speculative loads after reload.
25427 This is effective only with @option{-msched-ar-data-spec} enabled.
25428 The default setting is enabled.
25430 @item -msched-in-control-spec
25431 @itemx -mno-sched-in-control-spec
25432 @opindex msched-in-control-spec
25433 @opindex mno-sched-in-control-spec
25434 (En/Dis)able speculative scheduling of the instructions that
25435 are dependent on the control speculative loads.
25436 This is effective only with @option{-msched-control-spec} enabled.
25437 The default setting is enabled.
25439 @item -mno-sched-prefer-non-data-spec-insns
25440 @itemx -msched-prefer-non-data-spec-insns
25441 @opindex mno-sched-prefer-non-data-spec-insns
25442 @opindex msched-prefer-non-data-spec-insns
25443 If enabled, data-speculative instructions are chosen for schedule
25444 only if there are no other choices at the moment. This makes
25445 the use of the data speculation much more conservative.
25446 The default setting is disabled.
25448 @item -mno-sched-prefer-non-control-spec-insns
25449 @itemx -msched-prefer-non-control-spec-insns
25450 @opindex mno-sched-prefer-non-control-spec-insns
25451 @opindex msched-prefer-non-control-spec-insns
25452 If enabled, control-speculative instructions are chosen for schedule
25453 only if there are no other choices at the moment. This makes
25454 the use of the control speculation much more conservative.
25455 The default setting is disabled.
25457 @item -mno-sched-count-spec-in-critical-path
25458 @itemx -msched-count-spec-in-critical-path
25459 @opindex mno-sched-count-spec-in-critical-path
25460 @opindex msched-count-spec-in-critical-path
25461 If enabled, speculative dependencies are considered during
25462 computation of the instructions priorities. This makes the use of the
25463 speculation a bit more conservative.
25464 The default setting is disabled.
25466 @item -msched-spec-ldc
25467 @opindex msched-spec-ldc
25468 Use a simple data speculation check. This option is on by default.
25470 @item -msched-control-spec-ldc
25471 @opindex msched-spec-ldc
25472 Use a simple check for control speculation. This option is on by default.
25474 @item -msched-stop-bits-after-every-cycle
25475 @opindex msched-stop-bits-after-every-cycle
25476 Place a stop bit after every cycle when scheduling. This option is on
25479 @item -msched-fp-mem-deps-zero-cost
25480 @opindex msched-fp-mem-deps-zero-cost
25481 Assume that floating-point stores and loads are not likely to cause a conflict
25482 when placed into the same instruction group. This option is disabled by
25485 @item -msel-sched-dont-check-control-spec
25486 @opindex msel-sched-dont-check-control-spec
25487 Generate checks for control speculation in selective scheduling.
25488 This flag is disabled by default.
25490 @item -msched-max-memory-insns=@var{max-insns}
25491 @opindex msched-max-memory-insns
25492 Limit on the number of memory insns per instruction group, giving lower
25493 priority to subsequent memory insns attempting to schedule in the same
25494 instruction group. Frequently useful to prevent cache bank conflicts.
25495 The default value is 1.
25497 @item -msched-max-memory-insns-hard-limit
25498 @opindex msched-max-memory-insns-hard-limit
25499 Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
25500 disallowing more than that number in an instruction group.
25501 Otherwise, the limit is ``soft'', meaning that non-memory operations
25502 are preferred when the limit is reached, but memory operations may still
25508 @subsection LM32 Options
25509 @cindex LM32 options
25511 These @option{-m} options are defined for the LatticeMico32 architecture:
25514 @item -mbarrel-shift-enabled
25515 @opindex mbarrel-shift-enabled
25516 Enable barrel-shift instructions.
25518 @item -mdivide-enabled
25519 @opindex mdivide-enabled
25520 Enable divide and modulus instructions.
25522 @item -mmultiply-enabled
25523 @opindex multiply-enabled
25524 Enable multiply instructions.
25526 @item -msign-extend-enabled
25527 @opindex msign-extend-enabled
25528 Enable sign extend instructions.
25530 @item -muser-enabled
25531 @opindex muser-enabled
25532 Enable user-defined instructions.
25536 @node LoongArch Options
25537 @subsection LoongArch Options
25538 @cindex LoongArch Options
25540 These command-line options are defined for LoongArch targets:
25543 @item -march=@var{cpu-type}
25545 Generate instructions for the machine type @var{cpu-type}. In contrast to
25546 @option{-mtune=@var{cpu-type}}, which merely tunes the generated code
25547 for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
25548 to generate code that may not run at all on processors other than the one
25549 indicated. Specifying @option{-march=@var{cpu-type}} implies
25550 @option{-mtune=@var{cpu-type}}, except where noted otherwise.
25552 The choices for @var{cpu-type} are:
25556 This selects the CPU to generate code for at compilation time by determining
25557 the processor type of the compiling machine. Using @option{-march=native}
25558 enables all instruction subsets supported by the local machine (hence
25559 the result might not run on different machines). Using @option{-mtune=native}
25560 produces code optimized for the local machine under the constraints
25561 of the selected instruction set.
25563 A generic CPU with 64-bit extensions.
25565 LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
25568 @item -mtune=@var{cpu-type}
25570 Optimize the output for the given processor, specified by microarchitecture
25573 @item -mabi=@var{base-abi-type}
25575 Generate code for the specified calling convention.
25576 @var{base-abi-type} can be one of:
25579 Uses 64-bit general purpose registers and 32/64-bit floating-point
25580 registers for parameter passing. Data model is LP64, where @samp{int}
25581 is 32 bits, while @samp{long int} and pointers are 64 bits.
25583 Uses 64-bit general purpose registers and 32-bit floating-point
25584 registers for parameter passing. Data model is LP64, where @samp{int}
25585 is 32 bits, while @samp{long int} and pointers are 64 bits.
25587 Uses 64-bit general purpose registers and no floating-point
25588 registers for parameter passing. Data model is LP64, where @samp{int}
25589 is 32 bits, while @samp{long int} and pointers are 64 bits.
25592 @item -mfpu=@var{fpu-type}
25594 Generate code for the specified FPU type, which can be one of:
25597 Allow the use of hardware floating-point instructions for 32-bit
25598 and 64-bit operations.
25600 Allow the use of hardware floating-point instructions for 32-bit
25604 Prevent the use of hardware floating-point instructions.
25608 @opindex msoft-float
25609 Force @option{-mfpu=none} and prevents the use of floating-point
25610 registers for parameter passing. This option may change the target
25613 @item -msingle-float
25614 @opindex msingle-float
25615 Force @option{-mfpu=32} and allow the use of 32-bit floating-point
25616 registers for parameter passing. This option may change the target
25619 @item -mdouble-float
25620 @opindex mdouble-float
25621 Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
25622 registers for parameter passing. This option may change the target
25625 @item -mbranch-cost=@var{n}
25626 @opindex mbranch-cost
25627 Set the cost of branches to roughly @var{n} instructions.
25629 @item -mcheck-zero-division
25630 @itemx -mno-check-zero-divison
25631 @opindex mcheck-zero-division
25632 Trap (do not trap) on integer division by zero. The default is
25633 @option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
25634 @option{-mno-check-zero-division} for other optimization levels.
25636 @item -mcond-move-int
25637 @itemx -mno-cond-move-int
25638 @opindex mcond-move-int
25639 Conditional moves for integral data in general-purpose registers
25640 are enabled (disabled). The default is @option{-mcond-move-int}.
25642 @item -mcond-move-float
25643 @itemx -mno-cond-move-float
25644 @opindex mcond-move-float
25645 Conditional moves for floating-point registers are enabled (disabled).
25646 The default is @option{-mcond-move-float}.
25651 Force (do not force) the use of @code{memcpy} for non-trivial block moves.
25652 The default is @option{-mno-memcpy}, which allows GCC to inline most
25653 constant-sized copies. Setting optimization level to @option{-Os} also
25654 forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
25655 behavior if explicitly specified, regardless of the order these options on
25658 @item -mstrict-align
25659 @itemx -mno-strict-align
25660 @opindex mstrict-align
25661 Avoid or allow generating memory accesses that may not be aligned on a natural
25662 object boundary as described in the architecture specification. The default is
25663 @option{-mno-strict-align}.
25665 @item -msmall-data-limit=@var{number}
25666 @opindex msmall-data-limit
25667 Put global and static data smaller than @var{number} bytes into a special
25668 section (on some targets). The default value is 0.
25670 @item -mmax-inline-memcpy-size=@var{n}
25671 @opindex mmax-inline-memcpy-size
25672 Inline all block moves (such as calls to @code{memcpy} or structure copies)
25673 less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
25675 @item -mcmodel=@var{code-model}
25676 Set the code model to one of:
25678 @item tiny-static (Not implemented yet)
25679 @item tiny (Not implemented yet)
25682 The text segment must be within 128MB addressing space. The data segment must
25683 be within 2GB addressing space.
25686 The text segment and data segment must be within 2GB addressing space.
25688 @item large (Not implemented yet)
25691 This mode does not limit the size of the code segment and data segment.
25692 The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and
25693 @option{-mno-explicit-relocs}.
25695 The default code model is @code{normal}.
25697 @item -mexplicit-relocs
25698 @itemx -mno-explicit-relocs
25699 @opindex mexplicit-relocs
25700 @opindex mno-explicit-relocs
25701 Use or do not use assembler relocation operators when dealing with symbolic
25702 addresses. The alternative is to use assembler macros instead, which may
25703 limit optimization. The default value for the option is determined during
25704 GCC build-time by detecting corresponding assembler support:
25705 @code{-mexplicit-relocs} if said support is present,
25706 @code{-mno-explicit-relocs} otherwise. This option is mostly useful for
25707 debugging, or interoperation with assemblers different from the build-time
25710 @item -mdirect-extern-access
25711 @itemx -mno-direct-extern-access
25712 @opindex mdirect-extern-access
25713 Do not use or use GOT to access external symbols. The default is
25714 @option{-mno-direct-extern-access}: GOT is used for external symbols with
25715 default visibility, but not used for other external symbols.
25717 With @option{-mdirect-extern-access}, GOT is not used and all external
25718 symbols are PC-relatively addressed. It is @strong{only} suitable for
25719 environments where no dynamic link is performed, like firmwares, OS
25720 kernels, executables linked with @option{-static} or @option{-static-pie}.
25721 @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
25726 @subsection M32C Options
25727 @cindex M32C options
25730 @item -mcpu=@var{name}
25732 Select the CPU for which code is generated. @var{name} may be one of
25733 @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
25734 /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
25735 the M32C/80 series.
25739 Specifies that the program will be run on the simulator. This causes
25740 an alternate runtime library to be linked in which supports, for
25741 example, file I/O@. You must not use this option when generating
25742 programs that will run on real hardware; you must provide your own
25743 runtime library for whatever I/O functions are needed.
25745 @item -memregs=@var{number}
25747 Specifies the number of memory-based pseudo-registers GCC uses
25748 during code generation. These pseudo-registers are used like real
25749 registers, so there is a tradeoff between GCC's ability to fit the
25750 code into available registers, and the performance penalty of using
25751 memory instead of registers. Note that all modules in a program must
25752 be compiled with the same value for this option. Because of that, you
25753 must not use this option with GCC's default runtime libraries.
25757 @node M32R/D Options
25758 @subsection M32R/D Options
25759 @cindex M32R/D options
25761 These @option{-m} options are defined for Renesas M32R/D architectures:
25766 Generate code for the M32R/2@.
25770 Generate code for the M32R/X@.
25774 Generate code for the M32R@. This is the default.
25776 @item -mmodel=small
25777 @opindex mmodel=small
25778 Assume all objects live in the lower 16MB of memory (so that their addresses
25779 can be loaded with the @code{ld24} instruction), and assume all subroutines
25780 are reachable with the @code{bl} instruction.
25781 This is the default.
25783 The addressability of a particular object can be set with the
25784 @code{model} attribute.
25786 @item -mmodel=medium
25787 @opindex mmodel=medium
25788 Assume objects may be anywhere in the 32-bit address space (the compiler
25789 generates @code{seth/add3} instructions to load their addresses), and
25790 assume all subroutines are reachable with the @code{bl} instruction.
25792 @item -mmodel=large
25793 @opindex mmodel=large
25794 Assume objects may be anywhere in the 32-bit address space (the compiler
25795 generates @code{seth/add3} instructions to load their addresses), and
25796 assume subroutines may not be reachable with the @code{bl} instruction
25797 (the compiler generates the much slower @code{seth/add3/jl}
25798 instruction sequence).
25801 @opindex msdata=none
25802 Disable use of the small data area. Variables are put into
25803 one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
25804 @code{section} attribute has been specified).
25805 This is the default.
25807 The small data area consists of sections @code{.sdata} and @code{.sbss}.
25808 Objects may be explicitly put in the small data area with the
25809 @code{section} attribute using one of these sections.
25811 @item -msdata=sdata
25812 @opindex msdata=sdata
25813 Put small global and static data in the small data area, but do not
25814 generate special code to reference them.
25817 @opindex msdata=use
25818 Put small global and static data in the small data area, and generate
25819 special instructions to reference them.
25823 @cindex smaller data references
25824 Put global and static objects less than or equal to @var{num} bytes
25825 into the small data or BSS sections instead of the normal data or BSS
25826 sections. The default value of @var{num} is 8.
25827 The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
25828 for this option to have any effect.
25830 All modules should be compiled with the same @option{-G @var{num}} value.
25831 Compiling with different values of @var{num} may or may not work; if it
25832 doesn't the linker gives an error message---incorrect code is not
25837 Makes the M32R-specific code in the compiler display some statistics
25838 that might help in debugging programs.
25840 @item -malign-loops
25841 @opindex malign-loops
25842 Align all loops to a 32-byte boundary.
25844 @item -mno-align-loops
25845 @opindex mno-align-loops
25846 Do not enforce a 32-byte alignment for loops. This is the default.
25848 @item -missue-rate=@var{number}
25849 @opindex missue-rate=@var{number}
25850 Issue @var{number} instructions per cycle. @var{number} can only be 1
25853 @item -mbranch-cost=@var{number}
25854 @opindex mbranch-cost=@var{number}
25855 @var{number} can only be 1 or 2. If it is 1 then branches are
25856 preferred over conditional code, if it is 2, then the opposite applies.
25858 @item -mflush-trap=@var{number}
25859 @opindex mflush-trap=@var{number}
25860 Specifies the trap number to use to flush the cache. The default is
25861 12. Valid numbers are between 0 and 15 inclusive.
25863 @item -mno-flush-trap
25864 @opindex mno-flush-trap
25865 Specifies that the cache cannot be flushed by using a trap.
25867 @item -mflush-func=@var{name}
25868 @opindex mflush-func=@var{name}
25869 Specifies the name of the operating system function to call to flush
25870 the cache. The default is @samp{_flush_cache}, but a function call
25871 is only used if a trap is not available.
25873 @item -mno-flush-func
25874 @opindex mno-flush-func
25875 Indicates that there is no OS function for flushing the cache.
25879 @node M680x0 Options
25880 @subsection M680x0 Options
25881 @cindex M680x0 options
25883 These are the @samp{-m} options defined for M680x0 and ColdFire processors.
25884 The default settings depend on which architecture was selected when
25885 the compiler was configured; the defaults for the most common choices
25889 @item -march=@var{arch}
25891 Generate code for a specific M680x0 or ColdFire instruction set
25892 architecture. Permissible values of @var{arch} for M680x0
25893 architectures are: @samp{68000}, @samp{68010}, @samp{68020},
25894 @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
25895 architectures are selected according to Freescale's ISA classification
25896 and the permissible values are: @samp{isaa}, @samp{isaaplus},
25897 @samp{isab} and @samp{isac}.
25899 GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
25900 code for a ColdFire target. The @var{arch} in this macro is one of the
25901 @option{-march} arguments given above.
25903 When used together, @option{-march} and @option{-mtune} select code
25904 that runs on a family of similar processors but that is optimized
25905 for a particular microarchitecture.
25907 @item -mcpu=@var{cpu}
25909 Generate code for a specific M680x0 or ColdFire processor.
25910 The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
25911 @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
25912 and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
25913 below, which also classifies the CPUs into families:
25915 @multitable @columnfractions 0.20 0.80
25916 @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
25917 @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}
25918 @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
25919 @item @samp{5206e} @tab @samp{5206e}
25920 @item @samp{5208} @tab @samp{5207} @samp{5208}
25921 @item @samp{5211a} @tab @samp{5210a} @samp{5211a}
25922 @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
25923 @item @samp{5216} @tab @samp{5214} @samp{5216}
25924 @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
25925 @item @samp{5225} @tab @samp{5224} @samp{5225}
25926 @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
25927 @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
25928 @item @samp{5249} @tab @samp{5249}
25929 @item @samp{5250} @tab @samp{5250}
25930 @item @samp{5271} @tab @samp{5270} @samp{5271}
25931 @item @samp{5272} @tab @samp{5272}
25932 @item @samp{5275} @tab @samp{5274} @samp{5275}
25933 @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
25934 @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
25935 @item @samp{5307} @tab @samp{5307}
25936 @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
25937 @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
25938 @item @samp{5407} @tab @samp{5407}
25939 @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}
25942 @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
25943 @var{arch} is compatible with @var{cpu}. Other combinations of
25944 @option{-mcpu} and @option{-march} are rejected.
25946 GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
25947 @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
25948 where the value of @var{family} is given by the table above.
25950 @item -mtune=@var{tune}
25952 Tune the code for a particular microarchitecture within the
25953 constraints set by @option{-march} and @option{-mcpu}.
25954 The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
25955 @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
25956 and @samp{cpu32}. The ColdFire microarchitectures
25957 are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
25959 You can also use @option{-mtune=68020-40} for code that needs
25960 to run relatively well on 68020, 68030 and 68040 targets.
25961 @option{-mtune=68020-60} is similar but includes 68060 targets
25962 as well. These two options select the same tuning decisions as
25963 @option{-m68020-40} and @option{-m68020-60} respectively.
25965 GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
25966 when tuning for 680x0 architecture @var{arch}. It also defines
25967 @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
25968 option is used. If GCC is tuning for a range of architectures,
25969 as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
25970 it defines the macros for every architecture in the range.
25972 GCC also defines the macro @code{__m@var{uarch}__} when tuning for
25973 ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
25974 of the arguments given above.
25980 Generate output for a 68000. This is the default
25981 when the compiler is configured for 68000-based systems.
25982 It is equivalent to @option{-march=68000}.
25984 Use this option for microcontrollers with a 68000 or EC000 core,
25985 including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
25989 Generate output for a 68010. This is the default
25990 when the compiler is configured for 68010-based systems.
25991 It is equivalent to @option{-march=68010}.
25997 Generate output for a 68020. This is the default
25998 when the compiler is configured for 68020-based systems.
25999 It is equivalent to @option{-march=68020}.
26003 Generate output for a 68030. This is the default when the compiler is
26004 configured for 68030-based systems. It is equivalent to
26005 @option{-march=68030}.
26009 Generate output for a 68040. This is the default when the compiler is
26010 configured for 68040-based systems. It is equivalent to
26011 @option{-march=68040}.
26013 This option inhibits the use of 68881/68882 instructions that have to be
26014 emulated by software on the 68040. Use this option if your 68040 does not
26015 have code to emulate those instructions.
26019 Generate output for a 68060. This is the default when the compiler is
26020 configured for 68060-based systems. It is equivalent to
26021 @option{-march=68060}.
26023 This option inhibits the use of 68020 and 68881/68882 instructions that
26024 have to be emulated by software on the 68060. Use this option if your 68060
26025 does not have code to emulate those instructions.
26029 Generate output for a CPU32. This is the default
26030 when the compiler is configured for CPU32-based systems.
26031 It is equivalent to @option{-march=cpu32}.
26033 Use this option for microcontrollers with a
26034 CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
26035 68336, 68340, 68341, 68349 and 68360.
26039 Generate output for a 520X ColdFire CPU@. This is the default
26040 when the compiler is configured for 520X-based systems.
26041 It is equivalent to @option{-mcpu=5206}, and is now deprecated
26042 in favor of that option.
26044 Use this option for microcontroller with a 5200 core, including
26045 the MCF5202, MCF5203, MCF5204 and MCF5206.
26049 Generate output for a 5206e ColdFire CPU@. The option is now
26050 deprecated in favor of the equivalent @option{-mcpu=5206e}.
26054 Generate output for a member of the ColdFire 528X family.
26055 The option is now deprecated in favor of the equivalent
26056 @option{-mcpu=528x}.
26060 Generate output for a ColdFire 5307 CPU@. The option is now deprecated
26061 in favor of the equivalent @option{-mcpu=5307}.
26065 Generate output for a ColdFire 5407 CPU@. The option is now deprecated
26066 in favor of the equivalent @option{-mcpu=5407}.
26070 Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
26071 This includes use of hardware floating-point instructions.
26072 The option is equivalent to @option{-mcpu=547x}, and is now
26073 deprecated in favor of that option.
26077 Generate output for a 68040, without using any of the new instructions.
26078 This results in code that can run relatively efficiently on either a
26079 68020/68881 or a 68030 or a 68040. The generated code does use the
26080 68881 instructions that are emulated on the 68040.
26082 The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
26086 Generate output for a 68060, without using any of the new instructions.
26087 This results in code that can run relatively efficiently on either a
26088 68020/68881 or a 68030 or a 68040. The generated code does use the
26089 68881 instructions that are emulated on the 68060.
26091 The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
26095 @opindex mhard-float
26097 Generate floating-point instructions. This is the default for 68020
26098 and above, and for ColdFire devices that have an FPU@. It defines the
26099 macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
26100 on ColdFire targets.
26103 @opindex msoft-float
26104 Do not generate floating-point instructions; use library calls instead.
26105 This is the default for 68000, 68010, and 68832 targets. It is also
26106 the default for ColdFire devices that have no FPU.
26112 Generate (do not generate) ColdFire hardware divide and remainder
26113 instructions. If @option{-march} is used without @option{-mcpu},
26114 the default is ``on'' for ColdFire architectures and ``off'' for M680x0
26115 architectures. Otherwise, the default is taken from the target CPU
26116 (either the default CPU, or the one specified by @option{-mcpu}). For
26117 example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26118 @option{-mcpu=5206e}.
26120 GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26124 Consider type @code{int} to be 16 bits wide, like @code{short int}.
26125 Additionally, parameters passed on the stack are also aligned to a
26126 16-bit boundary even on targets whose API mandates promotion to 32-bit.
26130 Do not consider type @code{int} to be 16 bits wide. This is the default.
26133 @itemx -mno-bitfield
26134 @opindex mnobitfield
26135 @opindex mno-bitfield
26136 Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26137 and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26141 Do use the bit-field instructions. The @option{-m68020} option implies
26142 @option{-mbitfield}. This is the default if you use a configuration
26143 designed for a 68020.
26147 Use a different function-calling convention, in which functions
26148 that take a fixed number of arguments return with the @code{rtd}
26149 instruction, which pops their arguments while returning. This
26150 saves one instruction in the caller since there is no need to pop
26151 the arguments there.
26153 This calling convention is incompatible with the one normally
26154 used on Unix, so you cannot use it if you need to call libraries
26155 compiled with the Unix compiler.
26157 Also, you must provide function prototypes for all functions that
26158 take variable numbers of arguments (including @code{printf});
26159 otherwise incorrect code is generated for calls to those
26162 In addition, seriously incorrect code results if you call a
26163 function with too many arguments. (Normally, extra arguments are
26164 harmlessly ignored.)
26166 The @code{rtd} instruction is supported by the 68010, 68020, 68030,
26167 68040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26169 The default is @option{-mno-rtd}.
26172 @itemx -mno-align-int
26173 @opindex malign-int
26174 @opindex mno-align-int
26175 Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26176 @code{float}, @code{double}, and @code{long double} variables on a 32-bit
26177 boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26178 Aligning variables on 32-bit boundaries produces code that runs somewhat
26179 faster on processors with 32-bit busses at the expense of more memory.
26181 @strong{Warning:} if you use the @option{-malign-int} switch, GCC
26182 aligns structures containing the above types differently than
26183 most published application binary interface specifications for the m68k.
26186 Use the pc-relative addressing mode of the 68000 directly, instead of
26187 using a global offset table. At present, this option implies @option{-fpic},
26188 allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26189 not presently supported with @option{-mpcrel}, though this could be supported for
26190 68020 and higher processors.
26192 @item -mno-strict-align
26193 @itemx -mstrict-align
26194 @opindex mno-strict-align
26195 @opindex mstrict-align
26196 Do not (do) assume that unaligned memory references are handled by
26200 Generate code that allows the data segment to be located in a different
26201 area of memory from the text segment. This allows for execute-in-place in
26202 an environment without virtual memory management. This option implies
26205 @item -mno-sep-data
26206 Generate code that assumes that the data segment follows the text segment.
26207 This is the default.
26209 @item -mid-shared-library
26210 Generate code that supports shared libraries via the library ID method.
26211 This allows for execute-in-place and shared libraries in an environment
26212 without virtual memory management. This option implies @option{-fPIC}.
26214 @item -mno-id-shared-library
26215 Generate code that doesn't assume ID-based shared libraries are being used.
26216 This is the default.
26218 @item -mshared-library-id=n
26219 Specifies the identification number of the ID-based shared library being
26220 compiled. Specifying a value of 0 generates more compact code; specifying
26221 other values forces the allocation of that number to the current
26222 library, but is no more space- or time-efficient than omitting this option.
26228 When generating position-independent code for ColdFire, generate code
26229 that works if the GOT has more than 8192 entries. This code is
26230 larger and slower than code generated without this option. On M680x0
26231 processors, this option is not needed; @option{-fPIC} suffices.
26233 GCC normally uses a single instruction to load values from the GOT@.
26234 While this is relatively efficient, it only works if the GOT
26235 is smaller than about 64k. Anything larger causes the linker
26236 to report an error such as:
26238 @cindex relocation truncated to fit (ColdFire)
26240 relocation truncated to fit: R_68K_GOT16O foobar
26243 If this happens, you should recompile your code with @option{-mxgot}.
26244 It should then work with very large GOTs. However, code generated with
26245 @option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26246 the value of a global symbol.
26248 Note that some linkers, including newer versions of the GNU linker,
26249 can create multiple GOTs and sort GOT entries. If you have such a linker,
26250 you should only need to use @option{-mxgot} when compiling a single
26251 object file that accesses more than 8192 GOT entries. Very few do.
26253 These options have no effect unless GCC is generating
26254 position-independent code.
26256 @item -mlong-jump-table-offsets
26257 @opindex mlong-jump-table-offsets
26258 Use 32-bit offsets in @code{switch} tables. The default is to use
26263 @node MCore Options
26264 @subsection MCore Options
26265 @cindex MCore options
26267 These are the @samp{-m} options defined for the Motorola M*Core
26273 @itemx -mno-hardlit
26275 @opindex mno-hardlit
26276 Inline constants into the code stream if it can be done in two
26277 instructions or less.
26283 Use the divide instruction. (Enabled by default).
26285 @item -mrelax-immediate
26286 @itemx -mno-relax-immediate
26287 @opindex mrelax-immediate
26288 @opindex mno-relax-immediate
26289 Allow arbitrary-sized immediates in bit operations.
26291 @item -mwide-bitfields
26292 @itemx -mno-wide-bitfields
26293 @opindex mwide-bitfields
26294 @opindex mno-wide-bitfields
26295 Always treat bit-fields as @code{int}-sized.
26297 @item -m4byte-functions
26298 @itemx -mno-4byte-functions
26299 @opindex m4byte-functions
26300 @opindex mno-4byte-functions
26301 Force all functions to be aligned to a 4-byte boundary.
26303 @item -mcallgraph-data
26304 @itemx -mno-callgraph-data
26305 @opindex mcallgraph-data
26306 @opindex mno-callgraph-data
26307 Emit callgraph information.
26310 @itemx -mno-slow-bytes
26311 @opindex mslow-bytes
26312 @opindex mno-slow-bytes
26313 Prefer word access when reading byte quantities.
26315 @item -mlittle-endian
26316 @itemx -mbig-endian
26317 @opindex mlittle-endian
26318 @opindex mbig-endian
26319 Generate code for a little-endian target.
26325 Generate code for the 210 processor.
26329 Assume that runtime support has been provided and so omit the
26330 simulator library (@file{libsim.a)} from the linker command line.
26332 @item -mstack-increment=@var{size}
26333 @opindex mstack-increment
26334 Set the maximum amount for a single stack increment operation. Large
26335 values can increase the speed of programs that contain functions
26336 that need a large amount of stack space, but they can also trigger a
26337 segmentation fault if the stack is extended too much. The default
26342 @node MicroBlaze Options
26343 @subsection MicroBlaze Options
26344 @cindex MicroBlaze Options
26349 @opindex msoft-float
26350 Use software emulation for floating point (default).
26353 @opindex mhard-float
26354 Use hardware floating-point instructions.
26358 Do not optimize block moves, use @code{memcpy}.
26360 @item -mno-clearbss
26361 @opindex mno-clearbss
26362 This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
26364 @item -mcpu=@var{cpu-type}
26366 Use features of, and schedule code for, the given CPU.
26367 Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
26368 where @var{X} is a major version, @var{YY} is the minor version, and
26369 @var{Z} is compatibility code. Example values are @samp{v3.00.a},
26370 @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
26372 @item -mxl-soft-mul
26373 @opindex mxl-soft-mul
26374 Use software multiply emulation (default).
26376 @item -mxl-soft-div
26377 @opindex mxl-soft-div
26378 Use software emulation for divides (default).
26380 @item -mxl-barrel-shift
26381 @opindex mxl-barrel-shift
26382 Use the hardware barrel shifter.
26384 @item -mxl-pattern-compare
26385 @opindex mxl-pattern-compare
26386 Use pattern compare instructions.
26388 @item -msmall-divides
26389 @opindex msmall-divides
26390 Use table lookup optimization for small signed integer divisions.
26392 @item -mxl-stack-check
26393 @opindex mxl-stack-check
26394 This option is deprecated. Use @option{-fstack-check} instead.
26397 @opindex mxl-gp-opt
26398 Use GP-relative @code{.sdata}/@code{.sbss} sections.
26400 @item -mxl-multiply-high
26401 @opindex mxl-multiply-high
26402 Use multiply high instructions for high part of 32x32 multiply.
26404 @item -mxl-float-convert
26405 @opindex mxl-float-convert
26406 Use hardware floating-point conversion instructions.
26408 @item -mxl-float-sqrt
26409 @opindex mxl-float-sqrt
26410 Use hardware floating-point square root instruction.
26413 @opindex mbig-endian
26414 Generate code for a big-endian target.
26416 @item -mlittle-endian
26417 @opindex mlittle-endian
26418 Generate code for a little-endian target.
26421 @opindex mxl-reorder
26422 Use reorder instructions (swap and byte reversed load/store).
26424 @item -mxl-mode-@var{app-model}
26425 Select application model @var{app-model}. Valid models are
26428 normal executable (default), uses startup code @file{crt0.o}.
26431 for use with Xilinx Microprocessor Debugger (XMD) based
26432 software intrusive debug agent called xmdstub. This uses startup file
26433 @file{crt1.o} and sets the start address of the program to 0x800.
26436 for applications that are loaded using a bootloader.
26437 This model uses startup file @file{crt2.o} which does not contain a processor
26438 reset vector handler. This is suitable for transferring control on a
26439 processor reset to the bootloader rather than the application.
26442 for applications that do not require any of the
26443 MicroBlaze vectors. This option may be useful for applications running
26444 within a monitoring application. This model uses @file{crt3.o} as a startup file.
26447 Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
26448 @option{-mxl-mode-@var{app-model}}.
26450 @item -mpic-data-is-text-relative
26451 @opindex mpic-data-is-text-relative
26452 Assume that the displacement between the text and data segments is fixed
26453 at static link time. This allows data to be referenced by offset from start of
26454 text address instead of GOT since PC-relative addressing is not supported.
26459 @subsection MIPS Options
26460 @cindex MIPS options
26466 Generate big-endian code.
26470 Generate little-endian code. This is the default for @samp{mips*el-*-*}
26473 @item -march=@var{arch}
26475 Generate code that runs on @var{arch}, which can be the name of a
26476 generic MIPS ISA, or the name of a particular processor.
26478 @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
26479 @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
26480 @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
26481 @samp{mips64r5} and @samp{mips64r6}.
26482 The processor names are:
26483 @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
26484 @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
26485 @samp{5kc}, @samp{5kf},
26487 @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
26488 @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
26489 @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
26490 @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
26491 @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
26492 @samp{i6400}, @samp{i6500},
26494 @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
26495 @samp{gs464e}, @samp{gs264e},
26497 @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
26498 @samp{m5100}, @samp{m5101},
26499 @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
26501 @samp{p5600}, @samp{p6600},
26502 @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
26503 @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
26504 @samp{r6000}, @samp{r8000},
26505 @samp{rm7000}, @samp{rm9000},
26506 @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
26509 @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
26510 @samp{vr5000}, @samp{vr5400}, @samp{vr5500},
26511 @samp{xlr} and @samp{xlp}.
26512 The special value @samp{from-abi} selects the
26513 most compatible architecture for the selected ABI (that is,
26514 @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
26516 The native Linux/GNU toolchain also supports the value @samp{native},
26517 which selects the best architecture option for the host processor.
26518 @option{-march=native} has no effect if GCC does not recognize
26521 In processor names, a final @samp{000} can be abbreviated as @samp{k}
26522 (for example, @option{-march=r2k}). Prefixes are optional, and
26523 @samp{vr} may be written @samp{r}.
26525 Names of the form @samp{@var{n}f2_1} refer to processors with
26526 FPUs clocked at half the rate of the core, names of the form
26527 @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
26528 rate as the core, and names of the form @samp{@var{n}f3_2} refer to
26529 processors with FPUs clocked a ratio of 3:2 with respect to the core.
26530 For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
26531 for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
26532 accepted as synonyms for @samp{@var{n}f1_1}.
26534 GCC defines two macros based on the value of this option. The first
26535 is @code{_MIPS_ARCH}, which gives the name of target architecture, as
26536 a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
26537 where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
26538 For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
26539 to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
26541 Note that the @code{_MIPS_ARCH} macro uses the processor names given
26542 above. In other words, it has the full prefix and does not
26543 abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
26544 the macro names the resolved architecture (either @code{"mips1"} or
26545 @code{"mips3"}). It names the default architecture when no
26546 @option{-march} option is given.
26548 @item -mtune=@var{arch}
26550 Optimize for @var{arch}. Among other things, this option controls
26551 the way instructions are scheduled, and the perceived cost of arithmetic
26552 operations. The list of @var{arch} values is the same as for
26555 When this option is not used, GCC optimizes for the processor
26556 specified by @option{-march}. By using @option{-march} and
26557 @option{-mtune} together, it is possible to generate code that
26558 runs on a family of processors, but optimize the code for one
26559 particular member of that family.
26561 @option{-mtune} defines the macros @code{_MIPS_TUNE} and
26562 @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
26563 @option{-march} ones described above.
26567 Equivalent to @option{-march=mips1}.
26571 Equivalent to @option{-march=mips2}.
26575 Equivalent to @option{-march=mips3}.
26579 Equivalent to @option{-march=mips4}.
26583 Equivalent to @option{-march=mips32}.
26587 Equivalent to @option{-march=mips32r3}.
26591 Equivalent to @option{-march=mips32r5}.
26595 Equivalent to @option{-march=mips32r6}.
26599 Equivalent to @option{-march=mips64}.
26603 Equivalent to @option{-march=mips64r2}.
26607 Equivalent to @option{-march=mips64r3}.
26611 Equivalent to @option{-march=mips64r5}.
26615 Equivalent to @option{-march=mips64r6}.
26620 @opindex mno-mips16
26621 Generate (do not generate) MIPS16 code. If GCC is targeting a
26622 MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
26624 MIPS16 code generation can also be controlled on a per-function basis
26625 by means of @code{mips16} and @code{nomips16} attributes.
26626 @xref{Function Attributes}, for more information.
26628 @item -mflip-mips16
26629 @opindex mflip-mips16
26630 Generate MIPS16 code on alternating functions. This option is provided
26631 for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
26632 not intended for ordinary use in compiling user code.
26634 @item -minterlink-compressed
26635 @itemx -mno-interlink-compressed
26636 @opindex minterlink-compressed
26637 @opindex mno-interlink-compressed
26638 Require (do not require) that code using the standard (uncompressed) MIPS ISA
26639 be link-compatible with MIPS16 and microMIPS code, and vice versa.
26641 For example, code using the standard ISA encoding cannot jump directly
26642 to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
26643 @option{-minterlink-compressed} therefore disables direct jumps unless GCC
26644 knows that the target of the jump is not compressed.
26646 @item -minterlink-mips16
26647 @itemx -mno-interlink-mips16
26648 @opindex minterlink-mips16
26649 @opindex mno-interlink-mips16
26650 Aliases of @option{-minterlink-compressed} and
26651 @option{-mno-interlink-compressed}. These options predate the microMIPS ASE
26652 and are retained for backwards compatibility.
26664 Generate code for the given ABI@.
26666 Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
26667 generates 64-bit code when you select a 64-bit architecture, but you
26668 can use @option{-mgp32} to get 32-bit code instead.
26670 For information about the O64 ABI, see
26671 @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
26673 GCC supports a variant of the o32 ABI in which floating-point registers
26674 are 64 rather than 32 bits wide. You can select this combination with
26675 @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
26676 and @code{mfhc1} instructions and is therefore only supported for
26677 MIPS32R2, MIPS32R3 and MIPS32R5 processors.
26679 The register assignments for arguments and return values remain the
26680 same, but each scalar value is passed in a single 64-bit register
26681 rather than a pair of 32-bit registers. For example, scalar
26682 floating-point values are returned in @samp{$f0} only, not a
26683 @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
26684 remains the same in that the even-numbered double-precision registers
26687 Two additional variants of the o32 ABI are supported to enable
26688 a transition from 32-bit to 64-bit registers. These are FPXX
26689 (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
26690 The FPXX extension mandates that all code must execute correctly
26691 when run using 32-bit or 64-bit registers. The code can be interlinked
26692 with either FP32 or FP64, but not both.
26693 The FP64A extension is similar to the FP64 extension but forbids the
26694 use of odd-numbered single-precision registers. This can be used
26695 in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
26696 processors and allows both FP32 and FP64A code to interlink and
26697 run in the same process without changing FPU modes.
26700 @itemx -mno-abicalls
26702 @opindex mno-abicalls
26703 Generate (do not generate) code that is suitable for SVR4-style
26704 dynamic objects. @option{-mabicalls} is the default for SVR4-based
26709 Generate (do not generate) code that is fully position-independent,
26710 and that can therefore be linked into shared libraries. This option
26711 only affects @option{-mabicalls}.
26713 All @option{-mabicalls} code has traditionally been position-independent,
26714 regardless of options like @option{-fPIC} and @option{-fpic}. However,
26715 as an extension, the GNU toolchain allows executables to use absolute
26716 accesses for locally-binding symbols. It can also use shorter GP
26717 initialization sequences and generate direct calls to locally-defined
26718 functions. This mode is selected by @option{-mno-shared}.
26720 @option{-mno-shared} depends on binutils 2.16 or higher and generates
26721 objects that can only be linked by the GNU linker. However, the option
26722 does not affect the ABI of the final executable; it only affects the ABI
26723 of relocatable objects. Using @option{-mno-shared} generally makes
26724 executables both smaller and quicker.
26726 @option{-mshared} is the default.
26732 Assume (do not assume) that the static and dynamic linkers
26733 support PLTs and copy relocations. This option only affects
26734 @option{-mno-shared -mabicalls}. For the n64 ABI, this option
26735 has no effect without @option{-msym32}.
26737 You can make @option{-mplt} the default by configuring
26738 GCC with @option{--with-mips-plt}. The default is
26739 @option{-mno-plt} otherwise.
26745 Lift (do not lift) the usual restrictions on the size of the global
26748 GCC normally uses a single instruction to load values from the GOT@.
26749 While this is relatively efficient, it only works if the GOT
26750 is smaller than about 64k. Anything larger causes the linker
26751 to report an error such as:
26753 @cindex relocation truncated to fit (MIPS)
26755 relocation truncated to fit: R_MIPS_GOT16 foobar
26758 If this happens, you should recompile your code with @option{-mxgot}.
26759 This works with very large GOTs, although the code is also
26760 less efficient, since it takes three instructions to fetch the
26761 value of a global symbol.
26763 Note that some linkers can create multiple GOTs. If you have such a
26764 linker, you should only need to use @option{-mxgot} when a single object
26765 file accesses more than 64k's worth of GOT entries. Very few do.
26767 These options have no effect unless GCC is generating position
26772 Assume that general-purpose registers are 32 bits wide.
26776 Assume that general-purpose registers are 64 bits wide.
26780 Assume that floating-point registers are 32 bits wide.
26784 Assume that floating-point registers are 64 bits wide.
26788 Do not assume the width of floating-point registers.
26791 @opindex mhard-float
26792 Use floating-point coprocessor instructions.
26795 @opindex msoft-float
26796 Do not use floating-point coprocessor instructions. Implement
26797 floating-point calculations using library calls instead.
26801 Equivalent to @option{-msoft-float}, but additionally asserts that the
26802 program being compiled does not perform any floating-point operations.
26803 This option is presently supported only by some bare-metal MIPS
26804 configurations, where it may select a special set of libraries
26805 that lack all floating-point support (including, for example, the
26806 floating-point @code{printf} formats).
26807 If code compiled with @option{-mno-float} accidentally contains
26808 floating-point operations, it is likely to suffer a link-time
26809 or run-time failure.
26811 @item -msingle-float
26812 @opindex msingle-float
26813 Assume that the floating-point coprocessor only supports single-precision
26816 @item -mdouble-float
26817 @opindex mdouble-float
26818 Assume that the floating-point coprocessor supports double-precision
26819 operations. This is the default.
26822 @itemx -mno-odd-spreg
26823 @opindex modd-spreg
26824 @opindex mno-odd-spreg
26825 Enable the use of odd-numbered single-precision floating-point registers
26826 for the o32 ABI. This is the default for processors that are known to
26827 support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
26831 @itemx -mabs=legacy
26833 @opindex mabs=legacy
26834 These options control the treatment of the special not-a-number (NaN)
26835 IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
26836 @code{neg.@i{fmt}} machine instructions.
26838 By default or when @option{-mabs=legacy} is used the legacy
26839 treatment is selected. In this case these instructions are considered
26840 arithmetic and avoided where correct operation is required and the
26841 input operand might be a NaN. A longer sequence of instructions that
26842 manipulate the sign bit of floating-point datum manually is used
26843 instead unless the @option{-ffinite-math-only} option has also been
26846 The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
26847 this case these instructions are considered non-arithmetic and therefore
26848 operating correctly in all cases, including in particular where the
26849 input operand is a NaN. These instructions are therefore always used
26850 for the respective operations.
26853 @itemx -mnan=legacy
26855 @opindex mnan=legacy
26856 These options control the encoding of the special not-a-number (NaN)
26857 IEEE 754 floating-point data.
26859 The @option{-mnan=legacy} option selects the legacy encoding. In this
26860 case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
26861 significand field being 0, whereas signaling NaNs (sNaNs) are denoted
26862 by the first bit of their trailing significand field being 1.
26864 The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
26865 this case qNaNs are denoted by the first bit of their trailing
26866 significand field being 1, whereas sNaNs are denoted by the first bit of
26867 their trailing significand field being 0.
26869 The default is @option{-mnan=legacy} unless GCC has been configured with
26870 @option{--with-nan=2008}.
26876 Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
26877 implement atomic memory built-in functions. When neither option is
26878 specified, GCC uses the instructions if the target architecture
26881 @option{-mllsc} is useful if the runtime environment can emulate the
26882 instructions and @option{-mno-llsc} can be useful when compiling for
26883 nonstandard ISAs. You can make either option the default by
26884 configuring GCC with @option{--with-llsc} and @option{--without-llsc}
26885 respectively. @option{--with-llsc} is the default for some
26886 configurations; see the installation documentation for details.
26892 Use (do not use) revision 1 of the MIPS DSP ASE@.
26893 @xref{MIPS DSP Built-in Functions}. This option defines the
26894 preprocessor macro @code{__mips_dsp}. It also defines
26895 @code{__mips_dsp_rev} to 1.
26901 Use (do not use) revision 2 of the MIPS DSP ASE@.
26902 @xref{MIPS DSP Built-in Functions}. This option defines the
26903 preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
26904 It also defines @code{__mips_dsp_rev} to 2.
26907 @itemx -mno-smartmips
26908 @opindex msmartmips
26909 @opindex mno-smartmips
26910 Use (do not use) the MIPS SmartMIPS ASE.
26912 @item -mpaired-single
26913 @itemx -mno-paired-single
26914 @opindex mpaired-single
26915 @opindex mno-paired-single
26916 Use (do not use) paired-single floating-point instructions.
26917 @xref{MIPS Paired-Single Support}. This option requires
26918 hardware floating-point support to be enabled.
26924 Use (do not use) MIPS Digital Media Extension instructions.
26925 This option can only be used when generating 64-bit code and requires
26926 hardware floating-point support to be enabled.
26931 @opindex mno-mips3d
26932 Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
26933 The option @option{-mips3d} implies @option{-mpaired-single}.
26936 @itemx -mno-micromips
26937 @opindex mmicromips
26938 @opindex mno-mmicromips
26939 Generate (do not generate) microMIPS code.
26941 MicroMIPS code generation can also be controlled on a per-function basis
26942 by means of @code{micromips} and @code{nomicromips} attributes.
26943 @xref{Function Attributes}, for more information.
26949 Use (do not use) MT Multithreading instructions.
26955 Use (do not use) the MIPS MCU ASE instructions.
26961 Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
26967 Use (do not use) the MIPS Virtualization (VZ) instructions.
26973 Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
26979 Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
26985 Use (do not use) the MIPS Global INValidate (GINV) instructions.
26987 @item -mloongson-mmi
26988 @itemx -mno-loongson-mmi
26989 @opindex mloongson-mmi
26990 @opindex mno-loongson-mmi
26991 Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
26993 @item -mloongson-ext
26994 @itemx -mno-loongson-ext
26995 @opindex mloongson-ext
26996 @opindex mno-loongson-ext
26997 Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
26999 @item -mloongson-ext2
27000 @itemx -mno-loongson-ext2
27001 @opindex mloongson-ext2
27002 @opindex mno-loongson-ext2
27003 Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
27007 Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
27008 an explanation of the default and the way that the pointer size is
27013 Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
27015 The default size of @code{int}s, @code{long}s and pointers depends on
27016 the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
27017 uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
27018 32-bit @code{long}s. Pointers are the same size as @code{long}s,
27019 or the same size as integer registers, whichever is smaller.
27025 Assume (do not assume) that all symbols have 32-bit values, regardless
27026 of the selected ABI@. This option is useful in combination with
27027 @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
27028 to generate shorter and faster references to symbolic addresses.
27032 Put definitions of externally-visible data in a small data section
27033 if that data is no bigger than @var{num} bytes. GCC can then generate
27034 more efficient accesses to the data; see @option{-mgpopt} for details.
27036 The default @option{-G} option depends on the configuration.
27038 @item -mlocal-sdata
27039 @itemx -mno-local-sdata
27040 @opindex mlocal-sdata
27041 @opindex mno-local-sdata
27042 Extend (do not extend) the @option{-G} behavior to local data too,
27043 such as to static variables in C@. @option{-mlocal-sdata} is the
27044 default for all configurations.
27046 If the linker complains that an application is using too much small data,
27047 you might want to try rebuilding the less performance-critical parts with
27048 @option{-mno-local-sdata}. You might also want to build large
27049 libraries with @option{-mno-local-sdata}, so that the libraries leave
27050 more room for the main program.
27052 @item -mextern-sdata
27053 @itemx -mno-extern-sdata
27054 @opindex mextern-sdata
27055 @opindex mno-extern-sdata
27056 Assume (do not assume) that externally-defined data is in
27057 a small data section if the size of that data is within the @option{-G} limit.
27058 @option{-mextern-sdata} is the default for all configurations.
27060 If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
27061 @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
27062 that is no bigger than @var{num} bytes, you must make sure that @var{Var}
27063 is placed in a small data section. If @var{Var} is defined by another
27064 module, you must either compile that module with a high-enough
27065 @option{-G} setting or attach a @code{section} attribute to @var{Var}'s
27066 definition. If @var{Var} is common, you must link the application
27067 with a high-enough @option{-G} setting.
27069 The easiest way of satisfying these restrictions is to compile
27070 and link every module with the same @option{-G} option. However,
27071 you may wish to build a library that supports several different
27072 small data limits. You can do this by compiling the library with
27073 the highest supported @option{-G} setting and additionally using
27074 @option{-mno-extern-sdata} to stop the library from making assumptions
27075 about externally-defined data.
27081 Use (do not use) GP-relative accesses for symbols that are known to be
27082 in a small data section; see @option{-G}, @option{-mlocal-sdata} and
27083 @option{-mextern-sdata}. @option{-mgpopt} is the default for all
27086 @option{-mno-gpopt} is useful for cases where the @code{$gp} register
27087 might not hold the value of @code{_gp}. For example, if the code is
27088 part of a library that might be used in a boot monitor, programs that
27089 call boot monitor routines pass an unknown value in @code{$gp}.
27090 (In such situations, the boot monitor itself is usually compiled
27091 with @option{-G0}.)
27093 @option{-mno-gpopt} implies @option{-mno-local-sdata} and
27094 @option{-mno-extern-sdata}.
27096 @item -membedded-data
27097 @itemx -mno-embedded-data
27098 @opindex membedded-data
27099 @opindex mno-embedded-data
27100 Allocate variables to the read-only data section first if possible, then
27101 next in the small data section if possible, otherwise in data. This gives
27102 slightly slower code than the default, but reduces the amount of RAM required
27103 when executing, and thus may be preferred for some embedded systems.
27105 @item -muninit-const-in-rodata
27106 @itemx -mno-uninit-const-in-rodata
27107 @opindex muninit-const-in-rodata
27108 @opindex mno-uninit-const-in-rodata
27109 Put uninitialized @code{const} variables in the read-only data section.
27110 This option is only meaningful in conjunction with @option{-membedded-data}.
27112 @item -mcode-readable=@var{setting}
27113 @opindex mcode-readable
27114 Specify whether GCC may generate code that reads from executable sections.
27115 There are three possible settings:
27118 @item -mcode-readable=yes
27119 Instructions may freely access executable sections. This is the
27122 @item -mcode-readable=pcrel
27123 MIPS16 PC-relative load instructions can access executable sections,
27124 but other instructions must not do so. This option is useful on 4KSc
27125 and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27126 It is also useful on processors that can be configured to have a dual
27127 instruction/data SRAM interface and that, like the M4K, automatically
27128 redirect PC-relative loads to the instruction RAM.
27130 @item -mcode-readable=no
27131 Instructions must not access executable sections. This option can be
27132 useful on targets that are configured to have a dual instruction/data
27133 SRAM interface but that (unlike the M4K) do not automatically redirect
27134 PC-relative loads to the instruction RAM.
27137 @item -msplit-addresses
27138 @itemx -mno-split-addresses
27139 @opindex msplit-addresses
27140 @opindex mno-split-addresses
27141 Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27142 relocation operators. This option has been superseded by
27143 @option{-mexplicit-relocs} but is retained for backwards compatibility.
27145 @item -mexplicit-relocs
27146 @itemx -mno-explicit-relocs
27147 @opindex mexplicit-relocs
27148 @opindex mno-explicit-relocs
27149 Use (do not use) assembler relocation operators when dealing with symbolic
27150 addresses. The alternative, selected by @option{-mno-explicit-relocs},
27151 is to use assembler macros instead.
27153 @option{-mexplicit-relocs} is the default if GCC was configured
27154 to use an assembler that supports relocation operators.
27156 @item -mcheck-zero-division
27157 @itemx -mno-check-zero-division
27158 @opindex mcheck-zero-division
27159 @opindex mno-check-zero-division
27160 Trap (do not trap) on integer division by zero.
27162 The default is @option{-mcheck-zero-division}.
27164 @item -mdivide-traps
27165 @itemx -mdivide-breaks
27166 @opindex mdivide-traps
27167 @opindex mdivide-breaks
27168 MIPS systems check for division by zero by generating either a
27169 conditional trap or a break instruction. Using traps results in
27170 smaller code, but is only supported on MIPS II and later. Also, some
27171 versions of the Linux kernel have a bug that prevents trap from
27172 generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27173 allow conditional traps on architectures that support them and
27174 @option{-mdivide-breaks} to force the use of breaks.
27176 The default is usually @option{-mdivide-traps}, but this can be
27177 overridden at configure time using @option{--with-divide=breaks}.
27178 Divide-by-zero checks can be completely disabled using
27179 @option{-mno-check-zero-division}.
27181 @item -mload-store-pairs
27182 @itemx -mno-load-store-pairs
27183 @opindex mload-store-pairs
27184 @opindex mno-load-store-pairs
27185 Enable (disable) an optimization that pairs consecutive load or store
27186 instructions to enable load/store bonding. This option is enabled by
27187 default but only takes effect when the selected architecture is known
27188 to support bonding.
27190 @item -munaligned-access
27191 @itemx -mno-unaligned-access
27192 @opindex munaligned-access
27193 @opindex mno-unaligned-access
27194 Enable (disable) direct unaligned access for MIPS Release 6.
27195 MIPSr6 requires load/store unaligned-access support,
27196 by hardware or trap&emulate.
27197 So @option{-mno-unaligned-access} may be needed by kernel.
27202 @opindex mno-memcpy
27203 Force (do not force) the use of @code{memcpy} for non-trivial block
27204 moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27205 most constant-sized copies.
27208 @itemx -mno-long-calls
27209 @opindex mlong-calls
27210 @opindex mno-long-calls
27211 Disable (do not disable) use of the @code{jal} instruction. Calling
27212 functions using @code{jal} is more efficient but requires the caller
27213 and callee to be in the same 256 megabyte segment.
27215 This option has no effect on abicalls code. The default is
27216 @option{-mno-long-calls}.
27222 Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27223 instructions, as provided by the R4650 ISA@.
27229 Enable (disable) use of the @code{madd} and @code{msub} integer
27230 instructions. The default is @option{-mimadd} on architectures
27231 that support @code{madd} and @code{msub} except for the 74k
27232 architecture where it was found to generate slower code.
27235 @itemx -mno-fused-madd
27236 @opindex mfused-madd
27237 @opindex mno-fused-madd
27238 Enable (disable) use of the floating-point multiply-accumulate
27239 instructions, when they are available. The default is
27240 @option{-mfused-madd}.
27242 On the R8000 CPU when multiply-accumulate instructions are used,
27243 the intermediate product is calculated to infinite precision
27244 and is not subject to the FCSR Flush to Zero bit. This may be
27245 undesirable in some circumstances. On other processors the result
27246 is numerically identical to the equivalent computation using
27247 separate multiply, add, subtract and negate instructions.
27251 Tell the MIPS assembler to not run its preprocessor over user
27252 assembler files (with a @samp{.s} suffix) when assembling them.
27255 @itemx -mno-fix-24k
27257 @opindex mno-fix-24k
27258 Work around the 24K E48 (lost data on stores during refill) errata.
27259 The workarounds are implemented by the assembler rather than by GCC@.
27262 @itemx -mno-fix-r4000
27263 @opindex mfix-r4000
27264 @opindex mno-fix-r4000
27265 Work around certain R4000 CPU errata:
27268 A double-word or a variable shift may give an incorrect result if executed
27269 immediately after starting an integer division.
27271 A double-word or a variable shift may give an incorrect result if executed
27272 while an integer multiplication is in progress.
27274 An integer division may give an incorrect result if started in a delay slot
27275 of a taken branch or a jump.
27279 @itemx -mno-fix-r4400
27280 @opindex mfix-r4400
27281 @opindex mno-fix-r4400
27282 Work around certain R4400 CPU errata:
27285 A double-word or a variable shift may give an incorrect result if executed
27286 immediately after starting an integer division.
27290 @itemx -mno-fix-r10000
27291 @opindex mfix-r10000
27292 @opindex mno-fix-r10000
27293 Work around certain R10000 errata:
27296 @code{ll}/@code{sc} sequences may not behave atomically on revisions
27297 prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27300 This option can only be used if the target architecture supports
27301 branch-likely instructions. @option{-mfix-r10000} is the default when
27302 @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27306 @itemx -mno-fix-r5900
27307 @opindex mfix-r5900
27308 Do not attempt to schedule the preceding instruction into the delay slot
27309 of a branch instruction placed at the end of a short loop of six
27310 instructions or fewer and always schedule a @code{nop} instruction there
27311 instead. The short loop bug under certain conditions causes loops to
27312 execute only once or twice, due to a hardware bug in the R5900 chip. The
27313 workaround is implemented by the assembler rather than by GCC@.
27316 @itemx -mno-fix-rm7000
27317 @opindex mfix-rm7000
27318 Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27319 workarounds are implemented by the assembler rather than by GCC@.
27322 @itemx -mno-fix-vr4120
27323 @opindex mfix-vr4120
27324 Work around certain VR4120 errata:
27327 @code{dmultu} does not always produce the correct result.
27329 @code{div} and @code{ddiv} do not always produce the correct result if one
27330 of the operands is negative.
27332 The workarounds for the division errata rely on special functions in
27333 @file{libgcc.a}. At present, these functions are only provided by
27334 the @code{mips64vr*-elf} configurations.
27336 Other VR4120 errata require a NOP to be inserted between certain pairs of
27337 instructions. These errata are handled by the assembler, not by GCC itself.
27340 @opindex mfix-vr4130
27341 Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
27342 workarounds are implemented by the assembler rather than by GCC,
27343 although GCC avoids using @code{mflo} and @code{mfhi} if the
27344 VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
27345 instructions are available instead.
27348 @itemx -mno-fix-sb1
27350 Work around certain SB-1 CPU core errata.
27351 (This flag currently works around the SB-1 revision 2
27352 ``F1'' and ``F2'' floating-point errata.)
27354 @item -mr10k-cache-barrier=@var{setting}
27355 @opindex mr10k-cache-barrier
27356 Specify whether GCC should insert cache barriers to avoid the
27357 side effects of speculation on R10K processors.
27359 In common with many processors, the R10K tries to predict the outcome
27360 of a conditional branch and speculatively executes instructions from
27361 the ``taken'' branch. It later aborts these instructions if the
27362 predicted outcome is wrong. However, on the R10K, even aborted
27363 instructions can have side effects.
27365 This problem only affects kernel stores and, depending on the system,
27366 kernel loads. As an example, a speculatively-executed store may load
27367 the target memory into cache and mark the cache line as dirty, even if
27368 the store itself is later aborted. If a DMA operation writes to the
27369 same area of memory before the ``dirty'' line is flushed, the cached
27370 data overwrites the DMA-ed data. See the R10K processor manual
27371 for a full description, including other potential problems.
27373 One workaround is to insert cache barrier instructions before every memory
27374 access that might be speculatively executed and that might have side
27375 effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
27376 controls GCC's implementation of this workaround. It assumes that
27377 aborted accesses to any byte in the following regions does not have
27382 the memory occupied by the current function's stack frame;
27385 the memory occupied by an incoming stack argument;
27388 the memory occupied by an object with a link-time-constant address.
27391 It is the kernel's responsibility to ensure that speculative
27392 accesses to these regions are indeed safe.
27394 If the input program contains a function declaration such as:
27400 then the implementation of @code{foo} must allow @code{j foo} and
27401 @code{jal foo} to be executed speculatively. GCC honors this
27402 restriction for functions it compiles itself. It expects non-GCC
27403 functions (such as hand-written assembly code) to do the same.
27405 The option has three forms:
27408 @item -mr10k-cache-barrier=load-store
27409 Insert a cache barrier before a load or store that might be
27410 speculatively executed and that might have side effects even
27413 @item -mr10k-cache-barrier=store
27414 Insert a cache barrier before a store that might be speculatively
27415 executed and that might have side effects even if aborted.
27417 @item -mr10k-cache-barrier=none
27418 Disable the insertion of cache barriers. This is the default setting.
27421 @item -mflush-func=@var{func}
27422 @itemx -mno-flush-func
27423 @opindex mflush-func
27424 Specifies the function to call to flush the I and D caches, or to not
27425 call any such function. If called, the function must take the same
27426 arguments as the common @code{_flush_func}, that is, the address of the
27427 memory range for which the cache is being flushed, the size of the
27428 memory range, and the number 3 (to flush both caches). The default
27429 depends on the target GCC was configured for, but commonly is either
27430 @code{_flush_func} or @code{__cpu_flush}.
27432 @item mbranch-cost=@var{num}
27433 @opindex mbranch-cost
27434 Set the cost of branches to roughly @var{num} ``simple'' instructions.
27435 This cost is only a heuristic and is not guaranteed to produce
27436 consistent results across releases. A zero cost redundantly selects
27437 the default, which is based on the @option{-mtune} setting.
27439 @item -mbranch-likely
27440 @itemx -mno-branch-likely
27441 @opindex mbranch-likely
27442 @opindex mno-branch-likely
27443 Enable or disable use of Branch Likely instructions, regardless of the
27444 default for the selected architecture. By default, Branch Likely
27445 instructions may be generated if they are supported by the selected
27446 architecture. An exception is for the MIPS32 and MIPS64 architectures
27447 and processors that implement those architectures; for those, Branch
27448 Likely instructions are not be generated by default because the MIPS32
27449 and MIPS64 architectures specifically deprecate their use.
27451 @item -mcompact-branches=never
27452 @itemx -mcompact-branches=optimal
27453 @itemx -mcompact-branches=always
27454 @opindex mcompact-branches=never
27455 @opindex mcompact-branches=optimal
27456 @opindex mcompact-branches=always
27457 These options control which form of branches will be generated. The
27458 default is @option{-mcompact-branches=optimal}.
27460 The @option{-mcompact-branches=never} option ensures that compact branch
27461 instructions will never be generated.
27463 The @option{-mcompact-branches=always} option ensures that a compact
27464 branch instruction will be generated if available for MIPS Release 6 onwards.
27465 If a compact branch instruction is not available (or pre-R6),
27466 a delay slot form of the branch will be used instead.
27468 If it is used for MIPS16/microMIPS targets, it will be just ignored now.
27469 The behaviour for MIPS16/microMIPS may change in future,
27470 since they do have some compact branch instructions.
27472 The @option{-mcompact-branches=optimal} option will cause a delay slot
27473 branch to be used if one is available in the current ISA and the delay
27474 slot is successfully filled. If the delay slot is not filled, a compact
27475 branch will be chosen if one is available.
27477 @item -mfp-exceptions
27478 @itemx -mno-fp-exceptions
27479 @opindex mfp-exceptions
27480 Specifies whether FP exceptions are enabled. This affects how
27481 FP instructions are scheduled for some processors.
27482 The default is that FP exceptions are
27485 For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
27486 64-bit code, then we can use both FP pipes. Otherwise, we can only use one
27489 @item -mvr4130-align
27490 @itemx -mno-vr4130-align
27491 @opindex mvr4130-align
27492 The VR4130 pipeline is two-way superscalar, but can only issue two
27493 instructions together if the first one is 8-byte aligned. When this
27494 option is enabled, GCC aligns pairs of instructions that it
27495 thinks should execute in parallel.
27497 This option only has an effect when optimizing for the VR4130.
27498 It normally makes code faster, but at the expense of making it bigger.
27499 It is enabled by default at optimization level @option{-O3}.
27504 Enable (disable) generation of @code{synci} instructions on
27505 architectures that support it. The @code{synci} instructions (if
27506 enabled) are generated when @code{__builtin___clear_cache} is
27509 This option defaults to @option{-mno-synci}, but the default can be
27510 overridden by configuring GCC with @option{--with-synci}.
27512 When compiling code for single processor systems, it is generally safe
27513 to use @code{synci}. However, on many multi-core (SMP) systems, it
27514 does not invalidate the instruction caches on all cores and may lead
27515 to undefined behavior.
27517 @item -mrelax-pic-calls
27518 @itemx -mno-relax-pic-calls
27519 @opindex mrelax-pic-calls
27520 Try to turn PIC calls that are normally dispatched via register
27521 @code{$25} into direct calls. This is only possible if the linker can
27522 resolve the destination at link time and if the destination is within
27523 range for a direct call.
27525 @option{-mrelax-pic-calls} is the default if GCC was configured to use
27526 an assembler and a linker that support the @code{.reloc} assembly
27527 directive and @option{-mexplicit-relocs} is in effect. With
27528 @option{-mno-explicit-relocs}, this optimization can be performed by the
27529 assembler and the linker alone without help from the compiler.
27531 @item -mmcount-ra-address
27532 @itemx -mno-mcount-ra-address
27533 @opindex mmcount-ra-address
27534 @opindex mno-mcount-ra-address
27535 Emit (do not emit) code that allows @code{_mcount} to modify the
27536 calling function's return address. When enabled, this option extends
27537 the usual @code{_mcount} interface with a new @var{ra-address}
27538 parameter, which has type @code{intptr_t *} and is passed in register
27539 @code{$12}. @code{_mcount} can then modify the return address by
27540 doing both of the following:
27543 Returning the new address in register @code{$31}.
27545 Storing the new address in @code{*@var{ra-address}},
27546 if @var{ra-address} is nonnull.
27549 The default is @option{-mno-mcount-ra-address}.
27551 @item -mframe-header-opt
27552 @itemx -mno-frame-header-opt
27553 @opindex mframe-header-opt
27554 Enable (disable) frame header optimization in the o32 ABI. When using the
27555 o32 ABI, calling functions will allocate 16 bytes on the stack for the called
27556 function to write out register arguments. When enabled, this optimization
27557 will suppress the allocation of the frame header if it can be determined that
27560 This optimization is off by default at all optimization levels.
27563 @itemx -mno-lxc1-sxc1
27564 @opindex mlxc1-sxc1
27565 When applicable, enable (disable) the generation of @code{lwxc1},
27566 @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
27571 When applicable, enable (disable) the generation of 4-operand @code{madd.s},
27572 @code{madd.d} and related instructions. Enabled by default.
27577 @subsection MMIX Options
27578 @cindex MMIX Options
27580 These options are defined for the MMIX:
27584 @itemx -mno-libfuncs
27586 @opindex mno-libfuncs
27587 Specify that intrinsic library functions are being compiled, passing all
27588 values in registers, no matter the size.
27591 @itemx -mno-epsilon
27593 @opindex mno-epsilon
27594 Generate floating-point comparison instructions that compare with respect
27595 to the @code{rE} epsilon register.
27597 @item -mabi=mmixware
27599 @opindex mabi=mmixware
27601 Generate code that passes function parameters and return values that (in
27602 the called function) are seen as registers @code{$0} and up, as opposed to
27603 the GNU ABI which uses global registers @code{$231} and up.
27605 @item -mzero-extend
27606 @itemx -mno-zero-extend
27607 @opindex mzero-extend
27608 @opindex mno-zero-extend
27609 When reading data from memory in sizes shorter than 64 bits, use (do not
27610 use) zero-extending load instructions by default, rather than
27611 sign-extending ones.
27614 @itemx -mno-knuthdiv
27616 @opindex mno-knuthdiv
27617 Make the result of a division yielding a remainder have the same sign as
27618 the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
27619 remainder follows the sign of the dividend. Both methods are
27620 arithmetically valid, the latter being almost exclusively used.
27622 @item -mtoplevel-symbols
27623 @itemx -mno-toplevel-symbols
27624 @opindex mtoplevel-symbols
27625 @opindex mno-toplevel-symbols
27626 Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
27627 code can be used with the @code{PREFIX} assembly directive.
27631 Generate an executable in the ELF format, rather than the default
27632 @samp{mmo} format used by the @command{mmix} simulator.
27634 @item -mbranch-predict
27635 @itemx -mno-branch-predict
27636 @opindex mbranch-predict
27637 @opindex mno-branch-predict
27638 Use (do not use) the probable-branch instructions, when static branch
27639 prediction indicates a probable branch.
27641 @item -mbase-addresses
27642 @itemx -mno-base-addresses
27643 @opindex mbase-addresses
27644 @opindex mno-base-addresses
27645 Generate (do not generate) code that uses @emph{base addresses}. Using a
27646 base address automatically generates a request (handled by the assembler
27647 and the linker) for a constant to be set up in a global register. The
27648 register is used for one or more base address requests within the range 0
27649 to 255 from the value held in the register. The generally leads to short
27650 and fast code, but the number of different data items that can be
27651 addressed is limited. This means that a program that uses lots of static
27652 data may require @option{-mno-base-addresses}.
27654 @item -msingle-exit
27655 @itemx -mno-single-exit
27656 @opindex msingle-exit
27657 @opindex mno-single-exit
27658 Force (do not force) generated code to have a single exit point in each
27662 @node MN10300 Options
27663 @subsection MN10300 Options
27664 @cindex MN10300 options
27666 These @option{-m} options are defined for Matsushita MN10300 architectures:
27671 Generate code to avoid bugs in the multiply instructions for the MN10300
27672 processors. This is the default.
27674 @item -mno-mult-bug
27675 @opindex mno-mult-bug
27676 Do not generate code to avoid bugs in the multiply instructions for the
27677 MN10300 processors.
27681 Generate code using features specific to the AM33 processor.
27685 Do not generate code using features specific to the AM33 processor. This
27690 Generate code using features specific to the AM33/2.0 processor.
27694 Generate code using features specific to the AM34 processor.
27696 @item -mtune=@var{cpu-type}
27698 Use the timing characteristics of the indicated CPU type when
27699 scheduling instructions. This does not change the targeted processor
27700 type. The CPU type must be one of @samp{mn10300}, @samp{am33},
27701 @samp{am33-2} or @samp{am34}.
27703 @item -mreturn-pointer-on-d0
27704 @opindex mreturn-pointer-on-d0
27705 When generating a function that returns a pointer, return the pointer
27706 in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
27707 only in @code{a0}, and attempts to call such functions without a prototype
27708 result in errors. Note that this option is on by default; use
27709 @option{-mno-return-pointer-on-d0} to disable it.
27713 Do not link in the C run-time initialization object file.
27717 Indicate to the linker that it should perform a relaxation optimization pass
27718 to shorten branches, calls and absolute memory addresses. This option only
27719 has an effect when used on the command line for the final link step.
27721 This option makes symbolic debugging impossible.
27725 Allow the compiler to generate @emph{Long Instruction Word}
27726 instructions if the target is the @samp{AM33} or later. This is the
27727 default. This option defines the preprocessor macro @code{__LIW__}.
27731 Do not allow the compiler to generate @emph{Long Instruction Word}
27732 instructions. This option defines the preprocessor macro
27737 Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
27738 instructions if the target is the @samp{AM33} or later. This is the
27739 default. This option defines the preprocessor macro @code{__SETLB__}.
27743 Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
27744 instructions. This option defines the preprocessor macro
27745 @code{__NO_SETLB__}.
27749 @node Moxie Options
27750 @subsection Moxie Options
27751 @cindex Moxie Options
27757 Generate big-endian code. This is the default for @samp{moxie-*-*}
27762 Generate little-endian code.
27766 Generate mul.x and umul.x instructions. This is the default for
27767 @samp{moxiebox-*-*} configurations.
27771 Do not link in the C run-time initialization object file.
27775 @node MSP430 Options
27776 @subsection MSP430 Options
27777 @cindex MSP430 Options
27779 These options are defined for the MSP430:
27785 Force assembly output to always use hex constants. Normally such
27786 constants are signed decimals, but this option is available for
27787 testsuite and/or aesthetic purposes.
27791 Select the MCU to target. This is used to create a C preprocessor
27792 symbol based upon the MCU name, converted to upper case and pre- and
27793 post-fixed with @samp{__}. This in turn is used by the
27794 @file{msp430.h} header file to select an MCU-specific supplementary
27797 The option also sets the ISA to use. If the MCU name is one that is
27798 known to only support the 430 ISA then that is selected, otherwise the
27799 430X ISA is selected. A generic MCU name of @samp{msp430} can also be
27800 used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
27801 name selects the 430X ISA.
27803 In addition an MCU-specific linker script is added to the linker
27804 command line. The script's name is the name of the MCU with
27805 @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
27806 command line defines the C preprocessor symbol @code{__XXX__} and
27807 cause the linker to search for a script called @file{xxx.ld}.
27809 The ISA and hardware multiply supported for the different MCUs is hard-coded
27810 into GCC. However, an external @samp{devices.csv} file can be used to
27811 extend device support beyond those that have been hard-coded.
27813 GCC searches for the @samp{devices.csv} file using the following methods in the
27814 given precedence order, where the first method takes precendence over the
27815 second which takes precedence over the third.
27818 @item Include path specified with @code{-I} and @code{-L}
27819 @samp{devices.csv} will be searched for in each of the directories specified by
27820 include paths and linker library search paths.
27821 @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
27822 Define the value of the global environment variable
27823 @samp{MSP430_GCC_INCLUDE_DIR}
27824 to the full path to the directory containing devices.csv, and GCC will search
27825 this directory for devices.csv. If devices.csv is found, this directory will
27826 also be registered as an include path, and linker library path. Header files
27827 and linker scripts in this directory can therefore be used without manually
27828 specifying @code{-I} and @code{-L} on the command line.
27829 @item The @samp{msp430-elf@{,bare@}/include/devices} directory
27830 Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
27831 toolchain root directory. This directory does not exist in a default
27832 installation, but if the user has created it and copied @samp{devices.csv}
27833 there, then the MCU data will be read. As above, this directory will
27834 also be registered as an include path, and linker library path.
27837 If none of the above search methods find @samp{devices.csv}, then the
27838 hard-coded MCU data is used.
27842 @itemx -mno-warn-mcu
27844 @opindex mno-warn-mcu
27845 This option enables or disables warnings about conflicts between the
27846 MCU name specified by the @option{-mmcu} option and the ISA set by the
27847 @option{-mcpu} option and/or the hardware multiply support set by the
27848 @option{-mhwmult} option. It also toggles warnings about unrecognized
27849 MCU names. This option is on by default.
27853 Specifies the ISA to use. Accepted values are @samp{msp430},
27854 @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
27855 @option{-mmcu=} option should be used to select the ISA.
27859 Link to the simulator runtime libraries and linker script. Overrides
27860 any scripts that would be selected by the @option{-mmcu=} option.
27864 Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
27868 Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
27872 This option is passed to the assembler and linker, and allows the
27873 linker to perform certain optimizations that cannot be done until
27878 Describes the type of hardware multiply supported by the target.
27879 Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
27880 for the original 16-bit-only multiply supported by early MCUs.
27881 @samp{32bit} for the 16/32-bit multiply supported by later MCUs and
27882 @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
27883 A value of @samp{auto} can also be given. This tells GCC to deduce
27884 the hardware multiply support based upon the MCU name provided by the
27885 @option{-mmcu} option. If no @option{-mmcu} option is specified or if
27886 the MCU name is not recognized then no hardware multiply support is
27887 assumed. @code{auto} is the default setting.
27889 Hardware multiplies are normally performed by calling a library
27890 routine. This saves space in the generated code. When compiling at
27891 @option{-O3} or higher however the hardware multiplier is invoked
27892 inline. This makes for bigger, but faster code.
27894 The hardware multiply routines disable interrupts whilst running and
27895 restore the previous interrupt state when they finish. This makes
27896 them safe to use inside interrupt handlers as well as in normal code.
27900 Enable the use of a minimum runtime environment - no static
27901 initializers or constructors. This is intended for memory-constrained
27902 devices. The compiler includes special symbols in some objects
27903 that tell the linker and runtime which code fragments are required.
27905 @item -mtiny-printf
27906 @opindex mtiny-printf
27907 Enable reduced code size @code{printf} and @code{puts} library functions.
27908 The @samp{tiny} implementations of these functions are not reentrant, so
27909 must be used with caution in multi-threaded applications.
27911 Support for streams has been removed and the string to be printed will
27912 always be sent to stdout via the @code{write} syscall. The string is not
27913 buffered before it is sent to write.
27915 This option requires Newlib Nano IO, so GCC must be configured with
27916 @samp{--enable-newlib-nano-formatted-io}.
27918 @item -mmax-inline-shift=
27919 @opindex mmax-inline-shift=
27920 This option takes an integer between 0 and 64 inclusive, and sets
27921 the maximum number of inline shift instructions which should be emitted to
27922 perform a shift operation by a constant amount. When this value needs to be
27923 exceeded, an mspabi helper function is used instead. The default value is 4.
27925 This only affects cases where a shift by multiple positions cannot be
27926 completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
27928 Shifts of a 32-bit value are at least twice as costly, so the value passed for
27929 this option is divided by 2 and the resulting value used instead.
27931 @item -mcode-region=
27932 @itemx -mdata-region=
27933 @opindex mcode-region
27934 @opindex mdata-region
27935 These options tell the compiler where to place functions and data that
27936 do not have one of the @code{lower}, @code{upper}, @code{either} or
27937 @code{section} attributes. Possible values are @code{lower},
27938 @code{upper}, @code{either} or @code{any}. The first three behave
27939 like the corresponding attribute. The fourth possible value -
27940 @code{any} - is the default. It leaves placement entirely up to the
27941 linker script and how it assigns the standard sections
27942 (@code{.text}, @code{.data}, etc) to the memory regions.
27944 @item -msilicon-errata=
27945 @opindex msilicon-errata
27946 This option passes on a request to assembler to enable the fixes for
27947 the named silicon errata.
27949 @item -msilicon-errata-warn=
27950 @opindex msilicon-errata-warn
27951 This option passes on a request to the assembler to enable warning
27952 messages when a silicon errata might need to be applied.
27954 @item -mwarn-devices-csv
27955 @itemx -mno-warn-devices-csv
27956 @opindex mwarn-devices-csv
27957 @opindex mno-warn-devices-csv
27958 Warn if @samp{devices.csv} is not found or there are problem parsing it
27963 @node NDS32 Options
27964 @subsection NDS32 Options
27965 @cindex NDS32 Options
27967 These options are defined for NDS32 implementations:
27972 @opindex mbig-endian
27973 Generate code in big-endian mode.
27975 @item -mlittle-endian
27976 @opindex mlittle-endian
27977 Generate code in little-endian mode.
27979 @item -mreduced-regs
27980 @opindex mreduced-regs
27981 Use reduced-set registers for register allocation.
27984 @opindex mfull-regs
27985 Use full-set registers for register allocation.
27989 Generate conditional move instructions.
27993 Do not generate conditional move instructions.
27997 Generate performance extension instructions.
27999 @item -mno-ext-perf
28000 @opindex mno-ext-perf
28001 Do not generate performance extension instructions.
28004 @opindex mext-perf2
28005 Generate performance extension 2 instructions.
28007 @item -mno-ext-perf2
28008 @opindex mno-ext-perf2
28009 Do not generate performance extension 2 instructions.
28012 @opindex mext-string
28013 Generate string extension instructions.
28015 @item -mno-ext-string
28016 @opindex mno-ext-string
28017 Do not generate string extension instructions.
28021 Generate v3 push25/pop25 instructions.
28024 @opindex mno-v3push
28025 Do not generate v3 push25/pop25 instructions.
28029 Generate 16-bit instructions.
28032 @opindex mno-16-bit
28033 Do not generate 16-bit instructions.
28035 @item -misr-vector-size=@var{num}
28036 @opindex misr-vector-size
28037 Specify the size of each interrupt vector, which must be 4 or 16.
28039 @item -mcache-block-size=@var{num}
28040 @opindex mcache-block-size
28041 Specify the size of each cache block,
28042 which must be a power of 2 between 4 and 512.
28044 @item -march=@var{arch}
28046 Specify the name of the target architecture.
28048 @item -mcmodel=@var{code-model}
28050 Set the code model to one of
28053 All the data and read-only data segments must be within 512KB addressing space.
28054 The text segment must be within 16MB addressing space.
28055 @item @samp{medium}
28056 The data segment must be within 512KB while the read-only data segment can be
28057 within 4GB addressing space. The text segment should be still within 16MB
28060 All the text and data segments can be within 4GB addressing space.
28064 @opindex mctor-dtor
28065 Enable constructor/destructor feature.
28069 Guide linker to relax instructions.
28073 @node Nios II Options
28074 @subsection Nios II Options
28075 @cindex Nios II options
28076 @cindex Altera Nios II options
28078 These are the options defined for the Altera Nios II processor.
28084 @cindex smaller data references
28085 Put global and static objects less than or equal to @var{num} bytes
28086 into the small data or BSS sections instead of the normal data or BSS
28087 sections. The default value of @var{num} is 8.
28089 @item -mgpopt=@var{option}
28094 Generate (do not generate) GP-relative accesses. The following
28095 @var{option} names are recognized:
28100 Do not generate GP-relative accesses.
28103 Generate GP-relative accesses for small data objects that are not
28104 external, weak, or uninitialized common symbols.
28105 Also use GP-relative addressing for objects that
28106 have been explicitly placed in a small data section via a @code{section}
28110 As for @samp{local}, but also generate GP-relative accesses for
28111 small data objects that are external, weak, or common. If you use this option,
28112 you must ensure that all parts of your program (including libraries) are
28113 compiled with the same @option{-G} setting.
28116 Generate GP-relative accesses for all data objects in the program. If you
28117 use this option, the entire data and BSS segments
28118 of your program must fit in 64K of memory and you must use an appropriate
28119 linker script to allocate them within the addressable range of the
28123 Generate GP-relative addresses for function pointers as well as data
28124 pointers. If you use this option, the entire text, data, and BSS segments
28125 of your program must fit in 64K of memory and you must use an appropriate
28126 linker script to allocate them within the addressable range of the
28131 @option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28132 @option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28134 The default is @option{-mgpopt} except when @option{-fpic} or
28135 @option{-fPIC} is specified to generate position-independent code.
28136 Note that the Nios II ABI does not permit GP-relative accesses from
28139 You may need to specify @option{-mno-gpopt} explicitly when building
28140 programs that include large amounts of small data, including large
28141 GOT data sections. In this case, the 16-bit offset for GP-relative
28142 addressing may not be large enough to allow access to the entire
28143 small data section.
28145 @item -mgprel-sec=@var{regexp}
28146 @opindex mgprel-sec
28147 This option specifies additional section names that can be accessed via
28148 GP-relative addressing. It is most useful in conjunction with
28149 @code{section} attributes on variable declarations
28150 (@pxref{Common Variable Attributes}) and a custom linker script.
28151 The @var{regexp} is a POSIX Extended Regular Expression.
28153 This option does not affect the behavior of the @option{-G} option, and
28154 the specified sections are in addition to the standard @code{.sdata}
28155 and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28157 @item -mr0rel-sec=@var{regexp}
28158 @opindex mr0rel-sec
28159 This option specifies names of sections that can be accessed via a
28160 16-bit offset from @code{r0}; that is, in the low 32K or high 32K
28161 of the 32-bit address space. It is most useful in conjunction with
28162 @code{section} attributes on variable declarations
28163 (@pxref{Common Variable Attributes}) and a custom linker script.
28164 The @var{regexp} is a POSIX Extended Regular Expression.
28166 In contrast to the use of GP-relative addressing for small data,
28167 zero-based addressing is never generated by default and there are no
28168 conventional section names used in standard linker scripts for sections
28169 in the low or high areas of memory.
28175 Generate little-endian (default) or big-endian (experimental) code,
28178 @item -march=@var{arch}
28180 This specifies the name of the target Nios II architecture. GCC uses this
28181 name to determine what kind of instructions it can emit when generating
28182 assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28184 The preprocessor macro @code{__nios2_arch__} is available to programs,
28185 with value 1 or 2, indicating the targeted ISA level.
28187 @item -mbypass-cache
28188 @itemx -mno-bypass-cache
28189 @opindex mno-bypass-cache
28190 @opindex mbypass-cache
28191 Force all load and store instructions to always bypass cache by
28192 using I/O variants of the instructions. The default is not to
28195 @item -mno-cache-volatile
28196 @itemx -mcache-volatile
28197 @opindex mcache-volatile
28198 @opindex mno-cache-volatile
28199 Volatile memory access bypass the cache using the I/O variants of
28200 the load and store instructions. The default is not to bypass the cache.
28202 @item -mno-fast-sw-div
28203 @itemx -mfast-sw-div
28204 @opindex mno-fast-sw-div
28205 @opindex mfast-sw-div
28206 Do not use table-based fast divide for small numbers. The default
28207 is to use the fast divide at @option{-O3} and above.
28211 @itemx -mno-hw-mulx
28215 @opindex mno-hw-mul
28217 @opindex mno-hw-mulx
28219 @opindex mno-hw-div
28221 Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28222 instructions by the compiler. The default is to emit @code{mul}
28223 and not emit @code{div} and @code{mulx}.
28229 Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28230 CDX (code density) instructions. Enabling these instructions also
28231 requires @option{-march=r2}. Since these instructions are optional
28232 extensions to the R2 architecture, the default is not to emit them.
28234 @item -mcustom-@var{insn}=@var{N}
28235 @itemx -mno-custom-@var{insn}
28236 @opindex mcustom-@var{insn}
28237 @opindex mno-custom-@var{insn}
28238 Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28239 custom instruction with encoding @var{N} when generating code that uses
28240 @var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28241 instruction 253 for single-precision floating-point add operations instead
28242 of the default behavior of using a library call.
28244 The following values of @var{insn} are supported. Except as otherwise
28245 noted, floating-point operations are expected to be implemented with
28246 normal IEEE 754 semantics and correspond directly to the C operators or the
28247 equivalent GCC built-in functions (@pxref{Other Builtins}).
28249 Single-precision floating point:
28252 @item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28253 Binary arithmetic operations.
28259 Unary absolute value.
28261 @item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28262 Comparison operations.
28264 @item @samp{fmins}, @samp{fmaxs}
28265 Floating-point minimum and maximum. These instructions are only
28266 generated if @option{-ffinite-math-only} is specified.
28268 @item @samp{fsqrts}
28269 Unary square root operation.
28271 @item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28272 Floating-point trigonometric and exponential functions. These instructions
28273 are only generated if @option{-funsafe-math-optimizations} is also specified.
28277 Double-precision floating point:
28280 @item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28281 Binary arithmetic operations.
28287 Unary absolute value.
28289 @item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28290 Comparison operations.
28292 @item @samp{fmind}, @samp{fmaxd}
28293 Double-precision minimum and maximum. These instructions are only
28294 generated if @option{-ffinite-math-only} is specified.
28296 @item @samp{fsqrtd}
28297 Unary square root operation.
28299 @item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28300 Double-precision trigonometric and exponential functions. These instructions
28301 are only generated if @option{-funsafe-math-optimizations} is also specified.
28307 @item @samp{fextsd}
28308 Conversion from single precision to double precision.
28310 @item @samp{ftruncds}
28311 Conversion from double precision to single precision.
28313 @item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28314 Conversion from floating point to signed or unsigned integer types, with
28315 truncation towards zero.
28318 Conversion from single-precision floating point to signed integer,
28319 rounding to the nearest integer and ties away from zero.
28320 This corresponds to the @code{__builtin_lroundf} function when
28321 @option{-fno-math-errno} is used.
28323 @item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28324 Conversion from signed or unsigned integer types to floating-point types.
28328 In addition, all of the following transfer instructions for internal
28329 registers X and Y must be provided to use any of the double-precision
28330 floating-point instructions. Custom instructions taking two
28331 double-precision source operands expect the first operand in the
28332 64-bit register X. The other operand (or only operand of a unary
28333 operation) is given to the custom arithmetic instruction with the
28334 least significant half in source register @var{src1} and the most
28335 significant half in @var{src2}. A custom instruction that returns a
28336 double-precision result returns the most significant 32 bits in the
28337 destination register and the other half in 32-bit register Y.
28338 GCC automatically generates the necessary code sequences to write
28339 register X and/or read register Y when double-precision floating-point
28340 instructions are used.
28345 Write @var{src1} into the least significant half of X and @var{src2} into
28346 the most significant half of X.
28349 Write @var{src1} into Y.
28351 @item @samp{frdxhi}, @samp{frdxlo}
28352 Read the most or least (respectively) significant half of X and store it in
28356 Read the value of Y and store it into @var{dest}.
28359 Note that you can gain more local control over generation of Nios II custom
28360 instructions by using the @code{target("custom-@var{insn}=@var{N}")}
28361 and @code{target("no-custom-@var{insn}")} function attributes
28362 (@pxref{Function Attributes})
28363 or pragmas (@pxref{Function Specific Option Pragmas}).
28365 @item -mcustom-fpu-cfg=@var{name}
28366 @opindex mcustom-fpu-cfg
28368 This option enables a predefined, named set of custom instruction encodings
28369 (see @option{-mcustom-@var{insn}} above).
28370 Currently, the following sets are defined:
28372 @option{-mcustom-fpu-cfg=60-1} is equivalent to:
28373 @gccoptlist{-mcustom-fmuls=252 @gol
28374 -mcustom-fadds=253 @gol
28375 -mcustom-fsubs=254 @gol
28376 -fsingle-precision-constant}
28378 @option{-mcustom-fpu-cfg=60-2} is equivalent to:
28379 @gccoptlist{-mcustom-fmuls=252 @gol
28380 -mcustom-fadds=253 @gol
28381 -mcustom-fsubs=254 @gol
28382 -mcustom-fdivs=255 @gol
28383 -fsingle-precision-constant}
28385 @option{-mcustom-fpu-cfg=72-3} is equivalent to:
28386 @gccoptlist{-mcustom-floatus=243 @gol
28387 -mcustom-fixsi=244 @gol
28388 -mcustom-floatis=245 @gol
28389 -mcustom-fcmpgts=246 @gol
28390 -mcustom-fcmples=249 @gol
28391 -mcustom-fcmpeqs=250 @gol
28392 -mcustom-fcmpnes=251 @gol
28393 -mcustom-fmuls=252 @gol
28394 -mcustom-fadds=253 @gol
28395 -mcustom-fsubs=254 @gol
28396 -mcustom-fdivs=255 @gol
28397 -fsingle-precision-constant}
28399 @option{-mcustom-fpu-cfg=fph2} is equivalent to:
28400 @gccoptlist{-mcustom-fabss=224 @gol
28401 -mcustom-fnegs=225 @gol
28402 -mcustom-fcmpnes=226 @gol
28403 -mcustom-fcmpeqs=227 @gol
28404 -mcustom-fcmpges=228 @gol
28405 -mcustom-fcmpgts=229 @gol
28406 -mcustom-fcmples=230 @gol
28407 -mcustom-fcmplts=231 @gol
28408 -mcustom-fmaxs=232 @gol
28409 -mcustom-fmins=233 @gol
28410 -mcustom-round=248 @gol
28411 -mcustom-fixsi=249 @gol
28412 -mcustom-floatis=250 @gol
28413 -mcustom-fsqrts=251 @gol
28414 -mcustom-fmuls=252 @gol
28415 -mcustom-fadds=253 @gol
28416 -mcustom-fsubs=254 @gol
28417 -mcustom-fdivs=255 @gol}
28419 Custom instruction assignments given by individual
28420 @option{-mcustom-@var{insn}=} options override those given by
28421 @option{-mcustom-fpu-cfg=}, regardless of the
28422 order of the options on the command line.
28424 Note that you can gain more local control over selection of a FPU
28425 configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
28426 function attribute (@pxref{Function Attributes})
28427 or pragma (@pxref{Function Specific Option Pragmas}).
28429 The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
28430 Hardware 2 Component}. Please note that the custom instructions enabled by
28431 @option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
28432 if @option{-ffinite-math-only} is specified. The custom instruction enabled by
28433 @option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
28434 specified. In contrast to the other configurations,
28435 @option{-fsingle-precision-constant} is not set.
28439 These additional @samp{-m} options are available for the Altera Nios II
28440 ELF (bare-metal) target:
28446 Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
28447 startup and termination code, and is typically used in conjunction with
28448 @option{-msys-crt0=} to specify the location of the alternate startup code
28449 provided by the HAL BSP.
28453 Link with a limited version of the C library, @option{-lsmallc}, rather than
28456 @item -msys-crt0=@var{startfile}
28458 @var{startfile} is the file name of the startfile (crt0) to use
28459 when linking. This option is only useful in conjunction with @option{-mhal}.
28461 @item -msys-lib=@var{systemlib}
28463 @var{systemlib} is the library name of the library that provides
28464 low-level system calls required by the C library,
28465 e.g.@: @code{read} and @code{write}.
28466 This option is typically used to link with a library provided by a HAL BSP.
28470 @node Nvidia PTX Options
28471 @subsection Nvidia PTX Options
28472 @cindex Nvidia PTX options
28473 @cindex nvptx options
28475 These options are defined for Nvidia PTX:
28481 Ignored, but preserved for backward compatibility. Only 64-bit ABI is
28484 @item -march=@var{architecture-string}
28486 Generate code for the specified PTX ISA target architecture
28487 (e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
28488 @samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
28490 The default depends on how the compiler has been configured, see
28491 @option{--with-arch}.
28493 This option sets the value of the preprocessor macro
28494 @code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
28497 @item -misa=@var{architecture-string}
28499 Alias of @option{-march=}.
28501 @item -march-map=@var{architecture-string}
28503 Select the closest available @option{-march=} value that is not more
28504 capable. For instance, for @option{-march-map=sm_50} select
28505 @option{-march=sm_35}, and for @option{-march-map=sm_53} select
28506 @option{-march=sm_53}.
28508 @item -mptx=@var{version-string}
28510 Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
28511 Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
28512 @samp{7.0}. The default PTX ISA version is 6.0, unless a higher
28513 version is required for specified PTX ISA target architecture via
28514 option @option{-march=}.
28516 This option sets the values of the preprocessor macros
28517 @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
28518 for instance, for @samp{3.1} the macros have the values @samp{3} and
28519 @samp{1}, respectively.
28522 @opindex mmainkernel
28523 Link in code for a __main kernel. This is for stand-alone instead of
28524 offloading execution.
28528 Apply partitioned execution optimizations. This is the default when any
28529 level of optimization is selected.
28532 @opindex msoft-stack
28533 Generate code that does not use @code{.local} memory
28534 directly for stack storage. Instead, a per-warp stack pointer is
28535 maintained explicitly. This enables variable-length stack allocation (with
28536 variable-length arrays or @code{alloca}), and when global memory is used for
28537 underlying storage, makes it possible to access automatic variables from other
28538 threads, or with atomic instructions. This code generation variant is used
28539 for OpenMP offloading, but the option is exposed on its own for the purpose
28540 of testing the compiler; to generate code suitable for linking into programs
28541 using OpenMP offloading, use option @option{-mgomp}.
28543 @item -muniform-simt
28544 @opindex muniform-simt
28545 Switch to code generation variant that allows to execute all threads in each
28546 warp, while maintaining memory state and side effects as if only one thread
28547 in each warp was active outside of OpenMP SIMD regions. All atomic operations
28548 and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
28549 current lane index equals the master lane index), and the register being
28550 assigned is copied via a shuffle instruction from the master lane. Outside of
28551 SIMD regions lane 0 is the master; inside, each thread sees itself as the
28552 master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
28553 all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
28554 regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
28555 with current lane index to compute the master lane index.
28559 Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
28560 @option{-muniform-simt} options, and selects corresponding multilib variant.
28564 @node OpenRISC Options
28565 @subsection OpenRISC Options
28566 @cindex OpenRISC Options
28568 These options are defined for OpenRISC:
28572 @item -mboard=@var{name}
28574 Configure a board specific runtime. This will be passed to the linker for
28575 newlib board library linking. The default is @code{or1ksim}.
28579 This option is ignored; it is for compatibility purposes only. This used to
28580 select linker and preprocessor options for use with newlib.
28586 Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
28587 This default is hardware divide.
28593 Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
28594 This default is hardware multiply.
28597 @itemx -mhard-float
28598 @opindex msoft-float
28599 @opindex mhard-float
28600 Select software or hardware for floating point operations.
28601 The default is software.
28603 @item -mdouble-float
28604 @opindex mdouble-float
28605 When @option{-mhard-float} is selected, enables generation of double-precision
28606 floating point instructions. By default functions from @file{libgcc} are used
28607 to perform double-precision floating point operations.
28609 @item -munordered-float
28610 @opindex munordered-float
28611 When @option{-mhard-float} is selected, enables generation of unordered
28612 floating point compare and set flag (@code{lf.sfun*}) instructions. By default
28613 functions from @file{libgcc} are used to perform unordered floating point
28614 compare and set flag operations.
28618 Enable generation of conditional move (@code{l.cmov}) instructions. By
28619 default the equivalent will be generated using set and branch.
28623 Enable generation of rotate right (@code{l.ror}) instructions. By default
28624 functions from @file{libgcc} are used to perform rotate right operations.
28628 Enable generation of rotate right with immediate (@code{l.rori}) instructions.
28629 By default functions from @file{libgcc} are used to perform rotate right with
28630 immediate operations.
28634 Enable generation of sign extension (@code{l.ext*}) instructions. By default
28635 memory loads are used to perform sign extension.
28639 Enable generation of compare and set flag with immediate (@code{l.sf*i})
28640 instructions. By default extra instructions will be generated to store the
28641 immediate to a register first.
28645 Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
28646 @code{l.slli}) instructions. By default extra instructions will be generated
28647 to store the immediate to a register first.
28649 @item -mcmodel=small
28650 @opindex mcmodel=small
28651 Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
28654 @item -mcmodel=large
28655 @opindex mcmodel=large
28656 Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
28661 @node PDP-11 Options
28662 @subsection PDP-11 Options
28663 @cindex PDP-11 Options
28665 These options are defined for the PDP-11:
28670 Use hardware FPP floating point. This is the default. (FIS floating
28671 point on the PDP-11/40 is not supported.) Implies -m45.
28674 @opindex msoft-float
28675 Do not use hardware floating point.
28679 Return floating-point results in ac0 (fr0 in Unix assembler syntax).
28683 Return floating-point results in memory. This is the default.
28687 Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
28691 Generate code for a PDP-11/45. This is the default.
28695 Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
28701 Use 16-bit @code{int}. This is the default.
28707 Use 32-bit @code{int}.
28711 Target has split instruction and data space. Implies -m45.
28715 Use Unix assembler syntax.
28719 Use DEC assembler syntax.
28723 Use GNU assembler syntax. This is the default.
28727 Use the new LRA register allocator. By default, the old ``reload''
28731 @node PowerPC Options
28732 @subsection PowerPC Options
28733 @cindex PowerPC options
28735 These are listed under @xref{RS/6000 and PowerPC Options}.
28738 @subsection PRU Options
28739 @cindex PRU Options
28741 These command-line options are defined for PRU target:
28746 Link with a minimum runtime environment, with no support for static
28747 initializers and constructors. Using this option can significantly reduce
28748 the size of the final ELF binary. Beware that the compiler could still
28749 generate code with static initializers and constructors. It is up to the
28750 programmer to ensure that the source program will not use those features.
28752 @item -mmcu=@var{mcu}
28754 Specify the PRU MCU variant to use. Check Newlib for the exact list of
28759 Make GCC pass the @option{--no-relax} command-line option to the linker
28760 instead of the @option{--relax} option.
28764 Allow (or do not allow) GCC to use the LOOP instruction.
28766 @item -mabi=@var{variant}
28768 Specify the ABI variant to output code for. @option{-mabi=ti} selects the
28769 unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
28770 more naturally with certain GCC assumptions. These are the differences:
28773 @item Function Pointer Size
28774 TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
28775 supports only 32-bit data and code pointers.
28777 @item Optional Return Value Pointer
28778 Function return values larger than 64 bits are passed by using a hidden
28779 pointer as the first argument of the function. TI ABI, though, mandates that
28780 the pointer can be NULL in case the caller is not using the returned value.
28781 GNU always passes and expects a valid return value pointer.
28785 The current @option{-mabi=ti} implementation simply raises a compile error
28786 when any of the above code constructs is detected. As a consequence
28787 the standard C library cannot be built and it is omitted when linking with
28790 Relaxation is a GNU feature and for safety reasons is disabled when using
28791 @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
28792 instructions, so the GNU linker cannot adjust them when shortening adjacent
28793 LDI32 pseudo instructions.
28797 @node RISC-V Options
28798 @subsection RISC-V Options
28799 @cindex RISC-V Options
28801 These command-line options are defined for RISC-V targets:
28804 @item -mbranch-cost=@var{n}
28805 @opindex mbranch-cost
28806 Set the cost of branches to roughly @var{n} instructions.
28811 When generating PIC code, do or don't allow the use of PLTs. Ignored for
28812 non-PIC. The default is @option{-mplt}.
28814 @item -mabi=@var{ABI-string}
28816 Specify integer and floating-point calling convention. @var{ABI-string}
28817 contains two parts: the size of integer types and the registers used for
28818 floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
28819 @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
28820 32-bit), and that floating-point values up to 64 bits wide are passed in F
28821 registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
28822 allows the compiler to generate code that uses the F and D extensions but only
28823 allows floating-point values up to 32 bits long to be passed in registers; or
28824 @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
28825 passed in registers.
28827 The default for this argument is system dependent, users who want a specific
28828 calling convention should specify one explicitly. The valid calling
28829 conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
28830 @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
28831 implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
28832 invalid because the ABI requires 64-bit values be passed in F registers, but F
28833 registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
28834 only be used with the @samp{rv32e} architecture. This ABI is not well
28835 specified at present, and is subject to change.
28840 Do or don't use hardware floating-point divide and square root instructions.
28841 This requires the F or D extensions for floating-point registers. The default
28842 is to use them if the specified architecture has these instructions.
28847 Do or don't use hardware instructions for integer division. This requires the
28848 M extension. The default is to use them if the specified architecture has
28849 these instructions.
28851 @item -misa-spec=@var{ISA-spec-string}
28853 Specify the version of the RISC-V Unprivileged (formerly User-Level)
28854 ISA specification to produce code conforming to. The possibilities
28855 for @var{ISA-spec-string} are:
28858 Produce code conforming to version 2.2.
28860 Produce code conforming to version 20190608.
28862 Produce code conforming to version 20191213.
28864 The default is @option{-misa-spec=20191213} unless GCC has been configured
28865 with @option{--with-isa-spec=} specifying a different default version.
28867 @item -march=@var{ISA-string}
28869 Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
28870 lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
28873 When @option{-march=} is not specified, use the setting from @option{-mcpu}.
28875 If both @option{-march} and @option{-mcpu=} are not specified, the default for
28876 this argument is system dependent, users who want a specific architecture
28877 extensions should specify one explicitly.
28879 @item -mcpu=@var{processor-string}
28881 Use architecture of and optimize the output for the given processor, specified
28882 by particular CPU name.
28883 Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
28884 @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
28885 @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
28886 @samp{sifive-u54}, and @samp{sifive-u74}.
28888 @item -mtune=@var{processor-string}
28890 Optimize the output for the given processor, specified by microarchitecture or
28891 particular CPU name. Permissible values for this option are: @samp{rocket},
28892 @samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
28893 @samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
28895 When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
28896 the default is @samp{rocket} if both are not specified.
28898 The @samp{size} choice is not intended for use by end-users. This is used
28899 when @option{-Os} is specified. It overrides the instruction cost info
28900 provided by @option{-mtune=}, but does not override the pipeline info. This
28901 helps reduce code size while still giving good performance.
28903 @item -mpreferred-stack-boundary=@var{num}
28904 @opindex mpreferred-stack-boundary
28905 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
28906 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
28907 the default is 4 (16 bytes or 128-bits).
28909 @strong{Warning:} If you use this switch, then you must build all modules with
28910 the same value, including any libraries. This includes the system libraries
28911 and startup modules.
28913 @item -msmall-data-limit=@var{n}
28914 @opindex msmall-data-limit
28915 Put global and static data smaller than @var{n} bytes into a special section
28918 @item -msave-restore
28919 @itemx -mno-save-restore
28920 @opindex msave-restore
28921 Do or don't use smaller but slower prologue and epilogue code that uses
28922 library function calls. The default is to use fast inline prologues and
28925 @item -mshorten-memrefs
28926 @itemx -mno-shorten-memrefs
28927 @opindex mshorten-memrefs
28928 Do or do not attempt to make more use of compressed load/store instructions by
28929 replacing a load/store of 'base register + large offset' with a new load/store
28930 of 'new base + small offset'. If the new base gets stored in a compressed
28931 register, then the new load/store can be compressed. Currently targets 32-bit
28932 integer load/stores only.
28934 @item -mstrict-align
28935 @itemx -mno-strict-align
28936 @opindex mstrict-align
28937 Do not or do generate unaligned memory accesses. The default is set depending
28938 on whether the processor we are optimizing for supports fast unaligned access
28941 @item -mcmodel=medlow
28942 @opindex mcmodel=medlow
28943 Generate code for the medium-low code model. The program and its statically
28944 defined symbols must lie within a single 2 GiB address range and must lie
28945 between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
28946 statically or dynamically linked. This is the default code model.
28948 @item -mcmodel=medany
28949 @opindex mcmodel=medany
28950 Generate code for the medium-any code model. The program and its statically
28951 defined symbols must be within any single 2 GiB address range. Programs can be
28952 statically or dynamically linked.
28954 The code generated by the medium-any code model is position-independent, but is
28955 not guaranteed to function correctly when linked into position-independent
28956 executables or libraries.
28958 @item -mexplicit-relocs
28959 @itemx -mno-exlicit-relocs
28960 Use or do not use assembler relocation operators when dealing with symbolic
28961 addresses. The alternative is to use assembler macros instead, which may
28962 limit optimization.
28967 Take advantage of linker relaxations to reduce the number of instructions
28968 required to materialize symbol addresses. The default is to take advantage of
28969 linker relaxations.
28971 @item -mriscv-attribute
28972 @itemx -mno-riscv-attribute
28973 @opindex mriscv-attribute
28974 Emit (do not emit) RISC-V attribute to record extra information into ELF
28975 objects. This feature requires at least binutils 2.32.
28978 @itemx -mno-csr-check
28979 @opindex mcsr-check
28980 Enables or disables the CSR checking.
28982 @item -malign-data=@var{type}
28983 @opindex malign-data
28984 Control how GCC aligns variables and constants of array, structure, or union
28985 types. Supported values for @var{type} are @samp{xlen} which uses x register
28986 width as the alignment value, and @samp{natural} which uses natural alignment.
28987 @samp{xlen} is the default.
28990 @opindex mbig-endian
28991 Generate big-endian code. This is the default when GCC is configured for a
28992 @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
28994 @item -mlittle-endian
28995 @opindex mlittle-endian
28996 Generate little-endian code. This is the default when GCC is configured for a
28997 @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
28998 @samp{riscv32be-*-*} target.
29000 @item -mstack-protector-guard=@var{guard}
29001 @itemx -mstack-protector-guard-reg=@var{reg}
29002 @itemx -mstack-protector-guard-offset=@var{offset}
29003 @opindex mstack-protector-guard
29004 @opindex mstack-protector-guard-reg
29005 @opindex mstack-protector-guard-offset
29006 Generate stack protection code using canary at @var{guard}. Supported
29007 locations are @samp{global} for a global canary or @samp{tls} for per-thread
29008 canary in the TLS block.
29010 With the latter choice the options
29011 @option{-mstack-protector-guard-reg=@var{reg}} and
29012 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
29013 which register to use as base register for reading the canary,
29014 and from what offset from that base register. There is no default
29015 register or offset as this is entirely for use within the Linux
29020 @subsection RL78 Options
29021 @cindex RL78 Options
29027 Links in additional target libraries to support operation within a
29036 Specifies the type of hardware multiplication and division support to
29037 be used. The simplest is @code{none}, which uses software for both
29038 multiplication and division. This is the default. The @code{g13}
29039 value is for the hardware multiply/divide peripheral found on the
29040 RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
29041 the multiplication and division instructions supported by the RL78/G14
29042 (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
29043 the value @code{mg10} is an alias for @code{none}.
29045 In addition a C preprocessor macro is defined, based upon the setting
29046 of this option. Possible values are: @code{__RL78_MUL_NONE__},
29047 @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
29054 Specifies the RL78 core to target. The default is the G14 core, also
29055 known as an S3 core or just RL78. The G13 or S2 core does not have
29056 multiply or divide instructions, instead it uses a hardware peripheral
29057 for these operations. The G10 or S1 core does not have register
29058 banks, so it uses a different calling convention.
29060 If this option is set it also selects the type of hardware multiply
29061 support to use, unless this is overridden by an explicit
29062 @option{-mmul=none} option on the command line. Thus specifying
29063 @option{-mcpu=g13} enables the use of the G13 hardware multiply
29064 peripheral and specifying @option{-mcpu=g10} disables the use of
29065 hardware multiplications altogether.
29067 Note, although the RL78/G14 core is the default target, specifying
29068 @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
29069 change the behavior of the toolchain since it also enables G14
29070 hardware multiply support. If these options are not specified on the
29071 command line then software multiplication routines will be used even
29072 though the code targets the RL78 core. This is for backwards
29073 compatibility with older toolchains which did not have hardware
29074 multiply and divide support.
29076 In addition a C preprocessor macro is defined, based upon the setting
29077 of this option. Possible values are: @code{__RL78_G10__},
29078 @code{__RL78_G13__} or @code{__RL78_G14__}.
29088 These are aliases for the corresponding @option{-mcpu=} option. They
29089 are provided for backwards compatibility.
29093 Allow the compiler to use all of the available registers. By default
29094 registers @code{r24..r31} are reserved for use in interrupt handlers.
29095 With this option enabled these registers can be used in ordinary
29098 @item -m64bit-doubles
29099 @itemx -m32bit-doubles
29100 @opindex m64bit-doubles
29101 @opindex m32bit-doubles
29102 Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
29103 or 32 bits (@option{-m32bit-doubles}) in size. The default is
29104 @option{-m32bit-doubles}.
29106 @item -msave-mduc-in-interrupts
29107 @itemx -mno-save-mduc-in-interrupts
29108 @opindex msave-mduc-in-interrupts
29109 @opindex mno-save-mduc-in-interrupts
29110 Specifies that interrupt handler functions should preserve the
29111 MDUC registers. This is only necessary if normal code might use
29112 the MDUC registers, for example because it performs multiplication
29113 and division operations. The default is to ignore the MDUC registers
29114 as this makes the interrupt handlers faster. The target option -mg13
29115 needs to be passed for this to work as this feature is only available
29116 on the G13 target (S2 core). The MDUC registers will only be saved
29117 if the interrupt handler performs a multiplication or division
29118 operation or it calls another function.
29122 @node RS/6000 and PowerPC Options
29123 @subsection IBM RS/6000 and PowerPC Options
29124 @cindex RS/6000 and PowerPC Options
29125 @cindex IBM RS/6000 and PowerPC Options
29127 These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29129 @item -mpowerpc-gpopt
29130 @itemx -mno-powerpc-gpopt
29131 @itemx -mpowerpc-gfxopt
29132 @itemx -mno-powerpc-gfxopt
29135 @itemx -mno-powerpc64
29139 @itemx -mno-popcntb
29141 @itemx -mno-popcntd
29148 @itemx -mno-hard-dfp
29149 @opindex mpowerpc-gpopt
29150 @opindex mno-powerpc-gpopt
29151 @opindex mpowerpc-gfxopt
29152 @opindex mno-powerpc-gfxopt
29153 @opindex mpowerpc64
29154 @opindex mno-powerpc64
29158 @opindex mno-popcntb
29160 @opindex mno-popcntd
29166 @opindex mno-hard-dfp
29167 You use these options to specify which instructions are available on the
29168 processor you are using. The default value of these options is
29169 determined when configuring GCC@. Specifying the
29170 @option{-mcpu=@var{cpu_type}} overrides the specification of these
29171 options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29172 rather than the options listed above.
29174 Specifying @option{-mpowerpc-gpopt} allows
29175 GCC to use the optional PowerPC architecture instructions in the
29176 General Purpose group, including floating-point square root. Specifying
29177 @option{-mpowerpc-gfxopt} allows GCC to
29178 use the optional PowerPC architecture instructions in the Graphics
29179 group, including floating-point select.
29181 The @option{-mmfcrf} option allows GCC to generate the move from
29182 condition register field instruction implemented on the POWER4
29183 processor and other processors that support the PowerPC V2.01
29185 The @option{-mpopcntb} option allows GCC to generate the popcount and
29186 double-precision FP reciprocal estimate instruction implemented on the
29187 POWER5 processor and other processors that support the PowerPC V2.02
29189 The @option{-mpopcntd} option allows GCC to generate the popcount
29190 instruction implemented on the POWER7 processor and other processors
29191 that support the PowerPC V2.06 architecture.
29192 The @option{-mfprnd} option allows GCC to generate the FP round to
29193 integer instructions implemented on the POWER5+ processor and other
29194 processors that support the PowerPC V2.03 architecture.
29195 The @option{-mcmpb} option allows GCC to generate the compare bytes
29196 instruction implemented on the POWER6 processor and other processors
29197 that support the PowerPC V2.05 architecture.
29198 The @option{-mhard-dfp} option allows GCC to generate the decimal
29199 floating-point instructions implemented on some POWER processors.
29201 The @option{-mpowerpc64} option allows GCC to generate the additional
29202 64-bit instructions that are found in the full PowerPC64 architecture
29203 and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29204 @option{-mno-powerpc64}.
29206 @item -mcpu=@var{cpu_type}
29208 Set architecture type, register usage, and
29209 instruction scheduling parameters for machine type @var{cpu_type}.
29210 Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29211 @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29212 @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29213 @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29214 @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29215 @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29216 @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29217 @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29218 @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29219 @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29220 @samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29221 @samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29223 @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29224 @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29225 endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29226 architecture machine types, with an appropriate, generic processor
29227 model assumed for scheduling purposes.
29229 Specifying @samp{native} as cpu type detects and selects the
29230 architecture option that corresponds to the host processor of the
29231 system performing the compilation.
29232 @option{-mcpu=native} has no effect if GCC does not recognize the
29235 The other options specify a specific processor. Code generated under
29236 those options runs best on that processor, and may not run at all on
29239 The @option{-mcpu} options automatically enable or disable the
29242 @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple @gol
29243 -mpopcntb -mpopcntd -mpowerpc64 @gol
29244 -mpowerpc-gpopt -mpowerpc-gfxopt @gol
29245 -mmulhw -mdlmzb -mmfpgpr -mvsx @gol
29246 -mcrypto -mhtm -mpower8-fusion -mpower8-vector @gol
29247 -mquad-memory -mquad-memory-atomic -mfloat128 @gol
29248 -mfloat128-hardware -mprefixed -mpcrel -mmma @gol
29251 The particular options set for any particular CPU varies between
29252 compiler versions, depending on what setting seems to produce optimal
29253 code for that CPU; it doesn't necessarily reflect the actual hardware's
29254 capabilities. If you wish to set an individual option to a particular
29255 value, you may specify it after the @option{-mcpu} option, like
29256 @option{-mcpu=970 -mno-altivec}.
29258 On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29259 not enabled or disabled by the @option{-mcpu} option at present because
29260 AIX does not have full support for these options. You may still
29261 enable or disable them individually if you're sure it'll work in your
29264 @item -mtune=@var{cpu_type}
29266 Set the instruction scheduling parameters for machine type
29267 @var{cpu_type}, but do not set the architecture type or register usage,
29268 as @option{-mcpu=@var{cpu_type}} does. The same
29269 values for @var{cpu_type} are used for @option{-mtune} as for
29270 @option{-mcpu}. If both are specified, the code generated uses the
29271 architecture and registers set by @option{-mcpu}, but the
29272 scheduling parameters set by @option{-mtune}.
29274 @item -mcmodel=small
29275 @opindex mcmodel=small
29276 Generate PowerPC64 code for the small model: The TOC is limited to
29279 @item -mcmodel=medium
29280 @opindex mcmodel=medium
29281 Generate PowerPC64 code for the medium model: The TOC and other static
29282 data may be up to a total of 4G in size. This is the default for 64-bit
29285 @item -mcmodel=large
29286 @opindex mcmodel=large
29287 Generate PowerPC64 code for the large model: The TOC may be up to 4G
29288 in size. Other data and code is only limited by the 64-bit address
29292 @itemx -mno-altivec
29294 @opindex mno-altivec
29295 Generate code that uses (does not use) AltiVec instructions, and also
29296 enable the use of built-in functions that allow more direct access to
29297 the AltiVec instruction set. You may also need to set
29298 @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
29301 When @option{-maltivec} is used, the element order for AltiVec intrinsics
29302 such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
29303 match array element order corresponding to the endianness of the
29304 target. That is, element zero identifies the leftmost element in a
29305 vector register when targeting a big-endian platform, and identifies
29306 the rightmost element in a vector register when targeting a
29307 little-endian platform.
29312 @opindex mno-vrsave
29313 Generate VRSAVE instructions when generating AltiVec code.
29316 @opindex msecure-plt
29317 Generate code that allows @command{ld} and @command{ld.so}
29318 to build executables and shared
29319 libraries with non-executable @code{.plt} and @code{.got} sections.
29321 32-bit SYSV ABI option.
29325 Generate code that uses a BSS @code{.plt} section that @command{ld.so}
29327 requires @code{.plt} and @code{.got}
29328 sections that are both writable and executable.
29329 This is a PowerPC 32-bit SYSV ABI option.
29335 This switch enables or disables the generation of ISEL instructions.
29341 Generate code that uses (does not use) vector/scalar (VSX)
29342 instructions, and also enable the use of built-in functions that allow
29343 more direct access to the VSX instruction set.
29348 @opindex mno-crypto
29349 Enable the use (disable) of the built-in functions that allow direct
29350 access to the cryptographic instructions that were added in version
29351 2.07 of the PowerPC ISA.
29357 Enable (disable) the use of the built-in functions that allow direct
29358 access to the Hardware Transactional Memory (HTM) instructions that
29359 were added in version 2.07 of the PowerPC ISA.
29361 @item -mpower8-fusion
29362 @itemx -mno-power8-fusion
29363 @opindex mpower8-fusion
29364 @opindex mno-power8-fusion
29365 Generate code that keeps (does not keeps) some integer operations
29366 adjacent so that the instructions can be fused together on power8 and
29369 @item -mpower8-vector
29370 @itemx -mno-power8-vector
29371 @opindex mpower8-vector
29372 @opindex mno-power8-vector
29373 Generate code that uses (does not use) the vector and scalar
29374 instructions that were added in version 2.07 of the PowerPC ISA. Also
29375 enable the use of built-in functions that allow more direct access to
29376 the vector instructions.
29378 @item -mquad-memory
29379 @itemx -mno-quad-memory
29380 @opindex mquad-memory
29381 @opindex mno-quad-memory
29382 Generate code that uses (does not use) the non-atomic quad word memory
29383 instructions. The @option{-mquad-memory} option requires use of
29386 @item -mquad-memory-atomic
29387 @itemx -mno-quad-memory-atomic
29388 @opindex mquad-memory-atomic
29389 @opindex mno-quad-memory-atomic
29390 Generate code that uses (does not use) the atomic quad word memory
29391 instructions. The @option{-mquad-memory-atomic} option requires use of
29395 @itemx -mno-float128
29397 @opindex mno-float128
29398 Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
29399 and use either software emulation for IEEE 128-bit floating point or
29400 hardware instructions.
29402 The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
29403 128-bit floating point support. The IEEE 128-bit floating point is only
29404 supported on Linux.
29406 The default for @option{-mfloat128} is enabled on PowerPC Linux
29407 systems using the VSX instruction set, and disabled on other systems.
29409 If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
29410 @option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
29411 point support will also enable the generation of ISA 3.0 IEEE 128-bit
29412 floating point instructions. Otherwise, if you do not specify to
29413 generate ISA 3.0 instructions or you are targeting a 32-bit big endian
29414 system, IEEE 128-bit floating point will be done with software
29417 @item -mfloat128-hardware
29418 @itemx -mno-float128-hardware
29419 @opindex mfloat128-hardware
29420 @opindex mno-float128-hardware
29421 Enable/disable using ISA 3.0 hardware instructions to support the
29422 @var{__float128} data type.
29424 The default for @option{-mfloat128-hardware} is enabled on PowerPC
29425 Linux systems using the ISA 3.0 instruction set, and disabled on other
29432 Generate code for 32-bit or 64-bit environments of Darwin and SVR4
29433 targets (including GNU/Linux). The 32-bit environment sets int, long
29434 and pointer to 32 bits and generates code that runs on any PowerPC
29435 variant. The 64-bit environment sets int to 32 bits and long and
29436 pointer to 64 bits, and generates code for PowerPC64, as for
29437 @option{-mpowerpc64}.
29440 @itemx -mno-fp-in-toc
29441 @itemx -mno-sum-in-toc
29442 @itemx -mminimal-toc
29444 @opindex mno-fp-in-toc
29445 @opindex mno-sum-in-toc
29446 @opindex mminimal-toc
29447 Modify generation of the TOC (Table Of Contents), which is created for
29448 every executable file. The @option{-mfull-toc} option is selected by
29449 default. In that case, GCC allocates at least one TOC entry for
29450 each unique non-automatic variable reference in your program. GCC
29451 also places floating-point constants in the TOC@. However, only
29452 16,384 entries are available in the TOC@.
29454 If you receive a linker error message that saying you have overflowed
29455 the available TOC space, you can reduce the amount of TOC space used
29456 with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
29457 @option{-mno-fp-in-toc} prevents GCC from putting floating-point
29458 constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
29459 generate code to calculate the sum of an address and a constant at
29460 run time instead of putting that sum into the TOC@. You may specify one
29461 or both of these options. Each causes GCC to produce very slightly
29462 slower and larger code at the expense of conserving TOC space.
29464 If you still run out of space in the TOC even when you specify both of
29465 these options, specify @option{-mminimal-toc} instead. This option causes
29466 GCC to make only one TOC entry for every file. When you specify this
29467 option, GCC produces code that is slower and larger but which
29468 uses extremely little TOC space. You may wish to use this option
29469 only on files that contain less frequently-executed code.
29475 Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
29476 @code{long} type, and the infrastructure needed to support them.
29477 Specifying @option{-maix64} implies @option{-mpowerpc64},
29478 while @option{-maix32} disables the 64-bit ABI and
29479 implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
29482 @itemx -mno-xl-compat
29483 @opindex mxl-compat
29484 @opindex mno-xl-compat
29485 Produce code that conforms more closely to IBM XL compiler semantics
29486 when using AIX-compatible ABI@. Pass floating-point arguments to
29487 prototyped functions beyond the register save area (RSA) on the stack
29488 in addition to argument FPRs. Do not assume that most significant
29489 double in 128-bit long double value is properly rounded when comparing
29490 values and converting to double. Use XL symbol names for long double
29493 The AIX calling convention was extended but not initially documented to
29494 handle an obscure K&R C case of calling a function that takes the
29495 address of its arguments with fewer arguments than declared. IBM XL
29496 compilers access floating-point arguments that do not fit in the
29497 RSA from the stack when a subroutine is compiled without
29498 optimization. Because always storing floating-point arguments on the
29499 stack is inefficient and rarely needed, this option is not enabled by
29500 default and only is necessary when calling subroutines compiled by IBM
29501 XL compilers without optimization.
29505 Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
29506 application written to use message passing with special startup code to
29507 enable the application to run. The system must have PE installed in the
29508 standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
29509 must be overridden with the @option{-specs=} option to specify the
29510 appropriate directory location. The Parallel Environment does not
29511 support threads, so the @option{-mpe} option and the @option{-pthread}
29512 option are incompatible.
29514 @item -malign-natural
29515 @itemx -malign-power
29516 @opindex malign-natural
29517 @opindex malign-power
29518 On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
29519 @option{-malign-natural} overrides the ABI-defined alignment of larger
29520 types, such as floating-point doubles, on their natural size-based boundary.
29521 The option @option{-malign-power} instructs GCC to follow the ABI-specified
29522 alignment rules. GCC defaults to the standard alignment defined in the ABI@.
29524 On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
29528 @itemx -mhard-float
29529 @opindex msoft-float
29530 @opindex mhard-float
29531 Generate code that does not use (uses) the floating-point register set.
29532 Software floating-point emulation is provided if you use the
29533 @option{-msoft-float} option, and pass the option to GCC when linking.
29536 @itemx -mno-multiple
29538 @opindex mno-multiple
29539 Generate code that uses (does not use) the load multiple word
29540 instructions and the store multiple word instructions. These
29541 instructions are generated by default on POWER systems, and not
29542 generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
29543 PowerPC systems, since those instructions do not work when the
29544 processor is in little-endian mode. The exceptions are PPC740 and
29545 PPC750 which permit these instructions in little-endian mode.
29550 @opindex mno-update
29551 Generate code that uses (does not use) the load or store instructions
29552 that update the base register to the address of the calculated memory
29553 location. These instructions are generated by default. If you use
29554 @option{-mno-update}, there is a small window between the time that the
29555 stack pointer is updated and the address of the previous frame is
29556 stored, which means code that walks the stack frame across interrupts or
29557 signals may get corrupted data.
29559 @item -mavoid-indexed-addresses
29560 @itemx -mno-avoid-indexed-addresses
29561 @opindex mavoid-indexed-addresses
29562 @opindex mno-avoid-indexed-addresses
29563 Generate code that tries to avoid (not avoid) the use of indexed load
29564 or store instructions. These instructions can incur a performance
29565 penalty on Power6 processors in certain situations, such as when
29566 stepping through large arrays that cross a 16M boundary. This option
29567 is enabled by default when targeting Power6 and disabled otherwise.
29570 @itemx -mno-fused-madd
29571 @opindex mfused-madd
29572 @opindex mno-fused-madd
29573 Generate code that uses (does not use) the floating-point multiply and
29574 accumulate instructions. These instructions are generated by default
29575 if hardware floating point is used. The machine-dependent
29576 @option{-mfused-madd} option is now mapped to the machine-independent
29577 @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
29578 mapped to @option{-ffp-contract=off}.
29584 Generate code that uses (does not use) the half-word multiply and
29585 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
29586 These instructions are generated by default when targeting those
29593 Generate code that uses (does not use) the string-search @samp{dlmzb}
29594 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
29595 generated by default when targeting those processors.
29597 @item -mno-bit-align
29599 @opindex mno-bit-align
29600 @opindex mbit-align
29601 On System V.4 and embedded PowerPC systems do not (do) force structures
29602 and unions that contain bit-fields to be aligned to the base type of the
29605 For example, by default a structure containing nothing but 8
29606 @code{unsigned} bit-fields of length 1 is aligned to a 4-byte
29607 boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
29608 the structure is aligned to a 1-byte boundary and is 1 byte in
29611 @item -mno-strict-align
29612 @itemx -mstrict-align
29613 @opindex mno-strict-align
29614 @opindex mstrict-align
29615 On System V.4 and embedded PowerPC systems do not (do) assume that
29616 unaligned memory references are handled by the system.
29618 @item -mrelocatable
29619 @itemx -mno-relocatable
29620 @opindex mrelocatable
29621 @opindex mno-relocatable
29622 Generate code that allows (does not allow) a static executable to be
29623 relocated to a different address at run time. A simple embedded
29624 PowerPC system loader should relocate the entire contents of
29625 @code{.got2} and 4-byte locations listed in the @code{.fixup} section,
29626 a table of 32-bit addresses generated by this option. For this to
29627 work, all objects linked together must be compiled with
29628 @option{-mrelocatable} or @option{-mrelocatable-lib}.
29629 @option{-mrelocatable} code aligns the stack to an 8-byte boundary.
29631 @item -mrelocatable-lib
29632 @itemx -mno-relocatable-lib
29633 @opindex mrelocatable-lib
29634 @opindex mno-relocatable-lib
29635 Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
29636 @code{.fixup} section to allow static executables to be relocated at
29637 run time, but @option{-mrelocatable-lib} does not use the smaller stack
29638 alignment of @option{-mrelocatable}. Objects compiled with
29639 @option{-mrelocatable-lib} may be linked with objects compiled with
29640 any combination of the @option{-mrelocatable} options.
29646 On System V.4 and embedded PowerPC systems do not (do) assume that
29647 register 2 contains a pointer to a global area pointing to the addresses
29648 used in the program.
29651 @itemx -mlittle-endian
29653 @opindex mlittle-endian
29654 On System V.4 and embedded PowerPC systems compile code for the
29655 processor in little-endian mode. The @option{-mlittle-endian} option is
29656 the same as @option{-mlittle}.
29659 @itemx -mbig-endian
29661 @opindex mbig-endian
29662 On System V.4 and embedded PowerPC systems compile code for the
29663 processor in big-endian mode. The @option{-mbig-endian} option is
29664 the same as @option{-mbig}.
29666 @item -mdynamic-no-pic
29667 @opindex mdynamic-no-pic
29668 On Darwin and Mac OS X systems, compile code so that it is not
29669 relocatable, but that its external references are relocatable. The
29670 resulting code is suitable for applications, but not shared
29673 @item -msingle-pic-base
29674 @opindex msingle-pic-base
29675 Treat the register used for PIC addressing as read-only, rather than
29676 loading it in the prologue for each function. The runtime system is
29677 responsible for initializing this register with an appropriate value
29678 before execution begins.
29680 @item -mprioritize-restricted-insns=@var{priority}
29681 @opindex mprioritize-restricted-insns
29682 This option controls the priority that is assigned to
29683 dispatch-slot restricted instructions during the second scheduling
29684 pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
29685 or @samp{2} to assign no, highest, or second-highest (respectively)
29686 priority to dispatch-slot restricted
29689 @item -msched-costly-dep=@var{dependence_type}
29690 @opindex msched-costly-dep
29691 This option controls which dependences are considered costly
29692 by the target during instruction scheduling. The argument
29693 @var{dependence_type} takes one of the following values:
29697 No dependence is costly.
29700 All dependences are costly.
29702 @item @samp{true_store_to_load}
29703 A true dependence from store to load is costly.
29705 @item @samp{store_to_load}
29706 Any dependence from store to load is costly.
29709 Any dependence for which the latency is greater than or equal to
29710 @var{number} is costly.
29713 @item -minsert-sched-nops=@var{scheme}
29714 @opindex minsert-sched-nops
29715 This option controls which NOP insertion scheme is used during
29716 the second scheduling pass. The argument @var{scheme} takes one of the
29724 Pad with NOPs any dispatch group that has vacant issue slots,
29725 according to the scheduler's grouping.
29727 @item @samp{regroup_exact}
29728 Insert NOPs to force costly dependent insns into
29729 separate groups. Insert exactly as many NOPs as needed to force an insn
29730 to a new group, according to the estimated processor grouping.
29733 Insert NOPs to force costly dependent insns into
29734 separate groups. Insert @var{number} NOPs to force an insn to a new group.
29738 @opindex mcall-sysv
29739 On System V.4 and embedded PowerPC systems compile code using calling
29740 conventions that adhere to the March 1995 draft of the System V
29741 Application Binary Interface, PowerPC processor supplement. This is the
29742 default unless you configured GCC using @samp{powerpc-*-eabiaix}.
29744 @item -mcall-sysv-eabi
29746 @opindex mcall-sysv-eabi
29747 @opindex mcall-eabi
29748 Specify both @option{-mcall-sysv} and @option{-meabi} options.
29750 @item -mcall-sysv-noeabi
29751 @opindex mcall-sysv-noeabi
29752 Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
29754 @item -mcall-aixdesc
29755 @opindex mcall-aixdesc
29756 On System V.4 and embedded PowerPC systems compile code for the AIX
29760 @opindex mcall-linux
29761 On System V.4 and embedded PowerPC systems compile code for the
29762 Linux-based GNU system.
29764 @item -mcall-freebsd
29765 @opindex mcall-freebsd
29766 On System V.4 and embedded PowerPC systems compile code for the
29767 FreeBSD operating system.
29769 @item -mcall-netbsd
29770 @opindex mcall-netbsd
29771 On System V.4 and embedded PowerPC systems compile code for the
29772 NetBSD operating system.
29774 @item -mcall-openbsd
29775 @opindex mcall-openbsd
29776 On System V.4 and embedded PowerPC systems compile code for the
29777 OpenBSD operating system.
29779 @item -mtraceback=@var{traceback_type}
29780 @opindex mtraceback
29781 Select the type of traceback table. Valid values for @var{traceback_type}
29782 are @samp{full}, @samp{part}, and @samp{no}.
29784 @item -maix-struct-return
29785 @opindex maix-struct-return
29786 Return all structures in memory (as specified by the AIX ABI)@.
29788 @item -msvr4-struct-return
29789 @opindex msvr4-struct-return
29790 Return structures smaller than 8 bytes in registers (as specified by the
29793 @item -mabi=@var{abi-type}
29795 Extend the current ABI with a particular extension, or remove such extension.
29796 Valid values are: @samp{altivec}, @samp{no-altivec},
29797 @samp{ibmlongdouble}, @samp{ieeelongdouble},
29798 @samp{elfv1}, @samp{elfv2},
29799 and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
29801 @item -mabi=ibmlongdouble
29802 @opindex mabi=ibmlongdouble
29803 Change the current ABI to use IBM extended-precision long double.
29804 This is not likely to work if your system defaults to using IEEE
29805 extended-precision long double. If you change the long double type
29806 from IEEE extended-precision, the compiler will issue a warning unless
29807 you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29810 @item -mabi=ieeelongdouble
29811 @opindex mabi=ieeelongdouble
29812 Change the current ABI to use IEEE extended-precision long double.
29813 This is not likely to work if your system defaults to using IBM
29814 extended-precision long double. If you change the long double type
29815 from IBM extended-precision, the compiler will issue a warning unless
29816 you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29820 @opindex mabi=elfv1
29821 Change the current ABI to use the ELFv1 ABI.
29822 This is the default ABI for big-endian PowerPC 64-bit Linux.
29823 Overriding the default ABI requires special system support and is
29824 likely to fail in spectacular ways.
29827 @opindex mabi=elfv2
29828 Change the current ABI to use the ELFv2 ABI.
29829 This is the default ABI for little-endian PowerPC 64-bit Linux.
29830 Overriding the default ABI requires special system support and is
29831 likely to fail in spectacular ways.
29833 @item -mgnu-attribute
29834 @itemx -mno-gnu-attribute
29835 @opindex mgnu-attribute
29836 @opindex mno-gnu-attribute
29837 Emit .gnu_attribute assembly directives to set tag/value pairs in a
29838 .gnu.attributes section that specify ABI variations in function
29839 parameters or return values.
29842 @itemx -mno-prototype
29843 @opindex mprototype
29844 @opindex mno-prototype
29845 On System V.4 and embedded PowerPC systems assume that all calls to
29846 variable argument functions are properly prototyped. Otherwise, the
29847 compiler must insert an instruction before every non-prototyped call to
29848 set or clear bit 6 of the condition code register (@code{CR}) to
29849 indicate whether floating-point values are passed in the floating-point
29850 registers in case the function takes variable arguments. With
29851 @option{-mprototype}, only calls to prototyped variable argument functions
29852 set or clear the bit.
29856 On embedded PowerPC systems, assume that the startup module is called
29857 @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
29858 @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
29863 On embedded PowerPC systems, assume that the startup module is called
29864 @file{crt0.o} and the standard C libraries are @file{libmvme.a} and
29869 On embedded PowerPC systems, assume that the startup module is called
29870 @file{crt0.o} and the standard C libraries are @file{libads.a} and
29873 @item -myellowknife
29874 @opindex myellowknife
29875 On embedded PowerPC systems, assume that the startup module is called
29876 @file{crt0.o} and the standard C libraries are @file{libyk.a} and
29881 On System V.4 and embedded PowerPC systems, specify that you are
29882 compiling for a VxWorks system.
29886 On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
29887 header to indicate that @samp{eabi} extended relocations are used.
29893 On System V.4 and embedded PowerPC systems do (do not) adhere to the
29894 Embedded Applications Binary Interface (EABI), which is a set of
29895 modifications to the System V.4 specifications. Selecting @option{-meabi}
29896 means that the stack is aligned to an 8-byte boundary, a function
29897 @code{__eabi} is called from @code{main} to set up the EABI
29898 environment, and the @option{-msdata} option can use both @code{r2} and
29899 @code{r13} to point to two separate small data areas. Selecting
29900 @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
29901 no EABI initialization function is called from @code{main}, and the
29902 @option{-msdata} option only uses @code{r13} to point to a single
29903 small data area. The @option{-meabi} option is on by default if you
29904 configured GCC using one of the @samp{powerpc*-*-eabi*} options.
29907 @opindex msdata=eabi
29908 On System V.4 and embedded PowerPC systems, put small initialized
29909 @code{const} global and static data in the @code{.sdata2} section, which
29910 is pointed to by register @code{r2}. Put small initialized
29911 non-@code{const} global and static data in the @code{.sdata} section,
29912 which is pointed to by register @code{r13}. Put small uninitialized
29913 global and static data in the @code{.sbss} section, which is adjacent to
29914 the @code{.sdata} section. The @option{-msdata=eabi} option is
29915 incompatible with the @option{-mrelocatable} option. The
29916 @option{-msdata=eabi} option also sets the @option{-memb} option.
29919 @opindex msdata=sysv
29920 On System V.4 and embedded PowerPC systems, put small global and static
29921 data in the @code{.sdata} section, which is pointed to by register
29922 @code{r13}. Put small uninitialized global and static data in the
29923 @code{.sbss} section, which is adjacent to the @code{.sdata} section.
29924 The @option{-msdata=sysv} option is incompatible with the
29925 @option{-mrelocatable} option.
29927 @item -msdata=default
29929 @opindex msdata=default
29931 On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
29932 compile code the same as @option{-msdata=eabi}, otherwise compile code the
29933 same as @option{-msdata=sysv}.
29936 @opindex msdata=data
29937 On System V.4 and embedded PowerPC systems, put small global
29938 data in the @code{.sdata} section. Put small uninitialized global
29939 data in the @code{.sbss} section. Do not use register @code{r13}
29940 to address small data however. This is the default behavior unless
29941 other @option{-msdata} options are used.
29945 @opindex msdata=none
29947 On embedded PowerPC systems, put all initialized global and static data
29948 in the @code{.data} section, and all uninitialized data in the
29949 @code{.bss} section.
29951 @item -mreadonly-in-sdata
29952 @opindex mreadonly-in-sdata
29953 @opindex mno-readonly-in-sdata
29954 Put read-only objects in the @code{.sdata} section as well. This is the
29957 @item -mblock-move-inline-limit=@var{num}
29958 @opindex mblock-move-inline-limit
29959 Inline all block moves (such as calls to @code{memcpy} or structure
29960 copies) less than or equal to @var{num} bytes. The minimum value for
29961 @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
29962 targets. The default value is target-specific.
29964 @item -mblock-compare-inline-limit=@var{num}
29965 @opindex mblock-compare-inline-limit
29966 Generate non-looping inline code for all block compares (such as calls
29967 to @code{memcmp} or structure compares) less than or equal to @var{num}
29968 bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
29969 block compare is disabled. The default value is target-specific.
29971 @item -mblock-compare-inline-loop-limit=@var{num}
29972 @opindex mblock-compare-inline-loop-limit
29973 Generate an inline expansion using loop code for all block compares that
29974 are less than or equal to @var{num} bytes, but greater than the limit
29975 for non-loop inline block compare expansion. If the block length is not
29976 constant, at most @var{num} bytes will be compared before @code{memcmp}
29977 is called to compare the remainder of the block. The default value is
29980 @item -mstring-compare-inline-limit=@var{num}
29981 @opindex mstring-compare-inline-limit
29982 Compare at most @var{num} string bytes with inline code.
29983 If the difference or end of string is not found at the
29984 end of the inline compare a call to @code{strcmp} or @code{strncmp} will
29985 take care of the rest of the comparison. The default is 64 bytes.
29989 @cindex smaller data references (PowerPC)
29990 @cindex .sdata/.sdata2 references (PowerPC)
29991 On embedded PowerPC systems, put global and static items less than or
29992 equal to @var{num} bytes into the small data or BSS sections instead of
29993 the normal data or BSS section. By default, @var{num} is 8. The
29994 @option{-G @var{num}} switch is also passed to the linker.
29995 All modules should be compiled with the same @option{-G @var{num}} value.
29998 @itemx -mno-regnames
30000 @opindex mno-regnames
30001 On System V.4 and embedded PowerPC systems do (do not) emit register
30002 names in the assembly language output using symbolic forms.
30005 @itemx -mno-longcall
30007 @opindex mno-longcall
30008 By default assume that all calls are far away so that a longer and more
30009 expensive calling sequence is required. This is required for calls
30010 farther than 32 megabytes (33,554,432 bytes) from the current location.
30011 A short call is generated if the compiler knows
30012 the call cannot be that far away. This setting can be overridden by
30013 the @code{shortcall} function attribute, or by @code{#pragma
30016 Some linkers are capable of detecting out-of-range calls and generating
30017 glue code on the fly. On these systems, long calls are unnecessary and
30018 generate slower code. As of this writing, the AIX linker can do this,
30019 as can the GNU linker for PowerPC/64. It is planned to add this feature
30020 to the GNU linker for 32-bit PowerPC systems as well.
30022 On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
30023 GCC can generate long calls using an inline PLT call sequence (see
30024 @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
30025 ELFv1 (big-endian) do not support inline PLT calls.
30027 On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
30028 callee, L42}, plus a @dfn{branch island} (glue code). The two target
30029 addresses represent the callee and the branch island. The
30030 Darwin/PPC linker prefers the first address and generates a @code{bl
30031 callee} if the PPC @code{bl} instruction reaches the callee directly;
30032 otherwise, the linker generates @code{bl L42} to call the branch
30033 island. The branch island is appended to the body of the
30034 calling function; it computes the full 32-bit address of the callee
30037 On Mach-O (Darwin) systems, this option directs the compiler emit to
30038 the glue for every direct call, and the Darwin linker decides whether
30039 to use or discard it.
30041 In the future, GCC may ignore all longcall specifications
30042 when the linker is known to generate glue.
30047 @opindex mno-pltseq
30048 Implement (do not implement) -fno-plt and long calls using an inline
30049 PLT call sequence that supports lazy linking and long calls to
30050 functions in dlopen'd shared libraries. Inline PLT calls are only
30051 supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
30052 linkers, and are enabled by default if the support is detected when
30053 configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
30054 configured with @option{--enable-secureplt}. @option{-mpltseq} code
30055 and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
30058 @item -mtls-markers
30059 @itemx -mno-tls-markers
30060 @opindex mtls-markers
30061 @opindex mno-tls-markers
30062 Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
30063 specifying the function argument. The relocation allows the linker to
30064 reliably associate function call with argument setup instructions for
30065 TLS optimization, which in turn allows GCC to better schedule the
30071 This option enables use of the reciprocal estimate and
30072 reciprocal square root estimate instructions with additional
30073 Newton-Raphson steps to increase precision instead of doing a divide or
30074 square root and divide for floating-point arguments. You should use
30075 the @option{-ffast-math} option when using @option{-mrecip} (or at
30076 least @option{-funsafe-math-optimizations},
30077 @option{-ffinite-math-only}, @option{-freciprocal-math} and
30078 @option{-fno-trapping-math}). Note that while the throughput of the
30079 sequence is generally higher than the throughput of the non-reciprocal
30080 instruction, the precision of the sequence can be decreased by up to 2
30081 ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
30084 @item -mrecip=@var{opt}
30085 @opindex mrecip=opt
30086 This option controls which reciprocal estimate instructions
30087 may be used. @var{opt} is a comma-separated list of options, which may
30088 be preceded by a @code{!} to invert the option:
30093 Enable all estimate instructions.
30096 Enable the default instructions, equivalent to @option{-mrecip}.
30099 Disable all estimate instructions, equivalent to @option{-mno-recip}.
30102 Enable the reciprocal approximation instructions for both
30103 single and double precision.
30106 Enable the single-precision reciprocal approximation instructions.
30109 Enable the double-precision reciprocal approximation instructions.
30112 Enable the reciprocal square root approximation instructions for both
30113 single and double precision.
30116 Enable the single-precision reciprocal square root approximation instructions.
30119 Enable the double-precision reciprocal square root approximation instructions.
30123 So, for example, @option{-mrecip=all,!rsqrtd} enables
30124 all of the reciprocal estimate instructions, except for the
30125 @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30126 which handle the double-precision reciprocal square root calculations.
30128 @item -mrecip-precision
30129 @itemx -mno-recip-precision
30130 @opindex mrecip-precision
30131 Assume (do not assume) that the reciprocal estimate instructions
30132 provide higher-precision estimates than is mandated by the PowerPC
30133 ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30134 @option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30135 The double-precision square root estimate instructions are not generated by
30136 default on low-precision machines, since they do not provide an
30137 estimate that converges after three steps.
30139 @item -mveclibabi=@var{type}
30140 @opindex mveclibabi
30141 Specifies the ABI type to use for vectorizing intrinsics using an
30142 external library. The only type supported at present is @samp{mass},
30143 which specifies to use IBM's Mathematical Acceleration Subsystem
30144 (MASS) libraries for vectorizing intrinsics using external libraries.
30145 GCC currently emits calls to @code{acosd2}, @code{acosf4},
30146 @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30147 @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30148 @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30149 @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30150 @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30151 @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30152 @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30153 @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30154 @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30155 @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30156 @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30157 @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30158 @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30159 for power7. Both @option{-ftree-vectorize} and
30160 @option{-funsafe-math-optimizations} must also be enabled. The MASS
30161 libraries must be specified at link time.
30166 Generate (do not generate) the @code{friz} instruction when the
30167 @option{-funsafe-math-optimizations} option is used to optimize
30168 rounding of floating-point values to 64-bit integer and back to floating
30169 point. The @code{friz} instruction does not return the same value if
30170 the floating-point number is too large to fit in an integer.
30172 @item -mpointers-to-nested-functions
30173 @itemx -mno-pointers-to-nested-functions
30174 @opindex mpointers-to-nested-functions
30175 Generate (do not generate) code to load up the static chain register
30176 (@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30177 systems where a function pointer points to a 3-word descriptor giving
30178 the function address, TOC value to be loaded in register @code{r2}, and
30179 static chain value to be loaded in register @code{r11}. The
30180 @option{-mpointers-to-nested-functions} is on by default. You cannot
30181 call through pointers to nested functions or pointers
30182 to functions compiled in other languages that use the static chain if
30183 you use @option{-mno-pointers-to-nested-functions}.
30185 @item -msave-toc-indirect
30186 @itemx -mno-save-toc-indirect
30187 @opindex msave-toc-indirect
30188 Generate (do not generate) code to save the TOC value in the reserved
30189 stack location in the function prologue if the function calls through
30190 a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30191 saved in the prologue, it is saved just before the call through the
30192 pointer. The @option{-mno-save-toc-indirect} option is the default.
30194 @item -mcompat-align-parm
30195 @itemx -mno-compat-align-parm
30196 @opindex mcompat-align-parm
30197 Generate (do not generate) code to pass structure parameters with a
30198 maximum alignment of 64 bits, for compatibility with older versions
30201 Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30202 structure parameter on a 128-bit boundary when that structure contained
30203 a member requiring 128-bit alignment. This is corrected in more
30204 recent versions of GCC. This option may be used to generate code
30205 that is compatible with functions compiled with older versions of
30208 The @option{-mno-compat-align-parm} option is the default.
30210 @item -mstack-protector-guard=@var{guard}
30211 @itemx -mstack-protector-guard-reg=@var{reg}
30212 @itemx -mstack-protector-guard-offset=@var{offset}
30213 @itemx -mstack-protector-guard-symbol=@var{symbol}
30214 @opindex mstack-protector-guard
30215 @opindex mstack-protector-guard-reg
30216 @opindex mstack-protector-guard-offset
30217 @opindex mstack-protector-guard-symbol
30218 Generate stack protection code using canary at @var{guard}. Supported
30219 locations are @samp{global} for global canary or @samp{tls} for per-thread
30220 canary in the TLS block (the default with GNU libc version 2.4 or later).
30222 With the latter choice the options
30223 @option{-mstack-protector-guard-reg=@var{reg}} and
30224 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30225 which register to use as base register for reading the canary, and from what
30226 offset from that base register. The default for those is as specified in the
30227 relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30228 the offset with a symbol reference to a canary in the TLS block.
30234 Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30235 option requires that the medium code model (@option{-mcmodel=medium})
30236 and prefixed addressing (@option{-mprefixed}) options are enabled.
30239 @itemx -mno-prefixed
30241 @opindex mno-prefixed
30242 Generate (do not generate) addressing modes using prefixed load and
30243 store instructions. The @option{-mprefixed} option requires that
30244 the option @option{-mcpu=power10} (or later) is enabled.
30250 Generate (do not generate) the MMA instructions. The @option{-mma}
30251 option requires that the option @option{-mcpu=power10} (or later)
30254 @item -mrop-protect
30255 @itemx -mno-rop-protect
30256 @opindex mrop-protect
30257 @opindex mno-rop-protect
30258 Generate (do not generate) ROP protection instructions when the target
30259 processor supports them. Currently this option disables the shrink-wrap
30260 optimization (@option{-fshrink-wrap}).
30263 @itemx -mno-privileged
30264 @opindex mprivileged
30265 @opindex mno-privileged
30266 Generate (do not generate) code that will run in privileged state.
30268 @item -mblock-ops-unaligned-vsx
30269 @itemx -mno-block-ops-unaligned-vsx
30270 @opindex block-ops-unaligned-vsx
30271 @opindex no-block-ops-unaligned-vsx
30272 Generate (do not generate) unaligned vsx loads and stores for
30273 inline expansion of @code{memcpy} and @code{memmove}.
30275 @item --param rs6000-vect-unroll-limit=
30276 The vectorizer will check with target information to determine whether it
30277 would be beneficial to unroll the main vectorized loop and by how much. This
30278 parameter sets the upper bound of how much the vectorizer will unroll the main
30279 loop. The default value is four.
30284 @subsection RX Options
30287 These command-line options are defined for RX targets:
30290 @item -m64bit-doubles
30291 @itemx -m32bit-doubles
30292 @opindex m64bit-doubles
30293 @opindex m32bit-doubles
30294 Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30295 or 32 bits (@option{-m32bit-doubles}) in size. The default is
30296 @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30297 works on 32-bit values, which is why the default is
30298 @option{-m32bit-doubles}.
30304 Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
30305 floating-point hardware. The default is enabled for the RX600
30306 series and disabled for the RX200 series.
30308 Floating-point instructions are only generated for 32-bit floating-point
30309 values, however, so the FPU hardware is not used for doubles if the
30310 @option{-m64bit-doubles} option is used.
30312 @emph{Note} If the @option{-fpu} option is enabled then
30313 @option{-funsafe-math-optimizations} is also enabled automatically.
30314 This is because the RX FPU instructions are themselves unsafe.
30316 @item -mcpu=@var{name}
30318 Selects the type of RX CPU to be targeted. Currently three types are
30319 supported, the generic @samp{RX600} and @samp{RX200} series hardware and
30320 the specific @samp{RX610} CPU. The default is @samp{RX600}.
30322 The only difference between @samp{RX600} and @samp{RX610} is that the
30323 @samp{RX610} does not support the @code{MVTIPL} instruction.
30325 The @samp{RX200} series does not have a hardware floating-point unit
30326 and so @option{-nofpu} is enabled by default when this type is
30329 @item -mbig-endian-data
30330 @itemx -mlittle-endian-data
30331 @opindex mbig-endian-data
30332 @opindex mlittle-endian-data
30333 Store data (but not code) in the big-endian format. The default is
30334 @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
30337 @item -msmall-data-limit=@var{N}
30338 @opindex msmall-data-limit
30339 Specifies the maximum size in bytes of global and static variables
30340 which can be placed into the small data area. Using the small data
30341 area can lead to smaller and faster code, but the size of area is
30342 limited and it is up to the programmer to ensure that the area does
30343 not overflow. Also when the small data area is used one of the RX's
30344 registers (usually @code{r13}) is reserved for use pointing to this
30345 area, so it is no longer available for use by the compiler. This
30346 could result in slower and/or larger code if variables are pushed onto
30347 the stack instead of being held in this register.
30349 Note, common variables (variables that have not been initialized) and
30350 constants are not placed into the small data area as they are assigned
30351 to other sections in the output executable.
30353 The default value is zero, which disables this feature. Note, this
30354 feature is not enabled by default with higher optimization levels
30355 (@option{-O2} etc) because of the potentially detrimental effects of
30356 reserving a register. It is up to the programmer to experiment and
30357 discover whether this feature is of benefit to their program. See the
30358 description of the @option{-mpid} option for a description of how the
30359 actual register to hold the small data area pointer is chosen.
30365 Use the simulator runtime. The default is to use the libgloss
30366 board-specific runtime.
30368 @item -mas100-syntax
30369 @itemx -mno-as100-syntax
30370 @opindex mas100-syntax
30371 @opindex mno-as100-syntax
30372 When generating assembler output use a syntax that is compatible with
30373 Renesas's AS100 assembler. This syntax can also be handled by the GAS
30374 assembler, but it has some restrictions so it is not generated by default.
30376 @item -mmax-constant-size=@var{N}
30377 @opindex mmax-constant-size
30378 Specifies the maximum size, in bytes, of a constant that can be used as
30379 an operand in a RX instruction. Although the RX instruction set does
30380 allow constants of up to 4 bytes in length to be used in instructions,
30381 a longer value equates to a longer instruction. Thus in some
30382 circumstances it can be beneficial to restrict the size of constants
30383 that are used in instructions. Constants that are too big are instead
30384 placed into a constant pool and referenced via register indirection.
30386 The value @var{N} can be between 0 and 4. A value of 0 (the default)
30387 or 4 means that constants of any size are allowed.
30391 Enable linker relaxation. Linker relaxation is a process whereby the
30392 linker attempts to reduce the size of a program by finding shorter
30393 versions of various instructions. Disabled by default.
30395 @item -mint-register=@var{N}
30396 @opindex mint-register
30397 Specify the number of registers to reserve for fast interrupt handler
30398 functions. The value @var{N} can be between 0 and 4. A value of 1
30399 means that register @code{r13} is reserved for the exclusive use
30400 of fast interrupt handlers. A value of 2 reserves @code{r13} and
30401 @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
30402 @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
30403 A value of 0, the default, does not reserve any registers.
30405 @item -msave-acc-in-interrupts
30406 @opindex msave-acc-in-interrupts
30407 Specifies that interrupt handler functions should preserve the
30408 accumulator register. This is only necessary if normal code might use
30409 the accumulator register, for example because it performs 64-bit
30410 multiplications. The default is to ignore the accumulator as this
30411 makes the interrupt handlers faster.
30417 Enables the generation of position independent data. When enabled any
30418 access to constant data is done via an offset from a base address
30419 held in a register. This allows the location of constant data to be
30420 determined at run time without requiring the executable to be
30421 relocated, which is a benefit to embedded applications with tight
30422 memory constraints. Data that can be modified is not affected by this
30425 Note, using this feature reserves a register, usually @code{r13}, for
30426 the constant data base address. This can result in slower and/or
30427 larger code, especially in complicated functions.
30429 The actual register chosen to hold the constant data base address
30430 depends upon whether the @option{-msmall-data-limit} and/or the
30431 @option{-mint-register} command-line options are enabled. Starting
30432 with register @code{r13} and proceeding downwards, registers are
30433 allocated first to satisfy the requirements of @option{-mint-register},
30434 then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
30435 is possible for the small data area register to be @code{r8} if both
30436 @option{-mint-register=4} and @option{-mpid} are specified on the
30439 By default this feature is not enabled. The default can be restored
30440 via the @option{-mno-pid} command-line option.
30442 @item -mno-warn-multiple-fast-interrupts
30443 @itemx -mwarn-multiple-fast-interrupts
30444 @opindex mno-warn-multiple-fast-interrupts
30445 @opindex mwarn-multiple-fast-interrupts
30446 Prevents GCC from issuing a warning message if it finds more than one
30447 fast interrupt handler when it is compiling a file. The default is to
30448 issue a warning for each extra fast interrupt handler found, as the RX
30449 only supports one such interrupt.
30451 @item -mallow-string-insns
30452 @itemx -mno-allow-string-insns
30453 @opindex mallow-string-insns
30454 @opindex mno-allow-string-insns
30455 Enables or disables the use of the string manipulation instructions
30456 @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
30457 @code{SWHILE} and also the @code{RMPA} instruction. These
30458 instructions may prefetch data, which is not safe to do if accessing
30459 an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
30460 for more information).
30462 The default is to allow these instructions, but it is not possible for
30463 GCC to reliably detect all circumstances where a string instruction
30464 might be used to access an I/O register, so their use cannot be
30465 disabled automatically. Instead it is reliant upon the programmer to
30466 use the @option{-mno-allow-string-insns} option if their program
30467 accesses I/O space.
30469 When the instructions are enabled GCC defines the C preprocessor
30470 symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
30471 symbol @code{__RX_DISALLOW_STRING_INSNS__}.
30477 Use only (or not only) @code{JSR} instructions to access functions.
30478 This option can be used when code size exceeds the range of @code{BSR}
30479 instructions. Note that @option{-mno-jsr} does not mean to not use
30480 @code{JSR} but instead means that any type of branch may be used.
30483 @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
30484 has special significance to the RX port when used with the
30485 @code{interrupt} function attribute. This attribute indicates a
30486 function intended to process fast interrupts. GCC ensures
30487 that it only uses the registers @code{r10}, @code{r11}, @code{r12}
30488 and/or @code{r13} and only provided that the normal use of the
30489 corresponding registers have been restricted via the
30490 @option{-ffixed-@var{reg}} or @option{-mint-register} command-line
30493 @node S/390 and zSeries Options
30494 @subsection S/390 and zSeries Options
30495 @cindex S/390 and zSeries Options
30497 These are the @samp{-m} options defined for the S/390 and zSeries architecture.
30501 @itemx -msoft-float
30502 @opindex mhard-float
30503 @opindex msoft-float
30504 Use (do not use) the hardware floating-point instructions and registers
30505 for floating-point operations. When @option{-msoft-float} is specified,
30506 functions in @file{libgcc.a} are used to perform floating-point
30507 operations. When @option{-mhard-float} is specified, the compiler
30508 generates IEEE floating-point instructions. This is the default.
30511 @itemx -mno-hard-dfp
30513 @opindex mno-hard-dfp
30514 Use (do not use) the hardware decimal-floating-point instructions for
30515 decimal-floating-point operations. When @option{-mno-hard-dfp} is
30516 specified, functions in @file{libgcc.a} are used to perform
30517 decimal-floating-point operations. When @option{-mhard-dfp} is
30518 specified, the compiler generates decimal-floating-point hardware
30519 instructions. This is the default for @option{-march=z9-ec} or higher.
30521 @item -mlong-double-64
30522 @itemx -mlong-double-128
30523 @opindex mlong-double-64
30524 @opindex mlong-double-128
30525 These switches control the size of @code{long double} type. A size
30526 of 64 bits makes the @code{long double} type equivalent to the @code{double}
30527 type. This is the default.
30530 @itemx -mno-backchain
30531 @opindex mbackchain
30532 @opindex mno-backchain
30533 Store (do not store) the address of the caller's frame as backchain pointer
30534 into the callee's stack frame.
30535 A backchain may be needed to allow debugging using tools that do not understand
30536 DWARF call frame information.
30537 When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
30538 at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
30539 the backchain is placed into the topmost word of the 96/160 byte register
30542 In general, code compiled with @option{-mbackchain} is call-compatible with
30543 code compiled with @option{-mno-backchain}; however, use of the backchain
30544 for debugging purposes usually requires that the whole binary is built with
30545 @option{-mbackchain}. Note that the combination of @option{-mbackchain},
30546 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30547 to build a linux kernel use @option{-msoft-float}.
30549 The default is to not maintain the backchain.
30551 @item -mpacked-stack
30552 @itemx -mno-packed-stack
30553 @opindex mpacked-stack
30554 @opindex mno-packed-stack
30555 Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
30556 specified, the compiler uses the all fields of the 96/160 byte register save
30557 area only for their default purpose; unused fields still take up stack space.
30558 When @option{-mpacked-stack} is specified, register save slots are densely
30559 packed at the top of the register save area; unused space is reused for other
30560 purposes, allowing for more efficient use of the available stack space.
30561 However, when @option{-mbackchain} is also in effect, the topmost word of
30562 the save area is always used to store the backchain, and the return address
30563 register is always saved two words below the backchain.
30565 As long as the stack frame backchain is not used, code generated with
30566 @option{-mpacked-stack} is call-compatible with code generated with
30567 @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
30568 S/390 or zSeries generated code that uses the stack frame backchain at run
30569 time, not just for debugging purposes. Such code is not call-compatible
30570 with code compiled with @option{-mpacked-stack}. Also, note that the
30571 combination of @option{-mbackchain},
30572 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30573 to build a linux kernel use @option{-msoft-float}.
30575 The default is to not use the packed stack layout.
30578 @itemx -mno-small-exec
30579 @opindex msmall-exec
30580 @opindex mno-small-exec
30581 Generate (or do not generate) code using the @code{bras} instruction
30582 to do subroutine calls.
30583 This only works reliably if the total executable size does not
30584 exceed 64k. The default is to use the @code{basr} instruction instead,
30585 which does not have this limitation.
30591 When @option{-m31} is specified, generate code compliant to the
30592 GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
30593 code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
30594 particular to generate 64-bit instructions. For the @samp{s390}
30595 targets, the default is @option{-m31}, while the @samp{s390x}
30596 targets default to @option{-m64}.
30602 When @option{-mzarch} is specified, generate code using the
30603 instructions available on z/Architecture.
30604 When @option{-mesa} is specified, generate code using the
30605 instructions available on ESA/390. Note that @option{-mesa} is
30606 not possible with @option{-m64}.
30607 When generating code compliant to the GNU/Linux for S/390 ABI,
30608 the default is @option{-mesa}. When generating code compliant
30609 to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
30615 The @option{-mhtm} option enables a set of builtins making use of
30616 instructions available with the transactional execution facility
30617 introduced with the IBM zEnterprise EC12 machine generation
30618 @ref{S/390 System z Built-in Functions}.
30619 @option{-mhtm} is enabled by default when using @option{-march=zEC12}.
30625 When @option{-mvx} is specified, generate code using the instructions
30626 available with the vector extension facility introduced with the IBM
30627 z13 machine generation.
30628 This option changes the ABI for some vector type values with regard to
30629 alignment and calling conventions. In case vector type values are
30630 being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
30631 command will be added to mark the resulting binary with the ABI used.
30632 @option{-mvx} is enabled by default when using @option{-march=z13}.
30635 @itemx -mno-zvector
30637 @opindex mno-zvector
30638 The @option{-mzvector} option enables vector language extensions and
30639 builtins using instructions available with the vector extension
30640 facility introduced with the IBM z13 machine generation.
30641 This option adds support for @samp{vector} to be used as a keyword to
30642 define vector type variables and arguments. @samp{vector} is only
30643 available when GNU extensions are enabled. It will not be expanded
30644 when requesting strict standard compliance e.g.@: with @option{-std=c99}.
30645 In addition to the GCC low-level builtins @option{-mzvector} enables
30646 a set of builtins added for compatibility with AltiVec-style
30647 implementations like Power and Cell. In order to make use of these
30648 builtins the header file @file{vecintrin.h} needs to be included.
30649 @option{-mzvector} is disabled by default.
30655 Generate (or do not generate) code using the @code{mvcle} instruction
30656 to perform block moves. When @option{-mno-mvcle} is specified,
30657 use a @code{mvc} loop instead. This is the default unless optimizing for
30664 Print (or do not print) additional debug information when compiling.
30665 The default is to not print debug information.
30667 @item -march=@var{cpu-type}
30669 Generate code that runs on @var{cpu-type}, which is the name of a
30670 system representing a certain processor type. Possible values for
30671 @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
30672 @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
30673 @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
30674 @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
30675 @samp{z16}/@samp{arch14}, and @samp{native}.
30677 The default is @option{-march=z900}.
30679 Specifying @samp{native} as cpu type can be used to select the best
30680 architecture option for the host processor.
30681 @option{-march=native} has no effect if GCC does not recognize the
30684 @item -mtune=@var{cpu-type}
30686 Tune to @var{cpu-type} everything applicable about the generated code,
30687 except for the ABI and the set of available instructions.
30688 The list of @var{cpu-type} values is the same as for @option{-march}.
30689 The default is the value used for @option{-march}.
30692 @itemx -mno-tpf-trace
30693 @opindex mtpf-trace
30694 @opindex mno-tpf-trace
30695 Generate code that adds (does not add) in TPF OS specific branches to trace
30696 routines in the operating system. This option is off by default, even
30697 when compiling for the TPF OS@.
30699 @item -mtpf-trace-skip
30700 @itemx -mno-tpf-trace-skip
30701 @opindex mtpf-trace-skip
30702 @opindex mno-tpf-trace-skip
30703 Generate code that changes (does not change) the default branch
30704 targets enabled by @option{-mtpf-trace} to point to specialized trace
30705 routines providing the ability of selectively skipping function trace
30706 entries for the TPF OS. This option is off by default, even when
30707 compiling for the TPF OS and specifying @option{-mtpf-trace}.
30710 @itemx -mno-fused-madd
30711 @opindex mfused-madd
30712 @opindex mno-fused-madd
30713 Generate code that uses (does not use) the floating-point multiply and
30714 accumulate instructions. These instructions are generated by default if
30715 hardware floating point is used.
30717 @item -mwarn-framesize=@var{framesize}
30718 @opindex mwarn-framesize
30719 Emit a warning if the current function exceeds the given frame size. Because
30720 this is a compile-time check it doesn't need to be a real problem when the program
30721 runs. It is intended to identify functions that most probably cause
30722 a stack overflow. It is useful to be used in an environment with limited stack
30723 size e.g.@: the linux kernel.
30725 @item -mwarn-dynamicstack
30726 @opindex mwarn-dynamicstack
30727 Emit a warning if the function calls @code{alloca} or uses dynamically-sized
30728 arrays. This is generally a bad idea with a limited stack size.
30730 @item -mstack-guard=@var{stack-guard}
30731 @itemx -mstack-size=@var{stack-size}
30732 @opindex mstack-guard
30733 @opindex mstack-size
30734 If these options are provided the S/390 back end emits additional instructions in
30735 the function prologue that trigger a trap if the stack size is @var{stack-guard}
30736 bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
30737 If the @var{stack-guard} option is omitted the smallest power of 2 larger than
30738 the frame size of the compiled function is chosen.
30739 These options are intended to be used to help debugging stack overflow problems.
30740 The additionally emitted code causes only little overhead and hence can also be
30741 used in production-like systems without greater performance degradation. The given
30742 values have to be exact powers of 2 and @var{stack-size} has to be greater than
30743 @var{stack-guard} without exceeding 64k.
30744 In order to be efficient the extra code makes the assumption that the stack starts
30745 at an address aligned to the value given by @var{stack-size}.
30746 The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
30748 @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
30750 If the hotpatch option is enabled, a ``hot-patching'' function
30751 prologue is generated for all functions in the compilation unit.
30752 The funtion label is prepended with the given number of two-byte
30753 NOP instructions (@var{pre-halfwords}, maximum 1000000). After
30754 the label, 2 * @var{post-halfwords} bytes are appended, using the
30755 largest NOP like instructions the architecture allows (maximum
30758 If both arguments are zero, hotpatching is disabled.
30760 This option can be overridden for individual functions with the
30761 @code{hotpatch} attribute.
30765 @subsection SH Options
30767 These @samp{-m} options are defined for the SH implementations:
30772 Generate code for the SH1.
30776 Generate code for the SH2.
30779 Generate code for the SH2e.
30783 Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
30784 that the floating-point unit is not used.
30786 @item -m2a-single-only
30787 @opindex m2a-single-only
30788 Generate code for the SH2a-FPU, in such a way that no double-precision
30789 floating-point operations are used.
30792 @opindex m2a-single
30793 Generate code for the SH2a-FPU assuming the floating-point unit is in
30794 single-precision mode by default.
30798 Generate code for the SH2a-FPU assuming the floating-point unit is in
30799 double-precision mode by default.
30803 Generate code for the SH3.
30807 Generate code for the SH3e.
30811 Generate code for the SH4 without a floating-point unit.
30813 @item -m4-single-only
30814 @opindex m4-single-only
30815 Generate code for the SH4 with a floating-point unit that only
30816 supports single-precision arithmetic.
30820 Generate code for the SH4 assuming the floating-point unit is in
30821 single-precision mode by default.
30825 Generate code for the SH4.
30829 Generate code for SH4-100.
30831 @item -m4-100-nofpu
30832 @opindex m4-100-nofpu
30833 Generate code for SH4-100 in such a way that the
30834 floating-point unit is not used.
30836 @item -m4-100-single
30837 @opindex m4-100-single
30838 Generate code for SH4-100 assuming the floating-point unit is in
30839 single-precision mode by default.
30841 @item -m4-100-single-only
30842 @opindex m4-100-single-only
30843 Generate code for SH4-100 in such a way that no double-precision
30844 floating-point operations are used.
30848 Generate code for SH4-200.
30850 @item -m4-200-nofpu
30851 @opindex m4-200-nofpu
30852 Generate code for SH4-200 without in such a way that the
30853 floating-point unit is not used.
30855 @item -m4-200-single
30856 @opindex m4-200-single
30857 Generate code for SH4-200 assuming the floating-point unit is in
30858 single-precision mode by default.
30860 @item -m4-200-single-only
30861 @opindex m4-200-single-only
30862 Generate code for SH4-200 in such a way that no double-precision
30863 floating-point operations are used.
30867 Generate code for SH4-300.
30869 @item -m4-300-nofpu
30870 @opindex m4-300-nofpu
30871 Generate code for SH4-300 without in such a way that the
30872 floating-point unit is not used.
30874 @item -m4-300-single
30875 @opindex m4-300-single
30876 Generate code for SH4-300 in such a way that no double-precision
30877 floating-point operations are used.
30879 @item -m4-300-single-only
30880 @opindex m4-300-single-only
30881 Generate code for SH4-300 in such a way that no double-precision
30882 floating-point operations are used.
30886 Generate code for SH4-340 (no MMU, no FPU).
30890 Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
30895 Generate code for the SH4al-dsp, or for a SH4a in such a way that the
30896 floating-point unit is not used.
30898 @item -m4a-single-only
30899 @opindex m4a-single-only
30900 Generate code for the SH4a, in such a way that no double-precision
30901 floating-point operations are used.
30904 @opindex m4a-single
30905 Generate code for the SH4a assuming the floating-point unit is in
30906 single-precision mode by default.
30910 Generate code for the SH4a.
30914 Same as @option{-m4a-nofpu}, except that it implicitly passes
30915 @option{-dsp} to the assembler. GCC doesn't generate any DSP
30916 instructions at the moment.
30920 Compile code for the processor in big-endian mode.
30924 Compile code for the processor in little-endian mode.
30928 Align doubles at 64-bit boundaries. Note that this changes the calling
30929 conventions, and thus some functions from the standard C library do
30930 not work unless you recompile it first with @option{-mdalign}.
30934 Shorten some address references at link time, when possible; uses the
30935 linker option @option{-relax}.
30939 Use 32-bit offsets in @code{switch} tables. The default is to use
30944 Enable the use of bit manipulation instructions on SH2A.
30948 Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
30949 alignment constraints.
30953 Comply with the calling conventions defined by Renesas.
30956 @opindex mno-renesas
30957 Comply with the calling conventions defined for GCC before the Renesas
30958 conventions were available. This option is the default for all
30959 targets of the SH toolchain.
30962 @opindex mnomacsave
30963 Mark the @code{MAC} register as call-clobbered, even if
30964 @option{-mrenesas} is given.
30970 Control the IEEE compliance of floating-point comparisons, which affects the
30971 handling of cases where the result of a comparison is unordered. By default
30972 @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
30973 enabled @option{-mno-ieee} is implicitly set, which results in faster
30974 floating-point greater-equal and less-equal comparisons. The implicit settings
30975 can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
30977 @item -minline-ic_invalidate
30978 @opindex minline-ic_invalidate
30979 Inline code to invalidate instruction cache entries after setting up
30980 nested function trampolines.
30981 This option has no effect if @option{-musermode} is in effect and the selected
30982 code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
30984 If the selected code generation option does not allow the use of the @code{icbi}
30985 instruction, and @option{-musermode} is not in effect, the inlined code
30986 manipulates the instruction cache address array directly with an associative
30987 write. This not only requires privileged mode at run time, but it also
30988 fails if the cache line had been mapped via the TLB and has become unmapped.
30992 Dump instruction size and location in the assembly code.
30995 @opindex mpadstruct
30996 This option is deprecated. It pads structures to multiple of 4 bytes,
30997 which is incompatible with the SH ABI@.
30999 @item -matomic-model=@var{model}
31000 @opindex matomic-model=@var{model}
31001 Sets the model of atomic operations and additional parameters as a comma
31002 separated list. For details on the atomic built-in functions see
31003 @ref{__atomic Builtins}. The following models and parameters are supported:
31008 Disable compiler generated atomic sequences and emit library calls for atomic
31009 operations. This is the default if the target is not @code{sh*-*-linux*}.
31012 Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
31013 built-in functions. The generated atomic sequences require additional support
31014 from the interrupt/exception handling code of the system and are only suitable
31015 for SH3* and SH4* single-core systems. This option is enabled by default when
31016 the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
31017 this option also partially utilizes the hardware atomic instructions
31018 @code{movli.l} and @code{movco.l} to create more efficient code, unless
31019 @samp{strict} is specified.
31022 Generate software atomic sequences that use a variable in the thread control
31023 block. This is a variation of the gUSA sequences which can also be used on
31024 SH1* and SH2* targets. The generated atomic sequences require additional
31025 support from the interrupt/exception handling code of the system and are only
31026 suitable for single-core systems. When using this model, the @samp{gbr-offset=}
31027 parameter has to be specified as well.
31030 Generate software atomic sequences that temporarily disable interrupts by
31031 setting @code{SR.IMASK = 1111}. This model works only when the program runs
31032 in privileged mode and is only suitable for single-core systems. Additional
31033 support from the interrupt/exception handling code of the system is not
31034 required. This model is enabled by default when the target is
31035 @code{sh*-*-linux*} and SH1* or SH2*.
31038 Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
31039 instructions only. This is only available on SH4A and is suitable for
31040 multi-core systems. Since the hardware instructions support only 32 bit atomic
31041 variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
31042 Code compiled with this option is also compatible with other software
31043 atomic model interrupt/exception handling systems if executed on an SH4A
31044 system. Additional support from the interrupt/exception handling code of the
31045 system is not required for this model.
31048 This parameter specifies the offset in bytes of the variable in the thread
31049 control block structure that should be used by the generated atomic sequences
31050 when the @samp{soft-tcb} model has been selected. For other models this
31051 parameter is ignored. The specified value must be an integer multiple of four
31052 and in the range 0-1020.
31055 This parameter prevents mixed usage of multiple atomic models, even if they
31056 are compatible, and makes the compiler generate atomic sequences of the
31057 specified model only.
31063 Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
31064 Notice that depending on the particular hardware and software configuration
31065 this can degrade overall performance due to the operand cache line flushes
31066 that are implied by the @code{tas.b} instruction. On multi-core SH4A
31067 processors the @code{tas.b} instruction must be used with caution since it
31068 can result in data corruption for certain cache configurations.
31071 @opindex mprefergot
31072 When generating position-independent code, emit function calls using
31073 the Global Offset Table instead of the Procedure Linkage Table.
31076 @itemx -mno-usermode
31078 @opindex mno-usermode
31079 Don't allow (allow) the compiler generating privileged mode code. Specifying
31080 @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
31081 inlined code would not work in user mode. @option{-musermode} is the default
31082 when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
31083 @option{-musermode} has no effect, since there is no user mode.
31085 @item -multcost=@var{number}
31086 @opindex multcost=@var{number}
31087 Set the cost to assume for a multiply insn.
31089 @item -mdiv=@var{strategy}
31090 @opindex mdiv=@var{strategy}
31091 Set the division strategy to be used for integer division operations.
31092 @var{strategy} can be one of:
31097 Calls a library function that uses the single-step division instruction
31098 @code{div1} to perform the operation. Division by zero calculates an
31099 unspecified result and does not trap. This is the default except for SH4,
31100 SH2A and SHcompact.
31103 Calls a library function that performs the operation in double precision
31104 floating point. Division by zero causes a floating-point exception. This is
31105 the default for SHcompact with FPU. Specifying this for targets that do not
31106 have a double precision FPU defaults to @code{call-div1}.
31109 Calls a library function that uses a lookup table for small divisors and
31110 the @code{div1} instruction with case distinction for larger divisors. Division
31111 by zero calculates an unspecified result and does not trap. This is the default
31112 for SH4. Specifying this for targets that do not have dynamic shift
31113 instructions defaults to @code{call-div1}.
31117 When a division strategy has not been specified the default strategy is
31118 selected based on the current target. For SH2A the default strategy is to
31119 use the @code{divs} and @code{divu} instructions instead of library function
31122 @item -maccumulate-outgoing-args
31123 @opindex maccumulate-outgoing-args
31124 Reserve space once for outgoing arguments in the function prologue rather
31125 than around each call. Generally beneficial for performance and size. Also
31126 needed for unwinding to avoid changing the stack frame around conditional code.
31128 @item -mdivsi3_libfunc=@var{name}
31129 @opindex mdivsi3_libfunc=@var{name}
31130 Set the name of the library function used for 32-bit signed division to
31132 This only affects the name used in the @samp{call} division strategies, and
31133 the compiler still expects the same sets of input/output/clobbered registers as
31134 if this option were not present.
31136 @item -mfixed-range=@var{register-range}
31137 @opindex mfixed-range
31138 Generate code treating the given register range as fixed registers.
31139 A fixed register is one that the register allocator cannot use. This is
31140 useful when compiling kernel code. A register range is specified as
31141 two registers separated by a dash. Multiple register ranges can be
31142 specified separated by a comma.
31144 @item -mbranch-cost=@var{num}
31145 @opindex mbranch-cost=@var{num}
31146 Assume @var{num} to be the cost for a branch instruction. Higher numbers
31147 make the compiler try to generate more branch-free code if possible.
31148 If not specified the value is selected depending on the processor type that
31149 is being compiled for.
31152 @itemx -mno-zdcbranch
31153 @opindex mzdcbranch
31154 @opindex mno-zdcbranch
31155 Assume (do not assume) that zero displacement conditional branch instructions
31156 @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31157 compiler prefers zero displacement branch code sequences. This is
31158 enabled by default when generating code for SH4 and SH4A. It can be explicitly
31159 disabled by specifying @option{-mno-zdcbranch}.
31161 @item -mcbranch-force-delay-slot
31162 @opindex mcbranch-force-delay-slot
31163 Force the usage of delay slots for conditional branches, which stuffs the delay
31164 slot with a @code{nop} if a suitable instruction cannot be found. By default
31165 this option is disabled. It can be enabled to work around hardware bugs as
31166 found in the original SH7055.
31169 @itemx -mno-fused-madd
31170 @opindex mfused-madd
31171 @opindex mno-fused-madd
31172 Generate code that uses (does not use) the floating-point multiply and
31173 accumulate instructions. These instructions are generated by default
31174 if hardware floating point is used. The machine-dependent
31175 @option{-mfused-madd} option is now mapped to the machine-independent
31176 @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31177 mapped to @option{-ffp-contract=off}.
31183 Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31184 and cosine approximations. The option @option{-mfsca} must be used in
31185 combination with @option{-funsafe-math-optimizations}. It is enabled by default
31186 when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31187 approximations even if @option{-funsafe-math-optimizations} is in effect.
31193 Allow or disallow the compiler to emit the @code{fsrra} instruction for
31194 reciprocal square root approximations. The option @option{-mfsrra} must be used
31195 in combination with @option{-funsafe-math-optimizations} and
31196 @option{-ffinite-math-only}. It is enabled by default when generating code for
31197 SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31198 even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31201 @item -mpretend-cmove
31202 @opindex mpretend-cmove
31203 Prefer zero-displacement conditional branches for conditional move instruction
31204 patterns. This can result in faster code on the SH4 processor.
31208 Generate code using the FDPIC ABI.
31212 @node Solaris 2 Options
31213 @subsection Solaris 2 Options
31214 @cindex Solaris 2 options
31216 These @samp{-m} options are supported on Solaris 2:
31219 @item -mclear-hwcap
31220 @opindex mclear-hwcap
31221 @option{-mclear-hwcap} tells the compiler to remove the hardware
31222 capabilities generated by the Solaris assembler. This is only necessary
31223 when object files use ISA extensions not supported by the current
31224 machine, but check at runtime whether or not to use them.
31226 @item -mimpure-text
31227 @opindex mimpure-text
31228 @option{-mimpure-text}, used in addition to @option{-shared}, tells
31229 the compiler to not pass @option{-z text} to the linker when linking a
31230 shared object. Using this option, you can link position-dependent
31231 code into a shared object.
31233 @option{-mimpure-text} suppresses the ``relocations remain against
31234 allocatable but non-writable sections'' linker error message.
31235 However, the necessary relocations trigger copy-on-write, and the
31236 shared object is not actually shared across processes. Instead of
31237 using @option{-mimpure-text}, you should compile all source code with
31238 @option{-fpic} or @option{-fPIC}.
31242 These switches are supported in addition to the above on Solaris 2:
31247 This is a synonym for @option{-pthread}.
31250 @node SPARC Options
31251 @subsection SPARC Options
31252 @cindex SPARC options
31254 These @samp{-m} options are supported on the SPARC:
31257 @item -mno-app-regs
31259 @opindex mno-app-regs
31261 Specify @option{-mapp-regs} to generate output using the global registers
31262 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31263 global register 1, each global register 2 through 4 is then treated as an
31264 allocable register that is clobbered by function calls. This is the default.
31266 To be fully SVR4 ABI-compliant at the cost of some performance loss,
31267 specify @option{-mno-app-regs}. You should compile libraries and system
31268 software with this option.
31274 With @option{-mflat}, the compiler does not generate save/restore instructions
31275 and uses a ``flat'' or single register window model. This model is compatible
31276 with the regular register window model. The local registers and the input
31277 registers (0--5) are still treated as ``call-saved'' registers and are
31278 saved on the stack as needed.
31280 With @option{-mno-flat} (the default), the compiler generates save/restore
31281 instructions (except for leaf functions). This is the normal operating mode.
31284 @itemx -mhard-float
31286 @opindex mhard-float
31287 Generate output containing floating-point instructions. This is the
31291 @itemx -msoft-float
31293 @opindex msoft-float
31294 Generate output containing library calls for floating point.
31295 @strong{Warning:} the requisite libraries are not available for all SPARC
31296 targets. Normally the facilities of the machine's usual C compiler are
31297 used, but this cannot be done directly in cross-compilation. You must make
31298 your own arrangements to provide suitable library functions for
31299 cross-compilation. The embedded targets @samp{sparc-*-aout} and
31300 @samp{sparclite-*-*} do provide software floating-point support.
31302 @option{-msoft-float} changes the calling convention in the output file;
31303 therefore, it is only useful if you compile @emph{all} of a program with
31304 this option. In particular, you need to compile @file{libgcc.a}, the
31305 library that comes with GCC, with @option{-msoft-float} in order for
31308 @item -mhard-quad-float
31309 @opindex mhard-quad-float
31310 Generate output containing quad-word (long double) floating-point
31313 @item -msoft-quad-float
31314 @opindex msoft-quad-float
31315 Generate output containing library calls for quad-word (long double)
31316 floating-point instructions. The functions called are those specified
31317 in the SPARC ABI@. This is the default.
31319 As of this writing, there are no SPARC implementations that have hardware
31320 support for the quad-word floating-point instructions. They all invoke
31321 a trap handler for one of these instructions, and then the trap handler
31322 emulates the effect of the instruction. Because of the trap handler overhead,
31323 this is much slower than calling the ABI library routines. Thus the
31324 @option{-msoft-quad-float} option is the default.
31326 @item -mno-unaligned-doubles
31327 @itemx -munaligned-doubles
31328 @opindex mno-unaligned-doubles
31329 @opindex munaligned-doubles
31330 Assume that doubles have 8-byte alignment. This is the default.
31332 With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
31333 alignment only if they are contained in another type, or if they have an
31334 absolute address. Otherwise, it assumes they have 4-byte alignment.
31335 Specifying this option avoids some rare compatibility problems with code
31336 generated by other compilers. It is not the default because it results
31337 in a performance loss, especially for floating-point code.
31340 @itemx -mno-user-mode
31341 @opindex muser-mode
31342 @opindex mno-user-mode
31343 Do not generate code that can only run in supervisor mode. This is relevant
31344 only for the @code{casa} instruction emitted for the LEON3 processor. This
31347 @item -mfaster-structs
31348 @itemx -mno-faster-structs
31349 @opindex mfaster-structs
31350 @opindex mno-faster-structs
31351 With @option{-mfaster-structs}, the compiler assumes that structures
31352 should have 8-byte alignment. This enables the use of pairs of
31353 @code{ldd} and @code{std} instructions for copies in structure
31354 assignment, in place of twice as many @code{ld} and @code{st} pairs.
31355 However, the use of this changed alignment directly violates the SPARC
31356 ABI@. Thus, it's intended only for use on targets where the developer
31357 acknowledges that their resulting code is not directly in line with
31358 the rules of the ABI@.
31360 @item -mstd-struct-return
31361 @itemx -mno-std-struct-return
31362 @opindex mstd-struct-return
31363 @opindex mno-std-struct-return
31364 With @option{-mstd-struct-return}, the compiler generates checking code
31365 in functions returning structures or unions to detect size mismatches
31366 between the two sides of function calls, as per the 32-bit ABI@.
31368 The default is @option{-mno-std-struct-return}. This option has no effect
31375 Enable Local Register Allocation. This is the default for SPARC since GCC 7
31376 so @option{-mno-lra} needs to be passed to get old Reload.
31378 @item -mcpu=@var{cpu_type}
31380 Set the instruction set, register set, and instruction scheduling parameters
31381 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31382 @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
31383 @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
31384 @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
31385 @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
31386 @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
31389 Native Solaris and GNU/Linux toolchains also support the value @samp{native},
31390 which selects the best architecture option for the host processor.
31391 @option{-mcpu=native} has no effect if GCC does not recognize
31394 Default instruction scheduling parameters are used for values that select
31395 an architecture and not an implementation. These are @samp{v7}, @samp{v8},
31396 @samp{sparclite}, @samp{sparclet}, @samp{v9}.
31398 Here is a list of each supported architecture and their supported
31406 supersparc, hypersparc, leon, leon3, leon5
31409 f930, f934, sparclite86x
31415 ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
31419 By default (unless configured otherwise), GCC generates code for the V7
31420 variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
31421 additionally optimizes it for the Cypress CY7C602 chip, as used in the
31422 SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
31423 SPARCStation 1, 2, IPX etc.
31425 With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
31426 architecture. The only difference from V7 code is that the compiler emits
31427 the integer multiply and integer divide instructions which exist in SPARC-V8
31428 but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
31429 optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
31432 With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
31433 the SPARC architecture. This adds the integer multiply, integer divide step
31434 and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
31435 With @option{-mcpu=f930}, the compiler additionally optimizes it for the
31436 Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
31437 @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
31438 MB86934 chip, which is the more recent SPARClite with FPU@.
31440 With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
31441 the SPARC architecture. This adds the integer multiply, multiply/accumulate,
31442 integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
31443 but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
31444 optimizes it for the TEMIC SPARClet chip.
31446 With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
31447 architecture. This adds 64-bit integer and floating-point move instructions,
31448 3 additional floating-point condition code registers and conditional move
31449 instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
31450 optimizes it for the Sun UltraSPARC I/II/IIi chips. With
31451 @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
31452 Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
31453 @option{-mcpu=niagara}, the compiler additionally optimizes it for
31454 Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
31455 additionally optimizes it for Sun UltraSPARC T2 chips. With
31456 @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
31457 UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
31458 additionally optimizes it for Sun UltraSPARC T4 chips. With
31459 @option{-mcpu=niagara7}, the compiler additionally optimizes it for
31460 Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
31461 additionally optimizes it for Oracle M8 chips.
31463 @item -mtune=@var{cpu_type}
31465 Set the instruction scheduling parameters for machine type
31466 @var{cpu_type}, but do not set the instruction set or register set that the
31467 option @option{-mcpu=@var{cpu_type}} does.
31469 The same values for @option{-mcpu=@var{cpu_type}} can be used for
31470 @option{-mtune=@var{cpu_type}}, but the only useful values are those
31471 that select a particular CPU implementation. Those are
31472 @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
31473 @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
31474 @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
31475 @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
31476 @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
31477 and GNU/Linux toolchains, @samp{native} can also be used.
31482 @opindex mno-v8plus
31483 With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
31484 difference from the V8 ABI is that the global and out registers are
31485 considered 64 bits wide. This is enabled by default on Solaris in 32-bit
31486 mode for all SPARC-V9 processors.
31492 With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
31493 Visual Instruction Set extensions. The default is @option{-mno-vis}.
31499 With @option{-mvis2}, GCC generates code that takes advantage of
31500 version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
31501 default is @option{-mvis2} when targeting a cpu that supports such
31502 instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
31503 also sets @option{-mvis}.
31509 With @option{-mvis3}, GCC generates code that takes advantage of
31510 version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
31511 default is @option{-mvis3} when targeting a cpu that supports such
31512 instructions, such as niagara-3 and later. Setting @option{-mvis3}
31513 also sets @option{-mvis2} and @option{-mvis}.
31519 With @option{-mvis4}, GCC generates code that takes advantage of
31520 version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
31521 default is @option{-mvis4} when targeting a cpu that supports such
31522 instructions, such as niagara-7 and later. Setting @option{-mvis4}
31523 also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
31529 With @option{-mvis4b}, GCC generates code that takes advantage of
31530 version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
31531 the additional VIS instructions introduced in the Oracle SPARC
31532 Architecture 2017. The default is @option{-mvis4b} when targeting a
31533 cpu that supports such instructions, such as m8 and later. Setting
31534 @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
31535 @option{-mvis2} and @option{-mvis}.
31540 @opindex mno-cbcond
31541 With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
31542 Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
31543 when targeting a CPU that supports such instructions, such as Niagara-4 and
31550 With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
31551 Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
31552 when targeting a CPU that supports such instructions, such as Niagara-3 and
31558 @opindex mno-fsmuld
31559 With @option{-mfsmuld}, GCC generates code that takes advantage of the
31560 Floating-point Multiply Single to Double (FsMULd) instruction. The default is
31561 @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
31562 or V9 with FPU except @option{-mcpu=leon}.
31568 With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
31569 Population Count instruction. The default is @option{-mpopc}
31570 when targeting a CPU that supports such an instruction, such as Niagara-2 and
31577 With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
31578 Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
31579 when targeting a CPU that supports such an instruction, such as Niagara-7 and
31583 @opindex mfix-at697f
31584 Enable the documented workaround for the single erratum of the Atmel AT697F
31585 processor (which corresponds to erratum #13 of the AT697E processor).
31588 @opindex mfix-ut699
31589 Enable the documented workarounds for the floating-point errata and the data
31590 cache nullify errata of the UT699 processor.
31593 @opindex mfix-ut700
31594 Enable the documented workaround for the back-to-back store errata of
31595 the UT699E/UT700 processor.
31597 @item -mfix-gr712rc
31598 @opindex mfix-gr712rc
31599 Enable the documented workaround for the back-to-back store errata of
31600 the GR712RC processor.
31603 These @samp{-m} options are supported in addition to the above
31604 on SPARC-V9 processors in 64-bit environments:
31611 Generate code for a 32-bit or 64-bit environment.
31612 The 32-bit environment sets int, long and pointer to 32 bits.
31613 The 64-bit environment sets int to 32 bits and long and pointer
31616 @item -mcmodel=@var{which}
31618 Set the code model to one of
31622 The Medium/Low code model: 64-bit addresses, programs
31623 must be linked in the low 32 bits of memory. Programs can be statically
31624 or dynamically linked.
31627 The Medium/Middle code model: 64-bit addresses, programs
31628 must be linked in the low 44 bits of memory, the text and data segments must
31629 be less than 2GB in size and the data segment must be located within 2GB of
31633 The Medium/Anywhere code model: 64-bit addresses, programs
31634 may be linked anywhere in memory, the text and data segments must be less
31635 than 2GB in size and the data segment must be located within 2GB of the
31639 The Medium/Anywhere code model for embedded systems:
31640 64-bit addresses, the text and data segments must be less than 2GB in
31641 size, both starting anywhere in memory (determined at link time). The
31642 global register %g4 points to the base of the data segment. Programs
31643 are statically linked and PIC is not supported.
31646 @item -mmemory-model=@var{mem-model}
31647 @opindex mmemory-model
31648 Set the memory model in force on the processor to one of
31652 The default memory model for the processor and operating system.
31655 Relaxed Memory Order
31658 Partial Store Order
31664 Sequential Consistency
31667 These memory models are formally defined in Appendix D of the SPARC-V9
31668 architecture manual, as set in the processor's @code{PSTATE.MM} field.
31671 @itemx -mno-stack-bias
31672 @opindex mstack-bias
31673 @opindex mno-stack-bias
31674 With @option{-mstack-bias}, GCC assumes that the stack pointer, and
31675 frame pointer if present, are offset by @minus{}2047 which must be added back
31676 when making stack frame references. This is the default in 64-bit mode.
31677 Otherwise, assume no such offset is present.
31680 @node System V Options
31681 @subsection Options for System V
31683 These additional options are available on System V Release 4 for
31684 compatibility with other compilers on those systems:
31689 Create a shared object.
31690 It is recommended that @option{-symbolic} or @option{-shared} be used instead.
31694 Identify the versions of each tool used by the compiler, in a
31695 @code{.ident} assembler directive in the output.
31699 Refrain from adding @code{.ident} directives to the output file (this is
31702 @item -YP,@var{dirs}
31704 Search the directories @var{dirs}, and no others, for libraries
31705 specified with @option{-l}.
31707 @item -Ym,@var{dir}
31709 Look in the directory @var{dir} to find the M4 preprocessor.
31710 The assembler uses this option.
31711 @c This is supposed to go with a -Yd for predefined M4 macro files, but
31712 @c the generic assembler that comes with Solaris takes just -Ym.
31716 @subsection V850 Options
31717 @cindex V850 Options
31719 These @samp{-m} options are defined for V850 implementations:
31723 @itemx -mno-long-calls
31724 @opindex mlong-calls
31725 @opindex mno-long-calls
31726 Treat all calls as being far away (near). If calls are assumed to be
31727 far away, the compiler always loads the function's address into a
31728 register, and calls indirect through the pointer.
31734 Do not optimize (do optimize) basic blocks that use the same index
31735 pointer 4 or more times to copy pointer into the @code{ep} register, and
31736 use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
31737 option is on by default if you optimize.
31739 @item -mno-prolog-function
31740 @itemx -mprolog-function
31741 @opindex mno-prolog-function
31742 @opindex mprolog-function
31743 Do not use (do use) external functions to save and restore registers
31744 at the prologue and epilogue of a function. The external functions
31745 are slower, but use less code space if more than one function saves
31746 the same number of registers. The @option{-mprolog-function} option
31747 is on by default if you optimize.
31751 Try to make the code as small as possible. At present, this just turns
31752 on the @option{-mep} and @option{-mprolog-function} options.
31754 @item -mtda=@var{n}
31756 Put static or global variables whose size is @var{n} bytes or less into
31757 the tiny data area that register @code{ep} points to. The tiny data
31758 area can hold up to 256 bytes in total (128 bytes for byte references).
31760 @item -msda=@var{n}
31762 Put static or global variables whose size is @var{n} bytes or less into
31763 the small data area that register @code{gp} points to. The small data
31764 area can hold up to 64 kilobytes.
31766 @item -mzda=@var{n}
31768 Put static or global variables whose size is @var{n} bytes or less into
31769 the first 32 kilobytes of memory.
31773 Specify that the target processor is the V850.
31777 Specify that the target processor is the V850E3V5. The preprocessor
31778 constant @code{__v850e3v5__} is defined if this option is used.
31782 Specify that the target processor is the V850E3V5. This is an alias for
31783 the @option{-mv850e3v5} option.
31787 Specify that the target processor is the V850E2V3. The preprocessor
31788 constant @code{__v850e2v3__} is defined if this option is used.
31792 Specify that the target processor is the V850E2. The preprocessor
31793 constant @code{__v850e2__} is defined if this option is used.
31797 Specify that the target processor is the V850E1. The preprocessor
31798 constants @code{__v850e1__} and @code{__v850e__} are defined if
31799 this option is used.
31803 Specify that the target processor is the V850ES. This is an alias for
31804 the @option{-mv850e1} option.
31808 Specify that the target processor is the V850E@. The preprocessor
31809 constant @code{__v850e__} is defined if this option is used.
31811 If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
31812 nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
31813 are defined then a default target processor is chosen and the
31814 relevant @samp{__v850*__} preprocessor constant is defined.
31816 The preprocessor constants @code{__v850} and @code{__v851__} are always
31817 defined, regardless of which processor variant is the target.
31819 @item -mdisable-callt
31820 @itemx -mno-disable-callt
31821 @opindex mdisable-callt
31822 @opindex mno-disable-callt
31823 This option suppresses generation of the @code{CALLT} instruction for the
31824 v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
31827 This option is enabled by default when the RH850 ABI is
31828 in use (see @option{-mrh850-abi}), and disabled by default when the
31829 GCC ABI is in use. If @code{CALLT} instructions are being generated
31830 then the C preprocessor symbol @code{__V850_CALLT__} is defined.
31836 Pass on (or do not pass on) the @option{-mrelax} command-line option
31840 @itemx -mno-long-jumps
31841 @opindex mlong-jumps
31842 @opindex mno-long-jumps
31843 Disable (or re-enable) the generation of PC-relative jump instructions.
31846 @itemx -mhard-float
31847 @opindex msoft-float
31848 @opindex mhard-float
31849 Disable (or re-enable) the generation of hardware floating point
31850 instructions. This option is only significant when the target
31851 architecture is @samp{V850E2V3} or higher. If hardware floating point
31852 instructions are being generated then the C preprocessor symbol
31853 @code{__FPU_OK__} is defined, otherwise the symbol
31854 @code{__NO_FPU__} is defined.
31858 Enables the use of the e3v5 LOOP instruction. The use of this
31859 instruction is not enabled by default when the e3v5 architecture is
31860 selected because its use is still experimental.
31864 @opindex mrh850-abi
31866 Enables support for the RH850 version of the V850 ABI. This is the
31867 default. With this version of the ABI the following rules apply:
31871 Integer sized structures and unions are returned via a memory pointer
31872 rather than a register.
31875 Large structures and unions (more than 8 bytes in size) are passed by
31879 Functions are aligned to 16-bit boundaries.
31882 The @option{-m8byte-align} command-line option is supported.
31885 The @option{-mdisable-callt} command-line option is enabled by
31886 default. The @option{-mno-disable-callt} command-line option is not
31890 When this version of the ABI is enabled the C preprocessor symbol
31891 @code{__V850_RH850_ABI__} is defined.
31895 Enables support for the old GCC version of the V850 ABI. With this
31896 version of the ABI the following rules apply:
31900 Integer sized structures and unions are returned in register @code{r10}.
31903 Large structures and unions (more than 8 bytes in size) are passed by
31907 Functions are aligned to 32-bit boundaries, unless optimizing for
31911 The @option{-m8byte-align} command-line option is not supported.
31914 The @option{-mdisable-callt} command-line option is supported but not
31915 enabled by default.
31918 When this version of the ABI is enabled the C preprocessor symbol
31919 @code{__V850_GCC_ABI__} is defined.
31921 @item -m8byte-align
31922 @itemx -mno-8byte-align
31923 @opindex m8byte-align
31924 @opindex mno-8byte-align
31925 Enables support for @code{double} and @code{long long} types to be
31926 aligned on 8-byte boundaries. The default is to restrict the
31927 alignment of all objects to at most 4-bytes. When
31928 @option{-m8byte-align} is in effect the C preprocessor symbol
31929 @code{__V850_8BYTE_ALIGN__} is defined.
31932 @opindex mbig-switch
31933 Generate code suitable for big switch tables. Use this option only if
31934 the assembler/linker complain about out of range branches within a switch
31939 This option causes r2 and r5 to be used in the code generated by
31940 the compiler. This setting is the default.
31942 @item -mno-app-regs
31943 @opindex mno-app-regs
31944 This option causes r2 and r5 to be treated as fixed registers.
31949 @subsection VAX Options
31950 @cindex VAX options
31952 These @samp{-m} options are defined for the VAX:
31957 Do not output certain jump instructions (@code{aobleq} and so on)
31958 that the Unix assembler for the VAX cannot handle across long
31963 Do output those jump instructions, on the assumption that the
31964 GNU assembler is being used.
31968 Output code for G-format floating-point numbers instead of D-format.
31974 Enable Local Register Allocation. This is still experimental for the VAX,
31975 so by default the compiler uses standard reload.
31978 @node Visium Options
31979 @subsection Visium Options
31980 @cindex Visium options
31986 A program which performs file I/O and is destined to run on an MCM target
31987 should be linked with this option. It causes the libraries libc.a and
31988 libdebug.a to be linked. The program should be run on the target under
31989 the control of the GDB remote debugging stub.
31993 A program which performs file I/O and is destined to run on the simulator
31994 should be linked with option. This causes libraries libc.a and libsim.a to
31998 @itemx -mhard-float
32000 @opindex mhard-float
32001 Generate code containing floating-point instructions. This is the
32005 @itemx -msoft-float
32007 @opindex msoft-float
32008 Generate code containing library calls for floating-point.
32010 @option{-msoft-float} changes the calling convention in the output file;
32011 therefore, it is only useful if you compile @emph{all} of a program with
32012 this option. In particular, you need to compile @file{libgcc.a}, the
32013 library that comes with GCC, with @option{-msoft-float} in order for
32016 @item -mcpu=@var{cpu_type}
32018 Set the instruction set, register set, and instruction scheduling parameters
32019 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32020 @samp{mcm}, @samp{gr5} and @samp{gr6}.
32022 @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
32024 By default (unless configured otherwise), GCC generates code for the GR5
32025 variant of the Visium architecture.
32027 With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
32028 architecture. The only difference from GR5 code is that the compiler will
32029 generate block move instructions.
32031 @item -mtune=@var{cpu_type}
32033 Set the instruction scheduling parameters for machine type @var{cpu_type},
32034 but do not set the instruction set or register set that the option
32035 @option{-mcpu=@var{cpu_type}} would.
32039 Generate code for the supervisor mode, where there are no restrictions on
32040 the access to general registers. This is the default.
32043 @opindex muser-mode
32044 Generate code for the user mode, where the access to some general registers
32045 is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
32046 mode; on the GR6, only registers r29 to r31 are affected.
32050 @subsection VMS Options
32052 These @samp{-m} options are defined for the VMS implementations:
32055 @item -mvms-return-codes
32056 @opindex mvms-return-codes
32057 Return VMS condition codes from @code{main}. The default is to return POSIX-style
32058 condition (e.g.@: error) codes.
32060 @item -mdebug-main=@var{prefix}
32061 @opindex mdebug-main=@var{prefix}
32062 Flag the first routine whose name starts with @var{prefix} as the main
32063 routine for the debugger.
32067 Default to 64-bit memory allocation routines.
32069 @item -mpointer-size=@var{size}
32070 @opindex mpointer-size=@var{size}
32071 Set the default size of pointers. Possible options for @var{size} are
32072 @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
32073 for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
32074 The later option disables @code{pragma pointer_size}.
32077 @node VxWorks Options
32078 @subsection VxWorks Options
32079 @cindex VxWorks Options
32081 The options in this section are defined for all VxWorks targets.
32082 Options specific to the target hardware are listed with the other
32083 options for that target.
32088 GCC can generate code for both VxWorks kernels and real time processes
32089 (RTPs). This option switches from the former to the latter. It also
32090 defines the preprocessor macro @code{__RTP__}.
32093 @opindex non-static
32094 Link an RTP executable against shared libraries rather than static
32095 libraries. The options @option{-static} and @option{-shared} can
32096 also be used for RTPs (@pxref{Link Options}); @option{-static}
32103 These options are passed down to the linker. They are defined for
32104 compatibility with Diab.
32107 @opindex Xbind-lazy
32108 Enable lazy binding of function calls. This option is equivalent to
32109 @option{-Wl,-z,now} and is defined for compatibility with Diab.
32113 Disable lazy binding of function calls. This option is the default and
32114 is defined for compatibility with Diab.
32118 @subsection x86 Options
32119 @cindex x86 Options
32121 These @samp{-m} options are defined for the x86 family of computers.
32125 @item -march=@var{cpu-type}
32127 Generate instructions for the machine type @var{cpu-type}. In contrast to
32128 @option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32129 for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32130 to generate code that may not run at all on processors other than the one
32131 indicated. Specifying @option{-march=@var{cpu-type}} implies
32132 @option{-mtune=@var{cpu-type}}, except where noted otherwise.
32134 The choices for @var{cpu-type} are:
32138 This selects the CPU to generate code for at compilation time by determining
32139 the processor type of the compiling machine. Using @option{-march=native}
32140 enables all instruction subsets supported by the local machine (hence
32141 the result might not run on different machines). Using @option{-mtune=native}
32142 produces code optimized for the local machine under the constraints
32143 of the selected instruction set.
32146 A generic CPU with 64-bit extensions.
32151 These choices for @var{cpu-type} select the corresponding
32152 micro-architecture level from the x86-64 psABI. On ABIs other than
32153 the x86-64 psABI they select the same CPU features as the x86-64 psABI
32154 documents for the particular micro-architecture level.
32156 Since these @var{cpu-type} values do not have a corresponding
32157 @option{-mtune} setting, using @option{-march} with these values enables
32158 generic tuning. Specific tuning can be enabled using the
32159 @option{-mtune=@var{other-cpu-type}} option with an appropriate
32160 @var{other-cpu-type} value.
32163 Original Intel i386 CPU@.
32166 Intel i486 CPU@. (No scheduling is implemented for this chip.)
32170 Intel Pentium CPU with no MMX support.
32173 Intel Lakemont MCU, based on Intel Pentium CPU.
32176 Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32179 Intel Pentium Pro CPU@.
32182 When used with @option{-march}, the Pentium Pro
32183 instruction set is used, so the code runs on all i686 family chips.
32184 When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32187 Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32192 Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32193 instruction set support.
32196 Intel Pentium M; low-power version of Intel Pentium III CPU
32197 with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32202 Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
32205 Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
32206 instruction set support.
32209 Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32210 SSE2, SSE3 and FXSR instruction set support.
32213 Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32214 SAHF and FXSR instruction set support.
32217 Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32218 SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32221 Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32222 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32225 Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32226 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32230 Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32231 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32232 and F16C instruction set support.
32235 Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32236 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32237 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32240 Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32241 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32242 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32243 instruction set support.
32246 Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32247 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32248 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32249 CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32252 Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32253 instruction set support.
32256 Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32257 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32258 instruction set support.
32261 Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32262 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32263 RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32266 @item goldmont-plus
32267 Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32268 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32269 SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32270 RDPID and SGX instruction set support.
32273 Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32274 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32275 RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32276 SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32280 Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32281 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32282 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32283 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32284 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32285 AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
32288 Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32289 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32290 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32291 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32292 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32293 AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set
32297 Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32298 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32299 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32300 AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
32303 Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32304 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32305 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32306 AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
32307 AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
32309 @item skylake-avx512
32310 Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32311 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32312 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32313 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
32314 AVX512DQ and AVX512CD instruction set support.
32317 Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32318 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
32319 FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
32320 PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
32321 AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
32324 @item icelake-client
32325 Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32326 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32327 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32328 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32329 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32330 , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32332 @item icelake-server
32333 Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32334 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32335 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32336 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32337 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32338 , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
32339 instruction set support.
32342 Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32343 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32344 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32345 CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32346 AVX512CD and AVX512VNNI instruction set support.
32349 Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32350 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32351 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32352 CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32353 AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
32356 Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32357 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32358 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32359 CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32360 PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32361 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
32362 AVX512VP2INTERSECT and KEYLOCKER instruction set support.
32364 @item sapphirerapids
32365 Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32366 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32367 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32368 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32369 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32370 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32371 MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
32372 UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
32373 instruction set support.
32376 Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32377 SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
32378 XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
32379 CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
32380 VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
32384 Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
32385 , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32386 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32387 CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32388 PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32389 VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32391 @item graniterapids
32392 Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32393 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32394 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32395 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32396 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32397 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32398 MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
32399 SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16,
32400 AVX512BF16, AMX-FP16 and PREFETCHI instruction set support.
32403 AMD K6 CPU with MMX instruction set support.
32407 Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
32410 @itemx athlon-tbird
32411 AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
32417 Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
32418 instruction set support.
32424 Processors based on the AMD K8 core with x86-64 instruction set support,
32425 including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
32426 (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
32427 instruction set extensions.)
32430 @itemx opteron-sse3
32431 @itemx athlon64-sse3
32432 Improved versions of AMD K8 cores with SSE3 instruction set support.
32436 CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
32437 supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
32438 instruction set extensions.)
32441 CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
32442 supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
32443 SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
32446 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32447 supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
32448 SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
32452 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32453 supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
32454 PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
32455 64-bit instruction set extensions.)
32458 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32459 supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
32460 AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
32461 SSE4.2, ABM and 64-bit instruction set extensions.)
32464 AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32465 supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
32466 SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
32467 SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
32468 instruction set extensions.)
32471 AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32472 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32473 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32474 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32475 WBNOINVD, and 64-bit instruction set extensions.)
32478 AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32479 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32480 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32481 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32482 WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
32485 AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32486 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32487 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32488 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32489 WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
32490 AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
32491 AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
32494 CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
32495 supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
32496 instruction set extensions.)
32499 CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
32500 includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
32501 SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
32504 IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
32508 IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
32509 instruction set support.
32512 VIA C3 CPU with MMX and 3DNow!@: instruction set support.
32513 (No scheduling is implemented for this chip.)
32516 VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
32517 (No scheduling is implemented for this chip.)
32520 VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32521 (No scheduling is implemented for this chip.)
32524 VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
32525 (No scheduling is implemented for this chip.)
32528 VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
32529 (No scheduling is implemented for this chip.)
32532 VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32533 (No scheduling is implemented for this chip.)
32536 VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
32537 (No scheduling is implemented for this chip.)
32540 VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
32541 AVX and AVX2 instruction set support.
32542 (No scheduling is implemented for this chip.)
32545 Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32546 instruction set support.
32547 (No scheduling is implemented for this chip.)
32550 VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32551 instruction set support.
32552 (No scheduling is implemented for this chip.)
32555 VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32556 instruction set support.
32557 (No scheduling is implemented for this chip.)
32560 VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32561 instruction set support.
32562 (No scheduling is implemented for this chip.)
32565 VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32566 instruction set support.
32567 (No scheduling is implemented for this chip.)
32570 VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32571 instruction set support.
32572 (No scheduling is implemented for this chip.)
32575 ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
32576 SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
32577 ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
32580 AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
32583 @item -mtune=@var{cpu-type}
32585 Tune to @var{cpu-type} everything applicable about the generated code, except
32586 for the ABI and the set of available instructions.
32587 While picking a specific @var{cpu-type} schedules things appropriately
32588 for that particular chip, the compiler does not generate any code that
32589 cannot run on the default machine type unless you use a
32590 @option{-march=@var{cpu-type}} option.
32591 For example, if GCC is configured for i686-pc-linux-gnu
32592 then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
32593 but still runs on i686 machines.
32595 The choices for @var{cpu-type} are the same as for @option{-march}.
32596 In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
32600 Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
32601 If you know the CPU on which your code will run, then you should use
32602 the corresponding @option{-mtune} or @option{-march} option instead of
32603 @option{-mtune=generic}. But, if you do not know exactly what CPU users
32604 of your application will have, then you should use this option.
32606 As new processors are deployed in the marketplace, the behavior of this
32607 option will change. Therefore, if you upgrade to a newer version of
32608 GCC, code generation controlled by this option will change to reflect
32610 that are most common at the time that version of GCC is released.
32612 There is no @option{-march=generic} option because @option{-march}
32613 indicates the instruction set the compiler can use, and there is no
32614 generic instruction set applicable to all processors. In contrast,
32615 @option{-mtune} indicates the processor (or, in this case, collection of
32616 processors) for which the code is optimized.
32619 Produce code optimized for the most current Intel processors, which are
32620 Haswell and Silvermont for this version of GCC. If you know the CPU
32621 on which your code will run, then you should use the corresponding
32622 @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
32623 But, if you want your application performs better on both Haswell and
32624 Silvermont, then you should use this option.
32626 As new Intel processors are deployed in the marketplace, the behavior of
32627 this option will change. Therefore, if you upgrade to a newer version of
32628 GCC, code generation controlled by this option will change to reflect
32629 the most current Intel processors at the time that version of GCC is
32632 There is no @option{-march=intel} option because @option{-march} indicates
32633 the instruction set the compiler can use, and there is no common
32634 instruction set applicable to all processors. In contrast,
32635 @option{-mtune} indicates the processor (or, in this case, collection of
32636 processors) for which the code is optimized.
32639 @item -mcpu=@var{cpu-type}
32641 A deprecated synonym for @option{-mtune}.
32643 @item -mfpmath=@var{unit}
32645 Generate floating-point arithmetic for selected unit @var{unit}. The choices
32646 for @var{unit} are:
32650 Use the standard 387 floating-point coprocessor present on the majority of chips and
32651 emulated otherwise. Code compiled with this option runs almost everywhere.
32652 The temporary results are computed in 80-bit precision instead of the precision
32653 specified by the type, resulting in slightly different results compared to most
32654 of other chips. See @option{-ffloat-store} for more detailed description.
32656 This is the default choice for non-Darwin x86-32 targets.
32659 Use scalar floating-point instructions present in the SSE instruction set.
32660 This instruction set is supported by Pentium III and newer chips,
32661 and in the AMD line
32662 by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
32663 instruction set supports only single-precision arithmetic, thus the double and
32664 extended-precision arithmetic are still done using 387. A later version, present
32665 only in Pentium 4 and AMD x86-64 chips, supports double-precision
32668 For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
32669 or @option{-msse2} switches to enable SSE extensions and make this option
32670 effective. For the x86-64 compiler, these extensions are enabled by default.
32672 The resulting code should be considerably faster in the majority of cases and avoid
32673 the numerical instability problems of 387 code, but may break some existing
32674 code that expects temporaries to be 80 bits.
32676 This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
32677 and the default choice for x86-32 targets with the SSE2 instruction set
32678 when @option{-ffast-math} is enabled.
32683 Attempt to utilize both instruction sets at once. This effectively doubles the
32684 amount of available registers, and on chips with separate execution units for
32685 387 and SSE the execution resources too. Use this option with care, as it is
32686 still experimental, because the GCC register allocator does not model separate
32687 functional units well, resulting in unstable performance.
32690 @item -masm=@var{dialect}
32691 @opindex masm=@var{dialect}
32692 Output assembly instructions using selected @var{dialect}. Also affects
32693 which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
32694 extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
32695 order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
32696 not support @samp{intel}.
32699 @itemx -mno-ieee-fp
32701 @opindex mno-ieee-fp
32702 Control whether or not the compiler uses IEEE floating-point
32703 comparisons. These correctly handle the case where the result of a
32704 comparison is unordered.
32707 @itemx -mhard-float
32709 @opindex mhard-float
32710 Generate output containing 80387 instructions for floating point.
32713 @itemx -msoft-float
32715 @opindex msoft-float
32716 Generate output containing library calls for floating point.
32718 @strong{Warning:} the requisite libraries are not part of GCC@.
32719 Normally the facilities of the machine's usual C compiler are used, but
32720 this cannot be done directly in cross-compilation. You must make your
32721 own arrangements to provide suitable library functions for
32724 On machines where a function returns floating-point results in the 80387
32725 register stack, some floating-point opcodes may be emitted even if
32726 @option{-msoft-float} is used.
32728 @item -mno-fp-ret-in-387
32729 @opindex mno-fp-ret-in-387
32730 @opindex mfp-ret-in-387
32731 Do not use the FPU registers for return values of functions.
32733 The usual calling convention has functions return values of types
32734 @code{float} and @code{double} in an FPU register, even if there
32735 is no FPU@. The idea is that the operating system should emulate
32738 The option @option{-mno-fp-ret-in-387} causes such values to be returned
32739 in ordinary CPU registers instead.
32741 @item -mno-fancy-math-387
32742 @opindex mno-fancy-math-387
32743 @opindex mfancy-math-387
32744 Some 387 emulators do not support the @code{sin}, @code{cos} and
32745 @code{sqrt} instructions for the 387. Specify this option to avoid
32746 generating those instructions.
32747 This option is overridden when @option{-march}
32748 indicates that the target CPU always has an FPU and so the
32749 instruction does not need emulation. These
32750 instructions are not generated unless you also use the
32751 @option{-funsafe-math-optimizations} switch.
32753 @item -malign-double
32754 @itemx -mno-align-double
32755 @opindex malign-double
32756 @opindex mno-align-double
32757 Control whether GCC aligns @code{double}, @code{long double}, and
32758 @code{long long} variables on a two-word boundary or a one-word
32759 boundary. Aligning @code{double} variables on a two-word boundary
32760 produces code that runs somewhat faster on a Pentium at the
32761 expense of more memory.
32763 On x86-64, @option{-malign-double} is enabled by default.
32765 @strong{Warning:} if you use the @option{-malign-double} switch,
32766 structures containing the above types are aligned differently than
32767 the published application binary interface specifications for the x86-32
32768 and are not binary compatible with structures in code compiled
32769 without that switch.
32771 @item -m96bit-long-double
32772 @itemx -m128bit-long-double
32773 @opindex m96bit-long-double
32774 @opindex m128bit-long-double
32775 These switches control the size of @code{long double} type. The x86-32
32776 application binary interface specifies the size to be 96 bits,
32777 so @option{-m96bit-long-double} is the default in 32-bit mode.
32779 Modern architectures (Pentium and newer) prefer @code{long double}
32780 to be aligned to an 8- or 16-byte boundary. In arrays or structures
32781 conforming to the ABI, this is not possible. So specifying
32782 @option{-m128bit-long-double} aligns @code{long double}
32783 to a 16-byte boundary by padding the @code{long double} with an additional
32786 In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
32787 its ABI specifies that @code{long double} is aligned on 16-byte boundary.
32789 Notice that neither of these options enable any extra precision over the x87
32790 standard of 80 bits for a @code{long double}.
32792 @strong{Warning:} if you override the default value for your target ABI, this
32793 changes the size of
32794 structures and arrays containing @code{long double} variables,
32795 as well as modifying the function calling convention for functions taking
32796 @code{long double}. Hence they are not binary-compatible
32797 with code compiled without that switch.
32799 @item -mlong-double-64
32800 @itemx -mlong-double-80
32801 @itemx -mlong-double-128
32802 @opindex mlong-double-64
32803 @opindex mlong-double-80
32804 @opindex mlong-double-128
32805 These switches control the size of @code{long double} type. A size
32806 of 64 bits makes the @code{long double} type equivalent to the @code{double}
32807 type. This is the default for 32-bit Bionic C library. A size
32808 of 128 bits makes the @code{long double} type equivalent to the
32809 @code{__float128} type. This is the default for 64-bit Bionic C library.
32811 @strong{Warning:} if you override the default value for your target ABI, this
32812 changes the size of
32813 structures and arrays containing @code{long double} variables,
32814 as well as modifying the function calling convention for functions taking
32815 @code{long double}. Hence they are not binary-compatible
32816 with code compiled without that switch.
32818 @item -malign-data=@var{type}
32819 @opindex malign-data
32820 Control how GCC aligns variables. Supported values for @var{type} are
32821 @samp{compat} uses increased alignment value compatible uses GCC 4.8
32822 and earlier, @samp{abi} uses alignment value as specified by the
32823 psABI, and @samp{cacheline} uses increased alignment value to match
32824 the cache line size. @samp{compat} is the default.
32826 @item -mlarge-data-threshold=@var{threshold}
32827 @opindex mlarge-data-threshold
32828 When @option{-mcmodel=medium} is specified, data objects larger than
32829 @var{threshold} are placed in the large data section. This value must be the
32830 same across all objects linked into the binary, and defaults to 65535.
32834 Use a different function-calling convention, in which functions that
32835 take a fixed number of arguments return with the @code{ret @var{num}}
32836 instruction, which pops their arguments while returning. This saves one
32837 instruction in the caller since there is no need to pop the arguments
32840 You can specify that an individual function is called with this calling
32841 sequence with the function attribute @code{stdcall}. You can also
32842 override the @option{-mrtd} option by using the function attribute
32843 @code{cdecl}. @xref{Function Attributes}.
32845 @strong{Warning:} this calling convention is incompatible with the one
32846 normally used on Unix, so you cannot use it if you need to call
32847 libraries compiled with the Unix compiler.
32849 Also, you must provide function prototypes for all functions that
32850 take variable numbers of arguments (including @code{printf});
32851 otherwise incorrect code is generated for calls to those
32854 In addition, seriously incorrect code results if you call a
32855 function with too many arguments. (Normally, extra arguments are
32856 harmlessly ignored.)
32858 @item -mregparm=@var{num}
32860 Control how many registers are used to pass integer arguments. By
32861 default, no registers are used to pass arguments, and at most 3
32862 registers can be used. You can control this behavior for a specific
32863 function by using the function attribute @code{regparm}.
32864 @xref{Function Attributes}.
32866 @strong{Warning:} if you use this switch, and
32867 @var{num} is nonzero, then you must build all modules with the same
32868 value, including any libraries. This includes the system libraries and
32872 @opindex msseregparm
32873 Use SSE register passing conventions for float and double arguments
32874 and return values. You can control this behavior for a specific
32875 function by using the function attribute @code{sseregparm}.
32876 @xref{Function Attributes}.
32878 @strong{Warning:} if you use this switch then you must build all
32879 modules with the same value, including any libraries. This includes
32880 the system libraries and startup modules.
32882 @item -mvect8-ret-in-mem
32883 @opindex mvect8-ret-in-mem
32884 Return 8-byte vectors in memory instead of MMX registers. This is the
32885 default on VxWorks to match the ABI of the Sun Studio compilers until
32886 version 12. @emph{Only} use this option if you need to remain
32887 compatible with existing code produced by those previous compiler
32888 versions or older versions of GCC@.
32897 Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
32898 is specified, the significands of results of floating-point operations are
32899 rounded to 24 bits (single precision); @option{-mpc64} rounds the
32900 significands of results of floating-point operations to 53 bits (double
32901 precision) and @option{-mpc80} rounds the significands of results of
32902 floating-point operations to 64 bits (extended double precision), which is
32903 the default. When this option is used, floating-point operations in higher
32904 precisions are not available to the programmer without setting the FPU
32905 control word explicitly.
32907 Setting the rounding of floating-point operations to less than the default
32908 80 bits can speed some programs by 2% or more. Note that some mathematical
32909 libraries assume that extended-precision (80-bit) floating-point operations
32910 are enabled by default; routines in such libraries could suffer significant
32911 loss of accuracy, typically through so-called ``catastrophic cancellation'',
32912 when this option is used to set the precision to less than extended precision.
32917 The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
32918 are used to control floating-point calculations.SSE and AVX instructions
32919 including scalar and vector instructions could benefit from enabling the FTZ
32920 and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
32921 when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
32922 will set FTZ/DAZ flags even with @option{-shared}.
32924 @item -mstackrealign
32925 @opindex mstackrealign
32926 Realign the stack at entry. On the x86, the @option{-mstackrealign}
32927 option generates an alternate prologue and epilogue that realigns the
32928 run-time stack if necessary. This supports mixing legacy codes that keep
32929 4-byte stack alignment with modern codes that keep 16-byte stack alignment for
32930 SSE compatibility. See also the attribute @code{force_align_arg_pointer},
32931 applicable to individual functions.
32933 @item -mpreferred-stack-boundary=@var{num}
32934 @opindex mpreferred-stack-boundary
32935 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
32936 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
32937 the default is 4 (16 bytes or 128 bits).
32939 @strong{Warning:} When generating code for the x86-64 architecture with
32940 SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
32941 used to keep the stack boundary aligned to 8 byte boundary. Since
32942 x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
32943 intended to be used in controlled environment where stack space is
32944 important limitation. This option leads to wrong code when functions
32945 compiled with 16 byte stack alignment (such as functions from a standard
32946 library) are called with misaligned stack. In this case, SSE
32947 instructions may lead to misaligned memory access traps. In addition,
32948 variable arguments are handled incorrectly for 16 byte aligned
32949 objects (including x87 long double and __int128), leading to wrong
32950 results. You must build all modules with
32951 @option{-mpreferred-stack-boundary=3}, including any libraries. This
32952 includes the system libraries and startup modules.
32954 @item -mincoming-stack-boundary=@var{num}
32955 @opindex mincoming-stack-boundary
32956 Assume the incoming stack is aligned to a 2 raised to @var{num} byte
32957 boundary. If @option{-mincoming-stack-boundary} is not specified,
32958 the one specified by @option{-mpreferred-stack-boundary} is used.
32960 On Pentium and Pentium Pro, @code{double} and @code{long double} values
32961 should be aligned to an 8-byte boundary (see @option{-malign-double}) or
32962 suffer significant run time performance penalties. On Pentium III, the
32963 Streaming SIMD Extension (SSE) data type @code{__m128} may not work
32964 properly if it is not 16-byte aligned.
32966 To ensure proper alignment of this values on the stack, the stack boundary
32967 must be as aligned as that required by any value stored on the stack.
32968 Further, every function must be generated such that it keeps the stack
32969 aligned. Thus calling a function compiled with a higher preferred
32970 stack boundary from a function compiled with a lower preferred stack
32971 boundary most likely misaligns the stack. It is recommended that
32972 libraries that use callbacks always use the default setting.
32974 This extra alignment does consume extra stack space, and generally
32975 increases code size. Code that is sensitive to stack space usage, such
32976 as embedded systems and operating system kernels, may want to reduce the
32977 preferred alignment to @option{-mpreferred-stack-boundary=2}.
33034 @itemx -mavx512ifma
33035 @opindex mavx512ifma
33037 @itemx -mavx512vbmi
33038 @opindex mavx512vbmi
33049 @itemx -mclflushopt
33050 @opindex mclflushopt
33085 @itemx -mprefetchwt1
33086 @opindex mprefetchwt1
33157 @itemx -mavx512vbmi2
33158 @opindex mavx512vbmi2
33160 @itemx -mavx512bf16
33161 @opindex mavx512bf16
33163 @itemx -mavx512fp16
33164 @opindex mavx512fp16
33175 @itemx -mvpclmulqdq
33176 @opindex mvpclmulqdq
33178 @itemx -mavx512bitalg
33179 @opindex mavx512bitalg
33185 @opindex mmovdir64b
33195 @itemx -mavx512vpopcntdq
33196 @opindex mavx512vpopcntdq
33198 @itemx -mavx512vp2intersect
33199 @opindex mavx512vp2intersect
33201 @itemx -mavx5124fmaps
33202 @opindex mavx5124fmaps
33204 @itemx -mavx512vnni
33205 @opindex mavx512vnni
33210 @itemx -mavx5124vnniw
33211 @opindex mavx5124vnniw
33217 @opindex mserialize
33239 @itemx -mavxvnniint8
33240 @opindex mavxvnniint8
33242 @itemx -mavxneconvert
33243 @opindex mavxneconvert
33246 @opindex mcmpccxadd
33252 @opindex mprefetchi
33256 These switches enable the use of instructions in the MMX, SSE,
33257 SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF,
33258 AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
33259 AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
33260 WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
33261 3DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
33262 XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
33263 GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
33264 ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
33265 UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
33266 AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT or
33267 CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-}
33268 option to disable use of these instructions.
33270 These extensions are also available as built-in functions: see
33271 @ref{x86 Built-in Functions}, for details of the functions enabled and
33272 disabled by these switches.
33274 To generate SSE/SSE2 instructions automatically from floating-point
33275 code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
33277 GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
33278 generates new AVX instructions or AVX equivalence for all SSEx instructions
33281 These options enable GCC to use these extended instructions in
33282 generated code, even without @option{-mfpmath=sse}. Applications that
33283 perform run-time CPU detection must compile separate files for each
33284 supported architecture, using the appropriate flags. In particular,
33285 the file containing the CPU detection code should be compiled without
33288 @item -mdump-tune-features
33289 @opindex mdump-tune-features
33290 This option instructs GCC to dump the names of the x86 performance
33291 tuning features and default settings. The names can be used in
33292 @option{-mtune-ctrl=@var{feature-list}}.
33294 @item -mtune-ctrl=@var{feature-list}
33295 @opindex mtune-ctrl=@var{feature-list}
33296 This option is used to do fine grain control of x86 code generation features.
33297 @var{feature-list} is a comma separated list of @var{feature} names. See also
33298 @option{-mdump-tune-features}. When specified, the @var{feature} is turned
33299 on if it is not preceded with @samp{^}, otherwise, it is turned off.
33300 @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
33301 developers. Using it may lead to code paths not covered by testing and can
33302 potentially result in compiler ICEs or runtime errors.
33305 @opindex mno-default
33306 This option instructs GCC to turn off all tunable features. See also
33307 @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
33311 This option instructs GCC to emit a @code{cld} instruction in the prologue
33312 of functions that use string instructions. String instructions depend on
33313 the DF flag to select between autoincrement or autodecrement mode. While the
33314 ABI specifies the DF flag to be cleared on function entry, some operating
33315 systems violate this specification by not clearing the DF flag in their
33316 exception dispatchers. The exception handler can be invoked with the DF flag
33317 set, which leads to wrong direction mode when string instructions are used.
33318 This option can be enabled by default on 32-bit x86 targets by configuring
33319 GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
33320 instructions can be suppressed with the @option{-mno-cld} compiler option
33324 @opindex mvzeroupper
33325 This option instructs GCC to emit a @code{vzeroupper} instruction
33326 before a transfer of control flow out of the function to minimize
33327 the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
33330 @item -mprefer-avx128
33331 @opindex mprefer-avx128
33332 This option instructs GCC to use 128-bit AVX instructions instead of
33333 256-bit AVX instructions in the auto-vectorizer.
33335 @item -mprefer-vector-width=@var{opt}
33336 @opindex mprefer-vector-width
33337 This option instructs GCC to use @var{opt}-bit vector width in instructions
33338 instead of default on the selected platform.
33340 @item -mmove-max=@var{bits}
33342 This option instructs GCC to set the maximum number of bits can be
33343 moved from memory to memory efficiently to @var{bits}. The valid
33344 @var{bits} are 128, 256 and 512.
33346 @item -mstore-max=@var{bits}
33347 @opindex mstore-max
33348 This option instructs GCC to set the maximum number of bits can be
33349 stored to memory efficiently to @var{bits}. The valid @var{bits} are
33354 No extra limitations applied to GCC other than defined by the selected platform.
33357 Prefer 128-bit vector width for instructions.
33360 Prefer 256-bit vector width for instructions.
33363 Prefer 512-bit vector width for instructions.
33368 This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
33369 code to implement compare-and-exchange operations on 16-byte aligned 128-bit
33370 objects. This is useful for atomic updates of data structures exceeding one
33371 machine word in size. The compiler uses this instruction to implement
33372 @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
33373 128-bit integers, a library call is always used.
33377 This option enables generation of @code{SAHF} instructions in 64-bit code.
33378 Early Intel Pentium 4 CPUs with Intel 64 support,
33379 prior to the introduction of Pentium 4 G1 step in December 2005,
33380 lacked the @code{LAHF} and @code{SAHF} instructions
33381 which are supported by AMD64.
33382 These are load and store instructions, respectively, for certain status flags.
33383 In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
33384 @code{drem}, and @code{remainder} built-in functions;
33385 see @ref{Other Builtins} for details.
33389 This option enables use of the @code{movbe} instruction to implement
33390 @code{__builtin_bswap32} and @code{__builtin_bswap64}.
33394 The @option{-mshstk} option enables shadow stack built-in functions
33395 from x86 Control-flow Enforcement Technology (CET).
33399 This option enables built-in functions @code{__builtin_ia32_crc32qi},
33400 @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
33401 @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
33405 This option enables built-in functions @code{__builtin_ia32_monitor},
33406 and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
33407 @code{mwait} machine instructions.
33411 This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
33412 (and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
33413 with an additional Newton-Raphson step
33414 to increase precision instead of @code{DIVSS} and @code{SQRTSS}
33415 (and their vectorized
33416 variants) for single-precision floating-point arguments. These instructions
33417 are generated only when @option{-funsafe-math-optimizations} is enabled
33418 together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
33419 Note that while the throughput of the sequence is higher than the throughput
33420 of the non-reciprocal instruction, the precision of the sequence can be
33421 decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
33423 Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
33424 (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
33425 combination), and doesn't need @option{-mrecip}.
33427 Also note that GCC emits the above sequence with additional Newton-Raphson step
33428 for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
33429 already with @option{-ffast-math} (or the above option combination), and
33430 doesn't need @option{-mrecip}.
33432 @item -mrecip=@var{opt}
33433 @opindex mrecip=opt
33434 This option controls which reciprocal estimate instructions
33435 may be used. @var{opt} is a comma-separated list of options, which may
33436 be preceded by a @samp{!} to invert the option:
33440 Enable all estimate instructions.
33443 Enable the default instructions, equivalent to @option{-mrecip}.
33446 Disable all estimate instructions, equivalent to @option{-mno-recip}.
33449 Enable the approximation for scalar division.
33452 Enable the approximation for vectorized division.
33455 Enable the approximation for scalar square root.
33458 Enable the approximation for vectorized square root.
33461 So, for example, @option{-mrecip=all,!sqrt} enables
33462 all of the reciprocal approximations, except for square root.
33464 @item -mveclibabi=@var{type}
33465 @opindex mveclibabi
33466 Specifies the ABI type to use for vectorizing intrinsics using an
33467 external library. Supported values for @var{type} are @samp{svml}
33468 for the Intel short
33469 vector math library and @samp{acml} for the AMD math core library.
33470 To use this option, both @option{-ftree-vectorize} and
33471 @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
33472 ABI-compatible library must be specified at link time.
33474 GCC currently emits calls to @code{vmldExp2},
33475 @code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
33476 @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
33477 @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
33478 @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
33479 @code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
33480 @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
33481 @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
33482 @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
33483 @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
33484 function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
33485 @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
33486 @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
33487 @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
33488 @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
33489 when @option{-mveclibabi=acml} is used.
33491 @item -mabi=@var{name}
33493 Generate code for the specified calling convention. Permissible values
33494 are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
33495 @samp{ms} for the Microsoft ABI. The default is to use the Microsoft
33496 ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
33497 You can control this behavior for specific functions by
33498 using the function attributes @code{ms_abi} and @code{sysv_abi}.
33499 @xref{Function Attributes}.
33501 @item -mforce-indirect-call
33502 @opindex mforce-indirect-call
33503 Force all calls to functions to be indirect. This is useful
33504 when using Intel Processor Trace where it generates more precise timing
33505 information for function calls.
33507 @item -mmanual-endbr
33508 @opindex mmanual-endbr
33509 Insert ENDBR instruction at function entry only via the @code{cf_check}
33510 function attribute. This is useful when used with the option
33511 @option{-fcf-protection=branch} to control ENDBR insertion at the
33515 @opindex mcet-switch
33516 By default, CET instrumentation is turned off on switch statements that
33517 use a jump table and indirect branch track is disabled. Since jump
33518 tables are stored in read-only memory, this does not result in a direct
33519 loss of hardening. But if the jump table index is attacker-controlled,
33520 the indirect jump may not be constrained by CET. This option turns on
33521 CET instrumentation to enable indirect branch track for switch statements
33522 with jump tables which leads to the jump targets reachable via any indirect
33525 @item -mcall-ms2sysv-xlogues
33526 @opindex mcall-ms2sysv-xlogues
33527 @opindex mno-call-ms2sysv-xlogues
33528 Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
33529 System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
33530 default, the code for saving and restoring these registers is emitted inline,
33531 resulting in fairly lengthy prologues and epilogues. Using
33532 @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
33533 use stubs in the static portion of libgcc to perform these saves and restores,
33534 thus reducing function size at the cost of a few extra instructions.
33536 @item -mtls-dialect=@var{type}
33537 @opindex mtls-dialect
33538 Generate code to access thread-local storage using the @samp{gnu} or
33539 @samp{gnu2} conventions. @samp{gnu} is the conservative default;
33540 @samp{gnu2} is more efficient, but it may add compile- and run-time
33541 requirements that cannot be satisfied on all systems.
33544 @itemx -mno-push-args
33545 @opindex mpush-args
33546 @opindex mno-push-args
33547 Use PUSH operations to store outgoing parameters. This method is shorter
33548 and usually equally fast as method using SUB/MOV operations and is enabled
33549 by default. In some cases disabling it may improve performance because of
33550 improved scheduling and reduced dependencies.
33552 @item -maccumulate-outgoing-args
33553 @opindex maccumulate-outgoing-args
33554 If enabled, the maximum amount of space required for outgoing arguments is
33555 computed in the function prologue. This is faster on most modern CPUs
33556 because of reduced dependencies, improved scheduling and reduced stack usage
33557 when the preferred stack boundary is not equal to 2. The drawback is a notable
33558 increase in code size. This switch implies @option{-mno-push-args}.
33562 Support thread-safe exception handling on MinGW. Programs that rely
33563 on thread-safe exception handling must compile and link all code with the
33564 @option{-mthreads} option. When compiling, @option{-mthreads} defines
33565 @option{-D_MT}; when linking, it links in a special thread helper library
33566 @option{-lmingwthrd} which cleans up per-thread exception-handling data.
33568 @item -mms-bitfields
33569 @itemx -mno-ms-bitfields
33570 @opindex mms-bitfields
33571 @opindex mno-ms-bitfields
33573 Enable/disable bit-field layout compatible with the native Microsoft
33576 If @code{packed} is used on a structure, or if bit-fields are used,
33577 it may be that the Microsoft ABI lays out the structure differently
33578 than the way GCC normally does. Particularly when moving packed
33579 data between functions compiled with GCC and the native Microsoft compiler
33580 (either via function call or as data in a file), it may be necessary to access
33583 This option is enabled by default for Microsoft Windows
33584 targets. This behavior can also be controlled locally by use of variable
33585 or type attributes. For more information, see @ref{x86 Variable Attributes}
33586 and @ref{x86 Type Attributes}.
33588 The Microsoft structure layout algorithm is fairly simple with the exception
33589 of the bit-field packing.
33590 The padding and alignment of members of structures and whether a bit-field
33591 can straddle a storage-unit boundary are determine by these rules:
33594 @item Structure members are stored sequentially in the order in which they are
33595 declared: the first member has the lowest memory address and the last member
33598 @item Every data object has an alignment requirement. The alignment requirement
33599 for all data except structures, unions, and arrays is either the size of the
33600 object or the current packing size (specified with either the
33601 @code{aligned} attribute or the @code{pack} pragma),
33602 whichever is less. For structures, unions, and arrays,
33603 the alignment requirement is the largest alignment requirement of its members.
33604 Every object is allocated an offset so that:
33607 offset % alignment_requirement == 0
33610 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
33611 unit if the integral types are the same size and if the next bit-field fits
33612 into the current allocation unit without crossing the boundary imposed by the
33613 common alignment requirements of the bit-fields.
33616 MSVC interprets zero-length bit-fields in the following ways:
33619 @item If a zero-length bit-field is inserted between two bit-fields that
33620 are normally coalesced, the bit-fields are not coalesced.
33627 unsigned long bf_1 : 12;
33629 unsigned long bf_2 : 12;
33634 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
33635 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
33637 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
33638 alignment of the zero-length bit-field is greater than the member that follows it,
33639 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
33660 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
33661 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
33662 bit-field does not affect the alignment of @code{bar} or, as a result, the size
33665 Taking this into account, it is important to note the following:
33668 @item If a zero-length bit-field follows a normal bit-field, the type of the
33669 zero-length bit-field may affect the alignment of the structure as whole. For
33670 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
33671 normal bit-field, and is of type short.
33673 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
33674 still affect the alignment of the structure:
33685 Here, @code{t4} takes up 4 bytes.
33688 @item Zero-length bit-fields following non-bit-field members are ignored:
33700 Here, @code{t5} takes up 2 bytes.
33704 @item -mno-align-stringops
33705 @opindex mno-align-stringops
33706 @opindex malign-stringops
33707 Do not align the destination of inlined string operations. This switch reduces
33708 code size and improves performance in case the destination is already aligned,
33709 but GCC doesn't know about it.
33711 @item -minline-all-stringops
33712 @opindex minline-all-stringops
33713 By default GCC inlines string operations only when the destination is
33714 known to be aligned to least a 4-byte boundary.
33715 This enables more inlining and increases code
33716 size, but may improve performance of code that depends on fast
33717 @code{memcpy} and @code{memset} for short lengths.
33718 The option enables inline expansion of @code{strlen} for all
33719 pointer alignments.
33721 @item -minline-stringops-dynamically
33722 @opindex minline-stringops-dynamically
33723 For string operations of unknown size, use run-time checks with
33724 inline code for small blocks and a library call for large blocks.
33726 @item -mstringop-strategy=@var{alg}
33727 @opindex mstringop-strategy=@var{alg}
33728 Override the internal decision heuristic for the particular algorithm to use
33729 for inlining string operations. The allowed values for @var{alg} are:
33735 Expand using i386 @code{rep} prefix of the specified size.
33739 @itemx unrolled_loop
33740 Expand into an inline loop.
33743 Always use a library call.
33746 @item -mmemcpy-strategy=@var{strategy}
33747 @opindex mmemcpy-strategy=@var{strategy}
33748 Override the internal decision heuristic to decide if @code{__builtin_memcpy}
33749 should be inlined and what inline algorithm to use when the expected size
33750 of the copy operation is known. @var{strategy}
33751 is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
33752 @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
33753 the max byte size with which inline algorithm @var{alg} is allowed. For the last
33754 triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
33755 in the list must be specified in increasing order. The minimal byte size for
33756 @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
33759 @item -mmemset-strategy=@var{strategy}
33760 @opindex mmemset-strategy=@var{strategy}
33761 The option is similar to @option{-mmemcpy-strategy=} except that it is to control
33762 @code{__builtin_memset} expansion.
33764 @item -momit-leaf-frame-pointer
33765 @opindex momit-leaf-frame-pointer
33766 Don't keep the frame pointer in a register for leaf functions. This
33767 avoids the instructions to save, set up, and restore frame pointers and
33768 makes an extra register available in leaf functions. The option
33769 @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
33770 which might make debugging harder.
33772 @item -mtls-direct-seg-refs
33773 @itemx -mno-tls-direct-seg-refs
33774 @opindex mtls-direct-seg-refs
33775 Controls whether TLS variables may be accessed with offsets from the
33776 TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
33777 or whether the thread base pointer must be added. Whether or not this
33778 is valid depends on the operating system, and whether it maps the
33779 segment to cover the entire TLS area.
33781 For systems that use the GNU C Library, the default is on.
33784 @itemx -mno-sse2avx
33786 Specify that the assembler should encode SSE instructions with VEX
33787 prefix. The option @option{-mavx} turns this on by default.
33792 If profiling is active (@option{-pg}), put the profiling
33793 counter call before the prologue.
33794 Note: On x86 architectures the attribute @code{ms_hook_prologue}
33795 isn't possible at the moment for @option{-mfentry} and @option{-pg}.
33797 @item -mrecord-mcount
33798 @itemx -mno-record-mcount
33799 @opindex mrecord-mcount
33800 If profiling is active (@option{-pg}), generate a __mcount_loc section
33801 that contains pointers to each profiling call. This is useful for
33802 automatically patching and out calls.
33805 @itemx -mno-nop-mcount
33806 @opindex mnop-mcount
33807 If profiling is active (@option{-pg}), generate the calls to
33808 the profiling functions as NOPs. This is useful when they
33809 should be patched in later dynamically. This is likely only
33810 useful together with @option{-mrecord-mcount}.
33812 @item -minstrument-return=@var{type}
33813 @opindex minstrument-return
33814 Instrument function exit in -pg -mfentry instrumented functions with
33815 call to specified function. This only instruments true returns ending
33816 with ret, but not sibling calls ending with jump. Valid types
33817 are @var{none} to not instrument, @var{call} to generate a call to __return__,
33818 or @var{nop5} to generate a 5 byte nop.
33820 @item -mrecord-return
33821 @itemx -mno-record-return
33822 @opindex mrecord-return
33823 Generate a __return_loc section pointing to all return instrumentation code.
33825 @item -mfentry-name=@var{name}
33826 @opindex mfentry-name
33827 Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
33829 @item -mfentry-section=@var{name}
33830 @opindex mfentry-section
33831 Set name of section to record -mrecord-mcount calls (default __mcount_loc).
33833 @item -mskip-rax-setup
33834 @itemx -mno-skip-rax-setup
33835 @opindex mskip-rax-setup
33836 When generating code for the x86-64 architecture with SSE extensions
33837 disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
33838 register when there are no variable arguments passed in vector registers.
33840 @strong{Warning:} Since RAX register is used to avoid unnecessarily
33841 saving vector registers on stack when passing variable arguments, the
33842 impacts of this option are callees may waste some stack space,
33843 misbehave or jump to a random location. GCC 4.4 or newer don't have
33844 those issues, regardless the RAX register value.
33847 @itemx -mno-8bit-idiv
33848 @opindex m8bit-idiv
33849 On some processors, like Intel Atom, 8-bit unsigned integer divide is
33850 much faster than 32-bit/64-bit integer divide. This option generates a
33851 run-time check. If both dividend and divisor are within range of 0
33852 to 255, 8-bit unsigned integer divide is used instead of
33853 32-bit/64-bit integer divide.
33855 @item -mavx256-split-unaligned-load
33856 @itemx -mavx256-split-unaligned-store
33857 @opindex mavx256-split-unaligned-load
33858 @opindex mavx256-split-unaligned-store
33859 Split 32-byte AVX unaligned load and store.
33861 @item -mstack-protector-guard=@var{guard}
33862 @itemx -mstack-protector-guard-reg=@var{reg}
33863 @itemx -mstack-protector-guard-offset=@var{offset}
33864 @opindex mstack-protector-guard
33865 @opindex mstack-protector-guard-reg
33866 @opindex mstack-protector-guard-offset
33867 Generate stack protection code using canary at @var{guard}. Supported
33868 locations are @samp{global} for global canary or @samp{tls} for per-thread
33869 canary in the TLS block (the default). This option has effect only when
33870 @option{-fstack-protector} or @option{-fstack-protector-all} is specified.
33872 With the latter choice the options
33873 @option{-mstack-protector-guard-reg=@var{reg}} and
33874 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
33875 which segment register (@code{%fs} or @code{%gs}) to use as base register
33876 for reading the canary, and from what offset from that base register.
33877 The default for those is as specified in the relevant ABI.
33879 @item -mgeneral-regs-only
33880 @opindex mgeneral-regs-only
33881 Generate code that uses only the general-purpose registers. This
33882 prevents the compiler from using floating-point, vector, mask and bound
33885 @item -mrelax-cmpxchg-loop
33886 @opindex mrelax-cmpxchg-loop
33887 When emitting a compare-and-swap loop for @ref{__sync Builtins}
33888 and @ref{__atomic Builtins} lacking a native instruction, optimize
33889 for the highly contended case by issuing an atomic load before the
33890 @code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
33891 to save CPU power when restarting the loop.
33893 @item -mindirect-branch=@var{choice}
33894 @opindex mindirect-branch
33895 Convert indirect call and jump with @var{choice}. The default is
33896 @samp{keep}, which keeps indirect call and jump unmodified.
33897 @samp{thunk} converts indirect call and jump to call and return thunk.
33898 @samp{thunk-inline} converts indirect call and jump to inlined call
33899 and return thunk. @samp{thunk-extern} converts indirect call and jump
33900 to external call and return thunk provided in a separate object file.
33901 You can control this behavior for a specific function by using the
33902 function attribute @code{indirect_branch}. @xref{Function Attributes}.
33904 Note that @option{-mcmodel=large} is incompatible with
33905 @option{-mindirect-branch=thunk} and
33906 @option{-mindirect-branch=thunk-extern} since the thunk function may
33907 not be reachable in the large code model.
33909 Note that @option{-mindirect-branch=thunk-extern} is compatible with
33910 @option{-fcf-protection=branch} since the external thunk can be made
33911 to enable control-flow check.
33913 @item -mfunction-return=@var{choice}
33914 @opindex mfunction-return
33915 Convert function return with @var{choice}. The default is @samp{keep},
33916 which keeps function return unmodified. @samp{thunk} converts function
33917 return to call and return thunk. @samp{thunk-inline} converts function
33918 return to inlined call and return thunk. @samp{thunk-extern} converts
33919 function return to external call and return thunk provided in a separate
33920 object file. You can control this behavior for a specific function by
33921 using the function attribute @code{function_return}.
33922 @xref{Function Attributes}.
33924 Note that @option{-mindirect-return=thunk-extern} is compatible with
33925 @option{-fcf-protection=branch} since the external thunk can be made
33926 to enable control-flow check.
33928 Note that @option{-mcmodel=large} is incompatible with
33929 @option{-mfunction-return=thunk} and
33930 @option{-mfunction-return=thunk-extern} since the thunk function may
33931 not be reachable in the large code model.
33934 @item -mindirect-branch-register
33935 @opindex mindirect-branch-register
33936 Force indirect call and jump via register.
33938 @item -mharden-sls=@var{choice}
33939 @opindex mharden-sls
33940 Generate code to mitigate against straight line speculation (SLS) with
33941 @var{choice}. The default is @samp{none} which disables all SLS
33942 hardening. @samp{return} enables SLS hardening for function returns.
33943 @samp{indirect-jmp} enables SLS hardening for indirect jumps.
33944 @samp{all} enables all SLS hardening.
33946 @item -mindirect-branch-cs-prefix
33947 @opindex mindirect-branch-cs-prefix
33948 Add CS prefix to call and jmp to indirect thunk with branch target in
33949 r8-r15 registers so that the call and jmp instruction length is 6 bytes
33950 to allow them to be replaced with @samp{lfence; call *%r8-r15} or
33951 @samp{lfence; jmp *%r8-r15} at run-time.
33955 These @samp{-m} switches are supported in addition to the above
33956 on x86-64 processors in 64-bit environments.
33969 Generate code for a 16-bit, 32-bit or 64-bit environment.
33970 The @option{-m32} option sets @code{int}, @code{long}, and pointer types
33972 generates code that runs on any i386 system.
33974 The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
33975 types to 64 bits, and generates code for the x86-64 architecture.
33976 For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
33977 and @option{-mdynamic-no-pic} options.
33979 The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
33981 generates code for the x86-64 architecture.
33983 The @option{-m16} option is the same as @option{-m32}, except for that
33984 it outputs the @code{.code16gcc} assembly directive at the beginning of
33985 the assembly output so that the binary can run in 16-bit mode.
33987 The @option{-miamcu} option generates code which conforms to Intel MCU
33988 psABI. It requires the @option{-m32} option to be turned on.
33990 @item -mno-red-zone
33991 @opindex mno-red-zone
33993 Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
33994 by the x86-64 ABI; it is a 128-byte area beyond the location of the
33995 stack pointer that is not modified by signal or interrupt handlers
33996 and therefore can be used for temporary data without adjusting the stack
33997 pointer. The flag @option{-mno-red-zone} disables this red zone.
33999 @item -mcmodel=small
34000 @opindex mcmodel=small
34001 Generate code for the small code model: the program and its symbols must
34002 be linked in the lower 2 GB of the address space. Pointers are 64 bits.
34003 Programs can be statically or dynamically linked. This is the default
34006 @item -mcmodel=kernel
34007 @opindex mcmodel=kernel
34008 Generate code for the kernel code model. The kernel runs in the
34009 negative 2 GB of the address space.
34010 This model has to be used for Linux kernel code.
34012 @item -mcmodel=medium
34013 @opindex mcmodel=medium
34014 Generate code for the medium model: the program is linked in the lower 2
34015 GB of the address space. Small symbols are also placed there. Symbols
34016 with sizes larger than @option{-mlarge-data-threshold} are put into
34017 large data or BSS sections and can be located above 2GB. Programs can
34018 be statically or dynamically linked.
34020 @item -mcmodel=large
34021 @opindex mcmodel=large
34022 Generate code for the large model. This model makes no assumptions
34023 about addresses and sizes of sections.
34025 @item -maddress-mode=long
34026 @opindex maddress-mode=long
34027 Generate code for long address mode. This is only supported for 64-bit
34028 and x32 environments. It is the default address mode for 64-bit
34031 @item -maddress-mode=short
34032 @opindex maddress-mode=short
34033 Generate code for short address mode. This is only supported for 32-bit
34034 and x32 environments. It is the default address mode for 32-bit and
34040 Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
34041 indicate the micro-architecture ISA level required to execute the binary.
34043 @item -mno-direct-extern-access
34044 @opindex mno-direct-extern-access
34045 @opindex mdirect-extern-access
34046 Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
34047 to access external symbols. With @option{-fpic} or @option{-fPIC},
34048 treat access to protected symbols as local symbols. The default is
34049 @option{-mdirect-extern-access}.
34051 @strong{Warning:} shared libraries compiled with
34052 @option{-mno-direct-extern-access} and executable compiled with
34053 @option{-mdirect-extern-access} may not be binary compatible if
34054 protected symbols are used in shared libraries and executable.
34056 @item -munroll-only-small-loops
34057 @opindex munroll-only-small-loops
34058 @opindex mno-unroll-only-small-loops
34059 Controls conservative small loop unrolling. It is default enabled by
34060 O2, and unrolls loop with less than 4 insns by 1 time. Explicit
34061 -f[no-]unroll-[all-]loops would disable this flag to avoid any
34062 unintended unrolling behavior that user does not want.
34064 @item -mlam=@var{choice}
34066 LAM(linear-address masking) allows special bits in the pointer to be used
34067 for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
34068 positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
34069 positions 62:57 can be used for metadata.
34072 @node x86 Windows Options
34073 @subsection x86 Windows Options
34074 @cindex x86 Windows Options
34075 @cindex Windows Options for x86
34077 These additional options are available for Microsoft Windows targets:
34083 specifies that a console application is to be generated, by
34084 instructing the linker to set the PE header subsystem type
34085 required for console applications.
34086 This option is available for Cygwin and MinGW targets and is
34087 enabled by default on those targets.
34091 This option is available for Cygwin and MinGW targets. It
34092 specifies that a DLL---a dynamic link library---is to be
34093 generated, enabling the selection of the required runtime
34094 startup object and entry point.
34096 @item -mnop-fun-dllimport
34097 @opindex mnop-fun-dllimport
34098 This option is available for Cygwin and MinGW targets. It
34099 specifies that the @code{dllimport} attribute should be ignored.
34103 This option is available for MinGW targets. It specifies
34104 that MinGW-specific thread support is to be used.
34108 This option is available for MinGW-w64 targets. It causes
34109 the @code{UNICODE} preprocessor macro to be predefined, and
34110 chooses Unicode-capable runtime startup code.
34114 This option is available for Cygwin and MinGW targets. It
34115 specifies that the typical Microsoft Windows predefined macros are to
34116 be set in the pre-processor, but does not influence the choice
34117 of runtime library/startup code.
34121 This option is available for Cygwin and MinGW targets. It
34122 specifies that a GUI application is to be generated by
34123 instructing the linker to set the PE header subsystem type
34126 @item -fno-set-stack-executable
34127 @opindex fno-set-stack-executable
34128 @opindex fset-stack-executable
34129 This option is available for MinGW targets. It specifies that
34130 the executable flag for the stack used by nested functions isn't
34131 set. This is necessary for binaries running in kernel mode of
34132 Microsoft Windows, as there the User32 API, which is used to set executable
34133 privileges, isn't available.
34135 @item -fwritable-relocated-rdata
34136 @opindex fno-writable-relocated-rdata
34137 @opindex fwritable-relocated-rdata
34138 This option is available for MinGW and Cygwin targets. It specifies
34139 that relocated-data in read-only section is put into the @code{.data}
34140 section. This is a necessary for older runtimes not supporting
34141 modification of @code{.rdata} sections for pseudo-relocation.
34143 @item -mpe-aligned-commons
34144 @opindex mpe-aligned-commons
34145 This option is available for Cygwin and MinGW targets. It
34146 specifies that the GNU extension to the PE file format that
34147 permits the correct alignment of COMMON variables should be
34148 used when generating code. It is enabled by default if
34149 GCC detects that the target assembler found during configuration
34150 supports the feature.
34153 See also under @ref{x86 Options} for standard options.
34155 @node Xstormy16 Options
34156 @subsection Xstormy16 Options
34157 @cindex Xstormy16 Options
34159 These options are defined for Xstormy16:
34164 Choose startup files and linker script suitable for the simulator.
34167 @node Xtensa Options
34168 @subsection Xtensa Options
34169 @cindex Xtensa Options
34171 These options are supported for Xtensa targets:
34175 @itemx -mno-const16
34177 @opindex mno-const16
34178 Enable or disable use of @code{CONST16} instructions for loading
34179 constant values. The @code{CONST16} instruction is currently not a
34180 standard option from Tensilica. When enabled, @code{CONST16}
34181 instructions are always used in place of the standard @code{L32R}
34182 instructions. The use of @code{CONST16} is enabled by default only if
34183 the @code{L32R} instruction is not available.
34186 @itemx -mno-fused-madd
34187 @opindex mfused-madd
34188 @opindex mno-fused-madd
34189 Enable or disable use of fused multiply/add and multiply/subtract
34190 instructions in the floating-point option. This has no effect if the
34191 floating-point option is not also enabled. Disabling fused multiply/add
34192 and multiply/subtract instructions forces the compiler to use separate
34193 instructions for the multiply and add/subtract operations. This may be
34194 desirable in some cases where strict IEEE 754-compliant results are
34195 required: the fused multiply add/subtract instructions do not round the
34196 intermediate result, thereby producing results with @emph{more} bits of
34197 precision than specified by the IEEE standard. Disabling fused multiply
34198 add/subtract instructions also ensures that the program output is not
34199 sensitive to the compiler's ability to combine multiply and add/subtract
34202 @item -mserialize-volatile
34203 @itemx -mno-serialize-volatile
34204 @opindex mserialize-volatile
34205 @opindex mno-serialize-volatile
34206 When this option is enabled, GCC inserts @code{MEMW} instructions before
34207 @code{volatile} memory references to guarantee sequential consistency.
34208 The default is @option{-mserialize-volatile}. Use
34209 @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
34211 @item -mforce-no-pic
34212 @opindex mforce-no-pic
34213 For targets, like GNU/Linux, where all user-mode Xtensa code must be
34214 position-independent code (PIC), this option disables PIC for compiling
34217 @item -mtext-section-literals
34218 @itemx -mno-text-section-literals
34219 @opindex mtext-section-literals
34220 @opindex mno-text-section-literals
34221 These options control the treatment of literal pools. The default is
34222 @option{-mno-text-section-literals}, which places literals in a separate
34223 section in the output file. This allows the literal pool to be placed
34224 in a data RAM/ROM, and it also allows the linker to combine literal
34225 pools from separate object files to remove redundant literals and
34226 improve code size. With @option{-mtext-section-literals}, the literals
34227 are interspersed in the text section in order to keep them as close as
34228 possible to their references. This may be necessary for large assembly
34229 files. Literals for each function are placed right before that function.
34231 @item -mauto-litpools
34232 @itemx -mno-auto-litpools
34233 @opindex mauto-litpools
34234 @opindex mno-auto-litpools
34235 These options control the treatment of literal pools. The default is
34236 @option{-mno-auto-litpools}, which places literals in a separate
34237 section in the output file unless @option{-mtext-section-literals} is
34238 used. With @option{-mauto-litpools} the literals are interspersed in
34239 the text section by the assembler. Compiler does not produce explicit
34240 @code{.literal} directives and loads literals into registers with
34241 @code{MOVI} instructions instead of @code{L32R} to let the assembler
34242 do relaxation and place literals as necessary. This option allows
34243 assembler to create several literal pools per function and assemble
34244 very big functions, which may not be possible with
34245 @option{-mtext-section-literals}.
34247 @item -mtarget-align
34248 @itemx -mno-target-align
34249 @opindex mtarget-align
34250 @opindex mno-target-align
34251 When this option is enabled, GCC instructs the assembler to
34252 automatically align instructions to reduce branch penalties at the
34253 expense of some code density. The assembler attempts to widen density
34254 instructions to align branch targets and the instructions following call
34255 instructions. If there are not enough preceding safe density
34256 instructions to align a target, no widening is performed. The
34257 default is @option{-mtarget-align}. These options do not affect the
34258 treatment of auto-aligned instructions like @code{LOOP}, which the
34259 assembler always aligns, either by widening density instructions or
34260 by inserting NOP instructions.
34263 @itemx -mno-longcalls
34264 @opindex mlongcalls
34265 @opindex mno-longcalls
34266 When this option is enabled, GCC instructs the assembler to translate
34267 direct calls to indirect calls unless it can determine that the target
34268 of a direct call is in the range allowed by the call instruction. This
34269 translation typically occurs for calls to functions in other source
34270 files. Specifically, the assembler translates a direct @code{CALL}
34271 instruction into an @code{L32R} followed by a @code{CALLX} instruction.
34272 The default is @option{-mno-longcalls}. This option should be used in
34273 programs where the call target can potentially be out of range. This
34274 option is implemented in the assembler, not the compiler, so the
34275 assembly code generated by GCC still shows direct call
34276 instructions---look at the disassembled object code to see the actual
34277 instructions. Note that the assembler uses an indirect call for
34278 every cross-file call, not just those that really are out of range.
34280 @item -mabi=@var{name}
34282 Generate code for the specified ABI@. Permissible values are: @samp{call0},
34283 @samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
34286 @opindex mabi=call0
34287 When this option is enabled function parameters are passed in registers
34288 @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
34289 caller-saved, and register @code{a15} may be used as a frame pointer.
34290 When this version of the ABI is enabled the C preprocessor symbol
34291 @code{__XTENSA_CALL0_ABI__} is defined.
34293 @item -mabi=windowed
34294 @opindex mabi=windowed
34295 When this option is enabled function parameters are passed in registers
34296 @code{a10} through @code{a15}, and called function rotates register window
34297 by 8 registers on entry so that its arguments are found in registers
34298 @code{a2} through @code{a7}. Register @code{a7} may be used as a frame
34299 pointer. Register window is rotated 8 registers back upon return.
34300 When this version of the ABI is enabled the C preprocessor symbol
34301 @code{__XTENSA_WINDOWED_ABI__} is defined.
34303 @item -mextra-l32r-costs=@var{n}
34304 @opindex mextra-l32r-costs
34305 Specify an extra cost of instruction RAM/ROM access for @code{L32R}
34306 instructions, in clock cycles. This affects, when optimizing for speed,
34307 whether loading a constant from literal pool using @code{L32R} or
34308 synthesizing the constant from a small one with a couple of arithmetic
34309 instructions. The default value is 0.
34312 @node zSeries Options
34313 @subsection zSeries Options
34314 @cindex zSeries options
34316 These are listed under @xref{S/390 and zSeries Options}.
34322 @section Specifying Subprocesses and the Switches to Pass to Them
34325 @command{gcc} is a driver program. It performs its job by invoking a
34326 sequence of other programs to do the work of compiling, assembling and
34327 linking. GCC interprets its command-line parameters and uses these to
34328 deduce which programs it should invoke, and which command-line options
34329 it ought to place on their command lines. This behavior is controlled
34330 by @dfn{spec strings}. In most cases there is one spec string for each
34331 program that GCC can invoke, but a few programs have multiple spec
34332 strings to control their behavior. The spec strings built into GCC can
34333 be overridden by using the @option{-specs=} command-line switch to specify
34336 @dfn{Spec files} are plain-text files that are used to construct spec
34337 strings. They consist of a sequence of directives separated by blank
34338 lines. The type of directive is determined by the first non-whitespace
34339 character on the line, which can be one of the following:
34342 @item %@var{command}
34343 Issues a @var{command} to the spec file processor. The commands that can
34347 @item %include <@var{file}>
34348 @cindex @code{%include}
34349 Search for @var{file} and insert its text at the current point in the
34352 @item %include_noerr <@var{file}>
34353 @cindex @code{%include_noerr}
34354 Just like @samp{%include}, but do not generate an error message if the include
34355 file cannot be found.
34357 @item %rename @var{old_name} @var{new_name}
34358 @cindex @code{%rename}
34359 Rename the spec string @var{old_name} to @var{new_name}.
34363 @item *[@var{spec_name}]:
34364 This tells the compiler to create, override or delete the named spec
34365 string. All lines after this directive up to the next directive or
34366 blank line are considered to be the text for the spec string. If this
34367 results in an empty string then the spec is deleted. (Or, if the
34368 spec did not exist, then nothing happens.) Otherwise, if the spec
34369 does not currently exist a new spec is created. If the spec does
34370 exist then its contents are overridden by the text of this
34371 directive, unless the first character of that text is the @samp{+}
34372 character, in which case the text is appended to the spec.
34374 @item [@var{suffix}]:
34375 Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
34376 and up to the next directive or blank line are considered to make up the
34377 spec string for the indicated suffix. When the compiler encounters an
34378 input file with the named suffix, it processes the spec string in
34379 order to work out how to compile that file. For example:
34383 z-compile -input %i
34386 This says that any input file whose name ends in @samp{.ZZ} should be
34387 passed to the program @samp{z-compile}, which should be invoked with the
34388 command-line switch @option{-input} and with the result of performing the
34389 @samp{%i} substitution. (See below.)
34391 As an alternative to providing a spec string, the text following a
34392 suffix directive can be one of the following:
34395 @item @@@var{language}
34396 This says that the suffix is an alias for a known @var{language}. This is
34397 similar to using the @option{-x} command-line switch to GCC to specify a
34398 language explicitly. For example:
34405 Says that .ZZ files are, in fact, C++ source files.
34408 This causes an error messages saying:
34411 @var{name} compiler not installed on this system.
34415 GCC already has an extensive list of suffixes built into it.
34416 This directive adds an entry to the end of the list of suffixes, but
34417 since the list is searched from the end backwards, it is effectively
34418 possible to override earlier entries using this technique.
34422 GCC has the following spec strings built into it. Spec files can
34423 override these strings or create their own. Note that individual
34424 targets can also add their own spec strings to this list.
34427 asm Options to pass to the assembler
34428 asm_final Options to pass to the assembler post-processor
34429 cpp Options to pass to the C preprocessor
34430 cc1 Options to pass to the C compiler
34431 cc1plus Options to pass to the C++ compiler
34432 endfile Object files to include at the end of the link
34433 link Options to pass to the linker
34434 lib Libraries to include on the command line to the linker
34435 libgcc Decides which GCC support library to pass to the linker
34436 linker Sets the name of the linker
34437 predefines Defines to be passed to the C preprocessor
34438 signed_char Defines to pass to CPP to say whether @code{char} is signed
34440 startfile Object files to include at the start of the link
34443 Here is a small example of a spec file:
34446 %rename lib old_lib
34449 --start-group -lgcc -lc -leval1 --end-group %(old_lib)
34452 This example renames the spec called @samp{lib} to @samp{old_lib} and
34453 then overrides the previous definition of @samp{lib} with a new one.
34454 The new definition adds in some extra command-line options before
34455 including the text of the old definition.
34457 @dfn{Spec strings} are a list of command-line options to be passed to their
34458 corresponding program. In addition, the spec strings can contain
34459 @samp{%}-prefixed sequences to substitute variable text or to
34460 conditionally insert text into the command line. Using these constructs
34461 it is possible to generate quite complex command lines.
34463 Here is a table of all defined @samp{%}-sequences for spec
34464 strings. Note that spaces are not generated automatically around the
34465 results of expanding these sequences. Therefore you can concatenate them
34466 together or combine them with constant text in a single argument.
34470 Substitute one @samp{%} into the program name or argument.
34473 Substitute an empty argument.
34476 Substitute the name of the input file being processed.
34479 Substitute the basename for outputs related with the input file being
34480 processed. This is often the substring up to (and not including) the
34481 last period and not including the directory but, unless %w is active, it
34482 expands to the basename for auxiliary outputs, which may be influenced
34483 by an explicit output name, and by various other options that control
34484 how auxiliary outputs are named.
34487 This is the same as @samp{%b}, but include the file suffix (text after
34488 the last period). Without %w, it expands to the basename for dump
34492 Marks the argument containing or following the @samp{%d} as a
34493 temporary file name, so that that file is deleted if GCC exits
34494 successfully. Unlike @samp{%g}, this contributes no text to the
34497 @item %g@var{suffix}
34498 Substitute a file name that has suffix @var{suffix} and is chosen
34499 once per compilation, and mark the argument in the same way as
34500 @samp{%d}. To reduce exposure to denial-of-service attacks, the file
34501 name is now chosen in a way that is hard to predict even when previously
34502 chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
34503 might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
34504 the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
34505 treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
34506 was simply substituted with a file name chosen once per compilation,
34507 without regard to any appended suffix (which was therefore treated
34508 just like ordinary text), making such attacks more likely to succeed.
34510 @item %u@var{suffix}
34511 Like @samp{%g}, but generates a new temporary file name
34512 each time it appears instead of once per compilation.
34514 @item %U@var{suffix}
34515 Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
34516 new one if there is no such last file name. In the absence of any
34517 @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
34518 the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
34519 involves the generation of two distinct file names, one
34520 for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
34521 simply substituted with a file name chosen for the previous @samp{%u},
34522 without regard to any appended suffix.
34524 @item %j@var{suffix}
34525 Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
34526 writable, and if @option{-save-temps} is not used;
34527 otherwise, substitute the name
34528 of a temporary file, just like @samp{%u}. This temporary file is not
34529 meant for communication between processes, but rather as a junk
34530 disposal mechanism.
34532 @item %|@var{suffix}
34533 @itemx %m@var{suffix}
34534 Like @samp{%g}, except if @option{-pipe} is in effect. In that case
34535 @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
34536 all. These are the two most common ways to instruct a program that it
34537 should read from standard input or write to standard output. If you
34538 need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
34539 construct: see for example @file{gcc/fortran/lang-specs.h}.
34541 @item %.@var{SUFFIX}
34542 Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
34543 when it is subsequently output with @samp{%*}. @var{SUFFIX} is
34544 terminated by the next space or %.
34547 Marks the argument containing or following the @samp{%w} as the
34548 designated output file of this compilation. This puts the argument
34549 into the sequence of arguments that @samp{%o} substitutes.
34552 Indicates that this compilation produces no output file.
34555 Substitutes the names of all the output files, with spaces
34556 automatically placed around them. You should write spaces
34557 around the @samp{%o} as well or the results are undefined.
34558 @samp{%o} is for use in the specs for running the linker.
34559 Input files whose names have no recognized suffix are not compiled
34560 at all, but they are included among the output files, so they are
34564 Substitutes the suffix for object files. Note that this is
34565 handled specially when it immediately follows @samp{%g, %u, or %U},
34566 because of the need for those to form complete file names. The
34567 handling is such that @samp{%O} is treated exactly as if it had already
34568 been substituted, except that @samp{%g, %u, and %U} do not currently
34569 support additional @var{suffix} characters following @samp{%O} as they do
34570 following, for example, @samp{.o}.
34573 Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
34574 @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
34575 @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
34576 and @option{-imultilib} as necessary.
34579 Current argument is the name of a library or startup file of some sort.
34580 Search for that file in a standard list of directories and substitute
34581 the full name found. The current working directory is included in the
34582 list of directories scanned.
34585 Current argument is the name of a linker script. Search for that file
34586 in the current list of directories to scan for libraries. If the file
34587 is located insert a @option{--script} option into the command line
34588 followed by the full path name found. If the file is not found then
34589 generate an error message. Note: the current working directory is not
34593 Print @var{str} as an error message. @var{str} is terminated by a newline.
34594 Use this when inconsistent options are detected.
34597 Print @var{str} as a notice. @var{str} is terminated by a newline.
34599 @item %(@var{name})
34600 Substitute the contents of spec string @var{name} at this point.
34602 @item %x@{@var{option}@}
34603 Accumulate an option for @samp{%X}.
34606 Output the accumulated linker options specified by a @samp{%x} spec string.
34609 Output the accumulated assembler options specified by @option{-Wa}.
34612 Output the accumulated preprocessor options specified by @option{-Wp}.
34615 Output @code{multilib_os_dir}.
34618 Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
34621 Process the @code{asm} spec. This is used to compute the
34622 switches to be passed to the assembler.
34625 Process the @code{asm_final} spec. This is a spec string for
34626 passing switches to an assembler post-processor, if such a program is
34630 Process the @code{link} spec. This is the spec for computing the
34631 command line passed to the linker. Typically it makes use of the
34632 @samp{%L %G %S %D and %E} sequences.
34635 Dump out a @option{-L} option for each directory that GCC believes might
34636 contain startup files. If the target supports multilibs then the
34637 current multilib directory is prepended to each of these paths.
34640 Process the @code{lib} spec. This is a spec string for deciding which
34641 libraries are included on the command line to the linker.
34644 Process the @code{libgcc} spec. This is a spec string for deciding
34645 which GCC support library is included on the command line to the linker.
34648 Process the @code{startfile} spec. This is a spec for deciding which
34649 object files are the first ones passed to the linker. Typically
34650 this might be a file named @file{crt0.o}.
34653 Process the @code{endfile} spec. This is a spec string that specifies
34654 the last object files that are passed to the linker.
34657 Process the @code{cpp} spec. This is used to construct the arguments
34658 to be passed to the C preprocessor.
34661 Process the @code{cc1} spec. This is used to construct the options to be
34662 passed to the actual C compiler (@command{cc1}).
34665 Process the @code{cc1plus} spec. This is used to construct the options to be
34666 passed to the actual C++ compiler (@command{cc1plus}).
34669 Substitute the variable part of a matched option. See below.
34670 Note that each comma in the substituted string is replaced by
34674 Remove all occurrences of @code{-S} from the command line. Note---this
34675 command is position dependent. @samp{%} commands in the spec string
34676 before this one see @code{-S}, @samp{%} commands in the spec string
34677 after this one do not.
34680 Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
34683 Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
34685 @item %:@var{function}(@var{args})
34686 Call the named function @var{function}, passing it @var{args}.
34687 @var{args} is first processed as a nested spec string, then split
34688 into an argument vector in the usual fashion. The function returns
34689 a string which is processed as if it had appeared literally as part
34690 of the current spec.
34692 The following built-in spec functions are provided:
34695 @item @code{getenv}
34696 The @code{getenv} spec function takes two arguments: an environment
34697 variable name and a string. If the environment variable is not
34698 defined, a fatal error is issued. Otherwise, the return value is the
34699 value of the environment variable concatenated with the string. For
34700 example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
34703 %:getenv(TOPDIR /include)
34706 expands to @file{/path/to/top/include}.
34708 @item @code{if-exists}
34709 The @code{if-exists} spec function takes one argument, an absolute
34710 pathname to a file. If the file exists, @code{if-exists} returns the
34711 pathname. Here is a small example of its usage:
34715 crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
34718 @item @code{if-exists-else}
34719 The @code{if-exists-else} spec function is similar to the @code{if-exists}
34720 spec function, except that it takes two arguments. The first argument is
34721 an absolute pathname to a file. If the file exists, @code{if-exists-else}
34722 returns the pathname. If it does not exist, it returns the second argument.
34723 This way, @code{if-exists-else} can be used to select one file or another,
34724 based on the existence of the first. Here is a small example of its usage:
34728 crt0%O%s %:if-exists(crti%O%s) \
34729 %:if-exists-else(crtbeginT%O%s crtbegin%O%s)
34732 @item @code{if-exists-then-else}
34733 The @code{if-exists-then-else} spec function takes at least two arguments
34734 and an optional third one. The first argument is an absolute pathname to a
34735 file. If the file exists, the function returns the second argument.
34736 If the file does not exist, the function returns the third argument if there
34737 is one, or NULL otherwise. This can be used to expand one text, or optionally
34738 another, based on the existence of a file. Here is a small example of its
34742 -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
34745 @item @code{sanitize}
34746 The @code{sanitize} spec function takes no arguments. It returns non-NULL if
34747 any address, thread or undefined behavior sanitizers are active.
34750 %@{%:sanitize(address):-funwind-tables@}
34753 @item @code{replace-outfile}
34754 The @code{replace-outfile} spec function takes two arguments. It looks for the
34755 first argument in the outfiles array and replaces it with the second argument. Here
34756 is a small example of its usage:
34759 %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
34762 @item @code{remove-outfile}
34763 The @code{remove-outfile} spec function takes one argument. It looks for the
34764 first argument in the outfiles array and removes it. Here is a small example
34768 %:remove-outfile(-lm)
34771 @item @code{version-compare}
34772 The @code{version-compare} spec function takes four or five arguments of the following
34776 <comparison-op> <arg1> [<arg2>] <switch> <result>
34779 It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
34780 The supported @code{comparison-op} values are:
34784 True if @code{switch} is a later (or same) version than @code{arg1}
34787 Opposite of @code{>=}
34790 True if @code{switch} is an earlier version than @code{arg1}
34793 Opposite of @code{<}
34796 True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
34799 True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
34802 If the @code{switch} is not present at all, the condition is false unless the first character
34803 of the @code{comparison-op} is @code{!}.
34806 %:version-compare(>= 10.3 mmacosx-version-min= -lmx)
34809 The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
34812 @item @code{include}
34813 The @code{include} spec function behaves much like @code{%include}, with the advantage
34814 that it can be nested inside a spec and thus be conditionalized. It takes one argument,
34815 the filename, and looks for it in the startfile path. It always returns NULL.
34818 %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
34821 @item @code{pass-through-libs}
34822 The @code{pass-through-libs} spec function takes any number of arguments. It
34823 finds any @option{-l} options and any non-options ending in @file{.a} (which it
34824 assumes are the names of linker input library archive files) and returns a
34825 result containing all the found arguments each prepended by
34826 @option{-plugin-opt=-pass-through=} and joined by spaces. This list is
34827 intended to be passed to the LTO linker plugin.
34830 %:pass-through-libs(%G %L %G)
34833 @item @code{print-asm-header}
34834 The @code{print-asm-header} function takes no arguments and simply
34835 prints a banner like:
34841 Use "-Wa,OPTION" to pass "OPTION" to the assembler.
34844 It is used to separate compiler options from assembler options
34845 in the @option{--target-help} output.
34848 The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
34849 empty string) if the second-to-last argument is greater than the last argument, and NULL
34850 otherwise. The following example inserts the @code{link_gomp} spec if the last
34851 @option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
34854 %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
34857 @item @code{debug-level-gt}
34858 The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
34859 empty string) if @code{debug_info_level} is greater than the specified number, and NULL
34863 %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
34868 Substitutes the @code{-S} switch, if that switch is given to GCC@.
34869 If that switch is not specified, this substitutes nothing. Note that
34870 the leading dash is omitted when specifying this option, and it is
34871 automatically inserted if the substitution is performed. Thus the spec
34872 string @samp{%@{foo@}} matches the command-line option @option{-foo}
34873 and outputs the command-line option @option{-foo}.
34876 Like %@{@code{S}@} but mark last argument supplied within as a file to be
34877 deleted on failure.
34880 Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
34881 @code{@@FILE} if an @code{@@file} argument has been supplied.
34884 Substitutes all the switches specified to GCC whose names start
34885 with @code{-S}, but which also take an argument. This is used for
34886 switches like @option{-o}, @option{-D}, @option{-I}, etc.
34887 GCC considers @option{-o foo} as being
34888 one switch whose name starts with @samp{o}. %@{o*@} substitutes this
34889 text, including the space. Thus two arguments are generated.
34892 Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
34893 (the order of @code{S} and @code{T} in the spec is not significant).
34894 There can be any number of ampersand-separated variables; for each the
34895 wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
34898 Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
34901 Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
34904 Substitutes @code{X} if one or more switches whose names start with
34905 @code{-S} are specified to GCC@. Normally @code{X} is substituted only
34906 once, no matter how many such switches appeared. However, if @code{%*}
34907 appears somewhere in @code{X}, then @code{X} is substituted once
34908 for each matching switch, with the @code{%*} replaced by the part of
34909 that switch matching the @code{*}.
34911 If @code{%*} appears as the last part of a spec sequence then a space
34912 is added after the end of the last substitution. If there is more
34913 text in the sequence, however, then a space is not generated. This
34914 allows the @code{%*} substitution to be used as part of a larger
34915 string. For example, a spec string like this:
34918 %@{mcu=*:--script=%*/memory.ld@}
34922 when matching an option like @option{-mcu=newchip} produces:
34925 --script=newchip/memory.ld
34929 Substitutes @code{X}, if processing a file with suffix @code{S}.
34932 Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
34935 Substitutes @code{X}, if processing a file for language @code{S}.
34938 Substitutes @code{X}, if not processing a file for language @code{S}.
34941 Substitutes @code{X} if either @code{-S} or @code{-P} is given to
34942 GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
34943 @code{*} sequences as well, although they have a stronger binding than
34944 the @samp{|}. If @code{%*} appears in @code{X}, all of the
34945 alternatives must be starred, and only the first matching alternative
34948 For example, a spec string like this:
34951 %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
34955 outputs the following command-line options from the following input
34956 command-line options:
34961 -d fred.c -foo -baz -boggle
34962 -d jim.d -bar -baz -boggle
34965 @item %@{%:@var{function}(@var{args}):X@}
34967 Call function named @var{function} with args @var{args}. If the
34968 function returns non-NULL, then @code{X} is substituted, if it returns
34969 NULL, it isn't substituted.
34971 @item %@{S:X; T:Y; :D@}
34973 If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
34974 given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
34975 be as many clauses as you need. This may be combined with @code{.},
34976 @code{,}, @code{!}, @code{|}, and @code{*} as needed.
34981 The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
34982 or similar construct can use a backslash to ignore the special meaning
34983 of the character following it, thus allowing literal matching of a
34984 character that is otherwise specially treated. For example,
34985 @samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
34986 @option{-std=iso9899:1999} option is given.
34988 The conditional text @code{X} in a @samp{%@{S:X@}} or similar
34989 construct may contain other nested @samp{%} constructs or spaces, or
34990 even newlines. They are processed as usual, as described above.
34991 Trailing white space in @code{X} is ignored. White space may also
34992 appear anywhere on the left side of the colon in these constructs,
34993 except between @code{.} or @code{*} and the corresponding word.
34995 The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
34996 handled specifically in these constructs. If another value of
34997 @option{-O} or the negated form of a @option{-f}, @option{-m}, or
34998 @option{-W} switch is found later in the command line, the earlier
34999 switch value is ignored, except with @{@code{S}*@} where @code{S} is
35000 just one letter, which passes all matching options.
35002 The character @samp{|} at the beginning of the predicate text is used to
35003 indicate that a command should be piped to the following command, but
35004 only if @option{-pipe} is specified.
35006 It is built into GCC which switches take arguments and which do not.
35007 (You might think it would be useful to generalize this to allow each
35008 compiler's spec to say which switches take arguments. But this cannot
35009 be done in a consistent fashion. GCC cannot even decide which input
35010 files have been specified without knowing which switches take arguments,
35011 and it must know which input files to compile in order to tell which
35014 GCC also knows implicitly that arguments starting in @option{-l} are to be
35015 treated as compiler output files, and passed to the linker in their
35016 proper position among the other output files.
35018 @node Environment Variables
35019 @section Environment Variables Affecting GCC
35020 @cindex environment variables
35022 @c man begin ENVIRONMENT
35023 This section describes several environment variables that affect how GCC
35024 operates. Some of them work by specifying directories or prefixes to use
35025 when searching for various kinds of files. Some are used to specify other
35026 aspects of the compilation environment.
35028 Note that you can also specify places to search using options such as
35029 @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
35030 take precedence over places specified using environment variables, which
35031 in turn take precedence over those specified by the configuration of GCC@.
35032 @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
35033 GNU Compiler Collection (GCC) Internals}.
35038 @c @itemx LC_COLLATE
35040 @c @itemx LC_MONETARY
35041 @c @itemx LC_NUMERIC
35046 @c @findex LC_COLLATE
35047 @findex LC_MESSAGES
35048 @c @findex LC_MONETARY
35049 @c @findex LC_NUMERIC
35053 These environment variables control the way that GCC uses
35054 localization information which allows GCC to work with different
35055 national conventions. GCC inspects the locale categories
35056 @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
35057 so. These locale categories can be set to any value supported by your
35058 installation. A typical value is @samp{en_GB.UTF-8} for English in the United
35059 Kingdom encoded in UTF-8.
35061 The @env{LC_CTYPE} environment variable specifies character
35062 classification. GCC uses it to determine the character boundaries in
35063 a string; this is needed for some multibyte encodings that contain quote
35064 and escape characters that are otherwise interpreted as a string
35067 The @env{LC_MESSAGES} environment variable specifies the language to
35068 use in diagnostic messages.
35070 If the @env{LC_ALL} environment variable is set, it overrides the value
35071 of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
35072 and @env{LC_MESSAGES} default to the value of the @env{LANG}
35073 environment variable. If none of these variables are set, GCC
35074 defaults to traditional C English behavior.
35078 If @env{TMPDIR} is set, it specifies the directory to use for temporary
35079 files. GCC uses temporary files to hold the output of one stage of
35080 compilation which is to be used as input to the next stage: for example,
35081 the output of the preprocessor, which is the input to the compiler
35084 @item GCC_COMPARE_DEBUG
35085 @findex GCC_COMPARE_DEBUG
35086 Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
35087 @option{-fcompare-debug} to the compiler driver. See the documentation
35088 of this option for more details.
35090 @item GCC_EXEC_PREFIX
35091 @findex GCC_EXEC_PREFIX
35092 If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
35093 names of the subprograms executed by the compiler. No slash is added
35094 when this prefix is combined with the name of a subprogram, but you can
35095 specify a prefix that ends with a slash if you wish.
35097 If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
35098 an appropriate prefix to use based on the pathname it is invoked with.
35100 If GCC cannot find the subprogram using the specified prefix, it
35101 tries looking in the usual places for the subprogram.
35103 The default value of @env{GCC_EXEC_PREFIX} is
35104 @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
35105 the installed compiler. In many cases @var{prefix} is the value
35106 of @code{prefix} when you ran the @file{configure} script.
35108 Other prefixes specified with @option{-B} take precedence over this prefix.
35110 This prefix is also used for finding files such as @file{crt0.o} that are
35113 In addition, the prefix is used in an unusual way in finding the
35114 directories to search for header files. For each of the standard
35115 directories whose name normally begins with @samp{/usr/local/lib/gcc}
35116 (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
35117 replacing that beginning with the specified prefix to produce an
35118 alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
35119 @file{foo/bar} just before it searches the standard directory
35120 @file{/usr/local/lib/bar}.
35121 If a standard directory begins with the configured
35122 @var{prefix} then the value of @var{prefix} is replaced by
35123 @env{GCC_EXEC_PREFIX} when looking for header files.
35125 @item COMPILER_PATH
35126 @findex COMPILER_PATH
35127 The value of @env{COMPILER_PATH} is a colon-separated list of
35128 directories, much like @env{PATH}. GCC tries the directories thus
35129 specified when searching for subprograms, if it cannot find the
35130 subprograms using @env{GCC_EXEC_PREFIX}.
35133 @findex LIBRARY_PATH
35134 The value of @env{LIBRARY_PATH} is a colon-separated list of
35135 directories, much like @env{PATH}. When configured as a native compiler,
35136 GCC tries the directories thus specified when searching for special
35137 linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
35138 using GCC also uses these directories when searching for ordinary
35139 libraries for the @option{-l} option (but directories specified with
35140 @option{-L} come first).
35144 @cindex locale definition
35145 This variable is used to pass locale information to the compiler. One way in
35146 which this information is used is to determine the character set to be used
35147 when character literals, string literals and comments are parsed in C and C++.
35148 When the compiler is configured to allow multibyte characters,
35149 the following values for @env{LANG} are recognized:
35153 Recognize JIS characters.
35155 Recognize SJIS characters.
35157 Recognize EUCJP characters.
35160 If @env{LANG} is not defined, or if it has some other value, then the
35161 compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
35162 recognize and translate multibyte characters.
35164 @item GCC_EXTRA_DIAGNOSTIC_OUTPUT
35165 @findex GCC_EXTRA_DIAGNOSTIC_OUTPUT
35166 If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
35167 then additional text will be emitted to stderr when fix-it hints are
35168 emitted. @option{-fdiagnostics-parseable-fixits} and
35169 @option{-fno-diagnostics-parseable-fixits} take precedence over this
35170 environment variable.
35174 Emit parseable fix-it hints, equivalent to
35175 @option{-fdiagnostics-parseable-fixits}. In particular, columns are
35176 expressed as a count of bytes, starting at byte 1 for the initial column.
35179 As @code{fixits-v1}, but columns are expressed as display columns,
35180 as per @option{-fdiagnostics-column-unit=display}.
35186 Some additional environment variables affect the behavior of the
35189 @include cppenv.texi
35193 @node Precompiled Headers
35194 @section Using Precompiled Headers
35195 @cindex precompiled headers
35196 @cindex speed of compilation
35198 Often large projects have many header files that are included in every
35199 source file. The time the compiler takes to process these header files
35200 over and over again can account for nearly all of the time required to
35201 build the project. To make builds faster, GCC allows you to
35202 @dfn{precompile} a header file.
35204 To create a precompiled header file, simply compile it as you would any
35205 other file, if necessary using the @option{-x} option to make the driver
35206 treat it as a C or C++ header file. You may want to use a
35207 tool like @command{make} to keep the precompiled header up-to-date when
35208 the headers it contains change.
35210 A precompiled header file is searched for when @code{#include} is
35211 seen in the compilation. As it searches for the included file
35212 (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
35213 compiler looks for a precompiled header in each directory just before it
35214 looks for the include file in that directory. The name searched for is
35215 the name specified in the @code{#include} with @samp{.gch} appended. If
35216 the precompiled header file cannot be used, it is ignored.
35218 For instance, if you have @code{#include "all.h"}, and you have
35219 @file{all.h.gch} in the same directory as @file{all.h}, then the
35220 precompiled header file is used if possible, and the original
35221 header is used otherwise.
35223 Alternatively, you might decide to put the precompiled header file in a
35224 directory and use @option{-I} to ensure that directory is searched
35225 before (or instead of) the directory containing the original header.
35226 Then, if you want to check that the precompiled header file is always
35227 used, you can put a file of the same name as the original header in this
35228 directory containing an @code{#error} command.
35230 This also works with @option{-include}. So yet another way to use
35231 precompiled headers, good for projects not designed with precompiled
35232 header files in mind, is to simply take most of the header files used by
35233 a project, include them from another header file, precompile that header
35234 file, and @option{-include} the precompiled header. If the header files
35235 have guards against multiple inclusion, they are skipped because
35236 they've already been included (in the precompiled header).
35238 If you need to precompile the same header file for different
35239 languages, targets, or compiler options, you can instead make a
35240 @emph{directory} named like @file{all.h.gch}, and put each precompiled
35241 header in the directory, perhaps using @option{-o}. It doesn't matter
35242 what you call the files in the directory; every precompiled header in
35243 the directory is considered. The first precompiled header
35244 encountered in the directory that is valid for this compilation is
35245 used; they're searched in no particular order.
35247 There are many other possibilities, limited only by your imagination,
35248 good sense, and the constraints of your build system.
35250 A precompiled header file can be used only when these conditions apply:
35254 Only one precompiled header can be used in a particular compilation.
35257 A precompiled header cannot be used once the first C token is seen. You
35258 can have preprocessor directives before a precompiled header; you cannot
35259 include a precompiled header from inside another header.
35262 The precompiled header file must be produced for the same language as
35263 the current compilation. You cannot use a C precompiled header for a C++
35267 The precompiled header file must have been produced by the same compiler
35268 binary as the current compilation is using.
35271 Any macros defined before the precompiled header is included must
35272 either be defined in the same way as when the precompiled header was
35273 generated, or must not affect the precompiled header, which usually
35274 means that they don't appear in the precompiled header at all.
35276 The @option{-D} option is one way to define a macro before a
35277 precompiled header is included; using a @code{#define} can also do it.
35278 There are also some options that define macros implicitly, like
35279 @option{-O} and @option{-Wdeprecated}; the same rule applies to macros
35282 @item If debugging information is output when using the precompiled
35283 header, using @option{-g} or similar, the same kind of debugging information
35284 must have been output when building the precompiled header. However,
35285 a precompiled header built using @option{-g} can be used in a compilation
35286 when no debugging information is being output.
35288 @item The same @option{-m} options must generally be used when building
35289 and using the precompiled header. @xref{Submodel Options},
35290 for any cases where this rule is relaxed.
35292 @item Each of the following options must be the same when building and using
35293 the precompiled header:
35295 @gccoptlist{-fexceptions}
35298 Some other command-line options starting with @option{-f},
35299 @option{-p}, or @option{-O} must be defined in the same way as when
35300 the precompiled header was generated. At present, it's not clear
35301 which options are safe to change and which are not; the safest choice
35302 is to use exactly the same options when generating and using the
35303 precompiled header. The following are known to be safe:
35305 @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock @gol
35306 -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous @gol
35307 -fsched-verbose=@var{number} -fschedule-insns -fvisibility= @gol
35310 @item Address space layout randomization (ASLR) can lead to not binary identical
35311 PCH files. If you rely on stable PCH file contents disable ASLR when generating
35316 For all of these except the last, the compiler automatically
35317 ignores the precompiled header if the conditions aren't met. If you
35318 find an option combination that doesn't work and doesn't cause the
35319 precompiled header to be ignored, please consider filing a bug report,
35322 If you do use differing options when generating and using the
35323 precompiled header, the actual behavior is a mixture of the
35324 behavior for the options. For instance, if you use @option{-g} to
35325 generate the precompiled header but not when using it, you may or may
35326 not get debugging information for routines in the precompiled header.
35329 @section C++ Modules
35330 @cindex speed of compilation
35332 Modules are a C++20 language feature. As the name suggests, they
35333 provides a modular compilation system, intending to provide both
35334 faster builds and better library isolation. The ``Merging Modules''
35335 paper @uref{https://wg21.link/p1103}, provides the easiest to read set
35336 of changes to the standard, although it does not capture later
35339 @emph{G++'s modules support is not complete.} Other than bugs, the
35340 known missing pieces are:
35344 @item Private Module Fragment
35345 The Private Module Fragment is recognized, but an error is emitted.
35347 @item Partition definition visibility rules
35348 Entities may be defined in implementation partitions, and those
35349 definitions are not available outside of the module. This is not
35350 implemented, and the definitions are available to extra-module use.
35352 @item Textual merging of reachable GM entities
35353 Entities may be multiply defined across different header-units.
35354 These must be de-duplicated, and this is implemented across imports,
35355 or when an import redefines a textually-defined entity. However the
35356 reverse is not implemented---textually redefining an entity that has
35357 been defined in an imported header-unit. A redefinition error is
35360 @item Translation-Unit local referencing rules
35361 Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
35362 (@uref{https://wg21.link/p2003}) add limitations on which entities an
35363 exported region may reference (for instance, the entities an exported
35364 template definition may reference). These are not fully implemented.
35366 @item Standard Library Header Units
35367 The Standard Library is not provided as importable header units. If
35368 you want to import such units, you must explicitly build them first.
35369 If you do not do this with care, you may have multiple declarations,
35370 which the module machinery must merge---compiler resource usage can be
35371 affected by how you partition header files into header units.
35375 Modular compilation is @emph{not} enabled with just the
35376 @option{-std=c++20} option. You must explicitly enable it with the
35377 @option{-fmodules-ts} option. It is independent of the language
35378 version selected, although in pre-C++20 versions, it is of course an
35381 No new source file suffixes are required or supported. If you wish to
35382 use a non-standard suffix (@pxref{Overall Options}), you also need
35383 to provide a @option{-x c++} option too.@footnote{Some users like to
35384 distinguish module interface files with a new suffix, such as naming
35385 the source @code{module.cppm}, which involves
35386 teaching all tools about the new suffix. A different scheme, such as
35387 naming @code{module-m.cpp} would be less invasive.}
35389 Compiling a module interface unit produces an additional output (to
35390 the assembly or object file), called a Compiled Module Interface
35391 (CMI). This encodes the exported declarations of the module.
35392 Importing a module reads in the CMI. The import graph is a Directed
35393 Acyclic Graph (DAG). You must build imports before the importer.
35395 Header files may themselves be compiled to header units, which are a
35396 transitional ability aiming at faster compilation. The
35397 @option{-fmodule-header} option is used to enable this, and implies
35398 the @option{-fmodules-ts} option. These CMIs are named by the fully
35399 resolved underlying header file, and thus may be a complete pathname
35400 containing subdirectories. If the header file is found at an absolute
35401 pathname, the CMI location is still relative to a CMI root directory.
35403 As header files often have no suffix, you commonly have to specify a
35404 @option{-x} option to tell the compiler the source is a header file.
35405 You may use @option{-x c++-header}, @option{-x c++-user-header} or
35406 @option{-x c++-system-header}. When used in conjunction with
35407 @option{-fmodules-ts}, these all imply an appropriate
35408 @option{-fmodule-header} option. The latter two variants use the
35409 user or system include path to search for the file specified. This
35410 allows you to, for instance, compile standard library header files as
35411 header units, without needing to know exactly where they are
35412 installed. Specifying the language as one of these variants also
35413 inhibits output of the object file, as header files have no associated
35416 The @option{-fmodule-only} option disables generation of the
35417 associated object file for compiling a module interface. Only the CMI
35418 is generated. This option is implied when using the
35419 @option{-fmodule-header} option.
35421 The @option{-flang-info-include-translate} and
35422 @option{-flang-info-include-translate-not} options notes whether
35423 include translation occurs or not. With no argument, the first will
35424 note all include translation. The second will note all
35425 non-translations of include files not known to intentionally be
35426 textual. With an argument, queries about include translation of a
35427 header files with that particular trailing pathname are noted. You
35428 may repeat this form to cover several different header files. This
35429 option may be helpful in determining whether include translation is
35430 happening---if it is working correctly, it behaves as if it isn't
35433 The @option{-flang-info-module-cmi} option can be used to determine
35434 where the compiler is reading a CMI from. Without the option, the
35435 compiler is silent when such a read is successful. This option has an
35436 optional argument, which will restrict the notification to just the
35437 set of named modules or header units specified.
35439 The @option{-Winvalid-imported-macros} option causes all imported macros
35440 to be resolved at the end of compilation. Without this, imported
35441 macros are only resolved when expanded or (re)defined. This option
35442 detects conflicting import definitions for all macros.
35444 For details of the @option{-fmodule-mapper} family of options,
35445 @pxref{C++ Module Mapper}.
35448 * C++ Module Mapper:: Module Mapper
35449 * C++ Module Preprocessing:: Module Preprocessing
35450 * C++ Compiled Module Interface:: Compiled Module Interface
35453 @node C++ Module Mapper
35454 @subsection Module Mapper
35455 @cindex C++ Module Mapper
35457 A module mapper provides a server or file that the compiler queries to
35458 determine the mapping between module names and CMI files. It is also
35459 used to build CMIs on demand. @emph{Mapper functionality is in its
35460 infancy and is intended for experimentation with build system
35463 You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
35464 option or @env{CXX_MODULE_MAPPER} environment variable. The value may
35465 have one of the following forms:
35469 @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
35470 An optional hostname and a numeric port number to connect to. If the
35471 hostname is omitted, the loopback address is used. If the hostname
35472 corresponds to multiple IPV6 addresses, these are tried in turn, until
35473 one is successful. If your host lacks IPv6, this form is
35474 non-functional. If you must use IPv4 use
35475 @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
35477 @item =@var{socket}@r{[}?@var{ident}@r{]}
35478 A local domain socket. If your host lacks local domain sockets, this
35479 form is non-functional.
35481 @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
35482 A program to spawn, and communicate with on its stdin/stdout streams.
35483 Your @var{PATH} environment variable is searched for the program.
35484 Arguments are separated by space characters, (it is not possible for
35485 one of the arguments delivered to the program to contain a space). An
35486 exception is if @var{program} begins with @@. In that case
35487 @var{program} (sans @@) is looked for in the compiler's internal
35488 binary directory. Thus the sample mapper-server can be specified
35489 with @code{@@g++-mapper-server}.
35491 @item <>@r{[}?@var{ident}@r{]}
35492 @item <>@var{inout}@r{[}?@var{ident}@r{]}
35493 @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
35494 Named pipes or file descriptors to communicate over. The first form,
35495 @option{<>}, communicates over stdin and stdout. The other forms
35496 allow you to specify a file descriptor or name a pipe. A numeric value
35497 is interpreted as a file descriptor, otherwise named pipe is opened.
35498 The second form specifies a bidirectional pipe and the last form
35499 allows specifying two independent pipes. Using file descriptors
35500 directly in this manner is fragile in general, as it can require the
35501 cooperation of intermediate processes. In particular using stdin &
35502 stdout is fraught with danger as other compiler options might also
35503 cause the compiler to read stdin or write stdout, and it can have
35504 unfortunate interactions with signal delivery from the terminal.
35506 @item @var{file}@r{[}?@var{ident}@r{]}
35507 A mapping file consisting of space-separated module-name, filename
35508 pairs, one per line. Only the mappings for the direct imports and any
35509 module export name need be provided. If other mappings are provided,
35510 they override those stored in any imported CMI files. A repository
35511 root may be specified in the mapping file by using @samp{$root} as the
35512 module name in the first active line. Use of this option will disable
35513 any default module->CMI name mapping.
35517 As shown, an optional @var{ident} may suffix the first word of the
35518 option, indicated by a @samp{?} prefix. The value is used in the
35519 initial handshake with the module server, or to specify a prefix on
35520 mapping file lines. In the server case, the main source file name is
35521 used if no @var{ident} is specified. In the file case, all non-blank
35522 lines are significant, unless a value is specified, in which case only
35523 lines beginning with @var{ident} are significant. The @var{ident}
35524 must be separated by whitespace from the module name. Be aware that
35525 @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
35526 significant to the shell, and therefore may need quoting.
35528 The mapper is connected to or loaded lazily, when the first module
35529 mapping is required. The networking protocols are only supported on
35530 hosts that provide networking. If no mapper is specified a default is
35533 A project-specific mapper is expected to be provided by the build
35534 system that invokes the compiler. It is not expected that a
35535 general-purpose server is provided for all compilations. As such, the
35536 server will know the build configuration, the compiler it invoked, and
35537 the environment (such as working directory) in which that is
35538 operating. As it may parallelize builds, several compilations may
35539 connect to the same socket.
35541 The default mapper generates CMI files in a @samp{gcm.cache}
35542 directory. CMI files have a @samp{.gcm} suffix. The module unit name
35543 is used directly to provide the basename. Header units construct a
35544 relative path using the underlying header file name. If the path is
35545 already relative, a @samp{,} directory is prepended. Internal
35546 @samp{..} components are translated to @samp{,,}. No attempt is made
35547 to canonicalize these filenames beyond that done by the preprocessor's
35548 include search algorithm, as in general it is ambiguous when symbolic
35551 The mapper protocol was published as ``A Module Mapper''
35552 @uref{https://wg21.link/p1184}. The implementation is provided by
35553 @command{libcody}, @uref{https://github.com/urnathan/libcody},
35554 which specifies the canonical protocol definition. A proof of concept
35555 server implementation embedded in @command{make} was described in
35556 ''Make Me A Module'', @uref{https://wg21.link/p1602}.
35558 @node C++ Module Preprocessing
35559 @subsection Module Preprocessing
35560 @cindex C++ Module Preprocessing
35562 Modules affect preprocessing because of header units and include
35563 translation. Some uses of the preprocessor as a separate step either
35564 do not produce a correct output, or require CMIs to be available.
35566 Header units import macros. These macros can affect later conditional
35567 inclusion, which therefore can cascade to differing import sets. When
35568 preprocessing, it is necessary to load the CMI. If a header unit is
35569 unavailable, the preprocessor issues a warning and continue (when
35570 not just preprocessing, an error is emitted). Detecting such imports
35571 requires preprocessor tokenization of the input stream to phase 4
35574 Include translation converts @code{#include}, @code{#include_next} and
35575 @code{#import} directives to internal @code{import} declarations.
35576 Whether a particular directive is translated is controlled by the
35577 module mapper. Header unit names are canonicalized during
35580 Dependency information can be emitted for macro import, extending the
35581 functionality of @option{-MD} and @option{-MMD} options. Detection of
35582 import declarations also requires phase 4 preprocessing, and thus
35583 requires full preprocessing (or compilation).
35585 The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
35586 preprocessing before phase 4.
35588 The @option{-save-temps} option uses @option{-fdirectives-only} for
35589 preprocessing, and preserve the macro definitions in the preprocessed
35590 output. Usually you also want to use this option when explicitly
35591 preprocessing a header-unit, or consuming such preprocessed output:
35594 g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
35595 g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
35598 @node C++ Compiled Module Interface
35599 @subsection Compiled Module Interface
35600 @cindex C++ Compiled Module Interface
35602 CMIs are an additional artifact when compiling named module
35603 interfaces, partitions or header units. These are read when
35604 importing. CMI contents are implementation-specific, and in GCC's
35605 case tied to the compiler version. Consider them a rebuildable cache
35606 artifact, not a distributable object.
35608 When creating an output CMI, any missing directory components are
35609 created in a manner that is safe for concurrent builds creating
35610 multiple, different, CMIs within a common subdirectory tree.
35612 CMI contents are written to a temporary file, which is then atomically
35613 renamed. Observers either see old contents (if there is an
35614 existing file), or complete new contents. They do not observe the
35615 CMI during its creation. This is unlike object file writing, which
35616 may be observed by an external process.
35618 CMIs are read in lazily, if the host OS provides @code{mmap}
35619 functionality. Generally blocks are read when name lookup or template
35620 instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
35621 option may be used.
35623 The @option{--param lazy-modules=@var{n}} parameter controls the limit
35624 on the number of concurrently open module files during lazy loading.
35625 Should more modules be imported, an LRU algorithm is used to determine
35626 which files to close---until that file is needed again. This limit
35627 may be exceeded with deep module dependency hierarchies. With large
35628 code bases there may be more imports than the process limit of file
35629 descriptors. By default, the limit is a few less than the per-process
35630 file descriptor hard limit, if that is determinable.@footnote{Where
35631 applicable the soft limit is incremented as needed towards the hard limit.}
35633 GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
35634 You may use @command{readelf} to inspect them, although section
35635 contents are largely undecipherable. There is a section named
35636 @code{.gnu.c++.README}, which contains human-readable text. Other
35637 than the first line, each line consists of @code{@var{tag}: @code{value}}
35641 > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
35643 String dump of section '.gnu.c++.README':
35644 [ 0] GNU C++ primary module interface
35645 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
35646 [ 6f] version: 2020/11/16-04:54
35648 [ 95] source: c_b.ii
35649 [ a4] dialect: C++20/coroutines
35650 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
35651 [ ee] repository: gcm.cache
35652 [ 104] buildtime: 2020/11/16 15:03:21 UTC
35653 [ 127] localtime: 2020/11/16 07:03:21 PST
35654 [ 14a] export: foo:part1 foo-part1.gcm
35657 Amongst other things, this lists the source that was built, C++
35658 dialect used and imports of the module.@footnote{The precise contents
35659 of this output may change.} The timestamp is the same value as that
35660 provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
35661 explicitly specified with the environment variable
35662 @code{SOURCE_DATE_EPOCH}. For further details
35663 @pxref{Environment Variables}.
35665 A set of related CMIs may be copied, provided the relative pathnames
35668 The @code{.gnu.c++.README} contents do not affect CMI integrity, and
35669 it may be removed or altered. The section numbering of the sections
35670 whose names do not begin with @code{.gnu.c++.}, or are not the string
35671 section is significant and must not be altered.