1 @c Copyright (C) 1988-2024 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-2024 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}
190 -dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf}
191 -dumpdir @var{dumppfx} -x @var{language}
192 -v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version
193 -pass-exit-codes -pipe -specs=@var{file} -wrapper
194 @@@var{file} -ffile-prefix-map=@var{old}=@var{new} -fcanon-prefix-map
195 -fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg}
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}
202 -fno-builtin -fno-builtin-@var{function} -fcond-mismatch
203 -ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted
204 -flax-vector-conversions -fms-extensions
205 -foffload=@var{arg} -foffload-options=@var{arg}
206 -fopenacc -fopenacc-dim=@var{geom}
207 -fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]}
208 -fpermitted-flt-eval-methods=@var{standard}
209 -fplan9-extensions -fsigned-bitfields -funsigned-bitfields
210 -fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}]
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
216 -faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new
217 -fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n}
218 -fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n}
219 -fno-elide-constructors
220 -fno-enforce-eh-specs
222 -fno-immediate-escalation
223 -fno-implicit-templates
224 -fno-implicit-inline-templates
225 -fno-implement-inlines
226 -fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts
227 -fmodule-implicit-inline
229 -fmodule-mapper=@var{specification}
230 -fmodule-version-ignore
232 -fnew-inheriting-ctors
234 -fno-nonansi-builtins -fnothrow-opt -fno-operator-names
236 -fno-pretty-templates
237 -fno-rtti -fsized-deallocation
238 -ftemplate-backtrace-limit=@var{n}
239 -ftemplate-depth=@var{n}
240 -fno-threadsafe-statics -fuse-cxa-atexit
241 -fno-weak -nostdinc++
242 -fvisibility-inlines-hidden
243 -fvisibility-ms-compat
244 -fext-numeric-literals
245 -flang-info-include-translate@r{[}=@var{header}@r{]}
246 -flang-info-include-translate-not
247 -flang-info-module-cmi@r{[}=@var{module}@r{]}
248 -stdlib=@var{libstdc++,libc++}
249 -Wabi-tag -Wcatch-value -Wcatch-value=@var{n}
250 -Wno-class-conversion -Wclass-memaccess
251 -Wcomma-subscript -Wconditionally-supported
252 -Wno-conversion-null -Wctad-maybe-unsupported
253 -Wctor-dtor-privacy -Wdangling-reference
254 -Wno-delete-incomplete
255 -Wdelete-non-virtual-dtor -Wno-deprecated-array-compare
256 -Wdeprecated-copy -Wdeprecated-copy-dtor
257 -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion
258 -Weffc++ -Wno-elaborated-enum-base
259 -Wno-exceptions -Wextra-semi -Wno-global-module -Wno-inaccessible-base
260 -Wno-inherited-variadic-ctor -Wno-init-list-lifetime
261 -Winvalid-constexpr -Winvalid-imported-macros
262 -Wno-invalid-offsetof -Wno-literal-suffix
263 -Wmismatched-new-delete -Wmismatched-tags
264 -Wmultiple-inheritance -Wnamespaces -Wnarrowing
265 -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor
266 -Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n}
267 -Wrange-loop-construct -Wredundant-move -Wredundant-tags
269 -Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates
270 -Wno-non-template-friend -Wold-style-cast
271 -Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo
272 -Wsized-deallocation -Wsuggest-final-methods
273 -Wsuggest-final-types -Wsuggest-override -Wno-template-id-cdtor
274 -Wno-terminate -Wno-vexing-parse -Wvirtual-inheritance
275 -Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant}
277 @item Objective-C and Objective-C++ Language Options
278 @xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling
279 Objective-C and Objective-C++ Dialects}.
280 @gccoptlist{-fconstant-string-class=@var{class-name}
281 -fgnu-runtime -fnext-runtime
283 -fobjc-abi-version=@var{n}
284 -fobjc-call-cxx-cdtors
285 -fobjc-direct-dispatch
291 -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
292 -freplace-objc-classes
295 -Wassign-intercept -Wno-property-assign-default
296 -Wno-protocol -Wobjc-root-class -Wselector
297 -Wstrict-selector-match
298 -Wundeclared-selector}
300 @item Diagnostic Message Formatting Options
301 @xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
302 @gccoptlist{-fmessage-length=@var{n}
303 -fdiagnostics-plain-output
304 -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}
305 -fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]}
306 -fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]}
307 -fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]}
308 -fno-diagnostics-json-formatting
309 -fno-diagnostics-show-option -fno-diagnostics-show-caret
310 -fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers
311 -fno-diagnostics-show-cwe
312 -fno-diagnostics-show-rule
313 -fdiagnostics-minimum-margin-width=@var{width}
314 -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
315 -fdiagnostics-show-template-tree -fno-elide-type
316 -fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]}
317 -fdiagnostics-show-path-depths
319 -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]}
320 -fdiagnostics-column-origin=@var{origin}
321 -fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}
322 -fdiagnostics-text-art-charset=@r{[}none@r{|}ascii@r{|}unicode@r{|}emoji@r{]}}
324 @item Warning Options
325 @xref{Warning Options,,Options to Request or Suppress Warnings}.
326 @gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic
327 -pedantic-errors -fpermissive
328 -w -Wextra -Wall -Wabi=@var{n}
329 -Waddress -Wno-address-of-packed-member -Waggregate-return
330 -Walloc-size -Walloc-size-larger-than=@var{byte-size} -Walloc-zero
331 -Walloca -Walloca-larger-than=@var{byte-size}
332 -Wno-aggressive-loop-optimizations
334 -Warray-bounds -Warray-bounds=@var{n} -Warray-compare
335 -Warray-parameter -Warray-parameter=@var{n}
336 -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias
337 -Wno-attribute-warning
338 -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
339 -Wbool-compare -Wbool-operation
340 -Wno-builtin-declaration-mismatch
341 -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat
343 -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat
345 -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions
346 -Wno-c++20-extensions -Wno-c++23-extensions
347 -Wcalloc-transposed-args
348 -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual
350 -Wclobbered -Wcomment
351 -Wcompare-distinct-pointer-types
352 -Wno-complain-wrong-lang
353 -Wconversion -Wno-coverage-mismatch -Wno-cpp
354 -Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n}
356 -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init
357 -Wdisabled-optimization
358 -Wno-discarded-array-qualifiers -Wno-discarded-qualifiers
359 -Wno-div-by-zero -Wdouble-promotion
360 -Wduplicated-branches -Wduplicated-cond
361 -Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion
363 -Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors
364 -Wflex-array-member-not-at-end
365 -Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2
366 -Wno-format-contains-nul -Wno-format-extra-args
367 -Wformat-nonliteral -Wformat-overflow=@var{n}
368 -Wformat-security -Wformat-signedness -Wformat-truncation=@var{n}
369 -Wformat-y2k -Wframe-address
370 -Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object
371 -Wno-if-not-aligned -Wno-ignored-attributes
372 -Wignored-qualifiers -Wno-incompatible-pointer-types -Whardened
373 -Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n}
374 -Wno-implicit-function-declaration -Wno-implicit-int
376 -Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context
377 -Wno-int-to-pointer-cast -Wno-invalid-memory-model
378 -Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init
379 -Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op
380 -Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized
381 -Wmemset-elt-size -Wmemset-transposed-args
382 -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces
383 -Wmissing-field-initializers -Wmissing-format-attribute
384 -Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile
385 -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare
386 -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
387 -Wnull-dereference -Wno-odr
388 -Wopenacc-parallelism
389 -Wopenmp -Wopenmp-simd
390 -Wno-overflow -Woverlength-strings -Wno-override-init-side-effects
391 -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
392 -Wparentheses -Wno-pedantic-ms-format
393 -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
394 -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls
395 -Wrestrict -Wno-return-local-addr -Wreturn-type
396 -Wno-scalar-storage-order -Wsequence-point
397 -Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local
399 -Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value
400 -Wno-shift-overflow -Wshift-overflow=@var{n}
401 -Wsign-compare -Wsign-conversion
402 -Wno-sizeof-array-argument
404 -Wsizeof-pointer-div -Wsizeof-pointer-memaccess
405 -Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing
406 -Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n}
408 -Wno-stringop-overflow -Wno-stringop-overread
409 -Wno-stringop-truncation -Wstrict-flex-arrays
410 -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]}
411 -Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum
412 -Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand
413 -Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs
414 -Wtrivial-auto-var-init -Wno-tsan -Wtype-limits -Wundef
415 -Wuninitialized -Wunknown-pragmas
416 -Wunsuffixed-float-constants -Wunused
417 -Wunused-but-set-parameter -Wunused-but-set-variable
418 -Wunused-const-variable -Wunused-const-variable=@var{n}
419 -Wunused-function -Wunused-label -Wunused-local-typedefs
421 -Wunused-parameter -Wno-unused-result
422 -Wunused-value -Wunused-variable
423 -Wuse-after-free -Wuse-after-free=@var{n} -Wuseless-cast
424 -Wno-varargs -Wvariadic-macros
425 -Wvector-operation-performance
426 -Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than
427 -Wvolatile-register-var -Wwrite-strings
429 -Wzero-length-bounds}
431 @item Static Analyzer Options
434 -fanalyzer-call-summaries
435 -fanalyzer-checker=@var{name}
436 -fno-analyzer-feasibility
437 -fanalyzer-fine-grained
438 -fanalyzer-show-events-in-system-headers
439 -fno-analyzer-state-merge
440 -fno-analyzer-state-purge
441 -fno-analyzer-suppress-followups
442 -fanalyzer-transitivity
443 -fno-analyzer-undo-inlining
444 -fanalyzer-verbose-edges
445 -fanalyzer-verbose-state-changes
446 -fanalyzer-verbosity=@var{level}
448 -fdump-analyzer-callgraph
449 -fdump-analyzer-exploded-graph
450 -fdump-analyzer-exploded-nodes
451 -fdump-analyzer-exploded-nodes-2
452 -fdump-analyzer-exploded-nodes-3
453 -fdump-analyzer-exploded-paths
454 -fdump-analyzer-feasibility
455 -fdump-analyzer-infinite-loop
457 -fdump-analyzer-state-purge
458 -fdump-analyzer-stderr
459 -fdump-analyzer-supergraph
460 -fdump-analyzer-untracked
461 -Wno-analyzer-double-fclose
462 -Wno-analyzer-double-free
463 -Wno-analyzer-exposure-through-output-file
464 -Wno-analyzer-exposure-through-uninit-copy
465 -Wno-analyzer-fd-access-mode-mismatch
466 -Wno-analyzer-fd-double-close
467 -Wno-analyzer-fd-leak
468 -Wno-analyzer-fd-phase-mismatch
469 -Wno-analyzer-fd-type-mismatch
470 -Wno-analyzer-fd-use-after-close
471 -Wno-analyzer-fd-use-without-check
472 -Wno-analyzer-file-leak
473 -Wno-analyzer-free-of-non-heap
474 -Wno-analyzer-imprecise-fp-arithmetic
475 -Wno-analyzer-infinite-loop
476 -Wno-analyzer-infinite-recursion
477 -Wno-analyzer-jump-through-null
478 -Wno-analyzer-malloc-leak
479 -Wno-analyzer-mismatching-deallocation
480 -Wno-analyzer-null-argument
481 -Wno-analyzer-null-dereference
482 -Wno-analyzer-out-of-bounds
483 -Wno-analyzer-overlapping-buffers
484 -Wno-analyzer-possible-null-argument
485 -Wno-analyzer-possible-null-dereference
486 -Wno-analyzer-putenv-of-auto-var
487 -Wno-analyzer-shift-count-negative
488 -Wno-analyzer-shift-count-overflow
489 -Wno-analyzer-stale-setjmp-buffer
490 -Wno-analyzer-tainted-allocation-size
491 -Wno-analyzer-tainted-assertion
492 -Wno-analyzer-tainted-array-index
493 -Wno-analyzer-tainted-divisor
494 -Wno-analyzer-tainted-offset
495 -Wno-analyzer-tainted-size
496 -Wanalyzer-symbol-too-complex
497 -Wanalyzer-too-complex
498 -Wno-analyzer-undefined-behavior-strtok
499 -Wno-analyzer-unsafe-call-within-signal-handler
500 -Wno-analyzer-use-after-free
501 -Wno-analyzer-use-of-pointer-in-stale-stack-frame
502 -Wno-analyzer-use-of-uninitialized-value
503 -Wno-analyzer-va-arg-type-mismatch
504 -Wno-analyzer-va-list-exhausted
505 -Wno-analyzer-va-list-leak
506 -Wno-analyzer-va-list-use-after-va-end
507 -Wno-analyzer-write-to-const
508 -Wno-analyzer-write-to-string-literal
511 @item C and Objective-C-only Warning Options
512 @gccoptlist{-Wbad-function-cast -Wmissing-declarations
513 -Wmissing-parameter-type -Wdeclaration-missing-parameter-type
514 -Wmissing-prototypes -Wmissing-variable-declarations
515 -Wnested-externs -Wold-style-declaration -Wold-style-definition
516 -Wstrict-prototypes -Wtraditional -Wtraditional-conversion
517 -Wdeclaration-after-statement -Wpointer-sign}
519 @item Debugging Options
520 @xref{Debugging Options,,Options for Debugging Your Program}.
521 @gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version}
522 -gbtf -gctf -gctf@var{level}
523 -ggdb -grecord-gcc-switches -gno-record-gcc-switches
524 -gstrict-dwarf -gno-strict-dwarf
525 -gas-loc-support -gno-as-loc-support
526 -gas-locview-support -gno-as-locview-support
528 -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64
529 -gstatement-frontiers -gno-statement-frontiers
530 -gvariable-location-views -gno-variable-location-views
531 -ginternal-reset-location-views -gno-internal-reset-location-views
532 -ginline-points -gno-inline-points
533 -gvms -gz@r{[}=@var{type}@r{]}
534 -gsplit-dwarf -gdescribe-dies -gno-describe-dies
535 -fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section
536 -fno-eliminate-unused-debug-types
537 -femit-struct-debug-baseonly -femit-struct-debug-reduced
538 -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
539 -fno-eliminate-unused-debug-symbols -femit-class-debug-always
540 -fno-merge-debug-strings -fno-dwarf2-cfi-asm
541 -fvar-tracking -fvar-tracking-assignments}
543 @item Optimization Options
544 @xref{Optimize Options,,Options that Control Optimization}.
545 @gccoptlist{-faggressive-loop-optimizations
546 -falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
547 -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
548 -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
549 -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
550 -fmin-function-alignment=[@var{n}]
551 -fno-allocation-dce -fallow-store-data-races
552 -fassociative-math -fauto-profile -fauto-profile[=@var{path}]
553 -fauto-inc-dec -fbranch-probabilities
555 -fcombine-stack-adjustments -fconserve-stack
557 -fcompare-elim -fcprop-registers -fcrossjumping
558 -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules
560 -fdata-sections -fdce -fdelayed-branch
561 -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively
562 -fdevirtualize-at-ltrans -fdse
563 -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects
564 -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style}
566 -fforward-propagate -ffp-contract=@var{style} -ffunction-sections
567 -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity
568 -fgcse-sm -fhoist-adjacent-loads -fif-conversion
569 -fif-conversion2 -findirect-inlining
570 -finline-stringops[=@var{fn}]
571 -finline-functions -finline-functions-called-once -finline-limit=@var{n}
572 -finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone
573 -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const
574 -fipa-reference -fipa-reference-addressable
575 -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm}
576 -flive-patching=@var{level}
577 -fira-region=@var{region} -fira-hoist-pressure
578 -fira-loop-pressure -fno-ira-share-save-slots
579 -fno-ira-share-spill-slots
580 -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute
581 -fivopts -fkeep-inline-functions -fkeep-static-functions
582 -fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage
583 -floop-block -floop-interchange -floop-strip-mine
584 -floop-unroll-and-jam -floop-nest-optimize
585 -floop-parallelize-all -flra-remat -flto -flto-compression-level
586 -flto-partition=@var{alg} -fmerge-all-constants
587 -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
588 -fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg
589 -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
590 -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole
591 -fno-peephole2 -fno-printf-return-value -fno-sched-interblock
592 -fno-sched-spec -fno-signed-zeros
593 -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
594 -fomit-frame-pointer -foptimize-sibling-calls
595 -fpartial-inlining -fpeel-loops -fpredictive-commoning
596 -fprefetch-loop-arrays
598 -fprofile-use -fprofile-use=@var{path} -fprofile-partial-training
599 -fprofile-values -fprofile-reorder-functions
600 -freciprocal-math -free -frename-registers -freorder-blocks
601 -freorder-blocks-algorithm=@var{algorithm}
602 -freorder-blocks-and-partition -freorder-functions
603 -frerun-cse-after-loop -freschedule-modulo-scheduled-loops
604 -frounding-math -fsave-optimization-record
605 -fsched2-use-superblocks -fsched-pressure
606 -fsched-spec-load -fsched-spec-load-dangerous
607 -fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}]
608 -fsched-group-heuristic -fsched-critical-path-heuristic
609 -fsched-spec-insn-heuristic -fsched-rank-heuristic
610 -fsched-last-insn-heuristic -fsched-dep-count-heuristic
612 -fschedule-insns -fschedule-insns2 -fsection-anchors
613 -fselective-scheduling -fselective-scheduling2
614 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
615 -fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate
617 -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops
619 -fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt
620 -fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing
621 -fthread-jumps -ftracer -ftree-bit-ccp
622 -ftree-builtin-call-dce -ftree-ccp -ftree-ch
623 -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts
624 -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting
625 -ftree-loop-if-convert -ftree-loop-im
626 -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns
627 -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
628 -ftree-loop-vectorize
629 -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta
630 -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra
631 -ftree-switch-conversion -ftree-tail-merge
632 -ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init
633 -funconstrained-commons -funit-at-a-time -funroll-all-loops
634 -funroll-loops -funsafe-math-optimizations -funswitch-loops
635 -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt
636 -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs
637 --param @var{name}=@var{value}
638 -O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
640 @item Program Instrumentation Options
641 @xref{Instrumentation Options,,Program Instrumentation Options}.
642 @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage
644 -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path}
645 -fprofile-info-section -fprofile-info-section=@var{name}
646 -fprofile-note=@var{path} -fprofile-prefix-path=@var{path}
647 -fprofile-update=@var{method} -fprofile-filter-files=@var{regex}
648 -fprofile-exclude-files=@var{regex}
649 -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
650 -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style}
651 -fsanitize-trap -fsanitize-trap=@var{style}
652 -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},...
653 -fsanitize-undefined-trap-on-error -fbounds-check
654 -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
655 -fharden-compares -fharden-conditional-branches -fhardened
656 -fharden-control-flow-redundancy -fhardcfr-skip-leaf
657 -fhardcfr-check-exceptions -fhardcfr-check-returning-calls
658 -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
659 -fstack-protector -fstack-protector-all -fstack-protector-strong
660 -fstack-protector-explicit -fstack-check
661 -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym}
662 -fno-stack-limit -fsplit-stack
663 -fstrub=disable -fstrub=strict -fstrub=relaxed
664 -fstrub=all -fstrub=at-calls -fstrub=internal
665 -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
666 -fvtv-counts -fvtv-debug
667 -finstrument-functions -finstrument-functions-once
668 -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
669 -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
670 -fprofile-prefix-map=@var{old}=@var{new}
671 -fpatchable-function-entry=@var{N}@r{[},@var{M}@r{]}}
673 @item Preprocessor Options
674 @xref{Preprocessor Options,,Options Controlling the Preprocessor}.
675 @gccoptlist{-A@var{question}=@var{answer}
676 -A-@var{question}@r{[}=@var{answer}@r{]}
677 -C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
679 -fdebug-cpp -fdirectives-only -fdollars-in-identifiers
680 -fexec-charset=@var{charset} -fextended-identifiers
681 -finput-charset=@var{charset} -flarge-source-files
682 -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth}
683 -fno-canonical-system-headers -fpch-deps -fpch-preprocess
684 -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion
685 -fwide-exec-charset=@var{charset} -fworking-directory
686 -H -imacros @var{file} -include @var{file}
687 -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules
688 -no-integrated-cpp -P -pthread -remap
689 -traditional -traditional-cpp -trigraphs
691 -Wp,@var{option} -Xpreprocessor @var{option}}
693 @item Assembler Options
694 @xref{Assembler Options,,Passing Options to the Assembler}.
695 @gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
698 @xref{Link Options,,Options for Linking}.
699 @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library}
700 -nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++
701 -e @var{entry} --entry=@var{entry}
702 -pie -pthread -r -rdynamic
703 -s -static -static-pie -static-libgcc -static-libstdc++
704 -static-libasan -static-libtsan -static-liblsan -static-libubsan
705 -shared -shared-libgcc -symbolic
706 -T @var{script} -Wl,@var{option} -Xlinker @var{option}
707 -u @var{symbol} -z @var{keyword}}
709 @item Directory Options
710 @xref{Directory Options,,Options for Directory Search}.
711 @gccoptlist{-B@var{prefix} -I@var{dir} -I-
713 -imacros @var{file} -imultilib @var{dir}
714 -iplugindir=@var{dir} -iprefix @var{file}
715 -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir}
716 -iwithprefix @var{dir} -iwithprefixbefore @var{dir}
717 -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix
718 -nostdinc -nostdinc++ --sysroot=@var{dir}}
720 @item Code Generation Options
721 @xref{Code Gen Options,,Options for Code Generation Conventions}.
722 @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg}
723 -ffixed-@var{reg} -fexceptions
724 -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
725 -fasynchronous-unwind-tables
727 -finhibit-size-directive -fcommon -fno-ident
728 -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt
729 -fno-jump-tables -fno-bit-tests
730 -frecord-gcc-switches
731 -freg-struct-return -fshort-enums -fshort-wchar
732 -fverbose-asm -fpack-struct[=@var{n}]
733 -fleading-underscore -ftls-model=@var{model}
734 -fstack-reuse=@var{reuse_level}
735 -ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
737 -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
738 -fstrict-volatile-bitfields -fsync-libcalls}
740 @item Developer Options
741 @xref{Developer Options,,GCC Developer Options}.
742 @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion
743 -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
744 -fchecking -fchecking=@var{n}
745 -fdbg-cnt-list -fdbg-cnt=@var{counter-value-list}
746 -fdisable-ipa-@var{pass_name}
747 -fdisable-rtl-@var{pass_name}
748 -fdisable-rtl-@var{pass-name}=@var{range-list}
749 -fdisable-tree-@var{pass_name}
750 -fdisable-tree-@var{pass-name}=@var{range-list}
751 -fdump-debug -fdump-earlydebug
752 -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links
753 -fdump-final-insns@r{[}=@var{file}@r{]}
754 -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
756 -fdump-lang-@var{switch}
757 -fdump-lang-@var{switch}-@var{options}
758 -fdump-lang-@var{switch}-@var{options}=@var{filename}
760 -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename}
763 -fdump-tree-@var{switch}
764 -fdump-tree-@var{switch}-@var{options}
765 -fdump-tree-@var{switch}-@var{options}=@var{filename}
766 -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second
767 -fenable-@var{kind}-@var{pass}
768 -fenable-@var{kind}-@var{pass}=@var{range-list}
769 -fira-verbose=@var{n}
770 -flto-report -flto-report-wpa -fmem-report-wpa
771 -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report
772 -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]}
773 -fmultiflags -fprofile-report
774 -frandom-seed=@var{string} -fsched-verbose=@var{n}
775 -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
776 -fstats -fstack-usage -ftime-report -ftime-report-details
777 -fvar-tracking-assignments-toggle -gtoggle
778 -print-file-name=@var{library} -print-libgcc-file-name
779 -print-multi-directory -print-multi-lib -print-multi-os-directory
780 -print-prog-name=@var{program} -print-search-dirs -Q
781 -print-sysroot -print-sysroot-headers-suffix
782 -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
784 @item Machine-Dependent Options
785 @xref{Submodel Options,,Machine-Dependent Options}.
786 @c This list is ordered alphanumerically by subsection name.
787 @c Try and put the significant identifier (CPU or system) first,
788 @c so users have a clue at guessing where the ones they want will be.
790 @emph{AArch64 Options}
791 @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian
793 -mcmodel=tiny -mcmodel=small -mcmodel=large
794 -mstrict-align -mno-strict-align
795 -momit-leaf-frame-pointer
796 -mtls-dialect=desc -mtls-dialect=traditional
797 -mtls-size=@var{size}
798 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419
799 -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div
800 -mpc-relative-literal-loads
801 -msign-return-address=@var{scope}
802 -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
803 +@var{b-key}]|@var{bti}
804 -mharden-sls=@var{opts}
805 -march=@var{name} -mcpu=@var{name} -mtune=@var{name}
806 -moverride=@var{string} -mverbose-cost-dump
807 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg}
808 -mstack-protector-guard-offset=@var{offset} -mtrack-speculation
809 -moutline-atomics -mearly-ldp-fusion -mlate-ldp-fusion}
811 @emph{Adapteva Epiphany Options}
812 @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs
813 -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf
814 -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num}
815 -mround-nearest -mlong-calls -mshort-calls -msmall16
816 -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num}
817 -msplit-vecmove-early -m1reg-@var{reg}}
819 @emph{AMD GCN Options}
820 @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
823 @gccoptlist{-mbarrel-shifter -mjli-always
824 -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700
825 -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr
826 -mea -mno-mpy -mmul32x16 -mmul64 -matomic
827 -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap
828 -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape
829 -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof
830 -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved
831 -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num}
832 -mvolatile-cache -mtp-regno=@var{regno}
833 -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc
834 -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi
835 -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none
836 -mlra-priority-compact -mlra-priority-noncompact -mmillicode
837 -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level}
838 -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame
839 -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo}
840 -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
843 @gccoptlist{-mapcs-frame -mno-apcs-frame
845 -mapcs-stack-check -mno-apcs-stack-check
846 -mapcs-reentrant -mno-apcs-reentrant
848 -msched-prolog -mno-sched-prolog
849 -mlittle-endian -mbig-endian
851 -mfloat-abi=@var{name}
852 -mfp16-format=@var{name}
853 -mthumb-interwork -mno-thumb-interwork
854 -mcpu=@var{name} -march=@var{name} -mfpu=@var{name}
855 -mtune=@var{name} -mprint-tune-info
856 -mstructure-size-boundary=@var{n}
858 -mlong-calls -mno-long-calls
859 -msingle-pic-base -mno-single-pic-base
860 -mpic-register=@var{reg}
863 -mthumb -marm -mflip-thumb
864 -mtpcs-frame -mtpcs-leaf-frame
865 -mcaller-super-interworking -mcallee-super-interworking
866 -mtp=@var{name} -mtls-dialect=@var{dialect}
869 -mfix-cortex-a57-aes-1742098
870 -mfix-cortex-a72-aes-1655431
879 -mfix-cmse-cve-2021-35465
880 -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset}
882 -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
883 [+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
886 @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args
887 -mbranch-cost=@var{cost} -mfuse-add=@var{level}
888 -mcall-prologues -mgas-isr-prologues -mint8 -mflmap
889 -mdouble=@var{bits} -mlong-double=@var{bits}
890 -mn_flash=@var{size} -mno-interrupts
891 -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack
892 -mrodata-in-ram -mfract-convert-truncate
893 -mshort-calls -mskip-bug -nodevicelib -nodevicespecs
894 -Waddr-space-convert -Wmisspelled-isr}
896 @emph{Blackfin Options}
897 @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
898 -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer
899 -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly
900 -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
901 -mno-id-shared-library -mshared-library-id=@var{n}
902 -mleaf-id-shared-library -mno-leaf-id-shared-library
903 -msep-data -mno-sep-data -mlong-calls -mno-long-calls
904 -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram
908 @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu}
909 -msim -msdata=@var{sdata-type}}
912 @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
913 -mtune=@var{cpu} -mmax-stack-frame=@var{n}
914 -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects
915 -mstack-align -mdata-align -mconst-align
916 -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
917 -melf -maout -sim -sim2
918 -mmul-bug-workaround -mno-mul-bug-workaround}
921 @gccoptlist{-march=@var{arch} -mcpu=@var{cpu}
922 -mbig-endian -EB -mlittle-endian -EL
923 -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu
924 -mfloat-abi=@var{name}
925 -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust
927 -mdiv -msmart -mhigh-registers -manchor
928 -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt
929 -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
931 @emph{Darwin Options}
932 @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal
933 -arch_only -bind_at_load -bundle -bundle_loader
934 -client_name -compatibility_version -current_version
936 -dependency-file -dylib_file -dylinker_install_name
937 -dynamic -dynamiclib -exported_symbols_list
938 -filelist -flat_namespace -force_cpusubtype_ALL
939 -force_flat_namespace -headerpad_max_install_names
941 -image_base -init -install_name -keep_private_externs
942 -multi_module -multiply_defined -multiply_defined_unused
943 -noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths
944 -nofixprebinding -nomultidefs -noprebind -noseglinkedit
945 -pagezero_size -prebind -prebind_all_twolevel_modules
946 -private_bundle -read_only_relocs -sectalign
947 -sectobjectsymbols -whyload -seg1addr
948 -sectcreate -sectobjectsymbols -sectorder
949 -segaddr -segs_read_only_addr -segs_read_write_addr
950 -seg_addr_table -seg_addr_table_filename -seglinkedit
951 -segprot -segs_read_only_addr -segs_read_write_addr
952 -single_module -static -sub_library -sub_umbrella
953 -twolevel_namespace -umbrella -undefined
954 -unexported_symbols_list -weak_reference_mismatches
955 -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version}
956 -mkernel -mone-byte-bool}
958 @emph{DEC Alpha Options}
959 @gccoptlist{-mno-fp-regs -msoft-float
960 -mieee -mieee-with-inexact -mieee-conformant
961 -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
962 -mtrap-precision=@var{mode} -mbuild-constants
963 -mcpu=@var{cpu-type} -mtune=@var{cpu-type}
964 -mbwx -mmax -mfix -mcix
965 -mfloat-vax -mfloat-ieee
966 -mexplicit-relocs -msmall-data -mlarge-data
967 -msmall-text -mlarge-text
968 -mmemory-latency=@var{time}}
971 @gccoptlist{-mbig-endian -mlittle-endian
972 -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext
973 -mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version}
974 -masm=@var{dialect} -minline-memops-threshold=@var{bytes}}
977 @gccoptlist{-msmall-model -mno-lsim}
980 @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
983 @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64
984 -mhard-float -msoft-float
985 -malloc-cc -mfixed-cc -mdword -mno-dword
987 -mmedia -mno-media -mmuladd -mno-muladd
988 -mfdpic -minline-plt -mgprel-ro -multilib-library-pic
989 -mlinked-fp -mlong-calls -malign-labels
990 -mlibrary-pic -macc-4 -macc-8
991 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move
992 -moptimize-membar -mno-optimize-membar
993 -mscc -mno-scc -mcond-exec -mno-cond-exec
994 -mvliw-branch -mno-vliw-branch
995 -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec
996 -mno-nested-cond-exec -mtomcat-stats
1000 @emph{GNU/Linux Options}
1001 @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid
1002 -tno-android-cc -tno-android-ld}
1004 @emph{H8/300 Options}
1005 @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
1008 @gccoptlist{-march=@var{architecture-type}
1009 -matomic-libcalls -mbig-switch
1010 -mcaller-copies -mdisable-fpregs -mdisable-indexing
1011 -mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld
1012 -mfixed-range=@var{register-range}
1013 -mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls
1014 -mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs
1015 -mno-disable-indexing -mno-fast-indirect-calls -mno-gas
1016 -mno-jump-in-delay -mno-long-load-store
1017 -mno-portable-runtime -mno-soft-float
1018 -mno-space-regs -msoft-float -mpa-risc-1-0
1019 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime
1020 -mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio
1021 -munix=@var{unix-std} -nolibdld -static -threads}
1023 @emph{IA-64 Options}
1024 @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic
1025 -mvolatile-asm-stop -mregister-names -msdata -mno-sdata
1026 -mconstant-gp -mauto-pic -mfused-madd
1027 -minline-float-divide-min-latency
1028 -minline-float-divide-max-throughput
1029 -mno-inline-float-divide
1030 -minline-int-divide-min-latency
1031 -minline-int-divide-max-throughput
1032 -mno-inline-int-divide
1033 -minline-sqrt-min-latency -minline-sqrt-max-throughput
1035 -mdwarf2-asm -mearly-stop-bits
1036 -mfixed-range=@var{register-range} -mtls-size=@var{tls-size}
1037 -mtune=@var{cpu-type} -milp32 -mlp64
1038 -msched-br-data-spec -msched-ar-data-spec -msched-control-spec
1039 -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec
1040 -msched-spec-ldc -msched-spec-control-ldc
1041 -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns
1042 -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path
1043 -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
1044 -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1047 @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled
1048 -msign-extend-enabled -muser-enabled}
1050 @emph{LoongArch Options}
1051 @gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type}
1052 -mfpu=@var{fpu-type} -msimd=@var{simd-type}
1053 -msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx
1054 -mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division
1055 -mcond-move-int -mno-cond-move-int
1056 -mcond-move-float -mno-cond-move-float
1057 -memcpy -mno-memcpy -mstrict-align -mno-strict-align
1058 -mmax-inline-memcpy-size=@var{n}
1059 -mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs
1060 -mdirect-extern-access -mno-direct-extern-access
1061 -mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as}
1062 -mrecip -mrecip=@var{opt}
1064 @emph{M32R/D Options}
1065 @gccoptlist{-m32r2 -m32rx -m32r
1067 -malign-loops -mno-align-loops
1068 -missue-rate=@var{number}
1069 -mbranch-cost=@var{number}
1070 -mmodel=@var{code-size-model-type}
1071 -msdata=@var{sdata-type}
1072 -mno-flush-func -mflush-func=@var{name}
1073 -mno-flush-trap -mflush-trap=@var{number}
1077 @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1079 @emph{M680x0 Options}
1080 @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune}
1081 -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
1082 -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407
1083 -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020
1084 -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort
1085 -mno-short -mhard-float -m68881 -msoft-float -mpcrel
1086 -malign-int -mstrict-align -msep-data -mno-sep-data
1087 -mshared-library-id=n -mid-shared-library -mno-id-shared-library
1088 -mxgot -mno-xgot -mlong-jump-table-offsets}
1090 @emph{MCore Options}
1091 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates
1092 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields
1093 -m4byte-functions -mno-4byte-functions -mcallgraph-data
1094 -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim
1095 -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1097 @emph{MicroBlaze Options}
1098 @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu}
1099 -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift
1100 -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss
1101 -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt
1102 -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model}
1103 -mpic-data-is-text-relative}
1106 @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch}
1107 -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
1108 -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6
1109 -mips16 -mno-mips16 -mflip-mips16
1110 -minterlink-compressed -mno-interlink-compressed
1111 -minterlink-mips16 -mno-interlink-mips16
1112 -mabi=@var{abi} -mabicalls -mno-abicalls
1113 -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot
1114 -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float
1115 -mno-float -msingle-float -mdouble-float
1116 -modd-spreg -mno-odd-spreg
1117 -mabs=@var{mode} -mnan=@var{encoding}
1118 -mdsp -mno-dsp -mdspr2 -mno-dspr2
1125 -mmicromips -mno-micromips
1127 -mloongson-mmi -mno-loongson-mmi
1128 -mloongson-ext -mno-loongson-ext
1129 -mloongson-ext2 -mno-loongson-ext2
1130 -mfpu=@var{fpu-type}
1131 -msmartmips -mno-smartmips
1132 -mpaired-single -mno-paired-single -mdmx -mno-mdmx
1133 -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc
1134 -mlong64 -mlong32 -msym32 -mno-sym32
1135 -G@var{num} -mlocal-sdata -mno-local-sdata
1136 -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt
1137 -membedded-data -mno-embedded-data
1138 -muninit-const-in-rodata -mno-uninit-const-in-rodata
1139 -mcode-readable=@var{setting}
1140 -msplit-addresses -mno-split-addresses
1141 -mexplicit-relocs -mno-explicit-relocs
1142 -mexplicit-relocs=@var{release}
1143 -mcheck-zero-division -mno-check-zero-division
1144 -mdivide-traps -mdivide-breaks
1145 -mload-store-pairs -mno-load-store-pairs
1146 -mstrict-align -mno-strict-align
1147 -mno-unaligned-access -munaligned-access
1148 -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls
1149 -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp
1150 -mfix-24k -mno-fix-24k
1151 -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400
1152 -mfix-r5900 -mno-fix-r5900
1153 -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000
1154 -mfix-vr4120 -mno-fix-vr4120
1155 -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1
1156 -mflush-func=@var{func} -mno-flush-func
1157 -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely
1158 -mcompact-branches=@var{policy}
1159 -mfp-exceptions -mno-fp-exceptions
1160 -mvr4130-align -mno-vr4130-align -msynci -mno-synci
1161 -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4
1162 -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
1163 -mframe-header-opt -mno-frame-header-opt}
1166 @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu
1167 -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols
1168 -melf -mbranch-predict -mno-branch-predict -mbase-addresses
1169 -mno-base-addresses -msingle-exit -mno-single-exit}
1171 @emph{MN10300 Options}
1172 @gccoptlist{-mmult-bug -mno-mult-bug
1173 -mno-am33 -mam33 -mam33-2 -mam34
1174 -mtune=@var{cpu-type}
1175 -mreturn-pointer-on-d0
1176 -mno-crt0 -mrelax -mliw -msetlb}
1178 @emph{Moxie Options}
1179 @gccoptlist{-meb -mel -mmul.x -mno-crt0}
1181 @emph{MSP430 Options}
1182 @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax
1184 -mcode-region= -mdata-region=
1185 -msilicon-errata= -msilicon-errata-warn=
1186 -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1188 @emph{NDS32 Options}
1189 @gccoptlist{-mbig-endian -mlittle-endian
1190 -mreduced-regs -mfull-regs
1192 -mext-perf -mno-ext-perf
1193 -mext-perf2 -mno-ext-perf2
1194 -mext-string -mno-ext-string
1195 -mv3push -mno-v3push
1197 -misr-vector-size=@var{num}
1198 -mcache-block-size=@var{num}
1200 -mcmodel=@var{code-model}
1201 -mctor-dtor -mrelax}
1203 @emph{Nios II Options}
1204 @gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt
1205 -mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp}
1207 -mno-bypass-cache -mbypass-cache
1208 -mno-cache-volatile -mcache-volatile
1209 -mno-fast-sw-div -mfast-sw-div
1210 -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div
1211 -mcustom-@var{insn}=@var{N} -mno-custom-@var{insn}
1212 -mcustom-fpu-cfg=@var{name}
1213 -mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name}
1214 -march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1216 @emph{Nvidia PTX Options}
1217 @gccoptlist{-m64 -mmainkernel -moptimize}
1219 @emph{OpenRISC Options}
1220 @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div
1221 -msoft-mul -msoft-div
1222 -msoft-float -mhard-float -mdouble-float -munordered-float
1223 -mcmov -mror -mrori -msext -msfimm -mshftimm
1224 -mcmodel=@var{code-model}}
1226 @emph{PDP-11 Options}
1227 @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10
1228 -mint32 -mno-int16 -mint16 -mno-int32
1229 -msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1231 @emph{PowerPC Options}
1232 See RS/6000 and PowerPC Options.
1235 @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop
1236 -mabi=@var{variant}}
1238 @emph{RISC-V Options}
1239 @gccoptlist{-mbranch-cost=@var{N-instruction}
1241 -mabi=@var{ABI-string}
1244 -misa-spec=@var{ISA-spec-string}
1245 -march=@var{ISA-string}
1246 -mtune=@var{processor-string}
1247 -mpreferred-stack-boundary=@var{num}
1248 -msmall-data-limit=@var{N-bytes}
1249 -msave-restore -mno-save-restore
1250 -mshorten-memrefs -mno-shorten-memrefs
1251 -mstrict-align -mno-strict-align
1252 -mcmodel=medlow -mcmodel=medany
1253 -mexplicit-relocs -mno-explicit-relocs
1255 -mriscv-attribute -mno-riscv-attribute
1256 -malign-data=@var{type}
1257 -mbig-endian -mlittle-endian
1258 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1259 -mstack-protector-guard-offset=@var{offset}
1260 -mcsr-check -mno-csr-check
1262 -minline-atomics -mno-inline-atomics
1263 -minline-strlen -mno-inline-strlen
1264 -minline-strcmp -mno-inline-strcmp
1265 -minline-strncmp -mno-inline-strncmp}
1268 @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs
1269 -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
1270 -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1272 @emph{RS/6000 and PowerPC Options}
1273 @gccoptlist{-mcpu=@var{cpu-type}
1274 -mtune=@var{cpu-type}
1275 -mcmodel=@var{code-model}
1277 -maltivec -mno-altivec
1278 -mpowerpc-gpopt -mno-powerpc-gpopt
1279 -mpowerpc-gfxopt -mno-powerpc-gfxopt
1280 -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd
1282 -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp
1283 -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc
1284 -m64 -m32 -mxl-compat -mno-xl-compat -mpe
1285 -malign-power -malign-natural
1286 -msoft-float -mhard-float -mmultiple -mno-multiple
1287 -mupdate -mno-update
1288 -mavoid-indexed-addresses -mno-avoid-indexed-addresses
1289 -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
1290 -mstrict-align -mno-strict-align -mrelocatable
1291 -mno-relocatable -mrelocatable-lib -mno-relocatable-lib
1292 -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
1293 -mdynamic-no-pic -mswdiv -msingle-pic-base
1294 -mprioritize-restricted-insns=@var{priority}
1295 -msched-costly-dep=@var{dependence_type}
1296 -minsert-sched-nops=@var{scheme}
1297 -mcall-aixdesc -mcall-eabi -mcall-freebsd
1298 -mcall-linux -mcall-netbsd -mcall-openbsd
1299 -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi
1300 -mtraceback=@var{traceback_type}
1301 -maix-struct-return -msvr4-struct-return
1302 -mabi=@var{abi-type} -msecure-plt -mbss-plt
1303 -mlongcall -mno-longcall -mpltseq -mno-pltseq
1304 -mblock-move-inline-limit=@var{num}
1305 -mblock-compare-inline-limit=@var{num}
1306 -mblock-compare-inline-loop-limit=@var{num}
1307 -mno-block-ops-unaligned-vsx
1308 -mstring-compare-inline-limit=@var{num}
1310 -mvrsave -mno-vrsave
1313 -mprototype -mno-prototype
1314 -msim -mmvme -mads -myellowknife -memb -msdata
1315 -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num}
1316 -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision
1317 -mno-recip-precision
1318 -mveclibabi=@var{type} -mfriz -mno-friz
1319 -mpointers-to-nested-functions -mno-pointers-to-nested-functions
1320 -msave-toc-indirect -mno-save-toc-indirect
1321 -mpower8-fusion -mno-mpower8-fusion
1322 -mcrypto -mno-crypto -mhtm -mno-htm
1323 -mquad-memory -mno-quad-memory
1324 -mquad-memory-atomic -mno-quad-memory-atomic
1325 -mcompat-align-parm -mno-compat-align-parm
1326 -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware
1327 -mgnu-attribute -mno-gnu-attribute
1328 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1329 -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed
1330 -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect
1331 -mprivileged -mno-privileged}
1334 @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu
1336 -mbig-endian-data -mlittle-endian-data
1339 -mas100-syntax -mno-as100-syntax
1341 -mmax-constant-size=
1344 -mallow-string-insns -mno-allow-string-insns
1346 -mno-warn-multiple-fast-interrupts
1347 -msave-acc-in-interrupts}
1349 @emph{S/390 and zSeries Options}
1350 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1351 -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp
1352 -mlong-double-64 -mlong-double-128
1353 -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack
1354 -msmall-exec -mno-small-exec -mmvcle -mno-mvcle
1355 -m64 -m31 -mdebug -mno-debug -mesa -mzarch
1356 -mhtm -mvx -mzvector
1357 -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip
1358 -mfused-madd -mno-fused-madd
1359 -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard
1360 -mhotpatch=@var{halfwords},@var{halfwords}}
1363 @gccoptlist{-m1 -m2 -m2e
1364 -m2a-nofpu -m2a-single-only -m2a-single -m2a
1366 -m4-nofpu -m4-single-only -m4-single -m4
1367 -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al
1368 -mb -ml -mdalign -mrelax
1369 -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave
1370 -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct
1371 -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy}
1372 -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range}
1373 -maccumulate-outgoing-args
1374 -matomic-model=@var{atomic-model}
1375 -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch
1376 -mcbranch-force-delay-slot
1377 -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra
1378 -mpretend-cmove -mtas}
1380 @emph{Solaris 2 Options}
1381 @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text
1384 @emph{SPARC Options}
1385 @gccoptlist{-mcpu=@var{cpu-type}
1386 -mtune=@var{cpu-type}
1387 -mcmodel=@var{code-model}
1388 -mmemory-model=@var{mem-model}
1389 -m32 -m64 -mapp-regs -mno-app-regs
1390 -mfaster-structs -mno-faster-structs -mflat -mno-flat
1391 -mfpu -mno-fpu -mhard-float -msoft-float
1392 -mhard-quad-float -msoft-quad-float
1393 -mstack-bias -mno-stack-bias
1394 -mstd-struct-return -mno-std-struct-return
1395 -munaligned-doubles -mno-unaligned-doubles
1396 -muser-mode -mno-user-mode
1397 -mv8plus -mno-v8plus -mvis -mno-vis
1398 -mvis2 -mno-vis2 -mvis3 -mno-vis3
1399 -mvis4 -mno-vis4 -mvis4b -mno-vis4b
1400 -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld
1401 -mpopc -mno-popc -msubxc -mno-subxc
1402 -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc
1405 @emph{System V Options}
1406 @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1409 @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep
1410 -mprolog-function -mno-prolog-function -mspace
1411 -mtda=@var{n} -msda=@var{n} -mzda=@var{n}
1412 -mapp-regs -mno-app-regs
1413 -mdisable-callt -mno-disable-callt
1414 -mv850e2v3 -mv850e2 -mv850e1 -mv850es
1415 -mv850e -mv850 -mv850e3v5
1426 @gccoptlist{-mg -mgnu -munix -mlra}
1428 @emph{Visium Options}
1429 @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float
1430 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1433 @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64
1434 -mpointer-size=@var{size}}
1436 @emph{VxWorks Options}
1437 @gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic
1438 -Xbind-lazy -Xbind-now}
1441 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1442 -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default
1444 -masm=@var{dialect} -mno-fancy-math-387
1445 -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float
1446 -mno-wide-multiply -mrtd -malign-double
1447 -mpreferred-stack-boundary=@var{num}
1448 -mincoming-stack-boundary=@var{num}
1449 -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait
1450 -mrecip -mrecip=@var{opt}
1451 -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt}
1452 -mpartial-vector-fp-math
1453 -mmove-max=@var{bits} -mstore-max=@var{bits}
1454 -mnoreturn-no-callee-saved-registers
1455 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx
1456 -mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl
1457 -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
1458 -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd
1459 -mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves
1460 -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop
1461 -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp
1462 -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg
1463 -mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call
1464 -mavx512vbmi2 -mavx512bf16 -menqcmd
1465 -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
1466 -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid
1467 -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk
1468 -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni
1469 -mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16
1470 -mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf
1471 -musermsr -mavx10.1 -mavx10.1-256 -mavx10.1-512 -mevex512
1472 -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops
1473 -minline-stringops-dynamically -mstringop-strategy=@var{alg}
1475 -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy}
1476 -mpush-args -maccumulate-outgoing-args -m128bit-long-double
1477 -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128
1478 -mregparm=@var{num} -msseregparm
1479 -mveclibabi=@var{type} -mvect8-ret-in-mem
1480 -mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign
1481 -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
1482 -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode}
1483 -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num}
1484 -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv
1485 -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name}
1486 -mavx256-split-unaligned-load -mavx256-split-unaligned-store
1487 -malign-data=@var{type} -mstack-protector-guard=@var{guard}
1488 -mstack-protector-guard-reg=@var{reg}
1489 -mstack-protector-guard-offset=@var{offset}
1490 -mstack-protector-guard-symbol=@var{symbol}
1491 -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop
1492 -mindirect-branch=@var{choice} -mfunction-return=@var{choice}
1493 -mindirect-branch-register -mharden-sls=@var{choice}
1494 -mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access
1495 -munroll-only-small-loops -mlam=@var{choice}}
1497 @emph{x86 Windows Options}
1498 @gccoptlist{-mconsole -mcrtdll=@var{library} -mdll
1499 -mnop-fun-dllimport -mthread
1500 -municode -mwin32 -mwindows -fno-set-stack-executable}
1502 @emph{Xstormy16 Options}
1505 @emph{Xtensa Options}
1506 @gccoptlist{-mconst16 -mno-const16
1507 -mfused-madd -mno-fused-madd
1509 -mserialize-volatile -mno-serialize-volatile
1510 -mtext-section-literals -mno-text-section-literals
1511 -mauto-litpools -mno-auto-litpools
1512 -mtarget-align -mno-target-align
1513 -mlongcalls -mno-longcalls
1514 -mabi=@var{abi-type}
1515 -mextra-l32r-costs=@var{cycles}
1516 -mstrict-align -mno-strict-align}
1518 @emph{zSeries Options}
1519 See S/390 and zSeries Options.
1523 @node Overall Options
1524 @section Options Controlling the Kind of Output
1526 Compilation can involve up to four stages: preprocessing, compilation
1527 proper, assembly and linking, always in that order. GCC is capable of
1528 preprocessing and compiling several files either into several
1529 assembler input files, or into one assembler input file; then each
1530 assembler input file produces an object file, and linking combines all
1531 the object files (those newly compiled, and those specified as input)
1532 into an executable file.
1534 @cindex file name suffix
1535 For any given input file, the file name suffix determines what kind of
1536 compilation is done:
1540 C source code that must be preprocessed.
1543 C source code that should not be preprocessed.
1546 C++ source code that should not be preprocessed.
1549 Objective-C source code. Note that you must link with the @file{libobjc}
1550 library to make an Objective-C program work.
1553 Objective-C source code that should not be preprocessed.
1557 Objective-C++ source code. Note that you must link with the @file{libobjc}
1558 library to make an Objective-C++ program work. Note that @samp{.M} refers
1559 to a literal capital M@.
1561 @item @var{file}.mii
1562 Objective-C++ source code that should not be preprocessed.
1565 C, C++, Objective-C or Objective-C++ header file to be turned into a
1566 precompiled header (default), or C, C++ header file to be turned into an
1567 Ada spec (via the @option{-fdump-ada-spec} switch).
1570 @itemx @var{file}.cp
1571 @itemx @var{file}.cxx
1572 @itemx @var{file}.cpp
1573 @itemx @var{file}.CPP
1574 @itemx @var{file}.c++
1576 C++ source code that must be preprocessed. Note that in @samp{.cxx},
1577 the last two letters must both be literally @samp{x}. Likewise,
1578 @samp{.C} refers to a literal capital C@.
1582 Objective-C++ source code that must be preprocessed.
1584 @item @var{file}.mii
1585 Objective-C++ source code that should not be preprocessed.
1589 @itemx @var{file}.hp
1590 @itemx @var{file}.hxx
1591 @itemx @var{file}.hpp
1592 @itemx @var{file}.HPP
1593 @itemx @var{file}.h++
1594 @itemx @var{file}.tcc
1595 C++ header file to be turned into a precompiled header or Ada spec.
1598 @itemx @var{file}.for
1599 @itemx @var{file}.ftn
1600 @itemx @var{file}.fi
1601 Fixed form Fortran source code that should not be preprocessed.
1604 @itemx @var{file}.FOR
1605 @itemx @var{file}.fpp
1606 @itemx @var{file}.FPP
1607 @itemx @var{file}.FTN
1608 Fixed form Fortran source code that must be preprocessed (with the traditional
1611 @item @var{file}.f90
1612 @itemx @var{file}.f95
1613 @itemx @var{file}.f03
1614 @itemx @var{file}.f08
1615 @itemx @var{file}.fii
1616 Free form Fortran source code that should not be preprocessed.
1618 @item @var{file}.F90
1619 @itemx @var{file}.F95
1620 @itemx @var{file}.F03
1621 @itemx @var{file}.F08
1622 Free form Fortran source code that must be preprocessed (with the
1623 traditional preprocessor).
1635 D documentation code (Ddoc).
1637 @item @var{file}.ads
1638 Ada source code file that contains a library unit declaration (a
1639 declaration of a package, subprogram, or generic, or a generic
1640 instantiation), or a library unit renaming declaration (a package,
1641 generic, or subprogram renaming declaration). Such files are also
1644 @item @var{file}.adb
1645 Ada source code file containing a library unit body (a subprogram or
1646 package body). Such files are also called @dfn{bodies}.
1648 @c GCC also knows about some suffixes for languages not yet included:
1656 @itemx @var{file}.sx
1657 Assembler code that must be preprocessed.
1660 An object file to be fed straight into linking.
1661 Any file name with no recognized suffix is treated this way.
1665 You can specify the input language explicitly with the @option{-x} option:
1668 @item -x @var{language}
1669 Specify explicitly the @var{language} for the following input files
1670 (rather than letting the compiler choose a default based on the file
1671 name suffix). This option applies to all following input files until
1672 the next @option{-x} option. Possible values for @var{language} are:
1674 c c-header cpp-output
1675 c++ c++-header c++-system-header c++-user-header c++-cpp-output
1676 objective-c objective-c-header objective-c-cpp-output
1677 objective-c++ objective-c++-header objective-c++-cpp-output
1678 assembler assembler-with-cpp
1681 f77 f77-cpp-input f95 f95-cpp-input
1686 Turn off any specification of a language, so that subsequent files are
1687 handled according to their file name suffixes (as they are if @option{-x}
1688 has not been used at all).
1691 If you only want some of the stages of compilation, you can use
1692 @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1693 one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1694 @command{gcc} is to stop. Note that some combinations (for example,
1695 @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1700 Compile or assemble the source files, but do not link. The linking
1701 stage simply is not done. The ultimate output is in the form of an
1702 object file for each source file.
1704 By default, the object file name for a source file is made by replacing
1705 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1707 Unrecognized input files, not requiring compilation or assembly, are
1712 Stop after the stage of compilation proper; do not assemble. The output
1713 is in the form of an assembler code file for each non-assembler input
1716 By default, the assembler file name for a source file is made by
1717 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1719 Input files that don't require compilation are ignored.
1723 Stop after the preprocessing stage; do not run the compiler proper. The
1724 output is in the form of preprocessed source code, which is sent to the
1727 Input files that don't require preprocessing are ignored.
1729 @cindex output file option
1732 Place the primary output in file @var{file}. This applies to whatever
1733 sort of output is being produced, whether it be an executable file, an
1734 object file, an assembler file or preprocessed C code.
1736 If @option{-o} is not specified, the default is to put an executable
1737 file in @file{a.out}, the object file for
1738 @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1739 assembler file in @file{@var{source}.s}, a precompiled header file in
1740 @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1743 Though @option{-o} names only the primary output, it also affects the
1744 naming of auxiliary and dump outputs. See the examples below. Unless
1745 overridden, both auxiliary outputs and dump outputs are placed in the
1746 same directory as the primary output. In auxiliary outputs, the suffix
1747 of the input file is replaced with that of the auxiliary output file
1748 type; in dump outputs, the suffix of the dump file is appended to the
1749 input file suffix. In compilation commands, the base name of both
1750 auxiliary and dump outputs is that of the primary output; in compile and
1751 link commands, the primary output name, minus the executable suffix, is
1752 combined with the input file name. If both share the same base name,
1753 disregarding the suffix, the result of the combination is that base
1754 name, otherwise, they are concatenated, separated by a dash.
1760 will use @file{foo.o} as the primary output, and place aux outputs and
1761 dumps next to it, e.g., aux file @file{foo.dwo} for
1762 @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1763 @option{-fdump-rtl-final}.
1765 If a non-linker output file is explicitly specified, aux and dump files
1766 by default take the same base name:
1769 gcc -c foo.c -o dir/foobar.o ...
1772 will name aux outputs @file{dir/foobar.*} and dump outputs
1773 @file{dir/foobar.c.*}.
1775 A linker output will instead prefix aux and dump outputs:
1778 gcc foo.c bar.c -o dir/foobar ...
1781 will generally name aux outputs @file{dir/foobar-foo.*} and
1782 @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1783 @file{dir/foobar-bar.c.*}.
1785 The one exception to the above is when the executable shares the base
1786 name with the single input:
1789 gcc foo.c -o dir/foo ...
1792 in which case aux outputs are named @file{dir/foo.*} and dump outputs
1793 named @file{dir/foo.c.*}.
1795 The location and the names of auxiliary and dump outputs can be adjusted
1796 by the options @option{-dumpbase}, @option{-dumpbase-ext},
1797 @option{-dumpdir}, @option{-save-temps=cwd}, and
1798 @option{-save-temps=obj}.
1802 @item -dumpbase @var{dumpbase}
1803 This option sets the base name for auxiliary and dump output files. It
1804 does not affect the name of the primary output file. Intermediate
1805 outputs, when preserved, are not regarded as primary outputs, but as
1809 gcc -save-temps -S foo.c
1812 saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1813 then compiles to the (implied) output file @file{foo.s}, whereas:
1816 gcc -save-temps -dumpbase save-foo -c foo.c
1819 preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1820 an intermediate, thus auxiliary output), and then assembles to the
1821 (implied) output file @file{foo.o}.
1823 Absent this option, dump and aux files take their names from the input
1824 file, or from the (non-linker) output file, if one is explicitly
1825 specified: dump output files (e.g. those requested by @option{-fdump-*}
1826 options) with the input name suffix, and aux output files (those
1827 requested by other non-dump options, e.g. @code{-save-temps},
1828 @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1830 Similar suffix differentiation of dump and aux outputs can be attained
1831 for explicitly-given @option{-dumpbase basename.suf} by also specifying
1832 @option{-dumpbase-ext .suf}.
1834 If @var{dumpbase} is explicitly specified with any directory component,
1835 any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1836 @option{-save-temps=*}) is ignored, and instead of appending to it,
1837 @var{dumpbase} fully overrides it:
1840 gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1841 -dumpdir pfx- -save-temps=cwd ...
1844 creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1845 @file{dir/} in @option{-o}, the @file{./} prefix implied by
1846 @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1848 When @option{-dumpbase} is specified in a command that compiles multiple
1849 inputs, or that compiles and then links, it may be combined with
1850 @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1851 file is compiled using the combined @var{dumppfx}, and default values
1852 for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1856 gcc foo.c bar.c -c -dumpbase main ...
1859 creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1860 overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1861 as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1862 and @file{main-bar.*}.
1864 An empty string specified as @var{dumpbase} avoids the influence of the
1865 output basename in the naming of auxiliary and dump outputs during
1866 compilation, computing default values :
1869 gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1872 will name aux outputs @file{dir/foo.*} and dump outputs
1873 @file{dir/foo.c.*}. Note how their basenames are taken from the input
1874 name, but the directory still defaults to that of the output.
1876 The empty-string dumpbase does not prevent the use of the output
1877 basename for outputs during linking:
1880 gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1883 The compilation of the source files will name auxiliary outputs
1884 @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1885 @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1886 linking will use @file{dir/foobar.} as the prefix for dumps and
1890 @opindex dumpbase-ext
1891 @item -dumpbase-ext @var{auxdropsuf}
1892 When forming the name of an auxiliary (but not a dump) output file, drop
1893 trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1894 suffixes. If not specified, this option defaults to the suffix of a
1895 default @var{dumpbase}, i.e., the suffix of the input file when
1896 @option{-dumpbase} is not present in the command line, or @var{dumpbase}
1897 is combined with @var{dumppfx}.
1900 gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1903 creates @file{dir/foo.o} as the main output, and generates auxiliary
1904 outputs in @file{dir/x-foo.*}, taking the location of the primary
1905 output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1906 outputs retain the suffix: @file{dir/x-foo.c.*}.
1908 This option is disregarded if it does not match the suffix of a
1909 specified @var{dumpbase}, except as an alternative to the executable
1910 suffix when appending the linker output base name to @var{dumppfx}, as
1914 gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1917 creates @file{main.out} as the primary output, and avoids overwriting
1918 the auxiliary and dump outputs by using the executable name minus
1919 @var{auxdropsuf} as a prefix, creating auxiliary outputs named
1920 @file{main-foo.*} and @file{main-bar.*} and dump outputs named
1921 @file{main-foo.c.*} and @file{main-bar.c.*}.
1925 @item -dumpdir @var{dumppfx}
1926 When forming the name of an auxiliary or dump output file, use
1927 @var{dumppfx} as a prefix:
1930 gcc -dumpdir pfx- -c foo.c ...
1933 creates @file{foo.o} as the primary output, and auxiliary outputs named
1934 @file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1935 @var{dumpbase} derived from the default primary output, derived in turn
1936 from the input name. Dump outputs also take the input name suffix:
1939 If @var{dumppfx} is to be used as a directory name, it must end with a
1940 directory separator:
1943 gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1946 creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1947 named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1948 default @var{dumpbase} derived from the primary output name. Dump
1949 outputs also take the input name suffix: @file{dir/bar.c.*}.
1951 It defaults to the location of the output file, unless the output
1952 file is a special file like @code{/dev/null}. Options
1953 @option{-save-temps=cwd} and @option{-save-temps=obj} override this
1954 default, just like an explicit @option{-dumpdir} option. In case
1955 multiple such options are given, the last one prevails:
1958 gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1961 outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1962 @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1963 @option{-dumpdir} option. It does not matter that @option{=obj} is the
1964 default for @option{-save-temps}, nor that the output directory is
1965 implicitly the current directory. Dump outputs are named
1968 When compiling from multiple input files, if @option{-dumpbase} is
1969 specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1970 are appended to (or override, if containing any directory components) an
1971 explicit or defaulted @var{dumppfx}, so that each of the multiple
1972 compilations gets differently-named aux and dump outputs.
1975 gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1978 outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1979 @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1980 Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1981 and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1982 single-input compilation:
1985 gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1988 that, applying @option{-dumpbase} to a single source, does not compute
1989 and append a separate @var{dumpbase} per input file. Its auxiliary and
1990 dump outputs go in @file{dir/pfx-main.*}.
1992 When compiling and then linking from multiple input files, a defaulted
1993 or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1994 transformation above (e.g. the compilation of @file{foo.c} and
1995 @file{bar.c} above, but without @option{-c}). If neither
1996 @option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1997 base name, minus @var{auxdropsuf}, if specified, or the executable
1998 suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1999 instead. Note, however, that unlike earlier cases of linking:
2002 gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
2005 does not append the output name @file{main} to @var{dumppfx}, because
2006 @option{-dumpdir} is explicitly specified. The goal is that the
2007 explicitly-specified @var{dumppfx} may contain the specified output name
2008 as part of the prefix, if desired; only an explicitly-specified
2009 @option{-dumpbase} would be combined with it, in order to avoid simply
2010 discarding a meaningful option.
2012 When compiling and then linking from a single input file, the linker
2013 output base name will only be appended to the default @var{dumppfx} as
2014 above if it does not share the base name with the single input file
2015 name. This has been covered in single-input linking cases above, but
2016 not with an explicit @option{-dumpdir} that inhibits the combination,
2017 even if overridden by @option{-save-temps=*}:
2020 gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
2023 Auxiliary outputs are named @file{foo.*}, and dump outputs
2024 @file{foo.c.*}, in the current working directory as ultimately requested
2025 by @option{-save-temps=cwd}.
2027 Summing it all up for an intuitive though slightly imprecise data flow:
2028 the primary output name is broken into a directory part and a basename
2029 part; @var{dumppfx} is set to the former, unless overridden by
2030 @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
2031 to the latter, unless overriden by @option{-dumpbase}. If there are
2032 multiple inputs or linking, this @var{dumpbase} may be combined with
2033 @var{dumppfx} and taken from each input file. Auxiliary output names
2034 for each input are formed by combining @var{dumppfx}, @var{dumpbase}
2035 minus suffix, and the auxiliary output suffix; dump output names are
2036 only different in that the suffix from @var{dumpbase} is retained.
2038 When it comes to auxiliary and dump outputs created during LTO
2039 recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
2040 given or as derived from the linker output name but not from inputs,
2041 even in cases in which this combination would not otherwise be used as
2042 such, is passed down with a trailing period replacing the compiler-added
2043 dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2044 being involved in linking, this program does not normally get any
2045 @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2047 When running sub-compilers, @command{lto-wrapper} appends LTO stage
2048 names to the received @var{dumppfx}, ensures it contains a directory
2049 component so that it overrides any @option{-dumpdir}, and passes that as
2050 @option{-dumpbase} to sub-compilers.
2054 Print (on standard error output) the commands executed to run the stages
2055 of compilation. Also print the version number of the compiler driver
2056 program and of the preprocessor and the compiler proper.
2060 Like @option{-v} except the commands are not executed and arguments
2061 are quoted unless they contain only alphanumeric characters or @code{./-_}.
2062 This is useful for shell scripts to capture the driver-generated command lines.
2066 Print (on the standard output) a description of the command-line options
2067 understood by @command{gcc}. If the @option{-v} option is also specified
2068 then @option{--help} is also passed on to the various processes
2069 invoked by @command{gcc}, so that they can display the command-line options
2070 they accept. If the @option{-Wextra} option has also been specified
2071 (prior to the @option{--help} option), then command-line options that
2072 have no documentation associated with them are also displayed.
2074 @opindex target-help
2076 Print (on the standard output) a description of target-specific command-line
2077 options for each tool. For some targets extra target-specific
2078 information may also be printed.
2080 @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2081 Print (on the standard output) a description of the command-line
2082 options understood by the compiler that fit into all specified classes
2083 and qualifiers. These are the supported classes:
2086 @item @samp{optimizers}
2087 Display all of the optimization options supported by the
2090 @item @samp{warnings}
2091 Display all of the options controlling warning messages
2092 produced by the compiler.
2095 Display target-specific options. Unlike the
2096 @option{--target-help} option however, target-specific options of the
2097 linker and assembler are not displayed. This is because those
2098 tools do not currently support the extended @option{--help=} syntax.
2101 Display the values recognized by the @option{--param}
2104 @item @var{language}
2105 Display the options supported for @var{language}, where
2106 @var{language} is the name of one of the languages supported in this
2107 version of GCC@. If an option is supported by all languages, one needs
2108 to select @samp{common} class.
2111 Display the options that are common to all languages.
2114 These are the supported qualifiers:
2117 @item @samp{undocumented}
2118 Display only those options that are undocumented.
2121 Display options taking an argument that appears after an equal
2122 sign in the same continuous piece of text, such as:
2123 @samp{--help=target}.
2125 @item @samp{separate}
2126 Display options taking an argument that appears as a separate word
2127 following the original option, such as: @samp{-o output-file}.
2130 Thus for example to display all the undocumented target-specific
2131 switches supported by the compiler, use:
2134 --help=target,undocumented
2137 The sense of a qualifier can be inverted by prefixing it with the
2138 @samp{^} character, so for example to display all binary warning
2139 options (i.e., ones that are either on or off and that do not take an
2140 argument) that have a description, use:
2143 --help=warnings,^joined,^undocumented
2146 The argument to @option{--help=} should not consist solely of inverted
2149 Combining several classes is possible, although this usually
2150 restricts the output so much that there is nothing to display. One
2151 case where it does work, however, is when one of the classes is
2152 @var{target}. For example, to display all the target-specific
2153 optimization options, use:
2156 --help=target,optimizers
2159 The @option{--help=} option can be repeated on the command line. Each
2160 successive use displays its requested class of options, skipping
2161 those that have already been displayed. If @option{--help} is also
2162 specified anywhere on the command line then this takes precedence
2163 over any @option{--help=} option.
2165 If the @option{-Q} option appears on the command line before the
2166 @option{--help=} option, then the descriptive text displayed by
2167 @option{--help=} is changed. Instead of describing the displayed
2168 options, an indication is given as to whether the option is enabled,
2169 disabled or set to a specific value (assuming that the compiler
2170 knows this at the point where the @option{--help=} option is used).
2172 Here is a truncated example from the ARM port of @command{gcc}:
2175 % gcc -Q -mabi=2 --help=target -c
2176 The following options are target specific:
2178 -mabort-on-noreturn [disabled]
2182 The output is sensitive to the effects of previous command-line
2183 options, so for example it is possible to find out which optimizations
2184 are enabled at @option{-O2} by using:
2187 -Q -O2 --help=optimizers
2190 Alternatively you can discover which binary optimizations are enabled
2191 by @option{-O3} by using:
2194 gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2195 gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2196 diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2201 Display the version number and copyrights of the invoked GCC@.
2203 @opindex pass-exit-codes
2204 @item -pass-exit-codes
2205 Normally the @command{gcc} program exits with the code of 1 if any
2206 phase of the compiler returns a non-success return code. If you specify
2207 @option{-pass-exit-codes}, the @command{gcc} program instead returns with
2208 the numerically highest error produced by any phase returning an error
2209 indication. The C, C++, and Fortran front ends return 4 if an internal
2210 compiler error is encountered.
2214 Use pipes rather than temporary files for communication between the
2215 various stages of compilation. This fails to work on some systems where
2216 the assembler is unable to read from a pipe; but the GNU assembler has
2220 @item -specs=@var{file}
2221 Process @var{file} after the compiler reads in the standard @file{specs}
2222 file, in order to override the defaults which the @command{gcc} driver
2223 program uses when determining what switches to pass to @command{cc1},
2224 @command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2225 @option{-specs=@var{file}} can be specified on the command line, and they
2226 are processed in order, from left to right. @xref{Spec Files}, for
2227 information about the format of the @var{file}.
2231 Invoke all subcommands under a wrapper program. The name of the
2232 wrapper program and its parameters are passed as a comma separated
2236 gcc -c t.c -wrapper gdb,--args
2240 This invokes all subprograms of @command{gcc} under
2241 @samp{gdb --args}, thus the invocation of @command{cc1} is
2242 @samp{gdb --args cc1 @dots{}}.
2244 @opindex ffile-prefix-map
2245 @item -ffile-prefix-map=@var{old}=@var{new}
2246 When compiling files residing in directory @file{@var{old}}, record
2247 any references to them in the result of the compilation as if the
2248 files resided in directory @file{@var{new}} instead. Specifying this
2249 option is equivalent to specifying all the individual
2250 @option{-f*-prefix-map} options. This can be used to make reproducible
2251 builds that are location independent. Directories referenced by
2252 directives are not affected by these options. See also
2253 @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map},
2254 @option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}.
2256 @opindex fcanon-prefix-map
2257 @item -fcanon-prefix-map
2258 For the @option{-f*-prefix-map} options normally comparison
2259 of @file{@var{old}} prefix against the filename that would be normally
2260 referenced in the result of the compilation is done using textual
2261 comparison of the prefixes, or ignoring character case for case insensitive
2262 filesystems and considering slashes and backslashes as equal on DOS based
2263 filesystems. The @option{-fcanon-prefix-map} causes such comparisons
2264 to be done on canonicalized paths of @file{@var{old}}
2265 and the referenced filename.
2268 @item -fplugin=@var{name}.so
2269 Load the plugin code in file @var{name}.so, assumed to be a
2270 shared object to be dlopen'd by the compiler. The base name of
2271 the shared object file is used to identify the plugin for the
2272 purposes of argument parsing (See
2273 @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2274 Each plugin should define the callback functions specified in the
2277 @opindex fplugin-arg
2278 @item -fplugin-arg-@var{name}-@var{key}=@var{value}
2279 Define an argument called @var{key} with a value of @var{value}
2280 for the plugin called @var{name}.
2282 @opindex fdump-ada-spec
2283 @item -fdump-ada-spec@r{[}-slim@r{]}
2284 For C and C++ source and include files, generate corresponding Ada specs.
2285 @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2286 GNAT User's Guide}, which provides detailed documentation on this feature.
2288 @opindex fada-spec-parent
2289 @item -fada-spec-parent=@var{unit}
2290 In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2291 Ada specs as child units of parent @var{unit}.
2293 @opindex fdump-go-spec
2294 @item -fdump-go-spec=@var{file}
2295 For input files in any language, generate corresponding Go
2296 declarations in @var{file}. This generates Go @code{const},
2297 @code{type}, @code{var}, and @code{func} declarations which may be a
2298 useful way to start writing a Go interface to code written in some
2301 @include @value{srcdir}/../libiberty/at-file.texi
2305 @section Compiling C++ Programs
2307 @cindex suffixes for C++ source
2308 @cindex C++ source file suffixes
2309 C++ source files conventionally use one of the suffixes @samp{.C},
2310 @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2311 @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2312 @samp{.H}, or (for shared template code) @samp{.tcc}; and
2313 preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2314 files with these names and compiles them as C++ programs even if you
2315 call the compiler the same way as for compiling C programs (usually
2316 with the name @command{gcc}).
2320 However, the use of @command{gcc} does not add the C++ library.
2321 @command{g++} is a program that calls GCC and automatically specifies linking
2322 against the C++ library. It treats @samp{.c},
2323 @samp{.h} and @samp{.i} files as C++ source files instead of C source
2324 files unless @option{-x} is used. This program is also useful when
2325 precompiling a C header file with a @samp{.h} extension for use in C++
2326 compilations. On many systems, @command{g++} is also installed with
2327 the name @command{c++}.
2329 @cindex invoking @command{g++}
2330 When you compile C++ programs, you may specify many of the same
2331 command-line options that you use for compiling programs in any
2332 language; or command-line options meaningful for C and related
2333 languages; or options that are meaningful only for C++ programs.
2334 @xref{C Dialect Options,,Options Controlling C Dialect}, for
2335 explanations of options for languages related to C@.
2336 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2337 explanations of options that are meaningful only for C++ programs.
2339 @node C Dialect Options
2340 @section Options Controlling C Dialect
2341 @cindex dialect options
2342 @cindex language dialect options
2343 @cindex options, dialect
2345 The following options control the dialect of C (or languages derived
2346 from C, such as C++, Objective-C and Objective-C++) that the compiler
2350 @cindex ANSI support
2354 In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2355 equivalent to @option{-std=c++98}.
2357 This turns off certain features of GCC that are incompatible with ISO
2358 C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2359 such as the @code{asm} and @code{typeof} keywords, and
2360 predefined macros such as @code{unix} and @code{vax} that identify the
2361 type of system you are using. It also enables the undesirable and
2362 rarely used ISO trigraph feature. For the C compiler,
2363 it disables recognition of C++ style @samp{//} comments as well as
2364 the @code{inline} keyword.
2366 The alternate keywords @code{__asm__}, @code{__extension__},
2367 @code{__inline__} and @code{__typeof__} continue to work despite
2368 @option{-ansi}. You would not want to use them in an ISO C program, of
2369 course, but it is useful to put them in header files that might be included
2370 in compilations done with @option{-ansi}. Alternate predefined macros
2371 such as @code{__unix__} and @code{__vax__} are also available, with or
2372 without @option{-ansi}.
2374 The @option{-ansi} option does not cause non-ISO programs to be
2375 rejected gratuitously. For that, @option{-Wpedantic} is required in
2376 addition to @option{-ansi}. @xref{Warning Options}.
2378 The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2379 option is used. Some header files may notice this macro and refrain
2380 from declaring certain functions or defining certain macros that the
2381 ISO standard doesn't call for; this is to avoid interfering with any
2382 programs that might use these names for other things.
2384 Functions that are normally built in but do not have semantics
2385 defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2386 functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2387 built-in functions provided by GCC}, for details of the functions
2392 Determine the language standard. @xref{Standards,,Language Standards
2393 Supported by GCC}, for details of these standard versions. This option
2394 is currently only supported when compiling C or C++.
2396 The compiler can accept several base standards, such as @samp{c90} or
2397 @samp{c++98}, and GNU dialects of those standards, such as
2398 @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2399 compiler accepts all programs following that standard plus those
2400 using GNU extensions that do not contradict it. For example,
2401 @option{-std=c90} turns off certain features of GCC that are
2402 incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2403 keywords, but not other GNU extensions that do not have a meaning in
2404 ISO C90, such as omitting the middle term of a @code{?:}
2405 expression. On the other hand, when a GNU dialect of a standard is
2406 specified, all features supported by the compiler are enabled, even when
2407 those features change the meaning of the base standard. As a result, some
2408 strict-conforming programs may be rejected. The particular standard
2409 is used by @option{-Wpedantic} to identify which features are GNU
2410 extensions given that version of the standard. For example
2411 @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2412 comments, while @option{-std=gnu99 -Wpedantic} does not.
2414 A value for this option must be provided; possible values are
2420 Support all ISO C90 programs (certain GNU extensions that conflict
2421 with ISO C90 are disabled). Same as @option{-ansi} for C code.
2423 @item iso9899:199409
2424 ISO C90 as modified in amendment 1.
2430 ISO C99. This standard is substantially completely supported, modulo
2431 bugs and floating-point issues
2432 (mainly but not entirely relating to optional C99 features from
2433 Annexes F and G). See
2434 @w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2435 names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2440 ISO C11, the 2011 revision of the ISO C standard. This standard is
2441 substantially completely supported, modulo bugs, floating-point issues
2442 (mainly but not entirely relating to optional C11 features from
2443 Annexes F and G) and the optional Annexes K (Bounds-checking
2444 interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2450 ISO C17, the 2017 revision of the ISO C standard
2451 (published in 2018). This standard is
2452 same as C11 except for corrections of defects (all of which are also
2453 applied with @option{-std=c11}) and a new value of
2454 @code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2459 ISO C23, the 2023 revision of the ISO C standard (expected to be
2460 published in 2024). The support for this version is experimental and
2461 incomplete. The name @samp{c2x} is deprecated.
2465 GNU dialect of ISO C90 (including some C99 features).
2469 GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2473 GNU dialect of ISO C11.
2474 The name @samp{gnu1x} is deprecated.
2478 GNU dialect of ISO C17. This is the default for C code.
2482 The next version of the ISO C standard, still under development, plus
2483 GNU extensions. The support for this version is experimental and
2484 incomplete. The name @samp{gnu2x} is deprecated.
2488 The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2489 additional defect reports. Same as @option{-ansi} for C++ code.
2493 GNU dialect of @option{-std=c++98}.
2497 The 2011 ISO C++ standard plus amendments.
2498 The name @samp{c++0x} is deprecated.
2502 GNU dialect of @option{-std=c++11}.
2503 The name @samp{gnu++0x} is deprecated.
2507 The 2014 ISO C++ standard plus amendments.
2508 The name @samp{c++1y} is deprecated.
2512 GNU dialect of @option{-std=c++14}.
2513 The name @samp{gnu++1y} is deprecated.
2517 The 2017 ISO C++ standard plus amendments.
2518 The name @samp{c++1z} is deprecated.
2522 GNU dialect of @option{-std=c++17}.
2523 This is the default for C++ code.
2524 The name @samp{gnu++1z} is deprecated.
2528 The 2020 ISO C++ standard plus amendments.
2529 Support is experimental, and could change in incompatible ways in
2531 The name @samp{c++2a} is deprecated.
2535 GNU dialect of @option{-std=c++20}.
2536 Support is experimental, and could change in incompatible ways in
2538 The name @samp{gnu++2a} is deprecated.
2542 The next revision of the ISO C++ standard, planned for
2543 2023. Support is highly experimental, and will almost certainly
2544 change in incompatible ways in future releases.
2548 GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2549 and will almost certainly change in incompatible ways in future
2554 The next revision of the ISO C++ standard, planned for
2555 2026. Support is highly experimental, and will almost certainly
2556 change in incompatible ways in future releases.
2560 GNU dialect of @option{-std=c++2c}. Support is highly experimental,
2561 and will almost certainly change in incompatible ways in future
2566 @item -aux-info @var{filename}
2567 Output to the given filename prototyped declarations for all functions
2568 declared and/or defined in a translation unit, including those in header
2569 files. This option is silently ignored in any language other than C@.
2571 Besides declarations, the file indicates, in comments, the origin of
2572 each declaration (source file and line), whether the declaration was
2573 implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2574 @samp{O} for old, respectively, in the first character after the line
2575 number and the colon), and whether it came from a declaration or a
2576 definition (@samp{C} or @samp{F}, respectively, in the following
2577 character). In the case of function definitions, a K&R-style list of
2578 arguments followed by their declarations is also provided, inside
2579 comments, after the declaration.
2584 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2585 keyword, so that code can use these words as identifiers. You can use
2586 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2587 instead. In C, @option{-ansi} implies @option{-fno-asm}.
2589 In C++, @code{inline} is a standard keyword and is not affected by
2590 this switch. You may want to use the @option{-fno-gnu-keywords} flag
2591 instead, which disables @code{typeof} but not @code{asm} and
2592 @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2593 this switch only affects the @code{asm} and @code{typeof} keywords,
2594 since @code{inline} is a standard keyword in ISO C99. In C23 mode
2595 (@option{-std=c23} or @option{-std=gnu23}), this switch only affects
2596 the @code{asm} keyword, since @code{typeof} is a standard keyword in
2599 @opindex fno-builtin
2601 @cindex built-in functions
2603 @itemx -fno-builtin-@var{function}
2604 Don't recognize built-in functions that do not begin with
2605 @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2606 functions provided by GCC}, for details of the functions affected,
2607 including those which are not built-in functions when @option{-ansi} or
2608 @option{-std} options for strict ISO C conformance are used because they
2609 do not have an ISO standard meaning.
2611 GCC normally generates special code to handle certain built-in functions
2612 more efficiently; for instance, calls to @code{alloca} may become single
2613 instructions which adjust the stack directly, and calls to @code{memcpy}
2614 may become inline copy loops. The resulting code is often both smaller
2615 and faster, but since the function calls no longer appear as such, you
2616 cannot set a breakpoint on those calls, nor can you change the behavior
2617 of the functions by linking with a different library. In addition,
2618 when a function is recognized as a built-in function, GCC may use
2619 information about that function to warn about problems with calls to
2620 that function, or to generate more efficient code, even if the
2621 resulting code still contains calls to that function. For example,
2622 warnings are given with @option{-Wformat} for bad calls to
2623 @code{printf} when @code{printf} is built in and @code{strlen} is
2624 known not to modify global memory.
2626 With the @option{-fno-builtin-@var{function}} option
2627 only the built-in function @var{function} is
2628 disabled. @var{function} must not begin with @samp{__builtin_}. If a
2629 function is named that is not built-in in this version of GCC, this
2630 option is ignored. There is no corresponding
2631 @option{-fbuiltin-@var{function}} option; if you wish to enable
2632 built-in functions selectively when using @option{-fno-builtin} or
2633 @option{-ffreestanding}, you may define macros such as:
2636 #define abs(n) __builtin_abs ((n))
2637 #define strcpy(d, s) __builtin_strcpy ((d), (s))
2640 @opindex fcond-mismatch
2641 @item -fcond-mismatch
2642 Allow conditional expressions with mismatched types in the second and
2643 third arguments. The value of such an expression is void. This option
2644 is not supported for C++.
2646 @opindex ffreestanding
2647 @cindex hosted environment
2648 @item -ffreestanding
2650 Assert that compilation targets a freestanding environment. This
2651 implies @option{-fno-builtin}. A freestanding environment
2652 is one in which the standard library may not exist, and program startup may
2653 not necessarily be at @code{main}. The most obvious example is an OS kernel.
2654 This is equivalent to @option{-fno-hosted}.
2656 @xref{Standards,,Language Standards Supported by GCC}, for details of
2657 freestanding and hosted environments.
2662 Enable parsing of function definitions marked with @code{__GIMPLE}.
2663 This is an experimental feature that allows unit testing of GIMPLE
2668 When the option @option{-fgnu-tm} is specified, the compiler
2669 generates code for the Linux variant of Intel's current Transactional
2670 Memory ABI specification document (Revision 1.1, May 6 2009). This is
2671 an experimental feature whose interface may change in future versions
2672 of GCC, as the official specification changes. Please note that not
2673 all architectures are supported for this feature.
2675 For more information on GCC's support for transactional memory,
2676 @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2677 Transactional Memory Library}.
2679 Note that the transactional memory feature is not supported with
2680 non-call exceptions (@option{-fnon-call-exceptions}).
2682 @opindex fgnu89-inline
2683 @item -fgnu89-inline
2684 The option @option{-fgnu89-inline} tells GCC to use the traditional
2685 GNU semantics for @code{inline} functions when in C99 mode.
2686 @xref{Inline,,An Inline Function is As Fast As a Macro}.
2687 Using this option is roughly equivalent to adding the
2688 @code{gnu_inline} function attribute to all inline functions
2689 (@pxref{Function Attributes}).
2691 The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2692 C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2693 specifies the default behavior).
2694 This option is not supported in @option{-std=c90} or
2695 @option{-std=gnu90} mode.
2697 The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2698 @code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2699 in effect for @code{inline} functions. @xref{Common Predefined
2700 Macros,,,cpp,The C Preprocessor}.
2703 @cindex hosted environment
2706 Assert that compilation targets a hosted environment. This implies
2707 @option{-fbuiltin}. A hosted environment is one in which the
2708 entire standard library is available, and in which @code{main} has a return
2709 type of @code{int}. Examples are nearly everything except a kernel.
2710 This is equivalent to @option{-fno-freestanding}.
2712 @opindex flax-vector-conversions
2713 @item -flax-vector-conversions
2714 Allow implicit conversions between vectors with differing numbers of
2715 elements and/or incompatible element types. This option should not be
2718 @opindex fms-extensions
2719 @item -fms-extensions
2720 Accept some non-standard constructs used in Microsoft header files.
2722 In C++ code, this allows member names in structures to be similar
2723 to previous types declarations.
2732 Some cases of unnamed fields in structures and unions are only
2733 accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2734 fields within structs/unions}, for details.
2736 Note that this option is off for all targets except for x86
2737 targets using ms-abi.
2740 @cindex Offloading targets
2741 @cindex OpenACC offloading targets
2742 @cindex OpenMP offloading targets
2743 @item -foffload=disable
2744 @itemx -foffload=default
2745 @itemx -foffload=@var{target-list}
2746 Specify for which OpenMP and OpenACC offload targets code should be generated.
2747 The default behavior, equivalent to @option{-foffload=default}, is to generate
2748 code for all supported offload targets. The @option{-foffload=disable} form
2749 generates code only for the host fallback, while
2750 @option{-foffload=@var{target-list}} generates code only for the specified
2751 comma-separated list of offload targets.
2753 Offload targets are specified in GCC's internal target-triplet format. You can
2754 run the compiler with @option{-v} to show the list of configured offload targets
2755 under @code{OFFLOAD_TARGET_NAMES}.
2757 @opindex foffload-options
2758 @cindex Offloading options
2759 @cindex OpenACC offloading options
2760 @cindex OpenMP offloading options
2761 @item -foffload-options=@var{options}
2762 @itemx -foffload-options=@var{target-triplet-list}=@var{options}
2764 With @option{-foffload-options=@var{options}}, GCC passes the specified
2765 @var{options} to the compilers for all enabled offloading targets. You can
2766 specify options that apply only to a specific target or targets by using
2767 the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2768 @var{target-list} is a comma-separated list in the same format as for the
2769 @option{-foffload=} option.
2771 Typical command lines are
2774 -foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic
2775 -foffload-options=amdgcn-amdhsa=-march=gfx906
2779 @cindex OpenACC accelerator programming
2781 Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and
2782 @samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and
2783 @samp{*$acc} in fixed-form Fortran. When @option{-fopenacc} is specified,
2784 the compiler generates accelerated code according to the OpenACC Application
2785 Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2786 implies @option{-pthread}, and thus is only supported on targets that
2787 have support for @option{-pthread}.
2789 @opindex fopenacc-dim
2790 @cindex OpenACC accelerator programming
2791 @item -fopenacc-dim=@var{geom}
2792 Specify default compute dimensions for parallel offload regions that do
2793 not explicitly specify. The @var{geom} value is a triple of
2794 ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2795 can be omitted, to use a target-specific default value.
2798 @cindex OpenMP parallel
2800 Enable handling of OpenMP directives @samp{#pragma omp},
2801 @samp{[[omp::directive(...)]]}, @samp{[[omp::sequence(...)]]} and
2802 @samp{[[omp::decl(...)]]} in C/C++ and @samp{!$omp} in Fortran. It
2803 additionally enables the conditional compilation sentinel @samp{!$} in
2804 Fortran. In fixed source form Fortran, the sentinels can also start with
2805 @samp{c} or @samp{*}. When @option{-fopenmp} is specified, the
2806 compiler generates parallel code according to the OpenMP Application
2807 Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2808 implies @option{-pthread}, and thus is only supported on targets that
2809 have support for @option{-pthread}. @option{-fopenmp} implies
2810 @option{-fopenmp-simd}.
2812 @opindex fopenmp-simd
2816 Enable handling of OpenMP's @code{simd}, @code{declare simd},
2817 @code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}
2818 and @code{loop} directive, and of combined or composite directives with
2819 @code{simd} as constituent with @code{#pragma omp},
2820 @code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and
2821 @code{[[omp::decl(...)]]} in C/C++ and @code{!$omp} in Fortran. It
2822 additionally enables the conditional compilation sentinel @samp{!$} in
2823 Fortran. In fixed source form Fortran, the sentinels can also start with
2824 @samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless
2825 @option{-fopenmp} is additionally specified, the @code{loop} region binds
2826 to the current task region, independent of the specified @code{bind} clause.
2828 @opindex fopenmp-target-simd-clone
2829 @cindex OpenMP target SIMD clone
2830 @item -fopenmp-target-simd-clone
2831 @item -fopenmp-target-simd-clone=@var{device-type}
2832 In addition to generating SIMD clones for functions marked with the
2833 @code{declare simd} directive, GCC also generates clones
2834 for functions marked with the OpenMP @code{declare target} directive
2835 that are suitable for vectorization when this option is in effect. The
2836 @var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2837 and @code{any}, which correspond to keywords for the @code{device_type}
2838 clause of the @code{declare target} directive; clones are generated for
2839 the intersection of devices specified.
2840 @option{-fopenmp-target-simd-clone} is equivalent to
2841 @option{-fopenmp-target-simd-clone=any} and
2842 @option{-fno-openmp-target-simd-clone} is equivalent to
2843 @option{-fopenmp-target-simd-clone=none}.
2845 At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2846 optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2847 it is disabled by default.
2849 @opindex fpermitted-flt-eval-methods
2850 @opindex fpermitted-flt-eval-methods=c11
2851 @opindex fpermitted-flt-eval-methods=ts-18661-3
2852 @item -fpermitted-flt-eval-methods=@var{style}
2853 ISO/IEC TS 18661-3 defines new permissible values for
2854 @code{FLT_EVAL_METHOD} that indicate that operations and constants with
2855 a semantic type that is an interchange or extended format should be
2856 evaluated to the precision and range of that type. These new values are
2857 a superset of those permitted under C99/C11, which does not specify the
2858 meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2859 conforming to C11 may not have been written expecting the possibility of
2862 @option{-fpermitted-flt-eval-methods} specifies whether the compiler
2863 should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2864 or the extended set of values specified in ISO/IEC TS 18661-3.
2866 @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2868 The default when in a standards compliant mode (@option{-std=c11} or similar)
2869 is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2870 dialect (@option{-std=gnu11} or similar) is
2871 @option{-fpermitted-flt-eval-methods=ts-18661-3}.
2874 The @samp{-fdeps-*} options are used to extract structured dependency
2875 information for a source. This involves determining what resources provided by
2876 other source files will be required to compile the source as well as what
2877 resources are provided by the source. This information can be used to add
2878 required dependencies between compilation rules of dependent sources based on
2879 their contents rather than requiring such information be reflected within the
2880 build tools as well.
2883 @item -fdeps-file=@var{file}
2884 Where to write structured dependency information.
2886 @opindex fdeps-format
2887 @item -fdeps-format=@var{format}
2888 The format to use for structured dependency information. @samp{p1689r5} is the
2889 only supported format right now. Note that when this argument is specified, the
2890 output of @samp{-MF} is stripped of some information (namely C++ modules) so
2891 that it does not use extended makefile syntax not understood by most tools.
2893 @opindex fdeps-target
2894 @item -fdeps-target=@var{file}
2895 Analogous to @option{-MT} but for structured dependency information. This
2896 indicates the target which will ultimately need any required resources and
2897 provide any resources extracted from the source that may be required by other
2900 @opindex fplan9-extensions
2901 @item -fplan9-extensions
2902 Accept some non-standard constructs used in Plan 9 code.
2904 This enables @option{-fms-extensions}, permits passing pointers to
2905 structures with anonymous fields to functions that expect pointers to
2906 elements of the type of the field, and permits referring to anonymous
2907 fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2908 struct/union fields within structs/unions}, for details. This is only
2909 supported for C, not C++.
2911 @opindex fsigned-bitfields
2912 @opindex funsigned-bitfields
2913 @opindex fno-signed-bitfields
2914 @opindex fno-unsigned-bitfields
2915 @item -fsigned-bitfields
2916 @itemx -funsigned-bitfields
2917 @itemx -fno-signed-bitfields
2918 @itemx -fno-unsigned-bitfields
2919 These options control whether a bit-field is signed or unsigned, when the
2920 declaration does not use either @code{signed} or @code{unsigned}. By
2921 default, such a bit-field is signed, because this is consistent: the
2922 basic integer types such as @code{int} are signed types.
2924 @opindex fsigned-char
2926 Let the type @code{char} be signed, like @code{signed char}.
2928 Note that this is equivalent to @option{-fno-unsigned-char}, which is
2929 the negative form of @option{-funsigned-char}. Likewise, the option
2930 @option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2932 @opindex funsigned-char
2933 @item -funsigned-char
2934 Let the type @code{char} be unsigned, like @code{unsigned char}.
2936 Each kind of machine has a default for what @code{char} should
2937 be. It is either like @code{unsigned char} by default or like
2938 @code{signed char} by default.
2940 Ideally, a portable program should always use @code{signed char} or
2941 @code{unsigned char} when it depends on the signedness of an object.
2942 But many programs have been written to use plain @code{char} and
2943 expect it to be signed, or expect it to be unsigned, depending on the
2944 machines they were written for. This option, and its inverse, let you
2945 make such a program work with the opposite default.
2947 The type @code{char} is always a distinct type from each of
2948 @code{signed char} or @code{unsigned char}, even though its behavior
2949 is always just like one of those two.
2951 @opindex fstrict-flex-arrays
2952 @opindex fno-strict-flex-arrays
2953 @opindex fstrict-flex-arrays=@var{level}
2954 @item -fstrict-flex-arrays @r{(C and C++ only)}
2955 @itemx -fstrict-flex-arrays=@var{level} @r{(C and C++ only)}
2956 Control when to treat the trailing array of a structure as a flexible array
2957 member for the purpose of accessing the elements of such an array. The value
2958 of @var{level} controls the level of strictness.
2960 @option{-fstrict-flex-arrays} is equivalent to
2961 @option{-fstrict-flex-arrays=3}, which is the strictest; all
2962 trailing arrays of structures are treated as flexible array members.
2964 The negative form @option{-fno-strict-flex-arrays} is equivalent to
2965 @option{-fstrict-flex-arrays=0}, which is the least strict. In this
2966 case a trailing array is treated as a flexible array member only when
2967 it is declared as a flexible array member per C99 standard onwards.
2969 The possible values of @var{level} are the same as for the
2970 @code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2972 You can control this behavior for a specific trailing array field of a
2973 structure by using the variable attribute @code{strict_flex_array} attribute
2974 (@pxref{Variable Attributes}).
2976 The @option{-fstrict_flex_arrays} option interacts with the
2977 @option{-Wstrict-flex-arrays} option. @xref{Warning Options}, for more
2980 @opindex fsso-struct
2981 @item -fsso-struct=@var{endianness}
2982 Set the default scalar storage order of structures and unions to the
2983 specified endianness. The accepted values are @samp{big-endian},
2984 @samp{little-endian} and @samp{native} for the native endianness of
2985 the target (the default). This option is not supported for C++.
2987 @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2988 code that is not binary compatible with code generated without it if the
2989 specified endianness is not the native endianness of the target.
2992 @node C++ Dialect Options
2993 @section Options Controlling C++ Dialect
2995 @cindex compiler options, C++
2996 @cindex C++ options, command-line
2997 @cindex options, C++
2998 This section describes the command-line options that are only meaningful
2999 for C++ programs. You can also use most of the GNU compiler options
3000 regardless of what language your program is in. For example, you
3001 might compile a file @file{firstClass.C} like this:
3004 g++ -g -fstrict-enums -O -c firstClass.C
3008 In this example, only @option{-fstrict-enums} is an option meant
3009 only for C++ programs; you can use the other options with any
3010 language supported by GCC@.
3012 Some options for compiling C programs, such as @option{-std}, are also
3013 relevant for C++ programs.
3014 @xref{C Dialect Options,,Options Controlling C Dialect}.
3016 Here is a list of options that are @emph{only} for compiling C++ programs:
3020 @opindex fabi-version
3021 @item -fabi-version=@var{n}
3022 Use version @var{n} of the C++ ABI@. The default is version 0.
3024 Version 0 refers to the version conforming most closely to
3025 the C++ ABI specification. Therefore, the ABI obtained using version 0
3026 will change in different versions of G++ as ABI bugs are fixed.
3028 Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
3030 Version 2 is the version of the C++ ABI that first appeared in G++
3031 3.4, and was the default through G++ 4.9.
3033 Version 3 corrects an error in mangling a constant address as a
3036 Version 4, which first appeared in G++ 4.5, implements a standard
3037 mangling for vector types.
3039 Version 5, which first appeared in G++ 4.6, corrects the mangling of
3040 attribute const/volatile on function pointer types, decltype of a
3041 plain decl, and use of a function parameter in the declaration of
3044 Version 6, which first appeared in G++ 4.7, corrects the promotion
3045 behavior of C++11 scoped enums and the mangling of template argument
3046 packs, const/static_cast, prefix ++ and --, and a class scope function
3047 used as a template argument.
3049 Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
3050 builtin type and corrects the mangling of lambdas in default argument
3053 Version 8, which first appeared in G++ 4.9, corrects the substitution
3054 behavior of function types with function-cv-qualifiers.
3056 Version 9, which first appeared in G++ 5.2, corrects the alignment of
3059 Version 10, which first appeared in G++ 6.1, adds mangling of
3060 attributes that affect type identity, such as ia32 calling convention
3061 attributes (e.g.@: @samp{stdcall}).
3063 Version 11, which first appeared in G++ 7, corrects the mangling of
3064 sizeof... expressions and operator names. For multiple entities with
3065 the same name within a function, that are declared in different scopes,
3066 the mangling now changes starting with the twelfth occurrence. It also
3067 implies @option{-fnew-inheriting-ctors}.
3069 Version 12, which first appeared in G++ 8, corrects the calling
3070 conventions for empty classes on the x86_64 target and for classes
3071 with only deleted copy/move constructors. It accidentally changes the
3072 calling convention for classes with a deleted copy constructor and a
3073 trivial move constructor.
3075 Version 13, which first appeared in G++ 8.2, fixes the accidental
3076 change in version 12.
3078 Version 14, which first appeared in G++ 10, corrects the mangling of
3079 the nullptr expression.
3081 Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
3084 Version 16, which first appeared in G++ 11, changes the mangling of
3085 @code{__alignof__} to be distinct from that of @code{alignof}, and
3086 dependent operator names.
3088 Version 17, which first appeared in G++ 12, fixes layout of classes
3089 that inherit from aggregate classes with default member initializers
3092 Version 18, which first appeard in G++ 13, fixes manglings of lambdas
3093 that have additional context.
3095 Version 19, which first appeard in G++ 14, fixes manglings of structured
3096 bindings to include ABI tags.
3098 See also @option{-Wabi}.
3100 @opindex fabi-compat-version
3101 @item -fabi-compat-version=@var{n}
3102 On targets that support strong aliases, G++
3103 works around mangling changes by creating an alias with the correct
3104 mangled name when defining a symbol with an incorrect mangled name.
3105 This switch specifies which ABI version to use for the alias.
3107 With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
3108 compatibility). If another ABI version is explicitly selected, this
3109 defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
3110 use @option{-fabi-compat-version=2}.
3112 If this option is not provided but @option{-Wabi=@var{n}} is, that
3113 version is used for compatibility aliases. If this option is provided
3114 along with @option{-Wabi} (without the version), the version from this
3115 option is used for the warning.
3117 @opindex fno-access-control
3118 @opindex faccess-control
3119 @item -fno-access-control
3120 Turn off all access checking. This switch is mainly useful for working
3121 around bugs in the access control code.
3123 @opindex faligned-new
3125 Enable support for C++17 @code{new} of types that require more
3126 alignment than @code{void* ::operator new(std::size_t)} provides. A
3127 numeric argument such as @code{-faligned-new=32} can be used to
3128 specify how much alignment (in bytes) is provided by that function,
3129 but few users will need to override the default of
3130 @code{alignof(std::max_align_t)}.
3132 This flag is enabled by default for @option{-std=c++17}.
3135 @opindex fno-char8_t
3138 Enable support for @code{char8_t} as adopted for C++20. This includes
3139 the addition of a new @code{char8_t} fundamental type, changes to the
3140 types of UTF-8 string and character literals, new signatures for
3141 user-defined literals, associated standard library updates, and new
3142 @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3144 This option enables functions to be overloaded for ordinary and UTF-8
3148 int f(const char *); // #1
3149 int f(const char8_t *); // #2
3150 int v1 = f("text"); // Calls #1
3151 int v2 = f(u8"text"); // Calls #2
3155 and introduces new signatures for user-defined literals:
3158 int operator""_udl1(char8_t);
3159 int v3 = u8'x'_udl1;
3160 int operator""_udl2(const char8_t*, std::size_t);
3161 int v4 = u8"text"_udl2;
3162 template<typename T, T...> int operator""_udl3();
3163 int v5 = u8"text"_udl3;
3167 The change to the types of UTF-8 string and character literals introduces
3168 incompatibilities with ISO C++11 and later standards. For example, the
3169 following code is well-formed under ISO C++11, but is ill-formed when
3170 @option{-fchar8_t} is specified.
3173 const char *cp = u8"xx";// error: invalid conversion from
3174 // `const char8_t*' to `const char*'
3176 auto v = f(u8"xx"); // error: invalid conversion from
3177 // `const char8_t*' to `const char*'
3178 std::string s@{u8"xx"@}; // error: no matching function for call to
3179 // `std::basic_string<char>::basic_string()'
3180 using namespace std::literals;
3181 s = u8"xx"s; // error: conversion from
3182 // `basic_string<char8_t>' to non-scalar
3183 // type `basic_string<char>' requested
3188 Check that the pointer returned by @code{operator new} is non-null
3189 before attempting to modify the storage allocated. This check is
3190 normally unnecessary because the C++ standard specifies that
3191 @code{operator new} only returns @code{0} if it is declared
3192 @code{throw()}, in which case the compiler always checks the
3193 return value even without this option. In all other cases, when
3194 @code{operator new} has a non-empty exception specification, memory
3195 exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3196 @samp{new (nothrow)}.
3199 @opindex fconcepts-ts
3201 @itemx -fconcepts-ts
3202 Enable support for the C++ Concepts feature for constraining template
3203 arguments. With @option{-std=c++20} and above, Concepts are part of
3204 the language standard, so @option{-fconcepts} defaults to on.
3206 Some constructs that were allowed by the earlier C++ Extensions for
3207 Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3208 into the standard, can additionally be enabled by
3209 @option{-fconcepts-ts}. The option @option{-fconcepts-ts} was deprecated
3210 in GCC 14 and may be removed in GCC 15; users are expected to convert
3211 their code to C++20 concepts.
3213 @opindex fconstexpr-depth
3214 @item -fconstexpr-depth=@var{n}
3215 Set the maximum nested evaluation depth for C++11 constexpr functions
3216 to @var{n}. A limit is needed to detect endless recursion during
3217 constant expression evaluation. The minimum specified by the standard
3220 @opindex fconstexpr-cache-depth
3221 @item -fconstexpr-cache-depth=@var{n}
3222 Set the maximum level of nested evaluation depth for C++11 constexpr
3223 functions that will be cached to @var{n}. This is a heuristic that
3224 trades off compilation speed (when the cache avoids repeated
3225 calculations) against memory consumption (when the cache grows very
3226 large from highly recursive evaluations). The default is 8. Very few
3227 users are likely to want to adjust it, but if your code does heavy
3228 constexpr calculations you might want to experiment to find which
3229 value works best for you.
3231 @opindex fconstexpr-fp-except
3232 @item -fconstexpr-fp-except
3233 Annex F of the C standard specifies that IEC559 floating point
3234 exceptions encountered at compile time should not stop compilation.
3235 C++ compilers have historically not followed this guidance, instead
3236 treating floating point division by zero as non-constant even though
3237 it has a well defined value. This flag tells the compiler to give
3238 Annex F priority over other rules saying that a particular operation
3242 constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3245 @opindex fconstexpr-loop-limit
3246 @item -fconstexpr-loop-limit=@var{n}
3247 Set the maximum number of iterations for a loop in C++14 constexpr functions
3248 to @var{n}. A limit is needed to detect infinite loops during
3249 constant expression evaluation. The default is 262144 (1<<18).
3251 @opindex fconstexpr-ops-limit
3252 @item -fconstexpr-ops-limit=@var{n}
3253 Set the maximum number of operations during a single constexpr evaluation.
3254 Even when number of iterations of a single loop is limited with the above limit,
3255 if there are several nested loops and each of them has many iterations but still
3256 smaller than the above limit, or if in a body of some loop or even outside
3257 of a loop too many expressions need to be evaluated, the resulting constexpr
3258 evaluation might take too long.
3259 The default is 33554432 (1<<25).
3263 Enable experimental support for the C++ Contracts feature, as briefly
3264 added to and then removed from the C++20 working paper (N4820). The
3265 implementation also includes proposed enhancements from papers P1290,
3266 P1332, and P1429. This functionality is intended mostly for those
3267 interested in experimentation towards refining the feature to get it
3268 into shape for a future C++ standard.
3270 On violation of a checked contract, the violation handler is called.
3271 Users can replace the violation handler by defining
3274 handle_contract_violation (const std::experimental::contract_violation&);
3277 There are different sets of additional flags that can be used together
3278 to specify which contracts will be checked and how, for N4820
3279 contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3283 @opindex fcontract-mode
3284 @item -fcontract-mode=[on|off]
3285 Control whether any contracts have any semantics at all. Defaults to on.
3287 @opindex fcontract-assumption-mode
3288 @item -fcontract-assumption-mode=[on|off]
3289 [N4820] Control whether contracts with level @samp{axiom}
3290 should have the assume semantic. Defaults to on.
3292 @opindex fcontract-build-level
3293 @item -fcontract-build-level=[off|default|audit]
3294 [N4820] Specify which level of contracts to generate checks
3295 for. Defaults to @samp{default}.
3297 @opindex fcontract-continuation-mode
3298 @item -fcontract-continuation-mode=[on|off]
3299 [N4820] Control whether to allow the program to continue executing
3300 after a contract violation. That is, do checked contracts have the
3301 @samp{maybe} semantic described below rather than the @samp{never}
3302 semantic. Defaults to off.
3304 @opindex fcontract-role
3305 @item -fcontract-role=<name>:<default>,<audit>,<axiom>
3306 [P1332] Specify the concrete semantics for each contract level
3307 of a particular contract role.
3309 @item -fcontract-semantic=[default|audit|axiom]:<semantic>
3310 [P1429] Specify the concrete semantic for a particular
3313 @opindex fcontract-strict-declarations
3314 @item -fcontract-strict-declarations=[on|off]
3315 Control whether to reject adding contracts to a function after its
3316 first declaration. Defaults to off.
3319 The possible concrete semantics for that can be specified with
3320 @samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3324 This contract has no effect.
3327 This contract is treated like C++23 @code{[[assume]]}.
3329 @item check_never_continue
3332 This contract is checked. If it fails, the violation handler is
3333 called. If the handler returns, @code{std::terminate} is called.
3335 @item check_maybe_continue
3337 This contract is checked. If it fails, the violation handler is
3338 called. If the handler returns, execution continues normally.
3341 @opindex fcoroutines
3343 Enable support for the C++ coroutines extension (experimental).
3345 @opindex fdiagnostics-all-candidates
3346 @item -fdiagnostics-all-candidates
3347 Permit the C++ front end to note all candidates during overload resolution
3348 failure, including when a deleted function is selected.
3350 @opindex fno-elide-constructors
3351 @opindex felide-constructors
3352 @item -fno-elide-constructors
3353 The C++ standard allows an implementation to omit creating a temporary
3354 that is only used to initialize another object of the same type.
3355 Specifying this option disables that optimization, and forces G++ to
3356 call the copy constructor in all cases. This option also causes G++
3357 to call trivial member functions which otherwise would be expanded inline.
3359 In C++17, the compiler is required to omit these temporaries, but this
3360 option still affects trivial member functions.
3362 @opindex fno-enforce-eh-specs
3363 @opindex fenforce-eh-specs
3364 @item -fno-enforce-eh-specs
3365 Don't generate code to check for violation of exception specifications
3366 at run time. This option violates the C++ standard, but may be useful
3367 for reducing code size in production builds, much like defining
3368 @code{NDEBUG}. This does not give user code permission to throw
3369 exceptions in violation of the exception specifications; the compiler
3370 still optimizes based on the specifications, so throwing an
3371 unexpected exception results in undefined behavior at run time.
3373 @opindex fextern-tls-init
3374 @opindex fno-extern-tls-init
3375 @item -fextern-tls-init
3376 @itemx -fno-extern-tls-init
3377 The C++11 and OpenMP standards allow @code{thread_local} and
3378 @code{threadprivate} variables to have dynamic (runtime)
3379 initialization. To support this, any use of such a variable goes
3380 through a wrapper function that performs any necessary initialization.
3381 When the use and definition of the variable are in the same
3382 translation unit, this overhead can be optimized away, but when the
3383 use is in a different translation unit there is significant overhead
3384 even if the variable doesn't actually need dynamic initialization. If
3385 the programmer can be sure that no use of the variable in a
3386 non-defining TU needs to trigger dynamic initialization (either
3387 because the variable is statically initialized, or a use of the
3388 variable in the defining TU will be executed before any uses in
3389 another TU), they can avoid this overhead with the
3390 @option{-fno-extern-tls-init} option.
3392 On targets that support symbol aliases, the default is
3393 @option{-fextern-tls-init}. On targets that do not support symbol
3394 aliases, the default is @option{-fno-extern-tls-init}.
3396 @opindex ffold-simple-inlines
3397 @opindex fno-fold-simple-inlines
3398 @item -ffold-simple-inlines
3399 @itemx -fno-fold-simple-inlines
3400 Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3401 @code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3402 means no debug information will be generated for such calls. Since these
3403 functions are rarely interesting to debug, this flag is enabled by default
3404 unless @option{-fno-inline} is active.
3406 @opindex fno-gnu-keywords
3407 @opindex fgnu-keywords
3408 @item -fno-gnu-keywords
3409 Do not recognize @code{typeof} as a keyword, so that code can use this
3410 word as an identifier. You can use the keyword @code{__typeof__} instead.
3411 This option is implied by the strict ISO C++ dialects: @option{-ansi},
3412 @option{-std=c++98}, @option{-std=c++11}, etc.
3414 @opindex fno-immediate-escalation
3415 @opindex fimmediate-escalation
3416 @item -fno-immediate-escalation
3417 Do not enable immediate function escalation whereby certain functions
3418 can be promoted to consteval, as specified in P2564R3. For example:
3421 consteval int id(int i) @{ return i; @}
3423 constexpr int f(auto t)
3425 return t + id(t); // id causes f<int> to be promoted to consteval
3434 compiles in C++20: @code{f} is an immediate-escalating function (due to
3435 the @code{auto} it is a function template and is declared @code{constexpr})
3436 and @code{id(t)} is an immediate-escalating expression, so @code{f} is
3437 promoted to @code{consteval}. Consequently, the call to @code{id(t)}
3438 is in an immediate context, so doesn't have to produce a constant (that
3439 is the mechanism allowing consteval function composition). However,
3440 with @option{-fno-immediate-escalation}, @code{f} is not promoted to
3441 @code{consteval}, and since the call to consteval function @code{id(t)}
3442 is not a constant expression, the compiler rejects the code.
3444 This option is turned on by default; it is only effective in C++20 mode
3447 @opindex fimplicit-constexpr
3448 @item -fimplicit-constexpr
3449 Make inline functions implicitly constexpr, if they satisfy the
3450 requirements for a constexpr function. This option can be used in
3451 C++14 mode or later. This can result in initialization changing from
3452 dynamic to static and other optimizations.
3454 @opindex fno-implicit-templates
3455 @opindex fimplicit-templates
3456 @item -fno-implicit-templates
3457 Never emit code for non-inline templates that are instantiated
3458 implicitly (i.e.@: by use); only emit code for explicit instantiations.
3459 If you use this option, you must take care to structure your code to
3460 include all the necessary explicit instantiations to avoid getting
3461 undefined symbols at link time.
3462 @xref{Template Instantiation}, for more information.
3464 @opindex fno-implicit-inline-templates
3465 @opindex fimplicit-inline-templates
3466 @item -fno-implicit-inline-templates
3467 Don't emit code for implicit instantiations of inline templates, either.
3468 The default is to handle inlines differently so that compiles with and
3469 without optimization need the same set of explicit instantiations.
3471 @opindex fno-implement-inlines
3472 @opindex fimplement-inlines
3473 @item -fno-implement-inlines
3474 To save space, do not emit out-of-line copies of inline functions
3475 controlled by @code{#pragma implementation}. This causes linker
3476 errors if these functions are not inlined everywhere they are called.
3478 @opindex fmodules-ts
3479 @opindex fno-modules-ts
3481 @itemx -fno-modules-ts
3482 Enable support for C++20 modules (@pxref{C++ Modules}). The
3483 @option{-fno-modules-ts} is usually not needed, as that is the
3484 default. Even though this is a C++20 feature, it is not currently
3485 implicitly enabled by selecting that standard version.
3487 @opindex fmodule-header
3488 @item -fmodule-header
3489 @itemx -fmodule-header=user
3490 @itemx -fmodule-header=system
3491 Compile a header file to create an importable header unit.
3493 @opindex fmodule-implicit-inline
3494 @item -fmodule-implicit-inline
3495 Member functions defined in their class definitions are not implicitly
3496 inline for modular code. This is different to traditional C++
3497 behavior, for good reasons. However, it may result in a difficulty
3498 during code porting. This option makes such function definitions
3499 implicitly inline. It does however generate an ABI incompatibility,
3500 so you must use it everywhere or nowhere. (Such definitions outside
3501 of a named module remain implicitly inline, regardless.)
3503 @opindex fno-module-lazy
3504 @opindex fmodule-lazy
3505 @item -fno-module-lazy
3506 Disable lazy module importing and module mapper creation.
3508 @vindex CXX_MODULE_MAPPER @r{environment variable}
3509 @opindex fmodule-mapper
3510 @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3511 @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3512 @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3513 @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3514 @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3515 @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
3516 An oracle to query for module name to filename mappings. If
3517 unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3518 and if that is unset, an in-process default is provided.
3520 @opindex fmodule-only
3522 Only emit the Compiled Module Interface, inhibiting any object file.
3524 @opindex fms-extensions
3525 @item -fms-extensions
3526 Disable Wpedantic warnings about constructs used in MFC, such as implicit
3527 int and getting a pointer to member function via non-standard syntax.
3529 @opindex fnew-inheriting-ctors
3530 @item -fnew-inheriting-ctors
3531 Enable the P0136 adjustment to the semantics of C++11 constructor
3532 inheritance. This is part of C++17 but also considered to be a Defect
3533 Report against C++11 and C++14. This flag is enabled by default
3534 unless @option{-fabi-version=10} or lower is specified.
3536 @opindex fnew-ttp-matching
3537 @item -fnew-ttp-matching
3538 Enable the P0522 resolution to Core issue 150, template template
3539 parameters and default arguments: this allows a template with default
3540 template arguments as an argument for a template template parameter
3541 with fewer template parameters. This flag is enabled by default for
3542 @option{-std=c++17}.
3544 @opindex fno-nonansi-builtins
3545 @opindex fnonansi-builtins
3546 @item -fno-nonansi-builtins
3547 Disable built-in declarations of functions that are not mandated by
3548 ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3549 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
3551 @opindex fnothrow-opt
3553 Treat a @code{throw()} exception specification as if it were a
3554 @code{noexcept} specification to reduce or eliminate the text size
3555 overhead relative to a function with no exception specification. If
3556 the function has local variables of types with non-trivial
3557 destructors, the exception specification actually makes the
3558 function smaller because the EH cleanups for those variables can be
3559 optimized away. The semantic effect is that an exception thrown out of
3560 a function with such an exception specification results in a call
3561 to @code{terminate} rather than @code{unexpected}.
3563 @opindex fno-operator-names
3564 @opindex foperator-names
3565 @item -fno-operator-names
3566 Do not treat the operator name keywords @code{and}, @code{bitand},
3567 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3568 synonyms as keywords.
3570 @opindex fno-optional-diags
3571 @opindex foptional-diags
3572 @item -fno-optional-diags
3573 Disable diagnostics that the standard says a compiler does not need to
3574 issue. Currently, the only such diagnostic issued by G++ is the one for
3575 a name having multiple meanings within a class.
3577 @opindex fno-pretty-templates
3578 @opindex fpretty-templates
3579 @item -fno-pretty-templates
3580 When an error message refers to a specialization of a function
3581 template, the compiler normally prints the signature of the
3582 template followed by the template arguments and any typedefs or
3583 typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3584 rather than @code{void f(int)}) so that it's clear which template is
3585 involved. When an error message refers to a specialization of a class
3586 template, the compiler omits any template arguments that match
3587 the default template arguments for that template. If either of these
3588 behaviors make it harder to understand the error message rather than
3589 easier, you can use @option{-fno-pretty-templates} to disable them.
3594 Disable generation of information about every class with virtual
3595 functions for use by the C++ run-time type identification features
3596 (@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3597 of the language, you can save some space by using this flag. Note that
3598 exception handling uses the same information, but G++ generates it as
3599 needed. The @code{dynamic_cast} operator can still be used for casts that
3600 do not require run-time type information, i.e.@: casts to @code{void *} or to
3601 unambiguous base classes.
3603 Mixing code compiled with @option{-frtti} with that compiled with
3604 @option{-fno-rtti} may not work. For example, programs may
3605 fail to link if a class compiled with @option{-fno-rtti} is used as a base
3606 for a class compiled with @option{-frtti}.
3608 @opindex fsized-deallocation
3609 @item -fsized-deallocation
3610 Enable the built-in global declarations
3612 void operator delete (void *, std::size_t) noexcept;
3613 void operator delete[] (void *, std::size_t) noexcept;
3615 as introduced in C++14. This is useful for user-defined replacement
3616 deallocation functions that, for example, use the size of the object
3617 to make deallocation faster. Enabled by default under
3618 @option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3619 warns about places that might want to add a definition.
3621 @opindex fstrict-enums
3622 @item -fstrict-enums
3623 Allow the compiler to optimize using the assumption that a value of
3624 enumerated type can only be one of the values of the enumeration (as
3625 defined in the C++ standard; basically, a value that can be
3626 represented in the minimum number of bits needed to represent all the
3627 enumerators). This assumption may not be valid if the program uses a
3628 cast to convert an arbitrary integer value to the enumerated type.
3629 This option has no effect for an enumeration type with a fixed underlying
3632 @opindex fstrong-eval-order
3633 @item -fstrong-eval-order
3634 Evaluate member access, array subscripting, and shift expressions in
3635 left-to-right order, and evaluate assignment in right-to-left order,
3636 as adopted for C++17. Enabled by default with @option{-std=c++17}.
3637 @option{-fstrong-eval-order=some} enables just the ordering of member
3638 access and shift expressions, and is the default without
3639 @option{-std=c++17}.
3641 @opindex ftemplate-backtrace-limit
3642 @item -ftemplate-backtrace-limit=@var{n}
3643 Set the maximum number of template instantiation notes for a single
3644 warning or error to @var{n}. The default value is 10.
3646 @opindex ftemplate-depth
3647 @item -ftemplate-depth=@var{n}
3648 Set the maximum instantiation depth for template classes to @var{n}.
3649 A limit on the template instantiation depth is needed to detect
3650 endless recursions during template class instantiation. ANSI/ISO C++
3651 conforming programs must not rely on a maximum depth greater than 17
3652 (changed to 1024 in C++11). The default value is 900, as the compiler
3653 can run out of stack space before hitting 1024 in some situations.
3655 @opindex fno-threadsafe-statics
3656 @opindex fthreadsafe-statics
3657 @item -fno-threadsafe-statics
3658 Do not emit the extra code to use the routines specified in the C++
3659 ABI for thread-safe initialization of local statics. You can use this
3660 option to reduce code size slightly in code that doesn't need to be
3663 @opindex fuse-cxa-atexit
3664 @item -fuse-cxa-atexit
3665 Register destructors for objects with static storage duration with the
3666 @code{__cxa_atexit} function rather than the @code{atexit} function.
3667 This option is required for fully standards-compliant handling of static
3668 destructors, but only works if your C library supports
3669 @code{__cxa_atexit}.
3671 @opindex fno-use-cxa-get-exception-ptr
3672 @opindex fuse-cxa-get-exception-ptr
3673 @item -fno-use-cxa-get-exception-ptr
3674 Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3675 causes @code{std::uncaught_exception} to be incorrect, but is necessary
3676 if the runtime routine is not available.
3678 @opindex fvisibility-inlines-hidden
3679 @item -fvisibility-inlines-hidden
3680 This switch declares that the user does not attempt to compare
3681 pointers to inline functions or methods where the addresses of the two functions
3682 are taken in different shared objects.
3684 The effect of this is that GCC may, effectively, mark inline methods with
3685 @code{__attribute__ ((visibility ("hidden")))} so that they do not
3686 appear in the export table of a DSO and do not require a PLT indirection
3687 when used within the DSO@. Enabling this option can have a dramatic effect
3688 on load and link times of a DSO as it massively reduces the size of the
3689 dynamic export table when the library makes heavy use of templates.
3691 The behavior of this switch is not quite the same as marking the
3692 methods as hidden directly, because it does not affect static variables
3693 local to the function or cause the compiler to deduce that
3694 the function is defined in only one shared object.
3696 You may mark a method as having a visibility explicitly to negate the
3697 effect of the switch for that method. For example, if you do want to
3698 compare pointers to a particular inline method, you might mark it as
3699 having default visibility. Marking the enclosing class with explicit
3700 visibility has no effect.
3702 Explicitly instantiated inline methods are unaffected by this option
3703 as their linkage might otherwise cross a shared library boundary.
3704 @xref{Template Instantiation}.
3706 @opindex fvisibility-ms-compat
3707 @item -fvisibility-ms-compat
3708 This flag attempts to use visibility settings to make GCC's C++
3709 linkage model compatible with that of Microsoft Visual Studio.
3711 The flag makes these changes to GCC's linkage model:
3715 It sets the default visibility to @code{hidden}, like
3716 @option{-fvisibility=hidden}.
3719 Types, but not their members, are not hidden by default.
3722 The One Definition Rule is relaxed for types without explicit
3723 visibility specifications that are defined in more than one
3724 shared object: those declarations are permitted if they are
3725 permitted when this option is not used.
3728 In new code it is better to use @option{-fvisibility=hidden} and
3729 export those classes that are intended to be externally visible.
3730 Unfortunately it is possible for code to rely, perhaps accidentally,
3731 on the Visual Studio behavior.
3733 Among the consequences of these changes are that static data members
3734 of the same type with the same name but defined in different shared
3735 objects are different, so changing one does not change the other;
3736 and that pointers to function members defined in different shared
3737 objects may not compare equal. When this flag is given, it is a
3738 violation of the ODR to define types with the same name differently.
3743 Do not use weak symbol support, even if it is provided by the linker.
3744 By default, G++ uses weak symbols if they are available. This
3745 option exists only for testing, and should not be used by end-users;
3746 it results in inferior code and has no benefits. This option may
3747 be removed in a future release of G++.
3749 @opindex fext-numeric-literals
3750 @opindex fno-ext-numeric-literals
3751 @item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
3752 Accept imaginary, fixed-point, or machine-defined
3753 literal number suffixes as GNU extensions.
3754 When this option is turned off these suffixes are treated
3755 as C++11 user-defined literal numeric suffixes.
3756 This is on by default for all pre-C++11 dialects and all GNU dialects:
3757 @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3758 @option{-std=gnu++14}.
3759 This option is off by default
3760 for ISO C++11 onwards (@option{-std=c++11}, ...).
3764 Do not search for header files in the standard directories specific to
3765 C++, but do still search the other standard directories. (This option
3766 is used when building the C++ library.)
3768 @opindex flang-info-include-translate
3769 @opindex flang-info-include-translate-not
3770 @item -flang-info-include-translate
3771 @itemx -flang-info-include-translate-not
3772 @itemx -flang-info-include-translate=@var{header}
3773 Inform of include translation events. The first will note accepted
3774 include translations, the second will note declined include
3775 translations. The @var{header} form will inform of include
3776 translations relating to that specific header. If @var{header} is of
3777 the form @code{"user"} or @code{<system>} it will be resolved to a
3778 specific user or system header using the include path.
3780 @opindex flang-info-module-cmi
3781 @item -flang-info-module-cmi
3782 @itemx -flang-info-module-cmi=@var{module}
3783 Inform of Compiled Module Interface pathnames. The first will note
3784 all read CMI pathnames. The @var{module} form will not reading a
3785 specific module's CMI. @var{module} may be a named module or a
3786 header-unit (the latter indicated by either being a pathname containing
3787 directory separators or enclosed in @code{<>} or @code{""}).
3790 @item -stdlib=@var{libstdc++,libc++}
3791 When G++ is configured to support this option, it allows specification of
3792 alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3793 (the default, native C++ runtime for G++) and @var{libc++} which is the
3794 C++ runtime installed on some operating systems (e.g. Darwin versions from
3795 Darwin11 onwards). The option switches G++ to use the headers from the
3796 specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3797 when a C++ runtime is required for linking.
3800 In addition, these warning options have meanings only for C++ programs:
3804 @item -Wabi-tag @r{(C++ and Objective-C++ only)}
3805 Warn when a type with an ABI tag is used in a context that does not
3806 have that ABI tag. See @ref{C++ Attributes} for more information
3809 @opindex Wcomma-subscript
3810 @opindex Wno-comma-subscript
3811 @item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
3812 Warn about uses of a comma expression within a subscripting expression.
3813 This usage was deprecated in C++20 and is going to be removed in C++23.
3814 However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3818 void f(int *a, int b, int c) @{
3819 a[b,c]; // deprecated in C++20, invalid in C++23
3825 In C++23 it is valid to have comma separated expressions in a subscript
3826 when an overloaded subscript operator is found and supports the right
3827 number and types of arguments. G++ will accept the formerly valid syntax
3828 for code that is not valid in C++23 but used to be valid but deprecated
3829 in C++20 with a pedantic warning that can be disabled with
3830 @option{-Wno-comma-subscript}.
3832 Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3833 and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3835 This warning is upgraded to an error by @option{-pedantic-errors} in
3836 C++23 mode or later.
3838 @opindex Wctad-maybe-unsupported
3839 @opindex Wno-ctad-maybe-unsupported
3840 @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
3841 Warn when performing class template argument deduction (CTAD) on a type with
3842 no explicitly written deduction guides. This warning will point out cases
3843 where CTAD succeeded only because the compiler synthesized the implicit
3844 deduction guides, which might not be what the programmer intended. Certain
3845 style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3846 types that are designed to support CTAD. This warning can be suppressed with
3847 the following pattern:
3850 struct allow_ctad_t; // any name works
3851 template <typename T> struct S @{
3854 // Guide with incomplete parameter type will never be considered.
3855 S(allow_ctad_t) -> S<void>;
3858 @opindex Wctor-dtor-privacy
3859 @opindex Wno-ctor-dtor-privacy
3860 @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
3861 Warn when a class seems unusable because all the constructors or
3862 destructors in that class are private, and it has neither friends nor
3863 public static member functions. Also warn if there are no non-private
3864 methods, and there's at least one private member function that isn't
3865 a constructor or destructor.
3867 @opindex Wdangling-reference
3868 @opindex Wno-dangling-reference
3869 @item -Wdangling-reference @r{(C++ and Objective-C++ only)}
3870 Warn when a reference is bound to a temporary whose lifetime has ended.
3875 const int& r = std::max(n - 1, n + 1); // r is dangling
3878 In the example above, two temporaries are created, one for each
3879 argument, and a reference to one of the temporaries is returned.
3880 However, both temporaries are destroyed at the end of the full
3881 expression, so the reference @code{r} is dangling. This warning
3882 also detects dangling references in member initializer lists:
3885 const int& f(const int& i) @{ return i; @}
3887 const int &r; // r is dangling
3888 S() : r(f(10)) @{ @}
3892 Member functions are checked as well, but only their object argument:
3896 const S& self () @{ return *this; @}
3898 const S& s = S().self(); // s is dangling
3901 Certain functions are safe in this respect, for example @code{std::use_facet}:
3902 they take and return a reference, but they don't return one of its arguments,
3903 which can fool the warning. Such functions can be excluded from the warning
3904 by wrapping them in a @code{#pragma}:
3907 #pragma GCC diagnostic push
3908 #pragma GCC diagnostic ignored "-Wdangling-reference"
3909 const T& foo (const T&) @{ @dots{} @}
3910 #pragma GCC diagnostic pop
3913 The @code{#pragma} can also surround the class; in that case, the warning
3914 will be disabled for all the member functions.
3916 @option{-Wdangling-reference} also warns about code like
3919 auto p = std::minmax(1, 2);
3922 where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3923 both references dangle after the end of the full expression that contains
3924 the call to @code{std::minmax}.
3926 The warning does not warn for @code{std::span}-like classes. We consider
3927 classes of the form:
3930 template<typename T>
3937 as @code{std::span}-like; that is, the class is a non-union class
3938 that has a pointer data member and a trivial destructor.
3940 The warning can be disabled by using the @code{gnu::no_dangling} attribute
3941 (@pxref{C++ Attributes}).
3943 This warning is enabled by @option{-Wall}.
3945 @opindex Wdelete-non-virtual-dtor
3946 @opindex Wno-delete-non-virtual-dtor
3947 @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
3948 Warn when @code{delete} is used to destroy an instance of a class that
3949 has virtual functions and non-virtual destructor. It is unsafe to delete
3950 an instance of a derived class through a pointer to a base class if the
3951 base class does not have a virtual destructor. This warning is enabled
3954 @opindex Wdeprecated-copy
3955 @opindex Wno-deprecated-copy
3956 @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
3957 Warn that the implicit declaration of a copy constructor or copy
3958 assignment operator is deprecated if the class has a user-provided
3959 copy constructor or copy assignment operator, in C++11 and up. This
3960 warning is enabled by @option{-Wextra}. With
3961 @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3962 user-provided destructor.
3964 @opindex Wdeprecated-enum-enum-conversion
3965 @opindex Wno-deprecated-enum-enum-conversion
3966 @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
3967 Disable the warning about the case when the usual arithmetic conversions
3968 are applied on operands where one is of enumeration type and the other is
3969 of a different enumeration type. This conversion was deprecated in C++20.
3978 @option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3979 @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3980 by @option{-Wenum-conversion}.
3982 @opindex Wdeprecated-enum-float-conversion
3983 @opindex Wno-deprecated-enum-float-conversion
3984 @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
3985 Disable the warning about the case when the usual arithmetic conversions
3986 are applied on operands where one is of enumeration type and the other is
3987 of a floating-point type. This conversion was deprecated in C++20. For
3996 @option{-Wdeprecated-enum-float-conversion} is enabled by default with
3997 @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3998 by @option{-Wenum-conversion}.
4000 @opindex Welaborated-enum-base
4001 @opindex Wno-elaborated-enum-base
4002 @item -Wno-elaborated-enum-base
4003 For C++11 and above, warn if an (invalid) additional enum-base is used
4004 in an elaborated-type-specifier. That is, if an enum with given
4005 underlying type and no enumerator list is used in a declaration other
4006 than just a standalone declaration of the enum. Enabled by default. This
4007 warning is upgraded to an error with -pedantic-errors.
4009 @opindex Winit-list-lifetime
4010 @opindex Wno-init-list-lifetime
4011 @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
4012 Do not warn about uses of @code{std::initializer_list} that are likely
4013 to result in dangling pointers. Since the underlying array for an
4014 @code{initializer_list} is handled like a normal C++ temporary object,
4015 it is easy to inadvertently keep a pointer to the array past the end
4016 of the array's lifetime. For example:
4020 If a function returns a temporary @code{initializer_list}, or a local
4021 @code{initializer_list} variable, the array's lifetime ends at the end
4022 of the return statement, so the value returned has a dangling pointer.
4025 If a new-expression creates an @code{initializer_list}, the array only
4026 lives until the end of the enclosing full-expression, so the
4027 @code{initializer_list} in the heap has a dangling pointer.
4030 When an @code{initializer_list} variable is assigned from a
4031 brace-enclosed initializer list, the temporary array created for the
4032 right side of the assignment only lives until the end of the
4033 full-expression, so at the next statement the @code{initializer_list}
4034 variable has a dangling pointer.
4037 // li's initial underlying array lives as long as li
4038 std::initializer_list<int> li = @{ 1,2,3 @};
4039 // assignment changes li to point to a temporary array
4041 // now the temporary is gone and li has a dangling pointer
4042 int i = li.begin()[0] // undefined behavior
4046 When a list constructor stores the @code{begin} pointer from the
4047 @code{initializer_list} argument, this doesn't extend the lifetime of
4048 the array, so if a class variable is constructed from a temporary
4049 @code{initializer_list}, the pointer is left dangling by the end of
4050 the variable declaration statement.
4054 @opindex Winvalid-constexpr
4055 @opindex Wno-invalid-constexpr
4056 @item -Winvalid-constexpr
4058 Warn when a function never produces a constant expression. In C++20
4059 and earlier, for every @code{constexpr} function and function template,
4060 there must be at least one set of function arguments in at least one
4061 instantiation such that an invocation of the function or constructor
4062 could be an evaluated subexpression of a core constant expression.
4063 C++23 removed this restriction, so it's possible to have a function
4064 or a function template marked @code{constexpr} for which no invocation
4065 satisfies the requirements of a core constant expression.
4067 This warning is enabled as a pedantic warning by default in C++20 and
4068 earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
4069 which case it will be an ordinary warning. For example:
4076 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
4081 @opindex Winvalid-imported-macros
4082 @opindex Wno-invalid-imported-macros
4083 @item -Winvalid-imported-macros
4084 Verify all imported macro definitions are valid at the end of
4085 compilation. This is not enabled by default, as it requires
4086 additional processing to determine. It may be useful when preparing
4087 sets of header-units to ensure consistent macros.
4089 @opindex Wliteral-suffix
4090 @opindex Wno-literal-suffix
4091 @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
4092 Do not warn when a string or character literal is followed by a
4093 ud-suffix which does not begin with an underscore. As a conforming
4094 extension, GCC treats such suffixes as separate preprocessing tokens
4095 in order to maintain backwards compatibility with code that uses
4096 formatting macros from @code{<inttypes.h>}. For example:
4099 #define __STDC_FORMAT_MACROS
4100 #include <inttypes.h>
4105 printf("My int64: %" PRId64"\n", i64);
4109 In this case, @code{PRId64} is treated as a separate preprocessing token.
4111 This option also controls warnings when a user-defined literal
4112 operator is declared with a literal suffix identifier that doesn't
4113 begin with an underscore. Literal suffix identifiers that don't begin
4114 with an underscore are reserved for future standardization.
4116 These warnings are enabled by default.
4119 @opindex Wno-narrowing
4120 @item -Wno-narrowing @r{(C++ and Objective-C++ only)}
4121 For C++11 and later standards, narrowing conversions are diagnosed by default,
4122 as required by the standard. A narrowing conversion from a constant produces
4123 an error, and a narrowing conversion from a non-constant produces a warning,
4124 but @option{-Wno-narrowing} suppresses the diagnostic.
4125 Note that this does not affect the meaning of well-formed code;
4126 narrowing conversions are still considered ill-formed in SFINAE contexts.
4128 With @option{-Wnarrowing} in C++98, warn when a narrowing
4129 conversion prohibited by C++11 occurs within
4133 int i = @{ 2.2 @}; // error: narrowing from double to int
4136 This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
4139 @opindex Wno-noexcept
4140 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
4141 Warn when a noexcept-expression evaluates to false because of a call
4142 to a function that does not have a non-throwing exception
4143 specification (i.e. @code{throw()} or @code{noexcept}) but is known by
4144 the compiler to never throw an exception.
4146 @opindex Wnoexcept-type
4147 @opindex Wno-noexcept-type
4148 @item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
4149 Warn if the C++17 feature making @code{noexcept} part of a function
4150 type changes the mangled name of a symbol relative to C++14. Enabled
4151 by @option{-Wabi} and @option{-Wc++17-compat}.
4156 template <class T> void f(T t) @{ t(); @};
4158 void h() @{ f(g); @}
4162 In C++14, @code{f} calls @code{f<void(*)()>}, but in
4163 C++17 it calls @code{f<void(*)()noexcept>}.
4165 @opindex Wclass-memaccess
4166 @opindex Wno-class-memaccess
4167 @item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
4168 Warn when the destination of a call to a raw memory function such as
4169 @code{memset} or @code{memcpy} is an object of class type, and when writing
4170 into such an object might bypass the class non-trivial or deleted constructor
4171 or copy assignment, violate const-correctness or encapsulation, or corrupt
4172 virtual table pointers. Modifying the representation of such objects may
4173 violate invariants maintained by member functions of the class. For example,
4174 the call to @code{memset} below is undefined because it modifies a non-trivial
4175 class object and is, therefore, diagnosed. The safe way to either initialize
4176 or clear the storage of objects of such types is by using the appropriate
4177 constructor or assignment operator, if one is available.
4179 std::string str = "abc";
4180 memset (&str, 0, sizeof str);
4182 The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4183 Explicitly casting the pointer to the class object to @code{void *} or
4184 to a type that can be safely accessed by the raw memory function suppresses
4187 @opindex Wnon-virtual-dtor
4188 @opindex Wno-non-virtual-dtor
4189 @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
4190 Warn when a class has virtual functions and an accessible non-virtual
4191 destructor itself or in an accessible polymorphic base class, in which
4192 case it is possible but unsafe to delete an instance of a derived
4193 class through a pointer to the class itself or base class. This
4194 warning is automatically enabled if @option{-Weffc++} is specified.
4195 The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4196 should be preferred because it warns about the unsafe cases without false
4200 @opindex Wno-register
4201 @item -Wregister @r{(C++ and Objective-C++ only)}
4202 Warn on uses of the @code{register} storage class specifier, except
4203 when it is part of the GNU @ref{Explicit Register Variables} extension.
4204 The use of the @code{register} keyword as storage class specifier has
4205 been deprecated in C++11 and removed in C++17.
4206 Enabled by default with @option{-std=c++17}.
4209 @opindex Wno-reorder
4210 @cindex reordering, warning
4211 @cindex warning for reordering of member initializers
4212 @item -Wreorder @r{(C++ and Objective-C++ only)}
4213 Warn when the order of member initializers given in the code does not
4214 match the order in which they must be executed. For instance:
4220 A(): j (0), i (1) @{ @}
4225 The compiler rearranges the member initializers for @code{i}
4226 and @code{j} to match the declaration order of the members, emitting
4227 a warning to that effect. This warning is enabled by @option{-Wall}.
4229 @opindex Wpessimizing-move
4230 @opindex Wno-pessimizing-move
4231 @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
4232 This warning warns when a call to @code{std::move} prevents copy
4233 elision. A typical scenario when copy elision can occur is when returning in
4234 a function with a class return type, when the expression being returned is the
4235 name of a non-volatile automatic object, and is not a function parameter, and
4236 has the same type as the function return type.
4246 return std::move (t);
4250 But in this example, the @code{std::move} call prevents copy elision.
4252 This warning is enabled by @option{-Wall}.
4254 @opindex Wredundant-move
4255 @opindex Wno-redundant-move
4256 @item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
4257 This warning warns about redundant calls to @code{std::move}; that is, when
4258 a move operation would have been performed even without the @code{std::move}
4259 call. This happens because the compiler is forced to treat the object as if
4260 it were an rvalue in certain situations such as returning a local variable,
4261 where copy elision isn't applicable. Consider:
4270 return std::move (t);
4274 Here, the @code{std::move} call is redundant. Because G++ implements Core
4275 Issue 1579, another example is:
4278 struct T @{ // convertible to U
4288 return std::move (t);
4291 In this example, copy elision isn't applicable because the type of the
4292 expression being returned and the function return type differ, yet G++
4293 treats the return value as if it were designated by an rvalue.
4295 This warning is enabled by @option{-Wextra}.
4297 @opindex Wrange-loop-construct
4298 @opindex Wno-range-loop-construct
4299 @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
4300 This warning warns when a C++ range-based for-loop is creating an unnecessary
4301 copy. This can happen when the range declaration is not a reference, but
4302 probably should be. For example:
4305 struct S @{ char arr[128]; @};
4308 for (const auto x : arr) @{ @dots{} @}
4312 It does not warn when the type being copied is a trivially-copyable type whose
4313 size is less than 64 bytes.
4315 This warning also warns when a loop variable in a range-based for-loop is
4316 initialized with a value of a different type resulting in a copy. For example:
4321 for (const double &x : arr) @{ @dots{} @}
4325 In the example above, in every iteration of the loop a temporary value of
4326 type @code{double} is created and destroyed, to which the reference
4327 @code{const double &} is bound.
4329 This warning is enabled by @option{-Wall}.
4331 @opindex Wredundant-tags
4332 @opindex Wno-redundant-tags
4333 @item -Wredundant-tags @r{(C++ and Objective-C++ only)}
4334 Warn about redundant class-key and enum-key in references to class types
4335 and enumerated types in contexts where the key can be eliminated without
4336 causing an ambiguity. For example:
4340 struct foo *p; // warn that keyword struct can be eliminated
4344 On the other hand, in this example there is no warning:
4348 void foo (); // "hides" struct foo
4349 void bar (struct foo&); // no warning, keyword struct is necessary
4352 @opindex Wsubobject-linkage
4353 @opindex Wno-subobject-linkage
4354 @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
4356 if a class type has a base or a field whose type uses the anonymous
4357 namespace or depends on a type with no linkage. If a type A depends on
4358 a type B with no or internal linkage, defining it in multiple
4359 translation units would be an ODR violation because the meaning of B
4360 is different in each translation unit. If A only appears in a single
4361 translation unit, the best way to silence the warning is to give it
4362 internal linkage by putting it in an anonymous namespace as well. The
4363 compiler doesn't give this warning for types defined in the main .C
4364 file, as those are unlikely to have multiple definitions.
4365 @option{-Wsubobject-linkage} is enabled by default.
4369 @item -Weffc++ @r{(C++ and Objective-C++ only)}
4370 Warn about violations of the following style guidelines from Scott Meyers'
4371 @cite{Effective C++} series of books:
4375 Define a copy constructor and an assignment operator for classes
4376 with dynamically-allocated memory.
4379 Prefer initialization to assignment in constructors.
4382 Have @code{operator=} return a reference to @code{*this}.
4385 Don't try to return a reference when you must return an object.
4388 Distinguish between prefix and postfix forms of increment and
4389 decrement operators.
4392 Never overload @code{&&}, @code{||}, or @code{,}.
4396 This option also enables @option{-Wnon-virtual-dtor}, which is also
4397 one of the effective C++ recommendations. However, the check is
4398 extended to warn about the lack of virtual destructor in accessible
4399 non-polymorphic bases classes too.
4401 When selecting this option, be aware that the standard library
4402 headers do not obey all of these guidelines; use @samp{grep -v}
4403 to filter out those warnings.
4405 @opindex Wexceptions
4406 @opindex Wno-exceptions
4407 @item -Wno-exceptions @r{(C++ and Objective-C++ only)}
4408 Disable the warning about the case when an exception handler is shadowed by
4409 another handler, which can point out a wrong ordering of exception handlers.
4411 @opindex Wstrict-null-sentinel
4412 @opindex Wno-strict-null-sentinel
4413 @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
4414 Warn about the use of an uncasted @code{NULL} as sentinel. When
4415 compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4416 to @code{__null}. Although it is a null pointer constant rather than a
4417 null pointer, it is guaranteed to be of the same size as a pointer.
4418 But this use is not portable across different compilers.
4420 @opindex Wno-non-template-friend
4421 @opindex Wnon-template-friend
4422 @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
4423 Disable warnings when non-template friend functions are declared
4424 within a template. In very old versions of GCC that predate implementation
4425 of the ISO standard, declarations such as
4426 @samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4427 could be interpreted as a particular specialization of a template
4428 function; the warning exists to diagnose compatibility problems,
4429 and is enabled by default.
4431 @opindex Wold-style-cast
4432 @opindex Wno-old-style-cast
4433 @item -Wold-style-cast @r{(C++ and Objective-C++ only)}
4434 Warn if an old-style (C-style) cast to a non-void type is used within
4435 a C++ program. The new-style casts (@code{dynamic_cast},
4436 @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4437 less vulnerable to unintended effects and much easier to search for.
4439 @opindex Woverloaded-virtual
4440 @opindex Wno-overloaded-virtual
4441 @cindex overloaded virtual function, warning
4442 @cindex warning for overloaded virtual function
4443 @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4444 @itemx -Woverloaded-virtual=@var{n}
4445 Warn when a function declaration hides virtual functions from a
4446 base class. For example, in:
4453 struct B: public A @{
4454 void f(int); // does not override
4458 the @code{A} class version of @code{f} is hidden in @code{B}, and code
4469 In cases where the different signatures are not an accident, the
4470 simplest solution is to add a using-declaration to the derived class
4471 to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4473 The optional level suffix controls the behavior when all the
4474 declarations in the derived class override virtual functions in the
4475 base class, even if not all of the base functions are overridden:
4480 virtual void f(int);
4483 struct D: public C @{
4484 void f(int); // does override
4488 This pattern is less likely to be a mistake; if D is only used
4489 virtually, the user might have decided that the base class semantics
4490 for some of the overloads are fine.
4492 At level 1, this case does not warn; at level 2, it does.
4493 @option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4494 included in @option{-Wall}.
4496 @opindex Wno-pmf-conversions
4497 @opindex Wpmf-conversions
4498 @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
4499 Disable the diagnostic for converting a bound pointer to member function
4502 @opindex Wsign-promo
4503 @opindex Wno-sign-promo
4504 @item -Wsign-promo @r{(C++ and Objective-C++ only)}
4505 Warn when overload resolution chooses a promotion from unsigned or
4506 enumerated type to a signed type, over a conversion to an unsigned type of
4507 the same size. Previous versions of G++ tried to preserve
4508 unsignedness, but the standard mandates the current behavior.
4511 @opindex Wno-templates
4512 @item -Wtemplates @r{(C++ and Objective-C++ only)}
4513 Warn when a primary template declaration is encountered. Some coding
4514 rules disallow templates, and this may be used to enforce that rule.
4515 The warning is inactive inside a system header file, such as the STL, so
4516 one can still use the STL. One may also instantiate or specialize
4519 @opindex Wmismatched-new-delete
4520 @opindex Wno-mismatched-new-delete
4521 @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
4522 Warn for mismatches between calls to @code{operator new} or @code{operator
4523 delete} and the corresponding call to the allocation or deallocation function.
4524 This includes invocations of C++ @code{operator delete} with pointers
4525 returned from either mismatched forms of @code{operator new}, or from other
4526 functions that allocate objects for which the @code{operator delete} isn't
4527 a suitable deallocator, as well as calls to other deallocation functions
4528 with pointers returned from @code{operator new} for which the deallocation
4529 function isn't suitable.
4531 For example, the @code{delete} expression in the function below is diagnosed
4532 because it doesn't match the array form of the @code{new} expression
4533 the pointer argument was returned from. Similarly, the call to @code{free}
4539 int *a = new int[n];
4540 delete a; // warning: mismatch in array forms of expressions
4542 char *p = new char[n];
4543 free (p); // warning: mismatch between new and free
4547 The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4548 involving allocation and deallocation functions other than @code{operator
4549 new} and @code{operator delete}.
4551 @option{-Wmismatched-new-delete} is included in @option{-Wall}.
4553 @opindex Wmismatched-tags
4554 @opindex Wno-mismatched-tags
4555 @item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
4556 Warn for declarations of structs, classes, and class templates and their
4557 specializations with a class-key that does not match either the definition
4558 or the first declaration if no definition is provided.
4560 For example, the declaration of @code{struct Object} in the argument list
4561 of @code{draw} triggers the warning. To avoid it, either remove the redundant
4562 class-key @code{struct} or replace it with @code{class} to match its definition.
4566 virtual ~Object () = 0;
4568 void draw (struct Object*);
4571 It is not wrong to declare a class with the class-key @code{struct} as
4572 the example above shows. The @option{-Wmismatched-tags} option is intended
4573 to help achieve a consistent style of class declarations. In code that is
4574 intended to be portable to Windows-based compilers the warning helps prevent
4575 unresolved references due to the difference in the mangling of symbols
4576 declared with different class-keys. The option can be used either on its
4577 own or in conjunction with @option{-Wredundant-tags}.
4579 @opindex Wmultiple-inheritance
4580 @opindex Wno-multiple-inheritance
4581 @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
4582 Warn when a class is defined with multiple direct base classes. Some
4583 coding rules disallow multiple inheritance, and this may be used to
4584 enforce that rule. The warning is inactive inside a system header file,
4585 such as the STL, so one can still use the STL. One may also define
4586 classes that indirectly use multiple inheritance.
4588 @opindex Wvirtual-inheritance
4589 @opindex Wno-virtual-inheritance
4590 @item -Wvirtual-inheritance
4591 Warn when a class is defined with a virtual direct base class. Some
4592 coding rules disallow multiple inheritance, and this may be used to
4593 enforce that rule. The warning is inactive inside a system header file,
4594 such as the STL, so one can still use the STL. One may also define
4595 classes that indirectly use virtual inheritance.
4597 @opindex Wvirtual-move-assign
4598 @opindex Wno-virtual-move-assign
4599 @item -Wno-virtual-move-assign
4600 Suppress warnings about inheriting from a virtual base with a
4601 non-trivial C++11 move assignment operator. This is dangerous because
4602 if the virtual base is reachable along more than one path, it is
4603 moved multiple times, which can mean both objects end up in the
4604 moved-from state. If the move assignment operator is written to avoid
4605 moving from a moved-from object, this warning can be disabled.
4607 @opindex Wnamespaces
4608 @opindex Wno-namespaces
4610 Warn when a namespace definition is opened. Some coding rules disallow
4611 namespaces, and this may be used to enforce that rule. The warning is
4612 inactive inside a system header file, such as the STL, so one can still
4613 use the STL. One may also use using directives and qualified names.
4615 @opindex Wtemplate-id-cdtor
4616 @opindex Wno-template-id-cdtor
4617 @item -Wno-template-id-cdtor @r{(C++ and Objective-C++ only)}
4618 Disable the warning about the use of simple-template-id as the declarator-id
4619 of a constructor or destructor, which became invalid in C++20 via DR 2237.
4623 template<typename T> struct S @{
4624 S<T>(); // should be S();
4625 ~S<T>(); // should be ~S();
4629 @option{-Wtemplate-id-cdtor} is enabled by default with
4630 @option{-std=c++20}; it is also enabled by @option{-Wc++20-compat}.
4633 @opindex Wno-terminate
4634 @item -Wno-terminate @r{(C++ and Objective-C++ only)}
4635 Disable the warning about a throw-expression that will immediately
4636 result in a call to @code{terminate}.
4638 @opindex Wvexing-parse
4639 @opindex Wno-vexing-parse
4640 @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
4641 Warn about the most vexing parse syntactic ambiguity. This warns about
4642 the cases when a declaration looks like a variable definition, but the
4643 C++ language requires it to be interpreted as a function declaration.
4648 int i(); // extern int i (void);
4649 int n(int(a)); // extern int n (int);
4656 struct S @{ S(int); @};
4658 S x(int(a)); // extern struct S x (int);
4659 S y(int()); // extern struct S y (int (*) (void));
4660 S z(); // extern struct S z (void);
4664 The warning will suggest options how to deal with such an ambiguity; e.g.,
4665 it can suggest removing the parentheses or using braces instead.
4667 This warning is enabled by default.
4669 @opindex Wno-class-conversion
4670 @opindex Wclass-conversion
4671 @item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
4672 Do not warn when a conversion function converts an
4673 object to the same type, to a base class of that type, or to void; such
4674 a conversion function will never be called.
4677 @opindex Wno-volatile
4678 @item -Wvolatile @r{(C++ and Objective-C++ only)}
4679 Warn about deprecated uses of the @code{volatile} qualifier. This includes
4680 postfix and prefix @code{++} and @code{--} expressions of
4681 @code{volatile}-qualified types, using simple assignments where the left
4682 operand is a @code{volatile}-qualified non-class type for their value,
4683 compound assignments where the left operand is a @code{volatile}-qualified
4684 non-class type, @code{volatile}-qualified function return type,
4685 @code{volatile}-qualified parameter type, and structured bindings of a
4686 @code{volatile}-qualified type. This usage was deprecated in C++20.
4688 Enabled by default with @option{-std=c++20}.
4690 @opindex Wzero-as-null-pointer-constant
4691 @opindex Wno-zero-as-null-pointer-constant
4692 @item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
4693 Warn when a literal @samp{0} is used as null pointer constant. This can
4694 be useful to facilitate the conversion to @code{nullptr} in C++11.
4696 @opindex Waligned-new
4697 @opindex Wno-aligned-new
4699 Warn about a new-expression of a type that requires greater alignment
4700 than the @code{alignof(std::max_align_t)} but uses an allocation
4701 function without an explicit alignment parameter. This option is
4702 enabled by @option{-Wall}.
4704 Normally this only warns about global allocation functions, but
4705 @option{-Waligned-new=all} also warns about class member allocation
4708 @opindex Wplacement-new
4709 @opindex Wno-placement-new
4710 @item -Wno-placement-new
4711 @itemx -Wplacement-new=@var{n}
4712 Warn about placement new expressions with undefined behavior, such as
4713 constructing an object in a buffer that is smaller than the type of
4714 the object. For example, the placement new expression below is diagnosed
4715 because it attempts to construct an array of 64 integers in a buffer only
4721 This warning is enabled by default.
4724 @item -Wplacement-new=1
4725 This is the default warning level of @option{-Wplacement-new}. At this
4726 level the warning is not issued for some strictly undefined constructs that
4727 GCC allows as extensions for compatibility with legacy code. For example,
4728 the following @code{new} expression is not diagnosed at this level even
4729 though it has undefined behavior according to the C++ standard because
4730 it writes past the end of the one-element array.
4732 struct S @{ int n, a[1]; @};
4733 S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4734 new (s->a)int [32]();
4737 @item -Wplacement-new=2
4738 At this level, in addition to diagnosing all the same constructs as at level
4739 1, a diagnostic is also issued for placement new expressions that construct
4740 an object in the last member of structure whose type is an array of a single
4741 element and whose size is less than the size of the object being constructed.
4742 While the previous example would be diagnosed, the following construct makes
4743 use of the flexible member array extension to avoid the warning at level 2.
4745 struct S @{ int n, a[]; @};
4746 S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4747 new (s->a)int [32]();
4752 @opindex Wcatch-value
4753 @opindex Wno-catch-value
4755 @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
4756 Warn about catch handlers that do not catch via reference.
4757 With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4758 warn about polymorphic class types that are caught by value.
4759 With @option{-Wcatch-value=2} warn about all class types that are caught
4760 by value. With @option{-Wcatch-value=3} warn about all types that are
4761 not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4763 @opindex Wconditionally-supported
4764 @opindex Wno-conditionally-supported
4765 @item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
4766 Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4768 @opindex Wdelete-incomplete
4769 @opindex Wno-delete-incomplete
4770 @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
4771 Do not warn when deleting a pointer to incomplete type, which may cause
4772 undefined behavior at runtime. This warning is enabled by default.
4774 @opindex Wextra-semi
4775 @opindex Wno-extra-semi
4776 @item -Wextra-semi @r{(C++, Objective-C++ only)}
4777 Warn about redundant semicolons after in-class function definitions.
4779 @opindex Wno-global-module
4780 @opindex Wglobal-module
4781 @item -Wno-global-module @r{(C++ and Objective-C++ only)}
4782 Disable the diagnostic for when the global module fragment of a module
4783 unit does not consist only of preprocessor directives.
4785 @opindex Winaccessible-base
4786 @opindex Wno-inaccessible-base
4787 @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
4788 This option controls warnings
4789 when a base class is inaccessible in a class derived from it due to
4790 ambiguity. The warning is enabled by default.
4791 Note that the warning for ambiguous virtual
4792 bases is enabled by the @option{-Wextra} option.
4795 struct A @{ int a; @};
4799 struct C : B, A @{ @};
4803 @opindex Winherited-variadic-ctor
4804 @opindex Wno-inherited-variadic-ctor
4805 @item -Wno-inherited-variadic-ctor
4806 Suppress warnings about use of C++11 inheriting constructors when the
4807 base class inherited from has a C variadic constructor; the warning is
4808 on by default because the ellipsis is not inherited.
4810 @opindex Wno-invalid-offsetof
4811 @opindex Winvalid-offsetof
4812 @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
4813 Suppress warnings from applying the @code{offsetof} macro to a non-POD
4814 type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4815 to a non-standard-layout type is undefined. In existing C++ implementations,
4816 however, @code{offsetof} typically gives meaningful results.
4817 This flag is for users who are aware that they are
4818 writing nonportable code and who have deliberately chosen to ignore the
4821 The restrictions on @code{offsetof} may be relaxed in a future version
4822 of the C++ standard.
4824 @opindex Wsized-deallocation
4825 @opindex Wno-sized-deallocation
4826 @item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
4827 Warn about a definition of an unsized deallocation function
4829 void operator delete (void *) noexcept;
4830 void operator delete[] (void *) noexcept;
4832 without a definition of the corresponding sized deallocation function
4834 void operator delete (void *, std::size_t) noexcept;
4835 void operator delete[] (void *, std::size_t) noexcept;
4837 or vice versa. Enabled by @option{-Wextra} along with
4838 @option{-fsized-deallocation}.
4840 @opindex Wno-suggest-final-types
4841 @opindex Wsuggest-final-types
4842 @item -Wsuggest-final-types
4843 Warn about types with virtual methods where code quality would be improved
4844 if the type were declared with the C++11 @code{final} specifier,
4846 declared in an anonymous namespace. This allows GCC to more aggressively
4847 devirtualize the polymorphic calls. This warning is more effective with
4848 link-time optimization,
4849 where the information about the class hierarchy graph is
4852 @opindex Wno-suggest-final-methods
4853 @opindex Wsuggest-final-methods
4854 @item -Wsuggest-final-methods
4855 Warn about virtual methods where code quality would be improved if the method
4856 were declared with the C++11 @code{final} specifier,
4857 or, if possible, its type were
4858 declared in an anonymous namespace or with the @code{final} specifier.
4860 more effective with link-time optimization, where the information about the
4861 class hierarchy graph is more complete. It is recommended to first consider
4862 suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4865 @opindex Wsuggest-override
4866 @opindex Wno-suggest-override
4867 @item -Wsuggest-override
4868 Warn about overriding virtual functions that are not marked with the
4869 @code{override} keyword.
4871 @opindex Wconversion-null
4872 @opindex Wno-conversion-null
4873 @item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
4874 Do not warn for conversions between @code{NULL} and non-pointer
4875 types. @option{-Wconversion-null} is enabled by default.
4879 @node Objective-C and Objective-C++ Dialect Options
4880 @section Options Controlling Objective-C and Objective-C++ Dialects
4882 @cindex compiler options, Objective-C and Objective-C++
4883 @cindex Objective-C and Objective-C++ options, command-line
4884 @cindex options, Objective-C and Objective-C++
4885 (NOTE: This manual does not describe the Objective-C and Objective-C++
4886 languages themselves. @xref{Standards,,Language Standards
4887 Supported by GCC}, for references.)
4889 This section describes the command-line options that are only meaningful
4890 for Objective-C and Objective-C++ programs. You can also use most of
4891 the language-independent GNU compiler options.
4892 For example, you might compile a file @file{some_class.m} like this:
4895 gcc -g -fgnu-runtime -O -c some_class.m
4899 In this example, @option{-fgnu-runtime} is an option meant only for
4900 Objective-C and Objective-C++ programs; you can use the other options with
4901 any language supported by GCC@.
4903 Note that since Objective-C is an extension of the C language, Objective-C
4904 compilations may also use options specific to the C front-end (e.g.,
4905 @option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4906 C++-specific options (e.g., @option{-Wabi}).
4908 Here is a list of options that are @emph{only} for compiling Objective-C
4909 and Objective-C++ programs:
4912 @opindex fconstant-string-class
4913 @item -fconstant-string-class=@var{class-name}
4914 Use @var{class-name} as the name of the class to instantiate for each
4915 literal string specified with the syntax @code{@@"@dots{}"}. The default
4916 class name is @code{NXConstantString} if the GNU runtime is being used, and
4917 @code{NSConstantString} if the NeXT runtime is being used (see below). On
4918 Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if
4919 also present, overrides the @option{-fconstant-string-class} setting and cause
4920 @code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings.
4921 Note that @option{-fconstant-cfstrings} is an alias for the target-specific
4922 @option{-mconstant-cfstrings} equivalent.
4924 @opindex fgnu-runtime
4926 Generate object code compatible with the standard GNU Objective-C
4927 runtime. This is the default for most types of systems.
4929 @opindex fnext-runtime
4930 @item -fnext-runtime
4931 Generate output compatible with the NeXT runtime. This is the default
4932 for NeXT-based systems, including Darwin / macOS. The macro
4933 @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4936 @opindex fno-nil-receivers
4937 @opindex fnil-receivers
4938 @item -fno-nil-receivers
4939 Assume that all Objective-C message dispatches (@code{[receiver
4940 message:arg]}) in this translation unit ensure that the receiver is
4941 not @code{nil}. This allows for more efficient entry points in the
4942 runtime to be used. This option is only available in conjunction with
4943 the NeXT runtime and ABI version 0 or 1.
4945 @opindex fobjc-abi-version
4946 @item -fobjc-abi-version=@var{n}
4947 Use version @var{n} of the Objective-C ABI for the selected runtime.
4948 This option is currently supported only for the NeXT runtime. In that
4949 case, Version 0 is the traditional (32-bit) ABI without support for
4950 properties and other Objective-C 2.0 additions. Version 1 is the
4951 traditional (32-bit) ABI with support for properties and other
4952 Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4953 nothing is specified, the default is Version 0 on 32-bit target
4954 machines, and Version 2 on 64-bit target machines.
4956 @opindex fobjc-call-cxx-cdtors
4957 @item -fobjc-call-cxx-cdtors
4958 For each Objective-C class, check if any of its instance variables is a
4959 C++ object with a non-trivial default constructor. If so, synthesize a
4960 special @code{- (id) .cxx_construct} instance method which runs
4961 non-trivial default constructors on any such instance variables, in order,
4962 and then return @code{self}. Similarly, check if any instance variable
4963 is a C++ object with a non-trivial destructor, and if so, synthesize a
4964 special @code{- (void) .cxx_destruct} method which runs
4965 all such default destructors, in reverse order.
4967 The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4968 methods thusly generated only operate on instance variables
4969 declared in the current Objective-C class, and not those inherited
4970 from superclasses. It is the responsibility of the Objective-C
4971 runtime to invoke all such methods in an object's inheritance
4972 hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4973 by the runtime immediately after a new object instance is allocated;
4974 the @code{- (void) .cxx_destruct} methods are invoked immediately
4975 before the runtime deallocates an object instance.
4977 As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4978 support for invoking the @code{- (id) .cxx_construct} and
4979 @code{- (void) .cxx_destruct} methods.
4981 @opindex fobjc-direct-dispatch
4982 @item -fobjc-direct-dispatch
4983 Allow fast jumps to the message dispatcher. On Darwin this is
4984 accomplished via the comm page.
4986 @opindex fobjc-exceptions
4987 @item -fobjc-exceptions
4988 Enable syntactic support for structured exception handling in
4989 Objective-C, similar to what is offered by C++. This option
4990 is required to use the Objective-C keywords @code{@@try},
4991 @code{@@throw}, @code{@@catch}, @code{@@finally} and
4992 @code{@@synchronized}. This option is available with both the GNU
4993 runtime and the NeXT runtime (but not available in conjunction with
4994 the NeXT runtime on Mac OS X 10.2 and earlier).
4998 Enable garbage collection (GC) in Objective-C and Objective-C++
4999 programs. This option is only available with the NeXT runtime; the
5000 GNU runtime has a different garbage collection implementation that
5001 does not require special compiler flags.
5003 @opindex fobjc-nilcheck
5004 @item -fobjc-nilcheck
5005 For the NeXT runtime with version 2 of the ABI, check for a nil
5006 receiver in method invocations before doing the actual method call.
5007 This is the default and can be disabled using
5008 @option{-fno-objc-nilcheck}. Class methods and super calls are never
5009 checked for nil in this way no matter what this flag is set to.
5010 Currently this flag does nothing when the GNU runtime, or an older
5011 version of the NeXT runtime ABI, is used.
5014 @item -fobjc-std=objc1
5015 Conform to the language syntax of Objective-C 1.0, the language
5016 recognized by GCC 4.0. This only affects the Objective-C additions to
5017 the C/C++ language; it does not affect conformance to C/C++ standards,
5018 which is controlled by the separate C/C++ dialect option flags. When
5019 this option is used with the Objective-C or Objective-C++ compiler,
5020 any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
5021 This is useful if you need to make sure that your Objective-C code can
5022 be compiled with older versions of GCC@.
5024 @opindex freplace-objc-classes
5025 @item -freplace-objc-classes
5026 Emit a special marker instructing @command{ld(1)} not to statically link in
5027 the resulting object file, and allow @command{dyld(1)} to load it in at
5028 run time instead. This is used in conjunction with the Fix-and-Continue
5029 debugging mode, where the object file in question may be recompiled and
5030 dynamically reloaded in the course of program execution, without the need
5031 to restart the program itself. Currently, Fix-and-Continue functionality
5032 is only available in conjunction with the NeXT runtime on Mac OS X 10.3
5037 When compiling for the NeXT runtime, the compiler ordinarily replaces calls
5038 to @code{objc_getClass("@dots{}")} (when the name of the class is known at
5039 compile time) with static class references that get initialized at load time,
5040 which improves run-time performance. Specifying the @option{-fzero-link} flag
5041 suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
5042 to be retained. This is useful in Zero-Link debugging mode, since it allows
5043 for individual class implementations to be modified during program execution.
5044 The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
5045 regardless of command-line options.
5047 @opindex fno-local-ivars
5048 @opindex flocal-ivars
5049 @item -fno-local-ivars
5050 By default instance variables in Objective-C can be accessed as if
5051 they were local variables from within the methods of the class they're
5052 declared in. This can lead to shadowing between instance variables
5053 and other variables declared either locally inside a class method or
5054 globally with the same name. Specifying the @option{-fno-local-ivars}
5055 flag disables this behavior thus avoiding variable shadowing issues.
5057 @opindex fivar-visibility
5058 @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
5059 Set the default instance variable visibility to the specified option
5060 so that instance variables declared outside the scope of any access
5061 modifier directives default to the specified visibility.
5065 Dump interface declarations for all classes seen in the source file to a
5066 file named @file{@var{sourcename}.decl}.
5068 @opindex Wassign-intercept
5069 @opindex Wno-assign-intercept
5070 @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
5071 Warn whenever an Objective-C assignment is being intercepted by the
5074 @opindex Wproperty-assign-default
5075 @opindex Wno-property-assign-default
5076 @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
5077 Do not warn if a property for an Objective-C object has no assign
5078 semantics specified.
5080 @opindex Wno-protocol
5082 @item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
5083 If a class is declared to implement a protocol, a warning is issued for
5084 every method in the protocol that is not implemented by the class. The
5085 default behavior is to issue a warning for every method not explicitly
5086 implemented in the class, even if a method implementation is inherited
5087 from the superclass. If you use the @option{-Wno-protocol} option, then
5088 methods inherited from the superclass are considered to be implemented,
5089 and no warning is issued for them.
5091 @opindex Wobjc-root-class
5092 @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
5093 Warn if a class interface lacks a superclass. Most classes will inherit
5094 from @code{NSObject} (or @code{Object}) for example. When declaring
5095 classes intended to be root classes, the warning can be suppressed by
5096 marking their interfaces with @code{__attribute__((objc_root_class))}.
5099 @opindex Wno-selector
5100 @item -Wselector @r{(Objective-C and Objective-C++ only)}
5101 Warn if multiple methods of different types for the same selector are
5102 found during compilation. The check is performed on the list of methods
5103 in the final stage of compilation. Additionally, a check is performed
5104 for each selector appearing in a @code{@@selector(@dots{})}
5105 expression, and a corresponding method for that selector has been found
5106 during compilation. Because these checks scan the method table only at
5107 the end of compilation, these warnings are not produced if the final
5108 stage of compilation is not reached, for example because an error is
5109 found during compilation, or because the @option{-fsyntax-only} option is
5112 @opindex Wstrict-selector-match
5113 @opindex Wno-strict-selector-match
5114 @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
5115 Warn if multiple methods with differing argument and/or return types are
5116 found for a given selector when attempting to send a message using this
5117 selector to a receiver of type @code{id} or @code{Class}. When this flag
5118 is off (which is the default behavior), the compiler omits such warnings
5119 if any differences found are confined to types that share the same size
5122 @opindex Wundeclared-selector
5123 @opindex Wno-undeclared-selector
5124 @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
5125 Warn if a @code{@@selector(@dots{})} expression referring to an
5126 undeclared selector is found. A selector is considered undeclared if no
5127 method with that name has been declared before the
5128 @code{@@selector(@dots{})} expression, either explicitly in an
5129 @code{@@interface} or @code{@@protocol} declaration, or implicitly in
5130 an @code{@@implementation} section. This option always performs its
5131 checks as soon as a @code{@@selector(@dots{})} expression is found,
5132 while @option{-Wselector} only performs its checks in the final stage of
5133 compilation. This also enforces the coding style convention
5134 that methods and selectors must be declared before being used.
5136 @opindex print-objc-runtime-info
5137 @item -print-objc-runtime-info
5138 Generate C header describing the largest structure that is passed by
5143 @node Diagnostic Message Formatting Options
5144 @section Options to Control Diagnostic Messages Formatting
5145 @cindex options to control diagnostics formatting
5146 @cindex diagnostic messages
5147 @cindex message formatting
5149 Traditionally, diagnostic messages have been formatted irrespective of
5150 the output device's aspect (e.g.@: its width, @dots{}). You can use the
5151 options described below
5152 to control the formatting algorithm for diagnostic messages,
5153 e.g.@: how many characters per line, how often source location
5154 information should be reported. Note that some language front ends may not
5155 honor these options.
5158 @opindex fmessage-length
5159 @item -fmessage-length=@var{n}
5160 Try to format error messages so that they fit on lines of about
5161 @var{n} characters. If @var{n} is zero, then no line-wrapping is
5162 done; each error message appears on a single line. This is the
5163 default for all front ends.
5165 Note - this option also affects the display of the @samp{#error} and
5166 @samp{#warning} pre-processor directives, and the @samp{deprecated}
5167 function/type/variable attribute. It does not however affect the
5168 @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5170 @item -fdiagnostics-plain-output
5171 This option requests that diagnostic output look as plain as possible, which
5172 may be useful when running @command{dejagnu} or other utilities that need to
5173 parse diagnostics output and prefer that it remain more stable over time.
5174 @option{-fdiagnostics-plain-output} is currently equivalent to the following
5176 @gccoptlist{-fno-diagnostics-show-caret
5177 -fno-diagnostics-show-line-numbers
5178 -fdiagnostics-color=never
5179 -fdiagnostics-urls=never
5180 -fdiagnostics-path-format=separate-events
5181 -fdiagnostics-text-art-charset=none}
5182 In the future, if GCC changes the default appearance of its diagnostics, the
5183 corresponding option to disable the new behavior will be added to this list.
5185 @opindex fdiagnostics-show-location
5186 @item -fdiagnostics-show-location=once
5187 Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5188 reporter to emit source location information @emph{once}; that is, in
5189 case the message is too long to fit on a single physical line and has to
5190 be wrapped, the source location won't be emitted (as prefix) again,
5191 over and over, in subsequent continuation lines. This is the default
5194 @item -fdiagnostics-show-location=every-line
5195 Only meaningful in line-wrapping mode. Instructs the diagnostic
5196 messages reporter to emit the same source location information (as
5197 prefix) for physical lines that result from the process of breaking
5198 a message which is too long to fit on a single line.
5200 @opindex fdiagnostics-color
5201 @cindex highlight, color
5202 @vindex GCC_COLORS @r{environment variable}
5203 @item -fdiagnostics-color[=@var{WHEN}]
5204 @itemx -fno-diagnostics-color
5205 Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5206 or @samp{auto}. The default depends on how the compiler has been configured,
5207 it can be any of the above @var{WHEN} options or also @samp{never}
5208 if @env{GCC_COLORS} environment variable isn't present in the environment,
5209 and @samp{auto} otherwise.
5210 @samp{auto} makes GCC use color only when the standard error is a terminal,
5211 and when not executing in an emacs shell.
5212 The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5213 aliases for @option{-fdiagnostics-color=always} and
5214 @option{-fdiagnostics-color=never}, respectively.
5216 The colors are defined by the environment variable @env{GCC_COLORS}.
5217 Its value is a colon-separated list of capabilities and Select Graphic
5218 Rendition (SGR) substrings. SGR commands are interpreted by the
5219 terminal or terminal emulator. (See the section in the documentation
5220 of your text terminal for permitted values and their meanings as
5221 character attributes.) These substring values are integers in decimal
5222 representation and can be concatenated with semicolons.
5223 Common values to concatenate include
5225 @samp{4} for underline,
5227 @samp{7} for inverse,
5228 @samp{39} for default foreground color,
5229 @samp{30} to @samp{37} for foreground colors,
5230 @samp{90} to @samp{97} for 16-color mode foreground colors,
5231 @samp{38;5;0} to @samp{38;5;255}
5232 for 88-color and 256-color modes foreground colors,
5233 @samp{49} for default background color,
5234 @samp{40} to @samp{47} for background colors,
5235 @samp{100} to @samp{107} for 16-color mode background colors,
5236 and @samp{48;5;0} to @samp{48;5;255}
5237 for 88-color and 256-color modes background colors.
5239 The default @env{GCC_COLORS} is
5241 error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5242 quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5243 diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5244 type-diff=01;32:fnname=01;32:targs=35
5247 where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5248 @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5249 @samp{01} is bold, and @samp{31} is red.
5250 Setting @env{GCC_COLORS} to the empty string disables colors.
5251 Supported capabilities are as follows.
5254 @vindex error GCC_COLORS @r{capability}
5256 SGR substring for error: markers.
5258 @vindex warning GCC_COLORS @r{capability}
5260 SGR substring for warning: markers.
5262 @vindex note GCC_COLORS @r{capability}
5264 SGR substring for note: markers.
5266 @vindex path GCC_COLORS @r{capability}
5268 SGR substring for colorizing paths of control-flow events as printed
5269 via @option{-fdiagnostics-path-format=}, such as the identifiers of
5270 individual events and lines indicating interprocedural calls and returns.
5272 @vindex range1 GCC_COLORS @r{capability}
5274 SGR substring for first additional range.
5276 @vindex range2 GCC_COLORS @r{capability}
5278 SGR substring for second additional range.
5280 @vindex locus GCC_COLORS @r{capability}
5282 SGR substring for location information, @samp{file:line} or
5283 @samp{file:line:column} etc.
5285 @vindex quote GCC_COLORS @r{capability}
5287 SGR substring for information printed within quotes.
5289 @vindex fnname GCC_COLORS @r{capability}
5291 SGR substring for names of C++ functions.
5293 @vindex targs GCC_COLORS @r{capability}
5295 SGR substring for C++ function template parameter bindings.
5297 @vindex fixit-insert GCC_COLORS @r{capability}
5299 SGR substring for fix-it hints suggesting text to
5300 be inserted or replaced.
5302 @vindex fixit-delete GCC_COLORS @r{capability}
5304 SGR substring for fix-it hints suggesting text to
5307 @vindex diff-filename GCC_COLORS @r{capability}
5308 @item diff-filename=
5309 SGR substring for filename headers within generated patches.
5311 @vindex diff-hunk GCC_COLORS @r{capability}
5313 SGR substring for the starts of hunks within generated patches.
5315 @vindex diff-delete GCC_COLORS @r{capability}
5317 SGR substring for deleted lines within generated patches.
5319 @vindex diff-insert GCC_COLORS @r{capability}
5321 SGR substring for inserted lines within generated patches.
5323 @vindex type-diff GCC_COLORS @r{capability}
5325 SGR substring for highlighting mismatching types within template
5326 arguments in the C++ frontend.
5329 @opindex fdiagnostics-urls
5331 @vindex GCC_URLS @r{environment variable}
5332 @vindex TERM_URLS @r{environment variable}
5333 @item -fdiagnostics-urls[=@var{WHEN}]
5334 Use escape sequences to embed URLs in diagnostics. For example, when
5335 @option{-fdiagnostics-show-option} emits text showing the command-line
5336 option controlling a diagnostic, embed a URL for documentation of that
5339 @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5340 @samp{auto} makes GCC use URL escape sequences only when the standard error
5341 is a terminal, and when not executing in an emacs shell or any graphical
5342 terminal which is known to be incompatible with this feature, see below.
5344 The default depends on how the compiler has been configured.
5345 It can be any of the above @var{WHEN} options.
5347 GCC can also be configured (via the
5348 @option{--with-diagnostics-urls=auto-if-env} configure-time option)
5349 so that the default is affected by environment variables.
5350 Under such a configuration, GCC defaults to using @samp{auto}
5351 if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5352 present and non-empty in the environment of the compiler, or @samp{never}
5355 However, even with @option{-fdiagnostics-urls=always} the behavior is
5356 dependent on those environment variables:
5357 If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5358 diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5359 If set to @samp{bel}, the default, URLs use BEL escape sequences.
5360 Any other non-empty value enables the feature.
5361 If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5362 Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5363 BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5365 At this time GCC tries to detect also a few terminals that are known to
5366 not implement the URL feature, and have bugs or at least had bugs in
5367 some versions that are still in use, where the URL escapes are likely
5368 to misbehave, i.e. print garbage on the screen.
5369 That list is currently xfce4-terminal, certain known to be buggy
5370 gnome-terminal versions, the linux console, and mingw.
5371 This check can be skipped with the @option{-fdiagnostics-urls=always}.
5373 @opindex fno-diagnostics-show-option
5374 @opindex fdiagnostics-show-option
5375 @item -fno-diagnostics-show-option
5376 By default, each diagnostic emitted includes text indicating the
5377 command-line option that directly controls the diagnostic (if such an
5378 option is known to the diagnostic machinery). Specifying the
5379 @option{-fno-diagnostics-show-option} flag suppresses that behavior.
5381 @opindex fno-diagnostics-show-caret
5382 @opindex fdiagnostics-show-caret
5383 @item -fno-diagnostics-show-caret
5384 By default, each diagnostic emitted includes the original source line
5385 and a caret @samp{^} indicating the column. This option suppresses this
5386 information. The source line is truncated to @var{n} characters, if
5387 the @option{-fmessage-length=n} option is given. When the output is done
5388 to the terminal, the width is limited to the width given by the
5389 @env{COLUMNS} environment variable or, if not set, to the terminal width.
5391 @opindex fno-diagnostics-show-labels
5392 @opindex fdiagnostics-show-labels
5393 @item -fno-diagnostics-show-labels
5394 By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5395 diagnostics can label ranges of source code with pertinent information, such
5396 as the types of expressions:
5399 printf ("foo %s bar", long_i + long_j);
5405 This option suppresses the printing of these labels (in the example above,
5406 the vertical bars and the ``char *'' and ``long int'' text).
5408 @opindex fno-diagnostics-show-cwe
5409 @opindex fdiagnostics-show-cwe
5410 @item -fno-diagnostics-show-cwe
5411 Diagnostic messages can optionally have an associated
5412 @uref{https://cwe.mitre.org/index.html, CWE} identifier.
5413 GCC itself only provides such metadata for some of the @option{-fanalyzer}
5414 diagnostics. GCC plugins may also provide diagnostics with such metadata.
5415 By default, if this information is present, it will be printed with
5416 the diagnostic. This option suppresses the printing of this metadata.
5418 @opindex fno-diagnostics-show-rules
5419 @opindex fdiagnostics-show-rules
5420 @item -fno-diagnostics-show-rules
5421 Diagnostic messages can optionally have rules associated with them, such
5422 as from a coding standard, or a specification.
5423 GCC itself does not do this for any of its diagnostics, but plugins may do so.
5424 By default, if this information is present, it will be printed with
5425 the diagnostic. This option suppresses the printing of this metadata.
5427 @opindex fno-diagnostics-show-line-numbers
5428 @opindex fdiagnostics-show-line-numbers
5429 @item -fno-diagnostics-show-line-numbers
5430 By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5431 a left margin is printed, showing line numbers. This option suppresses this
5434 @opindex fdiagnostics-minimum-margin-width
5435 @item -fdiagnostics-minimum-margin-width=@var{width}
5436 This option controls the minimum width of the left margin printed by
5437 @option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5439 @opindex fdiagnostics-parseable-fixits
5440 @item -fdiagnostics-parseable-fixits
5441 Emit fix-it hints in a machine-parseable format, suitable for consumption
5442 by IDEs. For each fix-it, a line will be printed after the relevant
5443 diagnostic, starting with the string ``fix-it:''. For example:
5446 fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5449 The location is expressed as a half-open range, expressed as a count of
5450 bytes, starting at byte 1 for the initial column. In the above example,
5451 bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5455 00000000011111111112222222222
5456 12345678901234567890123456789
5457 gtk_widget_showall (dlg);
5462 The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5463 newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5464 (e.g. vertical tab as ``\013'').
5466 An empty replacement string indicates that the given range is to be removed.
5467 An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5468 be inserted at the given position.
5470 @opindex fdiagnostics-generate-patch
5471 @item -fdiagnostics-generate-patch
5472 Print fix-it hints to stderr in unified diff format, after any diagnostics
5473 are printed. For example:
5480 void show_cb(GtkDialog *dlg)
5482 - gtk_widget_showall(dlg);
5483 + gtk_widget_show_all(dlg);
5488 The diff may or may not be colorized, following the same rules
5489 as for diagnostics (see @option{-fdiagnostics-color}).
5491 @opindex fdiagnostics-show-template-tree
5492 @item -fdiagnostics-show-template-tree
5494 In the C++ frontend, when printing diagnostics showing mismatching
5495 template types, such as:
5498 could not convert 'std::map<int, std::vector<double> >()'
5499 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5502 the @option{-fdiagnostics-show-template-tree} flag enables printing a
5503 tree-like structure showing the common and differing parts of the types,
5513 The parts that differ are highlighted with color (``double'' and
5514 ``float'' in this case).
5516 @opindex fno-elide-type
5517 @opindex felide-type
5518 @item -fno-elide-type
5519 By default when the C++ frontend prints diagnostics showing mismatching
5520 template types, common parts of the types are printed as ``[...]'' to
5521 simplify the error message. For example:
5524 could not convert 'std::map<int, std::vector<double> >()'
5525 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5528 Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5529 This flag also affects the output of the
5530 @option{-fdiagnostics-show-template-tree} flag.
5532 @opindex fdiagnostics-path-format
5533 @item -fdiagnostics-path-format=@var{KIND}
5534 Specify how to print paths of control-flow events for diagnostics that
5535 have such a path associated with them.
5537 @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5540 @samp{none} means to not print diagnostic paths.
5542 @samp{separate-events} means to print a separate ``note'' diagnostic for
5543 each event within the diagnostic. For example:
5546 test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5547 test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5548 test.c:27:3: note: (2) when 'i < count'
5549 test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5552 @samp{inline-events} means to print the events ``inline'' within the source
5553 code. This view attempts to consolidate the events into runs of
5554 sufficiently-close events, printing them as labelled ranges within the source.
5556 For example, the same events as above might be printed as:
5561 | 25 | list = PyList_New(0);
5564 | | (1) when 'PyList_New' fails, returning NULL
5566 | 27 | for (i = 0; i < count; i++) @{
5569 | | (2) when 'i < count'
5570 | 28 | item = PyLong_FromLong(random());
5571 | 29 | PyList_Append(list, item);
5572 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5574 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5578 Interprocedural control flow is shown by grouping the events by stack frame,
5579 and using indentation to show how stack frames are nested, pushed, and popped.
5589 | | (1) entering 'test'
5590 | 134 | boxed_int *obj = make_boxed_int (i);
5591 | | ~~~~~~~~~~~~~~~~~~
5593 | | (2) calling 'make_boxed_int'
5595 +--> 'make_boxed_int': events 3-4
5600 | | (3) entering 'make_boxed_int'
5601 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5602 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5604 | | (4) calling 'wrapped_malloc'
5606 +--> 'wrapped_malloc': events 5-6
5611 | | (5) entering 'wrapped_malloc'
5612 | 8 | return malloc (size);
5615 | | (6) calling 'malloc'
5621 | 138 | free_boxed_int (obj);
5622 | | ^~~~~~~~~~~~~~~~~~~~
5624 | | (7) calling 'free_boxed_int'
5629 @opindex fdiagnostics-show-path-depths
5630 @item -fdiagnostics-show-path-depths
5631 This option provides additional information when printing control-flow paths
5632 associated with a diagnostic.
5634 If this is option is provided then the stack depth will be printed for
5635 each run of events within @option{-fdiagnostics-path-format=inline-events}.
5636 If provided with @option{-fdiagnostics-path-format=separate-events}, then
5637 the stack depth and function declaration will be appended when printing
5640 This is intended for use by GCC developers and plugin developers when
5641 debugging diagnostics that report interprocedural control flow.
5643 @opindex fno-show-column
5644 @opindex fshow-column
5645 @item -fno-show-column
5646 Do not print column numbers in diagnostics. This may be necessary if
5647 diagnostics are being scanned by a program that does not understand the
5648 column numbers, such as @command{dejagnu}.
5650 @opindex fdiagnostics-column-unit
5651 @item -fdiagnostics-column-unit=@var{UNIT}
5652 Select the units for the column number. This affects traditional diagnostics
5653 (in the absence of @option{-fno-show-column}), as well as JSON format
5654 diagnostics if requested.
5656 The default @var{UNIT}, @samp{display}, considers the number of display
5657 columns occupied by each character. This may be larger than the number
5658 of bytes required to encode the character, in the case of tab
5659 characters, or it may be smaller, in the case of multibyte characters.
5660 For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5661 display column, and its UTF-8 encoding requires two bytes; the character
5662 ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5663 its UTF-8 encoding requires four bytes.
5665 Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5666 count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5668 @opindex fdiagnostics-column-origin
5669 @item -fdiagnostics-column-origin=@var{ORIGIN}
5670 Select the origin for column numbers, i.e. the column number assigned to the
5671 first column. The default value of 1 corresponds to traditional GCC
5672 behavior and to the GNU style guide. Some utilities may perform better with an
5673 origin of 0; any non-negative value may be specified.
5675 @opindex fdiagnostics-escape-format
5676 @item -fdiagnostics-escape-format=@var{FORMAT}
5677 When GCC prints pertinent source lines for a diagnostic it normally attempts
5678 to print the source bytes directly. However, some diagnostics relate to encoding
5679 issues in the source file, such as malformed UTF-8, or issues with Unicode
5680 normalization. These diagnostics are flagged so that GCC will escape bytes
5681 that are not printable ASCII when printing their pertinent source lines.
5683 This option controls how such bytes should be escaped.
5685 The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5686 are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5687 correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5688 displayed as hexadecimal in the form @samp{<XX>}.
5690 For example, a source line containing the string @samp{before} followed by the
5691 Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
5692 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5693 the string @samp{after} will be printed for such a diagnostic as:
5696 before<U+03C0><BF>after
5699 Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5700 in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5701 Unicode characters. For the example above, the following will be printed:
5704 before<CF><80><BF>after
5707 @opindex fdiagnostics-text-art-charset
5708 @item -fdiagnostics-text-art-charset=@var{CHARSET}
5709 Some diagnostics can contain ``text art'' diagrams: visualizations created
5710 from text, intended to be viewed in a monospaced font.
5712 This option selects which characters should be used for printing such
5713 diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode},
5716 The @samp{none} value suppresses the printing of such diagrams.
5717 The @samp{ascii} value will ensure that such diagrams are pure ASCII
5718 (``ASCII art''). The @samp{unicode} value will allow for conservative use of
5719 unicode drawing characters (such as box-drawing characters). The @samp{emoji}
5720 value further adds the possibility of emoji in the output (such as emitting
5721 U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the
5722 emoji variant of the character).
5724 The default is @samp{emoji}, except when the environment variable @env{LANG}
5725 is set to @samp{C}, in which case the default is @samp{ascii}.
5727 @opindex fdiagnostics-format
5728 @item -fdiagnostics-format=@var{FORMAT}
5729 Select a different format for printing diagnostics.
5730 @var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5731 @samp{json}, @samp{json-stderr}, or @samp{json-file}.
5733 The default is @samp{text}.
5735 The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5736 diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5737 named @file{@var{source}.sarif}, respectively.
5739 The @samp{json} format is a synonym for @samp{json-stderr}.
5740 The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5741 where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5742 whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5744 The emitted JSON consists of a top-level JSON array containing JSON objects
5745 representing the diagnostics.
5747 Diagnostics can have child diagnostics. For example, this error and note:
5750 misleading-indentation.c:15:3: warning: this 'if' clause does not
5751 guard... [-Wmisleading-indentation]
5754 misleading-indentation.c:17:5: note: ...this statement, but the latter
5755 is misleadingly indented as if it were guarded by the 'if'
5761 might be printed in JSON form (after formatting) like this:
5770 "display-column": 3,
5773 "file": "misleading-indentation.c",
5777 "display-column": 4,
5780 "file": "misleading-indentation.c",
5785 "message": "this \u2018if\u2019 clause does not guard...",
5786 "option": "-Wmisleading-indentation",
5787 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5794 "display-column": 5,
5797 "file": "misleading-indentation.c",
5802 "escape-source": false,
5803 "message": "...this statement, but the latter is @dots{}"
5806 "escape-source": false,
5813 where the @code{note} is a child of the @code{warning}.
5815 A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5816 an @code{option} key describing the command-line option controlling the
5819 A diagnostic can contain zero or more locations. Each location has an
5820 optional @code{label} string and up to three positions within it: a
5821 @code{caret} position and optional @code{start} and @code{finish} positions.
5822 A position is described by a @code{file} name, a @code{line} number, and
5823 three numbers indicating a column position:
5827 @code{display-column} counts display columns, accounting for tabs and
5828 multibyte characters.
5831 @code{byte-column} counts raw bytes.
5834 @code{column} is equal to one of
5835 the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5839 All three columns are relative to the origin specified by
5840 @option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5841 be set, for instance, to 0 for compatibility with other utilities that
5842 number columns from 0. The column origin is recorded in the JSON output in
5843 the @code{column-origin} tag. In the remaining examples below, the extra
5844 column number outputs have been omitted for brevity.
5846 For example, this error:
5849 bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5850 'struct s'@} and 'T' @{aka 'struct t'@})
5851 64 | return callee_4a () + callee_4b ();
5852 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5854 | | T @{aka struct t@}
5855 | S @{aka struct s@}
5859 has three locations. Its primary location is at the ``+'' token at column
5860 23. It has two secondary locations, describing the left and right-hand sides
5861 of the expression, which have labels. It might be printed in JSON form as:
5870 "column": 23, "file": "bad-binary-ops.c", "line": 64
5875 "column": 10, "file": "bad-binary-ops.c", "line": 64
5878 "column": 21, "file": "bad-binary-ops.c", "line": 64
5880 "label": "S @{aka struct s@}"
5884 "column": 25, "file": "bad-binary-ops.c", "line": 64
5887 "column": 36, "file": "bad-binary-ops.c", "line": 64
5889 "label": "T @{aka struct t@}"
5892 "escape-source": false,
5893 "message": "invalid operands to binary + @dots{}"
5897 If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5898 consisting of half-open intervals, similar to the output of
5899 @option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5900 with a replacement fix-it hint:
5903 demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5905 8 | return ptr->colour;
5911 might be printed in JSON form as:
5946 "escape-source": false,
5947 "message": "\u2018struct s\u2019 has no member named @dots{}"
5952 where the fix-it hint suggests replacing the text from @code{start} up
5953 to but not including @code{next} with @code{string}'s value. Deletions
5954 are expressed via an empty value for @code{string}, insertions by
5955 having @code{start} equal @code{next}.
5957 If the diagnostic has a path of control-flow events associated with it,
5958 it has a @code{path} array of objects representing the events. Each
5959 event object has a @code{description} string, a @code{location} object,
5960 along with a @code{function} string and a @code{depth} number for
5961 representing interprocedural paths. The @code{function} represents the
5962 current function at that event, and the @code{depth} represents the
5963 stack depth relative to some baseline: the higher, the more frames are
5966 For example, the intraprocedural example shown for
5967 @option{-fdiagnostics-path-format=} might have this JSON for its path:
5973 "description": "when 'PyList_New' fails, returning NULL",
5983 "description": "when 'i < count'",
5993 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
6004 Diagnostics have a boolean attribute @code{escape-source}, hinting whether
6005 non-ASCII bytes should be escaped when printing the pertinent lines of
6006 source code (@code{true} for diagnostics involving source encoding issues).
6008 @opindex fno-diagnostics-json-formatting
6009 @opindex fdiagnostics-json-formatting
6010 @item -fno-diagnostics-json-formatting
6011 By default, when JSON is emitted for diagnostics (via
6012 @option{-fdiagnostics-format=sarif-stderr},
6013 @option{-fdiagnostics-format=sarif-file},
6014 @option{-fdiagnostics-format=json},
6015 @option{-fdiagnostics-format=json-stderr},
6016 @option{-fdiagnostics-format=json-file}),
6017 GCC will add newlines and indentation to visually emphasize the
6018 hierarchical structure of the JSON.
6020 Use @option{-fno-diagnostics-json-formatting} to suppress this whitespace.
6021 It must be passed before the option it is to affect.
6023 This is intended for compatibility with tools that do not expect the output
6024 to contain newlines, such as that emitted by older GCC releases.
6028 @node Warning Options
6029 @section Options to Request or Suppress Warnings
6030 @cindex options to control warnings
6031 @cindex warning messages
6032 @cindex messages, warning
6033 @cindex suppressing warnings
6035 Warnings are diagnostic messages that report constructions that
6036 are not inherently erroneous but that are risky or suggest there
6037 may have been an error.
6039 The following language-independent options do not enable specific
6040 warnings but control the kinds of diagnostics produced by GCC@.
6043 @cindex syntax checking
6044 @opindex fsyntax-only
6046 Check the code for syntax errors, but don't do anything beyond that.
6048 @opindex fmax-errors
6049 @item -fmax-errors=@var{n}
6050 Limits the maximum number of error messages to @var{n}, at which point
6051 GCC bails out rather than attempting to continue processing the source
6052 code. If @var{n} is 0 (the default), there is no limit on the number
6053 of error messages produced. If @option{-Wfatal-errors} is also
6054 specified, then @option{-Wfatal-errors} takes precedence over this
6059 Inhibit all warning messages.
6064 Make all warnings into errors.
6069 Make the specified warning into an error. The specifier for a warning
6070 is appended; for example @option{-Werror=switch} turns the warnings
6071 controlled by @option{-Wswitch} into errors. This switch takes a
6072 negative form, to be used to negate @option{-Werror} for specific
6073 warnings; for example @option{-Wno-error=switch} makes
6074 @option{-Wswitch} warnings not be errors, even when @option{-Werror}
6077 The warning message for each controllable warning includes the
6078 option that controls the warning. That option can then be used with
6079 @option{-Werror=} and @option{-Wno-error=} as described above.
6080 (Printing of the option in the warning message can be disabled using the
6081 @option{-fno-diagnostics-show-option} flag.)
6083 Note that specifying @option{-Werror=}@var{foo} automatically implies
6084 @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
6087 @opindex Wfatal-errors
6088 @opindex Wno-fatal-errors
6089 @item -Wfatal-errors
6090 This option causes the compiler to abort compilation on the first error
6091 occurred rather than trying to keep going and printing further error
6096 You can request many specific warnings with options beginning with
6097 @samp{-W}, for example @option{-Wimplicit} to request warnings on
6098 implicit declarations. Each of these specific warning options also
6099 has a negative form beginning @samp{-Wno-} to turn off warnings; for
6100 example, @option{-Wno-implicit}. This manual lists only one of the
6101 two forms, whichever is not the default. For further
6102 language-specific options also refer to @ref{C++ Dialect Options} and
6103 @ref{Objective-C and Objective-C++ Dialect Options}.
6104 Additional warnings can be produced by enabling the static analyzer;
6105 @xref{Static Analyzer Options}.
6107 Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
6108 options, such as @option{-Wunused}, which may turn on further options,
6109 such as @option{-Wunused-value}. The combined effect of positive and
6110 negative forms is that more specific options have priority over less
6111 specific ones, independently of their position in the command-line. For
6112 options of the same specificity, the last one takes effect. Options
6113 enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
6114 as if they appeared at the end of the command-line.
6116 When an unrecognized warning option is requested (e.g.,
6117 @option{-Wunknown-warning}), GCC emits a diagnostic stating
6118 that the option is not recognized. However, if the @option{-Wno-} form
6119 is used, the behavior is slightly different: no diagnostic is
6120 produced for @option{-Wno-unknown-warning} unless other diagnostics
6121 are being produced. This allows the use of new @option{-Wno-} options
6122 with old compilers, but if something goes wrong, the compiler
6123 warns that an unrecognized option is present.
6125 The effectiveness of some warnings depends on optimizations also being
6126 enabled. For example @option{-Wsuggest-final-types} is more effective
6127 with link-time optimization and some instances of other warnings may
6128 not be issued at all unless optimization is enabled. While optimization
6129 in general improves the efficacy of control and data flow sensitive
6130 warnings, in some cases it may also cause false positives.
6135 @opindex Wno-pedantic
6138 Issue all the warnings demanded by strict ISO C and ISO C++;
6139 diagnose all programs that use forbidden extensions, and some other
6140 programs that do not follow ISO C and ISO C++. This follows the version
6141 of the ISO C or C++ standard specified by any @option{-std} option used.
6143 Valid ISO C and ISO C++ programs should compile properly with or without
6144 this option (though a rare few require @option{-ansi} or a
6145 @option{-std} option specifying the version of the standard)@. However,
6146 without this option, certain GNU extensions and traditional C and C++
6147 features are supported as well. With this option, they are diagnosed
6148 (or rejected with @option{-pedantic-errors}).
6150 @option{-Wpedantic} does not cause warning messages for use of the
6151 alternate keywords whose names begin and end with @samp{__}. This alternate
6152 format can also be used to disable warnings for non-ISO @samp{__intN} types,
6153 i.e. @samp{__intN__}.
6154 Pedantic warnings are also disabled in the expression that follows
6155 @code{__extension__}. However, only system header files should use
6156 these escape routes; application programs should avoid them.
6157 @xref{Alternate Keywords}.
6159 Some warnings about non-conforming programs are controlled by options
6160 other than @option{-Wpedantic}; in many cases they are implied by
6161 @option{-Wpedantic} but can be disabled separately by their specific
6162 option, e.g. @option{-Wpedantic -Wno-pointer-sign}.
6164 Where the standard specified with @option{-std} represents a GNU
6165 extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6166 corresponding @dfn{base standard}, the version of ISO C on which the GNU
6167 extended dialect is based. Warnings from @option{-Wpedantic} are given
6168 where they are required by the base standard. (It does not make sense
6169 for such warnings to be given only for features not in the specified GNU
6170 C dialect, since by definition the GNU dialects of C include all
6171 features the compiler supports with the given option, and there would be
6172 nothing to warn about.)
6174 @opindex pedantic-errors
6175 @item -pedantic-errors
6176 Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6177 requires a diagnostic, in some cases where there is undefined behavior
6178 at compile-time and in some other cases that do not prevent compilation
6179 of programs that are valid according to the standard. This is not
6180 equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be
6181 useful, as it only makes errors of the diagnostics that are controlled by
6182 @option{-Wpedantic}, whereas this option also affects required diagnostics that
6183 are always enabled or controlled by options other than @option{-Wpedantic}.
6185 If you want the required diagnostics that are warnings by default to
6186 be errors instead, but don't also want to enable the @option{-Wpedantic}
6187 diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic}
6188 (or @option{-pedantic-errors -Wno-error=pedantic} to enable them but
6191 Some required diagnostics are errors by default, but can be reduced to
6192 warnings using @option{-fpermissive} or their specific warning option,
6193 e.g. @option{-Wno-error=narrowing}.
6195 Some diagnostics for non-ISO practices are controlled by specific
6196 warning options other than @option{-Wpedantic}, but are also made
6197 errors by @option{-pedantic-errors}. For instance:
6200 -Wattributes @r{(for standard attributes)}
6201 -Wchanges-meaning @r{(C++)}
6202 -Wcomma-subscript @r{(C++23 or later)}
6203 -Wdeclaration-after-statement @r{(C90 or earlier)}
6204 -Welaborated-enum-base @r{(C++11 or later)}
6205 -Wimplicit-int @r{(C99 or later)}
6206 -Wimplicit-function-declaration @r{(C99 or later)}
6207 -Wincompatible-pointer-types
6209 -Wlong-long @r{(C90 or earlier)}
6211 -Wnarrowing @r{(C++11 or later)}
6214 -Wincompatible-pointer-types
6215 -Wregister @r{(C++17 or later)}
6216 -Wvla @r{(C90 or earlier)}
6217 -Wwrite-strings @r{(C++11 or later)}
6220 @opindex fpermissive
6222 Downgrade some required diagnostics about nonconformant code from
6223 errors to warnings. Thus, using @option{-fpermissive} allows some
6224 nonconforming code to compile. Some C++ diagnostics are controlled
6225 only by this flag, but it also downgrades some C and C++ diagnostics
6226 that have their own flag:
6229 -Wdeclaration-missing-parameter-type @r{(C and Objective-C only)}
6230 -Wimplicit-function-declaration @r{(C and Objective-C only)}
6231 -Wimplicit-int @r{(C and Objective-C only)}
6232 -Wincompatible-pointer-types @r{(C and Objective-C only)}
6233 -Wint-conversion @r{(C and Objective-C only)}
6234 -Wnarrowing @r{(C++ and Objective-C++ only)}
6235 -Wreturn-mismatch @r{(C and Objective-C only)}
6238 The @option{-fpermissive} option is the default for historic C language
6239 modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90},
6240 @option{-std=gnu90}).
6245 This enables all the warnings about constructions that some users
6246 consider questionable, and that are easy to avoid (or modify to
6247 prevent the warning), even in conjunction with macros. This also
6248 enables some language-specific warnings described in @ref{C++ Dialect
6249 Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6251 @option{-Wall} turns on the following warning flags:
6253 @gccoptlist{-Waddress
6254 -Waligned-new @r{(C++ and Objective-C++ only)}
6255 -Warray-bounds=1 @r{(only with} @option{-O2}@r{)}
6260 -Wc++11-compat -Wc++14-compat -Wc++17compat -Wc++20compat
6261 -Wcatch-value @r{(C++ and Objective-C++ only)}
6263 -Wclass-memaccess @r{(C++ and Objective-C++ only)}
6266 -Wdangling-pointer=2
6267 -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
6268 -Wduplicate-decl-specifier @r{(C and Objective-C only)}
6269 -Wenum-compare @r{(in C/ObjC; this is on by default in C++)}
6270 -Wenum-int-mismatch @r{(C and Objective-C only)}
6272 -Wformat-contains-nul
6276 -Wformat-truncation=1
6277 -Wformat-zero-length
6279 -Wimplicit @r{(C and Objective-C only)}
6280 -Wimplicit-function-declaration @r{(C and Objective-C only)}
6281 -Wimplicit-int @r{(C and Objective-C only)}
6282 -Winfinite-recursion
6283 -Winit-self @r{(C++ and Objective-C++ only)}
6284 -Wint-in-bool-context
6285 -Wlogical-not-parentheses
6286 -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}
6287 -Wmaybe-uninitialized
6289 -Wmemset-transposed-args
6290 -Wmisleading-indentation @r{(only for C/C++)}
6291 -Wmismatched-dealloc
6292 -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
6293 -Wmissing-attributes
6294 -Wmissing-braces @r{(only for C/ObjC)}
6295 -Wmultistatement-macros
6296 -Wnarrowing @r{(C++ and Objective-C++ only)}
6299 -Wopenmp-simd @r{(C and C++ only)}
6300 -Woverloaded-virtual=1 @r{(C++ and Objective-C++ only)}
6301 -Wpacked-not-aligned
6303 -Wpessimizing-move @r{(C++ and Objective-C++ only)}
6304 -Wpointer-sign @r{(only for C/ObjC)}
6305 -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
6306 -Wreorder @r{(C++ and Objective-C++ only)}
6309 -Wself-move @r{(C++ and Objective-C++ only)}
6311 -Wsign-compare @r{(C++ and Objective-C++ only)}
6313 -Wsizeof-pointer-div
6314 -Wsizeof-pointer-memaccess
6318 -Wtautological-compare
6323 -Wunused-but-set-variable
6324 -Wunused-const-variable=1 @r{(only for C/ObjC)}
6327 -Wunused-local-typedefs
6332 -Wvolatile-register-var
6333 -Wzero-length-bounds}
6335 Note that some warning flags are not implied by @option{-Wall}. Some of
6336 them warn about constructions that users generally do not consider
6337 questionable, but which occasionally you might wish to check for;
6338 others warn about constructions that are necessary or hard to avoid in
6339 some cases, and there is no simple way to modify the code to suppress
6340 the warning. Some of them are enabled by @option{-Wextra} but many of
6341 them must be enabled individually.
6347 This enables some extra warning flags that are not enabled by
6348 @option{-Wall}. (This option used to be called @option{-W}. The older
6349 name is still supported, but the newer name is more descriptive.)
6351 @gccoptlist{-Wabsolute-value @r{(only for C/ObjC)}
6353 -Wcalloc-transposed-args
6354 -Wcast-function-type
6356 -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
6358 -Wenum-conversion @r{(only for C/ObjC)}
6359 -Wexpansion-to-defined
6360 -Wignored-qualifiers @r{(only for C/C++)}
6361 -Wimplicit-fallthrough=3
6362 -Wmaybe-uninitialized
6363 -Wmissing-field-initializers
6364 -Wmissing-parameter-type @r{(C/ObjC only)}
6365 -Wold-style-declaration @r{(C/ObjC only)}
6366 -Woverride-init @r{(C/ObjC only)}
6367 -Wredundant-move @r{(C++ and Objective-C++ only)}
6368 -Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
6369 -Wsign-compare @r{(C++ and Objective-C++ only)}
6370 -Wsized-deallocation @r{(C++ and Objective-C++ only)}
6374 -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
6375 -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6377 The option @option{-Wextra} also prints warning messages for the
6383 A pointer is compared against integer zero with @code{<}, @code{<=},
6384 @code{>}, or @code{>=}.
6387 (C++ only) An enumerator and a non-enumerator both appear in a
6388 conditional expression.
6391 (C++ only) Ambiguous virtual bases.
6394 (C++ only) Subscripting an array that has been declared @code{register}.
6397 (C++ only) Taking the address of a variable that has been declared
6401 (C++ only) A base class is not initialized in the copy constructor
6408 @item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
6410 Warn about code affected by ABI changes. This includes code that may
6411 not be compatible with the vendor-neutral C++ ABI as well as the psABI
6412 for the particular target.
6414 Since G++ now defaults to updating the ABI with each major release,
6415 normally @option{-Wabi} warns only about C++ ABI compatibility
6416 problems if there is a check added later in a release series for an
6417 ABI issue discovered since the initial release. @option{-Wabi} warns
6418 about more things if an older ABI version is selected (with
6419 @option{-fabi-version=@var{n}}).
6421 @option{-Wabi} can also be used with an explicit version number to
6422 warn about C++ ABI compatibility with a particular @option{-fabi-version}
6423 level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6424 @option{-fabi-version=2}.
6426 If an explicit version number is provided and
6427 @option{-fabi-compat-version} is not specified, the version number
6428 from this option is used for compatibility aliases. If no explicit
6429 version number is provided with this option, but
6430 @option{-fabi-compat-version} is specified, that version number is
6431 used for C++ ABI warnings.
6433 Although an effort has been made to warn about
6434 all such cases, there are probably some cases that are not warned about,
6435 even though G++ is generating incompatible code. There may also be
6436 cases where warnings are emitted even though the code that is generated
6439 You should rewrite your code to avoid these warnings if you are
6440 concerned about the fact that code generated by G++ may not be binary
6441 compatible with code generated by other compilers.
6443 Known incompatibilities in @option{-fabi-version=2} (which was the
6444 default from GCC 3.4 to 4.9) include:
6449 A template with a non-type template parameter of reference type was
6450 mangled incorrectly:
6453 template <int &> struct S @{@};
6457 This was fixed in @option{-fabi-version=3}.
6460 SIMD vector types declared using @code{__attribute ((vector_size))} were
6461 mangled in a non-standard way that does not allow for overloading of
6462 functions taking vectors of different sizes.
6464 The mangling was changed in @option{-fabi-version=4}.
6467 @code{__attribute ((const))} and @code{noreturn} were mangled as type
6468 qualifiers, and @code{decltype} of a plain declaration was folded away.
6470 These mangling issues were fixed in @option{-fabi-version=5}.
6473 Scoped enumerators passed as arguments to a variadic function are
6474 promoted like unscoped enumerators, causing @code{va_arg} to complain.
6475 On most targets this does not actually affect the parameter passing
6476 ABI, as there is no way to pass an argument smaller than @code{int}.
6478 Also, the ABI changed the mangling of template argument packs,
6479 @code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6480 a class scope function used as a template argument.
6482 These issues were corrected in @option{-fabi-version=6}.
6485 Lambdas in default argument scope were mangled incorrectly, and the
6486 ABI changed the mangling of @code{nullptr_t}.
6488 These issues were corrected in @option{-fabi-version=7}.
6491 When mangling a function type with function-cv-qualifiers, the
6492 un-qualified function type was incorrectly treated as a substitution
6495 This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6498 @code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6499 unaligned accesses. Note that this did not affect the ABI of a
6500 function with a @code{nullptr_t} parameter, as parameters have a
6503 This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6506 Target-specific attributes that affect the identity of a type, such as
6507 ia32 calling conventions on a function type (stdcall, regparm, etc.),
6508 did not affect the mangled name, leading to name collisions when
6509 function pointers were used as template arguments.
6511 This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6515 This option also enables warnings about psABI-related changes.
6516 The known psABI changes at this point include:
6521 For SysV/x86-64, unions with @code{long double} members are
6522 passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6523 the case. For example:
6533 @code{union U} is now always passed in memory.
6537 @item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6538 C++ requires that unqualified uses of a name within a class have the
6539 same meaning in the complete scope of the class, so declaring the name
6540 after using it is ill-formed:
6543 struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6544 struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6546 By default, the B1 case is only a warning because the two declarations
6547 have the same type, while the B2 case is an error. Both diagnostics
6548 can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6549 error case can be reduced to a warning with
6550 @option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6552 Both diagnostics are also suppressed by @option{-fms-extensions}.
6554 @opindex Wchar-subscripts
6555 @opindex Wno-char-subscripts
6556 @item -Wchar-subscripts
6557 Warn if an array subscript has type @code{char}. This is a common cause
6558 of error, as programmers often forget that this type is signed on some
6560 This warning is enabled by @option{-Wall}.
6562 @opindex Wno-coverage-mismatch
6563 @opindex Wcoverage-mismatch
6564 @item -Wno-coverage-mismatch
6565 Warn if feedback profiles do not match when using the
6566 @option{-fprofile-use} option.
6567 If a source file is changed between compiling with @option{-fprofile-generate}
6568 and with @option{-fprofile-use}, the files with the profile feedback can fail
6569 to match the source file and GCC cannot use the profile feedback
6570 information. By default, this warning is enabled and is treated as an
6571 error. @option{-Wno-coverage-mismatch} can be used to disable the
6572 warning or @option{-Wno-error=coverage-mismatch} can be used to
6573 disable the error. Disabling the error for this warning can result in
6574 poorly optimized code and is useful only in the
6575 case of very minor changes such as bug fixes to an existing code-base.
6576 Completely disabling the warning is not recommended.
6578 @opindex Wno-coverage-invalid-line-number
6579 @opindex Wcoverage-invalid-line-number
6580 @item -Wno-coverage-invalid-line-number
6581 Warn in case a function ends earlier than it begins due
6582 to an invalid linenum macros. The warning is emitted only
6583 with @option{--coverage} enabled.
6585 By default, this warning is enabled and is treated as an
6586 error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6587 warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6592 @item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
6593 Suppress warning messages emitted by @code{#warning} directives.
6595 @opindex Wdouble-promotion
6596 @opindex Wno-double-promotion
6597 @item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
6598 Give a warning when a value of type @code{float} is implicitly
6599 promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6600 floating-point unit implement @code{float} in hardware, but emulate
6601 @code{double} in software. On such a machine, doing computations
6602 using @code{double} values is much more expensive because of the
6603 overhead required for software emulation.
6605 It is easy to accidentally do computations with @code{double} because
6606 floating-point literals are implicitly of type @code{double}. For
6610 float area(float radius)
6612 return 3.14159 * radius * radius;
6616 the compiler performs the entire computation with @code{double}
6617 because the floating-point literal is a @code{double}.
6619 @opindex Wduplicate-decl-specifier
6620 @opindex Wno-duplicate-decl-specifier
6621 @item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
6622 Warn if a declaration has duplicate @code{const}, @code{volatile},
6623 @code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6628 @opindex ffreestanding
6629 @opindex fno-builtin
6632 @itemx -Wformat=@var{n}
6633 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6634 the arguments supplied have types appropriate to the format string
6635 specified, and that the conversions specified in the format string make
6636 sense. This includes standard functions, and others specified by format
6637 attributes (@pxref{Function Attributes}), in the @code{printf},
6638 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6639 not in the C standard) families (or other target-specific families).
6640 Which functions are checked without format attributes having been
6641 specified depends on the standard version selected, and such checks of
6642 functions without the attribute specified are disabled by
6643 @option{-ffreestanding} or @option{-fno-builtin}.
6645 The formats are checked against the format features supported by GNU
6646 libc version 2.2. These include all ISO C90 and C99 features, as well
6647 as features from the Single Unix Specification and some BSD and GNU
6648 extensions. Other library implementations may not support all these
6649 features; GCC does not support warning about features that go beyond a
6650 particular library's limitations. However, if @option{-Wpedantic} is used
6651 with @option{-Wformat}, warnings are given about format features not
6652 in the selected standard version (but not for @code{strfmon} formats,
6653 since those are not in any version of the C standard). @xref{C Dialect
6654 Options,,Options Controlling C Dialect}.
6661 Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6662 @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6663 @option{-Wformat} also checks for null format arguments for several
6664 functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6665 aspects of this level of format checking can be disabled by the
6666 options: @option{-Wno-format-contains-nul},
6667 @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6668 @option{-Wformat} is enabled by @option{-Wall}.
6672 Enable @option{-Wformat} plus additional format checks. Currently
6673 equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6677 @opindex Wno-format-contains-nul
6678 @opindex Wformat-contains-nul
6679 @item -Wno-format-contains-nul
6680 If @option{-Wformat} is specified, do not warn about format strings that
6683 @opindex Wno-format-extra-args
6684 @opindex Wformat-extra-args
6685 @item -Wno-format-extra-args
6686 If @option{-Wformat} is specified, do not warn about excess arguments to a
6687 @code{printf} or @code{scanf} format function. The C standard specifies
6688 that such arguments are ignored.
6690 Where the unused arguments lie between used arguments that are
6691 specified with @samp{$} operand number specifications, normally
6692 warnings are still given, since the implementation could not know what
6693 type to pass to @code{va_arg} to skip the unused arguments. However,
6694 in the case of @code{scanf} formats, this option suppresses the
6695 warning if the unused arguments are all pointers, since the Single
6696 Unix Specification says that such unused arguments are allowed.
6698 @opindex Wformat-overflow
6699 @opindex Wno-format-overflow
6700 @item -Wformat-overflow
6701 @itemx -Wformat-overflow=@var{level}
6702 Warn about calls to formatted input/output functions such as @code{sprintf}
6703 and @code{vsprintf} that might overflow the destination buffer. When the
6704 exact number of bytes written by a format directive cannot be determined
6705 at compile-time it is estimated based on heuristics that depend on the
6706 @var{level} argument and on optimization. While enabling optimization
6707 will in most cases improve the accuracy of the warning, it may also
6708 result in false positives.
6711 @opindex Wformat-overflow
6712 @opindex Wno-format-overflow
6713 @item -Wformat-overflow
6714 @itemx -Wformat-overflow=1
6715 Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6716 employs a conservative approach that warns only about calls that most
6717 likely overflow the buffer. At this level, numeric arguments to format
6718 directives with unknown values are assumed to have the value of one, and
6719 strings of unknown length to be empty. Numeric arguments that are known
6720 to be bounded to a subrange of their type, or string arguments whose output
6721 is bounded either by their directive's precision or by a finite set of
6722 string literals, are assumed to take on the value within the range that
6723 results in the most bytes on output. For example, the call to @code{sprintf}
6724 below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6725 the terminating NUL character (@code{'\0'}) appended by the function
6726 to the destination buffer will be written past its end. Increasing
6727 the size of the buffer by a single byte is sufficient to avoid the
6728 warning, though it may not be sufficient to avoid the overflow.
6731 void f (int a, int b)
6734 sprintf (buf, "a = %i, b = %i\n", a, b);
6738 @item -Wformat-overflow=2
6739 Level @var{2} warns also about calls that might overflow the destination
6740 buffer given an argument of sufficient length or magnitude. At level
6741 @var{2}, unknown numeric arguments are assumed to have the minimum
6742 representable value for signed types with a precision greater than 1, and
6743 the maximum representable value otherwise. Unknown string arguments whose
6744 length cannot be assumed to be bounded either by the directive's precision,
6745 or by a finite set of string literals they may evaluate to, or the character
6746 array they may point to, are assumed to be 1 character long.
6748 At level @var{2}, the call in the example above is again diagnosed, but
6749 this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6750 @code{%i} directive will write some of its digits beyond the end of
6751 the destination buffer. To make the call safe regardless of the values
6752 of the two variables, the size of the destination buffer must be increased
6753 to at least 34 bytes. GCC includes the minimum size of the buffer in
6754 an informational note following the warning.
6756 An alternative to increasing the size of the destination buffer is to
6757 constrain the range of formatted values. The maximum length of string
6758 arguments can be bounded by specifying the precision in the format
6759 directive. When numeric arguments of format directives can be assumed
6760 to be bounded by less than the precision of their type, choosing
6761 an appropriate length modifier to the format specifier will reduce
6762 the required buffer size. For example, if @var{a} and @var{b} in the
6763 example above can be assumed to be within the precision of
6764 the @code{short int} type then using either the @code{%hi} format
6765 directive or casting the argument to @code{short} reduces the maximum
6766 required size of the buffer to 24 bytes.
6769 void f (int a, int b)
6772 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6777 @opindex Wno-format-zero-length
6778 @opindex Wformat-zero-length
6779 @item -Wno-format-zero-length
6780 If @option{-Wformat} is specified, do not warn about zero-length formats.
6781 The C standard specifies that zero-length formats are allowed.
6783 @opindex Wformat-nonliteral
6784 @opindex Wno-format-nonliteral
6785 @item -Wformat-nonliteral
6786 If @option{-Wformat} is specified, also warn if the format string is not a
6787 string literal and so cannot be checked, unless the format function
6788 takes its format arguments as a @code{va_list}.
6790 @opindex Wformat-security
6791 @opindex Wno-format-security
6792 @item -Wformat-security
6793 If @option{-Wformat} is specified, also warn about uses of format
6794 functions that represent possible security problems. At present, this
6795 warns about calls to @code{printf} and @code{scanf} functions where the
6796 format string is not a string literal and there are no format arguments,
6797 as in @code{printf (foo);}. This may be a security hole if the format
6798 string came from untrusted input and contains @samp{%n}. (This is
6799 currently a subset of what @option{-Wformat-nonliteral} warns about, but
6800 in future warnings may be added to @option{-Wformat-security} that are not
6801 included in @option{-Wformat-nonliteral}.)
6803 @opindex Wformat-signedness
6804 @opindex Wno-format-signedness
6805 @item -Wformat-signedness
6806 If @option{-Wformat} is specified, also warn if the format string
6807 requires an unsigned argument and the argument is signed and vice versa.
6809 @opindex Wformat-truncation
6810 @opindex Wno-format-truncation
6811 @item -Wformat-truncation
6812 @itemx -Wformat-truncation=@var{level}
6813 Warn about calls to formatted input/output functions such as @code{snprintf}
6814 and @code{vsnprintf} that might result in output truncation. When the exact
6815 number of bytes written by a format directive cannot be determined at
6816 compile-time it is estimated based on heuristics that depend on
6817 the @var{level} argument and on optimization. While enabling optimization
6818 will in most cases improve the accuracy of the warning, it may also result
6819 in false positives. Except as noted otherwise, the option uses the same
6820 logic @option{-Wformat-overflow}.
6823 @opindex Wformat-truncation
6824 @opindex Wno-format-truncation
6825 @item -Wformat-truncation
6826 @itemx -Wformat-truncation=1
6827 Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6828 employs a conservative approach that warns only about calls to bounded
6829 functions whose return value is unused and that will most likely result
6830 in output truncation.
6832 @item -Wformat-truncation=2
6833 Level @var{2} warns also about calls to bounded functions whose return
6834 value is used and that might result in truncation given an argument of
6835 sufficient length or magnitude.
6838 @opindex Wformat-y2k
6839 @opindex Wno-format-y2k
6841 If @option{-Wformat} is specified, also warn about @code{strftime}
6842 formats that may yield only a two-digit year.
6845 @opindex Wno-nonnull
6847 Warn about passing a null pointer for arguments marked as
6848 requiring a non-null value by the @code{nonnull} function attribute.
6850 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6851 can be disabled with the @option{-Wno-nonnull} option.
6853 @opindex Wnonnull-compare
6854 @opindex Wno-nonnull-compare
6855 @item -Wnonnull-compare
6856 Warn when comparing an argument marked with the @code{nonnull}
6857 function attribute against null inside the function.
6859 @option{-Wnonnull-compare} is included in @option{-Wall}. It
6860 can be disabled with the @option{-Wno-nonnull-compare} option.
6862 @opindex Wnull-dereference
6863 @opindex Wno-null-dereference
6864 @item -Wnull-dereference
6865 Warn if the compiler detects paths that trigger erroneous or
6866 undefined behavior due to dereferencing a null pointer. This option
6867 is only active when @option{-fdelete-null-pointer-checks} is active,
6868 which is enabled by optimizations in most targets. The precision of
6869 the warnings depends on the optimization options used.
6873 @item -Wnrvo @r{(C++ and Objective-C++ only)}
6874 Warn if the compiler does not elide the copy from a local variable to
6875 the return value of a function in a context where it is allowed by
6876 [class.copy.elision]. This elision is commonly known as the Named
6877 Return Value Optimization. For instance, in the example below the
6878 compiler cannot elide copies from both v1 and v2, so it elides neither.
6881 std::vector<int> f()
6883 std::vector<int> v1, v2;
6885 if (cond) return v1;
6886 else return v2; // warning: not eliding copy
6890 @opindex Winfinite-recursion
6891 @opindex Wno-infinite-recursion
6892 @item -Winfinite-recursion
6893 Warn about infinitely recursive calls. The warning is effective at all
6894 optimization levels but requires optimization in order to detect infinite
6895 recursion in calls between two or more functions.
6896 @option{-Winfinite-recursion} is included in @option{-Wall}.
6898 Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6899 similar diagnostic, but is implemented in a different way (as part of
6900 @option{-fanalyzer}).
6903 @opindex Wno-init-self
6904 @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
6905 Warn about uninitialized variables that are initialized with themselves.
6906 Note this option can only be used with the @option{-Wuninitialized} option.
6908 For example, GCC warns about @code{i} being uninitialized in the
6909 following snippet only when @option{-Winit-self} has been specified:
6920 This warning is enabled by @option{-Wall} in C++.
6922 @opindex Wimplicit-int
6923 @opindex Wno-implicit-int
6924 @item -Wno-implicit-int @r{(C and Objective-C only)}
6925 This option controls warnings when a declaration does not specify a type.
6926 This warning is enabled by default, as an error, in C99 and later
6927 dialects of C, and also by @option{-Wall}. The error can be downgraded
6928 to a warning using @option{-fpermissive} (along with certain other
6929 errors), or for this error alone, with @option{-Wno-error=implicit-int}.
6931 This warning is upgraded to an error by @option{-pedantic-errors}.
6933 @opindex Wimplicit-function-declaration
6934 @opindex Wno-implicit-function-declaration
6935 @item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
6936 This option controls warnings when a function is used before being declared.
6937 This warning is enabled by default, as an error, in C99 and later
6938 dialects of C, and also by @option{-Wall}. The error can be downgraded
6939 to a warning using @option{-fpermissive} (along with certain other
6940 errors), or for this error alone, with
6941 @option{-Wno-error=implicit-function-declaration}.
6943 This warning is upgraded to an error by @option{-pedantic-errors}.
6946 @opindex Wno-implicit
6947 @item -Wimplicit @r{(C and Objective-C only)}
6948 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6949 This warning is enabled by @option{-Wall}.
6952 @opindex Wno-hardened
6954 Warn when @option{-fhardened} did not enable an option from its set (for
6955 which see @option{-fhardened}). For instance, using @option{-fhardened}
6956 and @option{-fstack-protector} at the same time on the command line causes
6957 @option{-Whardened} to warn because @option{-fstack-protector-strong} is
6958 not enabled by @option{-fhardened}.
6960 This warning is enabled by default and has effect only when @option{-fhardened}
6963 @opindex Wimplicit-fallthrough
6964 @opindex Wno-implicit-fallthrough
6965 @item -Wimplicit-fallthrough
6966 @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6967 and @option{-Wno-implicit-fallthrough} is the same as
6968 @option{-Wimplicit-fallthrough=0}.
6970 @opindex Wimplicit-fallthrough=
6971 @item -Wimplicit-fallthrough=@var{n}
6972 Warn when a switch case falls through. For example:
6990 This warning does not warn when the last statement of a case cannot
6991 fall through, e.g. when there is a return statement or a call to function
6992 declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6993 also takes into account control flow statements, such as ifs, and only
6994 warns when appropriate. E.g.@:
7004 @} else if (i < 1) @{
7014 Since there are occasions where a switch case fall through is desirable,
7015 GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
7016 to be used along with a null statement to suppress this warning that
7017 would normally occur:
7025 __attribute__ ((fallthrough));
7032 C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
7033 warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
7034 or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
7035 Instead of these attributes, it is also possible to add a fallthrough comment
7036 to silence the warning. The whole body of the C or C++ style comment should
7037 match the given regular expressions listed below. The option argument @var{n}
7038 specifies what kind of comments are accepted:
7042 @item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
7044 @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
7045 expression, any comment is used as fallthrough comment.
7047 @item @option{-Wimplicit-fallthrough=2} case insensitively matches
7048 @code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
7050 @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
7051 following regular expressions:
7055 @item @code{-fallthrough}
7057 @item @code{@@fallthrough@@}
7059 @item @code{lint -fallthrough[ \t]*}
7061 @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
7063 @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
7065 @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
7069 @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
7070 following regular expressions:
7074 @item @code{-fallthrough}
7076 @item @code{@@fallthrough@@}
7078 @item @code{lint -fallthrough[ \t]*}
7080 @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
7084 @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
7085 fallthrough comments, only attributes disable the warning.
7089 The comment needs to be followed after optional whitespace and other comments
7090 by @code{case} or @code{default} keywords or by a user label that precedes some
7091 @code{case} or @code{default} label.
7106 The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
7108 @opindex Wif-not-aligned
7109 @opindex Wno-if-not-aligned
7110 @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
7111 Control if warnings triggered by the @code{warn_if_not_aligned} attribute
7112 should be issued. These warnings are enabled by default.
7114 @opindex Wignored-qualifiers
7115 @opindex Wno-ignored-qualifiers
7116 @item -Wignored-qualifiers @r{(C and C++ only)}
7117 Warn if the return type of a function has a type qualifier
7118 such as @code{const}. For ISO C such a type qualifier has no effect,
7119 since the value returned by a function is not an lvalue.
7120 For C++, the warning is only emitted for scalar types or @code{void}.
7121 ISO C prohibits qualified @code{void} return types on function
7122 definitions, so such return types always receive a warning
7123 even without this option.
7125 This warning is also enabled by @option{-Wextra}.
7127 @opindex Wignored-attributes
7128 @opindex Wno-ignored-attributes
7129 @item -Wno-ignored-attributes @r{(C and C++ only)}
7130 This option controls warnings when an attribute is ignored.
7131 This is different from the
7132 @option{-Wattributes} option in that it warns whenever the compiler decides
7133 to drop an attribute, not that the attribute is either unknown, used in a
7134 wrong place, etc. This warning is enabled by default.
7139 Warn if the type of @code{main} is suspicious. @code{main} should be
7140 a function with external linkage, returning int, taking either zero
7141 arguments, two, or three arguments of appropriate types. This warning
7142 is enabled by default in C++ and is enabled by either @option{-Wall}
7143 or @option{-Wpedantic}.
7145 This warning is upgraded to an error by @option{-pedantic-errors}.
7147 @opindex Wmisleading-indentation
7148 @opindex Wno-misleading-indentation
7149 @item -Wmisleading-indentation @r{(C and C++ only)}
7150 Warn when the indentation of the code does not reflect the block structure.
7151 Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
7152 @code{for} clauses with a guarded statement that does not use braces,
7153 followed by an unguarded statement with the same indentation.
7155 In the following example, the call to ``bar'' is misleadingly indented as
7156 if it were guarded by the ``if'' conditional.
7159 if (some_condition ())
7161 bar (); /* Gotcha: this is not guarded by the "if". */
7164 In the case of mixed tabs and spaces, the warning uses the
7165 @option{-ftabstop=} option to determine if the statements line up
7168 The warning is not issued for code involving multiline preprocessor logic
7169 such as the following example.
7174 #if SOME_CONDITION_THAT_DOES_NOT_HOLD
7180 The warning is not issued after a @code{#line} directive, since this
7181 typically indicates autogenerated code, and no assumptions can be made
7182 about the layout of the file that the directive references.
7184 This warning is enabled by @option{-Wall} in C and C++.
7186 @opindex Wmissing-attributes
7187 @opindex Wno-missing-attributes
7188 @item -Wmissing-attributes
7189 Warn when a declaration of a function is missing one or more attributes
7190 that a related function is declared with and whose absence may adversely
7191 affect the correctness or efficiency of generated code. For example,
7192 the warning is issued for declarations of aliases that use attributes
7193 to specify less restrictive requirements than those of their targets.
7194 This typically represents a potential optimization opportunity.
7195 By contrast, the @option{-Wattribute-alias=2} option controls warnings
7196 issued when the alias is more restrictive than the target, which could
7197 lead to incorrect code generation.
7198 Attributes considered include @code{alloc_align}, @code{alloc_size},
7199 @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
7200 @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
7201 @code{returns_nonnull}, and @code{returns_twice}.
7203 In C++, the warning is issued when an explicit specialization of a primary
7204 template declared with attribute @code{alloc_align}, @code{alloc_size},
7205 @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
7206 or @code{nonnull} is declared without it. Attributes @code{deprecated},
7207 @code{error}, and @code{warning} suppress the warning.
7208 (@pxref{Function Attributes}).
7210 You can use the @code{copy} attribute to apply the same
7211 set of attributes to a declaration as that on another declaration without
7212 explicitly enumerating the attributes. This attribute can be applied
7213 to declarations of functions (@pxref{Common Function Attributes}),
7214 variables (@pxref{Common Variable Attributes}), or types
7215 (@pxref{Common Type Attributes}).
7217 @option{-Wmissing-attributes} is enabled by @option{-Wall}.
7219 For example, since the declaration of the primary function template
7220 below makes use of both attribute @code{malloc} and @code{alloc_size}
7221 the declaration of the explicit specialization of the template is
7222 diagnosed because it is missing one of the attributes.
7226 T* __attribute__ ((malloc, alloc_size (1)))
7230 void* __attribute__ ((malloc)) // missing alloc_size
7231 allocate<void> (size_t);
7234 @opindex Wmissing-braces
7235 @opindex Wno-missing-braces
7236 @item -Wmissing-braces
7237 Warn if an aggregate or union initializer is not fully bracketed. In
7238 the following example, the initializer for @code{a} is not fully
7239 bracketed, but that for @code{b} is fully bracketed.
7242 int a[2][2] = @{ 0, 1, 2, 3 @};
7243 int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
7246 This warning is enabled by @option{-Wall}.
7248 @opindex Wmissing-include-dirs
7249 @opindex Wno-missing-include-dirs
7250 @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
7251 Warn if a user-supplied include directory does not exist. This option is disabled
7252 by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
7253 enabled by default by warning for -I and -J, only.
7255 @opindex Wmissing-profile
7256 @opindex Wno-missing-profile
7257 @item -Wno-missing-profile
7258 This option controls warnings if feedback profiles are missing when using the
7259 @option{-fprofile-use} option.
7260 This option diagnoses those cases where a new function or a new file is added
7261 between compiling with @option{-fprofile-generate} and with
7262 @option{-fprofile-use}, without regenerating the profiles.
7263 In these cases, the profile feedback data files do not contain any
7264 profile feedback information for
7265 the newly added function or file respectively. Also, in the case when profile
7266 count data (.gcda) files are removed, GCC cannot use any profile feedback
7267 information. In all these cases, warnings are issued to inform you that a
7268 profile generation step is due.
7269 Ignoring the warning can result in poorly optimized code.
7270 @option{-Wno-missing-profile} can be used to
7271 disable the warning, but this is not recommended and should be done only
7272 when non-existent profile data is justified.
7274 @opindex Wmismatched-dealloc
7275 @opindex Wno-mismatched-dealloc
7276 @item -Wmismatched-dealloc
7278 Warn for calls to deallocation functions with pointer arguments returned
7279 from allocation functions for which the former isn't a suitable
7280 deallocator. A pair of functions can be associated as matching allocators
7281 and deallocators by use of attribute @code{malloc}. Unless disabled by
7282 the @option{-fno-builtin} option the standard functions @code{calloc},
7283 @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7284 forms of C++ @code{operator new} and @code{operator delete} are implicitly
7285 associated as matching allocators and deallocators. In the following
7286 example @code{mydealloc} is the deallocator for pointers returned from
7290 void mydealloc (void*);
7292 __attribute__ ((malloc (mydealloc, 1))) void*
7297 void *p = myalloc (32);
7298 // @dots{}use p@dots{}
7299 free (p); // warning: not a matching deallocator for myalloc
7300 mydealloc (p); // ok
7304 In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7305 mismatches involving either @code{operator new} or @code{operator delete}.
7307 Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7309 @opindex Wmultistatement-macros
7310 @opindex Wno-multistatement-macros
7311 @item -Wmultistatement-macros
7312 Warn about unsafe multiple statement macros that appear to be guarded
7313 by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7314 @code{while}, in which only the first statement is actually guarded after
7315 the macro is expanded.
7320 #define DOIT x++; y++
7325 will increment @code{y} unconditionally, not just when @code{c} holds.
7326 The can usually be fixed by wrapping the macro in a do-while loop:
7328 #define DOIT do @{ x++; y++; @} while (0)
7333 This warning is enabled by @option{-Wall} in C and C++.
7335 @opindex Wparentheses
7336 @opindex Wno-parentheses
7338 Warn if parentheses are omitted in certain contexts, such
7339 as when there is an assignment in a context where a truth value
7340 is expected, or when operators are nested whose precedence people
7341 often get confused about.
7343 Also warn if a comparison like @code{x<=y<=z} appears; this is
7344 equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7345 interpretation from that of ordinary mathematical notation.
7347 Also warn for dangerous uses of the GNU extension to
7348 @code{?:} with omitted middle operand. When the condition
7349 in the @code{?}: operator is a boolean expression, the omitted value is
7350 always 1. Often programmers expect it to be a value computed
7351 inside the conditional expression instead.
7353 For C++ this also warns for some cases of unnecessary parentheses in
7354 declarations, which can indicate an attempt at a function call instead
7358 // Declares a local variable called mymutex.
7359 std::unique_lock<std::mutex> (mymutex);
7360 // User meant std::unique_lock<std::mutex> lock (mymutex);
7364 This warning is enabled by @option{-Wall}.
7367 @opindex Wno-self-move
7368 @item -Wno-self-move @r{(C++ and Objective-C++ only)}
7369 This warning warns when a value is moved to itself with @code{std::move}.
7370 Such a @code{std::move} typically has no effect.
7384 This warning is enabled by @option{-Wall}.
7386 @opindex Wsequence-point
7387 @opindex Wno-sequence-point
7388 @item -Wsequence-point
7389 Warn about code that may have undefined semantics because of violations
7390 of sequence point rules in the C and C++ standards.
7392 The C and C++ standards define the order in which expressions in a C/C++
7393 program are evaluated in terms of @dfn{sequence points}, which represent
7394 a partial ordering between the execution of parts of the program: those
7395 executed before the sequence point, and those executed after it. These
7396 occur after the evaluation of a full expression (one which is not part
7397 of a larger expression), after the evaluation of the first operand of a
7398 @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7399 function is called (but after the evaluation of its arguments and the
7400 expression denoting the called function), and in certain other places.
7401 Other than as expressed by the sequence point rules, the order of
7402 evaluation of subexpressions of an expression is not specified. All
7403 these rules describe only a partial order rather than a total order,
7404 since, for example, if two functions are called within one expression
7405 with no sequence point between them, the order in which the functions
7406 are called is not specified. However, the standards committee have
7407 ruled that function calls do not overlap.
7409 It is not specified when between sequence points modifications to the
7410 values of objects take effect. Programs whose behavior depends on this
7411 have undefined behavior; the C and C++ standards specify that ``Between
7412 the previous and next sequence point an object shall have its stored
7413 value modified at most once by the evaluation of an expression.
7414 Furthermore, the prior value shall be read only to determine the value
7415 to be stored.''. If a program breaks these rules, the results on any
7416 particular implementation are entirely unpredictable.
7418 Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7419 = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7420 diagnosed by this option, and it may give an occasional false positive
7421 result, but in general it has been found fairly effective at detecting
7422 this sort of problem in programs.
7424 The C++17 standard will define the order of evaluation of operands in
7425 more cases: in particular it requires that the right-hand side of an
7426 assignment be evaluated before the left-hand side, so the above
7427 examples are no longer undefined. But this option will still warn
7428 about them, to help people avoid writing code that is undefined in C
7429 and earlier revisions of C++.
7431 The standard is worded confusingly, therefore there is some debate
7432 over the precise meaning of the sequence point rules in subtle cases.
7433 Links to discussions of the problem, including proposed formal
7434 definitions, may be found on the GCC readings page, at
7435 @uref{https://gcc.gnu.org/@/readings.html}.
7437 This warning is enabled by @option{-Wall} for C and C++.
7439 @opindex Wno-return-local-addr
7440 @opindex Wreturn-local-addr
7441 @item -Wno-return-local-addr
7442 Do not warn about returning a pointer (or in C++, a reference) to a
7443 variable that goes out of scope after the function returns.
7445 @opindex Wreturn-mismatch
7446 @opindex Wno-return-mismatch
7447 @item -Wreturn-mismatch
7448 Warn about return statements without an expressions in functions which
7449 do not return @code{void}. Also warn about a @code{return} statement
7450 with an expression in a function whose return type is @code{void},
7451 unless the expression type is also @code{void}. As a GNU extension, the
7452 latter case is accepted without a warning unless @option{-Wpedantic} is
7455 Attempting to use the return value of a non-@code{void} function other
7456 than @code{main} that flows off the end by reaching the closing curly
7457 brace that terminates the function is undefined.
7459 This warning is specific to C and enabled by default. In C99 and later
7460 language dialects, it is treated as an error. It can be downgraded
7461 to a warning using @option{-fpermissive} (along with other warnings),
7462 or for just this warning, with @option{-Wno-error=return-mismatch}.
7464 @opindex Wreturn-type
7465 @opindex Wno-return-type
7467 Warn whenever a function is defined with a return type that defaults to
7468 @code{int} (unless @option{-Wimplicit-int} is active, which takes
7469 precedence). Also warn if execution may reach the end of the function
7470 body, or if the function does not contain any return statement at all.
7472 Attempting to use the return value of a non-@code{void} function other
7473 than @code{main} that flows off the end by reaching the closing curly
7474 brace that terminates the function is undefined.
7476 Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7477 than @code{main} results in undefined behavior even when the value of
7478 the function is not used.
7480 This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7482 @opindex Wshift-count-negative
7483 @opindex Wno-shift-count-negative
7484 @item -Wno-shift-count-negative
7485 Controls warnings if a shift count is negative.
7486 This warning is enabled by default.
7488 @opindex Wshift-count-overflow
7489 @opindex Wno-shift-count-overflow
7490 @item -Wno-shift-count-overflow
7491 Controls warnings if a shift count is greater than or equal to the bit width
7492 of the type. This warning is enabled by default.
7494 @opindex Wshift-negative-value
7495 @opindex Wno-shift-negative-value
7496 @item -Wshift-negative-value
7497 Warn if left shifting a negative value. This warning is enabled by
7498 @option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7500 @opindex Wshift-overflow
7501 @opindex Wno-shift-overflow
7502 @item -Wno-shift-overflow
7503 @itemx -Wshift-overflow=@var{n}
7504 These options control warnings about left shift overflows.
7507 @item -Wshift-overflow=1
7508 This is the warning level of @option{-Wshift-overflow} and is enabled
7509 by default in C99 and C++11 modes (and newer). This warning level does
7510 not warn about left-shifting 1 into the sign bit. (However, in C, such
7511 an overflow is still rejected in contexts where an integer constant expression
7512 is required.) No warning is emitted in C++20 mode (and newer), as signed left
7515 @item -Wshift-overflow=2
7516 This warning level also warns about left-shifting 1 into the sign bit,
7517 unless C++14 mode (or newer) is active.
7523 Warn whenever a @code{switch} statement has an index of enumerated type
7524 and lacks a @code{case} for one or more of the named codes of that
7525 enumeration. (The presence of a @code{default} label prevents this
7526 warning.) @code{case} labels outside the enumeration range also
7527 provoke warnings when this option is used (even if there is a
7528 @code{default} label).
7529 This warning is enabled by @option{-Wall}.
7531 @opindex Wswitch-default
7532 @opindex Wno-switch-default
7533 @item -Wswitch-default
7534 Warn whenever a @code{switch} statement does not have a @code{default}
7537 @opindex Wswitch-enum
7538 @opindex Wno-switch-enum
7540 Warn whenever a @code{switch} statement has an index of enumerated type
7541 and lacks a @code{case} for one or more of the named codes of that
7542 enumeration. @code{case} labels outside the enumeration range also
7543 provoke warnings when this option is used. The only difference
7544 between @option{-Wswitch} and this option is that this option gives a
7545 warning about an omitted enumeration code even if there is a
7546 @code{default} label.
7548 @opindex Wswitch-bool
7549 @opindex Wno-switch-bool
7550 @item -Wno-switch-bool
7551 Do not warn when a @code{switch} statement has an index of boolean type
7552 and the case values are outside the range of a boolean type.
7553 It is possible to suppress this warning by casting the controlling
7554 expression to a type other than @code{bool}. For example:
7557 switch ((int) (a == 4))
7563 This warning is enabled by default for C and C++ programs.
7565 @opindex Wswitch-outside-range
7566 @opindex Wno-switch-outside-range
7567 @item -Wno-switch-outside-range
7568 This option controls warnings when a @code{switch} case has a value
7569 that is outside of its
7570 respective type range. This warning is enabled by default for
7573 @opindex Wswitch-unreachable
7574 @opindex Wno-switch-unreachable
7575 @item -Wno-switch-unreachable
7576 Do not warn when a @code{switch} statement contains statements between the
7577 controlling expression and the first case label, which will never be
7578 executed. For example:
7590 @option{-Wswitch-unreachable} does not warn if the statement between the
7591 controlling expression and the first case label is just a declaration:
7604 This warning is enabled by default for C and C++ programs.
7607 @opindex Wno-sync-nand
7608 @item -Wsync-nand @r{(C and C++ only)}
7609 Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7610 built-in functions are used. These functions changed semantics in GCC 4.4.
7612 @opindex Wtrivial-auto-var-init
7613 @opindex Wno-trivial-auto-var-init
7614 @item -Wtrivial-auto-var-init
7615 Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7616 variable. A common situation is an automatic variable that is declared
7617 between the controlling expression and the first case label of a @code{switch}
7620 @opindex Wunused-but-set-parameter
7621 @opindex Wno-unused-but-set-parameter
7622 @item -Wunused-but-set-parameter
7623 Warn whenever a function parameter is assigned to, but otherwise unused
7624 (aside from its declaration).
7626 To suppress this warning use the @code{unused} attribute
7627 (@pxref{Variable Attributes}).
7629 This warning is also enabled by @option{-Wunused} together with
7632 @opindex Wunused-but-set-variable
7633 @opindex Wno-unused-but-set-variable
7634 @item -Wunused-but-set-variable
7635 Warn whenever a local variable is assigned to, but otherwise unused
7636 (aside from its declaration).
7637 This warning is enabled by @option{-Wall}.
7639 To suppress this warning use the @code{unused} attribute
7640 (@pxref{Variable Attributes}).
7642 This warning is also enabled by @option{-Wunused}, which is enabled
7645 @opindex Wunused-function
7646 @opindex Wno-unused-function
7647 @item -Wunused-function
7648 Warn whenever a static function is declared but not defined or a
7649 non-inline static function is unused.
7650 This warning is enabled by @option{-Wall}.
7652 @opindex Wunused-label
7653 @opindex Wno-unused-label
7654 @item -Wunused-label
7655 Warn whenever a label is declared but not used.
7656 This warning is enabled by @option{-Wall}.
7658 To suppress this warning use the @code{unused} attribute
7659 (@pxref{Variable Attributes}).
7661 @opindex Wunused-local-typedefs
7662 @opindex Wno-unused-local-typedefs
7663 @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
7664 Warn when a typedef locally defined in a function is not used.
7665 This warning is enabled by @option{-Wall}.
7667 @opindex Wunused-parameter
7668 @opindex Wno-unused-parameter
7669 @item -Wunused-parameter
7670 Warn whenever a function parameter is unused aside from its declaration.
7671 This option is not enabled by @code{-Wunused} unless @code{-Wextra} is also
7674 To suppress this warning use the @code{unused} attribute
7675 (@pxref{Variable Attributes}).
7677 @opindex Wunused-result
7678 @opindex Wno-unused-result
7679 @item -Wno-unused-result
7680 Do not warn if a caller of a function marked with attribute
7681 @code{warn_unused_result} (@pxref{Function Attributes}) does not use
7682 its return value. The default is @option{-Wunused-result}.
7684 @opindex Wunused-variable
7685 @opindex Wno-unused-variable
7686 @item -Wunused-variable
7687 Warn whenever a local or static variable is unused aside from its
7688 declaration. This option implies @option{-Wunused-const-variable=1} for C,
7689 but not for C++. This warning is enabled by @option{-Wall}.
7691 To suppress this warning use the @code{unused} attribute
7692 (@pxref{Variable Attributes}).
7694 @opindex Wunused-const-variable
7695 @opindex Wno-unused-const-variable
7696 @item -Wunused-const-variable
7697 @itemx -Wunused-const-variable=@var{n}
7698 Warn whenever a constant static variable is unused aside from its declaration.
7700 To suppress this warning use the @code{unused} attribute
7701 (@pxref{Variable Attributes}).
7704 @item -Wunused-const-variable=1
7705 Warn about unused static const variables defined in the main
7706 compilation unit, but not about static const variables declared in any
7709 @option{-Wunused-const-variable=1} is enabled by either
7710 @option{-Wunused-variable} or @option{-Wunused} for C, but not for
7711 C++. In C this declares variable storage, but in C++ this is not an
7712 error since const variables take the place of @code{#define}s.
7714 @item -Wunused-const-variable=2
7715 This warning level also warns for unused constant static variables in
7716 headers (excluding system headers). It is equivalent to the short form
7717 @option{-Wunused-const-variable}. This level must be explicitly
7718 requested in both C and C++ because it might be hard to clean up all
7722 @opindex Wunused-value
7723 @opindex Wno-unused-value
7724 @item -Wunused-value
7725 Warn whenever a statement computes a result that is explicitly not
7726 used. To suppress this warning cast the unused expression to
7727 @code{void}. This includes an expression-statement or the left-hand
7728 side of a comma expression that contains no side effects. For example,
7729 an expression such as @code{x[i,j]} causes a warning, while
7730 @code{x[(void)i,j]} does not.
7732 This warning is enabled by @option{-Wall}.
7737 All the above @option{-Wunused} options combined, except those documented
7738 as needing to be specified explicitly.
7740 In order to get a warning about an unused function parameter, you must
7741 either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7742 @option{-Wunused}), or separately specify @option{-Wunused-parameter} and/or
7743 @option{-Wunused-but-set-parameter}.
7745 @option{-Wunused} enables only @option{-Wunused-const-variable=1} rather than
7746 @option{-Wunused-const-variable}, and only for C, not C++.
7748 @opindex Wuse-after-free
7749 @opindex Wno-use-after-free
7750 @item -Wuse-after-free @r{(C, Objective-C, C++ and Objective-C++ only)}
7751 @itemx -Wuse-after-free=@var{n}
7752 Warn about uses of pointers to dynamically allocated objects that have
7753 been rendered indeterminate by a call to a deallocation function.
7754 The warning is enabled at all optimization levels but may yield different
7755 results with optimization than without.
7758 @item -Wuse-after-free=1
7759 At level 1 the warning attempts to diagnose only unconditional uses
7760 of pointers made indeterminate by a deallocation call or a successful
7761 call to @code{realloc}, regardless of whether or not the call resulted
7762 in an actual reallocation of memory. This includes double-@code{free}
7763 calls as well as uses in arithmetic and relational expressions. Although
7764 undefined, uses of indeterminate pointers in equality (or inequality)
7765 expressions are not diagnosed at this level.
7766 @item -Wuse-after-free=2
7767 At level 2, in addition to unconditional uses, the warning also diagnoses
7768 conditional uses of pointers made indeterminate by a deallocation call.
7769 As at level 2, uses in equality (or inequality) expressions are not
7770 diagnosed. For example, the second call to @code{free} in the following
7771 function is diagnosed at this level:
7773 struct A @{ int refcount; void *data; @};
7775 void release (struct A *p)
7777 int refcount = --p->refcount;
7780 free (p->data); // warning: p may be used after free
7783 @item -Wuse-after-free=3
7784 At level 3, the warning also diagnoses uses of indeterminate pointers in
7785 equality expressions. All uses of indeterminate pointers are undefined
7786 but equality tests sometimes appear after calls to @code{realloc} as
7787 an attempt to determine whether the call resulted in relocating the object
7788 to a different address. They are diagnosed at a separate level to aid
7789 gradually transitioning legacy code to safe alternatives. For example,
7790 the equality test in the function below is diagnosed at this level:
7792 void adjust_pointers (int**, int);
7794 void grow (int **p, int n)
7796 int **q = (int**)realloc (p, n *= 2);
7799 adjust_pointers ((int**)q, n);
7802 To avoid the warning at this level, store offsets into allocated memory
7803 instead of pointers. This approach obviates needing to adjust the stored
7804 pointers after reallocation.
7807 @option{-Wuse-after-free=2} is included in @option{-Wall}.
7809 @opindex Wuseless-cast
7810 @opindex Wno-useless-cast
7811 @item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)}
7812 Warn when an expression is cast to its own type. This warning does not
7813 occur when a class object is converted to a non-reference type as that
7814 is a way to create a temporary:
7821 g (S(arg)); // make arg prvalue so that it can bind to S&&
7825 @opindex Wuninitialized
7826 @opindex Wno-uninitialized
7827 @item -Wuninitialized
7828 Warn if an object with automatic or allocated storage duration is used
7829 without having been initialized. In C++, also warn if a non-static
7830 reference or non-static @code{const} member appears in a class without
7833 In addition, passing a pointer (or in C++, a reference) to an uninitialized
7834 object to a @code{const}-qualified argument of a built-in function known to
7835 read the object is also diagnosed by this warning.
7836 (@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7838 If you want to warn about code that uses the uninitialized value of the
7839 variable in its own initializer, use the @option{-Winit-self} option.
7841 These warnings occur for individual uninitialized elements of
7842 structure, union or array variables as well as for variables that are
7843 uninitialized as a whole. They do not occur for variables or elements
7844 declared @code{volatile}. Because these warnings depend on
7845 optimization, the exact variables or elements for which there are
7846 warnings depend on the precise optimization options and version of GCC
7849 Note that there may be no warning about a variable that is used only
7850 to compute a value that itself is never used, because such
7851 computations may be deleted by data flow analysis before the warnings
7854 In C++, this warning also warns about using uninitialized objects in
7855 member-initializer-lists. For example, GCC warns about @code{b} being
7856 uninitialized in the following snippet:
7866 @opindex Winvalid-memory-model
7867 @opindex Wno-invalid-memory-model
7868 @item -Wno-invalid-memory-model
7869 This option controls warnings
7870 for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7871 and the C11 atomic generic functions with a memory consistency argument
7872 that is either invalid for the operation or outside the range of values
7873 of the @code{memory_order} enumeration. For example, since the
7874 @code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7875 defined for the relaxed, release, and sequentially consistent memory
7876 orders the following code is diagnosed:
7881 __atomic_store_n (i, 0, memory_order_consume);
7885 @option{-Winvalid-memory-model} is enabled by default.
7887 @opindex Wmaybe-uninitialized
7888 @opindex Wno-maybe-uninitialized
7889 @item -Wmaybe-uninitialized
7890 For an object with automatic or allocated storage duration, if there exists
7891 a path from the function entry to a use of the object that is initialized,
7892 but there exist some other paths for which the object is not initialized,
7893 the compiler emits a warning if it cannot prove the uninitialized paths
7894 are not executed at run time.
7896 In addition, passing a pointer (or in C++, a reference) to an uninitialized
7897 object to a @code{const}-qualified function argument is also diagnosed by
7898 this warning. (@option{-Wuninitialized} is issued for built-in functions
7899 known to read the object.) Annotating the function with attribute
7900 @code{access (none)} indicates that the argument isn't used to access
7901 the object and avoids the warning (@pxref{Common Function Attributes}).
7903 These warnings are only possible in optimizing compilation, because otherwise
7904 GCC does not keep track of the state of variables.
7906 These warnings are made optional because GCC may not be able to determine when
7907 the code is correct in spite of appearing to have an error. Here is one
7908 example of how this can happen:
7928 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7929 always initialized, but GCC doesn't know this. To suppress the
7930 warning, you need to provide a default case with assert(0) or
7933 @cindex @code{longjmp} warnings
7934 This option also warns when a non-volatile automatic variable might be
7935 changed by a call to @code{longjmp}.
7936 The compiler sees only the calls to @code{setjmp}. It cannot know
7937 where @code{longjmp} will be called; in fact, a signal handler could
7938 call it at any point in the code. As a result, you may get a warning
7939 even when there is in fact no problem because @code{longjmp} cannot
7940 in fact be called at the place that would cause a problem.
7942 Some spurious warnings can be avoided if you declare all the functions
7943 you use that never return as @code{noreturn}. @xref{Function
7946 This warning is enabled by @option{-Wall} or @option{-Wextra}.
7948 @opindex Wunknown-pragmas
7949 @opindex Wno-unknown-pragmas
7950 @cindex warning for unknown pragmas
7951 @cindex unknown pragmas, warning
7952 @cindex pragmas, warning of unknown
7953 @item -Wunknown-pragmas
7954 Warn when a @code{#pragma} directive is encountered that is not understood by
7955 GCC@. If this command-line option is used, warnings are even issued
7956 for unknown pragmas in system header files. This is not the case if
7957 the warnings are only enabled by the @option{-Wall} command-line option.
7959 @opindex Wno-pragmas
7962 Do not warn about misuses of pragmas, such as incorrect parameters,
7963 invalid syntax, or conflicts between pragmas. See also
7964 @option{-Wunknown-pragmas}.
7966 @opindex Wno-prio-ctor-dtor
7967 @opindex Wprio-ctor-dtor
7968 @item -Wno-prio-ctor-dtor
7969 Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7970 The use of constructor and destructor attributes allow you to assign a
7971 priority to the constructor/destructor to control its order of execution
7972 before @code{main} is called or after it returns. The priority values must be
7973 greater than 100 as the compiler reserves priority values between 0--100 for
7976 @opindex Wstrict-aliasing
7977 @opindex Wno-strict-aliasing
7978 @item -Wstrict-aliasing
7979 This option is only active when @option{-fstrict-aliasing} is active.
7980 It warns about code that might break the strict aliasing rules that the
7981 compiler is using for optimization. The warning does not catch all
7982 cases, but does attempt to catch the more common pitfalls. It is
7983 included in @option{-Wall}.
7984 It is equivalent to @option{-Wstrict-aliasing=3}
7986 @opindex Wstrict-aliasing=n
7987 @item -Wstrict-aliasing=n
7988 This option is only active when @option{-fstrict-aliasing} is active.
7989 It warns about code that might break the strict aliasing rules that the
7990 compiler is using for optimization.
7991 Higher levels correspond to higher accuracy (fewer false positives).
7992 Higher levels also correspond to more effort, similar to the way @option{-O}
7994 @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7996 Level 1: Most aggressive, quick, least accurate.
7997 Possibly useful when higher levels
7998 do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7999 false negatives. However, it has many false positives.
8000 Warns for all pointer conversions between possibly incompatible types,
8001 even if never dereferenced. Runs in the front end only.
8003 Level 2: Aggressive, quick, not too precise.
8004 May still have many false positives (not as many as level 1 though),
8005 and few false negatives (but possibly more than level 1).
8006 Unlike level 1, it only warns when an address is taken. Warns about
8007 incomplete types. Runs in the front end only.
8009 Level 3 (default for @option{-Wstrict-aliasing}):
8010 Should have very few false positives and few false
8011 negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
8012 Takes care of the common pun+dereference pattern in the front end:
8013 @code{*(int*)&some_float}.
8014 If optimization is enabled, it also runs in the back end, where it deals
8015 with multiple statement cases using flow-sensitive points-to information.
8016 Only warns when the converted pointer is dereferenced.
8017 Does not warn about incomplete types.
8019 @opindex Wstrict-overflow
8020 @opindex Wno-strict-overflow
8021 @item -Wstrict-overflow
8022 @itemx -Wstrict-overflow=@var{n}
8023 This option is only active when signed overflow is undefined.
8024 It warns about cases where the compiler optimizes based on the
8025 assumption that signed overflow does not occur. Note that it does not
8026 warn about all cases where the code might overflow: it only warns
8027 about cases where the compiler implements some optimization. Thus
8028 this warning depends on the optimization level.
8030 An optimization that assumes that signed overflow does not occur is
8031 perfectly safe if the values of the variables involved are such that
8032 overflow never does, in fact, occur. Therefore this warning can
8033 easily give a false positive: a warning about code that is not
8034 actually a problem. To help focus on important issues, several
8035 warning levels are defined. No warnings are issued for the use of
8036 undefined signed overflow when estimating how many iterations a loop
8037 requires, in particular when determining whether a loop will be
8041 @item -Wstrict-overflow=1
8042 Warn about cases that are both questionable and easy to avoid. For
8043 example the compiler simplifies
8044 @code{x + 1 > x} to @code{1}. This level of
8045 @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
8046 are not, and must be explicitly requested.
8048 @item -Wstrict-overflow=2
8049 Also warn about other cases where a comparison is simplified to a
8050 constant. For example: @code{abs (x) >= 0}. This can only be
8051 simplified when signed integer overflow is undefined, because
8052 @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
8053 zero. @option{-Wstrict-overflow} (with no level) is the same as
8054 @option{-Wstrict-overflow=2}.
8056 @item -Wstrict-overflow=3
8057 Also warn about other cases where a comparison is simplified. For
8058 example: @code{x + 1 > 1} is simplified to @code{x > 0}.
8060 @item -Wstrict-overflow=4
8061 Also warn about other simplifications not covered by the above cases.
8062 For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
8064 @item -Wstrict-overflow=5
8065 Also warn about cases where the compiler reduces the magnitude of a
8066 constant involved in a comparison. For example: @code{x + 2 > y} is
8067 simplified to @code{x + 1 >= y}. This is reported only at the
8068 highest warning level because this simplification applies to many
8069 comparisons, so this warning level gives a very large number of
8073 @opindex Wstring-compare
8074 @opindex Wno-string-compare
8075 @item -Wstring-compare
8076 Warn for calls to @code{strcmp} and @code{strncmp} whose result is
8077 determined to be either zero or non-zero in tests for such equality
8078 owing to the length of one argument being greater than the size of
8079 the array the other argument is stored in (or the bound in the case
8080 of @code{strncmp}). Such calls could be mistakes. For example,
8081 the call to @code{strcmp} below is diagnosed because its result is
8082 necessarily non-zero irrespective of the contents of the array @code{a}.
8088 strcpy (d, "string");
8090 if (0 == strcmp (a, d)) // cannot be true
8091 puts ("a and d are the same");
8095 @option{-Wstring-compare} is enabled by @option{-Wextra}.
8097 @opindex Wstringop-overflow
8098 @opindex Wno-stringop-overflow
8099 @item -Wno-stringop-overflow
8100 @item -Wstringop-overflow
8101 @itemx -Wstringop-overflow=@var{type}
8102 Warn for calls to string manipulation functions such as @code{memcpy} and
8103 @code{strcpy} that are determined to overflow the destination buffer. The
8104 optional argument is one greater than the type of Object Size Checking to
8105 perform to determine the size of the destination. @xref{Object Size Checking}.
8106 The argument is meaningful only for functions that operate on character arrays
8107 but not for raw memory functions like @code{memcpy} which always make use
8108 of Object Size type-0. The option also warns for calls that specify a size
8109 in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
8110 The option produces the best results with optimization enabled but can detect
8111 a small subset of simple buffer overflows even without optimization in
8112 calls to the GCC built-in functions like @code{__builtin_memcpy} that
8113 correspond to the standard functions. In any case, the option warns about
8114 just a subset of buffer overflows detected by the corresponding overflow
8115 checking built-ins. For example, the option issues a warning for
8116 the @code{strcpy} call below because it copies at least 5 characters
8117 (the string @code{"blue"} including the terminating NUL) into the buffer
8121 enum Color @{ blue, purple, yellow @};
8122 const char* f (enum Color clr)
8124 static char buf [4];
8128 case blue: str = "blue"; break;
8129 case purple: str = "purple"; break;
8130 case yellow: str = "yellow"; break;
8133 return strcpy (buf, str); // warning here
8137 Option @option{-Wstringop-overflow=2} is enabled by default.
8140 @opindex Wstringop-overflow
8141 @opindex Wno-stringop-overflow
8142 @item -Wstringop-overflow
8143 @itemx -Wstringop-overflow=1
8144 The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
8145 to determine the sizes of destination objects. At this setting the option
8146 does not warn for writes past the end of subobjects of larger objects accessed
8147 by pointers unless the size of the largest surrounding object is known. When
8148 the destination may be one of several objects it is assumed to be the largest
8149 one of them. On Linux systems, when optimization is enabled at this setting
8150 the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
8151 is defined to a non-zero value.
8153 @item -Wstringop-overflow=2
8154 The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
8155 to determine the sizes of destination objects. At this setting the option
8156 warns about overflows when writing to members of the largest complete
8157 objects whose exact size is known. However, it does not warn for excessive
8158 writes to the same members of unknown objects referenced by pointers since
8159 they may point to arrays containing unknown numbers of elements. This is
8160 the default setting of the option.
8162 @item -Wstringop-overflow=3
8163 The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
8164 to determine the sizes of destination objects. At this setting the option
8165 warns about overflowing the smallest object or data member. This is the
8166 most restrictive setting of the option that may result in warnings for safe
8169 @item -Wstringop-overflow=4
8170 The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
8171 to determine the sizes of destination objects. At this setting the option
8172 warns about overflowing any data members, and when the destination is
8173 one of several objects it uses the size of the largest of them to decide
8174 whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
8175 setting of the option may result in warnings for benign code.
8178 @opindex Wstringop-overread
8179 @opindex Wno-stringop-overread
8180 @item -Wno-stringop-overread
8181 Warn for calls to string manipulation functions such as @code{memchr}, or
8182 @code{strcpy} that are determined to read past the end of the source
8185 Option @option{-Wstringop-overread} is enabled by default.
8187 @opindex Wstringop-truncation
8188 @opindex Wno-stringop-truncation
8189 @item -Wno-stringop-truncation
8190 Do not warn for calls to bounded string manipulation functions
8191 such as @code{strncat},
8192 @code{strncpy}, and @code{stpncpy} that may either truncate the copied string
8193 or leave the destination unchanged.
8195 In the following example, the call to @code{strncat} specifies a bound that
8196 is less than the length of the source string. As a result, the copy of
8197 the source will be truncated and so the call is diagnosed. To avoid the
8198 warning use @code{bufsize - strlen (buf) - 1)} as the bound.
8201 void append (char *buf, size_t bufsize)
8203 strncat (buf, ".txt", 3);
8207 As another example, the following call to @code{strncpy} results in copying
8208 to @code{d} just the characters preceding the terminating NUL, without
8209 appending the NUL to the end. Assuming the result of @code{strncpy} is
8210 necessarily a NUL-terminated string is a common mistake, and so the call
8211 is diagnosed. To avoid the warning when the result is not expected to be
8212 NUL-terminated, call @code{memcpy} instead.
8215 void copy (char *d, const char *s)
8217 strncpy (d, s, strlen (s));
8221 In the following example, the call to @code{strncpy} specifies the size
8222 of the destination buffer as the bound. If the length of the source
8223 string is equal to or greater than this size the result of the copy will
8224 not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
8225 the warning, specify @code{sizeof buf - 1} as the bound and set the last
8226 element of the buffer to @code{NUL}.
8229 void copy (const char *s)
8232 strncpy (buf, s, sizeof buf);
8237 In situations where a character array is intended to store a sequence
8238 of bytes with no terminating @code{NUL} such an array may be annotated
8239 with attribute @code{nonstring} to avoid this warning. Such arrays,
8240 however, are not suitable arguments to functions that expect
8241 @code{NUL}-terminated strings. To help detect accidental misuses of
8242 such arrays GCC issues warnings unless it can prove that the use is
8243 safe. @xref{Common Variable Attributes}.
8245 @opindex Wstrict-flex-arrays
8246 @opindex Wno-strict-flex-arrays
8247 @item -Wstrict-flex-arrays @r{(C and C++ only)}
8248 Warn about improper usages of flexible array members
8249 according to the @var{level} of the @code{strict_flex_array (@var{level})}
8250 attribute attached to the trailing array field of a structure if it's
8251 available, otherwise according to the @var{level} of the option
8252 @option{-fstrict-flex-arrays=@var{level}}. @xref{Common Variable Attributes},
8253 for more information about the attribute, and @ref{C Dialect Options} for
8254 more information about the option. @code{-Wstrict-flex-arrays}
8255 is effective only when @var{level} is greater than 0.
8257 When @var{level}=1, warnings are issued for a trailing array reference
8258 of a structure that have 2 or more elements if the trailing array is referenced
8259 as a flexible array member.
8261 When @var{level}=2, in addition to @var{level}=1, additional warnings are
8262 issued for a trailing one-element array reference of a structure
8263 if the array is referenced as a flexible array member.
8265 When @var{level}=3, in addition to @var{level}=2, additional warnings are
8266 issued for a trailing zero-length array reference of a structure
8267 if the array is referenced as a flexible array member.
8269 This option is more effective when @option{-ftree-vrp} is active (the
8270 default for @option{-O2} and above) but some warnings may be diagnosed
8271 even without optimization.
8273 @opindex Wsuggest-attribute=
8274 @opindex Wno-suggest-attribute=
8275 @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}returns_nonnull@r{|}
8276 Warn for cases where adding an attribute may be beneficial. The
8277 attributes currently supported are listed below.
8280 @opindex Wsuggest-attribute=pure
8281 @opindex Wno-suggest-attribute=pure
8282 @opindex Wsuggest-attribute=const
8283 @opindex Wno-suggest-attribute=const
8284 @opindex Wsuggest-attribute=noreturn
8285 @opindex Wno-suggest-attribute=noreturn
8286 @opindex Wmissing-noreturn
8287 @opindex Wno-missing-noreturn
8288 @opindex Wsuggest-attribute=malloc
8289 @opindex Wno-suggest-attribute=malloc
8290 @item -Wsuggest-attribute=pure
8291 @itemx -Wsuggest-attribute=const
8292 @itemx -Wsuggest-attribute=noreturn
8293 @itemx -Wmissing-noreturn
8294 @itemx -Wsuggest-attribute=malloc
8295 @itemx -Wsuggest-attribute=returns_nonnull
8296 @itemx -Wno-suggest-attribute=returns_nonnull
8298 Warn about functions that might be candidates for attributes
8299 @code{pure}, @code{const}, @code{noreturn}, @code{malloc} or @code{returns_nonnull}. The compiler
8300 only warns for functions visible in other compilation units or (in the case of
8301 @code{pure} and @code{const}) if it cannot prove that the function returns
8302 normally. A function returns normally if it doesn't contain an infinite loop or
8303 return abnormally by throwing, calling @code{abort} or trapping. This analysis
8304 requires option @option{-fipa-pure-const}, which is enabled by default at
8305 @option{-O} and higher. Higher optimization levels improve the accuracy
8308 @opindex Wsuggest-attribute=format
8309 @opindex Wmissing-format-attribute
8310 @opindex Wno-suggest-attribute=format
8311 @opindex Wno-missing-format-attribute
8314 @item -Wsuggest-attribute=format
8315 @itemx -Wmissing-format-attribute
8317 Warn about function pointers that might be candidates for @code{format}
8318 attributes. Note these are only possible candidates, not absolute ones.
8319 GCC guesses that function pointers with @code{format} attributes that
8320 are used in assignment, initialization, parameter passing or return
8321 statements should have a corresponding @code{format} attribute in the
8322 resulting type. I.e.@: the left-hand side of the assignment or
8323 initialization, the type of the parameter variable, or the return type
8324 of the containing function respectively should also have a @code{format}
8325 attribute to avoid the warning.
8327 GCC also warns about function definitions that might be
8328 candidates for @code{format} attributes. Again, these are only
8329 possible candidates. GCC guesses that @code{format} attributes
8330 might be appropriate for any function that calls a function like
8331 @code{vprintf} or @code{vscanf}, but this might not always be the
8332 case, and some functions for which @code{format} attributes are
8333 appropriate may not be detected.
8335 @opindex Wsuggest-attribute=cold
8336 @opindex Wno-suggest-attribute=cold
8337 @item -Wsuggest-attribute=cold
8339 Warn about functions that might be candidates for @code{cold} attribute. This
8340 is based on static detection and generally only warns about functions which
8341 always leads to a call to another @code{cold} function such as wrappers of
8342 C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
8345 @opindex Wno-alloc-size
8346 @opindex Walloc-size
8348 Warn about calls to allocation functions decorated with attribute
8349 @code{alloc_size} that specify insufficient size for the target type of
8350 the pointer the result is assigned to, including those to the built-in
8351 forms of the functions @code{aligned_alloc}, @code{alloca},
8352 @code{calloc}, @code{malloc}, and @code{realloc}.
8354 @opindex Wno-alloc-zero
8355 @opindex Walloc-zero
8357 Warn about calls to allocation functions decorated with attribute
8358 @code{alloc_size} that specify zero bytes, including those to the built-in
8359 forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
8360 @code{malloc}, and @code{realloc}. Because the behavior of these functions
8361 when called with a zero size differs among implementations (and in the case
8362 of @code{realloc} has been deprecated) relying on it may result in subtle
8363 portability bugs and should be avoided.
8365 @opindex Wcalloc-transposed-args
8366 @opindex Wno-calloc-transposed-args
8367 @item -Wcalloc-transposed-args
8368 Warn about calls to allocation functions decorated with attribute
8369 @code{alloc_size} with two arguments, which use @code{sizeof} operator
8370 as the earlier size argument and don't use it as the later size argument.
8371 This is a coding style warning. The first argument to @code{calloc} is
8372 documented to be number of elements in array, while the second argument
8373 is size of each element, so @code{calloc (@var{n}, sizeof (int))} is preferred
8374 over @code{calloc (sizeof (int), @var{n})}. If @code{sizeof} in the earlier
8375 argument and not the latter is intentional, the warning can be suppressed
8376 by using @code{calloc (sizeof (struct @var{S}) + 0, n)} or
8377 @code{calloc (1 * sizeof (struct @var{S}), 4)} or using @code{sizeof} in the
8378 later argument as well.
8380 @opindex Walloc-size-larger-than=
8381 @opindex Wno-alloc-size-larger-than
8382 @item -Walloc-size-larger-than=@var{byte-size}
8383 Warn about calls to functions decorated with attribute @code{alloc_size}
8384 that attempt to allocate objects larger than the specified number of bytes,
8385 or where the result of the size computation in an integer type with infinite
8386 precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
8387 @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8388 Warnings controlled by the option can be disabled either by specifying
8389 @var{byte-size} of @samp{SIZE_MAX} or more or by
8390 @option{-Wno-alloc-size-larger-than}.
8391 @xref{Function Attributes}.
8393 @opindex Wno-alloc-size-larger-than
8394 @item -Wno-alloc-size-larger-than
8395 Disable @option{-Walloc-size-larger-than=} warnings. The option is
8396 equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
8402 This option warns on all uses of @code{alloca} in the source.
8404 @opindex Walloca-larger-than=
8405 @opindex Wno-alloca-larger-than
8406 @item -Walloca-larger-than=@var{byte-size}
8407 This option warns on calls to @code{alloca} with an integer argument whose
8408 value is either zero, or that is not bounded by a controlling predicate
8409 that limits its value to at most @var{byte-size}. It also warns for calls
8410 to @code{alloca} where the bound value is unknown. Arguments of non-integer
8411 types are considered unbounded even if they appear to be constrained to
8414 For example, a bounded case of @code{alloca} could be:
8417 void func (size_t n)
8428 In the above example, passing @code{-Walloca-larger-than=1000} would not
8429 issue a warning because the call to @code{alloca} is known to be at most
8430 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8431 the compiler would emit a warning.
8433 Unbounded uses, on the other hand, are uses of @code{alloca} with no
8434 controlling predicate constraining its integer argument. For example:
8439 void *p = alloca (n);
8444 If @code{-Walloca-larger-than=500} were passed, the above would trigger
8445 a warning, but this time because of the lack of bounds checking.
8447 Note, that even seemingly correct code involving signed integers could
8451 void func (signed int n)
8461 In the above example, @var{n} could be negative, causing a larger than
8462 expected argument to be implicitly cast into the @code{alloca} call.
8464 This option also warns when @code{alloca} is used in a loop.
8466 @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8467 but is usually only effective when @option{-ftree-vrp} is active (default
8468 for @option{-O2} and above).
8470 See also @option{-Wvla-larger-than=}@samp{byte-size}.
8472 @opindex Wno-alloca-larger-than
8473 @item -Wno-alloca-larger-than
8474 Disable @option{-Walloca-larger-than=} warnings. The option is
8475 equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8477 @opindex Warith-conversion
8478 @opindex Wno-arith-conversion
8479 @item -Warith-conversion
8480 Do warn about implicit conversions from arithmetic operations even
8481 when conversion of the operands to the same type cannot change their
8482 values. This affects warnings from @option{-Wconversion},
8483 @option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8487 void f (char c, int i)
8489 c = c + i; // warns with @option{-Wconversion}
8490 c = c + 1; // only warns with @option{-Warith-conversion}
8495 @opindex Wno-array-bounds
8496 @opindex Warray-bounds
8497 @item -Warray-bounds
8498 @itemx -Warray-bounds=@var{n}
8499 Warn about out of bounds subscripts or offsets into arrays. This warning
8500 is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8501 is active (the default for @option{-O2} and above) but a subset of instances
8502 are issued even without optimization.
8504 By default, the trailing array of a structure will be treated as a flexible
8505 array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8506 if it is declared as either a flexible array member per C99 standard onwards
8507 (@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8508 array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8509 zero-length arrays or one-element arrays are not warned by default.
8511 You can add the option @option{-fstrict-flex-arrays} or
8512 @option{-fstrict-flex-arrays=@var{level}} to control how this
8513 option treat trailing array of a structure as a flexible array member:
8515 when @var{level}<=1, no change to the default behavior.
8517 when @var{level}=2, additional warnings will be issued for out of bounds
8518 subscripts or offsets into one-element arrays;
8520 when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8521 issued for out of bounds subscripts or offsets into zero-length arrays.
8524 @item -Warray-bounds=1
8525 This is the default warning level of @option{-Warray-bounds} and is enabled
8526 by @option{-Wall}; higher levels are not, and must be explicitly requested.
8528 @item -Warray-bounds=2
8529 This warning level also warns about the intermediate results of pointer
8530 arithmetic that may yield out of bounds values. This warning level may
8531 give a larger number of false positives and is deactivated by default.
8534 @opindex Warray-compare
8535 @opindex Wno-array-compare
8536 @item -Warray-compare
8537 Warn about equality and relational comparisons between two operands of array
8538 type. This comparison was deprecated in C++20. For example:
8543 bool same = arr1 == arr2;
8546 @option{-Warray-compare} is enabled by @option{-Wall}.
8548 @opindex Wno-array-parameter
8549 @opindex Warray-parameter
8550 @item -Warray-parameter
8551 @itemx -Warray-parameter=@var{n}
8552 Warn about redeclarations of functions involving parameters of array or
8553 pointer types of inconsistent kinds or forms, and enable the detection
8554 of out-of-bounds accesses to such parameters by warnings such as
8555 @option{-Warray-bounds}.
8557 If the first function declaration uses the array form for a parameter
8558 declaration, the bound specified
8559 in the array is assumed to be the minimum number of elements expected to
8560 be provided in calls to the function and the maximum number of elements
8561 accessed by it. Failing to provide arguments of sufficient size or accessing
8562 more than the maximum number of elements may be diagnosed by warnings such
8563 as @option{-Warray-bounds} or @option{-Wstringop-overflow}.
8564 At level 1, the warning diagnoses inconsistencies
8565 involving array parameters declared using the @code{T[static N]} form.
8567 For example, the warning triggers for the second declaration of @code{f}
8568 because the first one with the keyword @code{static} specifies that
8569 the array argument must have at least four elements, while the second
8570 allows an array of any size to be passed to @code{f}.
8573 void f (int[static 4]);
8574 void f (int[]); // warning (inconsistent array form)
8578 int *p = (int *)malloc (1 * sizeof (int));
8579 f (p); // warning (array too small)
8584 At level 2 the warning also triggers for redeclarations involving any other
8585 inconsistency in array or pointer argument forms denoting array sizes.
8586 Pointers and arrays of unspecified bound are considered equivalent and do
8587 not trigger a warning.
8591 void g (int[]); // no warning
8592 void g (int[8]); // warning (inconsistent array bound)
8595 @option{-Warray-parameter=2} is included in @option{-Wall}. The
8596 @option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8597 involving Variable Length Array arguments.
8599 The short form of the option @option{-Warray-parameter} is equivalent to
8600 @option{-Warray-parameter=2}. The negative form @option{-Wno-array-parameter}
8601 is equivalent to @option{-Warray-parameter=0}.
8603 @opindex Wattribute-alias
8604 @opindex Wno-attribute-alias
8605 @item -Wattribute-alias=@var{n}
8606 @itemx -Wno-attribute-alias
8607 Warn about declarations using the @code{alias} and similar attributes whose
8608 target is incompatible with the type of the alias.
8609 @xref{Function Attributes,,Declaring Attributes of Functions}.
8612 @item -Wattribute-alias=1
8613 The default warning level of the @option{-Wattribute-alias} option diagnoses
8614 incompatibilities between the type of the alias declaration and that of its
8615 target. Such incompatibilities are typically indicative of bugs.
8617 @item -Wattribute-alias=2
8619 At this level @option{-Wattribute-alias} also diagnoses cases where
8620 the attributes of the alias declaration are more restrictive than the
8621 attributes applied to its target. These mismatches can potentially
8622 result in incorrect code generation. In other cases they may be
8623 benign and could be resolved simply by adding the missing attribute to
8624 the target. For comparison, see the @option{-Wmissing-attributes}
8625 option, which controls diagnostics when the alias declaration is less
8626 restrictive than the target, rather than more restrictive.
8628 Attributes considered include @code{alloc_align}, @code{alloc_size},
8629 @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8630 @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8631 @code{returns_nonnull}, and @code{returns_twice}.
8634 @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8635 This is the default. You can disable these warnings with either
8636 @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8638 @opindex Wbidi-chars=
8639 @opindex Wbidi-chars
8640 @opindex Wno-bidi-chars
8641 @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
8642 Warn about possibly misleading UTF-8 bidirectional control characters in
8643 comments, string literals, character constants, and identifiers. Such
8644 characters can change left-to-right writing direction into right-to-left
8645 (and vice versa), which can cause confusion between the logical order and
8646 visual order. This may be dangerous; for instance, it may seem that a piece
8647 of code is not commented out, whereas it in fact is.
8649 There are three levels of warning supported by GCC@. The default is
8650 @option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8651 bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8652 @option{-Wbidi-chars=any} warns about any use of bidirectional control
8655 By default, this warning does not warn about UCNs. It is, however, possible
8656 to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8657 @option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8658 and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8659 @option{-Wbidi-chars=any} was specified.
8661 @opindex Wno-bool-compare
8662 @opindex Wbool-compare
8663 @item -Wbool-compare
8664 Warn about boolean expression compared with an integer value different from
8665 @code{true}/@code{false}. For instance, the following comparison is
8670 if ((n > 1) == 2) @{ @dots{} @}
8672 This warning is enabled by @option{-Wall}.
8674 @opindex Wno-bool-operation
8675 @opindex Wbool-operation
8676 @item -Wbool-operation
8677 Warn about suspicious operations on expressions of a boolean type. For
8678 instance, bitwise negation of a boolean is very likely a bug in the program.
8679 For C, this warning also warns about incrementing or decrementing a boolean,
8680 which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8681 Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8683 This warning is enabled by @option{-Wall}.
8685 @opindex Wno-duplicated-branches
8686 @opindex Wduplicated-branches
8687 @item -Wduplicated-branches
8688 Warn when an if-else has identical branches. This warning detects cases like
8695 It doesn't warn when both branches contain just a null statement. This warning
8696 also warn for conditional operators:
8698 int i = x ? *p : *p;
8701 @opindex Wno-duplicated-cond
8702 @opindex Wduplicated-cond
8703 @item -Wduplicated-cond
8704 Warn about duplicated conditions in an if-else-if chain. For instance,
8705 warn for the following code:
8707 if (p->q != NULL) @{ @dots{} @}
8708 else if (p->q != NULL) @{ @dots{} @}
8711 @opindex Wno-frame-address
8712 @opindex Wframe-address
8713 @item -Wframe-address
8714 Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8715 is called with an argument greater than 0. Such calls may return indeterminate
8716 values or crash the program. The warning is included in @option{-Wall}.
8718 @opindex Wno-discarded-qualifiers
8719 @opindex Wdiscarded-qualifiers
8720 @item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
8721 Do not warn if type qualifiers on pointers are being discarded.
8722 Typically, the compiler warns if a @code{const char *} variable is
8723 passed to a function that takes a @code{char *} parameter. This option
8724 can be used to suppress such a warning.
8726 @opindex Wno-discarded-array-qualifiers
8727 @opindex Wdiscarded-array-qualifiers
8728 @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
8729 Do not warn if type qualifiers on arrays which are pointer targets
8730 are being discarded. Typically, the compiler warns if a
8731 @code{const int (*)[]} variable is passed to a function that
8732 takes a @code{int (*)[]} parameter. This option can be used to
8733 suppress such a warning.
8735 @opindex Wno-incompatible-pointer-types
8736 @opindex Wincompatible-pointer-types
8737 @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
8738 Do not warn when there is a conversion between pointers that have incompatible
8739 types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8740 which warns for pointer argument passing or assignment with different
8743 By default, in C99 and later dialects of C, GCC treats this issue as an
8744 error. The error can be downgraded to a warning using
8745 @option{-fpermissive} (along with certain other errors), or for this
8746 error alone, with @option{-Wno-error=incompatible-pointer-types}.
8748 This warning is upgraded to an error by @option{-pedantic-errors}.
8750 @opindex Wno-int-conversion
8751 @opindex Wint-conversion
8752 @item -Wno-int-conversion @r{(C and Objective-C only)}
8753 Do not warn about incompatible integer to pointer and pointer to integer
8754 conversions. This warning is about implicit conversions; for explicit
8755 conversions the warnings @option{-Wno-int-to-pointer-cast} and
8756 @option{-Wno-pointer-to-int-cast} may be used.
8758 By default, in C99 and later dialects of C, GCC treats this issue as an
8759 error. The error can be downgraded to a warning using
8760 @option{-fpermissive} (along with certain other errors), or for this
8761 error alone, with @option{-Wno-error=int-conversion}.
8763 This warning is upgraded to an error by @option{-pedantic-errors}.
8765 @opindex Wzero-length-bounds
8766 @opindex Wzero-length-bounds
8767 @item -Wzero-length-bounds
8768 Warn about accesses to elements of zero-length array members that might
8769 overlap other members of the same object. Declaring interior zero-length
8770 arrays is discouraged because accesses to them are undefined.
8773 For example, the first two stores in function @code{bad} are diagnosed
8774 because the array elements overlap the subsequent members @code{b} and
8775 @code{c}. The third store is diagnosed by @option{-Warray-bounds}
8776 because it is beyond the bounds of the enclosing object.
8779 struct X @{ int a[0]; int b, c; @};
8784 x.a[0] = 0; // -Wzero-length-bounds
8785 x.a[1] = 1; // -Wzero-length-bounds
8786 x.a[2] = 2; // -Warray-bounds
8790 Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8792 @opindex Wno-div-by-zero
8793 @opindex Wdiv-by-zero
8794 @item -Wno-div-by-zero
8795 Do not warn about compile-time integer division by zero. Floating-point
8796 division by zero is not warned about, as it can be a legitimate way of
8797 obtaining infinities and NaNs.
8799 @opindex Wsystem-headers
8800 @opindex Wno-system-headers
8801 @cindex warnings from system headers
8802 @cindex system headers, warnings from
8803 @item -Wsystem-headers
8804 Print warning messages for constructs found in system header files.
8805 Warnings from system headers are normally suppressed, on the assumption
8806 that they usually do not indicate real problems and would only make the
8807 compiler output harder to read. Using this command-line option tells
8808 GCC to emit warnings from system headers as if they occurred in user
8809 code. However, note that using @option{-Wall} in conjunction with this
8810 option does @emph{not} warn about unknown pragmas in system
8811 headers---for that, @option{-Wunknown-pragmas} must also be used.
8813 @opindex Wtautological-compare
8814 @opindex Wno-tautological-compare
8815 @item -Wtautological-compare
8816 Warn if a self-comparison always evaluates to true or false. This
8817 warning detects various mistakes such as:
8821 if (i > i) @{ @dots{} @}
8824 This warning also warns about bitwise comparisons that always evaluate
8825 to true or false, for instance:
8827 if ((a & 16) == 10) @{ @dots{} @}
8829 will always be false.
8831 This warning is enabled by @option{-Wall}.
8833 @opindex Wtrampolines
8834 @opindex Wno-trampolines
8836 Warn about trampolines generated for pointers to nested functions.
8837 A trampoline is a small piece of data or code that is created at run
8838 time on the stack when the address of a nested function is taken, and is
8839 used to call the nested function indirectly. For some targets, it is
8840 made up of data only and thus requires no special treatment. But, for
8841 most targets, it is made up of code and thus requires the stack to be
8842 made executable in order for the program to work properly.
8844 @opindex Wfloat-equal
8845 @opindex Wno-float-equal
8847 Warn if floating-point values are used in equality comparisons.
8849 The idea behind this is that sometimes it is convenient (for the
8850 programmer) to consider floating-point values as approximations to
8851 infinitely precise real numbers. If you are doing this, then you need
8852 to compute (by analyzing the code, or in some other way) the maximum or
8853 likely maximum error that the computation introduces, and allow for it
8854 when performing comparisons (and when producing output, but that's a
8855 different problem). In particular, instead of testing for equality, you
8856 should check to see whether the two values have ranges that overlap; and
8857 this is done with the relational operators, so equality comparisons are
8860 @opindex Wtraditional
8861 @opindex Wno-traditional
8862 @item -Wtraditional @r{(C and Objective-C only)}
8863 Warn about certain constructs that behave differently in traditional and
8864 ISO C@. Also warn about ISO C constructs that have no traditional C
8865 equivalent, and/or problematic constructs that should be avoided.
8869 Macro parameters that appear within string literals in the macro body.
8870 In traditional C macro replacement takes place within string literals,
8871 but in ISO C it does not.
8874 In traditional C, some preprocessor directives did not exist.
8875 Traditional preprocessors only considered a line to be a directive
8876 if the @samp{#} appeared in column 1 on the line. Therefore
8877 @option{-Wtraditional} warns about directives that traditional C
8878 understands but ignores because the @samp{#} does not appear as the
8879 first character on the line. It also suggests you hide directives like
8880 @code{#pragma} not understood by traditional C by indenting them. Some
8881 traditional implementations do not recognize @code{#elif}, so this option
8882 suggests avoiding it altogether.
8885 A function-like macro that appears without arguments.
8888 The unary plus operator.
8891 The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8892 constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8893 constants.) Note, these suffixes appear in macros defined in the system
8894 headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8895 Use of these macros in user code might normally lead to spurious
8896 warnings, however GCC's integrated preprocessor has enough context to
8897 avoid warning in these cases.
8900 A function declared external in one block and then used after the end of
8904 A @code{switch} statement has an operand of type @code{long}.
8907 A non-@code{static} function declaration follows a @code{static} one.
8908 This construct is not accepted by some traditional C compilers.
8911 The ISO type of an integer constant has a different width or
8912 signedness from its traditional type. This warning is only issued if
8913 the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8914 typically represent bit patterns, are not warned about.
8917 Usage of ISO string concatenation is detected.
8920 Initialization of automatic aggregates.
8923 Identifier conflicts with labels. Traditional C lacks a separate
8924 namespace for labels.
8927 Initialization of unions. If the initializer is zero, the warning is
8928 omitted. This is done under the assumption that the zero initializer in
8929 user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8930 initializer warnings and relies on default initialization to zero in the
8934 Conversions by prototypes between fixed/floating-point values and vice
8935 versa. The absence of these prototypes when compiling with traditional
8936 C causes serious problems. This is a subset of the possible
8937 conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8940 Use of ISO C style function definitions. This warning intentionally is
8941 @emph{not} issued for prototype declarations or variadic functions
8942 because these ISO C features appear in your code when using
8943 libiberty's traditional C compatibility macros, @code{PARAMS} and
8944 @code{VPARAMS}. This warning is also bypassed for nested functions
8945 because that feature is already a GCC extension and thus not relevant to
8946 traditional C compatibility.
8949 @opindex Wtraditional-conversion
8950 @opindex Wno-traditional-conversion
8951 @item -Wtraditional-conversion @r{(C and Objective-C only)}
8952 Warn if a prototype causes a type conversion that is different from what
8953 would happen to the same argument in the absence of a prototype. This
8954 includes conversions of fixed point to floating and vice versa, and
8955 conversions changing the width or signedness of a fixed-point argument
8956 except when the same as the default promotion.
8958 @opindex Wdeclaration-after-statement
8959 @opindex Wno-declaration-after-statement
8960 @item -Wdeclaration-after-statement @r{(C and Objective-C only)}
8961 Warn when a declaration is found after a statement in a block. This
8962 construct, known from C++, was introduced with ISO C99 and is by default
8963 allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8965 This warning is upgraded to an error by @option{-pedantic-errors}.
8970 Warn whenever a local variable or type declaration shadows another
8971 variable, parameter, type, class member (in C++), or instance variable
8972 (in Objective-C) or whenever a built-in function is shadowed. Note
8973 that in C++, the compiler warns if a local variable shadows an
8974 explicit typedef, but not if it shadows a struct/class/enum.
8975 If this warning is enabled, it includes also all instances of
8976 local shadowing. This means that @option{-Wno-shadow=local}
8977 and @option{-Wno-shadow=compatible-local} are ignored when
8978 @option{-Wshadow} is used.
8979 Same as @option{-Wshadow=global}.
8981 @opindex Wno-shadow-ivar
8982 @opindex Wshadow-ivar
8983 @item -Wno-shadow-ivar @r{(Objective-C only)}
8984 Do not warn whenever a local variable shadows an instance variable in an
8987 @opindex Wshadow=global
8988 @item -Wshadow=global
8989 Warn for any shadowing.
8990 Same as @option{-Wshadow}.
8992 @opindex Wshadow=local
8993 @item -Wshadow=local
8994 Warn when a local variable shadows another local variable or parameter.
8996 @opindex Wshadow=compatible-local
8997 @item -Wshadow=compatible-local
8998 Warn when a local variable shadows another local variable or parameter
8999 whose type is compatible with that of the shadowing variable. In C++,
9000 type compatibility here means the type of the shadowing variable can be
9001 converted to that of the shadowed variable. The creation of this flag
9002 (in addition to @option{-Wshadow=local}) is based on the idea that when
9003 a local variable shadows another one of incompatible type, it is most
9004 likely intentional, not a bug or typo, as shown in the following example:
9008 for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
9010 for (int i = 0; i < N; ++i)
9019 Since the two variable @code{i} in the example above have incompatible types,
9020 enabling only @option{-Wshadow=compatible-local} does not emit a warning.
9021 Because their types are incompatible, if a programmer accidentally uses one
9022 in place of the other, type checking is expected to catch that and emit an
9023 error or warning. Use of this flag instead of @option{-Wshadow=local} can
9024 possibly reduce the number of warnings triggered by intentional shadowing.
9025 Note that this also means that shadowing @code{const char *i} by
9026 @code{char *i} does not emit a warning.
9028 This warning is also enabled by @option{-Wshadow=local}.
9030 @opindex Wlarger-than=
9031 @opindex Wlarger-than-@var{byte-size}
9032 @item -Wlarger-than=@var{byte-size}
9033 Warn whenever an object is defined whose size exceeds @var{byte-size}.
9034 @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
9035 Warnings controlled by the option can be disabled either by specifying
9036 @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
9038 Also warn for calls to bounded functions such as @code{memchr} or
9039 @code{strnlen} that specify a bound greater than the largest possible
9040 object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
9041 can only be disabled by @option{-Wno-larger-than}.
9043 @opindex Wno-larger-than
9044 @item -Wno-larger-than
9045 Disable @option{-Wlarger-than=} warnings. The option is equivalent
9046 to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
9048 @opindex Wframe-larger-than=
9049 @opindex Wno-frame-larger-than
9050 @item -Wframe-larger-than=@var{byte-size}
9051 Warn if the size of a function frame exceeds @var{byte-size}.
9052 The computation done to determine the stack frame size is approximate
9053 and not conservative.
9054 The actual requirements may be somewhat greater than @var{byte-size}
9055 even if you do not get a warning. In addition, any space allocated
9056 via @code{alloca}, variable-length arrays, or related constructs
9057 is not included by the compiler when determining
9058 whether or not to issue a warning.
9059 @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
9060 Warnings controlled by the option can be disabled either by specifying
9061 @var{byte-size} of @samp{SIZE_MAX} or more or by
9062 @option{-Wno-frame-larger-than}.
9064 @opindex Wno-frame-larger-than
9065 @item -Wno-frame-larger-than
9066 Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
9067 to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
9069 @opindex Wfree-nonheap-object
9070 @opindex Wno-free-nonheap-object
9071 @item -Wfree-nonheap-object
9072 Warn when attempting to deallocate an object that was either not allocated
9073 on the heap, or by using a pointer that was not returned from a prior call
9074 to the corresponding allocation function. For example, because the call
9075 to @code{stpcpy} returns a pointer to the terminating nul character and
9076 not to the beginning of the object, the call to @code{free} below is
9082 p = stpcpy (p, "abc");
9084 free (p); // warning
9088 @option{-Wfree-nonheap-object} is included in @option{-Wall}.
9090 @opindex Wstack-usage
9091 @opindex Wno-stack-usage
9092 @item -Wstack-usage=@var{byte-size}
9093 Warn if the stack usage of a function might exceed @var{byte-size}.
9094 The computation done to determine the stack usage is conservative.
9095 Any space allocated via @code{alloca}, variable-length arrays, or related
9096 constructs is included by the compiler when determining whether or not to
9099 The message is in keeping with the output of @option{-fstack-usage}.
9103 If the stack usage is fully static but exceeds the specified amount, it's:
9106 warning: stack usage is 1120 bytes
9109 If the stack usage is (partly) dynamic but bounded, it's:
9112 warning: stack usage might be 1648 bytes
9115 If the stack usage is (partly) dynamic and not bounded, it's:
9118 warning: stack usage might be unbounded
9122 @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
9123 Warnings controlled by the option can be disabled either by specifying
9124 @var{byte-size} of @samp{SIZE_MAX} or more or by
9125 @option{-Wno-stack-usage}.
9127 @opindex Wno-stack-usage
9128 @item -Wno-stack-usage
9129 Disable @option{-Wstack-usage=} warnings. The option is equivalent
9130 to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
9132 @opindex Wunsafe-loop-optimizations
9133 @opindex Wno-unsafe-loop-optimizations
9134 @item -Wunsafe-loop-optimizations
9135 Warn if the loop cannot be optimized because the compiler cannot
9136 assume anything on the bounds of the loop indices. With
9137 @option{-funsafe-loop-optimizations} warn if the compiler makes
9140 @opindex Wno-pedantic-ms-format
9141 @opindex Wpedantic-ms-format
9142 @item -Wno-pedantic-ms-format @r{(MinGW targets only)}
9143 When used in combination with @option{-Wformat}
9144 and @option{-pedantic} without GNU extensions, this option
9145 disables the warnings about non-ISO @code{printf} / @code{scanf} format
9146 width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
9147 which depend on the MS runtime.
9149 @opindex Wpointer-arith
9150 @opindex Wno-pointer-arith
9151 @item -Wpointer-arith
9152 Warn about anything that depends on the ``size of'' a function type or
9153 of @code{void}. GNU C assigns these types a size of 1, for
9154 convenience in calculations with @code{void *} pointers and pointers
9155 to functions. In C++, warn also when an arithmetic operation involves
9156 @code{NULL}. This warning is also enabled by @option{-Wpedantic}.
9158 This warning is upgraded to an error by @option{-pedantic-errors}.
9160 @opindex Wpointer-compare
9161 @opindex Wno-pointer-compare
9162 @item -Wno-pointer-compare
9163 Do not warn if a pointer is compared with a zero character constant.
9165 means that the pointer was meant to be dereferenced. For example:
9168 const char *p = foo ();
9173 Note that the code above is invalid in C++11.
9175 This warning is enabled by default.
9181 Disable warnings about unsupported features in ThreadSanitizer.
9183 ThreadSanitizer does not support @code{std::atomic_thread_fence} and
9184 can report false positives.
9186 @opindex Wtype-limits
9187 @opindex Wno-type-limits
9189 Warn if a comparison is always true or always false due to the limited
9190 range of the data type, but do not warn for constant expressions. For
9191 example, warn if an unsigned variable is compared against zero with
9192 @code{<} or @code{>=}. This warning is also enabled by
9195 @opindex Wabsolute-value
9196 @opindex Wno-absolute-value
9197 @item -Wabsolute-value @r{(C and Objective-C only)}
9198 Warn for calls to standard functions that compute the absolute value
9199 of an argument when a more appropriate standard function is available.
9200 For example, calling @code{abs(3.14)} triggers the warning because the
9201 appropriate function to call to compute the absolute value of a double
9202 argument is @code{fabs}. The option also triggers warnings when the
9203 argument in a call to such a function has an unsigned type. This
9204 warning can be suppressed with an explicit type cast and it is also
9205 enabled by @option{-Wextra}.
9207 @include cppwarnopts.texi
9209 @opindex Wbad-function-cast
9210 @opindex Wno-bad-function-cast
9211 @item -Wbad-function-cast @r{(C and Objective-C only)}
9212 Warn when a function call is cast to a non-matching type.
9213 For example, warn if a call to a function returning an integer type
9214 is cast to a pointer type.
9216 @opindex Wc90-c99-compat
9217 @opindex Wno-c90-c99-compat
9218 @item -Wc90-c99-compat @r{(C and Objective-C only)}
9219 Warn about features not present in ISO C90, but present in ISO C99.
9220 For instance, warn about use of variable length arrays, @code{long long}
9221 type, @code{bool} type, compound literals, designated initializers, and so
9222 on. This option is independent of the standards mode. Warnings are disabled
9223 in the expression that follows @code{__extension__}.
9225 @opindex Wc99-c11-compat
9226 @opindex Wno-c99-c11-compat
9227 @item -Wc99-c11-compat @r{(C and Objective-C only)}
9228 Warn about features not present in ISO C99, but present in ISO C11.
9229 For instance, warn about use of anonymous structures and unions,
9230 @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
9231 @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
9232 and so on. This option is independent of the standards mode. Warnings are
9233 disabled in the expression that follows @code{__extension__}.
9235 @opindex Wc11-c23-compat
9236 @opindex Wno-c11-c23-compat
9237 @item -Wc11-c23-compat @r{(C and Objective-C only)}
9238 @itemx -Wc11-c2x-compat @r{(C and Objective-C only)}
9239 Warn about features not present in ISO C11, but present in ISO C23.
9240 For instance, warn about omitting the string in @code{_Static_assert},
9241 use of @samp{[[]]} syntax for attributes, use of decimal
9242 floating-point types, and so on. This option is independent of the
9243 standards mode. Warnings are disabled in the expression that follows
9244 @code{__extension__}. The name @option{-Wc11-c2x-compat} is
9247 When not compiling in C23 mode, these warnings are upgraded to errors
9248 by @option{-pedantic-errors}.
9250 @opindex Wc++-compat
9251 @opindex Wno-c++-compat
9252 @item -Wc++-compat @r{(C and Objective-C only)}
9253 Warn about ISO C constructs that are outside of the common subset of
9254 ISO C and ISO C++, e.g.@: request for implicit conversion from
9255 @code{void *} to a pointer to non-@code{void} type.
9257 @opindex Wc++11-compat
9258 @opindex Wno-c++11-compat
9259 @item -Wc++11-compat @r{(C++ and Objective-C++ only)}
9260 Warn about C++ constructs whose meaning differs between ISO C++ 1998
9261 and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
9262 in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
9263 enabled by @option{-Wall}.
9265 @opindex Wc++14-compat
9266 @opindex Wno-c++14-compat
9267 @item -Wc++14-compat @r{(C++ and Objective-C++ only)}
9268 Warn about C++ constructs whose meaning differs between ISO C++ 2011
9269 and ISO C++ 2014. This warning is enabled by @option{-Wall}.
9271 @opindex Wc++17-compat
9272 @opindex Wno-c++17-compat
9273 @item -Wc++17-compat @r{(C++ and Objective-C++ only)}
9274 Warn about C++ constructs whose meaning differs between ISO C++ 2014
9275 and ISO C++ 2017. This warning is enabled by @option{-Wall}.
9277 @opindex Wc++20-compat
9278 @opindex Wno-c++20-compat
9279 @item -Wc++20-compat @r{(C++ and Objective-C++ only)}
9280 Warn about C++ constructs whose meaning differs between ISO C++ 2017
9281 and ISO C++ 2020. This warning is enabled by @option{-Wall}.
9283 @opindex Wc++11-extensions
9284 @opindex Wno-c++11-extensions
9285 @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
9286 Do not warn about C++11 constructs in code being compiled using
9287 an older C++ standard. Even without this option, some C++11 constructs
9288 will only be diagnosed if @option{-Wpedantic} is used.
9290 @opindex Wc++14-extensions
9291 @opindex Wno-c++14-extensions
9292 @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
9293 Do not warn about C++14 constructs in code being compiled using
9294 an older C++ standard. Even without this option, some C++14 constructs
9295 will only be diagnosed if @option{-Wpedantic} is used.
9297 @opindex Wc++17-extensions
9298 @opindex Wno-c++17-extensions
9299 @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
9300 Do not warn about C++17 constructs in code being compiled using
9301 an older C++ standard. Even without this option, some C++17 constructs
9302 will only be diagnosed if @option{-Wpedantic} is used.
9304 @opindex Wc++20-extensions
9305 @opindex Wno-c++20-extensions
9306 @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
9307 Do not warn about C++20 constructs in code being compiled using
9308 an older C++ standard. Even without this option, some C++20 constructs
9309 will only be diagnosed if @option{-Wpedantic} is used.
9311 @opindex Wc++23-extensions
9312 @opindex Wno-c++23-extensions
9313 @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
9314 Do not warn about C++23 constructs in code being compiled using
9315 an older C++ standard. Even without this option, some C++23 constructs
9316 will only be diagnosed if @option{-Wpedantic} is used.
9318 @opindex Wc++26-extensions
9319 @opindex Wno-c++26-extensions
9320 @item -Wno-c++26-extensions @r{(C++ and Objective-C++ only)}
9321 Do not warn about C++26 constructs in code being compiled using
9322 an older C++ standard. Even without this option, some C++26 constructs
9323 will only be diagnosed if @option{-Wpedantic} is used.
9326 @opindex Wno-cast-qual
9328 Warn whenever a pointer is cast so as to remove a type qualifier from
9329 the target type. For example, warn if a @code{const char *} is cast
9330 to an ordinary @code{char *}.
9332 Also warn when making a cast that introduces a type qualifier in an
9333 unsafe way. For example, casting @code{char **} to @code{const char **}
9334 is unsafe, as in this example:
9337 /* p is char ** value. */
9338 const char **q = (const char **) p;
9339 /* Assignment of readonly string to const char * is OK. */
9341 /* Now char** pointer points to read-only memory. */
9345 @opindex Wcast-align
9346 @opindex Wno-cast-align
9348 Warn whenever a pointer is cast such that the required alignment of the
9349 target is increased. For example, warn if a @code{char *} is cast to
9350 an @code{int *} on machines where integers can only be accessed at
9351 two- or four-byte boundaries.
9353 @opindex Wcast-align=strict
9354 @item -Wcast-align=strict
9355 Warn whenever a pointer is cast such that the required alignment of the
9356 target is increased. For example, warn if a @code{char *} is cast to
9357 an @code{int *} regardless of the target machine.
9359 @opindex Wcast-function-type
9360 @opindex Wno-cast-function-type
9361 @item -Wcast-function-type
9362 Warn when a function pointer is cast to an incompatible function pointer.
9363 In a cast involving function types with a variable argument list only
9364 the types of initial arguments that are provided are considered.
9365 Any parameter of pointer-type matches any other pointer-type. Any benign
9366 differences in integral types are ignored, like @code{int} vs.@: @code{long}
9367 on ILP32 targets. Likewise type qualifiers are ignored. The function
9368 type @code{void (*) (void)} is special and matches everything, which can
9369 be used to suppress this warning.
9370 In a cast involving pointer to member types this warning warns whenever
9371 the type cast is changing the pointer to member type.
9372 This warning is enabled by @option{-Wextra}.
9374 @opindex Wwrite-strings
9375 @opindex Wno-write-strings
9376 @item -Wwrite-strings
9377 When compiling C, give string constants the type @code{const
9378 char[@var{length}]} so that copying the address of one into a
9379 non-@code{const} @code{char *} pointer produces a warning. These
9380 warnings help you find at compile time code that can try to write
9381 into a string constant, but only if you have been very careful about
9382 using @code{const} in declarations and prototypes. Otherwise, it is
9383 just a nuisance. This is why we did not make @option{-Wall} request
9386 When compiling C++, warn about the deprecated conversion from string
9387 literals to @code{char *}. This warning is enabled by default for C++
9390 This warning is upgraded to an error by @option{-pedantic-errors} in
9391 C++11 mode or later.
9394 @opindex Wno-clobbered
9396 Warn for variables that might be changed by @code{longjmp} or
9397 @code{vfork}. This warning is also enabled by @option{-Wextra}.
9399 @opindex Wcomplain-wrong-lang
9400 @opindex Wno-complain-wrong-lang
9401 @item -Wno-complain-wrong-lang
9402 By default, language front ends complain when a command-line option is
9403 valid, but not applicable to that front end.
9404 This may be disabled with @option{-Wno-complain-wrong-lang},
9405 which is mostly useful when invoking a single compiler driver for
9406 multiple source files written in different languages, for example:
9409 $ g++ -fno-rtti a.cc b.f90
9412 The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
9413 and the Fortran front end to compile @file{b.f90}.
9414 The latter front end diagnoses
9415 @samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
9416 which may be disabled with @option{-Wno-complain-wrong-lang}.
9418 @opindex Wcompare-distinct-pointer-types
9419 @item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)}
9420 Warn if pointers of distinct types are compared without a cast. This
9421 warning is enabled by default.
9423 @opindex Wconversion
9424 @opindex Wno-conversion
9426 Warn for implicit conversions that may alter a value. This includes
9427 conversions between real and integer, like @code{abs (x)} when
9428 @code{x} is @code{double}; conversions between signed and unsigned,
9429 like @code{unsigned ui = -1}; and conversions to smaller types, like
9430 @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
9431 ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
9432 changed by the conversion like in @code{abs (2.0)}. Warnings about
9433 conversions between signed and unsigned integers can be disabled by
9434 using @option{-Wno-sign-conversion}.
9436 For C++, also warn for confusing overload resolution for user-defined
9437 conversions; and conversions that never use a type conversion
9438 operator: conversions to @code{void}, the same type, a base class or a
9439 reference to them. Warnings about conversions between signed and
9440 unsigned integers are disabled by default in C++ unless
9441 @option{-Wsign-conversion} is explicitly enabled.
9443 Warnings about conversion from arithmetic on a small type back to that
9444 type are only given with @option{-Warith-conversion}.
9446 @opindex Wdangling-else
9447 @opindex Wno-dangling-else
9448 @item -Wdangling-else
9449 Warn about constructions where there may be confusion to which
9450 @code{if} statement an @code{else} branch belongs. Here is an example of
9465 In C/C++, every @code{else} branch belongs to the innermost possible
9466 @code{if} statement, which in this example is @code{if (b)}. This is
9467 often not what the programmer expected, as illustrated in the above
9468 example by indentation the programmer chose. When there is the
9469 potential for this confusion, GCC issues a warning when this flag
9470 is specified. To eliminate the warning, add explicit braces around
9471 the innermost @code{if} statement so there is no way the @code{else}
9472 can belong to the enclosing @code{if}. The resulting code
9489 This warning is enabled by @option{-Wparentheses}.
9491 @opindex Wdangling-pointer
9492 @opindex Wno-dangling-pointer
9493 @item -Wdangling-pointer
9494 @itemx -Wdangling-pointer=@var{n}
9495 Warn about uses of pointers (or C++ references) to objects with automatic
9496 storage duration after their lifetime has ended. This includes local
9497 variables declared in nested blocks, compound literals and other unnamed
9498 temporary objects. In addition, warn about storing the address of such
9499 objects in escaped pointers. The warning is enabled at all optimization
9500 levels but may yield different results with optimization than without.
9503 @item -Wdangling-pointer=1
9504 At level 1, the warning diagnoses only unconditional uses of dangling pointers.
9506 @item -Wdangling-pointer=2
9507 At level 2, in addition to unconditional uses the warning also diagnoses
9508 conditional uses of dangling pointers.
9511 The short form @option{-Wdangling-pointer} is equivalent to
9512 @option{-Wdangling-pointer=2}, while @option{-Wno-dangling-pointer} and
9513 @option{-Wdangling-pointer=0} have the same effect of disabling the warnings.
9514 @option{-Wdangling-pointer=2} is included in @option{-Wall}.
9516 This example triggers the warning at level 1; the address of the unnamed
9517 temporary is unconditionally referenced outside of its scope.
9520 char f (char c1, char c2, char c3)
9524 p = (char[]) @{ c1, c2, c3 @};
9526 // warning: using dangling pointer 'p' to an unnamed temporary
9531 In the following function the store of the address of the local variable
9532 @code{x} in the escaped pointer @code{*p} triggers the warning at
9539 // warning: storing the address of local variable 'x' in '*p'
9544 In this example, the array @var{a} is out of
9545 scope when the pointer @var{s} is used. Since the code that sets @code{s}
9546 is conditional, the warning triggers at level 2.
9549 extern void frob (const char *);
9554 char a[12] = "tmpname";
9557 // warning: dangling pointer 's' to 'a' may be used
9563 @opindex Wno-date-time
9565 Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9566 are encountered as they might prevent bit-wise-identical reproducible
9569 @opindex Wempty-body
9570 @opindex Wno-empty-body
9572 Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9573 while} statement. This warning is also enabled by @option{-Wextra}.
9575 @opindex Wendif-labels
9576 @opindex Wno-endif-labels
9577 @item -Wno-endif-labels
9578 Do not warn about stray tokens after @code{#else} and @code{#endif}.
9580 @opindex Wenum-compare
9581 @opindex Wno-enum-compare
9582 @item -Wenum-compare
9583 Warn about a comparison between values of different enumerated types.
9584 In C++ enumerated type mismatches in conditional expressions are also
9585 diagnosed and the warning is enabled by default. In C this warning is
9586 enabled by @option{-Wall}.
9588 @opindex Wenum-conversion
9589 @opindex Wno-enum-conversion
9590 @item -Wenum-conversion
9591 Warn when a value of enumerated type is implicitly converted to a
9592 different enumerated type. This warning is enabled by @option{-Wextra}
9595 @opindex Wenum-int-mismatch
9596 @opindex Wno-enum-int-mismatch
9597 @item -Wenum-int-mismatch @r{(C and Objective-C only)}
9598 Warn about mismatches between an enumerated type and an integer type in
9599 declarations. For example:
9602 enum E @{ l = -1, z = 0, g = 1 @};
9607 In C, an enumerated type is compatible with @code{char}, a signed
9608 integer type, or an unsigned integer type. However, since the choice
9609 of the underlying type of an enumerated type is implementation-defined,
9610 such mismatches may cause portability issues. In C++, such mismatches
9611 are an error. In C, this warning is enabled by @option{-Wall} and
9612 @option{-Wc++-compat}.
9614 @opindex Wjump-misses-init
9615 @opindex Wno-jump-misses-init
9616 @item -Wjump-misses-init @r{(C, Objective-C only)}
9617 Warn if a @code{goto} statement or a @code{switch} statement jumps
9618 forward across the initialization of a variable, or jumps backward to a
9619 label after the variable has been initialized. This only warns about
9620 variables that are initialized when they are declared. This warning is
9621 only supported for C and Objective-C; in C++ this sort of branch is an
9624 @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9625 can be disabled with the @option{-Wno-jump-misses-init} option.
9627 @opindex Wsign-compare
9628 @opindex Wno-sign-compare
9629 @cindex warning for comparison of signed and unsigned values
9630 @cindex comparison of signed and unsigned values, warning
9631 @cindex signed and unsigned values, comparison warning
9632 @item -Wsign-compare
9633 Warn when a comparison between signed and unsigned values could produce
9634 an incorrect result when the signed value is converted to unsigned.
9635 In C++, this warning is also enabled by @option{-Wall}. In C, it is
9636 also enabled by @option{-Wextra}.
9638 @opindex Wsign-conversion
9639 @opindex Wno-sign-conversion
9640 @item -Wsign-conversion
9641 Warn for implicit conversions that may change the sign of an integer
9642 value, like assigning a signed integer expression to an unsigned
9643 integer variable. An explicit cast silences the warning. In C, this
9644 option is enabled also by @option{-Wconversion}.
9646 @opindex Wflex-array-member-not-at-end
9647 @opindex Wno-flex-array-member-not-at-end
9648 @item -Wflex-array-member-not-at-end @r{(C and C++ only)}
9649 Warn when a structure containing a C99 flexible array member as the last
9650 field is not at the end of another structure.
9651 This warning warns e.g. about
9654 struct flex @{ int length; char data[]; @};
9655 struct mid_flex @{ int m; struct flex flex_data; int n; @};
9658 @opindex Wfloat-conversion
9659 @opindex Wno-float-conversion
9660 @item -Wfloat-conversion
9661 Warn for implicit conversions that reduce the precision of a real value.
9662 This includes conversions from real to integer, and from higher precision
9663 real to lower precision real values. This option is also enabled by
9664 @option{-Wconversion}.
9666 @opindex Wno-scalar-storage-order
9667 @opindex Wscalar-storage-order
9668 @item -Wno-scalar-storage-order
9669 Do not warn on suspicious constructs involving reverse scalar storage order.
9671 @opindex Wsizeof-array-div
9672 @opindex Wno-sizeof-array-div
9673 @item -Wsizeof-array-div
9674 Warn about divisions of two sizeof operators when the first one is applied
9675 to an array and the divisor does not equal the size of the array element.
9676 In such a case, the computation will not yield the number of elements in the
9677 array, which is likely what the user intended. This warning warns e.g. about
9682 return sizeof (arr) / sizeof (short);
9686 This warning is enabled by @option{-Wall}.
9688 @opindex Wsizeof-pointer-div
9689 @opindex Wno-sizeof-pointer-div
9690 @item -Wsizeof-pointer-div
9691 Warn for suspicious divisions of two sizeof expressions that divide
9692 the pointer size by the element size, which is the usual way to compute
9693 the array size but won't work out correctly with pointers. This warning
9694 warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9695 not an array, but a pointer. This warning is enabled by @option{-Wall}.
9697 @opindex Wsizeof-pointer-memaccess
9698 @opindex Wno-sizeof-pointer-memaccess
9699 @item -Wsizeof-pointer-memaccess
9700 Warn for suspicious length parameters to certain string and memory built-in
9701 functions if the argument uses @code{sizeof}. This warning triggers for
9702 example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9703 an array, but a pointer, and suggests a possible fix, or about
9704 @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9705 also warns about calls to bounded string copy functions like @code{strncat}
9706 or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9707 the source array. For example, in the following function the call to
9708 @code{strncat} specifies the size of the source string as the bound. That
9709 is almost certainly a mistake and so the call is diagnosed.
9711 void make_file (const char *name)
9713 char path[PATH_MAX];
9714 strncpy (path, name, sizeof path - 1);
9715 strncat (path, ".text", sizeof ".text");
9720 The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9722 @opindex Wsizeof-array-argument
9723 @opindex Wno-sizeof-array-argument
9724 @item -Wno-sizeof-array-argument
9725 Do not warn when the @code{sizeof} operator is applied to a parameter that is
9726 declared as an array in a function definition. This warning is enabled by
9727 default for C and C++ programs.
9729 @opindex Wmemset-elt-size
9730 @opindex Wno-memset-elt-size
9731 @item -Wmemset-elt-size
9732 Warn for suspicious calls to the @code{memset} built-in function, if the
9733 first argument references an array, and the third argument is a number
9734 equal to the number of elements, but not equal to the size of the array
9735 in memory. This indicates that the user has omitted a multiplication by
9736 the element size. This warning is enabled by @option{-Wall}.
9738 @opindex Wmemset-transposed-args
9739 @opindex Wno-memset-transposed-args
9740 @item -Wmemset-transposed-args
9741 Warn for suspicious calls to the @code{memset} built-in function where
9742 the second argument is not zero and the third argument is zero. For
9743 example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9744 @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9745 is only emitted if the third argument is a literal zero. Otherwise, if
9746 it is an expression that is folded to zero, or a cast of zero to some
9747 type, it is far less likely that the arguments have been mistakenly
9748 transposed and no warning is emitted. This warning is enabled
9752 @opindex Wno-address
9754 Warn about suspicious uses of address expressions. These include comparing
9755 the address of a function or a declared object to the null pointer constant
9761 if (!f) // warning: expression evaluates to false
9765 comparisons of a pointer to a string literal, such as in
9767 void f (const char *x)
9769 if (x == "abc") // warning: expression evaluates to false
9773 and tests of the results of pointer addition or subtraction for equality
9776 void f (const int *p, int i)
9778 return p + i == NULL;
9781 Such uses typically indicate a programmer error: the address of most
9782 functions and objects necessarily evaluates to true (the exception are
9783 weak symbols), so their use in a conditional might indicate missing
9784 parentheses in a function call or a missing dereference in an array
9785 expression. The subset of the warning for object pointers can be
9786 suppressed by casting the pointer operand to an integer type such
9787 as @code{intptr_t} or @code{uintptr_t}.
9788 Comparisons against string literals result in unspecified behavior
9789 and are not portable, and suggest the intent was to call @code{strcmp}.
9790 The warning is suppressed if the suspicious expression is the result
9792 @option{-Waddress} warning is enabled by @option{-Wall}.
9794 @opindex Waddress-of-packed-member
9795 @opindex Wno-address-of-packed-member
9796 @item -Wno-address-of-packed-member
9797 Do not warn when the address of packed member of struct or union is taken,
9798 which usually results in an unaligned pointer value. This is
9801 @opindex Wlogical-op
9802 @opindex Wno-logical-op
9804 Warn about suspicious uses of logical operators in expressions.
9805 This includes using logical operators in contexts where a
9806 bit-wise operator is likely to be expected. Also warns when
9807 the operands of a logical operator are the same:
9810 if (a < 0 && a < 0) @{ @dots{} @}
9813 @opindex Wlogical-not-parentheses
9814 @opindex Wno-logical-not-parentheses
9815 @item -Wlogical-not-parentheses
9816 Warn about logical not used on the left hand side operand of a comparison.
9817 This option does not warn if the right operand is considered to be a boolean
9818 expression. Its purpose is to detect suspicious code like the following:
9822 if (!a > 1) @{ @dots{} @}
9825 It is possible to suppress the warning by wrapping the LHS into
9828 if ((!a) > 1) @{ @dots{} @}
9831 This warning is enabled by @option{-Wall}.
9833 @opindex Waggregate-return
9834 @opindex Wno-aggregate-return
9835 @item -Waggregate-return
9836 Warn if any functions that return structures or unions are defined or
9837 called. (In languages where you can return an array, this also elicits
9840 @opindex Wno-aggressive-loop-optimizations
9841 @opindex Waggressive-loop-optimizations
9842 @item -Wno-aggressive-loop-optimizations
9843 Warn if in a loop with constant number of iterations the compiler detects
9844 undefined behavior in some statement during one or more of the iterations.
9846 @opindex Wno-attributes
9847 @opindex Wattributes
9848 @item -Wno-attributes
9849 Do not warn if an unexpected @code{__attribute__} is used, such as
9850 unrecognized attributes, function attributes applied to variables,
9851 etc. This does not stop errors for incorrect use of supported
9854 Warnings about ill-formed uses of standard attributes are upgraded to
9855 errors by @option{-pedantic-errors}.
9857 Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9858 warnings about unknown scoped attributes (in C++11 and C23). For example,
9859 @option{-Wno-attributes=vendor::attr} disables warning about the following
9863 [[vendor::attr]] void f();
9866 It is also possible to disable warning about all attributes in a namespace
9867 using @option{-Wno-attributes=vendor::} which prevents warning about both
9868 of these declarations:
9871 [[vendor::safe]] void f();
9872 [[vendor::unsafe]] void f2();
9875 Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9877 @opindex Wno-builtin-declaration-mismatch
9878 @opindex Wbuiltin-declaration-mismatch
9879 @item -Wno-builtin-declaration-mismatch
9880 Warn if a built-in function is declared with an incompatible signature
9881 or as a non-function, or when a built-in function declared with a type
9882 that does not include a prototype is called with arguments whose promoted
9883 types do not match those expected by the function. When @option{-Wextra}
9884 is specified, also warn when a built-in function that takes arguments is
9885 declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9886 warning is enabled by default. To avoid the warning include the appropriate
9887 header to bring the prototypes of built-in functions into scope.
9889 For example, the call to @code{memset} below is diagnosed by the warning
9890 because the function expects a value of type @code{size_t} as its argument
9891 but the type of @code{32} is @code{int}. With @option{-Wextra},
9892 the declaration of the function is diagnosed as well.
9894 extern void* memset ();
9897 memset (d, '\0', 32);
9901 @opindex Wno-builtin-macro-redefined
9902 @opindex Wbuiltin-macro-redefined
9903 @item -Wno-builtin-macro-redefined
9904 Do not warn if certain built-in macros are redefined. This suppresses
9905 warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9906 @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9908 @opindex Wstrict-prototypes
9909 @opindex Wno-strict-prototypes
9910 @item -Wstrict-prototypes @r{(C and Objective-C only)}
9911 Warn if a function is declared or defined without specifying the
9912 argument types. (An old-style function definition is permitted without
9913 a warning if preceded by a declaration that specifies the argument
9916 @opindex Wold-style-declaration
9917 @opindex Wno-old-style-declaration
9918 @item -Wold-style-declaration @r{(C and Objective-C only)}
9919 Warn for obsolescent usages, according to the C Standard, in a
9920 declaration. For example, warn if storage-class specifiers like
9921 @code{static} are not the first things in a declaration. This warning
9922 is also enabled by @option{-Wextra}.
9924 @opindex Wold-style-definition
9925 @opindex Wno-old-style-definition
9926 @item -Wold-style-definition @r{(C and Objective-C only)}
9927 Warn if an old-style function definition is used. A warning is given
9928 even if there is a previous prototype. A definition using @samp{()}
9929 is not considered an old-style definition in C23 mode, because it is
9930 equivalent to @samp{(void)} in that case, but is considered an
9931 old-style definition for older standards.
9933 @opindex Wmissing-parameter-type
9934 @opindex Wno-missing-parameter-type
9935 @item -Wmissing-parameter-type @r{(C and Objective-C only)}
9936 A function parameter is declared without a type specifier in K&R-style
9943 This warning is also enabled by @option{-Wextra}.
9945 @opindex Wno-declaration-missing-parameter-type
9946 @opindex Wdeclaration-missing-parameter-type
9947 @item -Wno-declaration-missing-parameter-type @r{(C and Objective-C only)}
9948 Do not warn if a function declaration contains a parameter name without
9949 a type. Such function declarations do not provide a function prototype
9950 and prevent most type checking in function calls.
9952 This warning is enabled by default. In C99 and later dialects of C, it
9953 is treated as an error. The error can be downgraded to a warning using
9954 @option{-fpermissive} (along with certain other errors), or for this
9955 error alone, with @option{-Wno-error=declaration-missing-parameter-type}.
9957 This warning is upgraded to an error by @option{-pedantic-errors}.
9959 @opindex Wmissing-prototypes
9960 @opindex Wno-missing-prototypes
9961 @item -Wmissing-prototypes @r{(C and Objective-C only)}
9962 Warn if a global function is defined without a previous prototype
9963 declaration. This warning is issued even if the definition itself
9964 provides a prototype. Use this option to detect global functions
9965 that do not have a matching prototype declaration in a header file.
9966 This option is not valid for C++ because all function declarations
9967 provide prototypes and a non-matching declaration declares an
9968 overload rather than conflict with an earlier declaration.
9969 Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9971 @opindex Wmissing-variable-declarations
9972 @opindex Wno-missing-variable-declarations
9973 @item -Wmissing-variable-declarations @r{(C and Objective-C only)}
9974 Warn if a global variable is defined without a previous declaration.
9975 Use this option to detect global variables that do not have a matching
9976 extern declaration in a header file.
9978 @opindex Wmissing-declarations
9979 @opindex Wno-missing-declarations
9980 @item -Wmissing-declarations
9981 Warn if a global function is defined without a previous declaration.
9982 Do so even if the definition itself provides a prototype.
9983 Use this option to detect global functions that are not declared in
9984 header files. In C, no warnings are issued for functions with previous
9985 non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9986 missing prototypes. In C++, no warnings are issued for function templates,
9987 or for inline functions, or for functions in anonymous namespaces.
9989 @opindex Wmissing-field-initializers
9990 @opindex Wno-missing-field-initializers
9994 @item -Wmissing-field-initializers
9995 Warn if a structure's initializer has some fields missing. For
9996 example, the following code causes such a warning, because
9997 @code{x.h} is implicitly zero:
10000 struct s @{ int f, g, h; @};
10001 struct s x = @{ 3, 4 @};
10004 @c It's unclear if this behavior is desirable. See PR39589 and PR96868.
10005 In C this option does not warn about designated initializers, so the
10006 following modification does not trigger a warning:
10009 struct s @{ int f, g, h; @};
10010 struct s x = @{ .f = 3, .g = 4 @};
10013 In C this option does not warn about the universal zero initializer
10017 struct s @{ int f, g, h; @};
10018 struct s x = @{ 0 @};
10021 Likewise, in C++ this option does not warn about the empty @{ @}
10022 initializer, for example:
10025 struct s @{ int f, g, h; @};
10029 This warning is included in @option{-Wextra}. To get other @option{-Wextra}
10030 warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
10032 @opindex Wmissing-requires
10033 @opindex Wno-missing-requires
10034 @item -Wno-missing-requires
10036 By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
10039 bool satisfied = requires @{ C<T> @};
10042 Here @samp{satisfied} will be true if @samp{C<T>} is a valid
10043 expression, which it is for all T. Presumably the user meant to write
10046 bool satisfied = requires @{ requires C<T> @};
10049 so @samp{satisfied} is only true if concept @samp{C} is satisfied for
10052 This warning can be disabled with @option{-Wno-missing-requires}.
10054 @opindex Wmissing-template-keyword
10055 @opindex Wno-missing-template-keyword
10056 @item -Wno-missing-template-keyword
10058 The member access tokens ., -> and :: must be followed by the @code{template}
10059 keyword if the parent object is dependent and the member being named is a
10066 x.template DoSomeOtherStuff<X>(); // Good.
10067 x.DoMoreStuff<X>(); // Warning, x is dependent.
10071 In rare cases it is possible to get false positives. To silence this, wrap
10072 the expression in parentheses. For example, the following is treated as a
10073 template, even where m and N are integers:
10076 void NotATemplate (my_class t)
10080 bool test = t.m < N > (0); // Treated as a template.
10081 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
10085 This warning can be disabled with @option{-Wno-missing-template-keyword}.
10087 @opindex Wno-multichar
10088 @opindex Wmultichar
10089 @item -Wno-multichar
10090 Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
10091 Usually they indicate a typo in the user's code, as they have
10092 implementation-defined values, and should not be used in portable code.
10094 @opindex Wnormalized=
10095 @opindex Wnormalized
10096 @opindex Wno-normalized
10099 @cindex character set, input normalization
10100 @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
10101 In ISO C and ISO C++, two identifiers are different if they are
10102 different sequences of characters. However, sometimes when characters
10103 outside the basic ASCII character set are used, you can have two
10104 different character sequences that look the same. To avoid confusion,
10105 the ISO 10646 standard sets out some @dfn{normalization rules} which
10106 when applied ensure that two sequences that look the same are turned into
10107 the same sequence. GCC can warn you if you are using identifiers that
10108 have not been normalized; this option controls that warning.
10110 There are four levels of warning supported by GCC@. The default is
10111 @option{-Wnormalized=nfc}, which warns about any identifier that is
10112 not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
10113 recommended form for most uses. It is equivalent to
10114 @option{-Wnormalized}.
10116 Unfortunately, there are some characters allowed in identifiers by
10117 ISO C and ISO C++ that, when turned into NFC, are not allowed in
10118 identifiers. That is, there's no way to use these symbols in portable
10119 ISO C or C++ and have all your identifiers in NFC@.
10120 @option{-Wnormalized=id} suppresses the warning for these characters.
10121 It is hoped that future versions of the standards involved will correct
10122 this, which is why this option is not the default.
10124 You can switch the warning off for all characters by writing
10125 @option{-Wnormalized=none} or @option{-Wno-normalized}. You should
10126 only do this if you are using some other normalization scheme (like
10127 ``D''), because otherwise you can easily create bugs that are
10128 literally impossible to see.
10130 Some characters in ISO 10646 have distinct meanings but look identical
10131 in some fonts or display methodologies, especially once formatting has
10132 been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
10133 LETTER N'', displays just like a regular @code{n} that has been
10134 placed in a superscript. ISO 10646 defines the @dfn{NFKC}
10135 normalization scheme to convert all these into a standard form as
10136 well, and GCC warns if your code is not in NFKC if you use
10137 @option{-Wnormalized=nfkc}. This warning is comparable to warning
10138 about every identifier that contains the letter O because it might be
10139 confused with the digit 0, and so is not the default, but may be
10140 useful as a local coding convention if the programming environment
10141 cannot be fixed to display these characters distinctly.
10143 @opindex Wno-attribute-warning
10144 @opindex Wattribute-warning
10145 @item -Wno-attribute-warning
10146 Do not warn about usage of functions (@pxref{Function Attributes})
10147 declared with @code{warning} attribute. By default, this warning is
10148 enabled. @option{-Wno-attribute-warning} can be used to disable the
10149 warning or @option{-Wno-error=attribute-warning} can be used to
10150 disable the error when compiled with @option{-Werror} flag.
10152 @opindex Wno-deprecated
10153 @opindex Wdeprecated
10154 @item -Wno-deprecated
10155 Do not warn about usage of deprecated features. @xref{Deprecated Features}.
10157 @opindex Wno-deprecated-declarations
10158 @opindex Wdeprecated-declarations
10159 @item -Wno-deprecated-declarations
10160 Do not warn about uses of functions (@pxref{Function Attributes}),
10161 variables (@pxref{Variable Attributes}), and types (@pxref{Type
10162 Attributes}) marked as deprecated by using the @code{deprecated}
10165 @opindex Wno-overflow
10167 @item -Wno-overflow
10168 Do not warn about compile-time overflow in constant expressions.
10173 Warn about One Definition Rule violations during link-time optimization.
10174 Enabled by default.
10176 @opindex Wopenacc-parallelism
10177 @opindex Wno-openacc-parallelism
10178 @cindex OpenACC accelerator programming
10179 @item -Wopenacc-parallelism
10180 Warn about potentially suboptimal choices related to OpenACC parallelism.
10183 @opindex Wno-openmp
10185 Warn about suspicious OpenMP code.
10187 @opindex Wopenmp-simd
10188 @opindex Wno-openmp-simd
10189 @item -Wopenmp-simd
10190 Warn if the vectorizer cost model overrides the OpenMP
10191 simd directive set by user. The @option{-fsimd-cost-model=unlimited}
10192 option can be used to relax the cost model.
10194 @opindex Woverride-init
10195 @opindex Wno-override-init
10199 @item -Woverride-init @r{(C and Objective-C only)}
10200 Warn if an initialized field without side effects is overridden when
10201 using designated initializers (@pxref{Designated Inits, , Designated
10204 This warning is included in @option{-Wextra}. To get other
10205 @option{-Wextra} warnings without this one, use @option{-Wextra
10206 -Wno-override-init}.
10208 @opindex Woverride-init-side-effects
10209 @opindex Wno-override-init-side-effects
10210 @item -Wno-override-init-side-effects @r{(C and Objective-C only)}
10211 Do not warn if an initialized field with side effects is overridden when
10212 using designated initializers (@pxref{Designated Inits, , Designated
10213 Initializers}). This warning is enabled by default.
10216 @opindex Wno-packed
10218 Warn if a structure is given the packed attribute, but the packed
10219 attribute has no effect on the layout or size of the structure.
10220 Such structures may be mis-aligned for little benefit. For
10221 instance, in this code, the variable @code{f.x} in @code{struct bar}
10222 is misaligned even though @code{struct bar} does not itself
10223 have the packed attribute:
10230 @} __attribute__((packed));
10238 @opindex Wpacked-bitfield-compat
10239 @opindex Wno-packed-bitfield-compat
10240 @item -Wnopacked-bitfield-compat
10241 The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
10242 on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
10243 the change can lead to differences in the structure layout. GCC
10244 informs you when the offset of such a field has changed in GCC 4.4.
10245 For example there is no longer a 4-bit padding between field @code{a}
10246 and @code{b} in this structure:
10253 @} __attribute__ ((packed));
10256 This warning is enabled by default. Use
10257 @option{-Wno-packed-bitfield-compat} to disable this warning.
10259 @opindex Wpacked-not-aligned
10260 @opindex Wno-packed-not-aligned
10261 @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
10262 Warn if a structure field with explicitly specified alignment in a
10263 packed struct or union is misaligned. For example, a warning will
10264 be issued on @code{struct S}, like, @code{warning: alignment 1 of
10265 'struct S' is less than 8}, in this code:
10269 struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
10270 struct __attribute__ ((packed)) S @{
10276 This warning is enabled by @option{-Wall}.
10279 @opindex Wno-padded
10281 Warn if padding is included in a structure, either to align an element
10282 of the structure or to align the whole structure. Sometimes when this
10283 happens it is possible to rearrange the fields of the structure to
10284 reduce the padding and so make the structure smaller.
10286 @opindex Wredundant-decls
10287 @opindex Wno-redundant-decls
10288 @item -Wredundant-decls
10289 Warn if anything is declared more than once in the same scope, even in
10290 cases where multiple declaration is valid and changes nothing.
10293 @opindex Wno-restrict
10295 Warn when an object referenced by a @code{restrict}-qualified parameter
10296 (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
10297 argument, or when copies between such objects overlap. For example,
10298 the call to the @code{strcpy} function below attempts to truncate the string
10299 by replacing its initial characters with the last four. However, because
10300 the call writes the terminating NUL into @code{a[4]}, the copies overlap and
10301 the call is diagnosed.
10306 char a[] = "abcd1234";
10311 The @option{-Wrestrict} option detects some instances of simple overlap
10312 even without optimization but works best at @option{-O2} and above. It
10313 is included in @option{-Wall}.
10315 @opindex Wnested-externs
10316 @opindex Wno-nested-externs
10317 @item -Wnested-externs @r{(C and Objective-C only)}
10318 Warn if an @code{extern} declaration is encountered within a function.
10321 @opindex Wno-inline
10323 Warn if a function that is declared as inline cannot be inlined.
10324 Even with this option, the compiler does not warn about failures to
10325 inline functions declared in system headers.
10327 The compiler uses a variety of heuristics to determine whether or not
10328 to inline a function. For example, the compiler takes into account
10329 the size of the function being inlined and the amount of inlining
10330 that has already been done in the current function. Therefore,
10331 seemingly insignificant changes in the source program can cause the
10332 warnings produced by @option{-Winline} to appear or disappear.
10334 @opindex Winterference-size
10335 @item -Winterference-size
10336 Warn about use of C++17 @code{std::hardware_destructive_interference_size}
10337 without specifying its value with @option{--param destructive-interference-size}.
10338 Also warn about questionable values for that option.
10340 This variable is intended to be used for controlling class layout, to
10341 avoid false sharing in concurrent code:
10344 struct independent_fields @{
10345 alignas(std::hardware_destructive_interference_size)
10346 std::atomic<int> one;
10347 alignas(std::hardware_destructive_interference_size)
10348 std::atomic<int> two;
10352 Here @samp{one} and @samp{two} are intended to be far enough apart
10353 that stores to one won't require accesses to the other to reload the
10356 By default, @option{--param destructive-interference-size} and
10357 @option{--param constructive-interference-size} are set based on the
10358 current @option{-mtune} option, typically to the L1 cache line size
10359 for the particular target CPU, sometimes to a range if tuning for a
10360 generic target. So all translation units that depend on ABI
10361 compatibility for the use of these variables must be compiled with
10362 the same @option{-mtune} (or @option{-mcpu}).
10364 If ABI stability is important, such as if the use is in a header for a
10365 library, you should probably not use the hardware interference size
10366 variables at all. Alternatively, you can force a particular value
10367 with @option{--param}.
10369 If you are confident that your use of the variable does not affect ABI
10370 outside a single build of your project, you can turn off the warning
10371 with @option{-Wno-interference-size}.
10373 @opindex Wint-in-bool-context
10374 @opindex Wno-int-in-bool-context
10375 @item -Wint-in-bool-context
10376 Warn for suspicious use of integer values where boolean values are expected,
10377 such as conditional expressions (?:) using non-boolean integer constants in
10378 boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
10379 integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
10380 for all kinds of multiplications regardless of the data type.
10381 This warning is enabled by @option{-Wall}.
10383 @opindex Wno-int-to-pointer-cast
10384 @opindex Wint-to-pointer-cast
10385 @item -Wno-int-to-pointer-cast
10386 Suppress warnings from casts to pointer type of an integer of a
10387 different size. In C++, casting to a pointer type of smaller size is
10388 an error. @option{Wint-to-pointer-cast} is enabled by default.
10391 @opindex Wno-pointer-to-int-cast
10392 @opindex Wpointer-to-int-cast
10393 @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
10394 Suppress warnings from casts from a pointer to an integer type of a
10397 @opindex Winvalid-pch
10398 @opindex Wno-invalid-pch
10399 @item -Winvalid-pch
10400 Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
10401 the search path but cannot be used.
10403 @opindex Winvalid-utf8
10404 @opindex Wno-invalid-utf8
10405 @item -Winvalid-utf8
10406 Warn if an invalid UTF-8 character is found.
10407 This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
10408 is used and turned into error with @option{-pedantic-errors}.
10411 @opindex Wno-unicode
10413 Don't diagnose invalid forms of delimited or named escape sequences which are
10414 treated as separate tokens. @option{Wunicode} is enabled by default.
10416 @opindex Wlong-long
10417 @opindex Wno-long-long
10419 Warn if @code{long long} type is used. This is enabled by either
10420 @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
10421 modes. To inhibit the warning messages, use @option{-Wno-long-long}.
10423 This warning is upgraded to an error by @option{-pedantic-errors}.
10425 @opindex Wvariadic-macros
10426 @opindex Wno-variadic-macros
10427 @item -Wvariadic-macros
10428 Warn if variadic macros are used in ISO C90 mode, or if the GNU
10429 alternate syntax is used in ISO C99 mode. This is enabled by either
10430 @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
10431 messages, use @option{-Wno-variadic-macros}.
10434 @opindex Wno-varargs
10436 Do not warn upon questionable usage of the macros used to handle variable
10437 arguments like @code{va_start}. These warnings are enabled by default.
10439 @opindex Wvector-operation-performance
10440 @opindex Wno-vector-operation-performance
10441 @item -Wvector-operation-performance
10442 Warn if vector operation is not implemented via SIMD capabilities of the
10443 architecture. Mainly useful for the performance tuning.
10444 Vector operation can be implemented @code{piecewise}, which means that the
10445 scalar operation is performed on every vector element;
10446 @code{in parallel}, which means that the vector operation is implemented
10447 using scalars of wider type, which normally is more performance efficient;
10448 and @code{as a single scalar}, which means that vector fits into a
10454 Warn if a variable-length array is used in the code.
10455 @option{-Wno-vla} prevents the @option{-Wpedantic} warning of
10456 the variable-length array.
10458 This warning is upgraded to an error by @option{-pedantic-errors}.
10460 @opindex Wvla-larger-than=
10461 @opindex Wno-vla-larger-than
10462 @item -Wvla-larger-than=@var{byte-size}
10463 If this option is used, the compiler warns for declarations of
10464 variable-length arrays whose size is either unbounded, or bounded
10465 by an argument that allows the array size to exceed @var{byte-size}
10466 bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
10467 works, but with variable-length arrays.
10469 Note that GCC may optimize small variable-length arrays of a known
10470 value into plain arrays, so this warning may not get triggered for
10473 @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
10474 is typically only effective when @option{-ftree-vrp} is active (default
10475 for @option{-O2} and above).
10477 See also @option{-Walloca-larger-than=@var{byte-size}}.
10479 @opindex Wno-vla-larger-than
10480 @item -Wno-vla-larger-than
10481 Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
10482 to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
10484 @opindex Wno-vla-parameter
10485 @item -Wvla-parameter
10486 Warn about redeclarations of functions involving arguments of Variable
10487 Length Array types of inconsistent kinds or forms, and enable the detection
10488 of out-of-bounds accesses to such parameters by warnings such as
10489 @option{-Warray-bounds}.
10491 If the first function declaration uses the VLA form the bound specified
10492 in the array is assumed to be the minimum number of elements expected to
10493 be provided in calls to the function and the maximum number of elements
10494 accessed by it. Failing to provide arguments of sufficient size or
10495 accessing more than the maximum number of elements may be diagnosed.
10497 For example, the warning triggers for the following redeclarations because
10498 the first one allows an array of any size to be passed to @code{f} while
10499 the second one specifies that the array argument must have at least @code{n}
10500 elements. In addition, calling @code{f} with the associated VLA bound
10501 parameter in excess of the actual VLA bound triggers a warning as well.
10504 void f (int n, int[n]);
10505 // warning: argument 2 previously declared as a VLA
10506 void f (int, int[]);
10513 // warning: access to a by f may be out of bounds
10520 @option{-Wvla-parameter} is included in @option{-Wall}. The
10521 @option{-Warray-parameter} option triggers warnings for similar problems
10522 involving ordinary array arguments.
10524 @opindex Wvolatile-register-var
10525 @opindex Wno-volatile-register-var
10526 @item -Wvolatile-register-var
10527 Warn if a register variable is declared volatile. The volatile
10528 modifier does not inhibit all optimizations that may eliminate reads
10529 and/or writes to register variables. This warning is enabled by
10532 @opindex Wxor-used-as-pow
10533 @opindex Wno-xor-used-as-pow
10534 @item -Wno-xor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
10535 Disable warnings about uses of @code{^}, the exclusive or operator,
10536 where it appears the code meant exponentiation.
10537 Specifically, the warning occurs when the
10538 left-hand side is the decimal constant 2 or 10 and the right-hand side
10539 is also a decimal constant.
10541 In C and C++, @code{^} means exclusive or, whereas in some other languages
10542 (e.g. TeX and some versions of BASIC) it means exponentiation.
10544 This warning can be silenced by converting one of the operands to
10545 hexadecimal as well as by compiling with @option{-Wno-xor-used-as-pow}.
10547 @opindex Wdisabled-optimization
10548 @opindex Wno-disabled-optimization
10549 @item -Wdisabled-optimization
10550 Warn if a requested optimization pass is disabled. This warning does
10551 not generally indicate that there is anything wrong with your code; it
10552 merely indicates that GCC's optimizers are unable to handle the code
10553 effectively. Often, the problem is that your code is too big or too
10554 complex; GCC refuses to optimize programs when the optimization
10555 itself is likely to take inordinate amounts of time.
10557 @opindex Wpointer-sign
10558 @opindex Wno-pointer-sign
10559 @item -Wpointer-sign @r{(C and Objective-C only)}
10560 Warn for pointer argument passing or assignment with different signedness.
10561 This option is only supported for C and Objective-C@. It is implied by
10562 @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10563 @option{-Wno-pointer-sign}.
10565 This warning is upgraded to an error by @option{-pedantic-errors}.
10567 @opindex Wstack-protector
10568 @opindex Wno-stack-protector
10569 @item -Wstack-protector
10570 This option is only active when @option{-fstack-protector} is active. It
10571 warns about functions that are not protected against stack smashing.
10573 @opindex Woverlength-strings
10574 @opindex Wno-overlength-strings
10575 @item -Woverlength-strings
10576 Warn about string constants that are longer than the ``minimum
10577 maximum'' length specified in the C standard. Modern compilers
10578 generally allow string constants that are much longer than the
10579 standard's minimum limit, but very portable programs should avoid
10580 using longer strings.
10582 The limit applies @emph{after} string constant concatenation, and does
10583 not count the trailing NUL@. In C90, the limit was 509 characters; in
10584 C99, it was raised to 4095. C++98 does not specify a normative
10585 minimum maximum, so we do not diagnose overlength strings in C++@.
10587 This option is implied by @option{-Wpedantic}, and can be disabled with
10588 @option{-Wno-overlength-strings}.
10590 @opindex Wunsuffixed-float-constants
10591 @opindex Wno-unsuffixed-float-constants
10592 @item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
10594 Issue a warning for any floating constant that does not have
10595 a suffix. When used together with @option{-Wsystem-headers} it
10596 warns about such constants in system header files. This can be useful
10597 when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10598 from the decimal floating-point extension to C99.
10600 @opindex Wlto-type-mismatch
10601 @opindex Wno-lto-type-mismatch
10602 @item -Wno-lto-type-mismatch
10604 During the link-time optimization, do not warn about type mismatches in
10605 global declarations from different compilation units.
10606 Requires @option{-flto} to be enabled. Enabled by default.
10608 @opindex Wdesignated-init
10609 @opindex Wno-designated-init
10610 @item -Wno-designated-init @r{(C and Objective-C only)}
10611 Suppress warnings when a positional initializer is used to initialize
10612 a structure that has been marked with the @code{designated_init}
10617 @node Static Analyzer Options
10618 @section Options That Control Static Analysis
10623 @opindex fno-analyzer
10625 This option enables an static analysis of program flow which looks
10626 for ``interesting'' interprocedural paths through the
10627 code, and issues warnings for problems found on them.
10629 This analysis is much more expensive than other GCC warnings.
10631 In technical terms, it performs coverage-guided symbolic execution of
10632 the code being compiled. It is neither sound nor complete: it can
10633 have false positives and false negatives. It is a bug-finding tool,
10634 rather than a tool for proving program correctness.
10636 The analyzer is only suitable for use on C code in this release.
10638 Enabling this option effectively enables the following warnings:
10641 -Wanalyzer-allocation-size
10642 -Wanalyzer-deref-before-check
10643 -Wanalyzer-double-fclose
10644 -Wanalyzer-double-free
10645 -Wanalyzer-exposure-through-output-file
10646 -Wanalyzer-exposure-through-uninit-copy
10647 -Wanalyzer-fd-access-mode-mismatch
10648 -Wanalyzer-fd-double-close
10650 -Wanalyzer-fd-phase-mismatch
10651 -Wanalyzer-fd-type-mismatch
10652 -Wanalyzer-fd-use-after-close
10653 -Wanalyzer-fd-use-without-check
10654 -Wanalyzer-file-leak
10655 -Wanalyzer-free-of-non-heap
10656 -Wanalyzer-imprecise-fp-arithmetic
10657 -Wanalyzer-infinite-loop
10658 -Wanalyzer-infinite-recursion
10659 -Wanalyzer-jump-through-null
10660 -Wanalyzer-malloc-leak
10661 -Wanalyzer-mismatching-deallocation
10662 -Wanalyzer-null-argument
10663 -Wanalyzer-null-dereference
10664 -Wanalyzer-out-of-bounds
10665 -Wanalyzer-overlapping-buffers
10666 -Wanalyzer-possible-null-argument
10667 -Wanalyzer-possible-null-dereference
10668 -Wanalyzer-putenv-of-auto-var
10669 -Wanalyzer-shift-count-negative
10670 -Wanalyzer-shift-count-overflow
10671 -Wanalyzer-stale-setjmp-buffer
10672 -Wanalyzer-tainted-allocation-size
10673 -Wanalyzer-tainted-array-index
10674 -Wanalyzer-tainted-assertion
10675 -Wanalyzer-tainted-divisor
10676 -Wanalyzer-tainted-offset
10677 -Wanalyzer-tainted-size
10678 -Wanalyzer-undefined-behavior-strtok
10679 -Wanalyzer-unsafe-call-within-signal-handler
10680 -Wanalyzer-use-after-free
10681 -Wanalyzer-use-of-pointer-in-stale-stack-frame
10682 -Wanalyzer-use-of-uninitialized-value
10683 -Wanalyzer-va-arg-type-mismatch
10684 -Wanalyzer-va-list-exhausted
10685 -Wanalyzer-va-list-leak
10686 -Wanalyzer-va-list-use-after-va-end
10687 -Wanalyzer-write-to-const
10688 -Wanalyzer-write-to-string-literal
10691 This option is only available if GCC was configured with analyzer
10694 @opindex Wanalyzer-symbol-too-complex
10695 @opindex Wno-analyzer-symbol-too-complex
10696 @item -Wanalyzer-symbol-too-complex
10697 If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10698 to attempt to track the state of memory, but these can be defeated by
10699 sufficiently complicated code.
10701 By default, the analysis silently stops tracking values of expressions
10702 if they exceed the threshold defined by
10703 @option{--param analyzer-max-svalue-depth=@var{value}}, and falls back
10704 to an imprecise representation for such expressions.
10705 The @option{-Wanalyzer-symbol-too-complex} option warns if this occurs.
10707 @opindex Wanalyzer-too-complex
10708 @opindex Wno-analyzer-too-complex
10709 @item -Wanalyzer-too-complex
10710 If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10711 to attempt to explore the control flow and data flow in the program,
10712 but these can be defeated by sufficiently complicated code.
10714 By default, the analysis silently stops if the code is too
10715 complicated for the analyzer to fully explore and it reaches an internal
10716 limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10718 @opindex Wanalyzer-allocation-size
10719 @opindex Wno-analyzer-allocation-size
10720 @item -Wno-analyzer-allocation-size
10721 This warning requires @option{-fanalyzer}, which enables it;
10722 to disable it, use @option{-Wno-analyzer-allocation-size}.
10724 This diagnostic warns for paths through the code in which a pointer to
10725 a buffer is assigned to point at a buffer with a size that is not a
10726 multiple of @code{sizeof (*pointer)}.
10728 See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10730 @opindex Wanalyzer-deref-before-check
10731 @opindex Wno-analyzer-deref-before-check
10732 @item -Wno-analyzer-deref-before-check
10733 This warning requires @option{-fanalyzer}, which enables it; use
10734 @option{-Wno-analyzer-deref-before-check}
10737 This diagnostic warns for paths through the code in which a pointer
10738 is checked for @code{NULL} *after* it has already been
10739 dereferenced, suggesting that the pointer could have been NULL.
10740 Such cases suggest that the check for NULL is either redundant,
10741 or that it needs to be moved to before the pointer is dereferenced.
10743 This diagnostic also considers values passed to a function argument
10744 marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10745 value, and thus will complain if such values are checked for @code{NULL}
10746 after returning from such a function call.
10748 This diagnostic is unlikely to be reported when any level of optimization
10749 is enabled, as GCC's optimization logic will typically consider such
10750 checks for NULL as being redundant, and optimize them away before the
10751 analyzer "sees" them. Hence optimization should be disabled when
10752 attempting to trigger this diagnostic.
10754 @opindex Wanalyzer-double-fclose
10755 @opindex Wno-analyzer-double-fclose
10756 @item -Wno-analyzer-double-fclose
10757 This warning requires @option{-fanalyzer}, which enables it; use
10758 @option{-Wno-analyzer-double-fclose} to disable it.
10760 This diagnostic warns for paths through the code in which a @code{FILE *}
10761 can have @code{fclose} called on it more than once.
10763 See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10765 @opindex Wanalyzer-double-free
10766 @opindex Wno-analyzer-double-free
10767 @item -Wno-analyzer-double-free
10768 This warning requires @option{-fanalyzer}, which enables it; use
10769 @option{-Wno-analyzer-double-free} to disable it.
10771 This diagnostic warns for paths through the code in which a pointer
10772 can have a deallocator called on it more than once, either @code{free},
10773 or a deallocator referenced by attribute @code{malloc}.
10775 See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10777 @opindex Wanalyzer-exposure-through-output-file
10778 @opindex Wno-analyzer-exposure-through-output-file
10779 @item -Wno-analyzer-exposure-through-output-file
10780 This warning requires @option{-fanalyzer}, which enables it; use
10781 @option{-Wno-analyzer-exposure-through-output-file}
10784 This diagnostic warns for paths through the code in which a
10785 security-sensitive value is written to an output file
10786 (such as writing a password to a log file).
10788 See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10790 @opindex Wanalyzer-exposure-through-uninit-copy
10791 @opindex Wno-analyzer-exposure-through-uninit-copy
10792 @item -Wanalyzer-exposure-through-uninit-copy
10793 This warning requires both @option{-fanalyzer} and the use of a plugin
10794 to specify a function that copies across a ``trust boundary''. Use
10795 @option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10797 This diagnostic warns for ``infoleaks'' - paths through the code in which
10798 uninitialized values are copied across a security boundary
10799 (such as code within an OS kernel that copies a partially-initialized
10800 struct on the stack to user space).
10802 See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10804 @opindex Wanalyzer-fd-access-mode-mismatch
10805 @opindex Wno-analyzer-fd-access-mode-mismatch
10806 @item -Wno-analyzer-fd-access-mode-mismatch
10807 This warning requires @option{-fanalyzer}, which enables it; use
10808 @option{-Wno-analyzer-fd-access-mode-mismatch}
10811 This diagnostic warns for paths through code in which a
10812 @code{read} on a write-only file descriptor is attempted, or vice versa.
10814 This diagnostic also warns for code paths in a which a function with attribute
10815 @code{fd_arg_read (N)} is called with a file descriptor opened with
10816 @code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10817 @code{fd_arg_write (N)} is called with a file descriptor opened with
10818 @code{O_RDONLY} at referenced argument @var{N}.
10820 @opindex Wanalyzer-fd-double-close
10821 @opindex Wno-analyzer-fd-double-close
10822 @item -Wno-analyzer-fd-double-close
10823 This warning requires @option{-fanalyzer}, which enables it; use
10824 @option{-Wno-analyzer-fd-double-close}
10827 This diagnostic warns for paths through code in which a
10828 file descriptor can be closed more than once.
10830 See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10832 @opindex Wanalyzer-fd-leak
10833 @opindex Wno-analyzer-fd-leak
10834 @item -Wno-analyzer-fd-leak
10835 This warning requires @option{-fanalyzer}, which enables it; use
10836 @option{-Wno-analyzer-fd-leak}
10839 This diagnostic warns for paths through code in which an
10840 open file descriptor is leaked.
10842 See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10844 @opindex Wanalyzer-fd-phase-mismatch
10845 @opindex Wno-analyzer-fd-phase-mismatch
10846 @item -Wno-analyzer-fd-phase-mismatch
10847 This warning requires @option{-fanalyzer}, which enables it; use
10848 @option{-Wno-analyzer-fd-phase-mismatch}
10851 This diagnostic warns for paths through code in which an operation is
10852 attempted in the wrong phase of a file descriptor's lifetime.
10853 For example, it will warn on attempts to call @code{accept} on a stream
10854 socket that has not yet had @code{listen} successfully called on it.
10856 See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10858 @opindex Wanalyzer-fd-type-mismatch
10859 @opindex Wno-analyzer-fd-type-mismatch
10860 @item -Wno-analyzer-fd-type-mismatch
10861 This warning requires @option{-fanalyzer}, which enables it; use
10862 @option{-Wno-analyzer-fd-type-mismatch}
10865 This diagnostic warns for paths through code in which an
10866 operation is attempted on the wrong type of file descriptor.
10867 For example, it will warn on attempts to use socket operations
10868 on a file descriptor obtained via @code{open}, or when attempting
10869 to use a stream socket operation on a datagram socket.
10871 @opindex Wanalyzer-fd-use-after-close
10872 @opindex Wno-analyzer-fd-use-after-close
10873 @item -Wno-analyzer-fd-use-after-close
10874 This warning requires @option{-fanalyzer}, which enables it; use
10875 @option{-Wno-analyzer-fd-use-after-close}
10878 This diagnostic warns for paths through code in which a
10879 read or write is called on a closed file descriptor.
10881 This diagnostic also warns for paths through code in which
10882 a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10883 or @code{fd_arg_write (N)} is called with a closed file descriptor at
10884 referenced argument @code{N}.
10886 @opindex Wanalyzer-fd-use-without-check
10887 @opindex Wno-analyzer-fd-use-without-check
10888 @item -Wno-analyzer-fd-use-without-check
10889 This warning requires @option{-fanalyzer}, which enables it; use
10890 @option{-Wno-analyzer-fd-use-without-check}
10893 This diagnostic warns for paths through code in which a
10894 file descriptor is used without being checked for validity.
10896 This diagnostic also warns for paths through code in which
10897 a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10898 or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10899 argument @code{N}, without being checked for validity.
10901 @opindex Wanalyzer-file-leak
10902 @opindex Wno-analyzer-file-leak
10903 @item -Wno-analyzer-file-leak
10904 This warning requires @option{-fanalyzer}, which enables it; use
10905 @option{-Wno-analyzer-file-leak}
10908 This diagnostic warns for paths through the code in which a
10909 @code{<stdio.h>} @code{FILE *} stream object is leaked.
10911 See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10913 @opindex Wanalyzer-free-of-non-heap
10914 @opindex Wno-analyzer-free-of-non-heap
10915 @item -Wno-analyzer-free-of-non-heap
10916 This warning requires @option{-fanalyzer}, which enables it; use
10917 @option{-Wno-analyzer-free-of-non-heap}
10920 This diagnostic warns for paths through the code in which @code{free}
10921 is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10923 See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10925 @opindex Wanalyzer-imprecise-fp-arithmetic
10926 @opindex Wno-analyzer-imprecise-fp-arithmetic
10927 @item -Wno-analyzer-imprecise-fp-arithmetic
10928 This warning requires @option{-fanalyzer}, which enables it; use
10929 @option{-Wno-analyzer-imprecise-fp-arithmetic}
10932 This diagnostic warns for paths through the code in which floating-point
10933 arithmetic is used in locations where precise computation is needed. This
10934 diagnostic only warns on use of floating-point operands inside the
10935 calculation of an allocation size at the moment.
10937 @opindex Wanalyzer-infinite-loop
10938 @opindex Wno-analyzer-infinite-loop
10939 @item -Wno-analyzer-infinite-loop
10940 This warning requires @option{-fanalyzer}, which enables it; use
10941 @option{-Wno-analyzer-infinite-loop} to disable it.
10943 This diagnostics warns for paths through the code which appear to
10944 lead to an infinite loop.
10946 Specifically, the analyzer will issue this warning when it "sees" a loop
10950 no externally-visible work could be being done within the loop
10952 there is no way to escape from the loop
10954 the analyzer is sufficiently confident about the program state
10955 throughout the loop to know that the above are true
10958 One way for this warning to be emitted is when there is an execution
10959 path through a loop for which taking the path on one iteration implies
10960 that the same path will be taken on all subsequent iterations.
10962 For example, consider:
10967 char opcode = *cpu_state.pc;
10971 handle_opcode_foo (&cpu_state);
10974 handle_opcode_bar (&cpu_state);
10980 The analyzer will complain for the above case because if @code{opcode}
10981 ever matches none of the cases, the @code{switch} will follow the
10982 implicit @code{default} case, making the body of the loop be a ``no-op''
10983 with @code{cpu_state.pc} unchanged, and thus using the same value of
10984 @code{opcode} on all subseqent iterations, leading to an infinite loop.
10986 See @uref{https://cwe.mitre.org/data/definitions/835.html, CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')}.
10988 @opindex Wanalyzer-infinite-recursion
10989 @opindex Wno-analyzer-infinite-recursion
10990 @item -Wno-analyzer-infinite-recursion
10991 This warning requires @option{-fanalyzer}, which enables it; use
10992 @option{-Wno-analyzer-infinite-recursion} to disable it.
10994 This diagnostics warns for paths through the code which appear to
10995 lead to infinite recursion.
10997 Specifically, when the analyzer "sees" a recursive call, it will compare
10998 the state of memory at the entry to the new frame with that at the entry
10999 to the previous frame of that function on the stack. The warning is
11000 issued if nothing in memory appears to be changing; any changes observed
11001 to parameters or globals are assumed to lead to termination of the
11002 recursion and thus suppress the warning.
11004 This diagnostic is likely to miss cases of infinite recursion that
11005 are convered to iteration by the optimizer before the analyzer "sees"
11006 them. Hence optimization should be disabled when attempting to trigger
11009 Compare with @option{-Winfinite-recursion}, which provides a similar
11010 diagnostic, but is implemented in a different way.
11012 See @uref{https://cwe.mitre.org/data/definitions/674.html, CWE-674: Uncontrolled Recursion}.
11014 @opindex Wanalyzer-jump-through-null
11015 @opindex Wno-analyzer-jump-through-null
11016 @item -Wno-analyzer-jump-through-null
11017 This warning requires @option{-fanalyzer}, which enables it; use
11018 @option{-Wno-analyzer-jump-through-null}
11021 This diagnostic warns for paths through the code in which a @code{NULL}
11022 function pointer is called.
11024 @opindex Wanalyzer-malloc-leak
11025 @opindex Wno-analyzer-malloc-leak
11026 @item -Wno-analyzer-malloc-leak
11027 This warning requires @option{-fanalyzer}, which enables it; use
11028 @option{-Wno-analyzer-malloc-leak}
11031 This diagnostic warns for paths through the code in which a
11032 pointer allocated via an allocator is leaked: either @code{malloc},
11033 or a function marked with attribute @code{malloc}.
11035 See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
11037 @opindex Wanalyzer-mismatching-deallocation
11038 @opindex Wno-analyzer-mismatching-deallocation
11039 @item -Wno-analyzer-mismatching-deallocation
11040 This warning requires @option{-fanalyzer}, which enables it; use
11041 @option{-Wno-analyzer-mismatching-deallocation}
11044 This diagnostic warns for paths through the code in which the
11045 wrong deallocation function is called on a pointer value, based on
11046 which function was used to allocate the pointer value. The diagnostic
11047 will warn about mismatches between @code{free}, scalar @code{delete}
11048 and vector @code{delete[]}, and those marked as allocator/deallocator
11049 pairs using attribute @code{malloc}.
11051 See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
11053 @opindex Wanalyzer-out-of-bounds
11054 @opindex Wno-analyzer-out-of-bounds
11055 @item -Wno-analyzer-out-of-bounds
11056 This warning requires @option{-fanalyzer}, which enables it; use
11057 @option{-Wno-analyzer-out-of-bounds} to disable it.
11059 This diagnostic warns for paths through the code in which a buffer is
11060 definitely read or written out-of-bounds. The diagnostic applies for
11061 cases where the analyzer is able to determine a constant offset and for
11062 accesses past the end of a buffer, also a constant capacity. Further,
11063 the diagnostic does limited checking for accesses past the end when the
11064 offset as well as the capacity is symbolic.
11066 See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
11068 For cases where the analyzer is able, it will emit a text art diagram
11069 visualizing the spatial relationship between the memory region that the
11070 analyzer predicts would be accessed, versus the range of memory that is
11071 valid to access: whether they overlap, are touching, are close or far
11072 apart; which one is before or after in memory, the relative sizes
11073 involved, the direction of the access (read vs write), and, in some
11074 cases, the values of data involved. This diagram can be suppressed
11075 using @option{-fdiagnostics-text-art-charset=none}.
11077 @opindex Wanalyzer-overlapping-buffers
11078 @opindex Wno-analyzer-overlapping-buffers
11079 @item -Wno-analyzer-overlapping-buffers
11080 This warning requires @option{-fanalyzer}, which enables it; use
11081 @option{-Wno-analyzer-overlapping-buffers} to disable it.
11083 This diagnostic warns for paths through the code in which overlapping
11084 buffers are passed to an API for which the behavior on such buffers
11087 Specifically, the diagnostic occurs on calls to the following functions
11089 @item @code{memcpy}
11090 @item @code{strcat}
11091 @item @code{strcpy}
11093 for cases where the buffers are known to overlap.
11095 @opindex Wanalyzer-possible-null-argument
11096 @opindex Wno-analyzer-possible-null-argument
11097 @item -Wno-analyzer-possible-null-argument
11098 This warning requires @option{-fanalyzer}, which enables it; use
11099 @option{-Wno-analyzer-possible-null-argument} to disable it.
11101 This diagnostic warns for paths through the code in which a
11102 possibly-NULL value is passed to a function argument marked
11103 with @code{__attribute__((nonnull))} as requiring a non-NULL
11106 See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
11108 @opindex Wanalyzer-possible-null-dereference
11109 @opindex Wno-analyzer-possible-null-dereference
11110 @item -Wno-analyzer-possible-null-dereference
11111 This warning requires @option{-fanalyzer}, which enables it; use
11112 @option{-Wno-analyzer-possible-null-dereference} to disable it.
11114 This diagnostic warns for paths through the code in which a
11115 possibly-NULL value is dereferenced.
11117 See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
11119 @opindex Wanalyzer-null-argument
11120 @opindex Wno-analyzer-null-argument
11121 @item -Wno-analyzer-null-argument
11122 This warning requires @option{-fanalyzer}, which enables it; use
11123 @option{-Wno-analyzer-null-argument} to disable it.
11125 This diagnostic warns for paths through the code in which a
11126 value known to be NULL is passed to a function argument marked
11127 with @code{__attribute__((nonnull))} as requiring a non-NULL
11130 See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
11132 @opindex Wanalyzer-null-dereference
11133 @opindex Wno-analyzer-null-dereference
11134 @item -Wno-analyzer-null-dereference
11135 This warning requires @option{-fanalyzer}, which enables it; use
11136 @option{-Wno-analyzer-null-dereference} to disable it.
11138 This diagnostic warns for paths through the code in which a
11139 value known to be NULL is dereferenced.
11141 See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
11143 @opindex Wanalyzer-putenv-of-auto-var
11144 @opindex Wno-analyzer-putenv-of-auto-var
11145 @item -Wno-analyzer-putenv-of-auto-var
11146 This warning requires @option{-fanalyzer}, which enables it; use
11147 @option{-Wno-analyzer-putenv-of-auto-var} to disable it.
11149 This diagnostic warns for paths through the code in which a
11150 call to @code{putenv} is passed a pointer to an automatic variable
11151 or an on-stack buffer.
11153 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}.
11155 @opindex Wanalyzer-shift-count-negative
11156 @opindex Wno-analyzer-shift-count-negative
11157 @item -Wno-analyzer-shift-count-negative
11158 This warning requires @option{-fanalyzer}, which enables it; use
11159 @option{-Wno-analyzer-shift-count-negative} to disable it.
11161 This diagnostic warns for paths through the code in which a
11162 shift is attempted with a negative count. It is analogous to
11163 the @option{-Wshift-count-negative} diagnostic implemented in
11164 the C/C++ front ends, but is implemented based on analyzing
11165 interprocedural paths, rather than merely parsing the syntax tree.
11166 However, the analyzer does not prioritize detection of such paths, so
11167 false negatives are more likely relative to other warnings.
11169 @opindex Wanalyzer-shift-count-overflow
11170 @opindex Wno-analyzer-shift-count-overflow
11171 @item -Wno-analyzer-shift-count-overflow
11172 This warning requires @option{-fanalyzer}, which enables it; use
11173 @option{-Wno-analyzer-shift-count-overflow} to disable it.
11175 This diagnostic warns for paths through the code in which a
11176 shift is attempted with a count greater than or equal to the
11177 precision of the operand's type. It is analogous to
11178 the @option{-Wshift-count-overflow} diagnostic implemented in
11179 the C/C++ front ends, but is implemented based on analyzing
11180 interprocedural paths, rather than merely parsing the syntax tree.
11181 However, the analyzer does not prioritize detection of such paths, so
11182 false negatives are more likely relative to other warnings.
11184 @opindex Wanalyzer-stale-setjmp-buffer
11185 @opindex Wno-analyzer-stale-setjmp-buffer
11186 @item -Wno-analyzer-stale-setjmp-buffer
11187 This warning requires @option{-fanalyzer}, which enables it; use
11188 @option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
11190 This diagnostic warns for paths through the code in which
11191 @code{longjmp} is called to rewind to a @code{jmp_buf} relating
11192 to a @code{setjmp} call in a function that has returned.
11194 When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
11195 location, it records the stack frame. The stack frame becomes invalid
11196 when the function containing the @code{setjmp} call returns. Attempting
11197 to rewind to it via @code{longjmp} would reference a stack frame that
11198 no longer exists, and likely lead to a crash (or worse).
11200 @opindex Wanalyzer-tainted-allocation-size
11201 @opindex Wno-analyzer-tainted-allocation-size
11202 @item -Wno-analyzer-tainted-allocation-size
11203 This warning requires @option{-fanalyzer} which enables it;
11204 use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
11206 This diagnostic warns for paths through the code in which a value
11207 that could be under an attacker's control is used as the size
11208 of an allocation without being sanitized, so that an attacker could
11209 inject an excessively large allocation and potentially cause a denial
11212 See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
11214 @opindex Wanalyzer-tainted-assertion
11215 @opindex Wno-analyzer-tainted-assertion
11216 @item -Wno-analyzer-tainted-assertion
11218 This warning requires @option{-fanalyzer} which enables it;
11219 use @option{-Wno-analyzer-tainted-assertion} to disable it.
11221 This diagnostic warns for paths through the code in which a value
11222 that could be under an attacker's control is used as part of a
11223 condition without being first sanitized, and that condition guards a
11224 call to a function marked with attribute @code{noreturn}
11225 (such as the function @code{__builtin_unreachable}). Such functions
11226 typically indicate abnormal termination of the program, such as for
11227 assertion failure handlers. For example:
11230 assert (some_tainted_value < SOME_LIMIT);
11237 when assertion-checking is enabled: an attacker could trigger
11238 a denial of service by injecting an assertion failure
11241 when assertion-checking is disabled, such as by defining @code{NDEBUG},
11242 an attacker could inject data that subverts the process, since it
11243 presumably violates a precondition that is being assumed by the code.
11247 Note that when assertion-checking is disabled, the assertions are
11248 typically removed by the preprocessor before the analyzer has a chance
11249 to "see" them, so this diagnostic can only generate warnings on builds
11250 in which assertion-checking is enabled.
11252 For the purpose of this warning, any function marked with attribute
11253 @code{noreturn} is considered as a possible assertion failure
11254 handler, including @code{__builtin_unreachable}. Note that these functions
11255 are sometimes removed by the optimizer before the analyzer "sees" them.
11256 Hence optimization should be disabled when attempting to trigger this
11259 See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
11261 The warning can also report problematic constructions such as
11264 switch (some_tainted_value) @{
11266 /* [...etc; various valid cases omitted...] */
11270 __builtin_unreachable (); /* BUG: attacker can trigger this */
11274 despite the above not being an assertion failure, strictly speaking.
11276 @opindex Wanalyzer-tainted-array-index
11277 @opindex Wno-analyzer-tainted-array-index
11278 @item -Wno-analyzer-tainted-array-index
11279 This warning requires @option{-fanalyzer} which enables it;
11280 use @option{-Wno-analyzer-tainted-array-index} to disable it.
11282 This diagnostic warns for paths through the code in which a value
11283 that could be under an attacker's control is used as the index
11284 of an array access without being sanitized, so that an attacker
11285 could inject an out-of-bounds access.
11287 See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11289 @opindex Wanalyzer-tainted-divisor
11290 @opindex Wno-analyzer-tainted-divisor
11291 @item -Wno-analyzer-tainted-divisor
11292 This warning requires @option{-fanalyzer} which enables it;
11293 use @option{-Wno-analyzer-tainted-divisor} to disable it.
11295 This diagnostic warns for paths through the code in which a value
11296 that could be under an attacker's control is used as the divisor
11297 in a division or modulus operation without being sanitized, so that
11298 an attacker could inject a division-by-zero.
11300 See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
11302 @opindex Wanalyzer-tainted-offset
11303 @opindex Wno-analyzer-tainted-offset
11304 @item -Wno-analyzer-tainted-offset
11305 This warning requires @option{-fanalyzer} which enables it;
11306 use @option{-Wno-analyzer-tainted-offset} to disable it.
11308 This diagnostic warns for paths through the code in which a value
11309 that could be under an attacker's control is used as a pointer offset
11310 without being sanitized, so that an attacker could inject an out-of-bounds
11313 See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
11315 @opindex Wanalyzer-tainted-size
11316 @opindex Wno-analyzer-tainted-size
11317 @item -Wno-analyzer-tainted-size
11318 This warning requires @option{-fanalyzer} which enables it;
11319 use @option{-Wno-analyzer-tainted-size} to disable it.
11321 This diagnostic warns for paths through the code in which a value
11322 that could be under an attacker's control is used as the size of
11323 an operation such as @code{memset} without being sanitized, so that an
11324 attacker could inject an out-of-bounds access.
11326 See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11328 @opindex Wanalyzer-undefined-behavior-strtok
11329 @opindex Wno-analyzer-undefined-behavior-strtok
11330 @item -Wno-analyzer-undefined-behavior-strtok
11331 This warning requires @option{-fanalyzer}, which enables it; use
11332 @option{-Wno-analyzer-undefined-behavior-strtok} to disable it.
11334 This diagnostic warns for paths through the code in which a
11335 call is made to @code{strtok} with undefined behavior.
11337 Specifically, passing NULL as the first parameter for the initial
11338 call to @code{strtok} within a process has undefined behavior.
11340 @opindex Wanalyzer-unsafe-call-within-signal-handler
11341 @opindex Wno-analyzer-unsafe-call-within-signal-handler
11342 @item -Wno-analyzer-unsafe-call-within-signal-handler
11343 This warning requires @option{-fanalyzer}, which enables it; use
11344 @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
11346 This diagnostic warns for paths through the code in which a
11347 function known to be async-signal-unsafe (such as @code{fprintf}) is
11348 called from a signal handler.
11350 See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
11352 @opindex Wanalyzer-use-after-free
11353 @opindex Wno-analyzer-use-after-free
11354 @item -Wno-analyzer-use-after-free
11355 This warning requires @option{-fanalyzer}, which enables it; use
11356 @option{-Wno-analyzer-use-after-free} to disable it.
11358 This diagnostic warns for paths through the code in which a
11359 pointer is used after a deallocator is called on it: either @code{free},
11360 or a deallocator referenced by attribute @code{malloc}.
11362 See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
11364 @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
11365 @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
11366 @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
11367 This warning requires @option{-fanalyzer}, which enables it; use
11368 @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
11371 This diagnostic warns for paths through the code in which a pointer
11372 is dereferenced that points to a variable in a stale stack frame.
11374 @opindex Wanalyzer-va-arg-type-mismatch
11375 @opindex Wno-analyzer-va-arg-type-mismatch
11376 @item -Wno-analyzer-va-arg-type-mismatch
11377 This warning requires @option{-fanalyzer}, which enables it; use
11378 @option{-Wno-analyzer-va-arg-type-mismatch}
11381 This diagnostic warns for interprocedural paths through the code for which
11382 the analyzer detects an attempt to use @code{va_arg} to extract a value
11383 passed to a variadic call, but uses a type that does not match that of
11384 the expression passed to the call.
11386 See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
11388 @opindex Wanalyzer-va-list-exhausted
11389 @opindex Wno-analyzer-va-list-exhausted
11390 @item -Wno-analyzer-va-list-exhausted
11391 This warning requires @option{-fanalyzer}, which enables it; use
11392 @option{-Wno-analyzer-va-list-exhausted}
11395 This diagnostic warns for interprocedural paths through the code for which
11396 the analyzer detects an attempt to use @code{va_arg} to access the next
11397 value passed to a variadic call, but all of the values in the
11398 @code{va_list} have already been consumed.
11400 See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
11402 @opindex Wanalyzer-va-list-leak
11403 @opindex Wno-analyzer-va-list-leak
11404 @item -Wno-analyzer-va-list-leak
11405 This warning requires @option{-fanalyzer}, which enables it; use
11406 @option{-Wno-analyzer-va-list-leak}
11409 This diagnostic warns for interprocedural paths through the code for which
11410 the analyzer detects that @code{va_start} or @code{va_copy} has been called
11411 on a @code{va_list} without a corresponding call to @code{va_end}.
11413 @opindex Wanalyzer-va-list-use-after-va-end
11414 @opindex Wno-analyzer-va-list-use-after-va-end
11415 @item -Wno-analyzer-va-list-use-after-va-end
11416 This warning requires @option{-fanalyzer}, which enables it; use
11417 @option{-Wno-analyzer-va-list-use-after-va-end}
11420 This diagnostic warns for interprocedural paths through the code for which
11421 the analyzer detects an attempt to use a @code{va_list} after
11422 @code{va_end} has been called on it.
11425 @opindex Wanalyzer-write-to-const
11426 @opindex Wno-analyzer-write-to-const
11427 @item -Wno-analyzer-write-to-const
11428 This warning requires @option{-fanalyzer}, which enables it; use
11429 @option{-Wno-analyzer-write-to-const}
11432 This diagnostic warns for paths through the code in which the analyzer
11433 detects an attempt to write through a pointer to a @code{const} object.
11434 However, the analyzer does not prioritize detection of such paths, so
11435 false negatives are more likely relative to other warnings.
11437 @opindex Wanalyzer-write-to-string-literal
11438 @opindex Wno-analyzer-write-to-string-literal
11439 @item -Wno-analyzer-write-to-string-literal
11440 This warning requires @option{-fanalyzer}, which enables it; use
11441 @option{-Wno-analyzer-write-to-string-literal}
11444 This diagnostic warns for paths through the code in which the analyzer
11445 detects an attempt to write through a pointer to a string literal.
11446 However, the analyzer does not prioritize detection of such paths, so
11447 false negatives are more likely relative to other warnings.
11449 @opindex Wanalyzer-use-of-uninitialized-value
11450 @opindex Wno-analyzer-use-of-uninitialized-value
11451 @item -Wno-analyzer-use-of-uninitialized-value
11452 This warning requires @option{-fanalyzer}, which enables it; use
11453 @option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
11455 This diagnostic warns for paths through the code in which an uninitialized
11458 See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
11462 The analyzer has hardcoded knowledge about the behavior of the following
11463 memory-management functions:
11466 @item @code{alloca}
11467 @item The built-in functions @code{__builtin_alloc},
11468 @code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
11469 @code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
11470 @code{__builtin_memcpy_chk}, @code{__builtin_memset},
11471 @code{__builtin_memset_chk}, @code{__builtin_realloc},
11472 @code{__builtin_stack_restore}, and @code{__builtin_stack_save}
11473 @item @code{calloc}
11475 @item @code{malloc}
11476 @item @code{memset}
11477 @item @code{operator delete}
11478 @item @code{operator delete []}
11479 @item @code{operator new}
11480 @item @code{operator new []}
11481 @item @code{realloc}
11482 @item @code{strdup}
11483 @item @code{strndup}
11487 of the following functions for working with file descriptors:
11493 @item @code{dup}, @code{dup2} and @code{dup3}
11494 @item @code{isatty}
11495 @item @code{pipe}, and @code{pipe2}
11498 @item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
11502 of the following functions for working with @code{<stdio.h>} streams:
11504 @item The built-in functions @code{__builtin_fprintf},
11505 @code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
11506 @code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
11507 @code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
11508 @code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
11509 @code{__builtin_printf_unlocked}, @code{__builtin_putc},
11510 @code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
11511 @code{__builtin_putc_unlocked}, @code{__builtin_puts},
11512 @code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
11513 @code{__builtin_vprintf}
11515 @item @code{fclose}
11516 @item @code{ferror}
11518 @item @code{fgets_unlocked}
11519 @item @code{fileno}
11522 @item @code{getchar}
11523 @item @code{fprintf}
11524 @item @code{printf}
11525 @item @code{fwrite}
11529 and of the following functions:
11532 @item The built-in functions @code{__builtin_expect},
11533 @code{__builtin_expect_with_probability}, @code{__builtin_strchr},
11534 @code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
11535 @code{__builtin_strlen}, @code{__builtin_va_copy}, and
11536 @code{__builtin_va_start}
11537 @item The GNU extensions @code{error} and @code{error_at_line}
11538 @item @code{getpass}
11539 @item @code{longjmp}
11540 @item @code{putenv}
11541 @item @code{setjmp}
11542 @item @code{siglongjmp}
11543 @item @code{signal}
11544 @item @code{sigsetjmp}
11545 @item @code{strcat}
11546 @item @code{strchr}
11547 @item @code{strlen}
11550 In addition, various functions with an @code{__analyzer_} prefix have
11551 special meaning to the analyzer, described in the GCC Internals manual.
11553 Pertinent parameters for controlling the exploration are:
11555 @item @option{--param analyzer-bb-explosion-factor=@var{value}}
11556 @item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
11557 @item @option{--param analyzer-max-recursion-depth=@var{value}}
11558 @item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
11561 The following options control the analyzer.
11565 @opindex fanalyzer-call-summaries
11566 @opindex fno-analyzer-call-summaries
11567 @item -fanalyzer-call-summaries
11568 Simplify interprocedural analysis by computing the effect of certain calls,
11569 rather than exploring all paths through the function from callsite to each
11572 If enabled, call summaries are only used for functions with more than one
11573 call site, and that are sufficiently complicated (as per
11574 @option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
11576 @opindex fanalyzer-checker
11577 @item -fanalyzer-checker=@var{name}
11578 Restrict the analyzer to run just the named checker, and enable it.
11580 @opindex fanalyzer-debug-text-art
11581 @opindex fno-analyzer-debug-text-art
11582 @item -fanalyzer-debug-text-art-headings
11583 This option is intended for analyzer developers. If enabled,
11584 the analyzer will add extra annotations to any diagrams it generates.
11586 @opindex fanalyzer-feasibility
11587 @opindex fno-analyzer-feasibility
11588 @item -fno-analyzer-feasibility
11589 This option is intended for analyzer developers.
11591 By default the analyzer verifies that there is a feasible control flow path
11592 for each diagnostic it emits: that the conditions that hold are not mutually
11593 exclusive. Diagnostics for which no feasible path can be found are rejected.
11594 This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
11595 debugging issues in this code.
11597 @opindex fanalyzer-fine-grained
11598 @opindex fno-analyzer-fine-grained
11599 @item -fanalyzer-fine-grained
11600 This option is intended for analyzer developers.
11602 Internally the analyzer builds an ``exploded graph'' that combines
11603 control flow graphs with data flow information.
11605 By default, an edge in this graph can contain the effects of a run
11606 of multiple statements within a basic block. With
11607 @option{-fanalyzer-fine-grained}, each statement gets its own edge.
11609 @opindex fanalyzer-show-duplicate-count
11610 @opindex fno-analyzer-show-duplicate-count
11611 @item -fanalyzer-show-duplicate-count
11612 This option is intended for analyzer developers: if multiple diagnostics
11613 have been detected as being duplicates of each other, it emits a note when
11614 reporting the best diagnostic, giving the number of additional diagnostics
11615 that were suppressed by the deduplication logic.
11617 @opindex fanalyzer-show-events-in-system-headers
11618 @opindex fno-analyzer-show-events-in-system-headers
11619 @item -fanalyzer-show-events-in-system-headers
11620 By default the analyzer emits simplified diagnostics paths by hiding
11621 events fully located within a system header.
11622 With @option{-fanalyzer-show-events-in-system-headers} such
11623 events are no longer suppressed.
11625 @opindex fanalyzer-state-merge
11626 @opindex fno-analyzer-state-merge
11627 @item -fno-analyzer-state-merge
11628 This option is intended for analyzer developers.
11630 By default the analyzer attempts to simplify analysis by merging
11631 sufficiently similar states at each program point as it builds its
11632 ``exploded graph''. With @option{-fno-analyzer-state-merge} this
11633 merging can be suppressed, for debugging state-handling issues.
11635 @opindex fanalyzer-state-purge
11636 @opindex fno-analyzer-state-purge
11637 @item -fno-analyzer-state-purge
11638 This option is intended for analyzer developers.
11640 By default the analyzer attempts to simplify analysis by purging
11641 aspects of state at a program point that appear to no longer be relevant
11642 e.g. the values of locals that aren't accessed later in the function
11643 and which aren't relevant to leak analysis.
11645 With @option{-fno-analyzer-state-purge} this purging of state can
11646 be suppressed, for debugging state-handling issues.
11648 @opindex fanalyzer-suppress-followups
11649 @opindex fno-analyzer-suppress-followups
11650 @item -fno-analyzer-suppress-followups
11651 This option is intended for analyzer developers.
11653 By default the analyzer will stop exploring an execution path after
11654 encountering certain diagnostics, in order to avoid potentially issuing a
11655 cascade of follow-up diagnostics.
11657 The diagnostics that terminate analysis along a path are:
11660 @item @option{-Wanalyzer-null-argument}
11661 @item @option{-Wanalyzer-null-dereference}
11662 @item @option{-Wanalyzer-use-after-free}
11663 @item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
11664 @item @option{-Wanalyzer-use-of-uninitialized-value}
11667 With @option{-fno-analyzer-suppress-followups} the analyzer will
11668 continue to explore such paths even after such diagnostics, which may
11669 be helpful for debugging issues in the analyzer, or for microbenchmarks
11670 for detecting undefined behavior.
11672 @opindex fanalyzer-transitivity
11673 @opindex fno-analyzer-transitivity
11674 @item -fanalyzer-transitivity
11675 This option enables transitivity of constraints within the analyzer.
11677 @opindex fanalyzer-undo-inlining
11678 @opindex fno-analyzer-undo-inlining
11679 @item -fno-analyzer-undo-inlining
11680 This option is intended for analyzer developers.
11682 @option{-fanalyzer} runs relatively late compared to other code analysis
11683 tools, and some optimizations have already been applied to the code. In
11684 particular function inlining may have occurred, leading to the
11685 interprocedural execution paths emitted by the analyzer containing
11686 function frames that don't correspond to those in the original source
11689 By default the analyzer attempts to reconstruct the original function
11690 frames, and to emit events showing the inlined calls.
11692 With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11693 the original frame information can be be disabled, which may be of help
11694 when debugging issues in the analyzer.
11696 @item -fanalyzer-verbose-edges
11697 This option is intended for analyzer developers. It enables more
11698 verbose, lower-level detail in the descriptions of control flow
11699 within diagnostic paths.
11701 @item -fanalyzer-verbose-state-changes
11702 This option is intended for analyzer developers. It enables more
11703 verbose, lower-level detail in the descriptions of events relating
11704 to state machines within diagnostic paths.
11706 @item -fanalyzer-verbosity=@var{level}
11707 This option controls the complexity of the control flow paths that are
11708 emitted for analyzer diagnostics.
11710 The @var{level} can be one of:
11714 At this level, interprocedural call and return events are displayed,
11715 along with the most pertinent state-change events relating to
11716 a diagnostic. For example, for a double-@code{free} diagnostic,
11717 both calls to @code{free} will be shown.
11720 As per the previous level, but also show events for the entry
11724 As per the previous level, but also show events relating to
11725 control flow that are significant to triggering the issue
11726 (e.g. ``true path taken'' at a conditional).
11728 This level is the default.
11731 As per the previous level, but show all control flow events, not
11732 just significant ones.
11735 This level is intended for analyzer developers; it adds various
11736 other events intended for debugging the analyzer.
11740 @opindex fdump-analyzer
11741 @item -fdump-analyzer
11742 Dump internal details about what the analyzer is doing to
11743 @file{@var{file}.analyzer.txt}.
11744 @option{-fdump-analyzer-stderr} overrides this option.
11746 @opindex fdump-analyzer-stderr
11747 @item -fdump-analyzer-stderr
11748 Dump internal details about what the analyzer is doing to stderr.
11749 This option overrides @option{-fdump-analyzer}.
11751 @opindex fdump-analyzer-callgraph
11752 @item -fdump-analyzer-callgraph
11753 Dump a representation of the call graph suitable for viewing with
11754 GraphViz to @file{@var{file}.callgraph.dot}.
11756 @opindex fdump-analyzer-exploded-graph
11757 @item -fdump-analyzer-exploded-graph
11758 Dump a representation of the ``exploded graph'' suitable for viewing with
11759 GraphViz to @file{@var{file}.eg.dot}.
11760 Nodes are color-coded based on state-machine states to emphasize
11763 @opindex dump-analyzer-exploded-nodes
11764 @item -fdump-analyzer-exploded-nodes
11765 Emit diagnostics showing where nodes in the ``exploded graph'' are
11766 in relation to the program source.
11768 @opindex dump-analyzer-exploded-nodes-2
11769 @item -fdump-analyzer-exploded-nodes-2
11770 Dump a textual representation of the ``exploded graph'' to
11771 @file{@var{file}.eg.txt}.
11773 @opindex dump-analyzer-exploded-nodes-3
11774 @item -fdump-analyzer-exploded-nodes-3
11775 Dump a textual representation of the ``exploded graph'' to
11776 one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11777 This is typically a large number of dump files.
11779 @opindex fdump-analyzer-exploded-paths
11780 @item -fdump-analyzer-exploded-paths
11781 Dump a textual representation of the ``exploded path'' for each
11782 diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11784 @opindex dump-analyzer-feasibility
11785 @item -fdump-analyzer-feasibility
11786 Dump internal details about the analyzer's search for feasible paths.
11787 The details are written in a form suitable for viewing with GraphViz
11788 to filenames of the form @file{@var{file}.*.fg.dot},
11789 @file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11791 @opindex dump-analyzer-infinite-loop
11792 @item -fdump-analyzer-infinite-loop
11793 Dump internal details about the analyzer's search for infinite loops.
11794 The details are written in a form suitable for viewing with GraphViz
11795 to filenames of the form @file{@var{file}.*.infinite-loop.dot}.
11797 @opindex fdump-analyzer-json
11798 @item -fdump-analyzer-json
11799 Dump a compressed JSON representation of analyzer internals to
11800 @file{@var{file}.analyzer.json.gz}. The precise format is subject
11803 @opindex fdump-analyzer-state-purge
11804 @item -fdump-analyzer-state-purge
11805 As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11806 ``supergraph'' suitable for viewing with GraphViz, but annotate the
11807 graph with information on what state will be purged at each node.
11808 The graph is written to @file{@var{file}.state-purge.dot}.
11810 @opindex fdump-analyzer-supergraph
11811 @item -fdump-analyzer-supergraph
11812 Dump representations of the ``supergraph'' suitable for viewing with
11813 GraphViz to @file{@var{file}.supergraph.dot} and to
11814 @file{@var{file}.supergraph-eg.dot}. These show all of the
11815 control flow graphs in the program, with interprocedural edges for
11816 calls and returns. The second dump contains annotations showing nodes
11817 in the ``exploded graph'' and diagnostics associated with them.
11819 @opindex fdump-analyzer-untracked
11820 @item -fdump-analyzer-untracked
11821 Emit custom warnings with internal details intended for analyzer developers.
11825 @node Debugging Options
11826 @section Options for Debugging Your Program
11827 @cindex options, debugging
11828 @cindex debugging information options
11830 To tell GCC to emit extra information for use by a debugger, in almost
11831 all cases you need only to add @option{-g} to your other options. Some debug
11832 formats can co-exist (like DWARF with CTF) when each of them is enabled
11833 explicitly by adding the respective command line option to your other options.
11835 GCC allows you to use @option{-g} with
11836 @option{-O}. The shortcuts taken by optimized code may occasionally
11837 be surprising: some variables you declared may not exist
11838 at all; flow of control may briefly move where you did not expect it;
11839 some statements may not be executed because they compute constant
11840 results or their values are already at hand; some statements may
11841 execute in different places because they have been moved out of loops.
11842 Nevertheless it is possible to debug optimized output. This makes
11843 it reasonable to use the optimizer for programs that might have bugs.
11845 If you are not using some other optimization option, consider
11846 using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11847 With no @option{-O} option at all, some compiler passes that collect
11848 information useful for debugging do not run at all, so that
11849 @option{-Og} may result in a better debugging experience.
11854 Produce debugging information in the operating system's native format
11855 (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11858 On most systems that use stabs format, @option{-g} enables use of extra
11859 debugging information that only GDB can use; this extra information
11860 makes debugging work better in GDB but probably makes other debuggers
11861 crash or refuse to read the program. If you want to control for certain whether
11862 to generate the extra information, use @option{-gvms} (see below).
11866 Produce debugging information for use by GDB@. This means to use the
11867 most expressive format available (DWARF, stabs, or the native format
11868 if neither of those are supported), including GDB extensions if at all
11873 @itemx -gdwarf-@var{version}
11874 Produce debugging information in DWARF format (if that is supported).
11875 The value of @var{version} may be either 2, 3, 4 or 5; the default
11876 version for most targets is 5 (with the exception of VxWorks, TPF and
11877 Darwin / macOS, which default to version 2, and AIX, which defaults
11880 Note that with DWARF Version 2, some ports require and always
11881 use some non-conflicting DWARF 3 extensions in the unwind tables.
11883 Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11884 for maximum benefit. Version 5 requires GDB 8.0 or higher.
11886 GCC no longer supports DWARF Version 1, which is substantially
11887 different than Version 2 and later. For historical reasons, some
11888 other DWARF-related options such as
11889 @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11890 in their names, but apply to all currently-supported versions of DWARF.
11894 Request BTF debug information. BTF is the default debugging format for the
11895 eBPF target. On other targets, like x86, BTF debug information can be
11896 generated along with DWARF debug information when both of the debug formats are
11897 enabled explicitly via their respective command line options.
11901 @itemx -gctf@var{level}
11902 Request CTF debug information and use level to specify how much CTF debug
11903 information should be produced. If @option{-gctf} is specified
11904 without a value for level, the default level of CTF debug information is 2.
11906 CTF debug information can be generated along with DWARF debug information when
11907 both of the debug formats are enabled explicitly via their respective command
11910 Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11911 negates @option{-gctf}.
11913 Level 1 produces CTF information for tracebacks only. This includes callsite
11914 information, but does not include type information.
11916 Level 2 produces type information for entities (functions, data objects etc.)
11917 at file-scope or global-scope only.
11921 Produce debugging information in Alpha/VMS debug format (if that is
11922 supported). This is the format used by DEBUG on Alpha/VMS systems.
11926 Produce debugging information in CodeView debug format (if that is
11927 supported). This is the format used by Microsoft Visual C++ on
11930 @item -g@var{level}
11931 @itemx -ggdb@var{level}
11932 @itemx -gvms@var{level}
11933 Request debugging information and also use @var{level} to specify how
11934 much information. The default level is 2.
11936 Level 0 produces no debug information at all. Thus, @option{-g0} negates
11939 Level 1 produces minimal information, enough for making backtraces in
11940 parts of the program that you don't plan to debug. This includes
11941 descriptions of functions and external variables, and line number
11942 tables, but no information about local variables.
11944 Level 3 includes extra information, such as all the macro definitions
11945 present in the program. Some debuggers support macro expansion when
11946 you use @option{-g3}.
11948 If you use multiple @option{-g} options, with or without level numbers,
11949 the last such option is the one that is effective.
11951 @option{-gdwarf} does not accept a concatenated debug level, to avoid
11952 confusion with @option{-gdwarf-@var{level}}.
11953 Instead use an additional @option{-g@var{level}} option to change the
11954 debug level for DWARF.
11956 @opindex feliminate-unused-debug-symbols
11957 @opindex fno-eliminate-unused-debug-symbols
11958 @item -fno-eliminate-unused-debug-symbols
11959 By default, no debug information is produced for symbols that are not actually
11960 used. Use this option if you want debug information for all symbols.
11962 @opindex femit-class-debug-always
11963 @item -femit-class-debug-always
11964 Instead of emitting debugging information for a C++ class in only one
11965 object file, emit it in all object files using the class. This option
11966 should be used only with debuggers that are unable to handle the way GCC
11967 normally emits debugging information for classes because using this
11968 option increases the size of debugging information by as much as a
11971 @opindex fmerge-debug-strings
11972 @opindex fno-merge-debug-strings
11973 @item -fno-merge-debug-strings
11974 Direct the linker to not merge together strings in the debugging
11975 information that are identical in different object files. Merging is
11976 not supported by all assemblers or linkers. Merging decreases the size
11977 of the debug information in the output file at the cost of increasing
11978 link processing time. Merging is enabled by default.
11980 @opindex fdebug-prefix-map
11981 @item -fdebug-prefix-map=@var{old}=@var{new}
11982 When compiling files residing in directory @file{@var{old}}, record
11983 debugging information describing them as if the files resided in
11984 directory @file{@var{new}} instead. This can be used to replace a
11985 build-time path with an install-time path in the debug info. It can
11986 also be used to change an absolute path to a relative path by using
11987 @file{.} for @var{new}. This can give more reproducible builds, which
11988 are location independent, but may require an extra command to tell GDB
11989 where to find the source files. See also @option{-ffile-prefix-map}
11990 and @option{-fcanon-prefix-map}.
11992 @opindex fvar-tracking
11993 @item -fvar-tracking
11994 Run variable tracking pass. It computes where variables are stored at each
11995 position in code. Better debugging information is then generated
11996 (if the debugging information format supports this information).
11998 It is enabled by default when compiling with optimization (@option{-Os},
11999 @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
12000 the debug info format supports it.
12002 @opindex fvar-tracking-assignments
12003 @opindex fno-var-tracking-assignments
12004 @item -fvar-tracking-assignments
12005 Annotate assignments to user variables early in the compilation and
12006 attempt to carry the annotations over throughout the compilation all the
12007 way to the end, in an attempt to improve debug information while
12008 optimizing. Use of @option{-gdwarf-4} is recommended along with it.
12010 It can be enabled even if var-tracking is disabled, in which case
12011 annotations are created and maintained, but discarded at the end.
12012 By default, this flag is enabled together with @option{-fvar-tracking},
12013 except when selective scheduling is enabled.
12015 @opindex gsplit-dwarf
12016 @item -gsplit-dwarf
12017 If DWARF debugging information is enabled, separate as much debugging
12018 information as possible into a separate output file with the extension
12019 @file{.dwo}. This option allows the build system to avoid linking files with
12020 debug information. To be useful, this option requires a debugger capable of
12021 reading @file{.dwo} files.
12027 If DWARF debugging information is enabled, the @option{-gdwarf32} selects
12028 the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
12029 DWARF format. The default is target specific, on most targets it is
12030 @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
12031 can't support more than 2GiB of debug information in any of the DWARF
12032 debug information sections. The 64-bit DWARF format allows larger debug
12033 information and might not be well supported by all consumers yet.
12035 @opindex gdescribe-dies
12036 @item -gdescribe-dies
12037 Add description attributes to some DWARF DIEs that have no name attribute,
12038 such as artificial variables, external references and call site
12043 Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
12045 @opindex ggnu-pubnames
12046 @item -ggnu-pubnames
12047 Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
12048 suitable for conversion into a GDB@ index. This option is only useful
12049 with a linker that can produce GDB@ index version 7.
12051 @opindex fdebug-types-section
12052 @opindex fno-debug-types-section
12053 @item -fdebug-types-section
12054 When using DWARF Version 4 or higher, type DIEs can be put into
12055 their own @code{.debug_types} section instead of making them part of the
12056 @code{.debug_info} section. It is more efficient to put them in a separate
12057 comdat section since the linker can then remove duplicates.
12058 But not all DWARF consumers support @code{.debug_types} sections yet
12059 and on some objects @code{.debug_types} produces larger instead of smaller
12060 debugging information.
12062 @opindex grecord-gcc-switches
12063 @opindex gno-record-gcc-switches
12064 @item -grecord-gcc-switches
12065 @itemx -gno-record-gcc-switches
12066 This switch causes the command-line options used to invoke the
12067 compiler that may affect code generation to be appended to the
12068 DW_AT_producer attribute in DWARF debugging information. The options
12069 are concatenated with spaces separating them from each other and from
12070 the compiler version.
12071 It is enabled by default.
12072 See also @option{-frecord-gcc-switches} for another
12073 way of storing compiler options into the object file.
12075 @opindex gstrict-dwarf
12076 @item -gstrict-dwarf
12077 Disallow using extensions of later DWARF standard version than selected
12078 with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
12079 DWARF extensions from later standard versions is allowed.
12081 @opindex gno-strict-dwarf
12082 @item -gno-strict-dwarf
12083 Allow using extensions of later DWARF standard version than selected with
12084 @option{-gdwarf-@var{version}}.
12086 @opindex gas-loc-support
12087 @item -gas-loc-support
12088 Inform the compiler that the assembler supports @code{.loc} directives.
12089 It may then use them for the assembler to generate DWARF2+ line number
12092 This is generally desirable, because assembler-generated line-number
12093 tables are a lot more compact than those the compiler can generate
12096 This option will be enabled by default if, at GCC configure time, the
12097 assembler was found to support such directives.
12099 @opindex gno-as-loc-support
12100 @item -gno-as-loc-support
12101 Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
12102 line number tables are to be generated.
12104 @opindex gas-locview-support
12105 @item -gas-locview-support
12106 Inform the compiler that the assembler supports @code{view} assignment
12107 and reset assertion checking in @code{.loc} directives.
12109 This option will be enabled by default if, at GCC configure time, the
12110 assembler was found to support them.
12112 @item -gno-as-locview-support
12113 Force GCC to assign view numbers internally, if
12114 @option{-gvariable-location-views} are explicitly requested.
12116 @opindex gcolumn-info
12117 @opindex gno-column-info
12118 @item -gcolumn-info
12119 @itemx -gno-column-info
12120 Emit location column information into DWARF debugging information, rather
12121 than just file and line.
12122 This option is enabled by default.
12124 @opindex gstatement-frontiers
12125 @opindex gno-statement-frontiers
12126 @item -gstatement-frontiers
12127 @itemx -gno-statement-frontiers
12128 This option causes GCC to create markers in the internal representation
12129 at the beginning of statements, and to keep them roughly in place
12130 throughout compilation, using them to guide the output of @code{is_stmt}
12131 markers in the line number table. This is enabled by default when
12132 compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
12133 @dots{}), and outputting DWARF 2 debug information at the normal level.
12135 @opindex gvariable-location-views
12136 @opindex gvariable-location-views=incompat5
12137 @opindex gno-variable-location-views
12138 @item -gvariable-location-views
12139 @itemx -gvariable-location-views=incompat5
12140 @itemx -gno-variable-location-views
12141 Augment variable location lists with progressive view numbers implied
12142 from the line number table. This enables debug information consumers to
12143 inspect state at certain points of the program, even if no instructions
12144 associated with the corresponding source locations are present at that
12145 point. If the assembler lacks support for view numbers in line number
12146 tables, this will cause the compiler to emit the line number table,
12147 which generally makes them somewhat less compact. The augmented line
12148 number tables and location lists are fully backward-compatible, so they
12149 can be consumed by debug information consumers that are not aware of
12150 these augmentations, but they won't derive any benefit from them either.
12152 This is enabled by default when outputting DWARF 2 debug information at
12153 the normal level, as long as there is assembler support,
12154 @option{-fvar-tracking-assignments} is enabled and
12155 @option{-gstrict-dwarf} is not. When assembler support is not
12156 available, this may still be enabled, but it will force GCC to output
12157 internal line number tables, and if
12158 @option{-ginternal-reset-location-views} is not enabled, that will most
12159 certainly lead to silently mismatching location views.
12161 There is a proposed representation for view numbers that is not backward
12162 compatible with the location list format introduced in DWARF 5, that can
12163 be enabled with @option{-gvariable-location-views=incompat5}. This
12164 option may be removed in the future, is only provided as a reference
12165 implementation of the proposed representation. Debug information
12166 consumers are not expected to support this extended format, and they
12167 would be rendered unable to decode location lists using it.
12169 @opindex ginternal-reset-location-views
12170 @opindex gno-internal-reset-location-views
12171 @item -ginternal-reset-location-views
12172 @itemx -gno-internal-reset-location-views
12173 Attempt to determine location views that can be omitted from location
12174 view lists. This requires the compiler to have very accurate insn
12175 length estimates, which isn't always the case, and it may cause
12176 incorrect view lists to be generated silently when using an assembler
12177 that does not support location view lists. The GNU assembler will flag
12178 any such error as a @code{view number mismatch}. This is only enabled
12179 on ports that define a reliable estimation function.
12181 @opindex ginline-points
12182 @opindex gno-inline-points
12183 @item -ginline-points
12184 @itemx -gno-inline-points
12185 Generate extended debug information for inlined functions. Location
12186 view tracking markers are inserted at inlined entry points, so that
12187 address and view numbers can be computed and output in debug
12188 information. This can be enabled independently of location views, in
12189 which case the view numbers won't be output, but it can only be enabled
12190 along with statement frontiers, and it is only enabled by default if
12191 location views are enabled.
12194 @item -gz@r{[}=@var{type}@r{]}
12195 Produce compressed debug sections in DWARF format, if that is supported.
12196 If @var{type} is not given, the default type depends on the capabilities
12197 of the assembler and linker used. @var{type} may be one of
12198 @samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
12199 compression in ELF gABI format). If the linker doesn't support writing
12200 compressed debug sections, the option is rejected. Otherwise, if the
12201 assembler does not support them, @option{-gz} is silently ignored when
12202 producing object files.
12204 @opindex femit-struct-debug-baseonly
12205 @item -femit-struct-debug-baseonly
12206 Emit debug information for struct-like types
12207 only when the base name of the compilation source file
12208 matches the base name of file in which the struct is defined.
12210 This option substantially reduces the size of debugging information,
12211 but at significant potential loss in type information to the debugger.
12212 See @option{-femit-struct-debug-reduced} for a less aggressive option.
12213 See @option{-femit-struct-debug-detailed} for more detailed control.
12215 This option works only with DWARF debug output.
12217 @opindex femit-struct-debug-reduced
12218 @item -femit-struct-debug-reduced
12219 Emit debug information for struct-like types
12220 only when the base name of the compilation source file
12221 matches the base name of file in which the type is defined,
12222 unless the struct is a template or defined in a system header.
12224 This option significantly reduces the size of debugging information,
12225 with some potential loss in type information to the debugger.
12226 See @option{-femit-struct-debug-baseonly} for a more aggressive option.
12227 See @option{-femit-struct-debug-detailed} for more detailed control.
12229 This option works only with DWARF debug output.
12231 @opindex femit-struct-debug-detailed
12232 @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
12233 Specify the struct-like types
12234 for which the compiler generates debug information.
12235 The intent is to reduce duplicate struct debug information
12236 between different object files within the same program.
12238 This option is a detailed version of
12239 @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
12240 which serves for most needs.
12242 A specification has the syntax@*
12243 [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
12245 The optional first word limits the specification to
12246 structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
12247 A struct type is used directly when it is the type of a variable, member.
12248 Indirect uses arise through pointers to structs.
12249 That is, when use of an incomplete struct is valid, the use is indirect.
12251 @samp{struct one direct; struct two * indirect;}.
12253 The optional second word limits the specification to
12254 ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
12255 Generic structs are a bit complicated to explain.
12256 For C++, these are non-explicit specializations of template classes,
12257 or non-template classes within the above.
12258 Other programming languages have generics,
12259 but @option{-femit-struct-debug-detailed} does not yet implement them.
12261 The third word specifies the source files for those
12262 structs for which the compiler should emit debug information.
12263 The values @samp{none} and @samp{any} have the normal meaning.
12264 The value @samp{base} means that
12265 the base of name of the file in which the type declaration appears
12266 must match the base of the name of the main compilation file.
12267 In practice, this means that when compiling @file{foo.c}, debug information
12268 is generated for types declared in that file and @file{foo.h},
12269 but not other header files.
12270 The value @samp{sys} means those types satisfying @samp{base}
12271 or declared in system or compiler headers.
12273 You may need to experiment to determine the best settings for your application.
12275 The default is @option{-femit-struct-debug-detailed=all}.
12277 This option works only with DWARF debug output.
12279 @opindex fdwarf2-cfi-asm
12280 @opindex fno-dwarf2-cfi-asm
12281 @item -fno-dwarf2-cfi-asm
12282 Emit DWARF unwind info as compiler generated @code{.eh_frame} section
12283 instead of using GAS @code{.cfi_*} directives.
12285 @opindex feliminate-unused-debug-types
12286 @opindex fno-eliminate-unused-debug-types
12287 @item -fno-eliminate-unused-debug-types
12288 Normally, when producing DWARF output, GCC avoids producing debug symbol
12289 output for types that are nowhere used in the source file being compiled.
12290 Sometimes it is useful to have GCC emit debugging
12291 information for all types declared in a compilation
12292 unit, regardless of whether or not they are actually used
12293 in that compilation unit, for example
12294 if, in the debugger, you want to cast a value to a type that is
12295 not actually used in your program (but is declared). More often,
12296 however, this results in a significant amount of wasted space.
12299 @node Optimize Options
12300 @section Options That Control Optimization
12301 @cindex optimize options
12302 @cindex options, optimization
12304 These options control various sorts of optimizations.
12306 Without any optimization option, the compiler's goal is to reduce the
12307 cost of compilation and to make debugging produce the expected
12308 results. Statements are independent: if you stop the program with a
12309 breakpoint between statements, you can then assign a new value to any
12310 variable or change the program counter to any other statement in the
12311 function and get exactly the results you expect from the source
12314 Turning on optimization flags makes the compiler attempt to improve
12315 the performance and/or code size at the expense of compilation time
12316 and possibly the ability to debug the program.
12318 The compiler performs optimization based on the knowledge it has of the
12319 program. Compiling multiple files at once to a single output file mode allows
12320 the compiler to use information gained from all of the files when compiling
12323 Not all optimizations are controlled directly by a flag. Only
12324 optimizations that have a flag are listed in this section.
12326 Most optimizations are completely disabled at @option{-O0} or if an
12327 @option{-O} level is not set on the command line, even if individual
12328 optimization flags are specified. Similarly, @option{-Og} suppresses
12329 many optimization passes.
12331 Depending on the target and how GCC was configured, a slightly different
12332 set of optimizations may be enabled at each @option{-O} level than
12333 those listed here. You can invoke GCC with @option{-Q --help=optimizers}
12334 to find out the exact set of optimizations that are enabled at each level.
12335 @xref{Overall Options}, for examples.
12342 Optimize. Optimizing compilation takes somewhat more time, and a lot
12343 more memory for a large function.
12345 With @option{-O}, the compiler tries to reduce code size and execution
12346 time, without performing any optimizations that take a great deal of
12349 @c Note that in addition to the default_options_table list in opts.cc,
12350 @c several optimization flags default to true but control optimization
12351 @c passes that are explicitly disabled at -O0.
12353 @option{-O} turns on the following optimization flags:
12355 @c Please keep the following list alphabetized.
12356 @gccoptlist{-fauto-inc-dec
12358 -fcombine-stack-adjustments
12365 -fforward-propagate
12366 -fguess-branch-probability
12369 -finline-functions-called-once
12374 -fipa-reference-addressable
12376 -fmove-loop-invariants
12378 -fomit-frame-pointer
12381 -fshrink-wrap-separate
12388 -ftree-coalesce-vars
12391 -ftree-dominator-opts
12406 Optimize even more. GCC performs nearly all supported optimizations
12407 that do not involve a space-speed tradeoff.
12408 As compared to @option{-O}, this option increases both compilation time
12409 and the performance of the generated code.
12411 @option{-O2} turns on all optimization flags specified by @option{-O1}. It
12412 also turns on the following optimization flags:
12414 @c Please keep the following list alphabetized!
12415 @gccoptlist{-falign-functions -falign-jumps
12416 -falign-labels -falign-loops
12420 -fcse-follow-jumps -fcse-skip-blocks
12421 -fdelete-null-pointer-checks
12422 -fdevirtualize -fdevirtualize-speculatively
12423 -fexpensive-optimizations
12426 -fhoist-adjacent-loads
12428 -finline-small-functions
12429 -findirect-inlining
12430 -fipa-bit-cp -fipa-cp -fipa-icf
12431 -fipa-ra -fipa-sra -fipa-vrp
12432 -fisolate-erroneous-paths-dereference
12434 -foptimize-sibling-calls
12438 -freorder-blocks-algorithm=stc
12439 -freorder-blocks-and-partition -freorder-functions
12440 -frerun-cse-after-loop
12441 -fschedule-insns -fschedule-insns2
12442 -fsched-interblock -fsched-spec
12446 -ftree-builtin-call-dce
12447 -ftree-loop-vectorize
12449 -ftree-slp-vectorize
12450 -ftree-switch-conversion -ftree-tail-merge
12452 -fvect-cost-model=very-cheap}
12454 Please note the warning under @option{-fgcse} about
12455 invoking @option{-O2} on programs that use computed gotos.
12459 Optimize yet more. @option{-O3} turns on all optimizations specified
12460 by @option{-O2} and also turns on the following optimization flags:
12462 @c Please keep the following list alphabetized!
12463 @gccoptlist{-fgcse-after-reload
12466 -floop-unroll-and-jam
12468 -fpredictive-commoning
12471 -ftree-loop-distribution
12474 -fvect-cost-model=dynamic
12475 -fversion-loops-for-strides}
12479 Reduce compilation time and make debugging produce the expected
12480 results. This is the default.
12484 Optimize for size. @option{-Os} enables all @option{-O2} optimizations
12485 except those that often increase code size:
12487 @gccoptlist{-falign-functions -falign-jumps
12488 -falign-labels -falign-loops
12489 -fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
12491 It also enables @option{-finline-functions}, causes the compiler to tune for
12492 code size rather than execution speed, and performs further optimizations
12493 designed to reduce code size.
12497 Disregard strict standards compliance. @option{-Ofast} enables all
12498 @option{-O3} optimizations. It also enables optimizations that are not
12499 valid for all standard-compliant programs.
12500 It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
12501 and the Fortran-specific @option{-fstack-arrays}, unless
12502 @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
12503 It turns off @option{-fsemantic-interposition}.
12507 Optimize debugging experience. @option{-Og} should be the optimization
12508 level of choice for the standard edit-compile-debug cycle, offering
12509 a reasonable level of optimization while maintaining fast compilation
12510 and a good debugging experience. It is a better choice than @option{-O0}
12511 for producing debuggable code because some compiler passes
12512 that collect debug information are disabled at @option{-O0}.
12514 Like @option{-O0}, @option{-Og} completely disables a number of
12515 optimization passes so that individual options controlling them have
12516 no effect. Otherwise @option{-Og} enables all @option{-O1}
12517 optimization flags except for those that may interfere with debugging:
12519 @gccoptlist{-fbranch-count-reg -fdelayed-branch
12520 -fdse -fif-conversion -fif-conversion2
12521 -finline-functions-called-once
12522 -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt
12523 -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
12527 Optimize aggressively for size rather than speed. This may increase
12528 the number of instructions executed if those instructions require
12529 fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
12530 including enabling most @option{-O2} optimizations.
12534 If you use multiple @option{-O} options, with or without level numbers,
12535 the last such option is the one that is effective.
12537 Options of the form @option{-f@var{flag}} specify machine-independent
12538 flags. Most flags have both positive and negative forms; the negative
12539 form of @option{-ffoo} is @option{-fno-foo}. In the table
12540 below, only one of the forms is listed---the one you typically
12541 use. You can figure out the other form by either removing @samp{no-}
12544 The following options control specific optimizations. They are either
12545 activated by @option{-O} options or are related to ones that are. You
12546 can use the following flags in the rare cases when ``fine-tuning'' of
12547 optimizations to be performed is desired.
12550 @opindex fno-defer-pop
12551 @opindex fdefer-pop
12552 @item -fno-defer-pop
12553 For machines that must pop arguments after a function call, always pop
12554 the arguments as soon as each function returns.
12555 At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
12556 this allows the compiler to let arguments accumulate on the stack for several
12557 function calls and pop them all at once.
12559 @opindex fforward-propagate
12560 @item -fforward-propagate
12561 Perform a forward propagation pass on RTL@. The pass tries to combine two
12562 instructions and checks if the result can be simplified. If loop unrolling
12563 is active, two passes are performed and the second is scheduled after
12566 This option is enabled by default at optimization levels @option{-O1},
12567 @option{-O2}, @option{-O3}, @option{-Os}.
12569 @opindex ffp-contract
12570 @item -ffp-contract=@var{style}
12571 @option{-ffp-contract=off} disables floating-point expression contraction.
12572 @option{-ffp-contract=fast} enables floating-point expression contraction
12573 such as forming of fused multiply-add operations if the target has
12574 native support for them.
12575 @option{-ffp-contract=on} enables floating-point expression contraction
12576 if allowed by the language standard. This is implemented for C and C++,
12577 where it enables contraction within one expression, but not across
12578 different statements.
12580 The default is @option{-ffp-contract=off} for C in a standards compliant mode
12581 (@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise.
12583 @opindex fomit-frame-pointer
12584 @item -fomit-frame-pointer
12585 Omit the frame pointer in functions that don't need one. This avoids the
12586 instructions to save, set up and restore the frame pointer; on many targets
12587 it also makes an extra register available.
12589 On some targets this flag has no effect because the standard calling sequence
12590 always uses a frame pointer, so it cannot be omitted.
12592 Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
12593 is used in all functions. Several targets always omit the frame pointer in
12596 Enabled by default at @option{-O1} and higher.
12598 @opindex foptimize-sibling-calls
12599 @item -foptimize-sibling-calls
12600 Optimize sibling and tail recursive calls.
12602 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12604 @opindex foptimize-strlen
12605 @item -foptimize-strlen
12606 Optimize various standard C string functions (e.g.@: @code{strlen},
12607 @code{strchr} or @code{strcpy}) and
12608 their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
12610 Enabled at levels @option{-O2}, @option{-O3}.
12612 @opindex finline-stringops
12613 @item -finline-stringops[=@var{fn}]
12614 Expand memory and string operations (for now, only @code{memset})
12615 inline, even when the length is variable or big enough as to require
12616 looping. This is most useful along with @option{-ffreestanding} and
12617 @option{-fno-builtin}.
12619 In some circumstances, it enables the compiler to generate code that
12620 takes advantage of known alignment and length multipliers, but even then
12621 it may be less efficient than optimized runtime implementations, and
12622 grow code size so much that even a less performant but shared
12623 implementation runs faster due to better use of code caches. This
12624 option is disabled by default.
12626 @opindex fno-inline
12629 Do not expand any functions inline apart from those marked with
12630 the @code{always_inline} attribute. This is the default when not
12633 Single functions can be exempted from inlining by marking them
12634 with the @code{noinline} attribute.
12636 @opindex finline-small-functions
12637 @item -finline-small-functions
12638 Integrate functions into their callers when their body is smaller than expected
12639 function call code (so overall size of program gets smaller). The compiler
12640 heuristically decides which functions are simple enough to be worth integrating
12641 in this way. This inlining applies to all functions, even those not declared
12644 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12646 @opindex findirect-inlining
12647 @item -findirect-inlining
12648 Inline also indirect calls that are discovered to be known at compile
12649 time thanks to previous inlining. This option has any effect only
12650 when inlining itself is turned on by the @option{-finline-functions}
12651 or @option{-finline-small-functions} options.
12653 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12655 @opindex finline-functions
12656 @item -finline-functions
12657 Consider all functions for inlining, even if they are not declared inline.
12658 The compiler heuristically decides which functions are worth integrating
12661 If all calls to a given function are integrated, and the function is
12662 declared @code{static}, then the function is normally not output as
12663 assembler code in its own right.
12665 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
12666 by @option{-fprofile-use} and @option{-fauto-profile}.
12668 @opindex finline-functions-called-once
12669 @item -finline-functions-called-once
12670 Consider all @code{static} functions called once for inlining into their
12671 caller even if they are not marked @code{inline}. If a call to a given
12672 function is integrated, then the function is not output as assembler code
12675 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
12676 but not @option{-Og}.
12678 @opindex fearly-inlining
12679 @item -fearly-inlining
12680 Inline functions marked by @code{always_inline} and functions whose body seems
12681 smaller than the function call overhead early before doing
12682 @option{-fprofile-generate} instrumentation and real inlining pass. Doing so
12683 makes profiling significantly cheaper and usually inlining faster on programs
12684 having large chains of nested wrapper functions.
12686 Enabled by default.
12690 Perform interprocedural scalar replacement of aggregates, removal of
12691 unused parameters and replacement of parameters passed by reference
12692 by parameters passed by value.
12694 Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12696 @opindex finline-limit
12697 @item -finline-limit=@var{n}
12698 By default, GCC limits the size of functions that can be inlined. This flag
12699 allows coarse control of this limit. @var{n} is the size of functions that
12700 can be inlined in number of pseudo instructions.
12702 Inlining is actually controlled by a number of parameters, which may be
12703 specified individually by using @option{--param @var{name}=@var{value}}.
12704 The @option{-finline-limit=@var{n}} option sets some of these parameters
12708 @item max-inline-insns-single
12709 is set to @var{n}/2.
12710 @item max-inline-insns-auto
12711 is set to @var{n}/2.
12714 See below for a documentation of the individual
12715 parameters controlling inlining and for the defaults of these parameters.
12717 @emph{Note:} there may be no value to @option{-finline-limit} that results
12718 in default behavior.
12720 @emph{Note:} pseudo instruction represents, in this particular context, an
12721 abstract measurement of function's size. In no way does it represent a count
12722 of assembly instructions and as such its exact meaning might change from one
12723 release to an another.
12725 @opindex fno-keep-inline-dllexport
12726 @opindex fkeep-inline-dllexport
12727 @item -fno-keep-inline-dllexport
12728 This is a more fine-grained version of @option{-fkeep-inline-functions},
12729 which applies only to functions that are declared using the @code{dllexport}
12730 attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12733 @opindex fkeep-inline-functions
12734 @item -fkeep-inline-functions
12735 In C, emit @code{static} functions that are declared @code{inline}
12736 into the object file, even if the function has been inlined into all
12737 of its callers. This switch does not affect functions using the
12738 @code{extern inline} extension in GNU C90@. In C++, emit any and all
12739 inline functions into the object file.
12741 @opindex fkeep-static-functions
12742 @item -fkeep-static-functions
12743 Emit @code{static} functions into the object file, even if the function
12746 @opindex fkeep-static-consts
12747 @item -fkeep-static-consts
12748 Emit variables declared @code{static const} when optimization isn't turned
12749 on, even if the variables aren't referenced.
12751 GCC enables this option by default. If you want to force the compiler to
12752 check if a variable is referenced, regardless of whether or not
12753 optimization is turned on, use the @option{-fno-keep-static-consts} option.
12755 @opindex fmerge-constants
12756 @item -fmerge-constants
12757 Attempt to merge identical constants (string constants and floating-point
12758 constants) across compilation units.
12760 This option is the default for optimized compilation if the assembler and
12761 linker support it. Use @option{-fno-merge-constants} to inhibit this
12764 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12766 @opindex fmerge-all-constants
12767 @item -fmerge-all-constants
12768 Attempt to merge identical constants and identical variables.
12770 This option implies @option{-fmerge-constants}. In addition to
12771 @option{-fmerge-constants} this considers e.g.@: even constant initialized
12772 arrays or initialized constant variables with integral or floating-point
12773 types. Languages like C or C++ require each variable, including multiple
12774 instances of the same variable in recursive calls, to have distinct locations,
12775 so using this option results in non-conforming
12778 @opindex fmodulo-sched
12779 @item -fmodulo-sched
12780 Perform swing modulo scheduling immediately before the first scheduling
12781 pass. This pass looks at innermost loops and reorders their
12782 instructions by overlapping different iterations.
12784 @opindex fmodulo-sched-allow-regmoves
12785 @item -fmodulo-sched-allow-regmoves
12786 Perform more aggressive SMS-based modulo scheduling with register moves
12787 allowed. By setting this flag certain anti-dependences edges are
12788 deleted, which triggers the generation of reg-moves based on the
12789 life-range analysis. This option is effective only with
12790 @option{-fmodulo-sched} enabled.
12792 @opindex fno-branch-count-reg
12793 @opindex fbranch-count-reg
12794 @item -fno-branch-count-reg
12795 Disable the optimization pass that scans for opportunities to use
12796 ``decrement and branch'' instructions on a count register instead of
12797 instruction sequences that decrement a register, compare it against zero, and
12798 then branch based upon the result. This option is only meaningful on
12799 architectures that support such instructions, which include x86, PowerPC,
12800 IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12801 doesn't remove the decrement and branch instructions from the generated
12802 instruction stream introduced by other optimization passes.
12804 The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12805 except for @option{-Og}.
12807 @opindex fno-function-cse
12808 @opindex ffunction-cse
12809 @item -fno-function-cse
12810 Do not put function addresses in registers; make each instruction that
12811 calls a constant function contain the function's address explicitly.
12813 This option results in less efficient code, but some strange hacks
12814 that alter the assembler output may be confused by the optimizations
12815 performed when this option is not used.
12817 The default is @option{-ffunction-cse}
12819 @opindex fno-zero-initialized-in-bss
12820 @opindex fzero-initialized-in-bss
12821 @item -fno-zero-initialized-in-bss
12822 If the target supports a BSS section, GCC by default puts variables that
12823 are initialized to zero into BSS@. This can save space in the resulting
12826 This option turns off this behavior because some programs explicitly
12827 rely on variables going to the data section---e.g., so that the
12828 resulting executable can find the beginning of that section and/or make
12829 assumptions based on that.
12831 The default is @option{-fzero-initialized-in-bss}.
12833 @opindex fthread-jumps
12834 @item -fthread-jumps
12835 Perform optimizations that check to see if a jump branches to a
12836 location where another comparison subsumed by the first is found. If
12837 so, the first branch is redirected to either the destination of the
12838 second branch or a point immediately following it, depending on whether
12839 the condition is known to be true or false.
12841 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12843 @opindex fsplit-wide-types
12844 @item -fsplit-wide-types
12845 When using a type that occupies multiple registers, such as @code{long
12846 long} on a 32-bit system, split the registers apart and allocate them
12847 independently. This normally generates better code for those types,
12848 but may make debugging more difficult.
12850 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12853 @opindex fsplit-wide-types-early
12854 @item -fsplit-wide-types-early
12855 Fully split wide types early, instead of very late.
12856 This option has no effect unless @option{-fsplit-wide-types} is turned on.
12858 This is the default on some targets.
12860 @opindex fcse-follow-jumps
12861 @item -fcse-follow-jumps
12862 In common subexpression elimination (CSE), scan through jump instructions
12863 when the target of the jump is not reached by any other path. For
12864 example, when CSE encounters an @code{if} statement with an
12865 @code{else} clause, CSE follows the jump when the condition
12868 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12870 @opindex fcse-skip-blocks
12871 @item -fcse-skip-blocks
12872 This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12873 follow jumps that conditionally skip over blocks. When CSE
12874 encounters a simple @code{if} statement with no else clause,
12875 @option{-fcse-skip-blocks} causes CSE to follow the jump around the
12876 body of the @code{if}.
12878 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12880 @opindex frerun-cse-after-loop
12881 @item -frerun-cse-after-loop
12882 Re-run common subexpression elimination after loop optimizations are
12885 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12889 Perform a global common subexpression elimination pass.
12890 This pass also performs global constant and copy propagation.
12892 @emph{Note:} When compiling a program using computed gotos, a GCC
12893 extension, you may get better run-time performance if you disable
12894 the global common subexpression elimination pass by adding
12895 @option{-fno-gcse} to the command line.
12897 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12901 When @option{-fgcse-lm} is enabled, global common subexpression elimination
12902 attempts to move loads that are only killed by stores into themselves. This
12903 allows a loop containing a load/store sequence to be changed to a load outside
12904 the loop, and a copy/store within the loop.
12906 Enabled by default when @option{-fgcse} is enabled.
12910 When @option{-fgcse-sm} is enabled, a store motion pass is run after
12911 global common subexpression elimination. This pass attempts to move
12912 stores out of loops. When used in conjunction with @option{-fgcse-lm},
12913 loops containing a load/store sequence can be changed to a load before
12914 the loop and a store after the loop.
12916 Not enabled at any optimization level.
12920 When @option{-fgcse-las} is enabled, the global common subexpression
12921 elimination pass eliminates redundant loads that come after stores to the
12922 same memory location (both partial and full redundancies).
12924 Not enabled at any optimization level.
12926 @opindex fgcse-after-reload
12927 @item -fgcse-after-reload
12928 When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12929 pass is performed after reload. The purpose of this pass is to clean up
12930 redundant spilling.
12932 Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12934 @opindex faggressive-loop-optimizations
12935 @item -faggressive-loop-optimizations
12936 This option tells the loop optimizer to use language constraints to
12937 derive bounds for the number of iterations of a loop. This assumes that
12938 loop code does not invoke undefined behavior by for example causing signed
12939 integer overflows or out-of-bound array accesses. The bounds for the
12940 number of iterations of a loop are used to guide loop unrolling and peeling
12941 and loop exit test optimizations.
12942 This option is enabled by default.
12944 @opindex funconstrained-commons
12945 @item -funconstrained-commons
12946 This option tells the compiler that variables declared in common blocks
12947 (e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12948 prevents certain optimizations that depend on knowing the array bounds.
12950 @opindex fcrossjumping
12951 @item -fcrossjumping
12952 Perform cross-jumping transformation.
12953 This transformation unifies equivalent code and saves code size. The
12954 resulting code may or may not perform better than without cross-jumping.
12956 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12958 @opindex fauto-inc-dec
12959 @item -fauto-inc-dec
12960 Combine increments or decrements of addresses with memory accesses.
12961 This pass is always skipped on architectures that do not have
12962 instructions to support this. Enabled by default at @option{-O1} and
12963 higher on architectures that support this.
12967 Perform dead code elimination (DCE) on RTL@.
12968 Enabled by default at @option{-O1} and higher.
12972 Perform dead store elimination (DSE) on RTL@.
12973 Enabled by default at @option{-O1} and higher.
12975 @opindex fif-conversion
12976 @item -fif-conversion
12977 Attempt to transform conditional jumps into branch-less equivalents. This
12978 includes use of conditional moves, min, max, set flags and abs instructions, and
12979 some tricks doable by standard arithmetics. The use of conditional execution
12980 on chips where it is available is controlled by @option{-fif-conversion2}.
12982 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12983 not with @option{-Og}.
12985 @opindex fif-conversion2
12986 @item -fif-conversion2
12987 Use conditional execution (where available) to transform conditional jumps into
12988 branch-less equivalents.
12990 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12991 not with @option{-Og}.
12993 @opindex fdeclone-ctor-dtor
12994 @item -fdeclone-ctor-dtor
12995 The C++ ABI requires multiple entry points for constructors and
12996 destructors: one for a base subobject, one for a complete object, and
12997 one for a virtual destructor that calls operator delete afterwards.
12998 For a hierarchy with virtual bases, the base and complete variants are
12999 clones, which means two copies of the function. With this option, the
13000 base and complete variants are changed to be thunks that call a common
13003 Enabled by @option{-Os}.
13005 @opindex fdelete-null-pointer-checks
13006 @item -fdelete-null-pointer-checks
13007 Assume that programs cannot safely dereference null pointers, and that
13008 no code or data element resides at address zero.
13009 This option enables simple constant
13010 folding optimizations at all optimization levels. In addition, other
13011 optimization passes in GCC use this flag to control global dataflow
13012 analyses that eliminate useless checks for null pointers; these assume
13013 that a memory access to address zero always results in a trap, so
13014 that if a pointer is checked after it has already been dereferenced,
13017 Note however that in some environments this assumption is not true.
13018 Use @option{-fno-delete-null-pointer-checks} to disable this optimization
13019 for programs that depend on that behavior.
13021 This option is enabled by default on most targets. On Nios II ELF, it
13022 defaults to off. On AVR and MSP430, this option is completely disabled.
13024 Passes that use the dataflow information
13025 are enabled independently at different optimization levels.
13027 @opindex fdevirtualize
13028 @item -fdevirtualize
13029 Attempt to convert calls to virtual functions to direct calls. This
13030 is done both within a procedure and interprocedurally as part of
13031 indirect inlining (@option{-findirect-inlining}) and interprocedural constant
13032 propagation (@option{-fipa-cp}).
13033 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13035 @opindex fdevirtualize-speculatively
13036 @item -fdevirtualize-speculatively
13037 Attempt to convert calls to virtual functions to speculative direct calls.
13038 Based on the analysis of the type inheritance graph, determine for a given call
13039 the set of likely targets. If the set is small, preferably of size 1, change
13040 the call into a conditional deciding between direct and indirect calls. The
13041 speculative calls enable more optimizations, such as inlining. When they seem
13042 useless after further optimization, they are converted back into original form.
13044 @opindex fdevirtualize-at-ltrans
13045 @item -fdevirtualize-at-ltrans
13046 Stream extra information needed for aggressive devirtualization when running
13047 the link-time optimizer in local transformation mode.
13048 This option enables more devirtualization but
13049 significantly increases the size of streamed data. For this reason it is
13050 disabled by default.
13052 @opindex fexpensive-optimizations
13053 @item -fexpensive-optimizations
13054 Perform a number of minor optimizations that are relatively expensive.
13056 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13060 Attempt to remove redundant extension instructions. This is especially
13061 helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
13062 registers after writing to their lower 32-bit half.
13064 Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at
13065 levels @option{-O2}, @option{-O3}, @option{-Os}.
13067 @opindex fno-lifetime-dse
13068 @opindex flifetime-dse
13069 @item -fno-lifetime-dse
13070 In C++ the value of an object is only affected by changes within its
13071 lifetime: when the constructor begins, the object has an indeterminate
13072 value, and any changes during the lifetime of the object are dead when
13073 the object is destroyed. Normally dead store elimination will take
13074 advantage of this; if your code relies on the value of the object
13075 storage persisting beyond the lifetime of the object, you can use this
13076 flag to disable this optimization. To preserve stores before the
13077 constructor starts (e.g.@: because your operator new clears the object
13078 storage) but still treat the object as dead after the destructor, you
13079 can use @option{-flifetime-dse=1}. The default behavior can be
13080 explicitly selected with @option{-flifetime-dse=2}.
13081 @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
13083 @opindex flive-range-shrinkage
13084 @item -flive-range-shrinkage
13085 Attempt to decrease register pressure through register live range
13086 shrinkage. This is helpful for fast processors with small or moderate
13087 size register sets.
13089 @opindex fira-algorithm
13090 @item -fira-algorithm=@var{algorithm}
13091 Use the specified coloring algorithm for the integrated register
13092 allocator. The @var{algorithm} argument can be @samp{priority}, which
13093 specifies Chow's priority coloring, or @samp{CB}, which specifies
13094 Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
13095 for all architectures, but for those targets that do support it, it is
13096 the default because it generates better code.
13098 @opindex fira-region
13099 @item -fira-region=@var{region}
13100 Use specified regions for the integrated register allocator. The
13101 @var{region} argument should be one of the following:
13106 Use all loops as register allocation regions.
13107 This can give the best results for machines with a small and/or
13108 irregular register set.
13111 Use all loops except for loops with small register pressure
13112 as the regions. This value usually gives
13113 the best results in most cases and for most architectures,
13114 and is enabled by default when compiling with optimization for speed
13115 (@option{-O}, @option{-O2}, @dots{}).
13118 Use all functions as a single region.
13119 This typically results in the smallest code size, and is enabled by default for
13120 @option{-Os} or @option{-O0}.
13124 @opindex fira-hoist-pressure
13125 @item -fira-hoist-pressure
13126 Use IRA to evaluate register pressure in the code hoisting pass for
13127 decisions to hoist expressions. This option usually results in smaller
13128 code, but it can slow the compiler down.
13130 This option is enabled at level @option{-Os} for all targets.
13132 @opindex fira-loop-pressure
13133 @item -fira-loop-pressure
13134 Use IRA to evaluate register pressure in loops for decisions to move
13135 loop invariants. This option usually results in generation
13136 of faster and smaller code on machines with large register files (>= 32
13137 registers), but it can slow the compiler down.
13139 This option is enabled at level @option{-O3} for some targets.
13141 @opindex fno-ira-share-save-slots
13142 @opindex fira-share-save-slots
13143 @item -fno-ira-share-save-slots
13144 Disable sharing of stack slots used for saving call-used hard
13145 registers living through a call. Each hard register gets a
13146 separate stack slot, and as a result function stack frames are
13149 @opindex fno-ira-share-spill-slots
13150 @opindex fira-share-spill-slots
13151 @item -fno-ira-share-spill-slots
13152 Disable sharing of stack slots allocated for pseudo-registers. Each
13153 pseudo-register that does not get a hard register gets a separate
13154 stack slot, and as a result function stack frames are larger.
13156 @opindex flra-remat
13158 Enable CFG-sensitive rematerialization in LRA. Instead of loading
13159 values of spilled pseudos, LRA tries to rematerialize (recalculate)
13160 values if it is profitable.
13162 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13164 @opindex fdelayed-branch
13165 @item -fdelayed-branch
13166 If supported for the target machine, attempt to reorder instructions
13167 to exploit instruction slots available after delayed branch
13170 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
13171 but not at @option{-Og}.
13173 @opindex fschedule-insns
13174 @item -fschedule-insns
13175 If supported for the target machine, attempt to reorder instructions to
13176 eliminate execution stalls due to required data being unavailable. This
13177 helps machines that have slow floating point or memory load instructions
13178 by allowing other instructions to be issued until the result of the load
13179 or floating-point instruction is required.
13181 Enabled at levels @option{-O2}, @option{-O3}.
13183 @opindex fschedule-insns2
13184 @item -fschedule-insns2
13185 Similar to @option{-fschedule-insns}, but requests an additional pass of
13186 instruction scheduling after register allocation has been done. This is
13187 especially useful on machines with a relatively small number of
13188 registers and where memory load instructions take more than one cycle.
13190 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13192 @opindex fno-sched-interblock
13193 @opindex fsched-interblock
13194 @item -fno-sched-interblock
13195 Disable instruction scheduling across basic blocks, which
13196 is normally enabled when scheduling before register allocation, i.e.@:
13197 with @option{-fschedule-insns} or at @option{-O2} or higher.
13199 @opindex fno-sched-spec
13200 @opindex fsched-spec
13201 @item -fno-sched-spec
13202 Disable speculative motion of non-load instructions, which
13203 is normally enabled when scheduling before register allocation, i.e.@:
13204 with @option{-fschedule-insns} or at @option{-O2} or higher.
13206 @opindex fsched-pressure
13207 @item -fsched-pressure
13208 Enable register pressure sensitive insn scheduling before register
13209 allocation. This only makes sense when scheduling before register
13210 allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
13211 @option{-O2} or higher. Usage of this option can improve the
13212 generated code and decrease its size by preventing register pressure
13213 increase above the number of available hard registers and subsequent
13214 spills in register allocation.
13216 @opindex fsched-spec-load
13217 @item -fsched-spec-load
13218 Allow speculative motion of some load instructions. This only makes
13219 sense when scheduling before register allocation, i.e.@: with
13220 @option{-fschedule-insns} or at @option{-O2} or higher.
13222 @opindex fsched-spec-load-dangerous
13223 @item -fsched-spec-load-dangerous
13224 Allow speculative motion of more load instructions. This only makes
13225 sense when scheduling before register allocation, i.e.@: with
13226 @option{-fschedule-insns} or at @option{-O2} or higher.
13228 @opindex fsched-stalled-insns
13229 @item -fsched-stalled-insns
13230 @itemx -fsched-stalled-insns=@var{n}
13231 Define how many insns (if any) can be moved prematurely from the queue
13232 of stalled insns into the ready list during the second scheduling pass.
13233 @option{-fno-sched-stalled-insns} means that no insns are moved
13234 prematurely, @option{-fsched-stalled-insns=0} means there is no limit
13235 on how many queued insns can be moved prematurely.
13236 @option{-fsched-stalled-insns} without a value is equivalent to
13237 @option{-fsched-stalled-insns=1}.
13239 @opindex fsched-stalled-insns-dep
13240 @item -fsched-stalled-insns-dep
13241 @itemx -fsched-stalled-insns-dep=@var{n}
13242 Define how many insn groups (cycles) are examined for a dependency
13243 on a stalled insn that is a candidate for premature removal from the queue
13244 of stalled insns. This has an effect only during the second scheduling pass,
13245 and only if @option{-fsched-stalled-insns} is used.
13246 @option{-fno-sched-stalled-insns-dep} is equivalent to
13247 @option{-fsched-stalled-insns-dep=0}.
13248 @option{-fsched-stalled-insns-dep} without a value is equivalent to
13249 @option{-fsched-stalled-insns-dep=1}.
13251 @opindex fsched2-use-superblocks
13252 @item -fsched2-use-superblocks
13253 When scheduling after register allocation, use superblock scheduling.
13254 This allows motion across basic block boundaries,
13255 resulting in faster schedules. This option is experimental, as not all machine
13256 descriptions used by GCC model the CPU closely enough to avoid unreliable
13257 results from the algorithm.
13259 This only makes sense when scheduling after register allocation, i.e.@: with
13260 @option{-fschedule-insns2} or at @option{-O2} or higher.
13262 @opindex fsched-group-heuristic
13263 @item -fsched-group-heuristic
13264 Enable the group heuristic in the scheduler. This heuristic favors
13265 the instruction that belongs to a schedule group. This is enabled
13266 by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
13267 or @option{-fschedule-insns2} or at @option{-O2} or higher.
13269 @opindex fsched-critical-path-heuristic
13270 @item -fsched-critical-path-heuristic
13271 Enable the critical-path heuristic in the scheduler. This heuristic favors
13272 instructions on the critical path. This is enabled by default when
13273 scheduling is enabled, i.e.@: with @option{-fschedule-insns}
13274 or @option{-fschedule-insns2} or at @option{-O2} or higher.
13276 @opindex fsched-spec-insn-heuristic
13277 @item -fsched-spec-insn-heuristic
13278 Enable the speculative instruction heuristic in the scheduler. This
13279 heuristic favors speculative instructions with greater dependency weakness.
13280 This is enabled by default when scheduling is enabled, i.e.@:
13281 with @option{-fschedule-insns} or @option{-fschedule-insns2}
13282 or at @option{-O2} or higher.
13284 @opindex fsched-rank-heuristic
13285 @item -fsched-rank-heuristic
13286 Enable the rank heuristic in the scheduler. This heuristic favors
13287 the instruction belonging to a basic block with greater size or frequency.
13288 This is enabled by default when scheduling is enabled, i.e.@:
13289 with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13290 at @option{-O2} or higher.
13292 @opindex fsched-last-insn-heuristic
13293 @item -fsched-last-insn-heuristic
13294 Enable the last-instruction heuristic in the scheduler. This heuristic
13295 favors the instruction that is less dependent on the last instruction
13296 scheduled. This is enabled by default when scheduling is enabled,
13297 i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13298 at @option{-O2} or higher.
13300 @opindex fsched-dep-count-heuristic
13301 @item -fsched-dep-count-heuristic
13302 Enable the dependent-count heuristic in the scheduler. This heuristic
13303 favors the instruction that has more instructions depending on it.
13304 This is enabled by default when scheduling is enabled, i.e.@:
13305 with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13306 at @option{-O2} or higher.
13308 @opindex freschedule-modulo-scheduled-loops
13309 @item -freschedule-modulo-scheduled-loops
13310 Modulo scheduling is performed before traditional scheduling. If a loop
13311 is modulo scheduled, later scheduling passes may change its schedule.
13312 Use this option to control that behavior.
13314 @opindex fselective-scheduling
13315 @item -fselective-scheduling
13316 Schedule instructions using selective scheduling algorithm. Selective
13317 scheduling runs instead of the first scheduler pass.
13319 @opindex fselective-scheduling2
13320 @item -fselective-scheduling2
13321 Schedule instructions using selective scheduling algorithm. Selective
13322 scheduling runs instead of the second scheduler pass.
13324 @opindex fsel-sched-pipelining
13325 @item -fsel-sched-pipelining
13326 Enable software pipelining of innermost loops during selective scheduling.
13327 This option has no effect unless one of @option{-fselective-scheduling} or
13328 @option{-fselective-scheduling2} is turned on.
13330 @opindex fsel-sched-pipelining-outer-loops
13331 @item -fsel-sched-pipelining-outer-loops
13332 When pipelining loops during selective scheduling, also pipeline outer loops.
13333 This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
13335 @opindex fsemantic-interposition
13336 @item -fsemantic-interposition
13337 Some object formats, like ELF, allow interposing of symbols by the
13339 This means that for symbols exported from the DSO, the compiler cannot perform
13340 interprocedural propagation, inlining and other optimizations in anticipation
13341 that the function or variable in question may change. While this feature is
13342 useful, for example, to rewrite memory allocation functions by a debugging
13343 implementation, it is expensive in the terms of code quality.
13344 With @option{-fno-semantic-interposition} the compiler assumes that
13345 if interposition happens for functions the overwriting function will have
13346 precisely the same semantics (and side effects).
13347 Similarly if interposition happens
13348 for variables, the constructor of the variable will be the same. The flag
13349 has no effect for functions explicitly declared inline
13350 (where it is never allowed for interposition to change semantics)
13351 and for symbols explicitly declared weak.
13353 @opindex fshrink-wrap
13354 @item -fshrink-wrap
13355 Emit function prologues only before parts of the function that need it,
13356 rather than at the top of the function. This flag is enabled by default at
13357 @option{-O} and higher.
13359 @opindex fshrink-wrap-separate
13360 @item -fshrink-wrap-separate
13361 Shrink-wrap separate parts of the prologue and epilogue separately, so that
13362 those parts are only executed when needed.
13363 This option is on by default, but has no effect unless @option{-fshrink-wrap}
13364 is also turned on and the target supports this.
13366 @opindex fcaller-saves
13367 @item -fcaller-saves
13368 Enable allocation of values to registers that are clobbered by
13369 function calls, by emitting extra instructions to save and restore the
13370 registers around such calls. Such allocation is done only when it
13371 seems to result in better code.
13373 This option is always enabled by default on certain machines, usually
13374 those which have no call-preserved registers to use instead.
13376 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13378 @opindex fcombine-stack-adjustments
13379 @item -fcombine-stack-adjustments
13380 Tracks stack adjustments (pushes and pops) and stack memory references
13381 and then tries to find ways to combine them.
13383 Enabled by default at @option{-O1} and higher.
13387 Use caller save registers for allocation if those registers are not used by
13388 any called function. In that case it is not necessary to save and restore
13389 them around calls. This is only possible if called functions are part of
13390 same compilation unit as current function and they are compiled before it.
13392 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
13393 is disabled if generated code will be instrumented for profiling
13394 (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
13395 exactly (this happens on targets that do not expose prologues
13396 and epilogues in RTL).
13398 @opindex fconserve-stack
13399 @item -fconserve-stack
13400 Attempt to minimize stack usage. The compiler attempts to use less
13401 stack space, even if that makes the program slower. This option
13402 implies setting the @option{large-stack-frame} parameter to 100
13403 and the @option{large-stack-frame-growth} parameter to 400.
13405 @opindex ftree-reassoc
13406 @item -ftree-reassoc
13407 Perform reassociation on trees. This flag is enabled by default
13408 at @option{-O1} and higher.
13410 @opindex fcode-hoisting
13411 @item -fcode-hoisting
13412 Perform code hoisting. Code hoisting tries to move the
13413 evaluation of expressions executed on all paths to the function exit
13414 as early as possible. This is especially useful as a code size
13415 optimization, but it often helps for code speed as well.
13416 This flag is enabled by default at @option{-O2} and higher.
13420 Perform partial redundancy elimination (PRE) on trees. This flag is
13421 enabled by default at @option{-O2} and @option{-O3}.
13423 @opindex ftree-partial-pre
13424 @item -ftree-partial-pre
13425 Make partial redundancy elimination (PRE) more aggressive. This flag is
13426 enabled by default at @option{-O3}.
13428 @opindex ftree-forwprop
13429 @item -ftree-forwprop
13430 Perform forward propagation on trees. This flag is enabled by default
13431 at @option{-O1} and higher.
13435 Perform full redundancy elimination (FRE) on trees. The difference
13436 between FRE and PRE is that FRE only considers expressions
13437 that are computed on all paths leading to the redundant computation.
13438 This analysis is faster than PRE, though it exposes fewer redundancies.
13439 This flag is enabled by default at @option{-O1} and higher.
13441 @opindex ftree-phiprop
13442 @item -ftree-phiprop
13443 Perform hoisting of loads from conditional pointers on trees. This
13444 pass is enabled by default at @option{-O1} and higher.
13446 @opindex fhoist-adjacent-loads
13447 @item -fhoist-adjacent-loads
13448 Speculatively hoist loads from both branches of an if-then-else if the
13449 loads are from adjacent locations in the same structure and the target
13450 architecture has a conditional move instruction. This flag is enabled
13451 by default at @option{-O2} and higher.
13453 @opindex ftree-copy-prop
13454 @item -ftree-copy-prop
13455 Perform copy propagation on trees. This pass eliminates unnecessary
13456 copy operations. This flag is enabled by default at @option{-O1} and
13459 @opindex fipa-pure-const
13460 @item -fipa-pure-const
13461 Discover which functions are pure or constant.
13462 Enabled by default at @option{-O1} and higher.
13464 @opindex fipa-reference
13465 @item -fipa-reference
13466 Discover which static variables do not escape the
13468 Enabled by default at @option{-O1} and higher.
13470 @opindex fipa-reference-addressable
13471 @item -fipa-reference-addressable
13472 Discover read-only, write-only and non-addressable static variables.
13473 Enabled by default at @option{-O1} and higher.
13475 @opindex fipa-stack-alignment
13476 @item -fipa-stack-alignment
13477 Reduce stack alignment on call sites if possible.
13478 Enabled by default.
13482 Perform interprocedural pointer analysis and interprocedural modification
13483 and reference analysis. This option can cause excessive memory and
13484 compile-time usage on large compilation units. It is not enabled by
13485 default at any optimization level.
13487 @opindex fipa-profile
13488 @item -fipa-profile
13489 Perform interprocedural profile propagation. The functions called only from
13490 cold functions are marked as cold. Also functions executed once (such as
13491 @code{cold}, @code{noreturn}, static constructors or destructors) are
13492 identified. Cold functions and loop less parts of functions executed once are
13493 then optimized for size.
13494 Enabled by default at @option{-O1} and higher.
13496 @opindex fipa-modref
13498 Perform interprocedural mod/ref analysis. This optimization analyzes the side
13499 effects of functions (memory locations that are modified or referenced) and
13500 enables better optimization across the function call boundary. This flag is
13501 enabled by default at @option{-O1} and higher.
13505 Perform interprocedural constant propagation.
13506 This optimization analyzes the program to determine when values passed
13507 to functions are constants and then optimizes accordingly.
13508 This optimization can substantially increase performance
13509 if the application has constants passed to functions.
13510 This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
13511 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13513 @opindex fipa-cp-clone
13514 @item -fipa-cp-clone
13515 Perform function cloning to make interprocedural constant propagation stronger.
13516 When enabled, interprocedural constant propagation performs function cloning
13517 when externally visible function can be called with constant arguments.
13518 Because this optimization can create multiple copies of functions,
13519 it may significantly increase code size
13520 (see @option{--param ipa-cp-unit-growth=@var{value}}).
13521 This flag is enabled by default at @option{-O3}.
13522 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13524 @opindex fipa-bit-cp
13526 When enabled, perform interprocedural bitwise constant
13527 propagation. This flag is enabled by default at @option{-O2} and
13528 by @option{-fprofile-use} and @option{-fauto-profile}.
13529 It requires that @option{-fipa-cp} is enabled.
13533 When enabled, perform interprocedural propagation of value
13534 ranges. This flag is enabled by default at @option{-O2}. It requires
13535 that @option{-fipa-cp} is enabled.
13539 Perform Identical Code Folding for functions and read-only variables.
13540 The optimization reduces code size and may disturb unwind stacks by replacing
13541 a function by equivalent one with a different name. The optimization works
13542 more effectively with link-time optimization enabled.
13544 Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
13545 works on different levels and thus the optimizations are not same - there are
13546 equivalences that are found only by GCC and equivalences found only by Gold.
13548 This flag is enabled by default at @option{-O2} and @option{-Os}.
13550 @opindex flive-patching
13551 @item -flive-patching=@var{level}
13552 Control GCC's optimizations to produce output suitable for live-patching.
13554 If the compiler's optimization uses a function's body or information extracted
13555 from its body to optimize/change another function, the latter is called an
13556 impacted function of the former. If a function is patched, its impacted
13557 functions should be patched too.
13559 The impacted functions are determined by the compiler's interprocedural
13560 optimizations. For example, a caller is impacted when inlining a function
13562 cloning a function and changing its caller to call this new clone,
13563 or extracting a function's pureness/constness information to optimize
13564 its direct or indirect callers, etc.
13566 Usually, the more IPA optimizations enabled, the larger the number of
13567 impacted functions for each function. In order to control the number of
13568 impacted functions and more easily compute the list of impacted function,
13569 IPA optimizations can be partially enabled at two different levels.
13571 The @var{level} argument should be one of the following:
13577 Only enable inlining and cloning optimizations, which includes inlining,
13578 cloning, interprocedural scalar replacement of aggregates and partial inlining.
13579 As a result, when patching a function, all its callers and its clones'
13580 callers are impacted, therefore need to be patched as well.
13582 @option{-flive-patching=inline-clone} disables the following optimization flags:
13583 @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra
13584 -fipa-icf -fipa-icf-functions -fipa-icf-variables
13585 -fipa-bit-cp -fipa-vrp -fipa-pure-const
13586 -fipa-reference-addressable
13587 -fipa-stack-alignment -fipa-modref}
13589 @item inline-only-static
13591 Only enable inlining of static functions.
13592 As a result, when patching a static function, all its callers are impacted
13593 and so need to be patched as well.
13595 In addition to all the flags that @option{-flive-patching=inline-clone}
13597 @option{-flive-patching=inline-only-static} disables the following additional
13598 optimization flags:
13599 @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
13603 When @option{-flive-patching} is specified without any value, the default value
13604 is @var{inline-clone}.
13606 This flag is disabled by default.
13608 Note that @option{-flive-patching} is not supported with link-time optimization
13611 @opindex fisolate-erroneous-paths-dereference
13612 @item -fisolate-erroneous-paths-dereference
13613 Detect paths that trigger erroneous or undefined behavior due to
13614 dereferencing a null pointer. Isolate those paths from the main control
13615 flow and turn the statement with erroneous or undefined behavior into a trap.
13616 This flag is enabled by default at @option{-O2} and higher and depends on
13617 @option{-fdelete-null-pointer-checks} also being enabled.
13619 @opindex fisolate-erroneous-paths-attribute
13620 @item -fisolate-erroneous-paths-attribute
13621 Detect paths that trigger erroneous or undefined behavior due to a null value
13622 being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
13623 attribute. Isolate those paths from the main control flow and turn the
13624 statement with erroneous or undefined behavior into a trap. This is not
13625 currently enabled, but may be enabled by @option{-O2} in the future.
13627 @opindex ftree-sink
13629 Perform forward store motion on trees. This flag is
13630 enabled by default at @option{-O1} and higher.
13632 @opindex ftree-bit-ccp
13633 @item -ftree-bit-ccp
13634 Perform sparse conditional bit constant propagation on trees and propagate
13635 pointer alignment information.
13636 This pass only operates on local scalar variables and is enabled by default
13637 at @option{-O1} and higher, except for @option{-Og}.
13638 It requires that @option{-ftree-ccp} is enabled.
13642 Perform sparse conditional constant propagation (CCP) on trees. This
13643 pass only operates on local scalar variables and is enabled by default
13644 at @option{-O1} and higher.
13646 @opindex fssa-backprop
13647 @item -fssa-backprop
13648 Propagate information about uses of a value up the definition chain
13649 in order to simplify the definitions. For example, this pass strips
13650 sign operations if the sign of a value never matters. The flag is
13651 enabled by default at @option{-O1} and higher.
13653 @opindex fssa-phiopt
13655 Perform pattern matching on SSA PHI nodes to optimize conditional
13656 code. This pass is enabled by default at @option{-O1} and higher,
13657 except for @option{-Og}.
13659 @opindex ftree-switch-conversion
13660 @item -ftree-switch-conversion
13661 Perform conversion of simple initializations in a switch to
13662 initializations from a scalar array. This flag is enabled by default
13663 at @option{-O2} and higher.
13665 @opindex ftree-tail-merge
13666 @item -ftree-tail-merge
13667 Look for identical code sequences. When found, replace one with a jump to the
13668 other. This optimization is known as tail merging or cross jumping. This flag
13669 is enabled by default at @option{-O2} and higher. The compilation time
13671 be limited using @option{max-tail-merge-comparisons} parameter and
13672 @option{max-tail-merge-iterations} parameter.
13676 Perform dead code elimination (DCE) on trees. This flag is enabled by
13677 default at @option{-O1} and higher.
13679 @opindex ftree-builtin-call-dce
13680 @item -ftree-builtin-call-dce
13681 Perform conditional dead code elimination (DCE) for calls to built-in functions
13682 that may set @code{errno} but are otherwise free of side effects. This flag is
13683 enabled by default at @option{-O2} and higher if @option{-Os} is not also
13686 @opindex ffinite-loops
13687 @opindex fno-finite-loops
13688 @item -ffinite-loops
13689 Assume that a loop with an exit will eventually take the exit and not loop
13690 indefinitely. This allows the compiler to remove loops that otherwise have
13691 no side-effects, not considering eventual endless looping as such.
13693 This option is enabled by default at @option{-O2} for C++ with -std=c++11
13696 @opindex ftree-dominator-opts
13697 @item -ftree-dominator-opts
13698 Perform a variety of simple scalar cleanups (constant/copy
13699 propagation, redundancy elimination, range propagation and expression
13700 simplification) based on a dominator tree traversal. This also
13701 performs jump threading (to reduce jumps to jumps). This flag is
13702 enabled by default at @option{-O1} and higher.
13706 Perform dead store elimination (DSE) on trees. A dead store is a store into
13707 a memory location that is later overwritten by another store without
13708 any intervening loads. In this case the earlier store can be deleted. This
13709 flag is enabled by default at @option{-O1} and higher.
13713 Perform loop header copying on trees. This is beneficial since it increases
13714 effectiveness of code motion optimizations. It also saves one jump. This flag
13715 is enabled by default at @option{-O1} and higher. It is not enabled
13716 for @option{-Os}, since it usually increases code size.
13718 @opindex ftree-loop-optimize
13719 @item -ftree-loop-optimize
13720 Perform loop optimizations on trees. This flag is enabled by default
13721 at @option{-O1} and higher.
13723 @opindex ftree-loop-linear
13724 @opindex floop-strip-mine
13725 @opindex floop-block
13726 @item -ftree-loop-linear
13727 @itemx -floop-strip-mine
13728 @itemx -floop-block
13729 Perform loop nest optimizations. Same as
13730 @option{-floop-nest-optimize}. To use this code transformation, GCC has
13731 to be configured with @option{--with-isl} to enable the Graphite loop
13732 transformation infrastructure.
13734 @opindex fgraphite-identity
13735 @item -fgraphite-identity
13736 Enable the identity transformation for graphite. For every SCoP we generate
13737 the polyhedral representation and transform it back to gimple. Using
13738 @option{-fgraphite-identity} we can check the costs or benefits of the
13739 GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13740 are also performed by the code generator isl, like index splitting and
13741 dead code elimination in loops.
13743 @opindex floop-nest-optimize
13744 @item -floop-nest-optimize
13745 Enable the isl based loop nest optimizer. This is a generic loop nest
13746 optimizer based on the Pluto optimization algorithms. It calculates a loop
13747 structure optimized for data-locality and parallelism. This option
13750 @opindex floop-parallelize-all
13751 @item -floop-parallelize-all
13752 Use the Graphite data dependence analysis to identify loops that can
13753 be parallelized. Parallelize all the loops that can be analyzed to
13754 not contain loop carried dependences without checking that it is
13755 profitable to parallelize the loops.
13757 @opindex ftree-coalesce-vars
13758 @item -ftree-coalesce-vars
13759 While transforming the program out of the SSA representation, attempt to
13760 reduce copying by coalescing versions of different user-defined
13761 variables, instead of just compiler temporaries. This may severely
13762 limit the ability to debug an optimized program compiled with
13763 @option{-fno-var-tracking-assignments}. In the negated form, this flag
13764 prevents SSA coalescing of user variables. This option is enabled by
13765 default if optimization is enabled, and it does very little otherwise.
13767 @opindex ftree-loop-if-convert
13768 @item -ftree-loop-if-convert
13769 Attempt to transform conditional jumps in the innermost loops to
13770 branch-less equivalents. The intent is to remove control-flow from
13771 the innermost loops in order to improve the ability of the
13772 vectorization pass to handle these loops. This is enabled by default
13773 if vectorization is enabled.
13775 @opindex ftree-loop-distribution
13776 @item -ftree-loop-distribution
13777 Perform loop distribution. This flag can improve cache performance on
13778 big loop bodies and allow further loop optimizations, like
13779 parallelization or vectorization, to take place. For example, the loop
13795 This flag is enabled by default at @option{-O3}.
13796 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13798 @opindex ftree-loop-distribute-patterns
13799 @item -ftree-loop-distribute-patterns
13800 Perform loop distribution of patterns that can be code generated with
13801 calls to a library. This flag is enabled by default at @option{-O2} and
13802 higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13804 This pass distributes the initialization loops and generates a call to
13805 memset zero. For example, the loop
13821 and the initialization loop is transformed into a call to memset zero.
13822 This flag is enabled by default at @option{-O3}.
13823 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13825 @opindex floop-interchange
13826 @item -floop-interchange
13827 Perform loop interchange outside of graphite. This flag can improve cache
13828 performance on loop nest and allow further loop optimizations, like
13829 vectorization, to take place. For example, the loop
13831 for (int i = 0; i < N; i++)
13832 for (int j = 0; j < N; j++)
13833 for (int k = 0; k < N; k++)
13834 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13838 for (int i = 0; i < N; i++)
13839 for (int k = 0; k < N; k++)
13840 for (int j = 0; j < N; j++)
13841 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13843 This flag is enabled by default at @option{-O3}.
13844 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13846 @opindex floop-unroll-and-jam
13847 @item -floop-unroll-and-jam
13848 Apply unroll and jam transformations on feasible loops. In a loop
13849 nest this unrolls the outer loop by some factor and fuses the resulting
13850 multiple inner loops. This flag is enabled by default at @option{-O3}.
13851 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13853 @opindex ftree-loop-im
13854 @item -ftree-loop-im
13855 Perform loop invariant motion on trees. This pass moves only invariants that
13856 are hard to handle at RTL level (function calls, operations that expand to
13857 nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13858 operands of conditions that are invariant out of the loop, so that we can use
13859 just trivial invariantness analysis in loop unswitching. The pass also includes
13862 @opindex ftree-loop-ivcanon
13863 @item -ftree-loop-ivcanon
13864 Create a canonical counter for number of iterations in loops for which
13865 determining number of iterations requires complicated analysis. Later
13866 optimizations then may determine the number easily. Useful especially
13867 in connection with unrolling.
13869 @opindex ftree-scev-cprop
13870 @item -ftree-scev-cprop
13871 Perform final value replacement. If a variable is modified in a loop
13872 in such a way that its value when exiting the loop can be determined using
13873 only its initial value and the number of loop iterations, replace uses of
13874 the final value by such a computation, provided it is sufficiently cheap.
13875 This reduces data dependencies and may allow further simplifications.
13876 Enabled by default at @option{-O1} and higher.
13880 Perform induction variable optimizations (strength reduction, induction
13881 variable merging and induction variable elimination) on trees.
13883 @opindex ftree-parallelize-loops
13884 @item -ftree-parallelize-loops=n
13885 Parallelize loops, i.e., split their iteration space to run in n threads.
13886 This is only possible for loops whose iterations are independent
13887 and can be arbitrarily reordered. The optimization is only
13888 profitable on multiprocessor machines, for loops that are CPU-intensive,
13889 rather than constrained e.g.@: by memory bandwidth. This option
13890 implies @option{-pthread}, and thus is only supported on targets
13891 that have support for @option{-pthread}.
13895 Perform function-local points-to analysis on trees. This flag is
13896 enabled by default at @option{-O1} and higher, except for @option{-Og}.
13900 Perform scalar replacement of aggregates. This pass replaces structure
13901 references with scalars to prevent committing structures to memory too
13902 early. This flag is enabled by default at @option{-O1} and higher,
13903 except for @option{-Og}.
13905 @opindex fstore-merging
13906 @item -fstore-merging
13907 Perform merging of narrow stores to consecutive memory addresses. This pass
13908 merges contiguous stores of immediate values narrower than a word into fewer
13909 wider stores to reduce the number of instructions. This is enabled by default
13910 at @option{-O2} and higher as well as @option{-Os}.
13914 Perform temporary expression replacement during the SSA->normal phase. Single
13915 use/single def temporaries are replaced at their use location with their
13916 defining expression. This results in non-GIMPLE code, but gives the expanders
13917 much more complex trees to work on resulting in better RTL generation. This is
13918 enabled by default at @option{-O1} and higher.
13920 @opindex ftree-slsr
13922 Perform straight-line strength reduction on trees. This recognizes related
13923 expressions involving multiplications and replaces them by less expensive
13924 calculations when possible. This is enabled by default at @option{-O1} and
13927 @opindex ftree-vectorize
13928 @item -ftree-vectorize
13929 Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13930 and @option{-ftree-slp-vectorize} if not explicitly specified.
13932 @opindex ftree-loop-vectorize
13933 @item -ftree-loop-vectorize
13934 Perform loop vectorization on trees. This flag is enabled by default at
13935 @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13936 and @option{-fauto-profile}.
13938 @opindex ftree-slp-vectorize
13939 @item -ftree-slp-vectorize
13940 Perform basic block vectorization on trees. This flag is enabled by default at
13941 @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13942 and @option{-fauto-profile}.
13944 @opindex ftrivial-auto-var-init
13945 @item -ftrivial-auto-var-init=@var{choice}
13946 Initialize automatic variables with either a pattern or with zeroes to increase
13947 the security and predictability of a program by preventing uninitialized memory
13948 disclosure and use.
13949 GCC still considers an automatic variable that doesn't have an explicit
13950 initializer as uninitialized, @option{-Wuninitialized} and
13951 @option{-Wanalyzer-use-of-uninitialized-value} will still report
13952 warning messages on such automatic variables and the compiler will
13953 perform optimization as if the variable were uninitialized.
13954 With this option, GCC will also initialize any padding of automatic variables
13955 that have structure or union types to zeroes.
13956 However, the current implementation cannot initialize automatic variables that
13957 are declared between the controlling expression and the first case of a
13958 @code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13961 The three values of @var{choice} are:
13965 @samp{uninitialized} doesn't initialize any automatic variables.
13966 This is C and C++'s default.
13969 @samp{pattern} Initialize automatic variables with values which will likely
13970 transform logic bugs into crashes down the line, are easily recognized in a
13971 crash dump and without being values that programmers can rely on for useful
13973 The current value is byte-repeatable pattern with byte "0xFE".
13974 The values used for pattern initialization might be changed in the future.
13977 @samp{zero} Initialize automatic variables with zeroes.
13980 The default is @samp{uninitialized}.
13982 Note that the initializer values, whether @samp{zero} or @samp{pattern},
13983 refer to data representation (in memory or machine registers), rather
13984 than to their interpretation as numerical values. This distinction may
13985 be important in languages that support types with biases or implicit
13986 multipliers, and with such extensions as @samp{hardbool} (@pxref{Type
13987 Attributes}). For example, a variable that uses 8 bits to represent
13988 (biased) quantities in the @code{range 160..400} will be initialized
13989 with the bit patterns @code{0x00} or @code{0xFE}, depending on
13990 @var{choice}, whether or not these representations stand for values in
13991 that range, and even if they do, the interpretation of the value held by
13992 the variable will depend on the bias. A @samp{hardbool} variable that
13993 uses say @code{0X5A} and @code{0xA5} for @code{false} and @code{true},
13994 respectively, will trap with either @samp{choice} of trivial
13995 initializer, i.e., @samp{zero} initialization will not convert to the
13996 representation for @code{false}, even if it would for a @code{static}
13997 variable of the same type. This means the initializer pattern doesn't
13998 generally depend on the type of the initialized variable. One notable
13999 exception is that (non-hardened) boolean variables that fit in registers
14000 are initialized with @code{false} (zero), even when @samp{pattern} is
14003 You can control this behavior for a specific variable by using the variable
14004 attribute @code{uninitialized} (@pxref{Variable Attributes}).
14006 @opindex fvect-cost-model
14007 @item -fvect-cost-model=@var{model}
14008 Alter the cost model used for vectorization. The @var{model} argument
14009 should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
14011 With the @samp{unlimited} model the vectorized code-path is assumed
14012 to be profitable while with the @samp{dynamic} model a runtime check
14013 guards the vectorized code-path to enable it only for iteration
14014 counts that will likely execute faster than when executing the original
14015 scalar loop. The @samp{cheap} model disables vectorization of
14016 loops where doing so would be cost prohibitive for example due to
14017 required runtime checks for data dependence or alignment but otherwise
14018 is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
14019 allows vectorization if the vector code would entirely replace the
14020 scalar code that is being vectorized. For example, if each iteration
14021 of a vectorized loop would only be able to handle exactly four iterations
14022 of the scalar loop, the @samp{very-cheap} model would only allow
14023 vectorization if the scalar iteration count is known to be a multiple
14026 The default cost model depends on other optimization flags and is
14027 either @samp{dynamic} or @samp{cheap}.
14029 @opindex fsimd-cost-model
14030 @item -fsimd-cost-model=@var{model}
14031 Alter the cost model used for vectorization of loops marked with the OpenMP
14032 simd directive. The @var{model} argument should be one of
14033 @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
14034 have the same meaning as described in @option{-fvect-cost-model} and by
14035 default a cost model defined with @option{-fvect-cost-model} is used.
14039 Perform Value Range Propagation on trees. This is similar to the
14040 constant propagation pass, but instead of values, ranges of values are
14041 propagated. This allows the optimizers to remove unnecessary range
14042 checks like array bound checks and null pointer checks. This is
14043 enabled by default at @option{-O2} and higher. Null pointer check
14044 elimination is only done if @option{-fdelete-null-pointer-checks} is
14047 @opindex fsplit-paths
14048 @item -fsplit-paths
14049 Split paths leading to loop backedges. This can improve dead code
14050 elimination and common subexpression elimination. This is enabled by
14051 default at @option{-O3} and above.
14053 @opindex fsplit-ivs-in-unroller
14054 @item -fsplit-ivs-in-unroller
14055 Enables expression of values of induction variables in later iterations
14056 of the unrolled loop using the value in the first iteration. This breaks
14057 long dependency chains, thus improving efficiency of the scheduling passes.
14059 A combination of @option{-fweb} and CSE is often sufficient to obtain the
14060 same effect. However, that is not reliable in cases where the loop body
14061 is more complicated than a single basic block. It also does not work at all
14062 on some architectures due to restrictions in the CSE pass.
14064 This optimization is enabled by default.
14066 @opindex fvariable-expansion-in-unroller
14067 @item -fvariable-expansion-in-unroller
14068 With this option, the compiler creates multiple copies of some
14069 local variables when unrolling a loop, which can result in superior code.
14071 This optimization is enabled by default for PowerPC targets, but disabled
14072 by default otherwise.
14074 @opindex fpartial-inlining
14075 @item -fpartial-inlining
14076 Inline parts of functions. This option has any effect only
14077 when inlining itself is turned on by the @option{-finline-functions}
14078 or @option{-finline-small-functions} options.
14080 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14082 @opindex fpredictive-commoning
14083 @item -fpredictive-commoning
14084 Perform predictive commoning optimization, i.e., reusing computations
14085 (especially memory loads and stores) performed in previous
14086 iterations of loops.
14088 This option is enabled at level @option{-O3}.
14089 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14091 @opindex fprefetch-loop-arrays
14092 @item -fprefetch-loop-arrays
14093 If supported by the target machine, generate instructions to prefetch
14094 memory to improve the performance of loops that access large arrays.
14096 This option may generate better or worse code; results are highly
14097 dependent on the structure of loops within the source code.
14099 Disabled at level @option{-Os}.
14101 @opindex fno-printf-return-value
14102 @opindex fprintf-return-value
14103 @item -fno-printf-return-value
14104 Do not substitute constants for known return value of formatted output
14105 functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
14106 @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
14107 transformation allows GCC to optimize or even eliminate branches based
14108 on the known return value of these functions called with arguments that
14109 are either constant, or whose values are known to be in a range that
14110 makes determining the exact return value possible. For example, when
14111 @option{-fprintf-return-value} is in effect, both the branch and the
14112 body of the @code{if} statement (but not the call to @code{snprint})
14113 can be optimized away when @code{i} is a 32-bit or smaller integer
14114 because the return value is guaranteed to be at most 8.
14118 if (snprintf (buf, "%08x", i) >= sizeof buf)
14122 The @option{-fprintf-return-value} option relies on other optimizations
14123 and yields best results with @option{-O2} and above. It works in tandem
14124 with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
14125 options. The @option{-fprintf-return-value} option is enabled by default.
14127 @opindex fno-peephole
14129 @opindex fno-peephole2
14130 @opindex fpeephole2
14131 @item -fno-peephole
14132 @itemx -fno-peephole2
14133 Disable any machine-specific peephole optimizations. The difference
14134 between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
14135 are implemented in the compiler; some targets use one, some use the
14136 other, a few use both.
14138 @option{-fpeephole} is enabled by default.
14139 @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14141 @opindex fno-guess-branch-probability
14142 @opindex fguess-branch-probability
14143 @item -fno-guess-branch-probability
14144 Do not guess branch probabilities using heuristics.
14146 GCC uses heuristics to guess branch probabilities if they are
14147 not provided by profiling feedback (@option{-fprofile-arcs}). These
14148 heuristics are based on the control flow graph. If some branch probabilities
14149 are specified by @code{__builtin_expect}, then the heuristics are
14150 used to guess branch probabilities for the rest of the control flow graph,
14151 taking the @code{__builtin_expect} info into account. The interactions
14152 between the heuristics and @code{__builtin_expect} can be complex, and in
14153 some cases, it may be useful to disable the heuristics so that the effects
14154 of @code{__builtin_expect} are easier to understand.
14156 It is also possible to specify expected probability of the expression
14157 with @code{__builtin_expect_with_probability} built-in function.
14159 The default is @option{-fguess-branch-probability} at levels
14160 @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
14162 @opindex freorder-blocks
14163 @item -freorder-blocks
14164 Reorder basic blocks in the compiled function in order to reduce number of
14165 taken branches and improve code locality.
14167 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14169 @opindex freorder-blocks-algorithm
14170 @item -freorder-blocks-algorithm=@var{algorithm}
14171 Use the specified algorithm for basic block reordering. The
14172 @var{algorithm} argument can be @samp{simple}, which does not increase
14173 code size (except sometimes due to secondary effects like alignment),
14174 or @samp{stc}, the ``software trace cache'' algorithm, which tries to
14175 put all often executed code together, minimizing the number of branches
14176 executed by making extra copies of code.
14178 The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
14179 @samp{stc} at levels @option{-O2}, @option{-O3}.
14181 @opindex freorder-blocks-and-partition
14182 @item -freorder-blocks-and-partition
14183 In addition to reordering basic blocks in the compiled function, in order
14184 to reduce number of taken branches, partitions hot and cold basic blocks
14185 into separate sections of the assembly and @file{.o} files, to improve
14186 paging and cache locality performance.
14188 This optimization is automatically turned off in the presence of
14189 exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
14190 section attribute and on any architecture that does not support named
14191 sections. When @option{-fsplit-stack} is used this option is not
14192 enabled by default (to avoid linker errors), but may be enabled
14193 explicitly (if using a working linker).
14195 Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
14197 @opindex freorder-functions
14198 @item -freorder-functions
14199 Reorder functions in the object file in order to
14200 improve code locality. This is implemented by using special
14201 subsections @code{.text.hot} for most frequently executed functions and
14202 @code{.text.unlikely} for unlikely executed functions. Reordering is done by
14203 the linker so object file format must support named sections and linker must
14204 place them in a reasonable way.
14206 This option isn't effective unless you either provide profile feedback
14207 (see @option{-fprofile-arcs} for details) or manually annotate functions with
14208 @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
14210 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14212 @opindex fstrict-aliasing
14213 @item -fstrict-aliasing
14214 Allow the compiler to assume the strictest aliasing rules applicable to
14215 the language being compiled. For C (and C++), this activates
14216 optimizations based on the type of expressions. In particular, an
14217 object of one type is assumed never to reside at the same address as an
14218 object of a different type, unless the types are almost the same. For
14219 example, an @code{unsigned int} can alias an @code{int}, but not a
14220 @code{void*} or a @code{double}. A character type may alias any other
14223 @anchor{Type-punning}Pay special attention to code like this:
14236 The practice of reading from a different union member than the one most
14237 recently written to (called ``type-punning'') is common. Even with
14238 @option{-fstrict-aliasing}, type-punning is allowed, provided the memory
14239 is accessed through the union type. So, the code above works as
14240 expected. @xref{Structures unions enumerations and bit-fields
14241 implementation}. However, this code might not:
14252 Similarly, access by taking the address, casting the resulting pointer
14253 and dereferencing the result has undefined behavior, even if the cast
14254 uses a union type, e.g.:
14258 return ((union a_union *) &d)->i;
14262 The @option{-fstrict-aliasing} option is enabled at levels
14263 @option{-O2}, @option{-O3}, @option{-Os}.
14265 @opindex fipa-strict-aliasing
14266 @item -fipa-strict-aliasing
14267 Controls whether rules of @option{-fstrict-aliasing} are applied across
14268 function boundaries. Note that if multiple functions gets inlined into a
14269 single function the memory accesses are no longer considered to be crossing a
14272 The @option{-fipa-strict-aliasing} option is enabled by default and is
14273 effective only in combination with @option{-fstrict-aliasing}.
14275 @opindex falign-functions
14276 @item -falign-functions
14277 @itemx -falign-functions=@var{n}
14278 @itemx -falign-functions=@var{n}:@var{m}
14279 @itemx -falign-functions=@var{n}:@var{m}:@var{n2}
14280 @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
14281 Align the start of functions to the next power-of-two greater than or
14282 equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
14283 least the first @var{m} bytes of the function can be fetched by the CPU
14284 without crossing an @var{n}-byte alignment boundary.
14285 This is an optimization of code performance and alignment is ignored for
14286 functions considered cold. If alignment is required for all functions,
14287 use @option{-fmin-function-alignment}.
14289 If @var{m} is not specified, it defaults to @var{n}.
14291 Examples: @option{-falign-functions=32} aligns functions to the next
14292 32-byte boundary, @option{-falign-functions=24} aligns to the next
14293 32-byte boundary only if this can be done by skipping 23 bytes or less,
14294 @option{-falign-functions=32:7} aligns to the next
14295 32-byte boundary only if this can be done by skipping 6 bytes or less.
14297 The second pair of @var{n2}:@var{m2} values allows you to specify
14298 a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
14299 the next 64-byte boundary if this can be done by skipping 6 bytes or less,
14300 otherwise aligns to the next 32-byte boundary if this can be done
14301 by skipping 2 bytes or less.
14302 If @var{m2} is not specified, it defaults to @var{n2}.
14304 Some assemblers only support this flag when @var{n} is a power of two;
14305 in that case, it is rounded up.
14307 @option{-fno-align-functions} and @option{-falign-functions=1} are
14308 equivalent and mean that functions are not aligned.
14310 If @var{n} is not specified or is zero, use a machine-dependent default.
14311 The maximum allowed @var{n} option value is 65536.
14313 Enabled at levels @option{-O2}, @option{-O3}.
14315 @item -flimit-function-alignment
14316 If this option is enabled, the compiler tries to avoid unnecessarily
14317 overaligning functions. It attempts to instruct the assembler to align
14318 by the amount specified by @option{-falign-functions}, but not to
14319 skip more bytes than the size of the function.
14321 @opindex falign-labels
14322 @item -falign-labels
14323 @itemx -falign-labels=@var{n}
14324 @itemx -falign-labels=@var{n}:@var{m}
14325 @itemx -falign-labels=@var{n}:@var{m}:@var{n2}
14326 @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
14327 Align all branch targets to a power-of-two boundary.
14329 Parameters of this option are analogous to the @option{-falign-functions} option.
14330 @option{-fno-align-labels} and @option{-falign-labels=1} are
14331 equivalent and mean that labels are not aligned.
14333 If @option{-falign-loops} or @option{-falign-jumps} are applicable and
14334 are greater than this value, then their values are used instead.
14336 If @var{n} is not specified or is zero, use a machine-dependent default
14337 which is very likely to be @samp{1}, meaning no alignment.
14338 The maximum allowed @var{n} option value is 65536.
14340 Enabled at levels @option{-O2}, @option{-O3}.
14342 @opindex falign-loops
14343 @item -falign-loops
14344 @itemx -falign-loops=@var{n}
14345 @itemx -falign-loops=@var{n}:@var{m}
14346 @itemx -falign-loops=@var{n}:@var{m}:@var{n2}
14347 @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
14348 Align loops to a power-of-two boundary. If the loops are executed
14349 many times, this makes up for any execution of the dummy padding
14351 This is an optimization of code performance and alignment is ignored for
14352 loops considered cold.
14354 If @option{-falign-labels} is greater than this value, then its value
14357 Parameters of this option are analogous to the @option{-falign-functions} option.
14358 @option{-fno-align-loops} and @option{-falign-loops=1} are
14359 equivalent and mean that loops are not aligned.
14360 The maximum allowed @var{n} option value is 65536.
14362 If @var{n} is not specified or is zero, use a machine-dependent default.
14364 Enabled at levels @option{-O2}, @option{-O3}.
14366 @opindex falign-jumps
14367 @item -falign-jumps
14368 @itemx -falign-jumps=@var{n}
14369 @itemx -falign-jumps=@var{n}:@var{m}
14370 @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
14371 @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
14372 Align branch targets to a power-of-two boundary, for branch targets
14373 where the targets can only be reached by jumping. In this case,
14374 no dummy operations need be executed.
14375 This is an optimization of code performance and alignment is ignored for
14376 jumps considered cold.
14378 If @option{-falign-labels} is greater than this value, then its value
14381 Parameters of this option are analogous to the @option{-falign-functions} option.
14382 @option{-fno-align-jumps} and @option{-falign-jumps=1} are
14383 equivalent and mean that loops are not aligned.
14385 If @var{n} is not specified or is zero, use a machine-dependent default.
14386 The maximum allowed @var{n} option value is 65536.
14388 Enabled at levels @option{-O2}, @option{-O3}.
14390 @opindex fmin-function-alignment=@var{n}
14391 @item -fmin-function-alignment
14392 Specify minimal alignment of functions to the next power-of-two greater than or
14393 equal to @var{n}. Unlike @option{-falign-functions} this alignment is applied
14394 also to all functions (even those considered cold). The alignment is also not
14395 affected by @option{-flimit-function-alignment}
14398 @opindex fno-allocation-dce
14399 @item -fno-allocation-dce
14400 Do not remove unused C++ allocations in dead code elimination.
14402 @opindex fallow-store-data-races
14403 @item -fallow-store-data-races
14404 Allow the compiler to perform optimizations that may introduce new data races
14405 on stores, without proving that the variable cannot be concurrently accessed
14406 by other threads. Does not affect optimization of local data. It is safe to
14407 use this option if it is known that global data will not be accessed by
14410 Examples of optimizations enabled by @option{-fallow-store-data-races} include
14411 hoisting or if-conversions that may cause a value that was already in memory
14412 to be re-written with that same value. Such re-writing is safe in a single
14413 threaded context but may be unsafe in a multi-threaded context. Note that on
14414 some processors, if-conversions may be required in order to enable
14417 Enabled at level @option{-Ofast}.
14419 @opindex funit-at-a-time
14420 @item -funit-at-a-time
14421 This option is left for compatibility reasons. @option{-funit-at-a-time}
14422 has no effect, while @option{-fno-unit-at-a-time} implies
14423 @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
14425 Enabled by default.
14427 @opindex fno-toplevel-reorder
14428 @opindex ftoplevel-reorder
14429 @item -fno-toplevel-reorder
14430 Do not reorder top-level functions, variables, and @code{asm}
14431 statements. Output them in the same order that they appear in the
14432 input file. When this option is used, unreferenced static variables
14433 are not removed. This option is intended to support existing code
14434 that relies on a particular ordering. For new code, it is better to
14435 use attributes when possible.
14437 @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
14438 also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
14439 Additionally @option{-fno-toplevel-reorder} implies
14440 @option{-fno-section-anchors}.
14442 @opindex funreachable-traps
14443 @item -funreachable-traps
14444 With this option, the compiler turns calls to
14445 @code{__builtin_unreachable} into traps, instead of using them for
14446 optimization. This also affects any such calls implicitly generated
14449 This option has the same effect as @option{-fsanitize=unreachable
14450 -fsanitize-trap=unreachable}, but does not affect the values of those
14451 options. If @option{-fsanitize=unreachable} is enabled, that option
14452 takes priority over this one.
14454 This option is enabled by default at @option{-O0} and @option{-Og}.
14458 Constructs webs as commonly used for register allocation purposes and assign
14459 each web individual pseudo register. This allows the register allocation pass
14460 to operate on pseudos directly, but also strengthens several other optimization
14461 passes, such as CSE, loop optimizer and trivial dead code remover. It can,
14462 however, make debugging impossible, since variables no longer stay in a
14465 Enabled by default with @option{-funroll-loops}.
14467 @opindex fwhole-program
14468 @item -fwhole-program
14469 Assume that the current compilation unit represents the whole program being
14470 compiled. All public functions and variables with the exception of @code{main}
14471 and those merged by attribute @code{externally_visible} become static functions
14472 and in effect are optimized more aggressively by interprocedural optimizers.
14474 With @option{-flto} this option has a limited use. In most cases the
14475 precise list of symbols used or exported from the binary is known the
14476 resolution info passed to the link-time optimizer by the linker plugin. It is
14477 still useful if no linker plugin is used or during incremental link step when
14478 final code is produced (with @option{-flto}
14479 @option{-flinker-output=nolto-rel}).
14482 @item -flto[=@var{n}]
14483 This option runs the standard link-time optimizer. When invoked
14484 with source code, it generates GIMPLE (one of GCC's internal
14485 representations) and writes it to special ELF sections in the object
14486 file. When the object files are linked together, all the function
14487 bodies are read from these ELF sections and instantiated as if they
14488 had been part of the same translation unit.
14490 To use the link-time optimizer, @option{-flto} and optimization
14491 options should be specified at compile time and during the final link.
14492 It is recommended that you compile all the files participating in the
14493 same link with the same options and also specify those options at
14498 gcc -c -O2 -flto foo.c
14499 gcc -c -O2 -flto bar.c
14500 gcc -o myprog -flto -O2 foo.o bar.o
14503 The first two invocations to GCC save a bytecode representation
14504 of GIMPLE into special ELF sections inside @file{foo.o} and
14505 @file{bar.o}. The final invocation reads the GIMPLE bytecode from
14506 @file{foo.o} and @file{bar.o}, merges the two files into a single
14507 internal image, and compiles the result as usual. Since both
14508 @file{foo.o} and @file{bar.o} are merged into a single image, this
14509 causes all the interprocedural analyses and optimizations in GCC to
14510 work across the two files as if they were a single one. This means,
14511 for example, that the inliner is able to inline functions in
14512 @file{bar.o} into functions in @file{foo.o} and vice-versa.
14514 Another (simpler) way to enable link-time optimization is:
14517 gcc -o myprog -flto -O2 foo.c bar.c
14520 The above generates bytecode for @file{foo.c} and @file{bar.c},
14521 merges them together into a single GIMPLE representation and optimizes
14522 them as usual to produce @file{myprog}.
14524 The important thing to keep in mind is that to enable link-time
14525 optimizations you need to use the GCC driver to perform the link step.
14526 GCC automatically performs link-time optimization if any of the
14527 objects involved were compiled with the @option{-flto} command-line option.
14528 You can always override
14529 the automatic decision to do link-time optimization
14530 by passing @option{-fno-lto} to the link command.
14532 To make whole program optimization effective, it is necessary to make
14533 certain whole program assumptions. The compiler needs to know
14534 what functions and variables can be accessed by libraries and runtime
14535 outside of the link-time optimized unit. When supported by the linker,
14536 the linker plugin (see @option{-fuse-linker-plugin}) passes information
14537 to the compiler about used and externally visible symbols. When
14538 the linker plugin is not available, @option{-fwhole-program} should be
14539 used to allow the compiler to make these assumptions, which leads
14540 to more aggressive optimization decisions.
14542 When a file is compiled with @option{-flto} without
14543 @option{-fuse-linker-plugin}, the generated object file is larger than
14544 a regular object file because it contains GIMPLE bytecodes and the usual
14545 final code (see @option{-ffat-lto-objects}). This means that
14546 object files with LTO information can be linked as normal object
14547 files; if @option{-fno-lto} is passed to the linker, no
14548 interprocedural optimizations are applied. Note that when
14549 @option{-fno-fat-lto-objects} is enabled the compile stage is faster
14550 but you cannot perform a regular, non-LTO link on them.
14552 When producing the final binary, GCC only
14553 applies link-time optimizations to those files that contain bytecode.
14554 Therefore, you can mix and match object files and libraries with
14555 GIMPLE bytecodes and final object code. GCC automatically selects
14556 which files to optimize in LTO mode and which files to link without
14557 further processing.
14559 Generally, options specified at link time override those
14560 specified at compile time, although in some cases GCC attempts to infer
14561 link-time options from the settings used to compile the input files.
14563 If you do not specify an optimization level option @option{-O} at
14564 link time, then GCC uses the highest optimization level
14565 used when compiling the object files. Note that it is generally
14566 ineffective to specify an optimization level option only at link time and
14567 not at compile time, for two reasons. First, compiling without
14568 optimization suppresses compiler passes that gather information
14569 needed for effective optimization at link time. Second, some early
14570 optimization passes can be performed only at compile time and
14573 There are some code generation flags preserved by GCC when
14574 generating bytecodes, as they need to be used during the final link.
14575 Currently, the following options and their settings are taken from
14576 the first object file that explicitly specifies them:
14577 @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
14578 @option{-fgnu-tm} and all the @option{-m} target flags.
14580 The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
14581 @option{-fPIE} are combined based on the following scheme:
14584 @option{-fPIC} + @option{-fpic} = @option{-fpic}
14585 @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
14586 @option{-fpic/-fPIC} + (no option) = (no option)
14587 @option{-fPIC} + @option{-fPIE} = @option{-fPIE}
14588 @option{-fpic} + @option{-fPIE} = @option{-fpie}
14589 @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
14592 Certain ABI-changing flags are required to match in all compilation units,
14593 and trying to override this at link time with a conflicting value
14594 is ignored. This includes options such as @option{-freg-struct-return}
14595 and @option{-fpcc-struct-return}.
14597 Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
14598 @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
14599 are passed through to the link stage and merged conservatively for
14600 conflicting translation units. Specifically
14601 @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
14602 precedence; and for example @option{-ffp-contract=off} takes precedence
14603 over @option{-ffp-contract=fast}. You can override them at link time.
14605 Diagnostic options such as @option{-Wstringop-overflow} are passed
14606 through to the link stage and their setting matches that of the
14607 compile-step at function granularity. Note that this matters only
14608 for diagnostics emitted during optimization. Note that code
14609 transforms such as inlining can lead to warnings being enabled
14610 or disabled for regions if code not consistent with the setting
14613 When you need to pass options to the assembler via @option{-Wa} or
14614 @option{-Xassembler} make sure to either compile such translation
14615 units with @option{-fno-lto} or consistently use the same assembler
14616 options on all translation units. You can alternatively also
14617 specify assembler options at LTO link time.
14619 To enable debug info generation you need to supply @option{-g} at
14620 compile time. If any of the input files at link time were built
14621 with debug info generation enabled the link will enable debug info
14622 generation as well. Any elaborate debug info settings
14623 like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
14624 at the linker command line and mixing different settings in different
14625 translation units is discouraged.
14627 If LTO encounters objects with C linkage declared with incompatible
14628 types in separate translation units to be linked together (undefined
14629 behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
14630 issued. The behavior is still undefined at run time. Similar
14631 diagnostics may be raised for other languages.
14633 Another feature of LTO is that it is possible to apply interprocedural
14634 optimizations on files written in different languages:
14638 g++ -c -flto bar.cc
14639 gfortran -c -flto baz.f90
14640 g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
14643 Notice that the final link is done with @command{g++} to get the C++
14644 runtime libraries and @option{-lgfortran} is added to get the Fortran
14645 runtime libraries. In general, when mixing languages in LTO mode, you
14646 should use the same link command options as when mixing languages in a
14647 regular (non-LTO) compilation.
14649 If object files containing GIMPLE bytecode are stored in a library archive, say
14650 @file{libfoo.a}, it is possible to extract and use them in an LTO link if you
14651 are using a linker with plugin support. To create static libraries suitable
14652 for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
14653 and @command{ranlib};
14654 to show the symbols of object files with GIMPLE bytecode, use
14655 @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
14656 and @command{nm} have been compiled with plugin support. At link time, use the
14657 flag @option{-fuse-linker-plugin} to ensure that the library participates in
14658 the LTO optimization process:
14661 gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
14664 With the linker plugin enabled, the linker extracts the needed
14665 GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
14666 to make them part of the aggregated GIMPLE image to be optimized.
14668 If you are not using a linker with plugin support and/or do not
14669 enable the linker plugin, then the objects inside @file{libfoo.a}
14670 are extracted and linked as usual, but they do not participate
14671 in the LTO optimization process. In order to make a static library suitable
14672 for both LTO optimization and usual linkage, compile its object files with
14673 @option{-flto} @option{-ffat-lto-objects}.
14675 Link-time optimizations do not require the presence of the whole program to
14676 operate. If the program does not require any symbols to be exported, it is
14677 possible to combine @option{-flto} and @option{-fwhole-program} to allow
14678 the interprocedural optimizers to use more aggressive assumptions which may
14679 lead to improved optimization opportunities.
14680 Use of @option{-fwhole-program} is not needed when linker plugin is
14681 active (see @option{-fuse-linker-plugin}).
14683 The current implementation of LTO makes no
14684 attempt to generate bytecode that is portable between different
14685 types of hosts. The bytecode files are versioned and there is a
14686 strict version check, so bytecode files generated in one version of
14687 GCC do not work with an older or newer version of GCC.
14689 Link-time optimization does not work well with generation of debugging
14690 information on systems other than those using a combination of ELF and
14693 If you specify the optional @var{n}, the optimization and code
14694 generation done at link time is executed in parallel using @var{n}
14695 parallel jobs by utilizing an installed @command{make} program. The
14696 environment variable @env{MAKE} may be used to override the program
14699 You can also specify @option{-flto=jobserver} to use GNU make's
14700 job server mode to determine the number of parallel jobs. This
14701 is useful when the Makefile calling GCC is already executing in parallel.
14702 You must prepend a @samp{+} to the command recipe in the parent Makefile
14703 for this to work. This option likely only works if @env{MAKE} is
14704 GNU make. Even without the option value, GCC tries to automatically
14705 detect a running GNU make's job server.
14707 Use @option{-flto=auto} to use GNU make's job server, if available,
14708 or otherwise fall back to autodetection of the number of CPU threads
14709 present in your system.
14711 @opindex flto-partition
14712 @item -flto-partition=@var{alg}
14713 Specify the partitioning algorithm used by the link-time optimizer.
14714 The value is either @samp{1to1} to specify a partitioning mirroring
14715 the original source files or @samp{balanced} to specify partitioning
14716 into equally sized chunks (whenever possible) or @samp{max} to create
14717 new partition for every symbol where possible. Specifying @samp{none}
14718 as an algorithm disables partitioning and streaming completely.
14719 The default value is @samp{balanced}. While @samp{1to1} can be used
14720 as an workaround for various code ordering issues, the @samp{max}
14721 partitioning is intended for internal testing only.
14722 The value @samp{one} specifies that exactly one partition should be
14723 used while the value @samp{none} bypasses partitioning and executes
14724 the link-time optimization step directly from the WPA phase.
14726 @opindex flto-compression-level
14727 @item -flto-compression-level=@var{n}
14728 This option specifies the level of compression used for intermediate
14729 language written to LTO object files, and is only meaningful in
14730 conjunction with LTO mode (@option{-flto}). GCC currently supports two
14731 LTO compression algorithms. For zstd, valid values are 0 (no compression)
14732 to 19 (maximum compression), while zlib supports values from 0 to 9.
14733 Values outside this range are clamped to either minimum or maximum
14734 of the supported values. If the option is not given,
14735 a default balanced compression setting is used.
14737 @opindex fuse-linker-plugin
14738 @item -fuse-linker-plugin
14739 Enables the use of a linker plugin during link-time optimization. This
14740 option relies on plugin support in the linker, which is available in gold
14741 or in GNU ld 2.21 or newer.
14743 This option enables the extraction of object files with GIMPLE bytecode out
14744 of library archives. This improves the quality of optimization by exposing
14745 more code to the link-time optimizer. This information specifies what
14746 symbols can be accessed externally (by non-LTO object or during dynamic
14747 linking). Resulting code quality improvements on binaries (and shared
14748 libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14749 See @option{-flto} for a description of the effect of this flag and how to
14752 This option is enabled by default when LTO support in GCC is enabled
14753 and GCC was configured for use with
14754 a linker supporting plugins (GNU ld 2.21 or newer or gold).
14756 @opindex ffat-lto-objects
14757 @item -ffat-lto-objects
14758 Fat LTO objects are object files that contain both the intermediate language
14759 and the object code. This makes them usable for both LTO linking and normal
14760 linking. This option is effective only when compiling with @option{-flto}
14761 and is ignored at link time.
14763 @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14764 requires the complete toolchain to be aware of LTO. It requires a linker with
14765 linker plugin support for basic functionality. Additionally,
14766 @command{nm}, @command{ar} and @command{ranlib}
14767 need to support linker plugins to allow a full-featured build environment
14768 (capable of building static libraries etc). GCC provides the @command{gcc-ar},
14769 @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14770 to these tools. With non fat LTO makefiles need to be modified to use them.
14772 Note that modern binutils provide plugin auto-load mechanism.
14773 Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14774 effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14775 @command{gcc-ranlib}).
14777 The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14780 @opindex fcompare-elim
14781 @item -fcompare-elim
14782 After register allocation and post-register allocation instruction splitting,
14783 identify arithmetic instructions that compute processor flags similar to a
14784 comparison operation based on that arithmetic. If possible, eliminate the
14785 explicit comparison operation.
14787 This pass only applies to certain targets that cannot explicitly represent
14788 the comparison operation before register allocation is complete.
14790 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14792 @opindex ffold-mem-offsets
14793 @item -ffold-mem-offsets
14794 @itemx -fno-fold-mem-offsets
14795 Try to eliminate add instructions by folding them in memory loads/stores.
14797 Enabled at levels @option{-O2}, @option{-O3}.
14799 @opindex fcprop-registers
14800 @item -fcprop-registers
14801 After register allocation and post-register allocation instruction splitting,
14802 perform a copy-propagation pass to try to reduce scheduling dependencies
14803 and occasionally eliminate the copy.
14805 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14807 @opindex fprofile-correction
14808 @item -fprofile-correction
14809 Profiles collected using an instrumented binary for multi-threaded programs may
14810 be inconsistent due to missed counter updates. When this option is specified,
14811 GCC uses heuristics to correct or smooth out such inconsistencies. By
14812 default, GCC emits an error message when an inconsistent profile is detected.
14814 This option is enabled by @option{-fauto-profile}.
14816 @opindex fprofile-partial-training
14817 @item -fprofile-partial-training
14818 With @code{-fprofile-use} all portions of programs not executed during train
14819 run are optimized agressively for size rather than speed. In some cases it is
14820 not practical to train all possible hot paths in the program. (For
14821 example, program may contain functions specific for a given hardware and
14822 trianing may not cover all hardware configurations program is run on.) With
14823 @code{-fprofile-partial-training} profile feedback will be ignored for all
14824 functions not executed during the train run leading them to be optimized as if
14825 they were compiled without profile feedback. This leads to better performance
14826 when train run is not representative but also leads to significantly bigger
14829 @opindex fprofile-use
14830 @item -fprofile-use
14831 @itemx -fprofile-use=@var{path}
14832 Enable profile feedback-directed optimizations,
14833 and the following optimizations, many of which
14834 are generally profitable only with profile feedback available:
14836 @gccoptlist{-fbranch-probabilities -fprofile-values
14837 -funroll-loops -fpeel-loops -ftracer -fvpt
14838 -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14839 -fpredictive-commoning -fsplit-loops -funswitch-loops
14840 -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14841 -fvect-cost-model=dynamic -ftree-loop-distribute-patterns
14842 -fprofile-reorder-functions}
14844 Before you can use this option, you must first generate profiling information.
14845 @xref{Instrumentation Options}, for information about the
14846 @option{-fprofile-generate} option.
14848 By default, GCC emits an error message if the feedback profiles do not
14849 match the source code. This error can be turned into a warning by using
14850 @option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14851 optimized code. Additionally, by default, GCC also emits a warning message if
14852 the feedback profiles do not exist (see @option{-Wmissing-profile}).
14854 If @var{path} is specified, GCC looks at the @var{path} to find
14855 the profile feedback data files. See @option{-fprofile-dir}.
14857 @opindex fauto-profile
14858 @item -fauto-profile
14859 @itemx -fauto-profile=@var{path}
14860 Enable sampling-based feedback-directed optimizations,
14861 and the following optimizations,
14862 many of which are generally profitable only with profile feedback available:
14864 @gccoptlist{-fbranch-probabilities -fprofile-values
14865 -funroll-loops -fpeel-loops -ftracer -fvpt
14866 -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14867 -fpredictive-commoning -fsplit-loops -funswitch-loops
14868 -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14869 -fvect-cost-model=dynamic -ftree-loop-distribute-patterns
14870 -fprofile-correction}
14872 @var{path} is the name of a file containing AutoFDO profile information.
14873 If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14875 Producing an AutoFDO profile data file requires running your program
14876 with the @command{perf} utility on a supported GNU/Linux target system.
14877 For more information, see @uref{https://perf.wiki.kernel.org/}.
14881 perf record -e br_inst_retired:near_taken -b -o perf.data \
14885 Then use the @command{create_gcov} tool to convert the raw profile data
14886 to a format that can be used by GCC.@ You must also supply the
14887 unstripped binary for your program to this tool.
14888 See @uref{https://github.com/google/autofdo}.
14892 create_gcov --binary=your_program.unstripped --profile=perf.data \
14893 --gcov=profile.afdo
14897 The following options control compiler behavior regarding floating-point
14898 arithmetic. These options trade off between speed and
14899 correctness. All must be specifically enabled.
14902 @opindex ffloat-store
14903 @item -ffloat-store
14904 Do not store floating-point variables in registers, and inhibit other
14905 options that might change whether a floating-point value is taken from a
14906 register or memory.
14908 @cindex floating-point precision
14909 This option prevents undesirable excess precision on machines such as
14910 the 68000 where the floating registers (of the 68881) keep more
14911 precision than a @code{double} is supposed to have. Similarly for the
14912 x86 architecture. For most programs, the excess precision does only
14913 good, but a few programs rely on the precise definition of IEEE floating
14914 point. Use @option{-ffloat-store} for such programs, after modifying
14915 them to store all pertinent intermediate computations into variables.
14917 @opindex fexcess-precision
14918 @item -fexcess-precision=@var{style}
14919 This option allows further control over excess precision on machines
14920 where floating-point operations occur in a format with more precision or
14921 range than the IEEE standard and interchange floating-point types. By
14922 default, @option{-fexcess-precision=fast} is in effect; this means that
14923 operations may be carried out in a wider precision than the types specified
14924 in the source if that would result in faster code, and it is unpredictable
14925 when rounding to the types specified in the source code takes place.
14926 When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14927 then excess precision follows the rules specified in ISO C99 or C++; in particular,
14928 both casts and assignments cause values to be rounded to their
14929 semantic types (whereas @option{-ffloat-store} only affects
14930 assignments). This option is enabled by default for C or C++ if a strict
14931 conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14932 @option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14933 regardless of whether a strict conformance option is used.
14936 @option{-fexcess-precision=standard} is not implemented for languages
14937 other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14938 or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14939 semantics apply without excess precision, and in the latter, rounding
14942 @opindex ffast-math
14944 Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14945 @option{-ffinite-math-only}, @option{-fno-rounding-math},
14946 @option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14947 @option{-fexcess-precision=fast}.
14949 This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14951 This option is not turned on by any @option{-O} option besides
14952 @option{-Ofast} since it can result in incorrect output for programs
14953 that depend on an exact implementation of IEEE or ISO rules/specifications
14954 for math functions. It may, however, yield faster code for programs
14955 that do not require the guarantees of these specifications.
14957 @opindex fno-math-errno
14958 @opindex fmath-errno
14959 @item -fno-math-errno
14960 Do not set @code{errno} after calling math functions that are executed
14961 with a single instruction, e.g., @code{sqrt}. A program that relies on
14962 IEEE exceptions for math error handling may want to use this flag
14963 for speed while maintaining IEEE arithmetic compatibility.
14965 This option is not turned on by any @option{-O} option since
14966 it can result in incorrect output for programs that depend on
14967 an exact implementation of IEEE or ISO rules/specifications for
14968 math functions. It may, however, yield faster code for programs
14969 that do not require the guarantees of these specifications.
14971 The default is @option{-fmath-errno}.
14973 On Darwin systems, the math library never sets @code{errno}. There is
14974 therefore no reason for the compiler to consider the possibility that
14975 it might, and @option{-fno-math-errno} is the default.
14977 @opindex funsafe-math-optimizations
14978 @item -funsafe-math-optimizations
14980 Allow optimizations for floating-point arithmetic that (a) assume
14981 that arguments and results are valid and (b) may violate IEEE or
14982 ANSI standards. When used at link time, it may include libraries
14983 or startup files that change the default FPU control word or other
14984 similar optimizations.
14986 This option is not turned on by any @option{-O} option since
14987 it can result in incorrect output for programs that depend on
14988 an exact implementation of IEEE or ISO rules/specifications for
14989 math functions. It may, however, yield faster code for programs
14990 that do not require the guarantees of these specifications.
14991 Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14992 @option{-fassociative-math} and @option{-freciprocal-math}.
14994 The default is @option{-fno-unsafe-math-optimizations}.
14996 @opindex fassociative-math
14997 @item -fassociative-math
14999 Allow re-association of operands in series of floating-point operations.
15000 This violates the ISO C and C++ language standard by possibly changing
15001 computation result. NOTE: re-ordering may change the sign of zero as
15002 well as ignore NaNs and inhibit or create underflow or overflow (and
15003 thus cannot be used on code that relies on rounding behavior like
15004 @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
15005 and thus may not be used when ordered comparisons are required.
15006 This option requires that both @option{-fno-signed-zeros} and
15007 @option{-fno-trapping-math} be in effect. Moreover, it doesn't make
15008 much sense with @option{-frounding-math}. For Fortran the option
15009 is automatically enabled when both @option{-fno-signed-zeros} and
15010 @option{-fno-trapping-math} are in effect.
15012 The default is @option{-fno-associative-math}.
15014 @opindex freciprocal-math
15015 @item -freciprocal-math
15017 Allow the reciprocal of a value to be used instead of dividing by
15018 the value if this enables optimizations. For example @code{x / y}
15019 can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
15020 is subject to common subexpression elimination. Note that this loses
15021 precision and increases the number of flops operating on the value.
15023 The default is @option{-fno-reciprocal-math}.
15025 @opindex ffinite-math-only
15026 @item -ffinite-math-only
15027 Allow optimizations for floating-point arithmetic that assume
15028 that arguments and results are not NaNs or +-Infs.
15030 This option is not turned on by any @option{-O} option since
15031 it can result in incorrect output for programs that depend on
15032 an exact implementation of IEEE or ISO rules/specifications for
15033 math functions. It may, however, yield faster code for programs
15034 that do not require the guarantees of these specifications.
15036 The default is @option{-fno-finite-math-only}.
15038 @opindex fno-signed-zeros
15039 @opindex fsigned-zeros
15040 @item -fno-signed-zeros
15041 Allow optimizations for floating-point arithmetic that ignore the
15042 signedness of zero. IEEE arithmetic specifies the behavior of
15043 distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
15044 of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
15045 This option implies that the sign of a zero result isn't significant.
15047 The default is @option{-fsigned-zeros}.
15049 @opindex fno-trapping-math
15050 @opindex ftrapping-math
15051 @item -fno-trapping-math
15052 Compile code assuming that floating-point operations cannot generate
15053 user-visible traps. These traps include division by zero, overflow,
15054 underflow, inexact result and invalid operation. This option requires
15055 that @option{-fno-signaling-nans} be in effect. Setting this option may
15056 allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
15058 This option should never be turned on by any @option{-O} option since
15059 it can result in incorrect output for programs that depend on
15060 an exact implementation of IEEE or ISO rules/specifications for
15063 The default is @option{-ftrapping-math}.
15065 Future versions of GCC may provide finer control of this setting
15066 using C99's @code{FENV_ACCESS} pragma. This command-line option
15067 will be used along with @option{-frounding-math} to specify the
15068 default state for @code{FENV_ACCESS}.
15070 @opindex frounding-math
15071 @item -frounding-math
15072 Disable transformations and optimizations that assume default floating-point
15073 rounding behavior. This is round-to-zero for all floating point
15074 to integer conversions, and round-to-nearest for all other arithmetic
15075 truncations. This option should be specified for programs that change
15076 the FP rounding mode dynamically, or that may be executed with a
15077 non-default rounding mode. This option disables constant folding of
15078 floating-point expressions at compile time (which may be affected by
15079 rounding mode) and arithmetic transformations that are unsafe in the
15080 presence of sign-dependent rounding modes.
15082 The default is @option{-fno-rounding-math}.
15084 This option is experimental and does not currently guarantee to
15085 disable all GCC optimizations that are affected by rounding mode.
15086 Future versions of GCC may provide finer control of this setting
15087 using C99's @code{FENV_ACCESS} pragma. This command-line option
15088 will be used along with @option{-ftrapping-math} to specify the
15089 default state for @code{FENV_ACCESS}.
15091 @opindex fsignaling-nans
15092 @item -fsignaling-nans
15093 Compile code assuming that IEEE signaling NaNs may generate user-visible
15094 traps during floating-point operations. Setting this option disables
15095 optimizations that may change the number of exceptions visible with
15096 signaling NaNs. This option implies @option{-ftrapping-math}.
15098 This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
15101 The default is @option{-fno-signaling-nans}.
15103 This option is experimental and does not currently guarantee to
15104 disable all GCC optimizations that affect signaling NaN behavior.
15106 @opindex fno-fp-int-builtin-inexact
15107 @opindex ffp-int-builtin-inexact
15108 @item -fno-fp-int-builtin-inexact
15109 Do not allow the built-in functions @code{ceil}, @code{floor},
15110 @code{round} and @code{trunc}, and their @code{float} and @code{long
15111 double} variants, to generate code that raises the ``inexact''
15112 floating-point exception for noninteger arguments. ISO C99 and C11
15113 allow these functions to raise the ``inexact'' exception, but ISO/IEC
15114 TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
15115 ISO C23, does not allow these functions to do so.
15117 The default is @option{-ffp-int-builtin-inexact}, allowing the
15118 exception to be raised, unless C23 or a later C standard is selected.
15119 This option does nothing unless @option{-ftrapping-math} is in effect.
15121 Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
15122 generate a call to a library function then the ``inexact'' exception
15123 may be raised if the library implementation does not follow TS 18661.
15125 @opindex fsingle-precision-constant
15126 @item -fsingle-precision-constant
15127 Treat floating-point constants as single precision instead of
15128 implicitly converting them to double-precision constants.
15130 @opindex fcx-limited-range
15131 @item -fcx-limited-range
15132 When enabled, this option states that a range reduction step is not
15133 needed when performing complex division. Also, there is no checking
15134 whether the result of a complex multiplication or division is @code{NaN
15135 + I*NaN}, with an attempt to rescue the situation in that case. The
15136 default is @option{-fno-cx-limited-range}, but is enabled by
15137 @option{-ffast-math}.
15139 This option controls the default setting of the ISO C99
15140 @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
15143 @opindex fcx-fortran-rules
15144 @item -fcx-fortran-rules
15145 Complex multiplication and division follow Fortran rules. Range
15146 reduction is done as part of complex division, but there is no checking
15147 whether the result of a complex multiplication or division is @code{NaN
15148 + I*NaN}, with an attempt to rescue the situation in that case.
15150 The default is @option{-fno-cx-fortran-rules}.
15154 The following options control optimizations that may improve
15155 performance, but are not enabled by any @option{-O} options. This
15156 section includes experimental options that may produce broken code.
15159 @opindex fbranch-probabilities
15160 @item -fbranch-probabilities
15161 After running a program compiled with @option{-fprofile-arcs}
15162 (@pxref{Instrumentation Options}),
15163 you can compile it a second time using
15164 @option{-fbranch-probabilities}, to improve optimizations based on
15165 the number of times each branch was taken. When a program
15166 compiled with @option{-fprofile-arcs} exits, it saves arc execution
15167 counts to a file called @file{@var{sourcename}.gcda} for each source
15168 file. The information in this data file is very dependent on the
15169 structure of the generated code, so you must use the same source code
15170 and the same optimization options for both compilations.
15171 See details about the file naming in @option{-fprofile-arcs}.
15173 With @option{-fbranch-probabilities}, GCC puts a
15174 @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
15175 These can be used to improve optimization. Currently, they are only
15176 used in one place: in @file{reorg.cc}, instead of guessing which path a
15177 branch is most likely to take, the @samp{REG_BR_PROB} values are used to
15178 exactly determine which path is taken more often.
15180 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15182 @opindex fprofile-values
15183 @item -fprofile-values
15184 If combined with @option{-fprofile-arcs}, it adds code so that some
15185 data about values of expressions in the program is gathered.
15187 With @option{-fbranch-probabilities}, it reads back the data gathered
15188 from profiling values of expressions for usage in optimizations.
15190 Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
15191 @option{-fauto-profile}.
15193 @opindex fprofile-reorder-functions
15194 @item -fprofile-reorder-functions
15195 Function reordering based on profile instrumentation collects
15196 first time of execution of a function and orders these functions
15197 in ascending order.
15199 Enabled with @option{-fprofile-use}.
15203 If combined with @option{-fprofile-arcs}, this option instructs the compiler
15204 to add code to gather information about values of expressions.
15206 With @option{-fbranch-probabilities}, it reads back the data gathered
15207 and actually performs the optimizations based on them.
15208 Currently the optimizations include specialization of division operations
15209 using the knowledge about the value of the denominator.
15211 Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
15213 @opindex frename-registers
15214 @item -frename-registers
15215 Attempt to avoid false dependencies in scheduled code by making use
15216 of registers left over after register allocation. This optimization
15217 most benefits processors with lots of registers. Depending on the
15218 debug information format adopted by the target, however, it can
15219 make debugging impossible, since variables no longer stay in
15220 a ``home register''.
15222 Enabled by default with @option{-funroll-loops}.
15224 @opindex fschedule-fusion
15225 @item -fschedule-fusion
15226 Performs a target dependent pass over the instruction stream to schedule
15227 instructions of same type together because target machine can execute them
15228 more efficiently if they are adjacent to each other in the instruction flow.
15230 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
15234 Perform tail duplication to enlarge superblock size. This transformation
15235 simplifies the control flow of the function allowing other optimizations to do
15238 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15240 @opindex funroll-loops
15241 @item -funroll-loops
15242 Unroll loops whose number of iterations can be determined at compile time or
15243 upon entry to the loop. @option{-funroll-loops} implies
15244 @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
15245 It also turns on complete loop peeling (i.e.@: complete removal of loops with
15246 a small constant number of iterations). This option makes code larger, and may
15247 or may not make it run faster.
15249 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15251 @opindex funroll-all-loops
15252 @item -funroll-all-loops
15253 Unroll all loops, even if their number of iterations is uncertain when
15254 the loop is entered. This usually makes programs run more slowly.
15255 @option{-funroll-all-loops} implies the same options as
15256 @option{-funroll-loops}.
15258 @opindex fpeel-loops
15260 Peels loops for which there is enough information that they do not
15261 roll much (from profile feedback or static analysis). It also turns on
15262 complete loop peeling (i.e.@: complete removal of loops with small constant
15263 number of iterations).
15265 Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
15267 @opindex fmove-loop-invariants
15268 @item -fmove-loop-invariants
15269 Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
15270 at level @option{-O1} and higher, except for @option{-Og}.
15272 @opindex fmove-loop-stores
15273 @item -fmove-loop-stores
15274 Enables the loop store motion pass in the GIMPLE loop optimizer. This
15275 moves invariant stores to after the end of the loop in exchange for
15276 carrying the stored value in a register across the iteration.
15277 Note for this option to have an effect @option{-ftree-loop-im} has to
15278 be enabled as well. Enabled at level @option{-O1} and higher, except
15281 @opindex fsplit-loops
15282 @item -fsplit-loops
15283 Split a loop into two if it contains a condition that's always true
15284 for one side of the iteration space and false for the other.
15286 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15288 @opindex funswitch-loops
15289 @item -funswitch-loops
15290 Move branches with loop invariant conditions out of the loop, with duplicates
15291 of the loop on both branches (modified according to result of the condition).
15293 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15295 @opindex fversion-loops-for-strides
15296 @item -fversion-loops-for-strides
15297 If a loop iterates over an array with a variable stride, create another
15298 version of the loop that assumes the stride is always one. For example:
15301 for (int i = 0; i < n; ++i)
15302 x[i * stride] = @dots{};
15309 for (int i = 0; i < n; ++i)
15312 for (int i = 0; i < n; ++i)
15313 x[i * stride] = @dots{};
15316 This is particularly useful for assumed-shape arrays in Fortran where
15317 (for example) it allows better vectorization assuming contiguous accesses.
15318 This flag is enabled by default at @option{-O3}.
15319 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15321 @opindex ffunction-sections
15322 @opindex fdata-sections
15323 @item -ffunction-sections
15324 @itemx -fdata-sections
15325 Place each function or data item into its own section in the output
15326 file if the target supports arbitrary sections. The name of the
15327 function or the name of the data item determines the section's name
15328 in the output file.
15330 Use these options on systems where the linker can perform optimizations to
15331 improve locality of reference in the instruction space. Most systems using the
15332 ELF object format have linkers with such optimizations. On AIX, the linker
15333 rearranges sections (CSECTs) based on the call graph. The performance impact
15336 Together with a linker garbage collection (linker @option{--gc-sections}
15337 option) these options may lead to smaller statically-linked executables (after
15340 On ELF/DWARF systems these options do not degenerate the quality of the debug
15341 information. There could be issues with other object files/debug info formats.
15343 Only use these options when there are significant benefits from doing so. When
15344 you specify these options, the assembler and linker create larger object and
15345 executable files and are also slower. These options affect code generation.
15346 They prevent optimizations by the compiler and assembler using relative
15347 locations inside a translation unit since the locations are unknown until
15348 link time. An example of such an optimization is relaxing calls to short call
15351 @opindex fstdarg-opt
15353 Optimize the prologue of variadic argument functions with respect to usage of
15356 @opindex fsection-anchors
15357 @item -fsection-anchors
15358 Try to reduce the number of symbolic address calculations by using
15359 shared ``anchor'' symbols to address nearby objects. This transformation
15360 can help to reduce the number of GOT entries and GOT accesses on some
15363 For example, the implementation of the following function @code{foo}:
15366 static int a, b, c;
15367 int foo (void) @{ return a + b + c; @}
15371 usually calculates the addresses of all three variables, but if you
15372 compile it with @option{-fsection-anchors}, it accesses the variables
15373 from a common anchor point instead. The effect is similar to the
15374 following pseudocode (which isn't valid C):
15379 register int *xr = &x;
15380 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
15384 Not all targets support this option.
15386 @opindex fzero-call-used-regs
15387 @item -fzero-call-used-regs=@var{choice}
15388 Zero call-used registers at function return to increase program
15389 security by either mitigating Return-Oriented Programming (ROP)
15390 attacks or preventing information leakage through registers.
15392 The possible values of @var{choice} are the same as for the
15393 @code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
15394 The default is @samp{skip}.
15396 You can control this behavior for a specific function by using the function
15397 attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
15400 @item --param @var{name}=@var{value}
15401 In some places, GCC uses various constants to control the amount of
15402 optimization that is done. For example, GCC does not inline functions
15403 that contain more than a certain number of instructions. You can
15404 control some of these constants on the command line using the
15405 @option{--param} option.
15407 The names of specific parameters, and the meaning of the values, are
15408 tied to the internals of the compiler, and are subject to change
15409 without notice in future releases.
15411 In order to get the minimal, maximal and default values of a parameter,
15412 use the @option{--help=param -Q} options.
15414 In each case, the @var{value} is an integer. The following choices
15415 of @var{name} are recognized for all targets:
15418 @item predictable-branch-outcome
15419 When branch is predicted to be taken with probability lower than this threshold
15420 (in percent), then it is considered well predictable.
15422 @item max-rtl-if-conversion-insns
15423 RTL if-conversion tries to remove conditional branches around a block and
15424 replace them with conditionally executed instructions. This parameter
15425 gives the maximum number of instructions in a block which should be
15426 considered for if-conversion. The compiler will
15427 also use other heuristics to decide whether if-conversion is likely to be
15430 @item max-rtl-if-conversion-predictable-cost
15431 RTL if-conversion will try to remove conditional branches around a block
15432 and replace them with conditionally executed instructions. These parameters
15433 give the maximum permissible cost for the sequence that would be generated
15434 by if-conversion depending on whether the branch is statically determined
15435 to be predictable or not. The units for this parameter are the same as
15436 those for the GCC internal seq_cost metric. The compiler will try to
15437 provide a reasonable default for this parameter using the BRANCH_COST
15440 @item max-crossjump-edges
15441 The maximum number of incoming edges to consider for cross-jumping.
15442 The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
15443 the number of edges incoming to each block. Increasing values mean
15444 more aggressive optimization, making the compilation time increase with
15445 probably small improvement in executable size.
15447 @item min-crossjump-insns
15448 The minimum number of instructions that must be matched at the end
15449 of two blocks before cross-jumping is performed on them. This
15450 value is ignored in the case where all instructions in the block being
15451 cross-jumped from are matched.
15453 @item max-grow-copy-bb-insns
15454 The maximum code size expansion factor when copying basic blocks
15455 instead of jumping. The expansion is relative to a jump instruction.
15457 @item max-goto-duplication-insns
15458 The maximum number of instructions to duplicate to a block that jumps
15459 to a computed goto. To avoid @math{O(N^2)} behavior in a number of
15460 passes, GCC factors computed gotos early in the compilation process,
15461 and unfactors them as late as possible. Only computed jumps at the
15462 end of a basic blocks with no more than max-goto-duplication-insns are
15465 @item max-delay-slot-insn-search
15466 The maximum number of instructions to consider when looking for an
15467 instruction to fill a delay slot. If more than this arbitrary number of
15468 instructions are searched, the time savings from filling the delay slot
15469 are minimal, so stop searching. Increasing values mean more
15470 aggressive optimization, making the compilation time increase with probably
15471 small improvement in execution time.
15473 @item max-delay-slot-live-search
15474 When trying to fill delay slots, the maximum number of instructions to
15475 consider when searching for a block with valid live register
15476 information. Increasing this arbitrarily chosen value means more
15477 aggressive optimization, increasing the compilation time. This parameter
15478 should be removed when the delay slot code is rewritten to maintain the
15479 control-flow graph.
15481 @item max-gcse-memory
15482 The approximate maximum amount of memory in @code{kB} that can be allocated in
15483 order to perform the global common subexpression elimination
15484 optimization. If more memory than specified is required, the
15485 optimization is not done.
15487 @item max-gcse-insertion-ratio
15488 If the ratio of expression insertions to deletions is larger than this value
15489 for any expression, then RTL PRE inserts or removes the expression and thus
15490 leaves partially redundant computations in the instruction stream.
15492 @item max-pending-list-length
15493 The maximum number of pending dependencies scheduling allows
15494 before flushing the current state and starting over. Large functions
15495 with few branches or calls can create excessively large lists which
15496 needlessly consume memory and resources.
15498 @item max-modulo-backtrack-attempts
15499 The maximum number of backtrack attempts the scheduler should make
15500 when modulo scheduling a loop. Larger values can exponentially increase
15503 @item max-inline-functions-called-once-loop-depth
15504 Maximal loop depth of a call considered by inline heuristics that tries to
15505 inline all functions called once.
15507 @item max-inline-functions-called-once-insns
15508 Maximal estimated size of functions produced while inlining functions called
15511 @item max-inline-insns-single
15512 Several parameters control the tree inliner used in GCC@. This number sets the
15513 maximum number of instructions (counted in GCC's internal representation) in a
15514 single function that the tree inliner considers for inlining. This only
15515 affects functions declared inline and methods implemented in a class
15519 @item max-inline-insns-auto
15520 When you use @option{-finline-functions} (included in @option{-O3}),
15521 a lot of functions that would otherwise not be considered for inlining
15522 by the compiler are investigated. To those functions, a different
15523 (more restrictive) limit compared to functions declared inline can
15524 be applied (@option{--param max-inline-insns-auto}).
15526 @item max-inline-insns-small
15527 This is bound applied to calls which are considered relevant with
15528 @option{-finline-small-functions}.
15530 @item max-inline-insns-size
15531 This is bound applied to calls which are optimized for size. Small growth
15532 may be desirable to anticipate optimization oppurtunities exposed by inlining.
15534 @item uninlined-function-insns
15535 Number of instructions accounted by inliner for function overhead such as
15536 function prologue and epilogue.
15538 @item uninlined-function-time
15539 Extra time accounted by inliner for function overhead such as time needed to
15540 execute function prologue and epilogue.
15542 @item inline-heuristics-hint-percent
15543 The scale (in percents) applied to @option{inline-insns-single},
15544 @option{inline-insns-single-O2}, @option{inline-insns-auto}
15545 when inline heuristics hints that inlining is
15546 very profitable (will enable later optimizations).
15548 @item uninlined-thunk-insns
15549 @item uninlined-thunk-time
15550 Same as @option{--param uninlined-function-insns} and
15551 @option{--param uninlined-function-time} but applied to function thunks.
15553 @item inline-min-speedup
15554 When estimated performance improvement of caller + callee runtime exceeds this
15555 threshold (in percent), the function can be inlined regardless of the limit on
15556 @option{--param max-inline-insns-single} and @option{--param
15557 max-inline-insns-auto}.
15559 @item large-function-insns
15560 The limit specifying really large functions. For functions larger than this
15561 limit after inlining, inlining is constrained by
15562 @option{--param large-function-growth}. This parameter is useful primarily
15563 to avoid extreme compilation time caused by non-linear algorithms used by the
15566 @item large-function-growth
15567 Specifies maximal growth of large function caused by inlining in percents.
15568 For example, parameter value 100 limits large function growth to 2.0 times
15571 @item large-unit-insns
15572 The limit specifying large translation unit. Growth caused by inlining of
15573 units larger than this limit is limited by @option{--param inline-unit-growth}.
15574 For small units this might be too tight.
15575 For example, consider a unit consisting of function A
15576 that is inline and B that just calls A three times. If B is small relative to
15577 A, the growth of unit is 300\% and yet such inlining is very sane. For very
15578 large units consisting of small inlineable functions, however, the overall unit
15579 growth limit is needed to avoid exponential explosion of code size. Thus for
15580 smaller units, the size is increased to @option{--param large-unit-insns}
15581 before applying @option{--param inline-unit-growth}.
15584 Maximum number of concurrently open C++ module files when lazy loading.
15586 @item inline-unit-growth
15587 Specifies maximal overall growth of the compilation unit caused by inlining.
15588 For example, parameter value 20 limits unit growth to 1.2 times the original
15589 size. Cold functions (either marked cold via an attribute or by profile
15590 feedback) are not accounted into the unit size.
15592 @item ipa-cp-unit-growth
15593 Specifies maximal overall growth of the compilation unit caused by
15594 interprocedural constant propagation. For example, parameter value 10 limits
15595 unit growth to 1.1 times the original size.
15597 @item ipa-cp-large-unit-insns
15598 The size of translation unit that IPA-CP pass considers large.
15600 @item large-stack-frame
15601 The limit specifying large stack frames. While inlining the algorithm is trying
15602 to not grow past this limit too much.
15604 @item large-stack-frame-growth
15605 Specifies maximal growth of large stack frames caused by inlining in percents.
15606 For example, parameter value 1000 limits large stack frame growth to 11 times
15609 @item max-inline-insns-recursive
15610 @itemx max-inline-insns-recursive-auto
15611 Specifies the maximum number of instructions an out-of-line copy of a
15612 self-recursive inline
15613 function can grow into by performing recursive inlining.
15615 @option{--param max-inline-insns-recursive} applies to functions
15617 For functions not declared inline, recursive inlining
15618 happens only when @option{-finline-functions} (included in @option{-O3}) is
15619 enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
15621 @item max-inline-recursive-depth
15622 @itemx max-inline-recursive-depth-auto
15623 Specifies the maximum recursion depth used for recursive inlining.
15625 @option{--param max-inline-recursive-depth} applies to functions
15626 declared inline. For functions not declared inline, recursive inlining
15627 happens only when @option{-finline-functions} (included in @option{-O3}) is
15628 enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
15630 @item min-inline-recursive-probability
15631 Recursive inlining is profitable only for function having deep recursion
15632 in average and can hurt for function having little recursion depth by
15633 increasing the prologue size or complexity of function body to other
15636 When profile feedback is available (see @option{-fprofile-generate}) the actual
15637 recursion depth can be guessed from the probability that function recurses
15638 via a given call expression. This parameter limits inlining only to call
15639 expressions whose probability exceeds the given threshold (in percents).
15641 @item early-inlining-insns
15642 Specify growth that the early inliner can make. In effect it increases
15643 the amount of inlining for code having a large abstraction penalty.
15645 @item max-early-inliner-iterations
15646 Limit of iterations of the early inliner. This basically bounds
15647 the number of nested indirect calls the early inliner can resolve.
15648 Deeper chains are still handled by late inlining.
15650 @item comdat-sharing-probability
15651 Probability (in percent) that C++ inline function with comdat visibility
15652 are shared across multiple compilation units.
15654 @item modref-max-bases
15655 @item modref-max-refs
15656 @item modref-max-accesses
15657 Specifies the maximal number of base pointers, references and accesses stored
15658 for a single function by mod/ref analysis.
15660 @item modref-max-tests
15661 Specifies the maxmal number of tests alias oracle can perform to disambiguate
15662 memory locations using the mod/ref information. This parameter ought to be
15663 bigger than @option{--param modref-max-bases} and @option{--param
15666 @item modref-max-depth
15667 Specifies the maximum depth of DFS walk used by modref escape analysis.
15668 Setting to 0 disables the analysis completely.
15670 @item modref-max-escape-points
15671 Specifies the maximum number of escape points tracked by modref per SSA-name.
15673 @item modref-max-adjustments
15674 Specifies the maximum number the access range is enlarged during modref dataflow
15677 @item profile-func-internal-id
15678 A parameter to control whether to use function internal id in profile
15679 database lookup. If the value is 0, the compiler uses an id that
15680 is based on function assembler name and filename, which makes old profile
15681 data more tolerant to source changes such as function reordering etc.
15683 @item min-vect-loop-bound
15684 The minimum number of iterations under which loops are not vectorized
15685 when @option{-ftree-vectorize} is used. The number of iterations after
15686 vectorization needs to be greater than the value specified by this option
15687 to allow vectorization.
15689 @item gcse-cost-distance-ratio
15690 Scaling factor in calculation of maximum distance an expression
15691 can be moved by GCSE optimizations. This is currently supported only in the
15692 code hoisting pass. The bigger the ratio, the more aggressive code hoisting
15693 is with simple expressions, i.e., the expressions that have cost
15694 less than @option{gcse-unrestricted-cost}. Specifying 0 disables
15695 hoisting of simple expressions.
15697 @item gcse-unrestricted-cost
15698 Cost, roughly measured as the cost of a single typical machine
15699 instruction, at which GCSE optimizations do not constrain
15700 the distance an expression can travel. This is currently
15701 supported only in the code hoisting pass. The lesser the cost,
15702 the more aggressive code hoisting is. Specifying 0
15703 allows all expressions to travel unrestricted distances.
15705 @item max-hoist-depth
15706 The depth of search in the dominator tree for expressions to hoist.
15707 This is used to avoid quadratic behavior in hoisting algorithm.
15708 The value of 0 does not limit on the search, but may slow down compilation
15711 @item max-tail-merge-comparisons
15712 The maximum amount of similar bbs to compare a bb with. This is used to
15713 avoid quadratic behavior in tree tail merging.
15715 @item max-tail-merge-iterations
15716 The maximum amount of iterations of the pass over the function. This is used to
15717 limit compilation time in tree tail merging.
15719 @item store-merging-allow-unaligned
15720 Allow the store merging pass to introduce unaligned stores if it is legal to
15723 @item max-stores-to-merge
15724 The maximum number of stores to attempt to merge into wider stores in the store
15727 @item max-store-chains-to-track
15728 The maximum number of store chains to track at the same time in the attempt
15729 to merge them into wider stores in the store merging pass.
15731 @item max-stores-to-track
15732 The maximum number of stores to track at the same time in the attemt to
15733 to merge them into wider stores in the store merging pass.
15735 @item max-unrolled-insns
15736 The maximum number of instructions that a loop may have to be unrolled.
15737 If a loop is unrolled, this parameter also determines how many times
15738 the loop code is unrolled.
15740 @item max-average-unrolled-insns
15741 The maximum number of instructions biased by probabilities of their execution
15742 that a loop may have to be unrolled. If a loop is unrolled,
15743 this parameter also determines how many times the loop code is unrolled.
15745 @item max-unroll-times
15746 The maximum number of unrollings of a single loop.
15748 @item max-peeled-insns
15749 The maximum number of instructions that a loop may have to be peeled.
15750 If a loop is peeled, this parameter also determines how many times
15751 the loop code is peeled.
15753 @item max-peel-times
15754 The maximum number of peelings of a single loop.
15756 @item max-peel-branches
15757 The maximum number of branches on the hot path through the peeled sequence.
15759 @item max-completely-peeled-insns
15760 The maximum number of insns of a completely peeled loop.
15762 @item max-completely-peel-times
15763 The maximum number of iterations of a loop to be suitable for complete peeling.
15765 @item max-completely-peel-loop-nest-depth
15766 The maximum depth of a loop nest suitable for complete peeling.
15768 @item max-unswitch-insns
15769 The maximum number of insns of an unswitched loop.
15771 @item max-unswitch-depth
15772 The maximum depth of a loop nest to be unswitched.
15774 @item lim-expensive
15775 The minimum cost of an expensive expression in the loop invariant motion.
15777 @item min-loop-cond-split-prob
15778 When FDO profile information is available, @option{min-loop-cond-split-prob}
15779 specifies minimum threshold for probability of semi-invariant condition
15780 statement to trigger loop split.
15782 @item iv-consider-all-candidates-bound
15783 Bound on number of candidates for induction variables, below which
15784 all candidates are considered for each use in induction variable
15785 optimizations. If there are more candidates than this,
15786 only the most relevant ones are considered to avoid quadratic time complexity.
15788 @item iv-max-considered-uses
15789 The induction variable optimizations give up on loops that contain more
15790 induction variable uses.
15792 @item iv-always-prune-cand-set-bound
15793 If the number of candidates in the set is smaller than this value,
15794 always try to remove unnecessary ivs from the set
15795 when adding a new one.
15797 @item avg-loop-niter
15798 Average number of iterations of a loop.
15800 @item dse-max-object-size
15801 Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15802 Larger values may result in larger compilation times.
15804 @item dse-max-alias-queries-per-store
15805 Maximum number of queries into the alias oracle per store.
15806 Larger values result in larger compilation times and may result in more
15807 removed dead stores.
15809 @item scev-max-expr-size
15810 Bound on size of expressions used in the scalar evolutions analyzer.
15811 Large expressions slow the analyzer.
15813 @item scev-max-expr-complexity
15814 Bound on the complexity of the expressions in the scalar evolutions analyzer.
15815 Complex expressions slow the analyzer.
15817 @item max-tree-if-conversion-phi-args
15818 Maximum number of arguments in a PHI supported by TREE if conversion
15819 unless the loop is marked with simd pragma.
15821 @item vect-max-layout-candidates
15822 The maximum number of possible vector layouts (such as permutations)
15823 to consider when optimizing to-be-vectorized code.
15825 @item vect-max-version-for-alignment-checks
15826 The maximum number of run-time checks that can be performed when
15827 doing loop versioning for alignment in the vectorizer.
15829 @item vect-max-version-for-alias-checks
15830 The maximum number of run-time checks that can be performed when
15831 doing loop versioning for alias in the vectorizer.
15833 @item vect-max-peeling-for-alignment
15834 The maximum number of loop peels to enhance access alignment
15835 for vectorizer. Value -1 means no limit.
15837 @item max-iterations-to-track
15838 The maximum number of iterations of a loop the brute-force algorithm
15839 for analysis of the number of iterations of the loop tries to evaluate.
15841 @item hot-bb-count-fraction
15842 The denominator n of fraction 1/n of the maximal execution count of a
15843 basic block in the entire program that a basic block needs to at least
15844 have in order to be considered hot. The default is 10000, which means
15845 that a basic block is considered hot if its execution count is greater
15846 than 1/10000 of the maximal execution count. 0 means that it is never
15847 considered hot. Used in non-LTO mode.
15849 @item hot-bb-count-ws-permille
15850 The number of most executed permilles, ranging from 0 to 1000, of the
15851 profiled execution of the entire program to which the execution count
15852 of a basic block must be part of in order to be considered hot. The
15853 default is 990, which means that a basic block is considered hot if
15854 its execution count contributes to the upper 990 permilles, or 99.0%,
15855 of the profiled execution of the entire program. 0 means that it is
15856 never considered hot. Used in LTO mode.
15858 @item hot-bb-frequency-fraction
15859 The denominator n of fraction 1/n of the execution frequency of the
15860 entry block of a function that a basic block of this function needs
15861 to at least have in order to be considered hot. The default is 1000,
15862 which means that a basic block is considered hot in a function if it
15863 is executed more frequently than 1/1000 of the frequency of the entry
15864 block of the function. 0 means that it is never considered hot.
15866 @item unlikely-bb-count-fraction
15867 The denominator n of fraction 1/n of the number of profiled runs of
15868 the entire program below which the execution count of a basic block
15869 must be in order for the basic block to be considered unlikely executed.
15870 The default is 20, which means that a basic block is considered unlikely
15871 executed if it is executed in fewer than 1/20, or 5%, of the runs of
15872 the program. 0 means that it is always considered unlikely executed.
15874 @item max-predicted-iterations
15875 The maximum number of loop iterations we predict statically. This is useful
15876 in cases where a function contains a single loop with known bound and
15877 another loop with unknown bound.
15878 The known number of iterations is predicted correctly, while
15879 the unknown number of iterations average to roughly 10. This means that the
15880 loop without bounds appears artificially cold relative to the other one.
15882 @item builtin-expect-probability
15883 Control the probability of the expression having the specified value. This
15884 parameter takes a percentage (i.e.@: 0 ... 100) as input.
15886 @item builtin-string-cmp-inline-length
15887 The maximum length of a constant string for a builtin string cmp call
15888 eligible for inlining.
15890 @item align-threshold
15892 Select fraction of the maximal frequency of executions of a basic block in
15893 a function to align the basic block.
15895 @item align-loop-iterations
15897 A loop expected to iterate at least the selected number of iterations is
15900 @item tracer-dynamic-coverage
15901 @itemx tracer-dynamic-coverage-feedback
15903 This value is used to limit superblock formation once the given percentage of
15904 executed instructions is covered. This limits unnecessary code size
15907 The @option{tracer-dynamic-coverage-feedback} parameter
15908 is used only when profile
15909 feedback is available. The real profiles (as opposed to statically estimated
15910 ones) are much less balanced allowing the threshold to be larger value.
15912 @item tracer-max-code-growth
15913 Stop tail duplication once code growth has reached given percentage. This is
15914 a rather artificial limit, as most of the duplicates are eliminated later in
15915 cross jumping, so it may be set to much higher values than is the desired code
15918 @item tracer-min-branch-ratio
15920 Stop reverse growth when the reverse probability of best edge is less than this
15921 threshold (in percent).
15923 @item tracer-min-branch-probability
15924 @itemx tracer-min-branch-probability-feedback
15926 Stop forward growth if the best edge has probability lower than this
15929 Similarly to @option{tracer-dynamic-coverage} two parameters are
15930 provided. @option{tracer-min-branch-probability-feedback} is used for
15931 compilation with profile feedback and @option{tracer-min-branch-probability}
15932 compilation without. The value for compilation with profile feedback
15933 needs to be more conservative (higher) in order to make tracer
15936 @item stack-clash-protection-guard-size
15937 Specify the size of the operating system provided stack guard as
15938 2 raised to @var{num} bytes. Higher values may reduce the
15939 number of explicit probes, but a value larger than the operating system
15940 provided guard will leave code vulnerable to stack clash style attacks.
15942 @item stack-clash-protection-probe-interval
15943 Stack clash protection involves probing stack space as it is allocated. This
15944 param controls the maximum distance between probes into the stack as 2 raised
15945 to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15946 larger than the operating system provided guard will leave code vulnerable to
15947 stack clash style attacks.
15949 @item max-cse-path-length
15951 The maximum number of basic blocks on path that CSE considers.
15953 @item max-cse-insns
15954 The maximum number of instructions CSE processes before flushing.
15956 @item ggc-min-expand
15958 GCC uses a garbage collector to manage its own memory allocation. This
15959 parameter specifies the minimum percentage by which the garbage
15960 collector's heap should be allowed to expand between collections.
15961 Tuning this may improve compilation speed; it has no effect on code
15964 The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15965 RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15966 the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15967 GCC is not able to calculate RAM on a particular platform, the lower
15968 bound of 30% is used. Setting this parameter and
15969 @option{ggc-min-heapsize} to zero causes a full collection to occur at
15970 every opportunity. This is extremely slow, but can be useful for
15973 @item ggc-min-heapsize
15975 Minimum size of the garbage collector's heap before it begins bothering
15976 to collect garbage. The first collection occurs after the heap expands
15977 by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15978 tuning this may improve compilation speed, and has no effect on code
15981 The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15982 tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15983 with a lower bound of 4096 (four megabytes) and an upper bound of
15984 131072 (128 megabytes). If GCC is not able to calculate RAM on a
15985 particular platform, the lower bound is used. Setting this parameter
15986 very large effectively disables garbage collection. Setting this
15987 parameter and @option{ggc-min-expand} to zero causes a full collection
15988 to occur at every opportunity.
15990 @item max-reload-search-insns
15991 The maximum number of instruction reload should look backward for equivalent
15992 register. Increasing values mean more aggressive optimization, making the
15993 compilation time increase with probably slightly better performance.
15995 @item max-cselib-memory-locations
15996 The maximum number of memory locations cselib should take into account.
15997 Increasing values mean more aggressive optimization, making the compilation time
15998 increase with probably slightly better performance.
16000 @item max-sched-ready-insns
16001 The maximum number of instructions ready to be issued the scheduler should
16002 consider at any given time during the first scheduling pass. Increasing
16003 values mean more thorough searches, making the compilation time increase
16004 with probably little benefit.
16006 @item max-sched-region-blocks
16007 The maximum number of blocks in a region to be considered for
16008 interblock scheduling.
16010 @item max-pipeline-region-blocks
16011 The maximum number of blocks in a region to be considered for
16012 pipelining in the selective scheduler.
16014 @item max-sched-region-insns
16015 The maximum number of insns in a region to be considered for
16016 interblock scheduling.
16018 @item max-pipeline-region-insns
16019 The maximum number of insns in a region to be considered for
16020 pipelining in the selective scheduler.
16022 @item min-spec-prob
16023 The minimum probability (in percents) of reaching a source block
16024 for interblock speculative scheduling.
16026 @item max-sched-extend-regions-iters
16027 The maximum number of iterations through CFG to extend regions.
16028 A value of 0 disables region extensions.
16030 @item max-sched-insn-conflict-delay
16031 The maximum conflict delay for an insn to be considered for speculative motion.
16033 @item sched-spec-prob-cutoff
16034 The minimal probability of speculation success (in percents), so that
16035 speculative insns are scheduled.
16037 @item sched-state-edge-prob-cutoff
16038 The minimum probability an edge must have for the scheduler to save its
16041 @item sched-mem-true-dep-cost
16042 Minimal distance (in CPU cycles) between store and load targeting same
16045 @item selsched-max-lookahead
16046 The maximum size of the lookahead window of selective scheduling. It is a
16047 depth of search for available instructions.
16049 @item selsched-max-sched-times
16050 The maximum number of times that an instruction is scheduled during
16051 selective scheduling. This is the limit on the number of iterations
16052 through which the instruction may be pipelined.
16054 @item selsched-insns-to-rename
16055 The maximum number of best instructions in the ready list that are considered
16056 for renaming in the selective scheduler.
16059 The minimum value of stage count that swing modulo scheduler
16062 @item max-last-value-rtl
16063 The maximum size measured as number of RTLs that can be recorded in an expression
16064 in combiner for a pseudo register as last known value of that register.
16066 @item max-combine-insns
16067 The maximum number of instructions the RTL combiner tries to combine.
16069 @item integer-share-limit
16070 Small integer constants can use a shared data structure, reducing the
16071 compiler's memory usage and increasing its speed. This sets the maximum
16072 value of a shared integer constant.
16074 @item ssp-buffer-size
16075 The minimum size of buffers (i.e.@: arrays) that receive stack smashing
16076 protection when @option{-fstack-protector} is used.
16078 @item min-size-for-stack-sharing
16079 The minimum size of variables taking part in stack slot sharing when not
16082 @item max-jump-thread-duplication-stmts
16083 Maximum number of statements allowed in a block that needs to be
16084 duplicated when threading jumps.
16086 @item max-jump-thread-paths
16087 The maximum number of paths to consider when searching for jump threading
16088 opportunities. When arriving at a block, incoming edges are only considered
16089 if the number of paths to be searched so far multiplied by the number of
16090 incoming edges does not exhaust the specified maximum number of paths to
16093 @item max-fields-for-field-sensitive
16094 Maximum number of fields in a structure treated in
16095 a field sensitive manner during pointer analysis.
16097 @item prefetch-latency
16098 Estimate on average number of instructions that are executed before
16099 prefetch finishes. The distance prefetched ahead is proportional
16100 to this constant. Increasing this number may also lead to less
16101 streams being prefetched (see @option{simultaneous-prefetches}).
16103 @item simultaneous-prefetches
16104 Maximum number of prefetches that can run at the same time.
16106 @item l1-cache-line-size
16107 The size of cache line in L1 data cache, in bytes.
16109 @item l1-cache-size
16110 The size of L1 data cache, in kilobytes.
16112 @item l2-cache-size
16113 The size of L2 data cache, in kilobytes.
16115 @item prefetch-dynamic-strides
16116 Whether the loop array prefetch pass should issue software prefetch hints
16117 for strides that are non-constant. In some cases this may be
16118 beneficial, though the fact the stride is non-constant may make it
16119 hard to predict when there is clear benefit to issuing these hints.
16121 Set to 1 if the prefetch hints should be issued for non-constant
16122 strides. Set to 0 if prefetch hints should be issued only for strides that
16123 are known to be constant and below @option{prefetch-minimum-stride}.
16125 @item prefetch-minimum-stride
16126 Minimum constant stride, in bytes, to start using prefetch hints for. If
16127 the stride is less than this threshold, prefetch hints will not be issued.
16129 This setting is useful for processors that have hardware prefetchers, in
16130 which case there may be conflicts between the hardware prefetchers and
16131 the software prefetchers. If the hardware prefetchers have a maximum
16132 stride they can handle, it should be used here to improve the use of
16133 software prefetchers.
16135 A value of -1 means we don't have a threshold and therefore
16136 prefetch hints can be issued for any constant stride.
16138 This setting is only useful for strides that are known and constant.
16140 @item destructive-interference-size
16141 @item constructive-interference-size
16142 The values for the C++17 variables
16143 @code{std::hardware_destructive_interference_size} and
16144 @code{std::hardware_constructive_interference_size}. The destructive
16145 interference size is the minimum recommended offset between two
16146 independent concurrently-accessed objects; the constructive
16147 interference size is the maximum recommended size of contiguous memory
16148 accessed together. Typically both will be the size of an L1 cache
16149 line for the target, in bytes. For a generic target covering a range of L1
16150 cache line sizes, typically the constructive interference size will be
16151 the small end of the range and the destructive size will be the large
16154 The destructive interference size is intended to be used for layout,
16155 and thus has ABI impact. The default value is not expected to be
16156 stable, and on some targets varies with @option{-mtune}, so use of
16157 this variable in a context where ABI stability is important, such as
16158 the public interface of a library, is strongly discouraged; if it is
16159 used in that context, users can stabilize the value using this
16162 The constructive interference size is less sensitive, as it is
16163 typically only used in a @samp{static_assert} to make sure that a type
16164 fits within a cache line.
16166 See also @option{-Winterference-size}.
16168 @item loop-interchange-max-num-stmts
16169 The maximum number of stmts in a loop to be interchanged.
16171 @item loop-interchange-stride-ratio
16172 The minimum ratio between stride of two loops for interchange to be profitable.
16174 @item min-insn-to-prefetch-ratio
16175 The minimum ratio between the number of instructions and the
16176 number of prefetches to enable prefetching in a loop.
16178 @item prefetch-min-insn-to-mem-ratio
16179 The minimum ratio between the number of instructions and the
16180 number of memory references to enable prefetching in a loop.
16182 @item use-canonical-types
16183 Whether the compiler should use the ``canonical'' type system.
16184 Should always be 1, which uses a more efficient internal
16185 mechanism for comparing types in C++ and Objective-C++. However, if
16186 bugs in the canonical type system are causing compilation failures,
16187 set this value to 0 to disable canonical types.
16189 @item switch-conversion-max-branch-ratio
16190 Switch initialization conversion refuses to create arrays that are
16191 bigger than @option{switch-conversion-max-branch-ratio} times the number of
16192 branches in the switch.
16194 @item max-partial-antic-length
16195 Maximum length of the partial antic set computed during the tree
16196 partial redundancy elimination optimization (@option{-ftree-pre}) when
16197 optimizing at @option{-O3} and above. For some sorts of source code
16198 the enhanced partial redundancy elimination optimization can run away,
16199 consuming all of the memory available on the host machine. This
16200 parameter sets a limit on the length of the sets that are computed,
16201 which prevents the runaway behavior. Setting a value of 0 for
16202 this parameter allows an unlimited set length.
16204 @item rpo-vn-max-loop-depth
16205 Maximum loop depth that is value-numbered optimistically.
16206 When the limit hits the innermost
16207 @var{rpo-vn-max-loop-depth} loops and the outermost loop in the
16208 loop nest are value-numbered optimistically and the remaining ones not.
16210 @item sccvn-max-alias-queries-per-access
16211 Maximum number of alias-oracle queries we perform when looking for
16212 redundancies for loads and stores. If this limit is hit the search
16213 is aborted and the load or store is not considered redundant. The
16214 number of queries is algorithmically limited to the number of
16215 stores on all paths from the load to the function entry.
16217 @item ira-max-loops-num
16218 IRA uses regional register allocation by default. If a function
16219 contains more loops than the number given by this parameter, only at most
16220 the given number of the most frequently-executed loops form regions
16221 for regional register allocation.
16223 @item ira-max-conflict-table-size
16224 Although IRA uses a sophisticated algorithm to compress the conflict
16225 table, the table can still require excessive amounts of memory for
16226 huge functions. If the conflict table for a function could be more
16227 than the size in MB given by this parameter, the register allocator
16228 instead uses a faster, simpler, and lower-quality
16229 algorithm that does not require building a pseudo-register conflict table.
16231 @item ira-loop-reserved-regs
16232 IRA can be used to evaluate more accurate register pressure in loops
16233 for decisions to move loop invariants (see @option{-O3}). The number
16234 of available registers reserved for some other purposes is given
16235 by this parameter. Default of the parameter
16236 is the best found from numerous experiments.
16238 @item ira-consider-dup-in-all-alts
16239 Make IRA to consider matching constraint (duplicated operand number)
16240 heavily in all available alternatives for preferred register class.
16241 If it is set as zero, it means IRA only respects the matching
16242 constraint when it's in the only available alternative with an
16243 appropriate register class. Otherwise, it means IRA will check all
16244 available alternatives for preferred register class even if it has
16245 found some choice with an appropriate register class and respect the
16246 found qualified matching constraint.
16248 @item ira-simple-lra-insn-threshold
16249 Approximate function insn number in 1K units triggering simple local RA.
16251 @item lra-inheritance-ebb-probability-cutoff
16252 LRA tries to reuse values reloaded in registers in subsequent insns.
16253 This optimization is called inheritance. EBB is used as a region to
16254 do this optimization. The parameter defines a minimal fall-through
16255 edge probability in percentage used to add BB to inheritance EBB in
16256 LRA. The default value was chosen
16257 from numerous runs of SPEC2000 on x86-64.
16259 @item loop-invariant-max-bbs-in-loop
16260 Loop invariant motion can be very expensive, both in compilation time and
16261 in amount of needed compile-time memory, with very large loops. Loops
16262 with more basic blocks than this parameter won't have loop invariant
16263 motion optimization performed on them.
16265 @item loop-max-datarefs-for-datadeps
16266 Building data dependencies is expensive for very large loops. This
16267 parameter limits the number of data references in loops that are
16268 considered for data dependence analysis. These large loops are no
16269 handled by the optimizations using loop data dependencies.
16271 @item max-vartrack-size
16272 Sets a maximum number of hash table slots to use during variable
16273 tracking dataflow analysis of any function. If this limit is exceeded
16274 with variable tracking at assignments enabled, analysis for that
16275 function is retried without it, after removing all debug insns from
16276 the function. If the limit is exceeded even without debug insns, var
16277 tracking analysis is completely disabled for the function. Setting
16278 the parameter to zero makes it unlimited.
16280 @item max-vartrack-expr-depth
16281 Sets a maximum number of recursion levels when attempting to map
16282 variable names or debug temporaries to value expressions. This trades
16283 compilation time for more complete debug information. If this is set too
16284 low, value expressions that are available and could be represented in
16285 debug information may end up not being used; setting this higher may
16286 enable the compiler to find more complex debug expressions, but compile
16287 time and memory use may grow.
16289 @item max-debug-marker-count
16290 Sets a threshold on the number of debug markers (e.g.@: begin stmt
16291 markers) to avoid complexity explosion at inlining or expanding to RTL.
16292 If a function has more such gimple stmts than the set limit, such stmts
16293 will be dropped from the inlined copy of a function, and from its RTL
16296 @item min-nondebug-insn-uid
16297 Use uids starting at this parameter for nondebug insns. The range below
16298 the parameter is reserved exclusively for debug insns created by
16299 @option{-fvar-tracking-assignments}, but debug insns may get
16300 (non-overlapping) uids above it if the reserved range is exhausted.
16302 @item ipa-sra-deref-prob-threshold
16303 IPA-SRA replaces a pointer which is known not be NULL with one or more
16304 new parameters only when the probability (in percent, relative to
16305 function entry) of it being dereferenced is higher than this parameter.
16307 @item ipa-sra-ptr-growth-factor
16308 IPA-SRA replaces a pointer to an aggregate with one or more new
16309 parameters only when their cumulative size is less or equal to
16310 @option{ipa-sra-ptr-growth-factor} times the size of the original
16313 @item ipa-sra-ptrwrap-growth-factor
16314 Additional maximum allowed growth of total size of new parameters
16315 that ipa-sra replaces a pointer to an aggregate with,
16316 if it points to a local variable that the caller only writes to and
16317 passes it as an argument to other functions.
16319 @item ipa-sra-max-replacements
16320 Maximum pieces of an aggregate that IPA-SRA tracks. As a
16321 consequence, it is also the maximum number of replacements of a formal
16324 @item sra-max-scalarization-size-Ospeed
16325 @itemx sra-max-scalarization-size-Osize
16326 The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
16327 replace scalar parts of aggregates with uses of independent scalar
16328 variables. These parameters control the maximum size, in storage units,
16329 of aggregate which is considered for replacement when compiling for
16331 (@option{sra-max-scalarization-size-Ospeed}) or size
16332 (@option{sra-max-scalarization-size-Osize}) respectively.
16334 @item sra-max-propagations
16335 The maximum number of artificial accesses that Scalar Replacement of
16336 Aggregates (SRA) will track, per one local variable, in order to
16337 facilitate copy propagation.
16339 @item tm-max-aggregate-size
16340 When making copies of thread-local variables in a transaction, this
16341 parameter specifies the size in bytes after which variables are
16342 saved with the logging functions as opposed to save/restore code
16343 sequence pairs. This option only applies when using
16346 @item graphite-max-nb-scop-params
16347 To avoid exponential effects in the Graphite loop transforms, the
16348 number of parameters in a Static Control Part (SCoP) is bounded.
16349 A value of zero can be used to lift
16350 the bound. A variable whose value is unknown at compilation time and
16351 defined outside a SCoP is a parameter of the SCoP.
16353 @item hardcfr-max-blocks
16354 Disable @option{-fharden-control-flow-redundancy} for functions with a
16355 larger number of blocks than the specified value. Zero removes any
16358 @item hardcfr-max-inline-blocks
16359 Force @option{-fharden-control-flow-redundancy} to use out-of-line
16360 checking for functions with a larger number of basic blocks than the
16363 @item loop-block-tile-size
16364 Loop blocking or strip mining transforms, enabled with
16365 @option{-floop-block} or @option{-floop-strip-mine}, strip mine each
16366 loop in the loop nest by a given number of iterations. The strip
16367 length can be changed using the @option{loop-block-tile-size}
16370 @item ipa-jump-function-lookups
16371 Specifies number of statements visited during jump function offset discovery.
16373 @item ipa-cp-value-list-size
16374 IPA-CP attempts to track all possible values and types passed to a function's
16375 parameter in order to propagate them and perform devirtualization.
16376 @option{ipa-cp-value-list-size} is the maximum number of values and types it
16377 stores per one formal parameter of a function.
16379 @item ipa-cp-eval-threshold
16380 IPA-CP calculates its own score of cloning profitability heuristics
16381 and performs those cloning opportunities with scores that exceed
16382 @option{ipa-cp-eval-threshold}.
16384 @item ipa-cp-max-recursive-depth
16385 Maximum depth of recursive cloning for self-recursive function.
16387 @item ipa-cp-min-recursive-probability
16388 Recursive cloning only when the probability of call being executed exceeds
16391 @item ipa-cp-profile-count-base
16392 When using @option{-fprofile-use} option, IPA-CP will consider the measured
16393 execution count of a call graph edge at this percentage position in their
16394 histogram as the basis for its heuristics calculation.
16396 @item ipa-cp-recursive-freq-factor
16397 The number of times interprocedural copy propagation expects recursive
16398 functions to call themselves.
16400 @item ipa-cp-recursion-penalty
16401 Percentage penalty the recursive functions will receive when they
16402 are evaluated for cloning.
16404 @item ipa-cp-single-call-penalty
16405 Percentage penalty functions containing a single call to another
16406 function will receive when they are evaluated for cloning.
16408 @item ipa-max-agg-items
16409 IPA-CP is also capable to propagate a number of scalar values passed
16410 in an aggregate. @option{ipa-max-agg-items} controls the maximum
16411 number of such values per one parameter.
16413 @item ipa-cp-loop-hint-bonus
16414 When IPA-CP determines that a cloning candidate would make the number
16415 of iterations of a loop known, it adds a bonus of
16416 @option{ipa-cp-loop-hint-bonus} to the profitability score of
16419 @item ipa-max-loop-predicates
16420 The maximum number of different predicates IPA will use to describe when
16421 loops in a function have known properties.
16423 @item ipa-max-aa-steps
16424 During its analysis of function bodies, IPA-CP employs alias analysis
16425 in order to track values pointed to by function parameters. In order
16426 not spend too much time analyzing huge functions, it gives up and
16427 consider all memory clobbered after examining
16428 @option{ipa-max-aa-steps} statements modifying memory.
16430 @item ipa-max-switch-predicate-bounds
16431 Maximal number of boundary endpoints of case ranges of switch statement.
16432 For switch exceeding this limit, IPA-CP will not construct cloning cost
16433 predicate, which is used to estimate cloning benefit, for default case
16434 of the switch statement.
16436 @item ipa-max-param-expr-ops
16437 IPA-CP will analyze conditional statement that references some function
16438 parameter to estimate benefit for cloning upon certain constant value.
16439 But if number of operations in a parameter expression exceeds
16440 @option{ipa-max-param-expr-ops}, the expression is treated as complicated
16441 one, and is not handled by IPA analysis.
16443 @item lto-partitions
16444 Specify desired number of partitions produced during WHOPR compilation.
16445 The number of partitions should exceed the number of CPUs used for compilation.
16447 @item lto-min-partition
16448 Size of minimal partition for WHOPR (in estimated instructions).
16449 This prevents expenses of splitting very small programs into too many
16452 @item lto-max-partition
16453 Size of max partition for WHOPR (in estimated instructions).
16454 to provide an upper bound for individual size of partition.
16455 Meant to be used only with balanced partitioning.
16457 @item lto-max-streaming-parallelism
16458 Maximal number of parallel processes used for LTO streaming.
16460 @item cxx-max-namespaces-for-diagnostic-help
16461 The maximum number of namespaces to consult for suggestions when C++
16462 name lookup fails for an identifier.
16464 @item sink-frequency-threshold
16465 The maximum relative execution frequency (in percents) of the target block
16466 relative to a statement's original block to allow statement sinking of a
16467 statement. Larger numbers result in more aggressive statement sinking.
16468 A small positive adjustment is applied for
16469 statements with memory operands as those are even more profitable so sink.
16471 @item max-stores-to-sink
16472 The maximum number of conditional store pairs that can be sunk. Set to 0
16473 if either vectorization (@option{-ftree-vectorize}) or if-conversion
16474 (@option{-ftree-loop-if-convert}) is disabled.
16476 @item case-values-threshold
16477 The smallest number of different values for which it is best to use a
16478 jump-table instead of a tree of conditional branches. If the value is
16479 0, use the default for the machine.
16481 @item jump-table-max-growth-ratio-for-size
16482 The maximum code size growth ratio when expanding
16483 into a jump table (in percent). The parameter is used when
16484 optimizing for size.
16486 @item jump-table-max-growth-ratio-for-speed
16487 The maximum code size growth ratio when expanding
16488 into a jump table (in percent). The parameter is used when
16489 optimizing for speed.
16491 @item tree-reassoc-width
16492 Set the maximum number of instructions executed in parallel in
16493 reassociated tree. This parameter overrides target dependent
16494 heuristics used by default if has non zero value.
16496 @item sched-pressure-algorithm
16497 Choose between the two available implementations of
16498 @option{-fsched-pressure}. Algorithm 1 is the original implementation
16499 and is the more likely to prevent instructions from being reordered.
16500 Algorithm 2 was designed to be a compromise between the relatively
16501 conservative approach taken by algorithm 1 and the rather aggressive
16502 approach taken by the default scheduler. It relies more heavily on
16503 having a regular register file and accurate register pressure classes.
16504 See @file{haifa-sched.cc} in the GCC sources for more details.
16506 The default choice depends on the target.
16508 @item max-slsr-cand-scan
16509 Set the maximum number of existing candidates that are considered when
16510 seeking a basis for a new straight-line strength reduction candidate.
16513 Enable buffer overflow detection for global objects. This kind
16514 of protection is enabled by default if you are using
16515 @option{-fsanitize=address} option.
16516 To disable global objects protection use @option{--param asan-globals=0}.
16519 Enable buffer overflow detection for stack objects. This kind of
16520 protection is enabled by default when using @option{-fsanitize=address}.
16521 To disable stack protection use @option{--param asan-stack=0} option.
16523 @item asan-instrument-reads
16524 Enable buffer overflow detection for memory reads. This kind of
16525 protection is enabled by default when using @option{-fsanitize=address}.
16526 To disable memory reads protection use
16527 @option{--param asan-instrument-reads=0}.
16529 @item asan-instrument-writes
16530 Enable buffer overflow detection for memory writes. This kind of
16531 protection is enabled by default when using @option{-fsanitize=address}.
16532 To disable memory writes protection use
16533 @option{--param asan-instrument-writes=0} option.
16535 @item asan-memintrin
16536 Enable detection for built-in functions. This kind of protection
16537 is enabled by default when using @option{-fsanitize=address}.
16538 To disable built-in functions protection use
16539 @option{--param asan-memintrin=0}.
16541 @item asan-use-after-return
16542 Enable detection of use-after-return. This kind of protection
16543 is enabled by default when using the @option{-fsanitize=address} option.
16544 To disable it use @option{--param asan-use-after-return=0}.
16546 Note: By default the check is disabled at run time. To enable it,
16547 add @code{detect_stack_use_after_return=1} to the environment variable
16548 @env{ASAN_OPTIONS}.
16550 @item asan-instrumentation-with-call-threshold
16551 If number of memory accesses in function being instrumented
16552 is greater or equal to this number, use callbacks instead of inline checks.
16553 E.g. to disable inline code use
16554 @option{--param asan-instrumentation-with-call-threshold=0}.
16556 @item asan-kernel-mem-intrinsic-prefix
16557 If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
16558 with @samp{__asan_} or @samp{__hwasan_}
16559 for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
16562 @item hwasan-instrument-stack
16563 Enable hwasan instrumentation of statically sized stack-allocated variables.
16564 This kind of instrumentation is enabled by default when using
16565 @option{-fsanitize=hwaddress} and disabled by default when using
16566 @option{-fsanitize=kernel-hwaddress}.
16567 To disable stack instrumentation use
16568 @option{--param hwasan-instrument-stack=0}, and to enable it use
16569 @option{--param hwasan-instrument-stack=1}.
16571 @item hwasan-random-frame-tag
16572 When using stack instrumentation, decide tags for stack variables using a
16573 deterministic sequence beginning at a random tag for each frame. With this
16574 parameter unset tags are chosen using the same sequence but beginning from 1.
16575 This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
16576 for @option{-fsanitize=kernel-hwaddress}.
16577 To disable it use @option{--param hwasan-random-frame-tag=0}.
16579 @item hwasan-instrument-allocas
16580 Enable hwasan instrumentation of dynamically sized stack-allocated variables.
16581 This kind of instrumentation is enabled by default when using
16582 @option{-fsanitize=hwaddress} and disabled by default when using
16583 @option{-fsanitize=kernel-hwaddress}.
16584 To disable instrumentation of such variables use
16585 @option{--param hwasan-instrument-allocas=0}, and to enable it use
16586 @option{--param hwasan-instrument-allocas=1}.
16588 @item hwasan-instrument-reads
16589 Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
16590 default for both @option{-fsanitize=hwaddress} and
16591 @option{-fsanitize=kernel-hwaddress}.
16592 To disable checking memory reads use
16593 @option{--param hwasan-instrument-reads=0}.
16595 @item hwasan-instrument-writes
16596 Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
16597 default for both @option{-fsanitize=hwaddress} and
16598 @option{-fsanitize=kernel-hwaddress}.
16599 To disable checking memory writes use
16600 @option{--param hwasan-instrument-writes=0}.
16602 @item hwasan-instrument-mem-intrinsics
16603 Enable hwasan instrumentation of builtin functions. Instrumentation of these
16604 builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
16605 and @option{-fsanitize=kernel-hwaddress}.
16606 To disable instrumentation of builtin functions use
16607 @option{--param hwasan-instrument-mem-intrinsics=0}.
16609 @item use-after-scope-direct-emission-threshold
16610 If the size of a local variable in bytes is smaller or equal to this
16611 number, directly poison (or unpoison) shadow memory instead of using
16612 run-time callbacks.
16614 @item tsan-distinguish-volatile
16615 Emit special instrumentation for accesses to volatiles.
16617 @item tsan-instrument-func-entry-exit
16618 Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
16620 @item max-fsm-thread-path-insns
16621 Maximum number of instructions to copy when duplicating blocks on a
16622 finite state automaton jump thread path.
16624 @item threader-debug
16625 threader-debug=[none|all] Enables verbose dumping of the threader solver.
16627 @item parloops-chunk-size
16628 Chunk size of omp schedule for loops parallelized by parloops.
16630 @item parloops-schedule
16631 Schedule type of omp schedule for loops parallelized by parloops (static,
16632 dynamic, guided, auto, runtime).
16634 @item parloops-min-per-thread
16635 The minimum number of iterations per thread of an innermost parallelized
16636 loop for which the parallelized variant is preferred over the single threaded
16637 one. Note that for a parallelized loop nest the
16638 minimum number of iterations of the outermost loop per thread is two.
16640 @item max-ssa-name-query-depth
16641 Maximum depth of recursion when querying properties of SSA names in things
16642 like fold routines. One level of recursion corresponds to following a
16645 @item max-speculative-devirt-maydefs
16646 The maximum number of may-defs we analyze when looking for a must-def
16647 specifying the dynamic type of an object that invokes a virtual call
16648 we may be able to devirtualize speculatively.
16651 Specifies the type of debug output to be issued for ranges.
16653 @item unroll-jam-min-percent
16654 The minimum percentage of memory references that must be optimized
16655 away for the unroll-and-jam transformation to be considered profitable.
16657 @item unroll-jam-max-unroll
16658 The maximum number of times the outer loop should be unrolled by
16659 the unroll-and-jam transformation.
16661 @item max-rtl-if-conversion-unpredictable-cost
16662 Maximum permissible cost for the sequence that would be generated
16663 by the RTL if-conversion pass for a branch that is considered unpredictable.
16665 @item max-variable-expansions-in-unroller
16666 If @option{-fvariable-expansion-in-unroller} is used, the maximum number
16667 of times that an individual variable will be expanded during loop unrolling.
16669 @item partial-inlining-entry-probability
16670 Maximum probability of the entry BB of split region
16671 (in percent relative to entry BB of the function)
16672 to make partial inlining happen.
16674 @item max-tracked-strlens
16675 Maximum number of strings for which strlen optimization pass will
16676 track string lengths.
16678 @item gcse-after-reload-partial-fraction
16679 The threshold ratio for performing partial redundancy
16680 elimination after reload.
16682 @item gcse-after-reload-critical-fraction
16683 The threshold ratio of critical edges execution count that
16684 permit performing redundancy elimination after reload.
16686 @item max-loop-header-insns
16687 The maximum number of insns in loop header duplicated
16688 by the copy loop headers pass.
16690 @item vect-epilogues-nomask
16691 Enable loop epilogue vectorization using smaller vector size.
16693 @item vect-partial-vector-usage
16694 Controls when the loop vectorizer considers using partial vector loads
16695 and stores as an alternative to falling back to scalar code. 0 stops
16696 the vectorizer from ever using partial vector loads and stores. 1 allows
16697 partial vector loads and stores if vectorization removes the need for the
16698 code to iterate. 2 allows partial vector loads and stores in all loops.
16699 The parameter only has an effect on targets that support partial
16700 vector loads and stores.
16702 @item vect-inner-loop-cost-factor
16703 The maximum factor which the loop vectorizer applies to the cost of statements
16704 in an inner loop relative to the loop being vectorized. The factor applied
16705 is the maximum of the estimated number of iterations of the inner loop and
16706 this parameter. The default value of this parameter is 50.
16708 @item vect-induction-float
16709 Enable loop vectorization of floating point inductions.
16711 @item vrp-sparse-threshold
16712 Maximum number of basic blocks before VRP uses a sparse bitmap cache.
16714 @item vrp-switch-limit
16715 Maximum number of outgoing edges in a switch before VRP will not process it.
16717 @item vrp-vector-threshold
16718 Maximum number of basic blocks for VRP to use a basic cache vector.
16720 @item avoid-fma-max-bits
16721 Maximum number of bits for which we avoid creating FMAs.
16723 @item fully-pipelined-fma
16724 Whether the target fully pipelines FMA instructions. If non-zero,
16725 reassociation considers the benefit of parallelizing FMA's multiplication
16726 part and addition part, assuming FMUL and FMA use the same units that can
16729 @item sms-loop-average-count-threshold
16730 A threshold on the average loop count considered by the swing modulo scheduler.
16732 @item sms-dfa-history
16733 The number of cycles the swing modulo scheduler considers when checking
16734 conflicts using DFA.
16736 @item graphite-allow-codegen-errors
16737 Whether codegen errors should be ICEs when @option{-fchecking}.
16739 @item sms-max-ii-factor
16740 A factor for tuning the upper bound that swing modulo scheduler
16741 uses for scheduling a loop.
16743 @item lra-max-considered-reload-pseudos
16744 The max number of reload pseudos which are considered during
16745 spilling a non-reload pseudo.
16747 @item max-pow-sqrt-depth
16748 Maximum depth of sqrt chains to use when synthesizing exponentiation
16749 by a real constant.
16751 @item max-dse-active-local-stores
16752 Maximum number of active local stores in RTL dead store elimination.
16754 @item asan-instrument-allocas
16755 Enable asan allocas/VLAs protection.
16757 @item max-iterations-computation-cost
16758 Bound on the cost of an expression to compute the number of iterations.
16760 @item max-isl-operations
16761 Maximum number of isl operations, 0 means unlimited.
16763 @item graphite-max-arrays-per-scop
16764 Maximum number of arrays per scop.
16766 @item max-vartrack-reverse-op-size
16767 Max. size of loc list for which reverse ops should be added.
16769 @item fsm-scale-path-stmts
16770 Scale factor to apply to the number of statements in a threading path
16771 crossing a loop backedge when comparing to
16772 @option{--param=max-jump-thread-duplication-stmts}.
16774 @item uninit-control-dep-attempts
16775 Maximum number of nested calls to search for control dependencies
16776 during uninitialized variable analysis.
16778 @item uninit-max-chain-len
16779 Maximum number of predicates anded for each predicate ored in the normalized
16782 @item uninit-max-num-chains
16783 Maximum number of predicates ored in the normalized predicate chain.
16785 @item sched-autopref-queue-depth
16786 Hardware autoprefetcher scheduler model control flag.
16787 Number of lookahead cycles the model looks into; at '
16788 ' only enable instruction sorting heuristic.
16790 @item loop-versioning-max-inner-insns
16791 The maximum number of instructions that an inner loop can have
16792 before the loop versioning pass considers it too big to copy.
16794 @item loop-versioning-max-outer-insns
16795 The maximum number of instructions that an outer loop can have
16796 before the loop versioning pass considers it too big to copy,
16797 discounting any instructions in inner loops that directly benefit
16800 @item ssa-name-def-chain-limit
16801 The maximum number of SSA_NAME assignments to follow in determining
16802 a property of a variable such as its value. This limits the number
16803 of iterations or recursive calls GCC performs when optimizing certain
16804 statements or when determining their validity prior to issuing
16807 @item store-merging-max-size
16808 Maximum size of a single store merging region in bytes.
16810 @item hash-table-verification-limit
16811 The number of elements for which hash table verification is done
16812 for each searched element.
16814 @item max-find-base-term-values
16815 Maximum number of VALUEs handled during a single find_base_term call.
16817 @item analyzer-max-enodes-per-program-point
16818 The maximum number of exploded nodes per program point within
16819 the analyzer, before terminating analysis of that point.
16821 @item analyzer-max-constraints
16822 The maximum number of constraints per state.
16824 @item analyzer-min-snodes-for-call-summary
16825 The minimum number of supernodes within a function for the
16826 analyzer to consider summarizing its effects at call sites.
16828 @item analyzer-max-enodes-for-full-dump
16829 The maximum depth of exploded nodes that should appear in a dot dump
16830 before switching to a less verbose format.
16832 @item analyzer-max-recursion-depth
16833 The maximum number of times a callsite can appear in a call stack
16834 within the analyzer, before terminating analysis of a call that would
16837 @item analyzer-max-svalue-depth
16838 The maximum depth of a symbolic value, before approximating
16839 the value as unknown.
16841 @item analyzer-max-infeasible-edges
16842 The maximum number of infeasible edges to reject before declaring
16843 a diagnostic as infeasible.
16845 @item gimple-fe-computed-hot-bb-threshold
16846 The number of executions of a basic block which is considered hot.
16847 The parameter is used only in GIMPLE FE.
16849 @item analyzer-bb-explosion-factor
16850 The maximum number of 'after supernode' exploded nodes within the analyzer
16851 per supernode, before terminating analysis.
16853 @item analyzer-text-art-string-ellipsis-threshold
16854 The number of bytes at which to ellipsize string literals in analyzer text art diagrams.
16856 @item analyzer-text-art-ideal-canvas-width
16857 The ideal width in characters of text art diagrams generated by the analyzer.
16859 @item analyzer-text-art-string-ellipsis-head-len
16860 The number of literal bytes to show at the head of a string literal in text art when ellipsizing it.
16862 @item analyzer-text-art-string-ellipsis-tail-len
16863 The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it.
16865 @item ranger-logical-depth
16866 Maximum depth of logical expression evaluation ranger will look through
16867 when evaluating outgoing edge ranges.
16869 @item ranger-recompute-depth
16870 Maximum depth of instruction chains to consider for recomputation
16871 in the outgoing range calculator.
16873 @item relation-block-limit
16874 Maximum number of relations the oracle will register in a basic block.
16877 Minimum page size for warning purposes.
16879 @item openacc-kernels
16880 Specify mode of OpenACC `kernels' constructs handling.
16881 With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16882 constructs are decomposed into parts, a sequence of compute
16883 constructs, each then handled individually.
16884 This is work in progress.
16885 With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16886 constructs are handled by the @samp{parloops} pass, en bloc.
16887 This is the current default.
16889 @item openacc-privatization
16890 Control whether the @option{-fopt-info-omp-note} and applicable
16891 @option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
16892 With @option{--param=openacc-privatization=quiet}, don't diagnose.
16893 This is the current default.
16894 With @option{--param=openacc-privatization=noisy}, do diagnose.
16898 The following choices of @var{name} are available on AArch64 targets:
16901 @item aarch64-vect-compare-costs
16902 When vectorizing, consider using multiple different approaches and use
16903 the cost model to choose the cheapest one. This includes:
16907 Trying both SVE and Advanced SIMD, when SVE is available.
16910 Trying to use 64-bit Advanced SIMD vectors for the smallest data elements,
16911 rather than using 128-bit vectors for everything.
16914 Trying to use ``unpacked'' SVE vectors for smaller elements. This includes
16915 storing smaller elements in larger containers and accessing elements with
16916 extending loads and truncating stores.
16919 @item aarch64-float-recp-precision
16920 The number of Newton iterations for calculating the reciprocal for float type.
16921 The precision of division is proportional to this param when division
16922 approximation is enabled. The default value is 1.
16924 @item aarch64-double-recp-precision
16925 The number of Newton iterations for calculating the reciprocal for double type.
16926 The precision of division is propotional to this param when division
16927 approximation is enabled. The default value is 2.
16929 @item aarch64-autovec-preference
16930 Force an ISA selection strategy for auto-vectorization. Accepts values from
16934 Use the default heuristics.
16936 Use only Advanced SIMD for auto-vectorization.
16938 Use only SVE for auto-vectorization.
16940 Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16943 Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16945 The default value is 0.
16947 @item aarch64-ldp-policy
16948 Fine-grained policy for load pairs.
16949 With @option{--param=aarch64-ldp-policy=default}, use the policy of the
16950 tuning structure. This is the current default.
16951 With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless
16953 With @option{--param=aarch64-ldp-policy=never}, do not emit ldp.
16954 With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the
16955 source pointer is aligned to at least double the alignment of the type.
16957 @item aarch64-stp-policy
16958 Fine-grained policy for store pairs.
16959 With @option{--param=aarch64-stp-policy=default}, use the policy of the
16960 tuning structure. This is the current default.
16961 With @option{--param=aarch64-stp-policy=always}, emit stp regardless
16963 With @option{--param=aarch64-stp-policy=never}, do not emit stp.
16964 With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the
16965 source pointer is aligned to at least double the alignment of the type.
16967 @item aarch64-ldp-alias-check-limit
16968 Limit on the number of alias checks performed by the AArch64 load/store pair
16969 fusion pass when attempting to form an ldp/stp. Higher values make the pass
16970 more aggressive at re-ordering loads over stores, at the expense of increased
16973 @item aarch64-ldp-writeback
16974 Param to control which writeback opportunities we try to handle in the AArch64
16975 load/store pair fusion pass. A value of zero disables writeback handling. One
16976 means we try to form pairs involving one or more existing individual writeback
16977 accesses where possible. A value of two means we also try to opportunistically
16978 form writeback opportunities by folding in trailing destructive updates of the
16979 base register used by a pair.
16981 @item aarch64-loop-vect-issue-rate-niters
16982 The tuning for some AArch64 CPUs tries to take both latencies and issue
16983 rates into account when deciding whether a loop should be vectorized
16984 using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16985 If this parameter is set to @var{n}, GCC will not use this heuristic
16986 for loops that are known to execute in fewer than @var{n} Advanced
16989 @item aarch64-vect-unroll-limit
16990 The vectorizer will use available tuning information to determine whether it
16991 would be beneficial to unroll the main vectorized loop and by how much. This
16992 parameter set's the upper bound of how much the vectorizer will unroll the main
16993 loop. The default value is four.
16997 The following choices of @var{name} are available on i386 and x86_64 targets:
17000 @item x86-stlf-window-ninsns
17001 Instructions number above which STFL stall penalty can be compensated.
17003 @item x86-stv-max-visits
17004 The maximum number of use and def visits when discovering a STV chain before
17005 the discovery is aborted.
17011 @node Instrumentation Options
17012 @section Program Instrumentation Options
17013 @cindex instrumentation options
17014 @cindex program instrumentation options
17015 @cindex run-time error checking options
17016 @cindex profiling options
17017 @cindex options, program instrumentation
17018 @cindex options, run-time error checking
17019 @cindex options, profiling
17021 GCC supports a number of command-line options that control adding
17022 run-time instrumentation to the code it normally generates.
17023 For example, one purpose of instrumentation is collect profiling
17024 statistics for use in finding program hot spots, code coverage
17025 analysis, or profile-guided optimizations.
17026 Another class of program instrumentation is adding run-time checking
17027 to detect programming errors like invalid pointer
17028 dereferences or out-of-bounds array accesses, as well as deliberately
17029 hostile attacks such as stack smashing or C++ vtable hijacking.
17030 There is also a general hook which can be used to implement other
17031 forms of tracing or function-level instrumentation for debug or
17032 program analysis purposes.
17035 @cindex @command{prof}
17036 @cindex @command{gprof}
17041 Generate extra code to write profile information suitable for the
17042 analysis program @command{prof} (for @option{-p}) or @command{gprof}
17043 (for @option{-pg}). You must use this option when compiling
17044 the source files you want data about, and you must also use it when
17047 You can use the function attribute @code{no_instrument_function} to
17048 suppress profiling of individual functions when compiling with these options.
17049 @xref{Common Function Attributes}.
17051 @opindex fprofile-arcs
17052 @item -fprofile-arcs
17053 Add code so that program flow @dfn{arcs} are instrumented. During
17054 execution the program records how many times each branch and call is
17055 executed and how many times it is taken or returns. On targets that support
17056 constructors with priority support, profiling properly handles constructors,
17057 destructors and C++ constructors (and destructors) of classes which are used
17058 as a type of a global variable.
17061 program exits it saves this data to a file called
17062 @file{@var{auxname}.gcda} for each source file. The data may be used for
17063 profile-directed optimizations (@option{-fbranch-probabilities}), or for
17064 test coverage analysis (@option{-ftest-coverage}). Each object file's
17065 @var{auxname} is generated from the name of the output file, if
17066 explicitly specified and it is not the final executable, otherwise it is
17067 the basename of the source file. In both cases any suffix is removed
17068 (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
17069 @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
17071 Note that if a command line directly links source files, the corresponding
17072 @var{.gcda} files will be prefixed with the unsuffixed name of the output file.
17073 E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
17074 @file{binary-b.gcda} files.
17076 @xref{Cross-profiling}.
17078 @cindex @command{gcov}
17082 This option is used to compile and link code instrumented for coverage
17083 analysis. The option is a synonym for @option{-fprofile-arcs}
17084 @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
17085 linking). See the documentation for those options for more details.
17090 Compile the source files with @option{-fprofile-arcs} plus optimization
17091 and code generation options. For test coverage analysis, use the
17092 additional @option{-ftest-coverage} option. You do not need to profile
17093 every source file in a program.
17096 Compile the source files additionally with @option{-fprofile-abs-path}
17097 to create absolute path names in the @file{.gcno} files. This allows
17098 @command{gcov} to find the correct sources in projects where compilations
17099 occur with different working directories.
17102 Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
17103 (the latter implies the former).
17106 Run the program on a representative workload to generate the arc profile
17107 information. This may be repeated any number of times. You can run
17108 concurrent instances of your program, and provided that the file system
17109 supports locking, the data files will be correctly updated. Unless
17110 a strict ISO C dialect option is in effect, @code{fork} calls are
17111 detected and correctly handled without double counting.
17113 Moreover, an object file can be recompiled multiple times
17114 and the corresponding @file{.gcda} file merges as long as
17115 the source file and the compiler options are unchanged.
17118 For profile-directed optimizations, compile the source files again with
17119 the same optimization and code generation options plus
17120 @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
17121 Control Optimization}).
17124 For test coverage analysis, use @command{gcov} to produce human readable
17125 information from the @file{.gcno} and @file{.gcda} files. Refer to the
17126 @command{gcov} documentation for further information.
17130 With @option{-fprofile-arcs}, for each function of your program GCC
17131 creates a program flow graph, then finds a spanning tree for the graph.
17132 Only arcs that are not on the spanning tree have to be instrumented: the
17133 compiler adds code to count the number of times that these arcs are
17134 executed. When an arc is the only exit or only entrance to a block, the
17135 instrumentation code can be added to the block; otherwise, a new basic
17136 block must be created to hold the instrumentation code.
17139 @opindex ftest-coverage
17140 @item -ftest-coverage
17141 Produce a notes file that the @command{gcov} code-coverage utility
17142 (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
17143 show program coverage. Each source file's note file is called
17144 @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
17145 above for a description of @var{auxname} and instructions on how to
17146 generate test coverage data. Coverage data matches the source files
17147 more closely if you do not optimize.
17149 @opindex fprofile-abs-path
17150 @item -fprofile-abs-path
17151 Automatically convert relative source file names to absolute path names
17152 in the @file{.gcno} files. This allows @command{gcov} to find the correct
17153 sources in projects where compilations occur with different working
17156 @opindex fprofile-dir
17157 @item -fprofile-dir=@var{path}
17159 Set the directory to search for the profile data files in to @var{path}.
17160 This option affects only the profile data generated by
17161 @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
17162 and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
17163 and its related options. Both absolute and relative paths can be used.
17164 By default, GCC uses the current directory as @var{path}, thus the
17165 profile data file appears in the same directory as the object file.
17166 In order to prevent the file name clashing, if the object file name is
17167 not an absolute path, we mangle the absolute path of the
17168 @file{@var{sourcename}.gcda} file and use it as the file name of a
17169 @file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
17170 See similar option @option{-fprofile-note}.
17172 When an executable is run in a massive parallel environment, it is recommended
17173 to save profile to different folders. That can be done with variables
17174 in @var{path} that are exported during run-time:
17182 value of environment variable @var{VAR}
17186 @opindex fprofile-generate
17187 @item -fprofile-generate
17188 @itemx -fprofile-generate=@var{path}
17190 Enable options usually used for instrumenting application to produce
17191 profile useful for later recompilation with profile feedback based
17192 optimization. You must use @option{-fprofile-generate} both when
17193 compiling and when linking your program.
17195 The following options are enabled:
17196 @option{-fprofile-arcs}, @option{-fprofile-values},
17197 @option{-finline-functions}, and @option{-fipa-bit-cp}.
17199 If @var{path} is specified, GCC looks at the @var{path} to find
17200 the profile feedback data files. See @option{-fprofile-dir}.
17202 To optimize the program based on the collected profile information, use
17203 @option{-fprofile-use}. @xref{Optimize Options}, for more information.
17205 @opindex fprofile-info-section
17206 @item -fprofile-info-section
17207 @itemx -fprofile-info-section=@var{name}
17209 Register the profile information in the specified section instead of using a
17210 constructor/destructor. The section name is @var{name} if it is specified,
17211 otherwise the section name defaults to @code{.gcov_info}. A pointer to the
17212 profile information generated by @option{-fprofile-arcs} is placed in the
17213 specified section for each translation unit. This option disables the profile
17214 information registration through a constructor and it disables the profile
17215 information processing through a destructor. This option is not intended to be
17216 used in hosted environments such as GNU/Linux. It targets freestanding
17217 environments (for example embedded systems) with limited resources which do not
17218 support constructors/destructors or the C library file I/O.
17220 The linker could collect the input sections in a continuous memory block and
17221 define start and end symbols. A GNU linker script example which defines a
17222 linker output section follows:
17227 PROVIDE (__gcov_info_start = .);
17228 KEEP (*(.gcov_info))
17229 PROVIDE (__gcov_info_end = .);
17233 The program could dump the profiling information registered in this linker set
17234 for example like this:
17239 #include <stdlib.h>
17241 extern const struct gcov_info *const __gcov_info_start[];
17242 extern const struct gcov_info *const __gcov_info_end[];
17245 dump (const void *d, unsigned n, void *arg)
17247 const unsigned char *c = d;
17249 for (unsigned i = 0; i < n; ++i)
17250 printf ("%02x", c[i]);
17254 filename (const char *f, void *arg)
17256 __gcov_filename_to_gcfn (f, dump, arg );
17260 allocate (unsigned length, void *arg)
17262 return malloc (length);
17266 dump_gcov_info (void)
17268 const struct gcov_info *const *info = __gcov_info_start;
17269 const struct gcov_info *const *end = __gcov_info_end;
17271 /* Obfuscate variable to prevent compiler optimizations. */
17272 __asm__ ("" : "+r" (info));
17274 while (info != end)
17277 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
17291 The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
17292 deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
17293 @code{__gcov_info_to_gcda} functions and merge the profile information into
17294 @file{.gcda} files on the host filesystem.
17296 @opindex fprofile-note
17297 @item -fprofile-note=@var{path}
17299 If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
17300 location. If you combine the option with multiple source files,
17301 the @file{.gcno} file will be overwritten.
17303 @opindex fprofile-prefix-path
17304 @item -fprofile-prefix-path=@var{path}
17306 This option can be used in combination with
17307 @option{profile-generate=}@var{profile_dir} and
17308 @option{profile-use=}@var{profile_dir} to inform GCC where is the base
17309 directory of built source tree. By default @var{profile_dir} will contain
17310 files with mangled absolute paths of all object files in the built project.
17311 This is not desirable when directory used to build the instrumented binary
17312 differs from the directory used to build the binary optimized with profile
17313 feedback because the profile data will not be found during the optimized build.
17314 In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
17315 pointing to the base directory of the build can be used to strip the irrelevant
17316 part of the path and keep all file names relative to the main build directory.
17318 @opindex fprofile-prefix-map
17319 @item -fprofile-prefix-map=@var{old}=@var{new}
17320 When compiling files residing in directory @file{@var{old}}, record
17321 profiling information (with @option{--coverage})
17322 describing them as if the files resided in
17323 directory @file{@var{new}} instead.
17324 See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
17326 @opindex fprofile-update
17327 @item -fprofile-update=@var{method}
17329 Alter the update method for an application instrumented for profile
17330 feedback based optimization. The @var{method} argument should be one of
17331 @samp{single}, @samp{atomic} or @samp{prefer-atomic}.
17332 The first one is useful for single-threaded applications,
17333 while the second one prevents profile corruption by emitting thread-safe code.
17335 @strong{Warning:} When an application does not properly join all threads
17336 (or creates an detached thread), a profile file can be still corrupted.
17338 Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
17339 when supported by a target, or to @samp{single} otherwise. The GCC driver
17340 automatically selects @samp{prefer-atomic} when @option{-pthread}
17341 is present in the command line, otherwise the default method is @samp{single}.
17343 If @samp{atomic} is selected, then the profile information is updated using
17344 atomic operations on a best-effort basis. Ideally, the profile information is
17345 updated through atomic operations in hardware. If the target platform does not
17346 support the required atomic operations in hardware, however, @file{libatomic}
17347 is available, then the profile information is updated through calls to
17348 @file{libatomic}. If the target platform neither supports the required atomic
17349 operations in hardware nor @file{libatomic}, then the profile information is
17350 not atomically updated and a warning is issued. In this case, the obtained
17351 profiling information may be corrupt for multi-threaded applications.
17353 For performance reasons, if 64-bit counters are used for the profiling
17354 information and the target platform only supports 32-bit atomic operations in
17355 hardware, then the performance critical profiling updates are done using two
17356 32-bit atomic operations for each counter update. If a signal interrupts these
17357 two operations updating a counter, then the profiling information may be in an
17358 inconsistent state.
17360 @opindex fprofile-filter-files
17361 @item -fprofile-filter-files=@var{regex}
17363 Instrument only functions from files whose name matches
17364 any of the regular expressions (separated by semi-colons).
17366 For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
17367 only @file{main.c} and all C files starting with 'module'.
17369 @opindex fprofile-exclude-files
17370 @item -fprofile-exclude-files=@var{regex}
17372 Instrument only functions from files whose name does not match
17373 any of the regular expressions (separated by semi-colons).
17375 For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
17376 of all files that are located in the @file{/usr/} folder.
17378 @opindex fprofile-reproducible
17379 @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
17380 Control level of reproducibility of profile gathered by
17381 @code{-fprofile-generate}. This makes it possible to rebuild program
17382 with same outcome which is useful, for example, for distribution
17385 With @option{-fprofile-reproducible=serial} the profile gathered by
17386 @option{-fprofile-generate} is reproducible provided the trained program
17387 behaves the same at each invocation of the train run, it is not
17388 multi-threaded and profile data streaming is always done in the same
17389 order. Note that profile streaming happens at the end of program run but
17390 also before @code{fork} function is invoked.
17392 Note that it is quite common that execution counts of some part of
17393 programs depends, for example, on length of temporary file names or
17394 memory space randomization (that may affect hash-table collision rate).
17395 Such non-reproducible part of programs may be annotated by
17396 @code{no_instrument_function} function attribute. @command{gcov-dump} with
17397 @option{-l} can be used to dump gathered data and verify that they are
17398 indeed reproducible.
17400 With @option{-fprofile-reproducible=parallel-runs} collected profile
17401 stays reproducible regardless the order of streaming of the data into
17402 gcda files. This setting makes it possible to run multiple instances of
17403 instrumented program in parallel (such as with @code{make -j}). This
17404 reduces quality of gathered data, in particular of indirect call
17407 @opindex fsanitize=address
17408 @item -fsanitize=address
17409 Enable AddressSanitizer, a fast memory error detector.
17410 Memory access instructions are instrumented to detect
17411 out-of-bounds and use-after-free bugs.
17412 The option enables @option{-fsanitize-address-use-after-scope}.
17413 See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
17414 more details. The run-time behavior can be influenced using the
17415 @env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
17416 the available options are shown at startup of the instrumented program. See
17417 @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
17418 for a list of supported options.
17419 The option cannot be combined with @option{-fsanitize=thread} or
17420 @option{-fsanitize=hwaddress}. Note that the only target
17421 @option{-fsanitize=hwaddress} is currently supported on is AArch64.
17423 To get more accurate stack traces, it is possible to use options such as
17424 @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
17425 most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
17426 optimizing sibling and tail recursive calls; this option is implicit for
17427 @option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
17428 disables Identical Code Folding for functions). Since multiple runs of the
17429 program may yield backtraces with different addresses due to ASLR (Address
17430 Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
17431 this can be achieved with @samp{setarch `uname -m` -R ./prog}.
17433 @opindex fsanitize=kernel-address
17434 @item -fsanitize=kernel-address
17435 Enable AddressSanitizer for Linux kernel.
17436 See @uref{https://github.com/google/kernel-sanitizers} for more details.
17438 @opindex fsanitize=hwaddress
17439 @item -fsanitize=hwaddress
17440 Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
17441 ignore the top byte of a pointer to allow the detection of memory errors with
17442 a low memory overhead.
17443 Memory access instructions are instrumented to detect out-of-bounds and
17444 use-after-free bugs.
17445 The option enables @option{-fsanitize-address-use-after-scope}.
17447 @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
17448 for more details. The run-time behavior can be influenced using the
17449 @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
17450 the available options are shown at startup of the instrumented program.
17451 The option cannot be combined with @option{-fsanitize=thread} or
17452 @option{-fsanitize=address}, and is currently only available on AArch64.
17454 @opindex fsanitize=kernel-hwaddress
17455 @item -fsanitize=kernel-hwaddress
17456 Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
17457 Similar to @option{-fsanitize=kernel-address} but using an alternate
17458 instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
17459 instrumentation differences necessary for compiling the Linux kernel.
17460 These differences are to avoid hwasan library initialization calls and to
17461 account for the stack pointer having a different value in its top byte.
17463 @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
17464 Instrumenting the stack and alloca calls are not on by default but are still
17465 possible by specifying the command-line options
17466 @option{--param hwasan-instrument-stack=1} and
17467 @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
17468 tag is not implemented for kernel instrumentation.
17470 @opindex fsanitize=pointer-compare
17471 @item -fsanitize=pointer-compare
17472 Instrument comparison operation (<, <=, >, >=) with pointer operands.
17473 The option must be combined with either @option{-fsanitize=kernel-address} or
17474 @option{-fsanitize=address}
17475 The option cannot be combined with @option{-fsanitize=thread}.
17476 Note: By default the check is disabled at run time. To enable it,
17477 add @code{detect_invalid_pointer_pairs=2} to the environment variable
17478 @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17479 invalid operation only when both pointers are non-null.
17481 @opindex fsanitize=pointer-subtract
17482 @item -fsanitize=pointer-subtract
17483 Instrument subtraction with pointer operands.
17484 The option must be combined with either @option{-fsanitize=kernel-address} or
17485 @option{-fsanitize=address}
17486 The option cannot be combined with @option{-fsanitize=thread}.
17487 Note: By default the check is disabled at run time. To enable it,
17488 add @code{detect_invalid_pointer_pairs=2} to the environment variable
17489 @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17490 invalid operation only when both pointers are non-null.
17492 @opindex fsanitize=shadow-call-stack
17493 @item -fsanitize=shadow-call-stack
17494 Enable ShadowCallStack, a security enhancement mechanism used to protect
17495 programs against return address overwrites (e.g. stack buffer overflows.)
17496 It works by saving a function's return address to a separately allocated
17497 shadow call stack in the function prologue and restoring the return address
17498 from the shadow call stack in the function epilogue. Instrumentation only
17499 occurs in functions that need to save the return address to the stack.
17501 Currently it only supports the aarch64 platform. It is specifically
17502 designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
17503 For the user space programs, runtime support is not currently provided
17504 in libc and libgcc. Users who want to use this feature in user space need
17505 to provide their own support for the runtime. It should be noted that
17506 this may cause the ABI rules to be broken.
17508 On aarch64, the instrumentation makes use of the platform register @code{x18}.
17509 This generally means that any code that may run on the same thread as code
17510 compiled with ShadowCallStack must be compiled with the flag
17511 @option{-ffixed-x18}, otherwise functions compiled without
17512 @option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
17515 Also, because there is no userspace runtime support, code compiled with
17516 ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
17517 to turn off exceptions.
17519 See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
17522 @opindex fsanitize=thread
17523 @item -fsanitize=thread
17524 Enable ThreadSanitizer, a fast data race detector.
17525 Memory access instructions are instrumented to detect
17526 data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
17527 details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
17528 environment variable; see
17529 @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
17531 The option cannot be combined with @option{-fsanitize=address},
17532 @option{-fsanitize=leak}.
17534 Note that sanitized atomic builtins cannot throw exceptions when
17535 operating on invalid memory addresses with non-call exceptions
17536 (@option{-fnon-call-exceptions}).
17538 @opindex fsanitize=leak
17539 @item -fsanitize=leak
17540 Enable LeakSanitizer, a memory leak detector.
17541 This option only matters for linking of executables.
17542 The executable is linked against a library that overrides @code{malloc}
17543 and other allocator functions. See
17544 @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
17545 details. The run-time behavior can be influenced using the
17546 @env{LSAN_OPTIONS} environment variable.
17547 The option cannot be combined with @option{-fsanitize=thread}.
17549 @opindex fsanitize=undefined
17550 @item -fsanitize=undefined
17551 Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
17552 Various computations are instrumented to detect undefined behavior
17553 at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
17554 @env{UBSAN_OPTIONS} environment variable. Current suboptions are:
17558 @opindex fsanitize=shift
17559 @item -fsanitize=shift
17560 This option enables checking that the result of a shift operation is
17561 not undefined. Note that what exactly is considered undefined differs
17562 slightly between C and C++, as well as between ISO C90 and C99, etc.
17563 This option has two suboptions, @option{-fsanitize=shift-base} and
17564 @option{-fsanitize=shift-exponent}.
17566 @opindex fsanitize=shift-exponent
17567 @item -fsanitize=shift-exponent
17568 This option enables checking that the second argument of a shift operation
17569 is not negative and is smaller than the precision of the promoted first
17572 @opindex fsanitize=shift-base
17573 @item -fsanitize=shift-base
17574 If the second argument of a shift operation is within range, check that the
17575 result of a shift operation is not undefined. Note that what exactly is
17576 considered undefined differs slightly between C and C++, as well as between
17577 ISO C90 and C99, etc.
17579 @opindex fsanitize=integer-divide-by-zero
17580 @item -fsanitize=integer-divide-by-zero
17581 Detect integer division by zero.
17583 @opindex fsanitize=unreachable
17584 @item -fsanitize=unreachable
17585 With this option, the compiler turns the @code{__builtin_unreachable}
17586 call into a diagnostics message call instead. When reaching the
17587 @code{__builtin_unreachable} call, the behavior is undefined.
17589 @opindex fsanitize=vla-bound
17590 @item -fsanitize=vla-bound
17591 This option instructs the compiler to check that the size of a variable
17592 length array is positive.
17594 @opindex fsanitize=null
17595 @item -fsanitize=null
17596 This option enables pointer checking. Particularly, the application
17597 built with this option turned on will issue an error message when it
17598 tries to dereference a NULL pointer, or if a reference (possibly an
17599 rvalue reference) is bound to a NULL pointer, or if a method is invoked
17600 on an object pointed by a NULL pointer.
17602 @opindex fsanitize=return
17603 @item -fsanitize=return
17604 This option enables return statement checking. Programs
17605 built with this option turned on will issue an error message
17606 when the end of a non-void function is reached without actually
17607 returning a value. This option works in C++ only.
17609 @opindex fsanitize=signed-integer-overflow
17610 @item -fsanitize=signed-integer-overflow
17611 This option enables signed integer overflow checking. We check that
17612 the result of @code{+}, @code{*}, and both unary and binary @code{-}
17613 does not overflow in the signed arithmetics. This also detects
17614 @code{INT_MIN / -1} signed division. Note, integer promotion
17615 rules must be taken into account. That is, the following is not an
17618 signed char a = SCHAR_MAX;
17622 @opindex fsanitize=bounds
17623 @item -fsanitize=bounds
17624 This option enables instrumentation of array bounds. Various out of bounds
17625 accesses are detected. Flexible array members, flexible array member-like
17626 arrays, and initializers of variables with static storage are not
17627 instrumented, with the exception of flexible array member-like arrays
17628 for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
17629 options or @code{strict_flex_array} attributes say they shouldn't be treated
17630 like flexible array member-like arrays.
17632 @opindex fsanitize=bounds-strict
17633 @item -fsanitize=bounds-strict
17634 This option enables strict instrumentation of array bounds. Most out of bounds
17635 accesses are detected, including flexible array member-like arrays.
17636 Initializers of variables with static storage are not instrumented.
17638 @opindex fsanitize=alignment
17639 @item -fsanitize=alignment
17641 This option enables checking of alignment of pointers when they are
17642 dereferenced, or when a reference is bound to insufficiently aligned target,
17643 or when a method or constructor is invoked on insufficiently aligned object.
17645 @opindex fsanitize=object-size
17646 @item -fsanitize=object-size
17647 This option enables instrumentation of memory references using the
17648 @code{__builtin_dynamic_object_size} function. Various out of bounds
17649 pointer accesses are detected.
17651 @opindex fsanitize=float-divide-by-zero
17652 @item -fsanitize=float-divide-by-zero
17653 Detect floating-point division by zero. Unlike other similar options,
17654 @option{-fsanitize=float-divide-by-zero} is not enabled by
17655 @option{-fsanitize=undefined}, since floating-point division by zero can
17656 be a legitimate way of obtaining infinities and NaNs.
17658 @opindex fsanitize=float-cast-overflow
17659 @item -fsanitize=float-cast-overflow
17660 This option enables floating-point type to integer conversion checking.
17661 We check that the result of the conversion does not overflow.
17662 Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
17663 not enabled by @option{-fsanitize=undefined}.
17664 This option does not work well with @code{FE_INVALID} exceptions enabled.
17666 @opindex fsanitize=nonnull-attribute
17667 @item -fsanitize=nonnull-attribute
17669 This option enables instrumentation of calls, checking whether null values
17670 are not passed to arguments marked as requiring a non-null value by the
17671 @code{nonnull} function attribute.
17673 @opindex fsanitize=returns-nonnull-attribute
17674 @item -fsanitize=returns-nonnull-attribute
17676 This option enables instrumentation of return statements in functions
17677 marked with @code{returns_nonnull} function attribute, to detect returning
17678 of null values from such functions.
17680 @opindex fsanitize=bool
17681 @item -fsanitize=bool
17683 This option enables instrumentation of loads from bool. If a value other
17684 than 0/1 is loaded, a run-time error is issued.
17686 @opindex fsanitize=enum
17687 @item -fsanitize=enum
17689 This option enables instrumentation of loads from an enum type. If
17690 a value outside the range of values for the enum type is loaded,
17691 a run-time error is issued.
17693 @opindex fsanitize=vptr
17694 @item -fsanitize=vptr
17696 This option enables instrumentation of C++ member function calls, member
17697 accesses and some conversions between pointers to base and derived classes,
17698 to verify the referenced object has the correct dynamic type.
17700 @opindex fsanitize=pointer-overflow
17701 @item -fsanitize=pointer-overflow
17703 This option enables instrumentation of pointer arithmetics. If the pointer
17704 arithmetics overflows, a run-time error is issued.
17706 @opindex fsanitize=builtin
17707 @item -fsanitize=builtin
17709 This option enables instrumentation of arguments to selected builtin
17710 functions. If an invalid value is passed to such arguments, a run-time
17711 error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
17712 or @code{__builtin_clz} invokes undefined behavior and is diagnosed
17717 Note that sanitizers tend to increase the rate of false positive
17718 warnings, most notably those around @option{-Wmaybe-uninitialized}.
17719 We recommend against combining @option{-Werror} and [the use of]
17722 While @option{-ftrapv} causes traps for signed overflows to be emitted,
17723 @option{-fsanitize=undefined} gives a diagnostic message.
17724 This currently works only for the C family of languages.
17726 @opindex fno-sanitize=all
17727 @item -fno-sanitize=all
17729 This option disables all previously enabled sanitizers.
17730 @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
17733 @opindex fasan-shadow-offset
17734 @item -fasan-shadow-offset=@var{number}
17735 This option forces GCC to use custom shadow offset in AddressSanitizer checks.
17736 It is useful for experimenting with different shadow memory layouts in
17737 Kernel AddressSanitizer.
17739 @opindex fsanitize-sections
17740 @item -fsanitize-sections=@var{s1},@var{s2},...
17741 Sanitize global variables in selected user-defined sections. @var{si} may
17744 @opindex fsanitize-recover
17745 @opindex fno-sanitize-recover
17746 @item -fsanitize-recover@r{[}=@var{opts}@r{]}
17747 @option{-fsanitize-recover=} controls error recovery mode for sanitizers
17748 mentioned in comma-separated list of @var{opts}. Enabling this option
17749 for a sanitizer component causes it to attempt to continue
17750 running the program as if no error happened. This means multiple
17751 runtime errors can be reported in a single program run, and the exit
17752 code of the program may indicate success even when errors
17753 have been reported. The @option{-fno-sanitize-recover=} option
17754 can be used to alter
17755 this behavior: only the first detected error is reported
17756 and program then exits with a non-zero exit code.
17758 Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
17759 except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
17760 @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
17761 @option{-fsanitize=bounds-strict},
17762 @option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
17763 For these sanitizers error recovery is turned on by default,
17764 except @option{-fsanitize=address}, for which this feature is experimental.
17765 @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
17766 accepted, the former enables recovery for all sanitizers that support it,
17767 the latter disables recovery for all sanitizers that support it.
17769 Even if a recovery mode is turned on the compiler side, it needs to be also
17770 enabled on the runtime library side, otherwise the failures are still fatal.
17771 The runtime library defaults to @code{halt_on_error=0} for
17772 ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
17773 AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
17774 setting the @code{halt_on_error} flag in the corresponding environment variable.
17776 Syntax without an explicit @var{opts} parameter is deprecated. It is
17777 equivalent to specifying an @var{opts} list of:
17780 undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
17783 @opindex fsanitize-address-use-after-scope
17784 @item -fsanitize-address-use-after-scope
17785 Enable sanitization of local variables to detect use-after-scope bugs.
17786 The option sets @option{-fstack-reuse} to @samp{none}.
17788 @opindex fsanitize-trap
17789 @opindex fno-sanitize-trap
17790 @item -fsanitize-trap@r{[}=@var{opts}@r{]}
17791 The @option{-fsanitize-trap=} option instructs the compiler to
17792 report for sanitizers mentioned in comma-separated list of @var{opts}
17793 undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
17794 library routine. If this option is enabled for certain sanitizer,
17795 it takes precedence over the @option{-fsanitizer-recover=} for that
17796 sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
17797 of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
17799 The advantage of this is that the @code{libubsan} library is not needed
17800 and is not linked in, so this is usable even in freestanding environments.
17802 Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
17803 except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
17804 @option{-fsanitize=float-divide-by-zero} and
17805 @option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
17806 specified, which enables it for @code{undefined} suboptions,
17807 @option{-fsanitize=float-cast-overflow},
17808 @option{-fsanitize=float-divide-by-zero} and
17809 @option{-fsanitize=bounds-strict}.
17810 If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
17811 and @code{-fsanitize=vptr} is enabled on the command line, the
17812 instrumentation is silently ignored as the instrumentation always needs
17813 @code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
17815 @opindex fsanitize-undefined-trap-on-error
17816 @item -fsanitize-undefined-trap-on-error
17817 The @option{-fsanitize-undefined-trap-on-error} option is deprecated
17818 equivalent of @option{-fsanitize-trap=all}.
17820 @opindex fsanitize-coverage=trace-pc
17821 @item -fsanitize-coverage=trace-pc
17822 Enable coverage-guided fuzzing code instrumentation.
17823 Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
17825 @opindex fsanitize-coverage=trace-cmp
17826 @item -fsanitize-coverage=trace-cmp
17827 Enable dataflow guided fuzzing code instrumentation.
17828 Inserts a call to @code{__sanitizer_cov_trace_cmp1},
17829 @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
17830 @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
17831 variable or @code{__sanitizer_cov_trace_const_cmp1},
17832 @code{__sanitizer_cov_trace_const_cmp2},
17833 @code{__sanitizer_cov_trace_const_cmp4} or
17834 @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
17835 operand constant, @code{__sanitizer_cov_trace_cmpf} or
17836 @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
17837 @code{__sanitizer_cov_trace_switch} for switch statements.
17839 @opindex fcf-protection
17840 @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
17841 Enable code instrumentation of control-flow transfers to increase
17842 program security by checking that target addresses of control-flow
17843 transfer instructions (such as indirect function call, function return,
17844 indirect jump) are valid. This prevents diverting the flow of control
17845 to an unexpected target. This is intended to protect against such
17846 threats as Return-oriented Programming (ROP), and similarly
17847 call/jmp-oriented programming (COP/JOP).
17849 The value @code{branch} tells the compiler to implement checking of
17850 validity of control-flow transfer at the point of indirect branch
17851 instructions, i.e.@: call/jmp instructions. The value @code{return}
17852 implements checking of validity at the point of returning from a
17853 function. The value @code{full} is an alias for specifying both
17854 @code{branch} and @code{return}. The value @code{none} turns off
17857 To override @option{-fcf-protection}, @option{-fcf-protection=none}
17858 needs to be added and then with @option{-fcf-protection=xxx}.
17860 The value @code{check} is used for the final link with link-time
17861 optimization (LTO). An error is issued if LTO object files are
17862 compiled with different @option{-fcf-protection} values. The
17863 value @code{check} is ignored at the compile time.
17865 The macro @code{__CET__} is defined when @option{-fcf-protection} is
17866 used. The first bit of @code{__CET__} is set to 1 for the value
17867 @code{branch} and the second bit of @code{__CET__} is set to 1 for
17870 You can also use the @code{nocf_check} attribute to identify
17871 which functions and calls should be skipped from instrumentation
17872 (@pxref{Function Attributes}).
17874 Currently the x86 GNU/Linux target provides an implementation based
17875 on Intel Control-flow Enforcement Technology (CET) which works for
17876 i686 processor or newer.
17878 @opindex fharden-compares
17879 @item -fharden-compares
17880 For every logical test that survives gimple optimizations and is
17881 @emph{not} the condition in a conditional branch (for example,
17882 conditions tested for conditional moves, or to store in boolean
17883 variables), emit extra code to compute and verify the reversed
17884 condition, and to call @code{__builtin_trap} if the results do not
17885 match. Use with @samp{-fharden-conditional-branches} to cover all
17888 @opindex fharden-conditional-branches
17889 @item -fharden-conditional-branches
17890 For every non-vectorized conditional branch that survives gimple
17891 optimizations, emit extra code to compute and verify the reversed
17892 condition, and to call @code{__builtin_trap} if the result is
17893 unexpected. Use with @samp{-fharden-compares} to cover all
17896 @opindex fharden-control-flow-redundancy
17897 @item -fharden-control-flow-redundancy
17898 Emit extra code to set booleans when entering basic blocks, and to
17899 verify and trap, at function exits, when the booleans do not form an
17900 execution path that is compatible with the control flow graph.
17902 Verification takes place before returns, before mandatory tail calls
17903 (see below) and, optionally, before escaping exceptions with
17904 @option{-fhardcfr-check-exceptions}, before returning calls with
17905 @option{-fhardcfr-check-returning-calls}, and before noreturn calls with
17906 @option{-fhardcfr-check-noreturn-calls}). Tuning options
17907 @option{--param hardcfr-max-blocks} and @option{--param
17908 hardcfr-max-inline-blocks} are available.
17910 Tail call optimization takes place too late to affect control flow
17911 redundancy, but calls annotated as mandatory tail calls by language
17912 front-ends, and any calls marked early enough as potential tail calls
17913 would also have verification issued before the call, but these
17914 possibilities are merely theoretical, as these conditions can only be
17915 met when using custom compiler plugins.
17917 @opindex fhardcfr-skip-leaf
17918 @item -fhardcfr-skip-leaf
17919 Disable @option{-fharden-control-flow-redundancy} in leaf functions.
17921 @opindex fhardcfr-check-exceptions
17922 @opindex fno-hardcfr-check-exceptions
17923 @item -fhardcfr-check-exceptions
17924 When @option{-fharden-control-flow-redundancy} is active, check the
17925 recorded execution path against the control flow graph at exception
17926 escape points, as if the function body was wrapped with a cleanup
17927 handler that performed the check and reraised. This option is enabled
17928 by default; use @option{-fno-hardcfr-check-exceptions} to disable it.
17930 @opindex fhardcfr-check-returning-calls
17931 @opindex fno-hardcfr-check-returning-calls
17932 @item -fhardcfr-check-returning-calls
17933 When @option{-fharden-control-flow-redundancy} is active, check the
17934 recorded execution path against the control flow graph before any
17935 function call immediately followed by a return of its result, if any, so
17936 as to not prevent tail-call optimization, whether or not it is
17937 ultimately optimized to a tail call.
17939 This option is enabled by default whenever sibling call optimizations
17940 are enabled (see @option{-foptimize-sibling-calls}), but it can be
17941 enabled (or disabled, using its negated form) explicitly, regardless of
17944 @opindex fhardcfr-check-noreturn-calls
17945 @item -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
17946 When @option{-fharden-control-flow-redundancy} is active, check the
17947 recorded execution path against the control flow graph before
17948 @code{noreturn} calls, either all of them (@option{always}), those that
17949 aren't expected to return control to the caller through an exception
17950 (@option{no-xthrow}, the default), those that may not return control to
17951 the caller through an exception either (@option{nothrow}), or none of
17952 them (@option{never}).
17954 Checking before a @code{noreturn} function that may return control to
17955 the caller through an exception may cause checking to be performed more
17956 than once, if the exception is caught in the caller, whether by a
17957 handler or a cleanup. When @option{-fhardcfr-check-exceptions} is also
17958 enabled, the compiler will avoid associating a @code{noreturn} call with
17959 the implicitly-added cleanup handler, since it would be redundant with
17960 the check performed before the call, but other handlers or cleanups in
17961 the function, if activated, will modify the recorded execution path and
17962 check it again when another checkpoint is hit. The checkpoint may even
17963 be another @code{noreturn} call, so checking may end up performed
17966 Various optimizers may cause calls to be marked as @code{noreturn}
17967 and/or @code{nothrow}, even in the absence of the corresponding
17968 attributes, which may affect the placement of checks before calls, as
17969 well as the addition of implicit cleanup handlers for them. This
17970 unpredictability, and the fact that raising and reraising exceptions
17971 frequently amounts to implicitly calling @code{noreturn} functions, have
17972 made @option{no-xthrow} the default setting for this option: it excludes
17973 from the @code{noreturn} treatment only internal functions used to
17974 (re)raise exceptions, that are not affected by these optimizations.
17978 Enable a set of flags for C and C++ that improve the security of the
17979 generated code without affecting its ABI. The precise flags enabled
17980 may change between major releases of GCC, but are currently:
17982 @c Keep this in sync with print_help_hardened!
17984 -D_FORTIFY_SOURCE=3
17985 -D_GLIBCXX_ASSERTIONS
17986 -ftrivial-auto-var-init=zero
17987 -fPIE -pie -Wl,-z,relro,-z,now
17988 -fstack-protector-strong
17989 -fstack-clash-protection
17990 -fcf-protection=full @r{(x86 GNU/Linux only)}
17993 The list of options enabled by @option{-fhardened} can be generated using
17994 the @option{--help=hardened} option.
17996 When the system glibc is older than 2.35, @option{-D_FORTIFY_SOURCE=2}
17999 This option is intended to be used in production builds, not merely
18002 Currently, @option{-fhardened} is only supported on GNU/Linux targets.
18004 @option{-fhardened} only enables a particular option if it wasn't
18005 already specified anywhere on the command line. For instance,
18006 @option{-fhardened} @option{-fstack-protector} will only enable
18007 @option{-fstack-protector}, but not @option{-fstack-protector-strong}.
18009 @opindex fstack-protector
18010 @item -fstack-protector
18011 Emit extra code to check for buffer overflows, such as stack smashing
18012 attacks. This is done by adding a guard variable to functions with
18013 vulnerable objects. This includes functions that call @code{alloca}, and
18014 functions with buffers larger than or equal to 8 bytes. The guards are
18015 initialized when a function is entered and then checked when the function
18016 exits. If a guard check fails, an error message is printed and the program
18017 exits. Only variables that are actually allocated on the stack are
18018 considered, optimized away variables or variables allocated in registers
18021 @opindex fstack-protector-all
18022 @item -fstack-protector-all
18023 Like @option{-fstack-protector} except that all functions are protected.
18025 @opindex fstack-protector-strong
18026 @item -fstack-protector-strong
18027 Like @option{-fstack-protector} but includes additional functions to
18028 be protected --- those that have local array definitions, or have
18029 references to local frame addresses. Only variables that are actually
18030 allocated on the stack are considered, optimized away variables or variables
18031 allocated in registers don't count.
18033 @opindex fstack-protector-explicit
18034 @item -fstack-protector-explicit
18035 Like @option{-fstack-protector} but only protects those functions which
18036 have the @code{stack_protect} attribute.
18038 @opindex fstack-check
18039 @item -fstack-check
18040 Generate code to verify that you do not go beyond the boundary of the
18041 stack. You should specify this flag if you are running in an
18042 environment with multiple threads, but you only rarely need to specify it in
18043 a single-threaded environment since stack overflow is automatically
18044 detected on nearly all systems if there is only one stack.
18046 Note that this switch does not actually cause checking to be done; the
18047 operating system or the language runtime must do that. The switch causes
18048 generation of code to ensure that they see the stack being extended.
18050 You can additionally specify a string parameter: @samp{no} means no
18051 checking, @samp{generic} means force the use of old-style checking,
18052 @samp{specific} means use the best checking method and is equivalent
18053 to bare @option{-fstack-check}.
18055 Old-style checking is a generic mechanism that requires no specific
18056 target support in the compiler but comes with the following drawbacks:
18060 Modified allocation strategy for large objects: they are always
18061 allocated dynamically if their size exceeds a fixed threshold. Note this
18062 may change the semantics of some code.
18065 Fixed limit on the size of the static frame of functions: when it is
18066 topped by a particular function, stack checking is not reliable and
18067 a warning is issued by the compiler.
18070 Inefficiency: because of both the modified allocation strategy and the
18071 generic implementation, code performance is hampered.
18074 Note that old-style stack checking is also the fallback method for
18075 @samp{specific} if no target support has been added in the compiler.
18077 @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
18078 and stack overflows. @samp{specific} is an excellent choice when compiling
18079 Ada code. It is not generally sufficient to protect against stack-clash
18080 attacks. To protect against those you want @samp{-fstack-clash-protection}.
18082 @opindex fstack-clash-protection
18083 @item -fstack-clash-protection
18084 Generate code to prevent stack clash style attacks. When this option is
18085 enabled, the compiler will only allocate one page of stack space at a time
18086 and each page is accessed immediately after allocation. Thus, it prevents
18087 allocations from jumping over any stack guard page provided by the
18090 Most targets do not fully support stack clash protection. However, on
18091 those targets @option{-fstack-clash-protection} will protect dynamic stack
18092 allocations. @option{-fstack-clash-protection} may also provide limited
18093 protection for static stack allocations if the target supports
18094 @option{-fstack-check=specific}.
18096 @opindex fstack-limit-register
18097 @opindex fstack-limit-symbol
18098 @opindex fno-stack-limit
18099 @item -fstack-limit-register=@var{reg}
18100 @itemx -fstack-limit-symbol=@var{sym}
18101 @itemx -fno-stack-limit
18102 Generate code to ensure that the stack does not grow beyond a certain value,
18103 either the value of a register or the address of a symbol. If a larger
18104 stack is required, a signal is raised at run time. For most targets,
18105 the signal is raised before the stack overruns the boundary, so
18106 it is possible to catch the signal without taking special precautions.
18108 For instance, if the stack starts at absolute address @samp{0x80000000}
18109 and grows downwards, you can use the flags
18110 @option{-fstack-limit-symbol=__stack_limit} and
18111 @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
18112 of 128KB@. Note that this may only work with the GNU linker.
18114 You can locally override stack limit checking by using the
18115 @code{no_stack_limit} function attribute (@pxref{Function Attributes}).
18117 @opindex fsplit-stack
18118 @item -fsplit-stack
18119 Generate code to automatically split the stack before it overflows.
18120 The resulting program has a discontiguous stack which can only
18121 overflow if the program is unable to allocate any more memory. This
18122 is most useful when running threaded programs, as it is no longer
18123 necessary to calculate a good stack size to use for each thread. This
18124 is currently only implemented for the x86 targets running
18127 When code compiled with @option{-fsplit-stack} calls code compiled
18128 without @option{-fsplit-stack}, there may not be much stack space
18129 available for the latter code to run. If compiling all code,
18130 including library code, with @option{-fsplit-stack} is not an option,
18131 then the linker can fix up these calls so that the code compiled
18132 without @option{-fsplit-stack} always has a large stack. Support for
18133 this is implemented in the gold linker in GNU binutils release 2.21
18136 @opindex -fstrub=disable
18137 @item -fstrub=disable
18138 Disable stack scrubbing entirely, ignoring any @code{strub} attributes.
18139 See @xref{Common Type Attributes}.
18141 @opindex fstrub=strict
18142 @item -fstrub=strict
18143 Functions default to @code{strub} mode @code{disabled}, and apply
18144 @option{strict}ly the restriction that only functions associated with
18145 @code{strub}-@code{callable} modes (@code{at-calls}, @code{callable} and
18146 @code{always_inline} @code{internal}) are @code{callable} by functions
18147 with @code{strub}-enabled modes (@code{at-calls} and @code{internal}).
18149 @opindex fstrub=relaxed
18150 @item -fstrub=relaxed
18151 Restore the default stack scrub (@code{strub}) setting, namely,
18152 @code{strub} is only enabled as required by @code{strub} attributes
18153 associated with function and data types. @code{Relaxed} means that
18154 strub contexts are only prevented from calling functions explicitly
18155 associated with @code{strub} mode @code{disabled}. This option is only
18156 useful to override other @option{-fstrub=*} options that precede it in
18159 @opindex fstrub=at-calls
18160 @item -fstrub=at-calls
18161 Enable @code{at-calls} @code{strub} mode where viable. The primary use
18162 of this option is for testing. It exercises the @code{strub} machinery
18163 in scenarios strictly local to a translation unit. This @code{strub}
18164 mode modifies function interfaces, so any function that is visible to
18165 other translation units, or that has its address taken, will @emph{not}
18166 be affected by this option. Optimization options may also affect
18167 viability. See the @code{strub} attribute documentation for details on
18168 viability and eligibility requirements.
18170 @opindex fstrub=internal
18171 @item -fstrub=internal
18172 Enable @code{internal} @code{strub} mode where viable. The primary use
18173 of this option is for testing. This option is intended to exercise
18174 thoroughly parts of the @code{strub} machinery that implement the less
18175 efficient, but interface-preserving @code{strub} mode. Functions that
18176 would not be affected by this option are quite uncommon.
18178 @opindex fstrub=all
18180 Enable some @code{strub} mode where viable. When both strub modes are
18181 viable, @code{at-calls} is preferred. @option{-fdump-ipa-strubm} adds
18182 function attributes that tell which mode was selected for each function.
18183 The primary use of this option is for testing, to exercise thoroughly
18184 the @code{strub} machinery.
18186 @opindex fvtable-verify
18187 @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
18188 This option is only available when compiling C++ code.
18189 It turns on (or off, if using @option{-fvtable-verify=none}) the security
18190 feature that verifies at run time, for every virtual call, that
18191 the vtable pointer through which the call is made is valid for the type of
18192 the object, and has not been corrupted or overwritten. If an invalid vtable
18193 pointer is detected at run time, an error is reported and execution of the
18194 program is immediately halted.
18196 This option causes run-time data structures to be built at program startup,
18197 which are used for verifying the vtable pointers.
18198 The options @samp{std} and @samp{preinit}
18199 control the timing of when these data structures are built. In both cases the
18200 data structures are built before execution reaches @code{main}. Using
18201 @option{-fvtable-verify=std} causes the data structures to be built after
18202 shared libraries have been loaded and initialized.
18203 @option{-fvtable-verify=preinit} causes them to be built before shared
18204 libraries have been loaded and initialized.
18206 If this option appears multiple times in the command line with different
18207 values specified, @samp{none} takes highest priority over both @samp{std} and
18208 @samp{preinit}; @samp{preinit} takes priority over @samp{std}.
18210 @opindex fvtv-debug
18212 When used in conjunction with @option{-fvtable-verify=std} or
18213 @option{-fvtable-verify=preinit}, causes debug versions of the
18214 runtime functions for the vtable verification feature to be called.
18215 This flag also causes the compiler to log information about which
18216 vtable pointers it finds for each class.
18217 This information is written to a file named @file{vtv_set_ptr_data.log}
18218 in the directory named by the environment variable @env{VTV_LOGS_DIR}
18219 if that is defined or the current working directory otherwise.
18221 Note: This feature @emph{appends} data to the log file. If you want a fresh log
18222 file, be sure to delete any existing one.
18224 @opindex fvtv-counts
18226 This is a debugging flag. When used in conjunction with
18227 @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
18228 causes the compiler to keep track of the total number of virtual calls
18229 it encounters and the number of verifications it inserts. It also
18230 counts the number of calls to certain run-time library functions
18231 that it inserts and logs this information for each compilation unit.
18232 The compiler writes this information to a file named
18233 @file{vtv_count_data.log} in the directory named by the environment
18234 variable @env{VTV_LOGS_DIR} if that is defined or the current working
18235 directory otherwise. It also counts the size of the vtable pointer sets
18236 for each class, and writes this information to @file{vtv_class_set_sizes.log}
18237 in the same directory.
18239 Note: This feature @emph{appends} data to the log files. To get fresh log
18240 files, be sure to delete any existing ones.
18242 @opindex finstrument-functions
18243 @item -finstrument-functions
18244 Generate instrumentation calls for entry and exit to functions. Just
18245 after function entry and just before function exit, the following
18246 profiling functions are called with the address of the current
18247 function and its call site. (On some platforms,
18248 @code{__builtin_return_address} does not work beyond the current
18249 function, so the call site information may not be available to the
18250 profiling functions otherwise.)
18253 void __cyg_profile_func_enter (void *this_fn,
18255 void __cyg_profile_func_exit (void *this_fn,
18259 The first argument is the address of the start of the current function,
18260 which may be looked up exactly in the symbol table.
18262 This instrumentation is also done for functions expanded inline in other
18263 functions. The profiling calls indicate where, conceptually, the
18264 inline function is entered and exited. This means that addressable
18265 versions of such functions must be available. If all your uses of a
18266 function are expanded inline, this may mean an additional expansion of
18267 code size. If you use @code{extern inline} in your C code, an
18268 addressable version of such functions must be provided. (This is
18269 normally the case anyway, but if you get lucky and the optimizer always
18270 expands the functions inline, you might have gotten away without
18271 providing static copies.)
18273 A function may be given the attribute @code{no_instrument_function}, in
18274 which case this instrumentation is not done. This can be used, for
18275 example, for the profiling functions listed above, high-priority
18276 interrupt routines, and any functions from which the profiling functions
18277 cannot safely be called (perhaps signal handlers, if the profiling
18278 routines generate output or allocate memory).
18279 @xref{Common Function Attributes}.
18281 @opindex finstrument-functions-once
18282 @item -finstrument-functions-once
18283 This is similar to @option{-finstrument-functions}, but the profiling
18284 functions are called only once per instrumented function, i.e. the first
18285 profiling function is called after the first entry into the instrumented
18286 function and the second profiling function is called before the exit
18287 corresponding to this first entry.
18289 The definition of @code{once} for the purpose of this option is a little
18290 vague because the implementation is not protected against data races.
18291 As a result, the implementation only guarantees that the profiling
18292 functions are called at @emph{least} once per process and at @emph{most}
18293 once per thread, but the calls are always paired, that is to say, if a
18294 thread calls the first function, then it will call the second function,
18295 unless it never reaches the exit of the instrumented function.
18297 @opindex finstrument-functions-exclude-file-list
18298 @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
18300 Set the list of functions that are excluded from instrumentation (see
18301 the description of @option{-finstrument-functions}). If the file that
18302 contains a function definition matches with one of @var{file}, then
18303 that function is not instrumented. The match is done on substrings:
18304 if the @var{file} parameter is a substring of the file name, it is
18305 considered to be a match.
18310 -finstrument-functions-exclude-file-list=/bits/stl,include/sys
18314 excludes any inline function defined in files whose pathnames
18315 contain @file{/bits/stl} or @file{include/sys}.
18317 If, for some reason, you want to include letter @samp{,} in one of
18318 @var{sym}, write @samp{\,}. For example,
18319 @option{-finstrument-functions-exclude-file-list='\,\,tmp'}
18320 (note the single quote surrounding the option).
18322 @opindex finstrument-functions-exclude-function-list
18323 @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
18325 This is similar to @option{-finstrument-functions-exclude-file-list},
18326 but this option sets the list of function names to be excluded from
18327 instrumentation. The function name to be matched is its user-visible
18328 name, such as @code{vector<int> blah(const vector<int> &)}, not the
18329 internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
18330 match is done on substrings: if the @var{sym} parameter is a substring
18331 of the function name, it is considered to be a match. For C99 and C++
18332 extended identifiers, the function name must be given in UTF-8, not
18333 using universal character names.
18335 @opindex fpatchable-function-entry
18336 @item -fpatchable-function-entry=@var{N}[,@var{M}]
18337 Generate @var{N} NOPs right at the beginning
18338 of each function, with the function entry point before the @var{M}th NOP.
18339 If @var{M} is omitted, it defaults to @code{0} so the
18340 function entry points to the address just at the first NOP.
18341 The NOP instructions reserve extra space which can be used to patch in
18342 any desired instrumentation at run time, provided that the code segment
18343 is writable. The amount of space is controllable indirectly via
18344 the number of NOPs; the NOP instruction used corresponds to the instruction
18345 emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
18346 is target-specific and may also depend on the architecture variant and/or
18347 other compilation options.
18349 For run-time identification, the starting addresses of these areas,
18350 which correspond to their respective function entries minus @var{M},
18351 are additionally collected in the @code{__patchable_function_entries}
18352 section of the resulting binary.
18354 Note that the value of @code{__attribute__ ((patchable_function_entry
18355 (N,M)))} takes precedence over command-line option
18356 @option{-fpatchable-function-entry=N,M}. This can be used to increase
18357 the area size or to remove it completely on a single function.
18358 If @code{N=0}, no pad location is recorded.
18360 The NOP instructions are inserted at---and maybe before, depending on
18361 @var{M}---the function entry address, even before the prologue. On
18362 PowerPC with the ELFv2 ABI, for a function with dual entry points,
18363 the local entry point is this function entry address.
18365 The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
18366 ELFv2 ABI, for a function with dual entry points, the supported values
18367 for @var{M} are 0, 2, 6 and 14.
18371 @node Preprocessor Options
18372 @section Options Controlling the Preprocessor
18373 @cindex preprocessor options
18374 @cindex options, preprocessor
18376 These options control the C preprocessor, which is run on each C source
18377 file before actual compilation.
18379 If you use the @option{-E} option, nothing is done except preprocessing.
18380 Some of these options make sense only together with @option{-E} because
18381 they cause the preprocessor output to be unsuitable for actual
18384 In addition to the options listed here, there are a number of options
18385 to control search paths for include files documented in
18386 @ref{Directory Options}.
18387 Options to control preprocessor diagnostics are listed in
18388 @ref{Warning Options}.
18391 @include cppopts.texi
18394 @item -Wp,@var{option}
18395 You can use @option{-Wp,@var{option}} to bypass the compiler driver
18396 and pass @var{option} directly through to the preprocessor. If
18397 @var{option} contains commas, it is split into multiple options at the
18398 commas. However, many options are modified, translated or interpreted
18399 by the compiler driver before being passed to the preprocessor, and
18400 @option{-Wp} forcibly bypasses this phase. The preprocessor's direct
18401 interface is undocumented and subject to change, so whenever possible
18402 you should avoid using @option{-Wp} and let the driver handle the
18405 @opindex Xpreprocessor
18406 @item -Xpreprocessor @var{option}
18407 Pass @var{option} as an option to the preprocessor. You can use this to
18408 supply system-specific preprocessor options that GCC does not
18411 If you want to pass an option that takes an argument, you must use
18412 @option{-Xpreprocessor} twice, once for the option and once for the argument.
18414 @opindex no-integrated-cpp
18415 @item -no-integrated-cpp
18416 Perform preprocessing as a separate pass before compilation.
18417 By default, GCC performs preprocessing as an integrated part of
18418 input tokenization and parsing.
18419 If this option is provided, the appropriate language front end
18420 (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
18421 and Objective-C, respectively) is instead invoked twice,
18422 once for preprocessing only and once for actual compilation
18423 of the preprocessed input.
18424 This option may be useful in conjunction with the @option{-B} or
18425 @option{-wrapper} options to specify an alternate preprocessor or
18426 perform additional processing of the program source between
18427 normal preprocessing and compilation.
18429 @opindex flarge-source-files
18430 @item -flarge-source-files
18431 Adjust GCC to expect large source files, at the expense of slower
18432 compilation and higher memory usage.
18434 Specifically, GCC normally tracks both column numbers and line numbers
18435 within source files and it normally prints both of these numbers in
18436 diagnostics. However, once it has processed a certain number of source
18437 lines, it stops tracking column numbers and only tracks line numbers.
18438 This means that diagnostics for later lines do not include column numbers.
18439 It also means that options like @option{-Wmisleading-indentation} cease to work
18440 at that point, although the compiler prints a note if this happens.
18441 Passing @option{-flarge-source-files} significantly increases the number
18442 of source lines that GCC can process before it stops tracking columns.
18446 @node Assembler Options
18447 @section Passing Options to the Assembler
18449 @c prevent bad page break with this line
18450 You can pass options to the assembler.
18454 @item -Wa,@var{option}
18455 Pass @var{option} as an option to the assembler. If @var{option}
18456 contains commas, it is split into multiple options at the commas.
18458 @opindex Xassembler
18459 @item -Xassembler @var{option}
18460 Pass @var{option} as an option to the assembler. You can use this to
18461 supply system-specific assembler options that GCC does not
18464 If you want to pass an option that takes an argument, you must use
18465 @option{-Xassembler} twice, once for the option and once for the argument.
18470 @section Options for Linking
18471 @cindex link options
18472 @cindex options, linking
18474 These options come into play when the compiler links object files into
18475 an executable output file. They are meaningless if the compiler is
18476 not doing a link step.
18480 @item @var{object-file-name}
18481 A file name that does not end in a special recognized suffix is
18482 considered to name an object file or library. (Object files are
18483 distinguished from libraries by the linker according to the file
18484 contents.) If linking is done, these object files are used as input
18493 If any of these options is used, then the linker is not run, and
18494 object file names should not be used as arguments. @xref{Overall
18497 @opindex flinker-output
18498 @item -flinker-output=@var{type}
18499 This option controls code generation of the link-time optimizer. By
18500 default the linker output is automatically determined by the linker
18501 plugin. For debugging the compiler and if incremental linking with a
18502 non-LTO object file is desired, it may be useful to control the type
18505 If @var{type} is @samp{exec}, code generation produces a static
18506 binary. In this case @option{-fpic} and @option{-fpie} are both
18509 If @var{type} is @samp{dyn}, code generation produces a shared
18510 library. In this case @option{-fpic} or @option{-fPIC} is preserved,
18511 but not enabled automatically. This allows to build shared libraries
18512 without position-independent code on architectures where this is
18513 possible, i.e.@: on x86.
18515 If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
18516 executable. This results in similar optimizations as @samp{exec}
18517 except that @option{-fpie} is not disabled if specified at compilation
18520 If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
18521 done. The sections containing intermediate code for link-time optimization are
18522 merged, pre-optimized, and output to the resulting object file. In addition, if
18523 @option{-ffat-lto-objects} is specified, binary code is produced for future
18524 non-LTO linking. The object file produced by incremental linking is smaller
18525 than a static library produced from the same object files. At link time the
18526 result of incremental linking also loads faster than a static
18527 library assuming that the majority of objects in the library are used.
18529 Finally @samp{nolto-rel} configures the compiler for incremental linking where
18530 code generation is forced, a final binary is produced, and the intermediate
18531 code for later link-time optimization is stripped. When multiple object files
18532 are linked together the resulting code is better optimized than with
18533 link-time optimizations disabled (for example, cross-module inlining
18534 happens), but most of benefits of whole program optimizations are lost.
18536 During the incremental link (by @option{-r}) the linker plugin defaults to
18537 @option{rel}. With current interfaces to GNU Binutils it is however not
18538 possible to incrementally link LTO objects and non-LTO objects into a single
18539 mixed object file. If any of object files in incremental link cannot
18540 be used for link-time optimization, the linker plugin issues a warning and
18541 uses @samp{nolto-rel}. To maintain whole program optimization, it is
18542 recommended to link such objects into static library instead. Alternatively it
18543 is possible to use H.J. Lu's binutils with support for mixed objects.
18545 @opindex fuse-ld=bfd
18547 Use the @command{bfd} linker instead of the default linker.
18549 @opindex fuse-ld=gold
18550 @item -fuse-ld=gold
18551 Use the @command{gold} linker instead of the default linker.
18553 @opindex fuse-ld=lld
18555 Use the LLVM @command{lld} linker instead of the default linker.
18557 @opindex fuse-ld=mold
18558 @item -fuse-ld=mold
18559 Use the Modern Linker (@command{mold}) instead of the default linker.
18563 @item -l@var{library}
18564 @itemx -l @var{library}
18565 Search the library named @var{library} when linking. (The second
18566 alternative with the library as a separate argument is only for
18567 POSIX compliance and is not recommended.)
18569 The @option{-l} option is passed directly to the linker by GCC. Refer
18570 to your linker documentation for exact details. The general
18571 description below applies to the GNU linker.
18573 The linker searches a standard list of directories for the library.
18574 The directories searched include several standard system directories
18575 plus any that you specify with @option{-L}.
18577 Static libraries are archives of object files, and have file names
18578 like @file{lib@var{library}.a}. Some targets also support shared
18579 libraries, which typically have names like @file{lib@var{library}.so}.
18580 If both static and shared libraries are found, the linker gives
18581 preference to linking with the shared library unless the
18582 @option{-static} option is used.
18584 It makes a difference where in the command you write this option; the
18585 linker searches and processes libraries and object files in the order they
18586 are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
18587 after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
18588 to functions in @samp{z}, those functions may not be loaded.
18592 You need this special case of the @option{-l} option in order to
18593 link an Objective-C or Objective-C++ program.
18595 @opindex nostartfiles
18596 @item -nostartfiles
18597 Do not use the standard system startup files when linking.
18598 The standard system libraries are used normally, unless @option{-nostdlib},
18599 @option{-nolibc}, or @option{-nodefaultlibs} is used.
18601 @opindex nodefaultlibs
18602 @item -nodefaultlibs
18603 Do not use the standard system libraries when linking.
18604 Only the libraries you specify are passed to the linker, and options
18605 specifying linkage of the system libraries, such as @option{-static-libgcc}
18606 or @option{-shared-libgcc}, are ignored.
18607 The standard startup files are used normally, unless @option{-nostartfiles}
18610 The compiler may generate calls to @code{memcmp},
18611 @code{memset}, @code{memcpy} and @code{memmove}.
18612 These entries are usually resolved by entries in
18613 libc. These entry points should be supplied through some other
18614 mechanism when this option is specified.
18618 Do not use the C library or system libraries tightly coupled with it when
18619 linking. Still link with the startup files, @file{libgcc} or toolchain
18620 provided language support libraries such as @file{libgnat}, @file{libgfortran}
18621 or @file{libstdc++} unless options preventing their inclusion are used as
18622 well. This typically removes @option{-lc} from the link command line, as well
18623 as system libraries that normally go with it and become meaningless when
18624 absence of a C library is assumed, for example @option{-lpthread} or
18625 @option{-lm} in some configurations. This is intended for bare-board
18626 targets when there is indeed no C library available.
18630 Do not use the standard system startup files or libraries when linking.
18631 No startup files and only the libraries you specify are passed to
18632 the linker, and options specifying linkage of the system libraries, such as
18633 @option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
18635 The compiler may generate calls to @code{memcmp}, @code{memset},
18636 @code{memcpy} and @code{memmove}.
18637 These entries are usually resolved by entries in
18638 libc. These entry points should be supplied through some other
18639 mechanism when this option is specified.
18641 @cindex @option{-lgcc}, use with @option{-nostdlib}
18642 @cindex @option{-nostdlib} and unresolved references
18643 @cindex unresolved references and @option{-nostdlib}
18644 @cindex @option{-lgcc}, use with @option{-nodefaultlibs}
18645 @cindex @option{-nodefaultlibs} and unresolved references
18646 @cindex unresolved references and @option{-nodefaultlibs}
18647 One of the standard libraries bypassed by @option{-nostdlib} and
18648 @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
18649 which GCC uses to overcome shortcomings of particular machines, or special
18650 needs for some languages.
18651 (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
18652 Collection (GCC) Internals},
18653 for more discussion of @file{libgcc.a}.)
18654 In most cases, you need @file{libgcc.a} even when you want to avoid
18655 other standard libraries. In other words, when you specify @option{-nostdlib}
18656 or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
18657 This ensures that you have no unresolved references to internal GCC
18658 library subroutines.
18659 (An example of such an internal subroutine is @code{__main}, used to ensure C++
18660 constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
18661 GNU Compiler Collection (GCC) Internals}.)
18663 @opindex nostdlib++
18665 Do not implicitly link with standard C++ libraries.
18669 @item -e @var{entry}
18670 @itemx --entry=@var{entry}
18672 Specify that the program entry point is @var{entry}. The argument is
18673 interpreted by the linker; the GNU linker accepts either a symbol name
18678 Produce a dynamically linked position independent executable on targets
18679 that support it. For predictable results, you must also specify the same
18680 set of options used for compilation (@option{-fpie}, @option{-fPIE},
18681 or model suboptions) when you specify this linker option.
18685 Don't produce a dynamically linked position independent executable.
18687 @opindex static-pie
18689 Produce a static position independent executable on targets that support
18690 it. A static position independent executable is similar to a static
18691 executable, but can be loaded at any address without a dynamic linker.
18692 For predictable results, you must also specify the same set of options
18693 used for compilation (@option{-fpie}, @option{-fPIE}, or model
18694 suboptions) when you specify this linker option.
18698 Link with the POSIX threads library. This option is supported on
18699 GNU/Linux targets, most other Unix derivatives, and also on
18700 x86 Cygwin and MinGW targets. On some targets this option also sets
18701 flags for the preprocessor, so it should be used consistently for both
18702 compilation and linking.
18706 Produce a relocatable object as output. This is also known as partial
18711 Pass the flag @option{-export-dynamic} to the ELF linker, on targets
18712 that support it. This instructs the linker to add all symbols, not
18713 only used ones, to the dynamic symbol table. This option is needed
18714 for some uses of @code{dlopen} or to allow obtaining backtraces
18715 from within a program.
18719 Remove all symbol table and relocation information from the executable.
18723 On systems that support dynamic linking, this overrides @option{-pie}
18724 and prevents linking with the shared libraries. On other systems, this
18725 option has no effect.
18729 Produce a shared object which can then be linked with other objects to
18730 form an executable. Not all systems support this option. For predictable
18731 results, you must also specify the same set of options used for compilation
18732 (@option{-fpic}, @option{-fPIC}, or model suboptions) when
18733 you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
18734 needs to build supplementary stub code for constructors to work. On
18735 multi-libbed systems, @samp{gcc -shared} must select the correct support
18736 libraries to link against. Failing to supply the correct flags may lead
18737 to subtle defects. Supplying them in cases where they are not necessary
18738 is innocuous. @option{-shared} suppresses the addition of startup code
18739 to alter the floating-point environment as done with @option{-ffast-math},
18740 @option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
18742 @opindex shared-libgcc
18743 @opindex static-libgcc
18744 @item -shared-libgcc
18745 @itemx -static-libgcc
18746 On systems that provide @file{libgcc} as a shared library, these options
18747 force the use of either the shared or static version, respectively.
18748 If no shared version of @file{libgcc} was built when the compiler was
18749 configured, these options have no effect.
18751 There are several situations in which an application should use the
18752 shared @file{libgcc} instead of the static version. The most common
18753 of these is when the application wishes to throw and catch exceptions
18754 across different shared libraries. In that case, each of the libraries
18755 as well as the application itself should use the shared @file{libgcc}.
18757 Therefore, the G++ driver automatically adds @option{-shared-libgcc}
18758 whenever you build a shared library or a main executable, because C++
18759 programs typically use exceptions, so this is the right thing to do.
18761 If, instead, you use the GCC driver to create shared libraries, you may
18762 find that they are not always linked with the shared @file{libgcc}.
18763 If GCC finds, at its configuration time, that you have a non-GNU linker
18764 or a GNU linker that does not support option @option{--eh-frame-hdr},
18765 it links the shared version of @file{libgcc} into shared libraries
18766 by default. Otherwise, it takes advantage of the linker and optimizes
18767 away the linking with the shared version of @file{libgcc}, linking with
18768 the static version of libgcc by default. This allows exceptions to
18769 propagate through such shared libraries, without incurring relocation
18770 costs at library load time.
18772 However, if a library or main executable is supposed to throw or catch
18773 exceptions, you must link it using the G++ driver, or using the option
18774 @option{-shared-libgcc}, such that it is linked with the shared
18777 @opindex static-libasan
18778 @item -static-libasan
18779 When the @option{-fsanitize=address} option is used to link a program,
18780 the GCC driver automatically links against @option{libasan}. If
18781 @file{libasan} is available as a shared library, and the @option{-static}
18782 option is not used, then this links against the shared version of
18783 @file{libasan}. The @option{-static-libasan} option directs the GCC
18784 driver to link @file{libasan} statically, without necessarily linking
18785 other libraries statically.
18787 @opindex static-libtsan
18788 @item -static-libtsan
18789 When the @option{-fsanitize=thread} option is used to link a program,
18790 the GCC driver automatically links against @option{libtsan}. If
18791 @file{libtsan} is available as a shared library, and the @option{-static}
18792 option is not used, then this links against the shared version of
18793 @file{libtsan}. The @option{-static-libtsan} option directs the GCC
18794 driver to link @file{libtsan} statically, without necessarily linking
18795 other libraries statically.
18797 @opindex static-liblsan
18798 @item -static-liblsan
18799 When the @option{-fsanitize=leak} option is used to link a program,
18800 the GCC driver automatically links against @option{liblsan}. If
18801 @file{liblsan} is available as a shared library, and the @option{-static}
18802 option is not used, then this links against the shared version of
18803 @file{liblsan}. The @option{-static-liblsan} option directs the GCC
18804 driver to link @file{liblsan} statically, without necessarily linking
18805 other libraries statically.
18807 @opindex static-libubsan
18808 @item -static-libubsan
18809 When the @option{-fsanitize=undefined} option is used to link a program,
18810 the GCC driver automatically links against @option{libubsan}. If
18811 @file{libubsan} is available as a shared library, and the @option{-static}
18812 option is not used, then this links against the shared version of
18813 @file{libubsan}. The @option{-static-libubsan} option directs the GCC
18814 driver to link @file{libubsan} statically, without necessarily linking
18815 other libraries statically.
18817 @opindex static-libstdc++
18818 @item -static-libstdc++
18819 When the @command{g++} program is used to link a C++ program, it
18820 normally automatically links against @option{libstdc++}. If
18821 @file{libstdc++} is available as a shared library, and the
18822 @option{-static} option is not used, then this links against the
18823 shared version of @file{libstdc++}. That is normally fine. However, it
18824 is sometimes useful to freeze the version of @file{libstdc++} used by
18825 the program without going all the way to a fully static link. The
18826 @option{-static-libstdc++} option directs the @command{g++} driver to
18827 link @file{libstdc++} statically, without necessarily linking other
18828 libraries statically.
18832 Bind references to global symbols when building a shared object. Warn
18833 about any unresolved references (unless overridden by the link editor
18834 option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
18838 @cindex linker script
18839 @item -T @var{script}
18840 Use @var{script} as the linker script. This option is supported by most
18841 systems using the GNU linker. On some targets, such as bare-board
18842 targets without an operating system, the @option{-T} option may be required
18843 when linking to avoid references to undefined symbols.
18846 @item -Xlinker @var{option}
18847 Pass @var{option} as an option to the linker. You can use this to
18848 supply system-specific linker options that GCC does not recognize.
18850 If you want to pass an option that takes a separate argument, you must use
18851 @option{-Xlinker} twice, once for the option and once for the argument.
18852 For example, to pass @option{-assert definitions}, you must write
18853 @option{-Xlinker -assert -Xlinker definitions}. It does not work to write
18854 @option{-Xlinker "-assert definitions"}, because this passes the entire
18855 string as a single argument, which is not what the linker expects.
18857 When using the GNU linker, it is usually more convenient to pass
18858 arguments to linker options using the @option{@var{option}=@var{value}}
18859 syntax than as separate arguments. For example, you can specify
18860 @option{-Xlinker -Map=output.map} rather than
18861 @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
18862 this syntax for command-line options.
18865 @item -Wl,@var{option}
18866 Pass @var{option} as an option to the linker. If @var{option} contains
18867 commas, it is split into multiple options at the commas. You can use this
18868 syntax to pass an argument to the option.
18869 For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
18870 linker. When using the GNU linker, you can also get the same effect with
18871 @option{-Wl,-Map=output.map}.
18874 @item -u @var{symbol}
18875 Pretend the symbol @var{symbol} is undefined, to force linking of
18876 library modules to define it. You can use @option{-u} multiple times with
18877 different symbols to force loading of additional library modules.
18880 @item -z @var{keyword}
18881 @option{-z} is passed directly on to the linker along with the keyword
18882 @var{keyword}. See the section in the documentation of your linker for
18883 permitted values and their meanings.
18886 @node Directory Options
18887 @section Options for Directory Search
18888 @cindex directory options
18889 @cindex options, directory search
18890 @cindex search path
18892 These options specify directories to search for header files, for
18893 libraries and for parts of the compiler:
18896 @include cppdiropts.texi
18898 @opindex iplugindir=
18899 @item -iplugindir=@var{dir}
18900 Set the directory to search for plugins that are passed
18901 by @option{-fplugin=@var{name}} instead of
18902 @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
18903 to be used by the user, but only passed by the driver.
18907 Add directory @var{dir} to the list of directories to be searched
18911 @item -B@var{prefix}
18912 This option specifies where to find the executables, libraries,
18913 include files, and data files of the compiler itself.
18915 The compiler driver program runs one or more of the subprograms
18916 @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
18917 @var{prefix} as a prefix for each program it tries to run, both with and
18918 without @samp{@var{machine}/@var{version}/} for the corresponding target
18919 machine and compiler version.
18921 For each subprogram to be run, the compiler driver first tries the
18922 @option{-B} prefix, if any. If that name is not found, or if @option{-B}
18923 is not specified, the driver tries two standard prefixes,
18924 @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
18925 those results in a file name that is found, the unmodified program
18926 name is searched for using the directories specified in your
18927 @env{PATH} environment variable.
18929 The compiler checks to see if the path provided by @option{-B}
18930 refers to a directory, and if necessary it adds a directory
18931 separator character at the end of the path.
18933 @option{-B} prefixes that effectively specify directory names also apply
18934 to libraries in the linker, because the compiler translates these
18935 options into @option{-L} options for the linker. They also apply to
18936 include files in the preprocessor, because the compiler translates these
18937 options into @option{-isystem} options for the preprocessor. In this case,
18938 the compiler appends @samp{include} to the prefix.
18940 The runtime support file @file{libgcc.a} can also be searched for using
18941 the @option{-B} prefix, if needed. If it is not found there, the two
18942 standard prefixes above are tried, and that is all. The file is left
18943 out of the link if it is not found by those means.
18945 Another way to specify a prefix much like the @option{-B} prefix is to use
18946 the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
18949 As a special kludge, if the path provided by @option{-B} is
18950 @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
18951 9, then it is replaced by @file{[dir/]include}. This is to help
18952 with boot-strapping the compiler.
18954 @opindex no-canonical-prefixes
18955 @item -no-canonical-prefixes
18956 Do not expand any symbolic links, resolve references to @samp{/../}
18957 or @samp{/./}, or make the path absolute when generating a relative
18961 @item --sysroot=@var{dir}
18962 Use @var{dir} as the logical root directory for headers and libraries.
18963 For example, if the compiler normally searches for headers in
18964 @file{/usr/include} and libraries in @file{/usr/lib}, it instead
18965 searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
18967 If you use both this option and the @option{-isysroot} option, then
18968 the @option{--sysroot} option applies to libraries, but the
18969 @option{-isysroot} option applies to header files.
18971 The GNU linker (beginning with version 2.16) has the necessary support
18972 for this option. If your linker does not support this option, the
18973 header file aspect of @option{--sysroot} still works, but the
18974 library aspect does not.
18976 @opindex no-sysroot-suffix
18977 @item --no-sysroot-suffix
18978 For some targets, a suffix is added to the root directory specified
18979 with @option{--sysroot}, depending on the other options used, so that
18980 headers may for example be found in
18981 @file{@var{dir}/@var{suffix}/usr/include} instead of
18982 @file{@var{dir}/usr/include}. This option disables the addition of
18987 @node Code Gen Options
18988 @section Options for Code Generation Conventions
18989 @cindex code generation conventions
18990 @cindex options, code generation
18991 @cindex run-time options
18993 These machine-independent options control the interface conventions
18994 used in code generation.
18996 Most of them have both positive and negative forms; the negative form
18997 of @option{-ffoo} is @option{-fno-foo}. In the table below, only
18998 one of the forms is listed---the one that is not the default. You
18999 can figure out the other form by either removing @samp{no-} or adding
19003 @opindex fstack_reuse
19004 @item -fstack-reuse=@var{reuse-level}
19005 This option controls stack space reuse for user declared local/auto variables
19006 and compiler generated temporaries. @var{reuse_level} can be @samp{all},
19007 @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
19008 local variables and temporaries, @samp{named_vars} enables the reuse only for
19009 user defined local variables with names, and @samp{none} disables stack reuse
19010 completely. The default value is @samp{all}. The option is needed when the
19011 program extends the lifetime of a scoped local variable or a compiler generated
19012 temporary beyond the end point defined by the language. When a lifetime of
19013 a variable ends, and if the variable lives in memory, the optimizing compiler
19014 has the freedom to reuse its stack space with other temporaries or scoped
19015 local variables whose live range does not overlap with it. Legacy code extending
19016 local lifetime is likely to break with the stack reuse optimization.
19035 if (*p == 10) // out of scope use of local1
19046 A(int k) : i(k), j(k) @{ @}
19053 void foo(const A& ar)
19060 foo(A(10)); // temp object's lifetime ends when foo returns
19066 ap->i+= 10; // ap references out of scope temp whose space
19067 // is reused with a. What is the value of ap->i?
19072 The lifetime of a compiler generated temporary is well defined by the C++
19073 standard. When a lifetime of a temporary ends, and if the temporary lives
19074 in memory, the optimizing compiler has the freedom to reuse its stack
19075 space with other temporaries or scoped local variables whose live range
19076 does not overlap with it. However some of the legacy code relies on
19077 the behavior of older compilers in which temporaries' stack space is
19078 not reused, the aggressive stack reuse can lead to runtime errors. This
19079 option is used to control the temporary stack reuse optimization.
19083 This option generates traps for signed overflow on addition, subtraction,
19084 multiplication operations.
19085 The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
19086 @option{-ftrapv} @option{-fwrapv} on the command-line results in
19087 @option{-fwrapv} being effective. Note that only active options override, so
19088 using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
19089 results in @option{-ftrapv} being effective.
19093 This option instructs the compiler to assume that signed arithmetic
19094 overflow of addition, subtraction and multiplication wraps around
19095 using twos-complement representation. This flag enables some optimizations
19096 and disables others.
19097 The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
19098 @option{-ftrapv} @option{-fwrapv} on the command-line results in
19099 @option{-fwrapv} being effective. Note that only active options override, so
19100 using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
19101 results in @option{-ftrapv} being effective.
19103 @opindex fwrapv-pointer
19104 @item -fwrapv-pointer
19105 This option instructs the compiler to assume that pointer arithmetic
19106 overflow on addition and subtraction wraps around using twos-complement
19107 representation. This flag disables some optimizations which assume
19108 pointer overflow is invalid.
19110 @opindex fstrict-overflow
19111 @item -fstrict-overflow
19112 This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
19113 negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
19115 @opindex fexceptions
19117 Enable exception handling. Generates extra code needed to propagate
19118 exceptions. For some targets, this implies GCC generates frame
19119 unwind information for all functions, which can produce significant data
19120 size overhead, although it does not affect execution. If you do not
19121 specify this option, GCC enables it by default for languages like
19122 C++ that normally require exception handling, and disables it for
19123 languages like C that do not normally require it. However, you may need
19124 to enable this option when compiling C code that needs to interoperate
19125 properly with exception handlers written in C++. You may also wish to
19126 disable this option if you are compiling older C++ programs that don't
19127 use exception handling.
19129 @opindex fnon-call-exceptions
19130 @item -fnon-call-exceptions
19131 Generate code that allows trapping instructions to throw exceptions.
19132 Note that this requires platform-specific runtime support that does
19133 not exist everywhere. Moreover, it only allows @emph{trapping}
19134 instructions to throw exceptions, i.e.@: memory references or floating-point
19135 instructions. It does not allow exceptions to be thrown from
19136 arbitrary signal handlers such as @code{SIGALRM}. This enables
19137 @option{-fexceptions}.
19139 @opindex fdelete-dead-exceptions
19140 @item -fdelete-dead-exceptions
19141 Consider that instructions that may throw exceptions but don't otherwise
19142 contribute to the execution of the program can be optimized away.
19143 This does not affect calls to functions except those with the
19144 @code{pure} or @code{const} attributes.
19145 This option is enabled by default for the Ada and C++ compilers, as permitted by
19146 the language specifications.
19147 Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
19149 @opindex funwind-tables
19150 @item -funwind-tables
19151 Similar to @option{-fexceptions}, except that it just generates any needed
19152 static data, but does not affect the generated code in any other way.
19153 You normally do not need to enable this option; instead, a language processor
19154 that needs this handling enables it on your behalf.
19156 @opindex fasynchronous-unwind-tables
19157 @item -fasynchronous-unwind-tables
19158 Generate unwind table in DWARF format, if supported by target machine. The
19159 table is exact at each instruction boundary, so it can be used for stack
19160 unwinding from asynchronous events (such as debugger or garbage collector).
19162 @opindex fno-gnu-unique
19163 @opindex fgnu-unique
19164 @item -fno-gnu-unique
19165 On systems with recent GNU assembler and C library, the C++ compiler
19166 uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
19167 of template static data members and static local variables in inline
19168 functions are unique even in the presence of @code{RTLD_LOCAL}; this
19169 is necessary to avoid problems with a library used by two different
19170 @code{RTLD_LOCAL} plugins depending on a definition in one of them and
19171 therefore disagreeing with the other one about the binding of the
19172 symbol. But this causes @code{dlclose} to be ignored for affected
19173 DSOs; if your program relies on reinitialization of a DSO via
19174 @code{dlclose} and @code{dlopen}, you can use
19175 @option{-fno-gnu-unique}.
19177 @opindex fpcc-struct-return
19178 @item -fpcc-struct-return
19179 Return ``short'' @code{struct} and @code{union} values in memory like
19180 longer ones, rather than in registers. This convention is less
19181 efficient, but it has the advantage of allowing intercallability between
19182 GCC-compiled files and files compiled with other compilers, particularly
19183 the Portable C Compiler (pcc).
19185 The precise convention for returning structures in memory depends
19186 on the target configuration macros.
19188 Short structures and unions are those whose size and alignment match
19189 that of some integer type.
19191 @strong{Warning:} code compiled with the @option{-fpcc-struct-return}
19192 switch is not binary compatible with code compiled with the
19193 @option{-freg-struct-return} switch.
19194 Use it to conform to a non-default application binary interface.
19196 @opindex freg-struct-return
19197 @item -freg-struct-return
19198 Return @code{struct} and @code{union} values in registers when possible.
19199 This is more efficient for small structures than
19200 @option{-fpcc-struct-return}.
19202 If you specify neither @option{-fpcc-struct-return} nor
19203 @option{-freg-struct-return}, GCC defaults to whichever convention is
19204 standard for the target. If there is no standard convention, GCC
19205 defaults to @option{-fpcc-struct-return}, except on targets where GCC is
19206 the principal compiler. In those cases, we can choose the standard, and
19207 we chose the more efficient register return alternative.
19209 @strong{Warning:} code compiled with the @option{-freg-struct-return}
19210 switch is not binary compatible with code compiled with the
19211 @option{-fpcc-struct-return} switch.
19212 Use it to conform to a non-default application binary interface.
19214 @opindex fshort-enums
19215 @item -fshort-enums
19216 Allocate to an @code{enum} type only as many bytes as it needs for the
19217 declared range of possible values. Specifically, the @code{enum} type
19218 is equivalent to the smallest integer type that has enough room.
19219 This option has no effect for an enumeration type with a fixed underlying
19222 @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
19223 code that is not binary compatible with code generated without that switch.
19224 Use it to conform to a non-default application binary interface.
19226 @opindex fshort-wchar
19227 @item -fshort-wchar
19228 Override the underlying type for @code{wchar_t} to be @code{short
19229 unsigned int} instead of the default for the target. This option is
19230 useful for building programs to run under WINE@.
19232 @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
19233 code that is not binary compatible with code generated without that switch.
19234 Use it to conform to a non-default application binary interface.
19237 @opindex fno-common
19238 @cindex tentative definitions
19240 In C code, this option controls the placement of global variables
19241 defined without an initializer, known as @dfn{tentative definitions}
19242 in the C standard. Tentative definitions are distinct from declarations
19243 of a variable with the @code{extern} keyword, which do not allocate storage.
19245 The default is @option{-fno-common}, which specifies that the compiler places
19246 uninitialized global variables in the BSS section of the object file.
19247 This inhibits the merging of tentative definitions by the linker so you get a
19248 multiple-definition error if the same variable is accidentally defined in more
19249 than one compilation unit.
19251 The @option{-fcommon} places uninitialized global variables in a common block.
19252 This allows the linker to resolve all tentative definitions of the same variable
19253 in different compilation units to the same object, or to a non-tentative
19254 definition. This behavior is inconsistent with C++, and on many targets implies
19255 a speed and code size penalty on global variable references. It is mainly
19256 useful to enable legacy code to link without errors.
19261 Ignore the @code{#ident} directive.
19263 @opindex finhibit-size-directive
19264 @item -finhibit-size-directive
19265 Don't output a @code{.size} assembler directive, or anything else that
19266 would cause trouble if the function is split in the middle, and the
19267 two halves are placed at locations far apart in memory. This option is
19268 used when compiling @file{crtstuff.c}; you should not need to use it
19271 @opindex fverbose-asm
19272 @item -fverbose-asm
19273 Put extra commentary information in the generated assembly code to
19274 make it more readable. This option is generally only of use to those
19275 who actually need to read the generated assembly code (perhaps while
19276 debugging the compiler itself).
19278 @option{-fno-verbose-asm}, the default, causes the
19279 extra information to be omitted and is useful when comparing two assembler
19282 The added comments include:
19287 information on the compiler version and command-line options,
19290 the source code lines associated with the assembly instructions,
19291 in the form FILENAME:LINENUMBER:CONTENT OF LINE,
19294 hints on which high-level expressions correspond to
19295 the various assembly instruction operands.
19299 For example, given this C source file:
19307 for (i = 0; i < n; i++)
19314 compiling to (x86_64) assembly via @option{-S} and emitting the result
19315 direct to stdout via @option{-o} @option{-}
19318 gcc -S test.c -fverbose-asm -Os -o -
19321 gives output similar to this:
19325 # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
19332 .type test, @@function
19336 # test.c:4: int total = 0;
19337 xorl %eax, %eax # <retval>
19338 # test.c:6: for (i = 0; i < n; i++)
19339 xorl %edx, %edx # i
19341 # test.c:6: for (i = 0; i < n; i++)
19342 cmpl %edi, %edx # n, i
19344 # test.c:7: total += i * i;
19345 movl %edx, %ecx # i, tmp92
19346 imull %edx, %ecx # i, tmp92
19347 # test.c:6: for (i = 0; i < n; i++)
19349 # test.c:7: total += i * i;
19350 addl %ecx, %eax # tmp92, <retval>
19358 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
19359 .section .note.GNU-stack,"",@@progbits
19362 The comments are intended for humans rather than machines and hence the
19363 precise format of the comments is subject to change.
19365 @opindex frecord-gcc-switches
19366 @item -frecord-gcc-switches
19367 This switch causes the command line used to invoke the
19368 compiler to be recorded into the object file that is being created.
19369 This switch is only implemented on some targets and the exact format
19370 of the recording is target and binary file format dependent, but it
19371 usually takes the form of a section containing ASCII text. This
19372 switch is related to the @option{-fverbose-asm} switch, but that
19373 switch only records information in the assembler output file as
19374 comments, so it never reaches the object file.
19375 See also @option{-grecord-gcc-switches} for another
19376 way of storing compiler options into the object file.
19379 @cindex global offset table
19382 Generate position-independent code (PIC) suitable for use in a shared
19383 library, if supported for the target machine. Such code accesses all
19384 constant addresses through a global offset table (GOT)@. The dynamic
19385 loader resolves the GOT entries when the program starts (the dynamic
19386 loader is not part of GCC; it is part of the operating system). If
19387 the GOT size for the linked executable exceeds a machine-specific
19388 maximum size, you get an error message from the linker indicating that
19389 @option{-fpic} does not work; in that case, recompile with @option{-fPIC}
19390 instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
19391 on the m68k and RS/6000. The x86 has no such limit.)
19393 Position-independent code requires special support, and therefore works
19394 only on certain machines. For the x86, GCC supports PIC for System V
19395 but not for the Sun 386i. Code generated for the IBM RS/6000 is always
19396 position-independent.
19398 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
19403 If supported for the target machine, emit position-independent code,
19404 suitable for dynamic linking and avoiding any limit on the size of the
19405 global offset table. This option makes a difference on AArch64, m68k,
19406 PowerPC and SPARC@.
19408 Position-independent code requires special support, and therefore works
19409 only on certain machines.
19411 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
19418 These options are similar to @option{-fpic} and @option{-fPIC}, but the
19419 generated position-independent code can be only linked into executables.
19420 Usually these options are used to compile code that will be linked using
19421 the @option{-pie} GCC option.
19423 @option{-fpie} and @option{-fPIE} both define the macros
19424 @code{__pie__} and @code{__PIE__}. The macros have the value 1
19425 for @option{-fpie} and 2 for @option{-fPIE}.
19430 Do not use the PLT for external function calls in position-independent code.
19431 Instead, load the callee address at call sites from the GOT and branch to it.
19432 This leads to more efficient code by eliminating PLT stubs and exposing
19433 GOT loads to optimizations. On architectures such as 32-bit x86 where
19434 PLT stubs expect the GOT pointer in a specific register, this gives more
19435 register allocation freedom to the compiler.
19436 Lazy binding requires use of the PLT;
19437 with @option{-fno-plt} all external symbols are resolved at load time.
19439 Alternatively, the function attribute @code{noplt} can be used to avoid calls
19440 through the PLT for specific external functions.
19442 In position-dependent code, a few targets also convert calls to
19443 functions that are marked to not use the PLT to use the GOT instead.
19445 @opindex fno-jump-tables
19446 @opindex fjump-tables
19447 @item -fno-jump-tables
19448 Do not use jump tables for switch statements even where it would be
19449 more efficient than other code generation strategies. This option is
19450 of use in conjunction with @option{-fpic} or @option{-fPIC} for
19451 building code that forms part of a dynamic linker and cannot
19452 reference the address of a jump table. On some targets, jump tables
19453 do not require a GOT and this option is not needed.
19455 @opindex fno-bit-tests
19456 @opindex fbit-tests
19457 @item -fno-bit-tests
19458 Do not use bit tests for switch statements even where it would be
19459 more efficient than other code generation strategies.
19462 @item -ffixed-@var{reg}
19463 Treat the register named @var{reg} as a fixed register; generated code
19464 should never refer to it (except perhaps as a stack pointer, frame
19465 pointer or in some other fixed role).
19467 @var{reg} must be the name of a register. The register names accepted
19468 are machine-specific and are defined in the @code{REGISTER_NAMES}
19469 macro in the machine description macro file.
19471 This flag does not have a negative form, because it specifies a
19474 @opindex fcall-used
19475 @item -fcall-used-@var{reg}
19476 Treat the register named @var{reg} as an allocable register that is
19477 clobbered by function calls. It may be allocated for temporaries or
19478 variables that do not live across a call. Functions compiled this way
19479 do not save and restore the register @var{reg}.
19481 It is an error to use this flag with the frame pointer or stack pointer.
19482 Use of this flag for other registers that have fixed pervasive roles in
19483 the machine's execution model produces disastrous results.
19485 This flag does not have a negative form, because it specifies a
19488 @opindex fcall-saved
19489 @item -fcall-saved-@var{reg}
19490 Treat the register named @var{reg} as an allocable register saved by
19491 functions. It may be allocated even for temporaries or variables that
19492 live across a call. Functions compiled this way save and restore
19493 the register @var{reg} if they use it.
19495 It is an error to use this flag with the frame pointer or stack pointer.
19496 Use of this flag for other registers that have fixed pervasive roles in
19497 the machine's execution model produces disastrous results.
19499 A different sort of disaster results from the use of this flag for
19500 a register in which function values may be returned.
19502 This flag does not have a negative form, because it specifies a
19505 @opindex fpack-struct
19506 @item -fpack-struct[=@var{n}]
19507 Without a value specified, pack all structure members together without
19508 holes. When a value is specified (which must be a small power of two), pack
19509 structure members according to this value, representing the maximum
19510 alignment (that is, objects with default alignment requirements larger than
19511 this are output potentially unaligned at the next fitting location.
19513 @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
19514 code that is not binary compatible with code generated without that switch.
19515 Additionally, it makes the code suboptimal.
19516 Use it to conform to a non-default application binary interface.
19518 @opindex fleading-underscore
19519 @item -fleading-underscore
19520 This option and its counterpart, @option{-fno-leading-underscore}, forcibly
19521 change the way C symbols are represented in the object file. One use
19522 is to help link with legacy assembly code.
19524 @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
19525 generate code that is not binary compatible with code generated without that
19526 switch. Use it to conform to a non-default application binary interface.
19527 Not all targets provide complete support for this switch.
19529 @opindex ftls-model
19530 @item -ftls-model=@var{model}
19531 Alter the thread-local storage model to be used (@pxref{Thread-Local}).
19532 The @var{model} argument should be one of @samp{global-dynamic},
19533 @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
19534 Note that the choice is subject to optimization: the compiler may use
19535 a more efficient model for symbols not visible outside of the translation
19536 unit, or if @option{-fpic} is not given on the command line.
19538 The default without @option{-fpic} is @samp{initial-exec}; with
19539 @option{-fpic} the default is @samp{global-dynamic}.
19541 @opindex ftrampolines
19542 @item -ftrampolines
19543 For targets that normally need trampolines for nested functions, always
19544 generate them instead of using descriptors. Otherwise, for targets that
19545 do not need them, like for example HP-PA or IA-64, do nothing.
19547 A trampoline is a small piece of code that is created at run time on the
19548 stack when the address of a nested function is taken, and is used to call
19549 the nested function indirectly. Therefore, it requires the stack to be
19550 made executable in order for the program to work properly.
19552 @option{-fno-trampolines} is enabled by default on a language by language
19553 basis to let the compiler avoid generating them, if it computes that this
19554 is safe, and replace them with descriptors. Descriptors are made up of data
19555 only, but the generated code must be prepared to deal with them. As of this
19556 writing, @option{-fno-trampolines} is enabled by default only for Ada.
19558 Moreover, code compiled with @option{-ftrampolines} and code compiled with
19559 @option{-fno-trampolines} are not binary compatible if nested functions are
19560 present. This option must therefore be used on a program-wide basis and be
19561 manipulated with extreme care.
19563 For languages other than Ada, the @code{-ftrampolines} and
19564 @code{-fno-trampolines} options currently have no effect, and
19565 trampolines are always generated on platforms that need them
19566 for nested functions.
19568 @opindex ftrampoline-impl
19569 @item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
19570 By default, trampolines are generated on stack. However, certain platforms
19571 (such as the Apple M1) do not permit an executable stack. Compiling with
19572 @option{-ftrampoline-impl=heap} generate calls to
19573 @code{__gcc_nested_func_ptr_created} and
19574 @code{__gcc_nested_func_ptr_deleted} in order to allocate and
19575 deallocate trampoline space on the executable heap. These functions are
19576 implemented in libgcc, and will only be provided on specific targets:
19577 x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap
19578 trampolines are @emph{not} guaranteed to be correctly deallocated if you
19579 @code{setjmp}, instantiate nested functions, and then @code{longjmp} back
19580 to a state prior to having allocated those nested functions.
19582 @opindex fvisibility
19583 @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
19584 Set the default ELF image symbol visibility to the specified option---all
19585 symbols are marked with this unless overridden within the code.
19586 Using this feature can very substantially improve linking and
19587 load times of shared object libraries, produce more optimized
19588 code, provide near-perfect API export and prevent symbol clashes.
19589 It is @strong{strongly} recommended that you use this in any shared objects
19592 Despite the nomenclature, @samp{default} always means public; i.e.,
19593 available to be linked against from outside the shared object.
19594 @samp{protected} and @samp{internal} are pretty useless in real-world
19595 usage so the only other commonly used option is @samp{hidden}.
19596 The default if @option{-fvisibility} isn't specified is
19597 @samp{default}, i.e., make every symbol public.
19599 A good explanation of the benefits offered by ensuring ELF
19600 symbols have the correct visibility is given by ``How To Write
19601 Shared Libraries'' by Ulrich Drepper (which can be found at
19602 @w{@uref{https://www.akkadia.org/drepper/}})---however a superior
19603 solution made possible by this option to marking things hidden when
19604 the default is public is to make the default hidden and mark things
19605 public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
19606 and @code{__attribute__ ((visibility("default")))} instead of
19607 @code{__declspec(dllexport)} you get almost identical semantics with
19608 identical syntax. This is a great boon to those working with
19609 cross-platform projects.
19611 For those adding visibility support to existing code, you may find
19612 @code{#pragma GCC visibility} of use. This works by you enclosing
19613 the declarations you wish to set visibility for with (for example)
19614 @code{#pragma GCC visibility push(hidden)} and
19615 @code{#pragma GCC visibility pop}.
19616 Bear in mind that symbol visibility should be viewed @strong{as
19617 part of the API interface contract} and thus all new code should
19618 always specify visibility when it is not the default; i.e., declarations
19619 only for use within the local DSO should @strong{always} be marked explicitly
19620 as hidden as so to avoid PLT indirection overheads---making this
19621 abundantly clear also aids readability and self-documentation of the code.
19622 Note that due to ISO C++ specification requirements, @code{operator new} and
19623 @code{operator delete} must always be of default visibility.
19625 Be aware that headers from outside your project, in particular system
19626 headers and headers from any other library you use, may not be
19627 expecting to be compiled with visibility other than the default. You
19628 may need to explicitly say @code{#pragma GCC visibility push(default)}
19629 before including any such headers.
19631 @code{extern} declarations are not affected by @option{-fvisibility}, so
19632 a lot of code can be recompiled with @option{-fvisibility=hidden} with
19633 no modifications. However, this means that calls to @code{extern}
19634 functions with no explicit visibility use the PLT, so it is more
19635 effective to use @code{__attribute ((visibility))} and/or
19636 @code{#pragma GCC visibility} to tell the compiler which @code{extern}
19637 declarations should be treated as hidden.
19639 Note that @option{-fvisibility} does affect C++ vague linkage
19640 entities. This means that, for instance, an exception class that is
19641 be thrown between DSOs must be explicitly marked with default
19642 visibility so that the @samp{type_info} nodes are unified between
19645 An overview of these techniques, their benefits and how to use them
19646 is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
19648 @opindex fstrict-volatile-bitfields
19649 @item -fstrict-volatile-bitfields
19650 This option should be used if accesses to volatile bit-fields (or other
19651 structure fields, although the compiler usually honors those types
19652 anyway) should use a single access of the width of the
19653 field's type, aligned to a natural alignment if possible. For
19654 example, targets with memory-mapped peripheral registers might require
19655 all such accesses to be 16 bits wide; with this flag you can
19656 declare all peripheral bit-fields as @code{unsigned short} (assuming short
19657 is 16 bits on these targets) to force GCC to use 16-bit accesses
19658 instead of, perhaps, a more efficient 32-bit access.
19660 If this option is disabled, the compiler uses the most efficient
19661 instruction. In the previous example, that might be a 32-bit load
19662 instruction, even though that accesses bytes that do not contain
19663 any portion of the bit-field, or memory-mapped registers unrelated to
19664 the one being updated.
19666 In some cases, such as when the @code{packed} attribute is applied to a
19667 structure field, it may not be possible to access the field with a single
19668 read or write that is correctly aligned for the target machine. In this
19669 case GCC falls back to generating multiple accesses rather than code that
19670 will fault or truncate the result at run time.
19672 Note: Due to restrictions of the C/C++11 memory model, write accesses are
19673 not allowed to touch non bit-field members. It is therefore recommended
19674 to define all bits of the field's type as bit-field members.
19676 The default value of this option is determined by the application binary
19677 interface for the target processor.
19679 @opindex fsync-libcalls
19680 @item -fsync-libcalls
19681 This option controls whether any out-of-line instance of the @code{__sync}
19682 family of functions may be used to implement the C++11 @code{__atomic}
19683 family of functions.
19685 The default value of this option is enabled, thus the only useful form
19686 of the option is @option{-fno-sync-libcalls}. This option is used in
19687 the implementation of the @file{libatomic} runtime library.
19691 @node Developer Options
19692 @section GCC Developer Options
19693 @cindex developer options
19694 @cindex debugging GCC
19695 @cindex debug dump options
19696 @cindex dump options
19697 @cindex compilation statistics
19699 This section describes command-line options that are primarily of
19700 interest to GCC developers, including options to support compiler
19701 testing and investigation of compiler bugs and compile-time
19702 performance problems. This includes options that produce debug dumps
19703 at various points in the compilation; that print statistics such as
19704 memory use and execution time; and that print information about GCC's
19705 configuration, such as where it searches for libraries. You should
19706 rarely need to use any of these options for ordinary compilation and
19709 Many developer options that cause GCC to dump output to a file take an
19710 optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
19711 or @samp{-} to dump to standard output, and @samp{stderr} for standard
19714 If @samp{=@var{filename}} is omitted, a default dump file name is
19715 constructed by concatenating the base dump file name, a pass number,
19716 phase letter, and pass name. The base dump file name is the name of
19717 output file produced by the compiler if explicitly specified and not
19718 an executable; otherwise it is the source file name.
19719 The pass number is determined by the order passes are registered with
19720 the compiler's pass manager.
19721 This is generally the same as the order of execution, but passes
19722 registered by plugins, target-specific passes, or passes that are
19723 otherwise registered late are numbered higher than the pass named
19724 @samp{final}, even if they are executed earlier. The phase letter is
19725 one of @samp{i} (inter-procedural analysis), @samp{l}
19726 (language-specific), @samp{r} (RTL), or @samp{t} (tree).
19727 The files are created in the directory of the output file.
19731 @opindex fcallgraph-info
19732 @item -fcallgraph-info
19733 @itemx -fcallgraph-info=@var{MARKERS}
19734 Makes the compiler output callgraph information for the program, on a
19735 per-object-file basis. The information is generated in the common VCG
19736 format. It can be decorated with additional, per-node and/or per-edge
19737 information, if a list of comma-separated markers is additionally
19738 specified. When the @code{su} marker is specified, the callgraph is
19739 decorated with stack usage information; it is equivalent to
19740 @option{-fstack-usage}. When the @code{da} marker is specified, the
19741 callgraph is decorated with information about dynamically allocated
19744 When compiling with @option{-flto}, no callgraph information is output
19745 along with the object file. At LTO link time, @option{-fcallgraph-info}
19746 may generate multiple callgraph information files next to intermediate
19750 @opindex fdump-rtl-@var{pass}
19751 @item -d@var{letters}
19752 @itemx -fdump-rtl-@var{pass}
19753 @itemx -fdump-rtl-@var{pass}=@var{filename}
19754 Says to make debugging dumps during compilation at times specified by
19755 @var{letters}. This is used for debugging the RTL-based passes of the
19758 Some @option{-d@var{letters}} switches have different meaning when
19759 @option{-E} is used for preprocessing. @xref{Preprocessor Options},
19760 for information about preprocessor-specific dump options.
19762 Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
19763 @option{-d} option @var{letters}. Here are the possible
19764 letters for use in @var{pass} and @var{letters}, and their meanings:
19768 @opindex fdump-rtl-alignments
19769 @item -fdump-rtl-alignments
19770 Dump after branch alignments have been computed.
19772 @opindex fdump-rtl-asmcons
19773 @item -fdump-rtl-asmcons
19774 Dump after fixing rtl statements that have unsatisfied in/out constraints.
19776 @opindex fdump-rtl-auto_inc_dec
19777 @item -fdump-rtl-auto_inc_dec
19778 Dump after auto-inc-dec discovery. This pass is only run on
19779 architectures that have auto inc or auto dec instructions.
19781 @opindex fdump-rtl-barriers
19782 @item -fdump-rtl-barriers
19783 Dump after cleaning up the barrier instructions.
19785 @opindex fdump-rtl-bbpart
19786 @item -fdump-rtl-bbpart
19787 Dump after partitioning hot and cold basic blocks.
19789 @opindex fdump-rtl-bbro
19790 @item -fdump-rtl-bbro
19791 Dump after block reordering.
19793 @opindex fdump-rtl-btl2
19794 @opindex fdump-rtl-btl2
19795 @item -fdump-rtl-btl1
19796 @itemx -fdump-rtl-btl2
19797 @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
19798 after the two branch
19799 target load optimization passes.
19801 @opindex fdump-rtl-bypass
19802 @item -fdump-rtl-bypass
19803 Dump after jump bypassing and control flow optimizations.
19805 @opindex fdump-rtl-combine
19806 @item -fdump-rtl-combine
19807 Dump after the RTL instruction combination pass.
19809 @opindex fdump-rtl-compgotos
19810 @item -fdump-rtl-compgotos
19811 Dump after duplicating the computed gotos.
19813 @opindex fdump-rtl-ce1
19814 @opindex fdump-rtl-ce2
19815 @opindex fdump-rtl-ce3
19816 @item -fdump-rtl-ce1
19817 @itemx -fdump-rtl-ce2
19818 @itemx -fdump-rtl-ce3
19819 @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
19820 @option{-fdump-rtl-ce3} enable dumping after the three
19821 if conversion passes.
19823 @opindex fdump-rtl-cprop_hardreg
19824 @item -fdump-rtl-cprop_hardreg
19825 Dump after hard register copy propagation.
19827 @opindex fdump-rtl-csa
19828 @item -fdump-rtl-csa
19829 Dump after combining stack adjustments.
19831 @opindex fdump-rtl-cse1
19832 @opindex fdump-rtl-cse2
19833 @item -fdump-rtl-cse1
19834 @itemx -fdump-rtl-cse2
19835 @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
19836 the two common subexpression elimination passes.
19838 @opindex fdump-rtl-dce
19839 @item -fdump-rtl-dce
19840 Dump after the standalone dead code elimination passes.
19842 @opindex fdump-rtl-dbr
19843 @item -fdump-rtl-dbr
19844 Dump after delayed branch scheduling.
19846 @opindex fdump-rtl-dce1
19847 @opindex fdump-rtl-dce2
19848 @item -fdump-rtl-dce1
19849 @itemx -fdump-rtl-dce2
19850 @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
19851 the two dead store elimination passes.
19853 @opindex fdump-rtl-eh
19854 @item -fdump-rtl-eh
19855 Dump after finalization of EH handling code.
19857 @opindex fdump-rtl-eh_ranges
19858 @item -fdump-rtl-eh_ranges
19859 Dump after conversion of EH handling range regions.
19861 @opindex fdump-rtl-expand
19862 @item -fdump-rtl-expand
19863 Dump after RTL generation.
19865 @opindex fdump-rtl-fwprop1
19866 @opindex fdump-rtl-fwprop2
19867 @item -fdump-rtl-fwprop1
19868 @itemx -fdump-rtl-fwprop2
19869 @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
19870 dumping after the two forward propagation passes.
19872 @opindex fdump-rtl-gcse1
19873 @opindex fdump-rtl-gcse2
19874 @item -fdump-rtl-gcse1
19875 @itemx -fdump-rtl-gcse2
19876 @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
19877 after global common subexpression elimination.
19879 @opindex fdump-rtl-init-regs
19880 @item -fdump-rtl-init-regs
19881 Dump after the initialization of the registers.
19883 @opindex fdump-rtl-initvals
19884 @item -fdump-rtl-initvals
19885 Dump after the computation of the initial value sets.
19887 @opindex fdump-rtl-into_cfglayout
19888 @item -fdump-rtl-into_cfglayout
19889 Dump after converting to cfglayout mode.
19891 @opindex fdump-rtl-ira
19892 @item -fdump-rtl-ira
19893 Dump after iterated register allocation.
19895 @opindex fdump-rtl-jump
19896 @item -fdump-rtl-jump
19897 Dump after the second jump optimization.
19899 @opindex fdump-rtl-loop2
19900 @item -fdump-rtl-loop2
19901 @option{-fdump-rtl-loop2} enables dumping after the rtl
19902 loop optimization passes.
19904 @opindex fdump-rtl-mach
19905 @item -fdump-rtl-mach
19906 Dump after performing the machine dependent reorganization pass, if that
19909 @opindex fdump-rtl-mode_sw
19910 @item -fdump-rtl-mode_sw
19911 Dump after removing redundant mode switches.
19913 @opindex fdump-rtl-rnreg
19914 @item -fdump-rtl-rnreg
19915 Dump after register renumbering.
19917 @opindex fdump-rtl-outof_cfglayout
19918 @item -fdump-rtl-outof_cfglayout
19919 Dump after converting from cfglayout mode.
19921 @opindex fdump-rtl-peephole2
19922 @item -fdump-rtl-peephole2
19923 Dump after the peephole pass.
19925 @opindex fdump-rtl-postreload
19926 @item -fdump-rtl-postreload
19927 Dump after post-reload optimizations.
19929 @opindex fdump-rtl-pro_and_epilogue
19930 @item -fdump-rtl-pro_and_epilogue
19931 Dump after generating the function prologues and epilogues.
19933 @opindex fdump-rtl-sched1
19934 @opindex fdump-rtl-sched2
19935 @item -fdump-rtl-sched1
19936 @itemx -fdump-rtl-sched2
19937 @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
19938 after the basic block scheduling passes.
19940 @opindex fdump-rtl-ree
19941 @item -fdump-rtl-ree
19942 Dump after sign/zero extension elimination.
19944 @opindex fdump-rtl-seqabstr
19945 @item -fdump-rtl-seqabstr
19946 Dump after common sequence discovery.
19948 @opindex fdump-rtl-shorten
19949 @item -fdump-rtl-shorten
19950 Dump after shortening branches.
19952 @opindex fdump-rtl-sibling
19953 @item -fdump-rtl-sibling
19954 Dump after sibling call optimizations.
19956 @opindex fdump-rtl-split1
19957 @opindex fdump-rtl-split2
19958 @opindex fdump-rtl-split3
19959 @opindex fdump-rtl-split4
19960 @opindex fdump-rtl-split5
19961 @item -fdump-rtl-split1
19962 @itemx -fdump-rtl-split2
19963 @itemx -fdump-rtl-split3
19964 @itemx -fdump-rtl-split4
19965 @itemx -fdump-rtl-split5
19966 These options enable dumping after five rounds of
19967 instruction splitting.
19969 @opindex fdump-rtl-sms
19970 @item -fdump-rtl-sms
19971 Dump after modulo scheduling. This pass is only run on some
19974 @opindex fdump-rtl-stack
19975 @item -fdump-rtl-stack
19976 Dump after conversion from GCC's ``flat register file'' registers to the
19977 x87's stack-like registers. This pass is only run on x86 variants.
19979 @opindex fdump-rtl-subreg1
19980 @opindex fdump-rtl-subreg2
19981 @item -fdump-rtl-subreg1
19982 @itemx -fdump-rtl-subreg2
19983 @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
19984 the two subreg expansion passes.
19986 @opindex fdump-rtl-unshare
19987 @item -fdump-rtl-unshare
19988 Dump after all rtl has been unshared.
19990 @opindex fdump-rtl-vartrack
19991 @item -fdump-rtl-vartrack
19992 Dump after variable tracking.
19994 @opindex fdump-rtl-vregs
19995 @item -fdump-rtl-vregs
19996 Dump after converting virtual registers to hard registers.
19998 @opindex fdump-rtl-web
19999 @item -fdump-rtl-web
20000 Dump after live range splitting.
20002 @opindex fdump-rtl-regclass
20003 @opindex fdump-rtl-subregs_of_mode_init
20004 @opindex fdump-rtl-subregs_of_mode_finish
20005 @opindex fdump-rtl-dfinit
20006 @opindex fdump-rtl-dfinish
20007 @item -fdump-rtl-regclass
20008 @itemx -fdump-rtl-subregs_of_mode_init
20009 @itemx -fdump-rtl-subregs_of_mode_finish
20010 @itemx -fdump-rtl-dfinit
20011 @itemx -fdump-rtl-dfinish
20012 These dumps are defined but always produce empty files.
20015 @opindex fdump-rtl-all
20017 @itemx -fdump-rtl-all
20018 Produce all the dumps listed above.
20022 Annotate the assembler output with miscellaneous debugging information.
20026 Dump all macro definitions, at the end of preprocessing, in addition to
20031 Produce a core dump whenever an error occurs.
20035 Annotate the assembler output with a comment indicating which
20036 pattern and alternative is used. The length and cost of each instruction are
20041 Dump the RTL in the assembler output as a comment before each instruction.
20042 Also turns on @option{-dp} annotation.
20046 Just generate RTL for a function instead of compiling it. Usually used
20047 with @option{-fdump-rtl-expand}.
20050 @opindex fdump-debug
20052 Dump debugging information generated during the debug
20055 @opindex fdump-earlydebug
20056 @item -fdump-earlydebug
20057 Dump debugging information generated during the early debug
20060 @opindex fdump-noaddr
20061 @item -fdump-noaddr
20062 When doing debugging dumps, suppress address output. This makes it more
20063 feasible to use diff on debugging dumps for compiler invocations with
20064 different compiler binaries and/or different
20065 text / bss / data / heap / stack / dso start locations.
20067 @opindex freport-bug
20069 Collect and dump debug information into a temporary file if an
20070 internal compiler error (ICE) occurs.
20072 @opindex fdump-unnumbered
20073 @item -fdump-unnumbered
20074 When doing debugging dumps, suppress instruction numbers and address output.
20075 This makes it more feasible to use diff on debugging dumps for compiler
20076 invocations with different options, in particular with and without
20079 @opindex fdump-unnumbered-links
20080 @item -fdump-unnumbered-links
20081 When doing debugging dumps (see @option{-d} option above), suppress
20082 instruction numbers for the links to the previous and next instructions
20086 @item -fdump-ipa-@var{switch}
20087 @itemx -fdump-ipa-@var{switch}-@var{options}
20088 Control the dumping at various stages of inter-procedural analysis
20089 language tree to a file. The file name is generated by appending a
20090 switch specific suffix to the source file name, and the file is created
20091 in the same directory as the output file. The following dumps are
20096 Enables all inter-procedural analysis dumps.
20099 Dumps information about call-graph optimization, unused function removal,
20100 and inlining decisions.
20103 Dump after function inlining.
20106 Dump after selecting @code{strub} modes, and recording the selections as
20107 function attributes.
20110 Dump @code{strub} transformations: interface changes, function wrapping,
20111 and insertion of builtin calls for stack scrubbing and watermarking.
20115 Additionally, the options @option{-optimized}, @option{-missed},
20116 @option{-note}, and @option{-all} can be provided, with the same meaning
20117 as for @option{-fopt-info}, defaulting to @option{-optimized}.
20119 For example, @option{-fdump-ipa-inline-optimized-missed} will emit
20120 information on callsites that were inlined, along with callsites
20121 that were not inlined.
20123 By default, the dump will contain messages about successful
20124 optimizations (equivalent to @option{-optimized}) together with
20125 low-level details about the analysis.
20127 @opindex fdump-lang
20129 Dump language-specific information. The file name is made by appending
20130 @file{.lang} to the source file name.
20132 @opindex fdump-lang-all
20133 @opindex fdump-lang
20134 @item -fdump-lang-all
20135 @itemx -fdump-lang-@var{switch}
20136 @itemx -fdump-lang-@var{switch}-@var{options}
20137 @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
20138 Control the dumping of language-specific information. The @var{options}
20139 and @var{filename} portions behave as described in the
20140 @option{-fdump-tree} option. The following @var{switch} values are
20146 Enable all language-specific dumps.
20149 Dump class hierarchy information. Virtual table information is emitted
20150 unless '@option{slim}' is specified. This option is applicable to C++ only.
20153 Dump module information. Options @option{lineno} (locations),
20154 @option{graph} (reachability), @option{blocks} (clusters),
20155 @option{uid} (serialization), @option{alias} (mergeable),
20156 @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
20157 (macros) may provide additional information. This option is
20158 applicable to C++ only.
20161 Dump the raw internal tree data. This option is applicable to C++ only.
20165 @opindex fdump-passes
20166 @item -fdump-passes
20167 Print on @file{stderr} the list of optimization passes that are turned
20168 on and off by the current command-line options.
20170 @opindex fdump-statistics
20171 @item -fdump-statistics-@var{option}
20172 Enable and control dumping of pass statistics in a separate file. The
20173 file name is generated by appending a suffix ending in
20174 @samp{.statistics} to the source file name, and the file is created in
20175 the same directory as the output file. If the @samp{-@var{option}}
20176 form is used, @samp{-stats} causes counters to be summed over the
20177 whole compilation unit while @samp{-details} dumps every event as
20178 the passes generate them. The default with no option is to sum
20179 counters for each function compiled.
20181 @opindex fdump-tree-all
20182 @opindex fdump-tree
20183 @item -fdump-tree-all
20184 @itemx -fdump-tree-@var{switch}
20185 @itemx -fdump-tree-@var{switch}-@var{options}
20186 @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
20187 Control the dumping at various stages of processing the intermediate
20188 language tree to a file. If the @samp{-@var{options}}
20189 form is used, @var{options} is a list of @samp{-} separated options
20190 which control the details of the dump. Not all options are applicable
20191 to all dumps; those that are not meaningful are ignored. The
20192 following options are available
20196 Print the address of each node. Usually this is not meaningful as it
20197 changes according to the environment and source file. Its primary use
20198 is for tying up a dump file with a debug environment.
20200 If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
20201 in the dump instead of @code{DECL_NAME}. Its primary use is ease of
20202 use working backward from mangled names in the assembly file.
20204 When dumping front-end intermediate representations, inhibit dumping
20205 of members of a scope or body of a function merely because that scope
20206 has been reached. Only dump such items when they are directly reachable
20207 by some other path.
20209 When dumping pretty-printed trees, this option inhibits dumping the
20210 bodies of control structures.
20212 When dumping RTL, print the RTL in slim (condensed) form instead of
20213 the default LISP-like representation.
20215 Print a raw representation of the tree. By default, trees are
20216 pretty-printed into a C-like representation.
20218 Enable more detailed dumps (not honored by every dump option). Also
20219 include information from the optimization passes.
20221 Enable dumping various statistics about the pass (not honored by every dump
20224 Enable showing basic block boundaries (disabled in raw dumps).
20226 For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
20227 dump a representation of the control flow graph suitable for viewing with
20228 GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
20229 the file is pretty-printed as a subgraph, so that GraphViz can render them
20230 all in a single plot.
20232 This option currently only works for RTL dumps, and the RTL is always
20233 dumped in slim form.
20235 Enable showing virtual operands for every statement.
20237 Enable showing line numbers for statements.
20239 Enable showing the unique ID (@code{DECL_UID}) for each variable.
20241 Enable showing the tree dump for each statement.
20243 Enable showing the EH region number holding each statement.
20245 Enable showing scalar evolution analysis details.
20247 Enable showing optimization information (only available in certain
20250 Enable showing missed optimization information (only available in certain
20253 Enable other detailed optimization information (only available in
20256 Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
20257 and @option{lineno}.
20259 Turn on all optimization options, i.e., @option{optimized},
20260 @option{missed}, and @option{note}.
20263 To determine what tree dumps are available or find the dump for a pass
20264 of interest follow the steps below.
20268 Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
20269 look for a code that corresponds to the pass you are interested in.
20270 For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
20271 @code{tree-vrp2} correspond to the three Value Range Propagation passes.
20272 The number at the end distinguishes distinct invocations of the same pass.
20274 To enable the creation of the dump file, append the pass code to
20275 the @option{-fdump-} option prefix and invoke GCC with it. For example,
20276 to enable the dump from the Early Value Range Propagation pass, invoke
20277 GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
20278 specify the name of the dump file. If you don't specify one, GCC
20279 creates as described below.
20281 Find the pass dump in a file whose name is composed of three components
20282 separated by a period: the name of the source file GCC was invoked to
20283 compile, a numeric suffix indicating the pass number followed by the
20284 letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
20285 and finally the pass code. For example, the Early VRP pass dump might
20286 be in a file named @file{myfile.c.038t.evrp} in the current working
20287 directory. Note that the numeric codes are not stable and may change
20288 from one version of GCC to another.
20293 @itemx -fopt-info-@var{options}
20294 @itemx -fopt-info-@var{options}=@var{filename}
20295 Controls optimization dumps from various optimization passes. If the
20296 @samp{-@var{options}} form is used, @var{options} is a list of
20297 @samp{-} separated option keywords to select the dump details and
20300 The @var{options} can be divided into three groups:
20303 options describing what kinds of messages should be emitted,
20305 options describing the verbosity of the dump, and
20307 options describing which optimizations should be included.
20309 The options from each group can be freely mixed as they are
20310 non-overlapping. However, in case of any conflicts,
20311 the later options override the earlier options on the command
20314 The following options control which kinds of messages should be emitted:
20318 Print information when an optimization is successfully applied. It is
20319 up to a pass to decide which information is relevant. For example, the
20320 vectorizer passes print the source location of loops which are
20321 successfully vectorized.
20323 Print information about missed optimizations. Individual passes
20324 control which information to include in the output.
20326 Print verbose information about optimizations, such as certain
20327 transformations, more detailed messages about decisions etc.
20329 Print detailed optimization information. This includes
20330 @samp{optimized}, @samp{missed}, and @samp{note}.
20333 The following option controls the dump verbosity:
20337 By default, only ``high-level'' messages are emitted. This option enables
20338 additional, more detailed, messages, which are likely to only be of interest
20342 One or more of the following option keywords can be used to describe a
20343 group of optimizations:
20347 Enable dumps from all interprocedural optimizations.
20349 Enable dumps from all loop optimizations.
20351 Enable dumps from all inlining optimizations.
20353 Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
20355 Enable dumps from all vectorization optimizations.
20357 Enable dumps from all optimizations. This is a superset of
20358 the optimization groups listed above.
20361 If @var{options} is
20362 omitted, it defaults to @samp{optimized-optall}, which means to dump messages
20363 about successful optimizations from all the passes, omitting messages
20364 that are treated as ``internals''.
20366 If the @var{filename} is provided, then the dumps from all the
20367 applicable optimizations are concatenated into the @var{filename}.
20368 Otherwise the dump is output onto @file{stderr}. Though multiple
20369 @option{-fopt-info} options are accepted, only one of them can include
20370 a @var{filename}. If other filenames are provided then all but the
20371 first such option are ignored.
20373 Note that the output @var{filename} is overwritten
20374 in case of multiple translation units. If a combined output from
20375 multiple translation units is desired, @file{stderr} should be used
20378 In the following example, the optimization info is output to
20387 gcc -O3 -fopt-info-missed=missed.all
20391 outputs missed optimization report from all the passes into
20392 @file{missed.all}, and this one:
20395 gcc -O2 -ftree-vectorize -fopt-info-vec-missed
20399 prints information about missed optimization opportunities from
20400 vectorization passes on @file{stderr}.
20401 Note that @option{-fopt-info-vec-missed} is equivalent to
20402 @option{-fopt-info-missed-vec}. The order of the optimization group
20403 names and message types listed after @option{-fopt-info} does not matter.
20405 As another example,
20407 gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
20411 outputs information about missed optimizations as well as
20412 optimized locations from all the inlining passes into
20418 gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
20422 Here the two output filenames @file{vec.miss} and @file{loop.opt} are
20423 in conflict since only one output file is allowed. In this case, only
20424 the first option takes effect and the subsequent options are
20425 ignored. Thus only @file{vec.miss} is produced which contains
20426 dumps from the vectorizer about missed opportunities.
20428 @opindex fsave-optimization-record
20429 @item -fsave-optimization-record
20430 Write a SRCFILE.opt-record.json.gz file detailing what optimizations
20431 were performed, for those optimizations that support @option{-fopt-info}.
20433 This option is experimental and the format of the data within the
20434 compressed JSON file is subject to change.
20436 It is roughly equivalent to a machine-readable version of
20437 @option{-fopt-info-all}, as a collection of messages with source file,
20438 line number and column number, with the following additional data for
20444 the execution count of the code being optimized, along with metadata about
20445 whether this was from actual profile data, or just an estimate, allowing
20446 consumers to prioritize messages by code hotness,
20449 the function name of the code being optimized, where applicable,
20452 the ``inlining chain'' for the code being optimized, so that when
20453 a function is inlined into several different places (which might
20454 themselves be inlined), the reader can distinguish between the copies,
20457 objects identifying those parts of the message that refer to expressions,
20458 statements or symbol-table nodes, which of these categories they are, and,
20459 when available, their source code location,
20462 the GCC pass that emitted the message, and
20465 the location in GCC's own code from which the message was emitted
20469 Additionally, some messages are logically nested within other
20470 messages, reflecting implementation details of the optimization
20473 @opindex fsched-verbose
20474 @item -fsched-verbose=@var{n}
20475 On targets that use instruction scheduling, this option controls the
20476 amount of debugging output the scheduler prints to the dump files.
20478 For @var{n} greater than zero, @option{-fsched-verbose} outputs the
20479 same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
20480 For @var{n} greater than one, it also output basic block probabilities,
20481 detailed ready list information and unit/insn info. For @var{n} greater
20482 than two, it includes RTL at abort point, control-flow and regions info.
20483 And for @var{n} over four, @option{-fsched-verbose} also includes
20490 @item -fenable-@var{kind}-@var{pass}
20491 @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
20493 This is a set of options that are used to explicitly disable/enable
20494 optimization passes. These options are intended for use for debugging GCC.
20495 Compiler users should use regular options for enabling/disabling
20500 @item -fdisable-ipa-@var{pass}
20501 Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
20502 statically invoked in the compiler multiple times, the pass name should be
20503 appended with a sequential number starting from 1.
20505 @item -fdisable-rtl-@var{pass}
20506 @itemx -fdisable-rtl-@var{pass}=@var{range-list}
20507 Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
20508 statically invoked in the compiler multiple times, the pass name should be
20509 appended with a sequential number starting from 1. @var{range-list} is a
20510 comma-separated list of function ranges or assembler names. Each range is a number
20511 pair separated by a colon. The range is inclusive in both ends. If the range
20512 is trivial, the number pair can be simplified as a single number. If the
20513 function's call graph node's @var{uid} falls within one of the specified ranges,
20514 the @var{pass} is disabled for that function. The @var{uid} is shown in the
20515 function header of a dump file, and the pass names can be dumped by using
20516 option @option{-fdump-passes}.
20518 @item -fdisable-tree-@var{pass}
20519 @itemx -fdisable-tree-@var{pass}=@var{range-list}
20520 Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
20523 @item -fenable-ipa-@var{pass}
20524 Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
20525 statically invoked in the compiler multiple times, the pass name should be
20526 appended with a sequential number starting from 1.
20528 @item -fenable-rtl-@var{pass}
20529 @itemx -fenable-rtl-@var{pass}=@var{range-list}
20530 Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
20531 description and examples.
20533 @item -fenable-tree-@var{pass}
20534 @itemx -fenable-tree-@var{pass}=@var{range-list}
20535 Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
20536 of option arguments.
20540 Here are some examples showing uses of these options.
20544 # disable ccp1 for all functions
20545 -fdisable-tree-ccp1
20546 # disable complete unroll for function whose cgraph node uid is 1
20547 -fenable-tree-cunroll=1
20548 # disable gcse2 for functions at the following ranges [1,1],
20549 # [300,400], and [400,1000]
20550 # disable gcse2 for functions foo and foo2
20551 -fdisable-rtl-gcse2=foo,foo2
20552 # disable early inlining
20553 -fdisable-tree-einline
20554 # disable ipa inlining
20555 -fdisable-ipa-inline
20556 # enable tree full unroll
20557 -fenable-tree-unroll
20562 @opindex fno-checking
20564 @itemx -fchecking=@var{n}
20565 Enable internal consistency checking. The default depends on
20566 the compiler configuration. @option{-fchecking=2} enables further
20567 internal consistency checking that might affect code generation.
20569 @opindex frandom-seed
20570 @item -frandom-seed=@var{string}
20571 This option provides a seed that GCC uses in place of
20572 random numbers in generating certain symbol names
20573 that have to be different in every compiled file. It is also used to
20574 place unique stamps in coverage data files and the object files that
20575 produce them. You can use the @option{-frandom-seed} option to produce
20576 reproducibly identical object files.
20578 The @var{string} can either be a number (decimal, octal or hex) or an
20579 arbitrary string (in which case it's converted to a number by
20582 The @var{string} should be different for every file you compile.
20584 @opindex save-temps
20586 Store the usual ``temporary'' intermediate files permanently; name them
20587 as auxiliary output files, as specified described under
20588 @option{-dumpbase} and @option{-dumpdir}.
20590 When used in combination with the @option{-x} command-line option,
20591 @option{-save-temps} is sensible enough to avoid overwriting an
20592 input source file with the same extension as an intermediate file.
20593 The corresponding intermediate file may be obtained by renaming the
20594 source file before using @option{-save-temps}.
20596 @opindex save-temps=cwd
20597 @item -save-temps=cwd
20598 Equivalent to @option{-save-temps -dumpdir ./}.
20600 @opindex save-temps=obj
20601 @item -save-temps=obj
20602 Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
20603 @file{outdir/} is the directory of the output file specified after the
20604 @option{-o} option, including any directory separators. If the
20605 @option{-o} option is not used, the @option{-save-temps=obj} switch
20606 behaves like @option{-save-temps=cwd}.
20609 @item -time@r{[}=@var{file}@r{]}
20610 Report the CPU time taken by each subprocess in the compilation
20611 sequence. For C source files, this is the compiler proper and assembler
20612 (plus the linker if linking is done).
20614 Without the specification of an output file, the output looks like this:
20621 The first number on each line is the ``user time'', that is time spent
20622 executing the program itself. The second number is ``system time'',
20623 time spent executing operating system routines on behalf of the program.
20624 Both numbers are in seconds.
20626 With the specification of an output file, the output is appended to the
20627 named file, and it looks like this:
20630 0.12 0.01 cc1 @var{options}
20631 0.00 0.01 as @var{options}
20634 The ``user time'' and the ``system time'' are moved before the program
20635 name, and the options passed to the program are displayed, so that one
20636 can later tell what file was being compiled, and with which options.
20638 @opindex fdump-final-insns
20639 @item -fdump-final-insns@r{[}=@var{file}@r{]}
20640 Dump the final internal representation (RTL) to @var{file}. If the
20641 optional argument is omitted (or if @var{file} is @code{.}), the name
20642 of the dump file is determined by appending @code{.gkd} to the
20643 dump base name, see @option{-dumpbase}.
20645 @opindex fcompare-debug
20646 @opindex fno-compare-debug
20647 @item -fcompare-debug@r{[}=@var{opts}@r{]}
20648 If no error occurs during compilation, run the compiler a second time,
20649 adding @var{opts} and @option{-fcompare-debug-second} to the arguments
20650 passed to the second compilation. Dump the final internal
20651 representation in both compilations, and print an error if they differ.
20653 If the equal sign is omitted, the default @option{-gtoggle} is used.
20655 The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
20656 and nonzero, implicitly enables @option{-fcompare-debug}. If
20657 @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
20658 then it is used for @var{opts}, otherwise the default @option{-gtoggle}
20661 @option{-fcompare-debug=}, with the equal sign but without @var{opts},
20662 is equivalent to @option{-fno-compare-debug}, which disables the dumping
20663 of the final representation and the second compilation, preventing even
20664 @env{GCC_COMPARE_DEBUG} from taking effect.
20666 To verify full coverage during @option{-fcompare-debug} testing, set
20667 @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
20668 which GCC rejects as an invalid option in any actual compilation
20669 (rather than preprocessing, assembly or linking). To get just a
20670 warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
20671 not overridden} will do.
20673 @opindex fcompare-debug-second
20674 @item -fcompare-debug-second
20675 This option is implicitly passed to the compiler for the second
20676 compilation requested by @option{-fcompare-debug}, along with options to
20677 silence warnings, and omitting other options that would cause the compiler
20678 to produce output to files or to standard output as a side effect. Dump
20679 files and preserved temporary files are renamed so as to contain the
20680 @code{.gk} additional extension during the second compilation, to avoid
20681 overwriting those generated by the first.
20683 When this option is passed to the compiler driver, it causes the
20684 @emph{first} compilation to be skipped, which makes it useful for little
20685 other than debugging the compiler proper.
20689 Turn off generation of debug info, if leaving out this option
20690 generates it, or turn it on at level 2 otherwise. The position of this
20691 argument in the command line does not matter; it takes effect after all
20692 other options are processed, and it does so only once, no matter how
20693 many times it is given. This is mainly intended to be used with
20694 @option{-fcompare-debug}.
20696 @opindex fvar-tracking-assignments-toggle
20697 @opindex fno-var-tracking-assignments-toggle
20698 @item -fvar-tracking-assignments-toggle
20699 Toggle @option{-fvar-tracking-assignments}, in the same way that
20700 @option{-gtoggle} toggles @option{-g}.
20704 Makes the compiler print out each function name as it is compiled, and
20705 print some statistics about each pass when it finishes.
20707 @opindex ftime-report
20708 @item -ftime-report
20709 Makes the compiler print some statistics to stderr about the time consumed
20710 by each pass when it finishes.
20712 If SARIF output of diagnostics was requested via
20713 @option{-fdiagnostics-format=sarif-file} or
20714 @option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report}
20715 information is instead emitted in JSON form as part of SARIF output. The
20716 precise format of this JSON data is subject to change, and the values may
20717 not exactly match those emitted to stderr due to being written out at a
20718 slightly different place within the compiler.
20720 @opindex ftime-report-details
20721 @item -ftime-report-details
20722 Record the time consumed by infrastructure parts separately for each pass.
20724 @opindex fira-verbose
20725 @item -fira-verbose=@var{n}
20726 Control the verbosity of the dump file for the integrated register allocator.
20727 The default value is 5. If the value @var{n} is greater or equal to 10,
20728 the dump output is sent to stderr using the same format as @var{n} minus 10.
20730 @opindex flto-report
20732 Prints a report with internal details on the workings of the link-time
20733 optimizer. The contents of this report vary from version to version.
20734 It is meant to be useful to GCC developers when processing object
20735 files in LTO mode (via @option{-flto}).
20737 Disabled by default.
20739 @opindex flto-report-wpa
20740 @item -flto-report-wpa
20741 Like @option{-flto-report}, but only print for the WPA phase of link-time
20744 @opindex fmem-report
20746 Makes the compiler print some statistics about permanent memory
20747 allocation when it finishes.
20749 @opindex fmem-report-wpa
20750 @item -fmem-report-wpa
20751 Makes the compiler print some statistics about permanent memory
20752 allocation for the WPA phase only.
20754 @opindex fpre-ipa-mem-report
20755 @opindex fpost-ipa-mem-report
20756 @item -fpre-ipa-mem-report
20757 @item -fpost-ipa-mem-report
20758 Makes the compiler print some statistics about permanent memory
20759 allocation before or after interprocedural optimization.
20761 @opindex fmultiflags
20763 This option enables multilib-aware @code{TFLAGS} to be used to build
20764 target libraries with options different from those the compiler is
20765 configured to use by default, through the use of specs (@pxref{Spec
20766 Files}) set up by compiler internals, by the target, or by builders at
20769 Like @code{TFLAGS}, this allows the target libraries to be built for
20770 portable baseline environments, while the compiler defaults to more
20771 demanding ones. That's useful because users can easily override the
20772 defaults the compiler is configured to use to build their own programs,
20773 if the defaults are not ideal for their target environment, whereas
20774 rebuilding the runtime libraries is usually not as easy or desirable.
20776 Unlike @code{TFLAGS}, the use of specs enables different flags to be
20777 selected for different multilibs. The way to accomplish that is to
20778 build with @samp{make TFLAGS=-fmultiflags}, after configuring
20779 @samp{--with-specs=%@{fmultiflags:...@}}.
20781 This option is discarded by the driver once it's done processing driver
20784 It is also useful to check that @code{TFLAGS} are being used to build
20785 all target libraries, by configuring a non-bootstrap compiler
20786 @samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
20787 the compiler and target libraries.
20789 @opindex fprofile-report
20790 @item -fprofile-report
20791 Makes the compiler print some statistics about consistency of the
20792 (estimated) profile and effect of individual passes.
20794 @opindex fstack-usage
20795 @item -fstack-usage
20796 Makes the compiler output stack usage information for the program, on a
20797 per-function basis. The filename for the dump is made by appending
20798 @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
20799 the output file, if explicitly specified and it is not an executable,
20800 otherwise it is the basename of the source file. An entry is made up
20805 The name of the function.
20809 One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
20812 The qualifier @code{static} means that the function manipulates the stack
20813 statically: a fixed number of bytes are allocated for the frame on function
20814 entry and released on function exit; no stack adjustments are otherwise made
20815 in the function. The second field is this fixed number of bytes.
20817 The qualifier @code{dynamic} means that the function manipulates the stack
20818 dynamically: in addition to the static allocation described above, stack
20819 adjustments are made in the body of the function, for example to push/pop
20820 arguments around function calls. If the qualifier @code{bounded} is also
20821 present, the amount of these adjustments is bounded at compile time and
20822 the second field is an upper bound of the total amount of stack used by
20823 the function. If it is not present, the amount of these adjustments is
20824 not bounded at compile time and the second field only represents the
20829 Emit statistics about front-end processing at the end of the compilation.
20830 This option is supported only by the C++ front end, and
20831 the information is generally only useful to the G++ development team.
20833 @opindex fdbg-cnt-list
20834 @item -fdbg-cnt-list
20835 Print the name and the counter upper bound for all debug counters.
20839 @item -fdbg-cnt=@var{counter-value-list}
20840 Set the internal debug counter lower and upper bound. @var{counter-value-list}
20841 is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
20842 [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
20843 the name of the counter and list of closed intervals.
20844 The @var{lower_bound} is optional and is zero
20845 initialized if not set.
20846 For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
20847 @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
20848 eleventh invocation.
20849 For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
20851 @opindex print-file-name
20852 @item -print-file-name=@var{library}
20853 Print the full absolute name of the library file @var{library} that
20854 would be used when linking---and don't do anything else. With this
20855 option, GCC does not compile or link anything; it just prints the
20858 @opindex print-multi-directory
20859 @item -print-multi-directory
20860 Print the directory name corresponding to the multilib selected by any
20861 other switches present in the command line. This directory is supposed
20862 to exist in @env{GCC_EXEC_PREFIX}.
20864 @opindex print-multi-lib
20865 @item -print-multi-lib
20866 Print the mapping from multilib directory names to compiler switches
20867 that enable them. The directory name is separated from the switches by
20868 @samp{;}, and each switch starts with an @samp{@@} instead of the
20869 @samp{-}, without spaces between multiple switches. This is supposed to
20870 ease shell processing.
20872 @opindex print-multi-os-directory
20873 @item -print-multi-os-directory
20874 Print the path to OS libraries for the selected
20875 multilib, relative to some @file{lib} subdirectory. If OS libraries are
20876 present in the @file{lib} subdirectory and no multilibs are used, this is
20877 usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
20878 sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
20879 @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
20880 subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
20882 @opindex print-multiarch
20883 @item -print-multiarch
20884 Print the path to OS libraries for the selected multiarch,
20885 relative to some @file{lib} subdirectory.
20887 @opindex print-prog-name
20888 @item -print-prog-name=@var{program}
20889 Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
20891 @opindex print-libgcc-file-name
20892 @item -print-libgcc-file-name
20893 Same as @option{-print-file-name=libgcc.a}.
20895 This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
20896 but you do want to link with @file{libgcc.a}. You can do:
20899 gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
20902 @opindex print-search-dirs
20903 @item -print-search-dirs
20904 Print the name of the configured installation directory and a list of
20905 program and library directories @command{gcc} searches---and don't do anything else.
20907 This is useful when @command{gcc} prints the error message
20908 @samp{installation problem, cannot exec cpp0: No such file or directory}.
20909 To resolve this you either need to put @file{cpp0} and the other compiler
20910 components where @command{gcc} expects to find them, or you can set the environment
20911 variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
20912 Don't forget the trailing @samp{/}.
20913 @xref{Environment Variables}.
20915 @opindex print-sysroot
20916 @item -print-sysroot
20917 Print the target sysroot directory that is used during
20918 compilation. This is the target sysroot specified either at configure
20919 time or using the @option{--sysroot} option, possibly with an extra
20920 suffix that depends on compilation options. If no target sysroot is
20921 specified, the option prints nothing.
20923 @opindex print-sysroot-headers-suffix
20924 @item -print-sysroot-headers-suffix
20925 Print the suffix added to the target sysroot when searching for
20926 headers, or give an error if the compiler is not configured with such
20927 a suffix---and don't do anything else.
20929 @opindex dumpmachine
20931 Print the compiler's target machine (for example,
20932 @samp{i686-pc-linux-gnu})---and don't do anything else.
20934 @opindex dumpversion
20936 Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
20937 anything else. This is the compiler version used in filesystem paths and
20938 specs. Depending on how the compiler has been configured it can be just
20939 a single number (major version), two numbers separated by a dot (major and
20940 minor version) or three numbers separated by dots (major, minor and patchlevel
20943 @opindex dumpfullversion
20944 @item -dumpfullversion
20945 Print the full compiler version---and don't do anything else. The output is
20946 always three numbers separated by dots, major, minor and patchlevel version.
20950 Print the compiler's built-in specs---and don't do anything else. (This
20951 is used when GCC itself is being built.) @xref{Spec Files}.
20954 @node Submodel Options
20955 @section Machine-Dependent Options
20956 @cindex submodel options
20957 @cindex specifying hardware config
20958 @cindex hardware models and configurations, specifying
20959 @cindex target-dependent options
20960 @cindex machine-dependent options
20962 Each target machine supported by GCC can have its own options---for
20963 example, to allow you to compile for a particular processor variant or
20964 ABI, or to control optimizations specific to that machine. By
20965 convention, the names of machine-specific options start with
20968 Some configurations of the compiler also support additional target-specific
20969 options, usually for compatibility with other compilers on the same
20972 @c This list is ordered alphanumerically by subsection name.
20973 @c It should be the same order and spelling as these options are listed
20974 @c in Machine Dependent Options
20977 * AArch64 Options::
20978 * Adapteva Epiphany Options::
20979 * AMD GCN Options::
20983 * Blackfin Options::
20988 * DEC Alpha Options::
20993 * GNU/Linux Options::
20998 * LoongArch Options::
21003 * MicroBlaze Options::
21006 * MN10300 Options::
21010 * Nios II Options::
21011 * Nvidia PTX Options::
21012 * OpenRISC Options::
21014 * PowerPC Options::
21018 * RS/6000 and PowerPC Options::
21020 * S/390 and zSeries Options::
21022 * Solaris 2 Options::
21024 * System V Options::
21029 * VxWorks Options::
21031 * x86 Windows Options::
21032 * Xstormy16 Options::
21034 * zSeries Options::
21037 @node AArch64 Options
21038 @subsection AArch64 Options
21039 @cindex AArch64 Options
21041 These options are defined for AArch64 implementations:
21046 @item -mabi=@var{name}
21047 Generate code for the specified data model. Permissible values
21048 are @samp{ilp32} for SysV-like data model where int, long int and pointers
21049 are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
21050 but long int and pointers are 64 bits.
21052 The default depends on the specific target configuration. Note that
21053 the LP64 and ILP32 ABIs are not link-compatible; you must compile your
21054 entire program with the same ABI, and link with a compatible set of libraries.
21056 @opindex mbig-endian
21058 Generate big-endian code. This is the default when GCC is configured for an
21059 @samp{aarch64_be-*-*} target.
21061 @opindex mgeneral-regs-only
21062 @item -mgeneral-regs-only
21063 Generate code which uses only the general-purpose registers. This will prevent
21064 the compiler from using floating-point and Advanced SIMD registers but will not
21065 impose any restrictions on the assembler.
21067 @opindex mlittle-endian
21068 @item -mlittle-endian
21069 Generate little-endian code. This is the default when GCC is configured for an
21070 @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
21072 @opindex mcmodel=tiny
21073 @item -mcmodel=tiny
21074 Generate code for the tiny code model. The program and its statically defined
21075 symbols must be within 1MB of each other. Programs can be statically or
21076 dynamically linked.
21078 @opindex mcmodel=small
21079 @item -mcmodel=small
21080 Generate code for the small code model. The program and its statically defined
21081 symbols must be within 4GB of each other. Programs can be statically or
21082 dynamically linked. This is the default code model.
21084 @opindex mcmodel=large
21085 @item -mcmodel=large
21086 Generate code for the large code model. This makes no assumptions about
21087 addresses and sizes of sections. Programs can be statically linked only. The
21088 @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
21089 @option{-fpic} and @option{-fPIC}.
21091 @item -mtp=@var{name}
21093 Specify the system register to use as a thread pointer. The valid values
21094 are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2},
21095 @samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0},
21096 @samp{el1}, @samp{el2}, @samp{el3} are also accepted.
21097 The default setting is @samp{tpidr_el0}. It is recommended to compile all
21098 code intended to interoperate with the same value of this option to avoid
21099 accessing a different thread pointer from the wrong exception level.
21101 @opindex mstrict-align
21102 @opindex mno-strict-align
21103 @item -mstrict-align
21104 @itemx -mno-strict-align
21105 Avoid or allow generating memory accesses that may not be aligned on a natural
21106 object boundary as described in the architecture specification.
21108 @opindex momit-leaf-frame-pointer
21109 @opindex mno-omit-leaf-frame-pointer
21110 @item -momit-leaf-frame-pointer
21111 @itemx -mno-omit-leaf-frame-pointer
21112 Omit or keep the frame pointer in leaf functions. The former behavior is the
21115 @opindex mstack-protector-guard
21116 @opindex mstack-protector-guard-reg
21117 @opindex mstack-protector-guard-offset
21118 @item -mstack-protector-guard=@var{guard}
21119 @itemx -mstack-protector-guard-reg=@var{reg}
21120 @itemx -mstack-protector-guard-offset=@var{offset}
21121 Generate stack protection code using canary at @var{guard}. Supported
21122 locations are @samp{global} for a global canary or @samp{sysreg} for a
21123 canary in an appropriate system register.
21125 With the latter choice the options
21126 @option{-mstack-protector-guard-reg=@var{reg}} and
21127 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
21128 which system register to use as base register for reading the canary,
21129 and from what offset from that base register. There is no default
21130 register or offset as this is entirely for use within the Linux
21133 @opindex mtls-dialect=desc
21134 @item -mtls-dialect=desc
21135 Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
21136 of TLS variables. This is the default.
21138 @opindex mtls-dialect=traditional
21139 @item -mtls-dialect=traditional
21140 Use traditional TLS as the thread-local storage mechanism for dynamic accesses
21144 @item -mtls-size=@var{size}
21145 Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
21146 This option requires binutils 2.26 or newer.
21148 @opindex mfix-cortex-a53-835769
21149 @opindex mno-fix-cortex-a53-835769
21150 @item -mfix-cortex-a53-835769
21151 @itemx -mno-fix-cortex-a53-835769
21152 Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
21153 This involves inserting a NOP instruction between memory instructions and
21154 64-bit integer multiply-accumulate instructions.
21156 @opindex mfix-cortex-a53-843419
21157 @opindex mno-fix-cortex-a53-843419
21158 @item -mfix-cortex-a53-843419
21159 @itemx -mno-fix-cortex-a53-843419
21160 Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
21161 This erratum workaround is made at link time and this will only pass the
21162 corresponding flag to the linker.
21164 @opindex mlow-precision-recip-sqrt
21165 @opindex mno-low-precision-recip-sqrt
21166 @item -mlow-precision-recip-sqrt
21167 @itemx -mno-low-precision-recip-sqrt
21168 Enable or disable the reciprocal square root approximation.
21169 This option only has an effect if @option{-ffast-math} or
21170 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
21171 precision of reciprocal square root results to about 16 bits for
21172 single precision and to 32 bits for double precision.
21174 @opindex mlow-precision-sqrt
21175 @opindex mno-low-precision-sqrt
21176 @item -mlow-precision-sqrt
21177 @itemx -mno-low-precision-sqrt
21178 Enable or disable the square root approximation.
21179 This option only has an effect if @option{-ffast-math} or
21180 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
21181 precision of square root results to about 16 bits for
21182 single precision and to 32 bits for double precision.
21183 If enabled, it implies @option{-mlow-precision-recip-sqrt}.
21185 @opindex mlow-precision-div
21186 @opindex mno-low-precision-div
21187 @item -mlow-precision-div
21188 @itemx -mno-low-precision-div
21189 Enable or disable the division approximation.
21190 This option only has an effect if @option{-ffast-math} or
21191 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
21192 precision of division results to about 16 bits for
21193 single precision and to 32 bits for double precision.
21195 @item -mtrack-speculation
21196 @itemx -mno-track-speculation
21197 Enable or disable generation of additional code to track speculative
21198 execution through conditional branches. The tracking state can then
21199 be used by the compiler when expanding calls to
21200 @code{__builtin_speculation_safe_copy} to permit a more efficient code
21201 sequence to be generated.
21203 @item -moutline-atomics
21204 @itemx -mno-outline-atomics
21205 Enable or disable calls to out-of-line helpers to implement atomic operations.
21206 These helpers will, at runtime, determine if the LSE instructions from
21207 ARMv8.1-A can be used; if not, they will use the load/store-exclusive
21208 instructions that are present in the base ARMv8.0 ISA.
21210 This option is only applicable when compiling for the base ARMv8.0
21211 instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
21212 or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
21213 used directly. The same applies when using @option{-mcpu=} when the
21214 selected cpu supports the @samp{lse} feature.
21215 This option is on by default.
21218 @item -march=@var{name}
21219 Specify the name of the target architecture and, optionally, one or
21220 more feature modifiers. This option has the form
21221 @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
21223 The table below summarizes the permissible values for @var{arch}
21224 and the features that they enable by default:
21226 @multitable @columnfractions 0.20 0.20 0.60
21227 @headitem @var{arch} value @tab Architecture @tab Includes by default
21228 @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
21229 @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
21230 @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
21231 @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
21232 @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
21233 @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
21234 @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
21235 @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
21236 @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
21237 @item @samp{armv8.9-a} @tab Armv8.9-a @tab @samp{armv8.8-a}
21238 @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
21239 @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
21240 @item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
21241 @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
21242 @item @samp{armv9.4-a} @tab Armv9.4-A @tab @samp{armv9.3-a}
21243 @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
21246 The value @samp{native} is available on native AArch64 GNU/Linux and
21247 causes the compiler to pick the architecture of the host system. This
21248 option has no effect if the compiler is unable to recognize the
21249 architecture of the host system,
21251 The permissible values for @var{feature} are listed in the sub-section
21252 on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
21253 Feature Modifiers}. Where conflicting feature modifiers are
21254 specified, the right-most feature is used.
21256 GCC uses @var{name} to determine what kind of instructions it can emit
21257 when generating assembly code. If @option{-march} is specified
21258 without either of @option{-mtune} or @option{-mcpu} also being
21259 specified, the code is tuned to perform well across a range of target
21260 processors implementing the target architecture.
21263 @item -mtune=@var{name}
21264 Specify the name of the target processor for which GCC should tune the
21265 performance of the code. Permissible values for this option are:
21266 @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
21267 @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
21268 @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
21269 @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
21270 @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
21271 @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
21272 @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
21273 @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
21274 @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
21275 @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
21276 @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
21277 @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
21278 @samp{octeontx2f95mm},
21280 @samp{thunderx}, @samp{thunderxt88},
21281 @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
21282 @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
21283 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
21284 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
21285 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
21286 @samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
21287 @samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510}, @samp{cortex-a520},
21288 @samp{cortex-a710}, @samp{cortex-a715}, @samp{cortex-a720}, @samp{ampere1},
21289 @samp{ampere1a}, @samp{ampere1b}, @samp{cobalt-100} and @samp{native}.
21291 The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
21292 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
21293 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
21294 should tune for a big.LITTLE system.
21296 The value @samp{neoverse-512tvb} specifies that GCC should tune
21297 for Neoverse cores that (a) implement SVE and (b) have a total vector
21298 bandwidth of 512 bits per cycle. In other words, the option tells GCC to
21299 tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
21300 instructions a cycle and that can execute an equivalent number of SVE
21301 arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
21302 This is more general than tuning for a specific core like Neoverse V1
21303 but is more specific than the default tuning described below.
21305 Additionally on native AArch64 GNU/Linux systems the value
21306 @samp{native} tunes performance to the host system. This option has no effect
21307 if the compiler is unable to recognize the processor of the host system.
21309 Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
21310 are specified, the code is tuned to perform well across a range
21311 of target processors.
21313 This option cannot be suffixed by feature modifiers.
21316 @item -mcpu=@var{name}
21317 Specify the name of the target processor, optionally suffixed by one
21318 or more feature modifiers. This option has the form
21319 @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
21320 the permissible values for @var{cpu} are the same as those available
21321 for @option{-mtune}. The permissible values for @var{feature} are
21322 documented in the sub-section on
21323 @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
21324 Feature Modifiers}. Where conflicting feature modifiers are
21325 specified, the right-most feature is used.
21327 GCC uses @var{name} to determine what kind of instructions it can emit when
21328 generating assembly code (as if by @option{-march}) and to determine
21329 the target processor for which to tune for performance (as if
21330 by @option{-mtune}). Where this option is used in conjunction
21331 with @option{-march} or @option{-mtune}, those options take precedence
21332 over the appropriate part of this option.
21334 @option{-mcpu=neoverse-512tvb} is special in that it does not refer
21335 to a specific core, but instead refers to all Neoverse cores that
21336 (a) implement SVE and (b) have a total vector bandwidth of 512 bits
21337 a cycle. Unless overridden by @option{-march},
21338 @option{-mcpu=neoverse-512tvb} generates code that can run on a
21339 Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
21340 these properties. Unless overridden by @option{-mtune},
21341 @option{-mcpu=neoverse-512tvb} tunes code in the same way as for
21342 @option{-mtune=neoverse-512tvb}.
21345 @item -moverride=@var{string}
21346 Override tuning decisions made by the back-end in response to a
21347 @option{-mtune=} switch. The syntax, semantics, and accepted values
21348 for @var{string} in this option are not guaranteed to be consistent
21351 This option is only intended to be useful when developing GCC.
21353 @opindex mverbose-cost-dump
21354 @item -mverbose-cost-dump
21355 Enable verbose cost model dumping in the debug dump files. This option is
21356 provided for use in debugging the compiler.
21358 @opindex mpc-relative-literal-loads
21359 @opindex mno-pc-relative-literal-loads
21360 @item -mpc-relative-literal-loads
21361 @itemx -mno-pc-relative-literal-loads
21362 Enable or disable PC-relative literal loads. With this option literal pools are
21363 accessed using a single instruction and emitted after each function. This
21364 limits the maximum size of functions to 1MB. This is enabled by default for
21365 @option{-mcmodel=tiny}.
21367 @opindex msign-return-address
21368 @item -msign-return-address=@var{scope}
21369 Select the function scope on which return address signing will be applied.
21370 Permissible values are @samp{none}, which disables return address signing,
21371 @samp{non-leaf}, which enables pointer signing for functions which are not leaf
21372 functions, and @samp{all}, which enables pointer signing for all functions. The
21373 default value is @samp{none}. This option has been deprecated by
21374 -mbranch-protection.
21376 @opindex mbranch-protection
21377 @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
21378 Select the branch protection features to use.
21379 @samp{none} is the default and turns off all types of branch protection.
21380 @samp{standard} turns on all types of branch protection features. If a feature
21381 has additional tuning options, then @samp{standard} sets it to its standard
21383 @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
21384 level: signing functions that save the return address to memory (non-leaf
21385 functions will practically always do this) using the a-key. The optional
21386 argument @samp{leaf} can be used to extend the signing to include leaf
21387 functions. The optional argument @samp{b-key} can be used to sign the functions
21388 with the B-key instead of the A-key.
21389 @samp{bti} turns on branch target identification mechanism.
21391 @opindex mharden-sls
21392 @item -mharden-sls=@var{opts}
21393 Enable compiler hardening against straight line speculation (SLS).
21394 @var{opts} is a comma-separated list of the following options:
21399 In addition, @samp{-mharden-sls=all} enables all SLS hardening while
21400 @samp{-mharden-sls=none} disables all SLS hardening.
21403 @item -mearly-ra=@var{scope}
21404 Determine when to enable an early register allocation pass. This pass runs
21405 before instruction scheduling and tries to find a spill-free allocation of
21406 floating-point and vector code. It also tries to make use of strided
21407 multi-register instructions, such as SME2's strided LD1 and ST1.
21409 The possible values of @var{scope} are: @var{all}, which runs the pass on
21410 all functions; @var{strided}, which runs the pass on functions that have
21411 access to strided multi-register instructions; and @var{none}, which
21414 @option{-mearly-ra=all} is the default for @option{-O2} and above, and for
21415 @option{-Os}. @option{-mearly-ra=none} is the default otherwise.
21417 @opindex mearly-ldp-fusion
21418 @item -mearly-ldp-fusion
21419 Enable the copy of the AArch64 load/store pair fusion pass that runs before
21420 register allocation. Enabled by default at @samp{-O} and above.
21422 @opindex mlate-ldp-fusion
21423 @item -mlate-ldp-fusion
21424 Enable the copy of the AArch64 load/store pair fusion pass that runs after
21425 register allocation. Enabled by default at @samp{-O} and above.
21427 @opindex msve-vector-bits
21428 @item -msve-vector-bits=@var{bits}
21429 Specify the number of bits in an SVE vector register. This option only has
21430 an effect when SVE is enabled.
21432 GCC supports two forms of SVE code generation: ``vector-length
21433 agnostic'' output that works with any size of vector register and
21434 ``vector-length specific'' output that allows GCC to make assumptions
21435 about the vector length when it is useful for optimization reasons.
21436 The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
21437 @samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
21438 Specifying @samp{scalable} selects vector-length agnostic
21439 output. At present @samp{-msve-vector-bits=128} also generates vector-length
21440 agnostic output for big-endian targets. All other values generate
21441 vector-length specific code. The behavior of these values may change
21442 in future releases and no value except @samp{scalable} should be
21443 relied on for producing code that is portable across different
21444 hardware SVE vector lengths.
21446 The default is @samp{-msve-vector-bits=scalable}, which produces
21447 vector-length agnostic code.
21450 @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
21451 @anchor{aarch64-feature-modifiers}
21452 @cindex @option{-march} feature modifiers
21453 @cindex @option{-mcpu} feature modifiers
21454 Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
21455 the following and their inverses @option{no@var{feature}}:
21459 Enable CRC extension. This is on by default for
21460 @option{-march=armv8.1-a}.
21462 Enable Crypto extension. This also enables Advanced SIMD and floating-point
21465 Enable floating-point instructions. This is on by default for all possible
21466 values for options @option{-march} and @option{-mcpu}.
21468 Enable Advanced SIMD instructions. This also enables floating-point
21469 instructions. This is on by default for all possible values for options
21470 @option{-march} and @option{-mcpu}.
21472 Enable Scalable Vector Extension instructions. This also enables Advanced
21473 SIMD and floating-point instructions.
21475 Enable Large System Extension instructions. This is on by default for
21476 @option{-march=armv8.1-a}.
21478 Enable Round Double Multiply Accumulate instructions. This is on by default
21479 for @option{-march=armv8.1-a}.
21481 Enable FP16 extension. This also enables floating-point instructions.
21483 Enable FP16 fmla extension. This also enables FP16 extensions and
21484 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.
21487 Enable the RCpc extension. This enables the use of the LDAPR instructions for
21488 load-acquire atomic semantics, and passes it on to the assembler, enabling
21489 inline asm statements to use instructions from the RCpc extension.
21491 Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21493 Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
21496 Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
21498 Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
21499 instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
21501 Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
21502 Use of this option with architectures prior to Armv8.2-A is not supported.
21504 Enable the Statistical Profiling extension. This option is only to enable the
21505 extension at the assembler level and does not affect code generation.
21507 Enable the Armv8.5-a Random Number instructions. This option is only to
21508 enable the extension at the assembler level and does not affect code
21511 Enable the Armv8.5-a Memory Tagging Extensions.
21512 Use of this option with architectures prior to Armv8.5-A is not supported.
21514 Enable the Armv8-a Speculation Barrier instruction. This option is only to
21515 enable the extension at the assembler level and does not affect code
21516 generation. This option is enabled by default for @option{-march=armv8.5-a}.
21518 Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
21519 is only to enable the extension at the assembler level and does not affect code
21520 generation. This option is enabled by default for @option{-march=armv8.5-a}.
21522 Enable the Armv8-a Execution and Data Prediction Restriction instructions.
21523 This option is only to enable the extension at the assembler level and does
21524 not affect code generation. This option is enabled by default for
21525 @option{-march=armv8.5-a}.
21527 Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
21530 Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
21532 Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
21534 Enable SVE2 aes instructions. This also enables SVE2 instructions.
21536 Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
21538 Enable the Transactional Memory Extension.
21540 Enable 8-bit Integer Matrix Multiply instructions. This also enables
21541 Advanced SIMD and floating-point instructions. This option is enabled by
21542 default for @option{-march=armv8.6-a}. Use of this option with architectures
21543 prior to Armv8.2-A is not supported.
21545 Enable 32-bit Floating point Matrix Multiply instructions. This also enables
21546 SVE instructions. Use of this option with architectures prior to Armv8.2-A is
21549 Enable 64-bit Floating point Matrix Multiply instructions. This also enables
21550 SVE instructions. Use of this option with architectures prior to Armv8.2-A is
21553 Enable brain half-precision floating-point instructions. This also enables
21554 Advanced SIMD and floating-point instructions. This option is enabled by
21555 default for @option{-march=armv8.6-a}. Use of this option with architectures
21556 prior to Armv8.2-A is not supported.
21558 Enable the 64-byte atomic load and store instructions for accelerators.
21559 This option is enabled by default for @option{-march=armv8.7-a}.
21561 Enable the instructions to accelerate memory operations like @code{memcpy},
21562 @code{memmove}, @code{memset}. This option is enabled by default for
21563 @option{-march=armv8.8-a}
21565 Enable the Flag Manipulation instructions Extension.
21567 Enable the Pointer Authentication Extension.
21569 Enable the Common Short Sequence Compression instructions.
21571 Enable the Scalable Matrix Extension.
21573 Enable the FEAT_SME_I16I64 extension to SME.
21575 Enable the FEAT_SME_F64F64 extension to SME.
21577 Enable the Scalable Matrix Extension 2. This also enables SME instructions.
21579 Enable support for 128-bit system register read/write instructions.
21581 Enable support for Armv9.4-a Guarded Control Stack extension.
21583 Enable support for Armv8.9-a/9.4-a translation hardening extension.
21585 Enable the RCpc3 (Release Consistency) extension.
21589 Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
21590 which implies @option{fp}.
21591 Conversely, @option{nofp} implies @option{nosimd}, which implies
21592 @option{nocrypto}, @option{noaes} and @option{nosha2}.
21594 @node Adapteva Epiphany Options
21595 @subsection Adapteva Epiphany Options
21597 These @samp{-m} options are defined for Adapteva Epiphany:
21600 @opindex mhalf-reg-file
21601 @item -mhalf-reg-file
21602 Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
21603 That allows code to run on hardware variants that lack these registers.
21605 @opindex mprefer-short-insn-regs
21606 @item -mprefer-short-insn-regs
21607 Preferentially allocate registers that allow short instruction generation.
21608 This can result in increased instruction count, so this may either reduce or
21609 increase overall code size.
21611 @opindex mbranch-cost
21612 @item -mbranch-cost=@var{num}
21613 Set the cost of branches to roughly @var{num} ``simple'' instructions.
21614 This cost is only a heuristic and is not guaranteed to produce
21615 consistent results across releases.
21619 Enable the generation of conditional moves.
21622 @item -mnops=@var{num}
21623 Emit @var{num} NOPs before every other generated instruction.
21625 @opindex mno-soft-cmpsf
21626 @opindex msoft-cmpsf
21627 @item -mno-soft-cmpsf
21628 For single-precision floating-point comparisons, emit an @code{fsub} instruction
21629 and test the flags. This is faster than a software comparison, but can
21630 get incorrect results in the presence of NaNs, or when two different small
21631 numbers are compared such that their difference is calculated as zero.
21632 The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
21633 software comparisons.
21635 @opindex mstack-offset
21636 @item -mstack-offset=@var{num}
21637 Set the offset between the top of the stack and the stack pointer.
21638 E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
21639 can be used by leaf functions without stack allocation.
21640 Values other than @samp{8} or @samp{16} are untested and unlikely to work.
21641 Note also that this option changes the ABI; compiling a program with a
21642 different stack offset than the libraries have been compiled with
21643 generally does not work.
21644 This option can be useful if you want to evaluate if a different stack
21645 offset would give you better code, but to actually use a different stack
21646 offset to build working programs, it is recommended to configure the
21647 toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
21649 @opindex mno-round-nearest
21650 @opindex mround-nearest
21651 @item -mno-round-nearest
21652 Make the scheduler assume that the rounding mode has been set to
21653 truncating. The default is @option{-mround-nearest}.
21655 @opindex mlong-calls
21657 If not otherwise specified by an attribute, assume all calls might be beyond
21658 the offset range of the @code{b} / @code{bl} instructions, and therefore load the
21659 function address into a register before performing a (otherwise direct) call.
21660 This is the default.
21662 @opindex short-calls
21663 @item -mshort-calls
21664 If not otherwise specified by an attribute, assume all direct calls are
21665 in the range of the @code{b} / @code{bl} instructions, so use these instructions
21666 for direct calls. The default is @option{-mlong-calls}.
21670 Assume addresses can be loaded as 16-bit unsigned values. This does not
21671 apply to function addresses for which @option{-mlong-calls} semantics
21675 @item -mfp-mode=@var{mode}
21676 Set the prevailing mode of the floating-point unit.
21677 This determines the floating-point mode that is provided and expected
21678 at function call and return time. Making this mode match the mode you
21679 predominantly need at function start can make your programs smaller and
21680 faster by avoiding unnecessary mode switches.
21682 @var{mode} can be set to one the following values:
21686 Any mode at function entry is valid, and retained or restored when
21687 the function returns, and when it calls other functions.
21688 This mode is useful for compiling libraries or other compilation units
21689 you might want to incorporate into different programs with different
21690 prevailing FPU modes, and the convenience of being able to use a single
21691 object file outweighs the size and speed overhead for any extra
21692 mode switching that might be needed, compared with what would be needed
21693 with a more specific choice of prevailing FPU mode.
21696 This is the mode used for floating-point calculations with
21697 truncating (i.e.@: round towards zero) rounding mode. That includes
21698 conversion from floating point to integer.
21700 @item round-nearest
21701 This is the mode used for floating-point calculations with
21702 round-to-nearest-or-even rounding mode.
21705 This is the mode used to perform integer calculations in the FPU, e.g.@:
21706 integer multiply, or integer multiply-and-accumulate.
21709 The default is @option{-mfp-mode=caller}
21711 @opindex mno-split-lohi
21712 @opindex msplit-lohi
21713 @opindex mno-postinc
21715 @opindex mno-postmodify
21716 @opindex mpostmodify
21717 @item -mno-split-lohi
21718 @itemx -mno-postinc
21719 @itemx -mno-postmodify
21720 Code generation tweaks that disable, respectively, splitting of 32-bit
21721 loads, generation of post-increment addresses, and generation of
21722 post-modify addresses. The defaults are @option{msplit-lohi},
21723 @option{-mpost-inc}, and @option{-mpost-modify}.
21725 @opindex mno-vect-double
21726 @opindex mvect-double
21727 @item -mnovect-double
21728 Change the preferred SIMD mode to SImode. The default is
21729 @option{-mvect-double}, which uses DImode as preferred SIMD mode.
21731 @opindex max-vect-align
21732 @item -max-vect-align=@var{num}
21733 The maximum alignment for SIMD vector mode types.
21734 @var{num} may be 4 or 8. The default is 8.
21735 Note that this is an ABI change, even though many library function
21736 interfaces are unaffected if they don't use SIMD vector modes
21737 in places that affect size and/or alignment of relevant types.
21739 @opindex msplit-vecmove-early
21740 @item -msplit-vecmove-early
21741 Split vector moves into single word moves before reload. In theory this
21742 can give better register allocation, but so far the reverse seems to be
21743 generally the case.
21746 @item -m1reg-@var{reg}
21747 Specify a register to hold the constant @minus{}1, which makes loading small negative
21748 constants and certain bitmasks faster.
21749 Allowable values for @var{reg} are @samp{r43} and @samp{r63},
21750 which specify use of that register as a fixed register,
21751 and @samp{none}, which means that no register is used for this
21752 purpose. The default is @option{-m1reg-none}.
21756 @node AMD GCN Options
21757 @subsection AMD GCN Options
21758 @cindex AMD GCN Options
21760 These options are defined specifically for the AMD GCN port.
21766 @item -march=@var{gpu}
21767 @itemx -mtune=@var{gpu}
21768 Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
21773 Compile for GCN3 Fiji devices (gfx803). Support deprecated; availablility
21774 depends on how GCC has been configured, see @option{--with-arch} and
21775 @option{--with-multilib-list}.
21778 Compile for GCN5 Vega 10 devices (gfx900).
21781 Compile for GCN5 Vega 20 devices (gfx906).
21784 Compile for CDNA1 Instinct MI100 series devices (gfx908).
21787 Compile for CDNA2 Instinct MI200 series devices (gfx90a).
21790 Compile for RDNA2 gfx1030 devices (GFX10 series).
21793 Compile for RDNA3 gfx1100 devices (GFX11 series).
21798 @item -msram-ecc=on
21799 @itemx -msram-ecc=off
21800 @itemx -msram-ecc=any
21801 Compile binaries suitable for devices with the SRAM-ECC feature enabled,
21802 disabled, or either mode. This feature can be enabled per-process on some
21803 devices. The compiled code must match the device mode. The default is
21804 @samp{any}, for devices that support it.
21806 @opindex mstack-size
21807 @item -mstack-size=@var{bytes}
21808 Specify how many @var{bytes} of stack space will be requested for each GPU
21809 thread (wave-front). Beware that there may be many threads and limited memory
21810 available. The size of the stack allocation may also have an impact on
21811 run-time performance. The default is 32KB when using OpenACC or OpenMP, and
21818 Compile binaries suitable for devices with the XNACK feature enabled, disabled,
21819 or either mode. Some devices always require XNACK and some allow the user to
21820 configure XNACK. The compiled code must match the device mode.
21821 The default is @samp{-mxnack=any} on devices that support Unified Shared
21822 Memory, and @samp{-mxnack=no} otherwise.
21827 @subsection ARC Options
21828 @cindex ARC options
21830 The following options control the architecture variant for which code
21833 @c architecture variants
21836 @opindex mbarrel-shifter
21837 @item -mbarrel-shifter
21838 Generate instructions supported by barrel shifter. This is the default
21839 unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
21841 @opindex mjli-always
21843 Force to call a function using jli_s instruction. This option is
21844 valid only for ARCv2 architecture.
21847 @item -mcpu=@var{cpu}
21848 Set architecture type, register usage, and instruction scheduling
21849 parameters for @var{cpu}. There are also shortcut alias options
21850 available for backward compatibility and convenience. Supported
21851 values for @var{cpu} are
21857 Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
21861 Compile for ARC601. Alias: @option{-mARC601}.
21866 Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
21867 This is the default when configured with @option{--with-cpu=arc700}@.
21870 Compile for ARC EM.
21873 Compile for ARC HS.
21876 Compile for ARC EM CPU with no hardware extensions.
21879 Compile for ARC EM4 CPU.
21882 Compile for ARC EM4 DMIPS CPU.
21885 Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
21889 Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
21890 double assist instructions.
21893 Compile for ARC HS CPU with no hardware extensions except the atomic
21897 Compile for ARC HS34 CPU.
21900 Compile for ARC HS38 CPU.
21903 Compile for ARC HS38 CPU with all hardware extensions on.
21906 Compile for ARC HS4x CPU.
21909 Compile for ARC HS4xD CPU.
21912 Compile for ARC HS4x CPU release 3.10a.
21915 Compile for ARC 600 CPU with @code{norm} instructions enabled.
21917 @item arc600_mul32x16
21918 Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
21919 instructions enabled.
21922 Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
21923 instructions enabled.
21926 Compile for ARC 601 CPU with @code{norm} instructions enabled.
21928 @item arc601_mul32x16
21929 Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
21930 instructions enabled.
21933 Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
21934 instructions enabled.
21937 Compile for ARC 700 on NPS400 chip.
21940 Compile for ARC EM minimalist configuration featuring reduced register
21946 @opindex mdpfp-compact
21948 @itemx -mdpfp-compact
21949 Generate double-precision FPX instructions, tuned for the compact
21952 @opindex mdpfp-fast
21954 Generate double-precision FPX instructions, tuned for the fast
21957 @opindex mno-dpfp-lrsr
21958 @item -mno-dpfp-lrsr
21959 Disable @code{lr} and @code{sr} instructions from using FPX extension
21964 Generate extended arithmetic instructions. Currently only
21965 @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
21966 supported. Only valid for @option{-mcpu=ARC700}.
21971 Do not generate @code{mpy}-family instructions for ARC700. This option is
21976 Generate 32x16-bit multiply and multiply-accumulate instructions.
21980 Generate @code{mul64} and @code{mulu64} instructions.
21981 Only valid for @option{-mcpu=ARC600}.
21985 Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
21989 @opindex mspfp-compact
21991 @itemx -mspfp-compact
21992 Generate single-precision FPX instructions, tuned for the compact
21995 @opindex mspfp-fast
21997 Generate single-precision FPX instructions, tuned for the fast
22002 Enable generation of ARC SIMD instructions via target-specific
22003 builtins. Only valid for @option{-mcpu=ARC700}.
22005 @opindex msoft-float
22007 This option ignored; it is provided for compatibility purposes only.
22008 Software floating-point code is emitted by default, and this default
22009 can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
22010 @option{-mspfp-fast} for single precision, and @option{-mdpfp},
22011 @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
22015 Generate @code{swap} instructions.
22019 This enables use of the locked load/store conditional extension to implement
22020 atomic memory built-in functions. Not available for ARC 6xx or ARC
22025 Enable @code{div} and @code{rem} instructions for ARCv2 cores.
22027 @opindex mcode-density
22028 @item -mcode-density
22029 Enable code density instructions for ARC EM.
22030 This option is on by default for ARC HS.
22034 Enable double load/store operations for ARC HS cores.
22037 @item -mtp-regno=@var{regno}
22038 Specify thread pointer register number.
22040 @opindex mmpy-option
22041 @item -mmpy-option=@var{multo}
22042 Compile ARCv2 code with a multiplier design option. You can specify
22043 the option using either a string or numeric value for @var{multo}.
22044 @samp{wlh1} is the default value. The recognized values are:
22049 No multiplier available.
22053 16x16 multiplier, fully pipelined.
22054 The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
22058 32x32 multiplier, fully
22059 pipelined (1 stage). The following instructions are additionally
22060 enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22064 32x32 multiplier, fully pipelined
22065 (2 stages). The following instructions are additionally enabled: @code{mpy},
22066 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22070 Two 16x16 multipliers, blocking,
22071 sequential. The following instructions are additionally enabled: @code{mpy},
22072 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22076 One 16x16 multiplier, blocking,
22077 sequential. The following instructions are additionally enabled: @code{mpy},
22078 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22082 One 32x4 multiplier, blocking,
22083 sequential. The following instructions are additionally enabled: @code{mpy},
22084 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22088 ARC HS SIMD support.
22092 ARC HS SIMD support.
22096 ARC HS SIMD support.
22100 This option is only available for ARCv2 cores@.
22103 @item -mfpu=@var{fpu}
22104 Enables support for specific floating-point hardware extensions for ARCv2
22105 cores. Supported values for @var{fpu} are:
22110 Enables support for single-precision floating-point hardware
22114 Enables support for double-precision floating-point hardware
22115 extensions. The single-precision floating-point extension is also
22116 enabled. Not available for ARC EM@.
22119 Enables support for double-precision floating-point hardware
22120 extensions using double-precision assist instructions. The single-precision
22121 floating-point extension is also enabled. This option is
22122 only available for ARC EM@.
22125 Enables support for double-precision floating-point hardware
22126 extensions using double-precision assist instructions.
22127 The single-precision floating-point, square-root, and divide
22128 extensions are also enabled. This option is
22129 only available for ARC EM@.
22132 Enables support for double-precision floating-point hardware
22133 extensions using double-precision assist instructions.
22134 The single-precision floating-point and fused multiply and add
22135 hardware extensions are also enabled. This option is
22136 only available for ARC EM@.
22139 Enables support for double-precision floating-point hardware
22140 extensions using double-precision assist instructions.
22141 All single-precision floating-point hardware extensions are also
22142 enabled. This option is only available for ARC EM@.
22145 Enables support for single-precision floating-point, square-root and divide
22146 hardware extensions@.
22149 Enables support for double-precision floating-point, square-root and divide
22150 hardware extensions. This option
22151 includes option @samp{fpus_div}. Not available for ARC EM@.
22154 Enables support for single-precision floating-point and
22155 fused multiply and add hardware extensions@.
22158 Enables support for double-precision floating-point and
22159 fused multiply and add hardware extensions. This option
22160 includes option @samp{fpus_fma}. Not available for ARC EM@.
22163 Enables support for all single-precision floating-point hardware
22167 Enables support for all single- and double-precision floating-point
22168 hardware extensions. Not available for ARC EM@.
22172 @opindex mirq-ctrl-saved
22173 @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
22174 Specifies general-purposes registers that the processor automatically
22175 saves/restores on interrupt entry and exit. @var{register-range} is
22176 specified as two registers separated by a dash. The register range
22177 always starts with @code{r0}, the upper limit is @code{fp} register.
22178 @var{blink} and @var{lp_count} are optional. This option is only
22179 valid for ARC EM and ARC HS cores.
22181 @opindex mrgf-banked-regs
22182 @item -mrgf-banked-regs=@var{number}
22183 Specifies the number of registers replicated in second register bank
22184 on entry to fast interrupt. Fast interrupts are interrupts with the
22185 highest priority level P0. These interrupts save only PC and STATUS32
22186 registers to avoid memory transactions during interrupt entry and exit
22187 sequences. Use this option when you are using fast interrupts in an
22188 ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
22190 @opindex mlpc-width
22191 @item -mlpc-width=@var{width}
22192 Specify the width of the @code{lp_count} register. Valid values for
22193 @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
22194 fixed to 32 bits. If the width is less than 32, the compiler does not
22195 attempt to transform loops in your program to use the zero-delay loop
22196 mechanism unless it is known that the @code{lp_count} register can
22197 hold the required loop-counter value. Depending on the width
22198 specified, the compiler and run-time library might continue to use the
22199 loop mechanism for various needs. This option defines macro
22200 @code{__ARC_LPC_WIDTH__} with the value of @var{width}.
22204 This option instructs the compiler to generate code for a 16-entry
22205 register file. This option defines the @code{__ARC_RF16__}
22206 preprocessor macro.
22208 @opindex mbranch-index
22209 @item -mbranch-index
22210 Enable use of @code{bi} or @code{bih} instructions to implement jump
22215 The following options are passed through to the assembler, and also
22216 define preprocessor macro symbols.
22218 @c Flags used by the assembler, but for which we define preprocessor
22219 @c macro symbols as well.
22221 @opindex mdsp-packa
22223 Passed down to the assembler to enable the DSP Pack A extensions.
22224 Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
22229 Passed down to the assembler to enable the dual Viterbi butterfly
22230 extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
22231 option is deprecated.
22233 @c ARC700 4.10 extension instruction
22236 Passed down to the assembler to enable the locked load/store
22237 conditional extension. Also sets the preprocessor symbol
22242 Passed down to the assembler. Also sets the preprocessor symbol
22243 @code{__Xxmac_d16}. This option is deprecated.
22247 Passed down to the assembler. Also sets the preprocessor symbol
22248 @code{__Xxmac_24}. This option is deprecated.
22250 @c ARC700 4.10 extension instruction
22253 Passed down to the assembler to enable the 64-bit time-stamp counter
22254 extension instruction. Also sets the preprocessor symbol
22255 @code{__Xrtsc}. This option is deprecated.
22257 @c ARC700 4.10 extension instruction
22260 Passed down to the assembler to enable the swap byte ordering
22261 extension instruction. Also sets the preprocessor symbol
22264 @opindex mtelephony
22266 Passed down to the assembler to enable dual- and single-operand
22267 instructions for telephony. Also sets the preprocessor symbol
22268 @code{__Xtelephony}. This option is deprecated.
22272 Passed down to the assembler to enable the XY memory extension. Also
22273 sets the preprocessor symbol @code{__Xxy}.
22277 The following options control how the assembly code is annotated:
22279 @c Assembly annotation options
22283 Annotate assembler instructions with estimated addresses.
22285 @opindex mannotate-align
22286 @item -mannotate-align
22287 Does nothing. Preserved for backward compatibility.
22291 The following options are passed through to the linker:
22293 @c options passed through to the linker
22297 Passed through to the linker, to specify use of the @code{arclinux} emulation.
22298 This option is enabled by default in tool chains built for
22299 @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
22300 when profiling is not requested.
22302 @opindex marclinux_prof
22303 @item -marclinux_prof
22304 Passed through to the linker, to specify use of the
22305 @code{arclinux_prof} emulation. This option is enabled by default in
22306 tool chains built for @w{@code{arc-linux-uclibc}} and
22307 @w{@code{arceb-linux-uclibc}} targets when profiling is requested.
22311 The following options control the semantics of generated code:
22313 @c semantically relevant code generation options
22315 @opindex mlong-calls
22317 Generate calls as register indirect calls, thus providing access
22318 to the full 32-bit address range.
22320 @opindex mmedium-calls
22321 @item -mmedium-calls
22322 Don't use less than 25-bit addressing range for calls, which is the
22323 offset available for an unconditional branch-and-link
22324 instruction. Conditional execution of function calls is suppressed, to
22325 allow use of the 25-bit range, rather than the 21-bit range with
22326 conditional branch-and-link. This is the default for tool chains built
22327 for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
22331 Put definitions of externally-visible data in a small data section if
22332 that data is no bigger than @var{num} bytes. The default value of
22333 @var{num} is 4 for any ARC configuration, or 8 when we have double
22334 load/store operations.
22339 Do not generate sdata references. This is the default for tool chains
22340 built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
22343 @opindex mvolatile-cache
22344 @item -mvolatile-cache
22345 Use ordinarily cached memory accesses for volatile references. This is the
22348 @opindex mno-volatile-cache
22349 @opindex mvolatile-cache
22350 @item -mno-volatile-cache
22351 Enable cache bypass for volatile references.
22355 The following options fine tune code generation:
22356 @c code generation tuning options
22358 @opindex malign-call
22360 Does nothing. Preserved for backward compatibility.
22362 @opindex mauto-modify-reg
22363 @item -mauto-modify-reg
22364 Enable the use of pre/post modify with register displacement.
22366 @opindex mbbit-peephole
22367 @item -mbbit-peephole
22368 Does nothing. Preserved for backward compatibility.
22372 This option disables a target-specific pass in @file{arc_reorg} to
22373 generate compare-and-branch (@code{br@var{cc}}) instructions.
22374 It has no effect on
22375 generation of these instructions driven by the combiner pass.
22377 @opindex mcase-vector-pcrel
22378 @item -mcase-vector-pcrel
22379 Use PC-relative switch case tables to enable case table shortening.
22380 This is the default for @option{-Os}.
22382 @opindex mcompact-casesi
22383 @item -mcompact-casesi
22384 Enable compact @code{casesi} pattern. This is the default for @option{-Os},
22385 and only available for ARCv1 cores. This option is deprecated.
22387 @opindex mno-cond-exec
22388 @item -mno-cond-exec
22389 Disable the ARCompact-specific pass to generate conditional
22390 execution instructions.
22392 Due to delay slot scheduling and interactions between operand numbers,
22393 literal sizes, instruction lengths, and the support for conditional execution,
22394 the target-independent pass to generate conditional execution is often lacking,
22395 so the ARC port has kept a special pass around that tries to find more
22396 conditional execution generation opportunities after register allocation,
22397 branch shortening, and delay slot scheduling have been done. This pass
22398 generally, but not always, improves performance and code size, at the cost of
22399 extra compilation time, which is why there is an option to switch it off.
22400 If you have a problem with call instructions exceeding their allowable
22401 offset range because they are conditionalized, you should consider using
22402 @option{-mmedium-calls} instead.
22404 @opindex mearly-cbranchsi
22405 @item -mearly-cbranchsi
22406 Enable pre-reload use of the @code{cbranchsi} pattern.
22408 @opindex mexpand-adddi
22409 @item -mexpand-adddi
22410 Expand @code{adddi3} and @code{subdi3} at RTL generation time into
22411 @code{add.f}, @code{adc} etc. This option is deprecated.
22413 @opindex mindexed-loads
22414 @item -mindexed-loads
22415 Enable the use of indexed loads. This can be problematic because some
22416 optimizers then assume that indexed stores exist, which is not
22421 Enable Local Register Allocation. This is still experimental for ARC,
22422 so by default the compiler uses standard reload
22423 (i.e.@: @option{-mno-lra}).
22425 @opindex mlra-priority-none
22426 @item -mlra-priority-none
22427 Don't indicate any priority for target registers.
22429 @opindex mlra-priority-compact
22430 @item -mlra-priority-compact
22431 Indicate target register priority for r0..r3 / r12..r15.
22433 @opindex mlra-priority-noncompact
22434 @item -mlra-priority-noncompact
22435 Reduce target register priority for r0..r3 / r12..r15.
22437 @opindex mmillicode
22439 When optimizing for size (using @option{-Os}), prologues and epilogues
22440 that have to save or restore a large number of registers are often
22441 shortened by using call to a special function in libgcc; this is
22442 referred to as a @emph{millicode} call. As these calls can pose
22443 performance issues, and/or cause linking issues when linking in a
22444 nonstandard way, this option is provided to turn on or off millicode
22447 @opindex mcode-density-frame
22448 @item -mcode-density-frame
22449 This option enable the compiler to emit @code{enter} and @code{leave}
22450 instructions. These instructions are only valid for CPUs with
22451 code-density feature.
22453 @opindex mmixed-code
22455 Does nothing. Preserved for backward compatibility.
22459 Ths option is deprecated. Enable @samp{q} instruction alternatives.
22460 This is the default for @option{-Os}.
22464 Does nothing. Preserved for backward compatibility.
22468 Does nothing. Preserved for backward compatibility.
22470 @opindex msize-level
22471 @item -msize-level=@var{level}
22472 Fine-tune size optimization with regards to instruction lengths and alignment.
22473 The recognized values for @var{level} are:
22476 No size optimization. This level is deprecated and treated like @samp{1}.
22479 Short instructions are used opportunistically.
22482 In addition, alignment of loops and of code after barriers are dropped.
22485 In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
22489 This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
22490 the behavior when this is not set is equivalent to level @samp{1}.
22493 @item -mtune=@var{cpu}
22494 Set instruction scheduling parameters for @var{cpu}, overriding any implied
22495 by @option{-mcpu=}.
22497 Supported values for @var{cpu} are
22501 Tune for ARC600 CPU.
22504 Tune for ARC601 CPU.
22507 Tune for ARC700 CPU with standard multiplier block.
22510 Tune for ARC700 CPU with XMAC block.
22513 Tune for ARC725D CPU.
22516 Tune for ARC750D CPU.
22519 Tune for ARCv2 core3 type CPU. This option enable usage of
22520 @code{dbnz} instruction.
22523 Tune for ARC4x release 3.10a.
22528 @item -mmultcost=@var{num}
22529 Cost to assume for a multiply instruction, with @samp{4} being equal to a
22530 normal instruction.
22532 @opindex munalign-prob-threshold
22533 @item -munalign-prob-threshold=@var{probability}
22534 Does nothing. Preserved for backward compatibility.
22538 The following options are maintained for backward compatibility, but
22539 are now deprecated and will be removed in a future release:
22541 @c Deprecated options
22548 @opindex mbig-endian
22552 Compile code for big-endian targets. Use of these options is now
22553 deprecated. Big-endian code is supported by configuring GCC to build
22554 @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
22555 for which big endian is the default.
22557 @opindex mlittle-endian
22559 @item -mlittle-endian
22561 Compile code for little-endian targets. Use of these options is now
22562 deprecated. Little-endian code is supported by configuring GCC to build
22563 @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
22564 for which little endian is the default.
22566 @opindex mbarrel_shifter
22567 @item -mbarrel_shifter
22568 Replaced by @option{-mbarrel-shifter}.
22570 @opindex mdpfp_compact
22571 @item -mdpfp_compact
22572 Replaced by @option{-mdpfp-compact}.
22574 @opindex mdpfp_fast
22576 Replaced by @option{-mdpfp-fast}.
22578 @opindex mdsp_packa
22580 Replaced by @option{-mdsp-packa}.
22584 Replaced by @option{-mea}.
22588 Replaced by @option{-mmac-24}.
22592 Replaced by @option{-mmac-d16}.
22594 @opindex mspfp_compact
22595 @item -mspfp_compact
22596 Replaced by @option{-mspfp-compact}.
22598 @opindex mspfp_fast
22600 Replaced by @option{-mspfp-fast}.
22603 @item -mtune=@var{cpu}
22604 Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
22605 @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
22606 @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
22609 @item -multcost=@var{num}
22610 Replaced by @option{-mmultcost}.
22615 @subsection ARM Options
22616 @cindex ARM options
22618 These @samp{-m} options are defined for the ARM port:
22622 @item -mabi=@var{name}
22623 Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
22624 @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
22626 @opindex mapcs-frame
22628 Generate a stack frame that is compliant with the ARM Procedure Call
22629 Standard for all functions, even if this is not strictly necessary for
22630 correct execution of the code. Specifying @option{-fomit-frame-pointer}
22631 with this option causes the stack frames not to be generated for
22632 leaf functions. The default is @option{-mno-apcs-frame}.
22633 This option is deprecated.
22637 This is a synonym for @option{-mapcs-frame} and is deprecated.
22640 @c not currently implemented
22641 @opindex mapcs-stack-check
22642 @item -mapcs-stack-check
22643 Generate code to check the amount of stack space available upon entry to
22644 every function (that actually uses some stack space). If there is
22645 insufficient space available then either the function
22646 @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
22647 called, depending upon the amount of stack space required. The runtime
22648 system is required to provide these functions. The default is
22649 @option{-mno-apcs-stack-check}, since this produces smaller code.
22651 @c not currently implemented
22652 @opindex mapcs-reentrant
22653 @item -mapcs-reentrant
22654 Generate reentrant, position-independent code. The default is
22655 @option{-mno-apcs-reentrant}.
22658 @opindex mthumb-interwork
22659 @item -mthumb-interwork
22660 Generate code that supports calling between the ARM and Thumb
22661 instruction sets. Without this option, on pre-v5 architectures, the
22662 two instruction sets cannot be reliably used inside one program. The
22663 default is @option{-mno-thumb-interwork}, since slightly larger code
22664 is generated when @option{-mthumb-interwork} is specified. In AAPCS
22665 configurations this option is meaningless.
22667 @opindex mno-sched-prolog
22668 @opindex msched-prolog
22669 @item -mno-sched-prolog
22670 Prevent the reordering of instructions in the function prologue, or the
22671 merging of those instruction with the instructions in the function's
22672 body. This means that all functions start with a recognizable set
22673 of instructions (or in fact one of a choice from a small set of
22674 different function prologues), and this information can be used to
22675 locate the start of functions inside an executable piece of code. The
22676 default is @option{-msched-prolog}.
22678 @opindex mfloat-abi
22679 @item -mfloat-abi=@var{name}
22680 Specifies which floating-point ABI to use. Permissible values
22681 are: @samp{soft}, @samp{softfp} and @samp{hard}.
22683 Specifying @samp{soft} causes GCC to generate output containing
22684 library calls for floating-point operations.
22685 @samp{softfp} allows the generation of code using hardware floating-point
22686 instructions, but still uses the soft-float calling conventions.
22687 @samp{hard} allows generation of floating-point instructions
22688 and uses FPU-specific calling conventions.
22690 The default depends on the specific target configuration. Note that
22691 the hard-float and soft-float ABIs are not link-compatible; you must
22692 compile your entire program with the same ABI, and link with a
22693 compatible set of libraries.
22695 @opindex mgeneral-regs-only
22696 @item -mgeneral-regs-only
22697 Generate code which uses only the general-purpose registers. This will prevent
22698 the compiler from using floating-point and Advanced SIMD registers but will not
22699 impose any restrictions on the assembler.
22701 @opindex mlittle-endian
22702 @item -mlittle-endian
22703 Generate code for a processor running in little-endian mode. This is
22704 the default for all standard configurations.
22706 @opindex mbig-endian
22708 Generate code for a processor running in big-endian mode; the default is
22709 to compile code for a little-endian processor.
22714 When linking a big-endian image select between BE8 and BE32 formats.
22715 The option has no effect for little-endian images and is ignored. The
22716 default is dependent on the selected target architecture. For ARMv6
22717 and later architectures the default is BE8, for older architectures
22718 the default is BE32. BE32 format has been deprecated by ARM.
22721 @item -march=@var{name}@r{[}+extension@dots{}@r{]}
22722 This specifies the name of the target ARM architecture. GCC uses this
22723 name to determine what kind of instructions it can emit when generating
22724 assembly code. This option can be used in conjunction with or instead
22725 of the @option{-mcpu=} option.
22727 Permissible names are:
22729 @samp{armv5t}, @samp{armv5te},
22730 @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
22731 @samp{armv6z}, @samp{armv6zk},
22732 @samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
22733 @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
22740 @samp{armv6-m}, @samp{armv6s-m},
22741 @samp{armv7-m}, @samp{armv7e-m},
22742 @samp{armv8-m.base}, @samp{armv8-m.main},
22743 @samp{armv8.1-m.main},
22745 @samp{iwmmxt} and @samp{iwmmxt2}.
22747 Additionally, the following architectures, which lack support for the
22748 Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
22750 Many of the architectures support extensions. These can be added by
22751 appending @samp{+@var{extension}} to the architecture name. Extension
22752 options are processed in order and capabilities accumulate. An extension
22753 will also enable any necessary base extensions
22754 upon which it depends. For example, the @samp{+crypto} extension
22755 will always enable the @samp{+simd} extension. The exception to the
22756 additive construction is for extensions that are prefixed with
22757 @samp{+no@dots{}}: these extensions disable the specified option and
22758 any other extensions that may depend on the presence of that
22761 For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
22762 writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
22763 entirely disabled by the @samp{+nofp} option that follows it.
22765 Most extension names are generically named, but have an effect that is
22766 dependent upon the architecture to which it is applied. For example,
22767 the @samp{+simd} option can be applied to both @samp{armv7-a} and
22768 @samp{armv8-a} architectures, but will enable the original ARMv7-A
22769 Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
22770 variant for @samp{armv8-a}.
22772 The table below lists the supported extensions for each architecture.
22773 Architectures not mentioned do not support any extensions.
22786 The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
22787 used as an alias for this extension.
22790 Disable the floating-point instructions.
22794 The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
22797 The VFPv3 floating-point instructions, with 16 double-precision
22798 registers. The extension @samp{+vfpv3-d16} can be used as an alias
22799 for this extension. Note that floating-point is not supported by the
22800 base ARMv7-M architecture, but is compatible with both the ARMv7-A and
22801 ARMv7-R architectures.
22804 Disable the floating-point instructions.
22810 The multiprocessing extension.
22813 The security extension.
22816 The VFPv3 floating-point instructions, with 16 double-precision
22817 registers. The extension @samp{+vfpv3-d16} can be used as an alias
22818 for this extension.
22821 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22822 The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
22823 for this extension.
22826 The VFPv3 floating-point instructions, with 32 double-precision
22829 @item +vfpv3-d16-fp16
22830 The VFPv3 floating-point instructions, with 16 double-precision
22831 registers and the half-precision floating-point conversion operations.
22834 The VFPv3 floating-point instructions, with 32 double-precision
22835 registers and the half-precision floating-point conversion operations.
22838 The VFPv4 floating-point instructions, with 16 double-precision
22842 The VFPv4 floating-point instructions, with 32 double-precision
22846 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22847 the half-precision floating-point conversion operations.
22850 The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
22853 Disable the Advanced SIMD instructions (does not disable floating point).
22856 Disable the floating-point and Advanced SIMD instructions.
22860 The extended version of the ARMv7-A architecture with support for
22864 The VFPv4 floating-point instructions, with 16 double-precision registers.
22865 The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
22868 The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
22869 extension @samp{+neon-vfpv4} can be used as an alias for this extension.
22872 The VFPv3 floating-point instructions, with 16 double-precision
22876 The VFPv3 floating-point instructions, with 32 double-precision
22879 @item +vfpv3-d16-fp16
22880 The VFPv3 floating-point instructions, with 16 double-precision
22881 registers and the half-precision floating-point conversion operations.
22884 The VFPv3 floating-point instructions, with 32 double-precision
22885 registers and the half-precision floating-point conversion operations.
22888 The VFPv4 floating-point instructions, with 16 double-precision
22892 The VFPv4 floating-point instructions, with 32 double-precision
22896 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22897 The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
22900 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22901 the half-precision floating-point conversion operations.
22904 Disable the Advanced SIMD instructions (does not disable floating point).
22907 Disable the floating-point and Advanced SIMD instructions.
22913 The Cyclic Redundancy Check (CRC) instructions.
22915 The ARMv8-A Advanced SIMD and floating-point instructions.
22917 The cryptographic instructions.
22919 Disable the cryptographic instructions.
22921 Disable the floating-point, Advanced SIMD and cryptographic instructions.
22923 Speculation Barrier Instruction.
22925 Execution and Data Prediction Restriction Instructions.
22931 The ARMv8.1-A Advanced SIMD and floating-point instructions.
22934 The cryptographic instructions. This also enables the Advanced SIMD and
22935 floating-point instructions.
22938 Disable the cryptographic instructions.
22941 Disable the floating-point, Advanced SIMD and cryptographic instructions.
22944 Speculation Barrier Instruction.
22947 Execution and Data Prediction Restriction Instructions.
22954 The half-precision floating-point data processing instructions.
22955 This also enables the Advanced SIMD and floating-point instructions.
22958 The half-precision floating-point fmla extension. This also enables
22959 the half-precision floating-point extension and Advanced SIMD and
22960 floating-point instructions.
22963 The ARMv8.1-A Advanced SIMD and floating-point instructions.
22966 The cryptographic instructions. This also enables the Advanced SIMD and
22967 floating-point instructions.
22970 Enable the Dot Product extension. This also enables Advanced SIMD instructions.
22973 Disable the cryptographic extension.
22976 Disable the floating-point, Advanced SIMD and cryptographic instructions.
22979 Speculation Barrier Instruction.
22982 Execution and Data Prediction Restriction Instructions.
22985 8-bit Integer Matrix Multiply instructions.
22986 This also enables Advanced SIMD and floating-point instructions.
22989 Brain half-precision floating-point instructions.
22990 This also enables Advanced SIMD and floating-point instructions.
22996 The half-precision floating-point data processing instructions.
22997 This also enables the Advanced SIMD and floating-point instructions as well
22998 as the Dot Product extension and the half-precision floating-point fmla
23002 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
23003 Dot Product extension.
23006 The cryptographic instructions. This also enables the Advanced SIMD and
23007 floating-point instructions as well as the Dot Product extension.
23010 Disable the cryptographic extension.
23013 Disable the floating-point, Advanced SIMD and cryptographic instructions.
23016 Speculation Barrier Instruction.
23019 Execution and Data Prediction Restriction Instructions.
23022 8-bit Integer Matrix Multiply instructions.
23023 This also enables Advanced SIMD and floating-point instructions.
23026 Brain half-precision floating-point instructions.
23027 This also enables Advanced SIMD and floating-point instructions.
23033 The half-precision floating-point data processing instructions.
23034 This also enables the Advanced SIMD and floating-point instructions as well
23035 as the Dot Product extension and the half-precision floating-point fmla
23039 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
23040 Dot Product extension.
23043 The cryptographic instructions. This also enables the Advanced SIMD and
23044 floating-point instructions as well as the Dot Product extension.
23047 Disable the cryptographic extension.
23050 Disable the floating-point, Advanced SIMD and cryptographic instructions.
23053 8-bit Integer Matrix Multiply instructions.
23054 This also enables Advanced SIMD and floating-point instructions.
23057 Brain half-precision floating-point instructions.
23058 This also enables Advanced SIMD and floating-point instructions.
23064 The half-precision floating-point data processing instructions.
23065 This also enables the Advanced SIMD and floating-point instructions as well
23066 as the Dot Product extension and the half-precision floating-point fmla
23070 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
23071 Dot Product extension.
23074 The cryptographic instructions. This also enables the Advanced SIMD and
23075 floating-point instructions as well as the Dot Product extension.
23078 Disable the cryptographic extension.
23081 Disable the floating-point, Advanced SIMD and cryptographic instructions.
23084 8-bit Integer Matrix Multiply instructions.
23085 This also enables Advanced SIMD and floating-point instructions.
23088 Brain half-precision floating-point instructions.
23089 This also enables Advanced SIMD and floating-point instructions.
23095 The single-precision VFPv3 floating-point instructions. The extension
23096 @samp{+vfpv3xd} can be used as an alias for this extension.
23099 The VFPv3 floating-point instructions with 16 double-precision registers.
23100 The extension +vfpv3-d16 can be used as an alias for this extension.
23102 @item +vfpv3xd-d16-fp16
23103 The single-precision VFPv3 floating-point instructions with 16 double-precision
23104 registers and the half-precision floating-point conversion operations.
23106 @item +vfpv3-d16-fp16
23107 The VFPv3 floating-point instructions with 16 double-precision
23108 registers and the half-precision floating-point conversion operations.
23111 Disable the floating-point extension.
23114 The ARM-state integer division instructions.
23117 Disable the ARM-state integer division extension.
23123 The single-precision VFPv4 floating-point instructions.
23126 The single-precision FPv5 floating-point instructions.
23129 The single- and double-precision FPv5 floating-point instructions.
23132 Disable the floating-point extensions.
23135 @item armv8.1-m.main
23139 The DSP instructions.
23142 The M-Profile Vector Extension (MVE) integer instructions.
23145 The M-Profile Vector Extension (MVE) integer and single precision
23146 floating-point instructions.
23149 The single-precision floating-point instructions.
23152 The single- and double-precision floating-point instructions.
23155 Disable the floating-point extension.
23157 @item +cdecp0, +cdecp1, ... , +cdecp7
23158 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
23159 to the numbers given in the options in the range 0 to 7.
23162 Enable the Pointer Authentication and Branch Target Identification Extension.
23168 The DSP instructions.
23171 Disable the DSP extension.
23174 The single-precision floating-point instructions.
23177 The single- and double-precision floating-point instructions.
23180 Disable the floating-point extension.
23182 @item +cdecp0, +cdecp1, ... , +cdecp7
23183 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
23184 to the numbers given in the options in the range 0 to 7.
23190 The Cyclic Redundancy Check (CRC) instructions.
23192 The single-precision FPv5 floating-point instructions.
23194 The ARMv8-A Advanced SIMD and floating-point instructions.
23196 The cryptographic instructions.
23198 Disable the cryptographic instructions.
23200 Disable the floating-point, Advanced SIMD and cryptographic instructions.
23205 @option{-march=native} causes the compiler to auto-detect the architecture
23206 of the build computer. At present, this feature is only supported on
23207 GNU/Linux, and not all architectures are recognized. If the auto-detect
23208 is unsuccessful the option has no effect.
23211 @item -mtune=@var{name}
23212 This option specifies the name of the target ARM processor for
23213 which GCC should tune the performance of the code.
23214 For some ARM implementations better performance can be obtained by using
23216 Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
23217 @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
23218 @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
23219 @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
23220 @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
23221 @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
23222 @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
23223 @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
23224 @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
23225 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
23226 @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
23227 @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
23228 @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
23229 @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
23230 @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
23231 @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
23232 @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
23233 @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
23234 @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
23235 @samp{cortex-m35p}, @samp{cortex-m52}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
23236 @samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
23237 @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
23238 @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
23239 @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
23240 @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
23243 Additionally, this option can specify that GCC should tune the performance
23244 of the code for a big.LITTLE system. Permissible names are:
23245 @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
23246 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
23247 @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
23248 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
23250 @option{-mtune=generic-@var{arch}} specifies that GCC should tune the
23251 performance for a blend of processors within architecture @var{arch}.
23252 The aim is to generate code that run well on the current most popular
23253 processors, balancing between optimizations that benefit some CPUs in the
23254 range, and avoiding performance pitfalls of other CPUs. The effects of
23255 this option may change in future GCC versions as CPU models come and go.
23257 @option{-mtune} permits the same extension options as @option{-mcpu}, but
23258 the extension options do not affect the tuning of the generated code.
23260 @option{-mtune=native} causes the compiler to auto-detect the CPU
23261 of the build computer. At present, this feature is only supported on
23262 GNU/Linux, and not all architectures are recognized. If the auto-detect is
23263 unsuccessful the option has no effect.
23266 @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
23267 This specifies the name of the target ARM processor. GCC uses this name
23268 to derive the name of the target ARM architecture (as if specified
23269 by @option{-march}) and the ARM processor type for which to tune for
23270 performance (as if specified by @option{-mtune}). Where this option
23271 is used in conjunction with @option{-march} or @option{-mtune},
23272 those options take precedence over the appropriate part of this option.
23274 Many of the supported CPUs implement optional architectural
23275 extensions. Where this is so the architectural extensions are
23276 normally enabled by default. If implementations that lack the
23277 extension exist, then the extension syntax can be used to disable
23278 those extensions that have been omitted. For floating-point and
23279 Advanced SIMD (Neon) instructions, the settings of the options
23280 @option{-mfloat-abi} and @option{-mfpu} must also be considered:
23281 floating-point and Advanced SIMD instructions will only be used if
23282 @option{-mfloat-abi} is not set to @samp{soft}; and any setting of
23283 @option{-mfpu} other than @samp{auto} will override the available
23284 floating-point and SIMD extension instructions.
23286 For example, @samp{cortex-a9} can be found in three major
23287 configurations: integer only, with just a floating-point unit or with
23288 floating-point and Advanced SIMD. The default is to enable all the
23289 instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
23290 be used to disable just the SIMD or both the SIMD and floating-point
23291 instructions respectively.
23293 Permissible names for this option are the same as those for
23296 The following extension options are common to the listed CPUs:
23300 Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
23301 @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
23302 Also disable the M-Profile Vector Extension (MVE) integer and
23303 single precision floating-point instructions on
23304 @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
23307 Disable the Pointer Authentication and Branch Target Identification Extension
23308 on @samp{cortex-m52} and @samp{cortex-m85}.
23311 Disable the M-Profile Vector Extension (MVE) integer and single precision
23312 floating-point instructions on @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
23315 Disable the M-Profile Vector Extension (MVE) single precision floating-point
23316 instructions on @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
23318 @item +cdecp0, +cdecp1, ... , +cdecp7
23319 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
23320 to the numbers given in the options in the range 0 to 7 on @samp{cortex-m52} and @samp{cortex-m55}.
23323 Disables the floating-point instructions on @samp{arm9e},
23324 @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
23325 @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
23326 @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
23327 @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
23328 @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
23329 Disables the floating-point and SIMD instructions on
23330 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
23331 @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
23332 @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
23333 @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
23334 @samp{cortex-a53} and @samp{cortex-a55}.
23337 Disables the double-precision component of the floating-point instructions
23338 on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
23339 @samp{cortex-r52plus} and @samp{cortex-m7}.
23342 Disables the SIMD (but not floating-point) instructions on
23343 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
23344 and @samp{cortex-a9}.
23347 Enables the cryptographic instructions on @samp{cortex-a32},
23348 @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
23349 @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
23350 @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
23351 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
23352 @samp{cortex-a75.cortex-a55}.
23355 Additionally the @samp{generic-armv7-a} pseudo target defaults to
23356 VFPv3 with 16 double-precision registers. It supports the following
23357 extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
23358 @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
23359 @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
23360 @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
23361 the extensions to @option{-march=armv7-a}.
23363 @option{-mcpu=generic-@var{arch}} is also permissible, and is
23364 equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
23365 See @option{-mtune} for more information.
23367 @option{-mcpu=native} causes the compiler to auto-detect the CPU
23368 of the build computer. At present, this feature is only supported on
23369 GNU/Linux, and not all architectures are recognized. If the auto-detect
23370 is unsuccessful the option has no effect.
23373 @item -mfpu=@var{name}
23374 This specifies what floating-point hardware (or hardware emulation) is
23375 available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
23377 @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
23378 @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
23379 @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
23380 @samp{fpv5-d16}, @samp{fpv5-sp-d16},
23381 @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
23382 Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
23383 is an alias for @samp{vfpv2}.
23385 The setting @samp{auto} is the default and is special. It causes the
23386 compiler to select the floating-point and Advanced SIMD instructions
23387 based on the settings of @option{-mcpu} and @option{-march}.
23389 If the selected floating-point hardware includes the NEON extension
23390 (e.g.@: @option{-mfpu=neon}), note that floating-point
23391 operations are not generated by GCC's auto-vectorization pass unless
23392 @option{-funsafe-math-optimizations} is also specified. This is
23393 because NEON hardware does not fully implement the IEEE 754 standard for
23394 floating-point arithmetic (in particular denormal values are treated as
23395 zero), so the use of NEON instructions may lead to a loss of precision.
23397 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}).
23399 @opindex mfp16-format
23400 @item -mfp16-format=@var{name}
23401 Specify the format of the @code{__fp16} half-precision floating-point type.
23402 Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
23403 the default is @samp{none}, in which case the @code{__fp16} type is not
23404 defined. @xref{Half-Precision}, for more information.
23406 @opindex mstructure-size-boundary
23407 @item -mstructure-size-boundary=@var{n}
23408 The sizes of all structures and unions are rounded up to a multiple
23409 of the number of bits set by this option. Permissible values are 8, 32
23410 and 64. The default value varies for different toolchains. For the COFF
23411 targeted toolchain the default value is 8. A value of 64 is only allowed
23412 if the underlying ABI supports it.
23414 Specifying a larger number can produce faster, more efficient code, but
23415 can also increase the size of the program. Different values are potentially
23416 incompatible. Code compiled with one value cannot necessarily expect to
23417 work with code or libraries compiled with another value, if they exchange
23418 information using structures or unions.
23420 This option is deprecated.
23422 @opindex mabort-on-noreturn
23423 @item -mabort-on-noreturn
23424 Generate a call to the function @code{abort} at the end of a
23425 @code{noreturn} function. It is executed if the function tries to
23428 @opindex mlong-calls
23429 @opindex mno-long-calls
23431 @itemx -mno-long-calls
23432 Tells the compiler to perform function calls by first loading the
23433 address of the function into a register and then performing a subroutine
23434 call on this register. This switch is needed if the target function
23435 lies outside of the 64-megabyte addressing range of the offset-based
23436 version of subroutine call instruction.
23438 Even if this switch is enabled, not all function calls are turned
23439 into long calls. The heuristic is that static functions, functions
23440 that have the @code{short_call} attribute, functions that are inside
23441 the scope of a @code{#pragma no_long_calls} directive, and functions whose
23442 definitions have already been compiled within the current compilation
23443 unit are not turned into long calls. The exceptions to this rule are
23444 that weak function definitions, functions with the @code{long_call}
23445 attribute or the @code{section} attribute, and functions that are within
23446 the scope of a @code{#pragma long_calls} directive are always
23447 turned into long calls.
23449 This feature is not enabled by default. Specifying
23450 @option{-mno-long-calls} restores the default behavior, as does
23451 placing the function calls within the scope of a @code{#pragma
23452 long_calls_off} directive. Note these switches have no effect on how
23453 the compiler generates code to handle function calls via function
23456 @opindex msingle-pic-base
23457 @item -msingle-pic-base
23458 Treat the register used for PIC addressing as read-only, rather than
23459 loading it in the prologue for each function. The runtime system is
23460 responsible for initializing this register with an appropriate value
23461 before execution begins.
23463 @opindex mpic-register
23464 @item -mpic-register=@var{reg}
23465 Specify the register to be used for PIC addressing.
23466 For standard PIC base case, the default is any suitable register
23467 determined by compiler. For single PIC base case, the default is
23468 @samp{R9} if target is EABI based or stack-checking is enabled,
23469 otherwise the default is @samp{R10}.
23471 @opindex mpic-data-is-text-relative
23472 @item -mpic-data-is-text-relative
23473 Assume that the displacement between the text and data segments is fixed
23474 at static link time. This permits using PC-relative addressing
23475 operations to access data known to be in the data segment. For
23476 non-VxWorks RTP targets, this option is enabled by default. When
23477 disabled on such targets, it will enable @option{-msingle-pic-base} by
23480 @opindex mpoke-function-name
23481 @item -mpoke-function-name
23482 Write the name of each function into the text section, directly
23483 preceding the function prologue. The generated code is similar to this:
23487 .ascii "arm_poke_function_name", 0
23490 .word 0xff000000 + (t1 - t0)
23491 arm_poke_function_name
23493 stmfd sp!, @{fp, ip, lr, pc@}
23497 When performing a stack backtrace, code can inspect the value of
23498 @code{pc} stored at @code{fp + 0}. If the trace function then looks at
23499 location @code{pc - 12} and the top 8 bits are set, then we know that
23500 there is a function name embedded immediately preceding this location
23501 and has length @code{((pc[-3]) & 0xff000000)}.
23508 Select between generating code that executes in ARM and Thumb
23509 states. The default for most configurations is to generate code
23510 that executes in ARM state, but the default can be changed by
23511 configuring GCC with the @option{--with-mode=}@var{state}
23514 You can also override the ARM and Thumb mode for each function
23515 by using the @code{target("thumb")} and @code{target("arm")} function attributes
23516 (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
23518 @opindex mflip-thumb
23520 Switch ARM/Thumb modes on alternating functions.
23521 This option is provided for regression testing of mixed Thumb/ARM code
23522 generation, and is not intended for ordinary use in compiling code.
23524 @opindex mtpcs-frame
23526 Generate a stack frame that is compliant with the Thumb Procedure Call
23527 Standard for all non-leaf functions. (A leaf function is one that does
23528 not call any other functions.) The default is @option{-mno-tpcs-frame}.
23530 @opindex mtpcs-leaf-frame
23531 @item -mtpcs-leaf-frame
23532 Generate a stack frame that is compliant with the Thumb Procedure Call
23533 Standard for all leaf functions. (A leaf function is one that does
23534 not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
23536 @opindex mcallee-super-interworking
23537 @item -mcallee-super-interworking
23538 Gives all externally visible functions in the file being compiled an ARM
23539 instruction set header which switches to Thumb mode before executing the
23540 rest of the function. This allows these functions to be called from
23541 non-interworking code. This option is not valid in AAPCS configurations
23542 because interworking is enabled by default.
23544 @opindex mcaller-super-interworking
23545 @item -mcaller-super-interworking
23546 Allows calls via function pointers (including virtual functions) to
23547 execute correctly regardless of whether the target code has been
23548 compiled for interworking or not. There is a small overhead in the cost
23549 of executing a function pointer if this option is enabled. This option
23550 is not valid in AAPCS configurations because interworking is enabled
23554 @item -mtp=@var{name}
23555 Specify the access model for the thread local storage pointer. The model
23556 @samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted
23557 models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch
23558 the thread pointer from the corresponding system register directly
23559 (supported from the arm6k architecture and later). These system registers
23560 are accessed through the CP15 co-processor interface and the argument
23561 @samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}.
23562 The argument @samp{auto} uses the best available method for the selected
23563 processor. The default setting is @samp{auto}.
23565 @opindex mtls-dialect
23566 @item -mtls-dialect=@var{dialect}
23567 Specify the dialect to use for accessing thread local storage. Two
23568 @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
23569 @samp{gnu} dialect selects the original GNU scheme for supporting
23570 local and global dynamic TLS models. The @samp{gnu2} dialect
23571 selects the GNU descriptor scheme, which provides better performance
23572 for shared libraries. The GNU descriptor scheme is compatible with
23573 the original scheme, but does require new assembler, linker and
23574 library support. Initial and local exec TLS models are unaffected by
23575 this option and always use the original scheme.
23577 @opindex mword-relocations
23578 @item -mword-relocations
23579 Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
23580 This is enabled by default on targets (uClinux, SymbianOS) where the runtime
23581 loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
23582 is specified. This option conflicts with @option{-mslow-flash-data}.
23584 @opindex mfix-cortex-m3-ldrd
23585 @item -mfix-cortex-m3-ldrd
23586 Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
23587 with overlapping destination and base registers are used. This option avoids
23588 generating these instructions. This option is enabled by default when
23589 @option{-mcpu=cortex-m3} is specified.
23591 @item -mfix-cortex-a57-aes-1742098
23592 @itemx -mno-fix-cortex-a57-aes-1742098
23593 @itemx -mfix-cortex-a72-aes-1655431
23594 @itemx -mno-fix-cortex-a72-aes-1655431
23595 Enable (disable) mitigation for an erratum on Cortex-A57 and
23596 Cortex-A72 that affects the AES cryptographic instructions. This
23597 option is enabled by default when either @option{-mcpu=cortex-a57} or
23598 @option{-mcpu=cortex-a72} is specified.
23600 @opindex munaligned-access
23601 @opindex mno-unaligned-access
23602 @item -munaligned-access
23603 @itemx -mno-unaligned-access
23604 Enables (or disables) reading and writing of 16- and 32- bit values
23605 from addresses that are not 16- or 32- bit aligned. By default
23606 unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
23607 ARMv8-M Baseline architectures, and enabled for all other
23608 architectures. If unaligned access is not enabled then words in packed
23609 data structures are accessed a byte at a time.
23611 The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
23612 generated object file to either true or false, depending upon the
23613 setting of this option. If unaligned access is enabled then the
23614 preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
23617 @opindex mneon-for-64bits
23618 @item -mneon-for-64bits
23619 This option is deprecated and has no effect.
23621 @opindex mslow-flash-data
23622 @item -mslow-flash-data
23623 Assume loading data from flash is slower than fetching instruction.
23624 Therefore literal load is minimized for better performance.
23625 This option is only supported when compiling for ARMv7 M-profile and
23626 off by default. It conflicts with @option{-mword-relocations}.
23628 @opindex masm-syntax-unified
23629 @item -masm-syntax-unified
23630 Assume inline assembler is using unified asm syntax. The default is
23631 currently off which implies divided syntax. This option has no impact
23632 on Thumb2. However, this may change in future releases of GCC.
23633 Divided syntax should be considered deprecated.
23635 @opindex mrestrict-it
23636 @item -mrestrict-it
23637 Restricts generation of IT blocks to conform to the rules of ARMv8-A.
23638 IT blocks can only contain a single 16-bit instruction from a select
23639 set of instructions. This option is on by default for ARMv8-A Thumb mode.
23641 @opindex mprint-tune-info
23642 @item -mprint-tune-info
23643 Print CPU tuning information as comment in assembler file. This is
23644 an option used only for regression testing of the compiler and not
23645 intended for ordinary use in compiling code. This option is disabled
23648 @opindex mverbose-cost-dump
23649 @item -mverbose-cost-dump
23650 Enable verbose cost model dumping in the debug dump files. This option is
23651 provided for use in debugging the compiler.
23653 @opindex mpure-code
23655 Do not allow constant data to be placed in code sections.
23656 Additionally, when compiling for ELF object format give all text sections the
23657 ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
23658 is only available when generating non-pic code for M-profile targets.
23662 Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
23663 Development Tools Engineering Specification", which can be found on
23664 @url{https://developer.arm.com/documentation/ecm0359818/latest/}.
23666 @opindex mfix-cmse-cve-2021-35465
23667 @item -mfix-cmse-cve-2021-35465
23668 Mitigate against a potential security issue with the @code{VLLDM} instruction
23669 in some M-profile devices when using CMSE (CVE-2021-365465). This option is
23670 enabled by default when the option @option{-mcpu=} is used with
23671 @code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m52}, @code{cortex-m55},
23672 @code{cortex-m85} or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465}
23673 can be used to disable the mitigation.
23675 @opindex mstack-protector-guard
23676 @opindex mstack-protector-guard-offset
23677 @item -mstack-protector-guard=@var{guard}
23678 @itemx -mstack-protector-guard-offset=@var{offset}
23679 Generate stack protection code using canary at @var{guard}. Supported
23680 locations are @samp{global} for a global canary or @samp{tls} for a
23681 canary accessible via the TLS register. The option
23682 @option{-mstack-protector-guard-offset=} is for use with
23683 @option{-fstack-protector-guard=tls} and not for use in user-land code.
23689 Select the FDPIC ABI, which uses 64-bit function descriptors to
23690 represent pointers to functions. When the compiler is configured for
23691 @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
23692 and implies @option{-fPIE} if none of the PIC/PIE-related options is
23693 provided. On other targets, it only enables the FDPIC-specific code
23694 generation features, and the user should explicitly provide the
23695 PIC/PIE-related options as needed.
23697 Note that static linking is not supported because it would still
23698 involve the dynamic linker when the program self-relocates. If such
23699 behavior is acceptable, use -static and -Wl,-dynamic-linker options.
23701 The opposite @option{-mno-fdpic} option is useful (and required) to
23702 build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
23703 toolchain as the one used to build the userland programs.
23705 @opindex mbranch-protection
23706 @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
23707 Enable branch protection features (armv8.1-m.main only).
23708 @samp{none} generate code without branch protection or return address
23710 @samp{standard[+@var{leaf}]} generate code with all branch protection
23711 features enabled at their standard level.
23712 @samp{pac-ret[+@var{leaf}]} generate code with return address signing
23713 set to its standard level, which is to sign all functions that save
23714 the return address to memory.
23715 @samp{leaf} When return address signing is enabled, also sign leaf
23716 functions even if they do not write the return address to memory.
23717 +@samp{bti} Add landing-pad instructions at the permitted targets of
23718 indirect branch instructions.
23720 If the @samp{+pacbti} architecture extension is not enabled, then all
23721 branch protection and return address signing operations are
23722 constrained to use only the instructions defined in the
23723 architectural-NOP space. The generated code will remain
23724 backwards-compatible with earlier versions of the architecture, but
23725 the additional security can be enabled at run time on processors that
23726 support the @samp{PACBTI} extension.
23728 Branch target enforcement using BTI can only be enabled at runtime if
23729 all code in the application has been compiled with at least
23730 @samp{-mbranch-protection=bti}.
23732 Any setting other than @samp{none} is supported only on armv8-m.main
23735 The default is to generate code without branch protection or return
23741 @subsection AVR Options
23742 @cindex AVR Options
23744 These options are defined for AVR implementations:
23748 @item -mmcu=@var{mcu}
23749 Specify the AVR instruction set architecture (ISA) or device type.
23750 The default for this option is@tie{}@code{avr2}.
23752 The following AVR devices and ISAs are supported.
23753 @emph{Note:} A complete device support consists of
23754 startup code @code{crt@var{mcu}.o}, a device header @code{avr/io*.h},
23755 a device library @code{lib@var{mcu}.a} and a
23756 @uref{https://gcc.gnu.org/wiki/avr-gcc#spec-files,device-specs} file
23757 @code{specs-@var{mcu}}. Only the latter is provided by the compiler
23758 according the supported @code{@var{mcu}}s below. The rest is supported
23759 by @w{@uref{https://www.nongnu.org/avr-libc/,AVR-LibC}}, or by means of
23760 @uref{https://gcc.gnu.org/wiki/avr-gcc#atpack,@code{atpack}} files
23761 from the hardware manufacturer.
23763 @c Auto-generated. Re-build when new devices are added to avr-mcus.def
23764 @c by running "make avr-mcus" in $builddir/gcc.
23765 @include avr-mmcu.texi
23770 Assume that all data in static storage can be accessed by LDS / STS
23771 instructions. This option has only an effect on reduced Tiny devices like
23772 ATtiny40. See also the @code{absdata}
23773 @ref{AVR Variable Attributes,variable attribute}.
23775 @opindex maccumulate-args
23776 @item -maccumulate-args
23777 Accumulate outgoing function arguments and acquire/release the needed
23778 stack space for outgoing function arguments once in function
23779 prologue/epilogue. Without this option, outgoing arguments are pushed
23780 before calling a function and popped afterwards.
23782 Popping the arguments after the function call can be expensive on
23783 AVR so that accumulating the stack space might lead to smaller
23784 executables because arguments need not be removed from the
23785 stack after such a function call.
23787 This option can lead to reduced code size for functions that perform
23788 several calls to functions that get their arguments on the stack like
23789 calls to printf-like functions.
23791 @opindex mbranch-cost
23792 @item -mbranch-cost=@var{cost}
23793 Set the branch costs for conditional branch instructions to
23794 @var{cost}. Reasonable values for @var{cost} are small, non-negative
23795 integers. The default branch cost is 0.
23797 @opindex mcall-prologues
23798 @item -mcall-prologues
23799 Functions prologues/epilogues are expanded as calls to appropriate
23800 subroutines. Code size is smaller.
23804 @itemx -mno-fuse-add
23805 @itemx -mfuse-add=@var{level}
23806 Optimize indirect memory accesses on reduced Tiny devices.
23807 The default uses @code{@var{level}=1} for optimizations @option{-Og}
23808 and @option{-O1}, and @code{@var{level}=2} for higher optimizations.
23809 Valid values for @var{level} are @code{0}, @code{1} and @code{2}.
23812 @opindex mlong-double
23813 @item -mdouble=@var{bits}
23814 @itemx -mlong-double=@var{bits}
23815 Set the size (in bits) of the @code{double} or @code{long double} type,
23816 respectively. Possible values for @var{bits} are 32 and 64.
23817 Whether or not a specific value for @var{bits} is allowed depends on
23818 the @code{--with-double=} and @code{--with-long-double=}
23819 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
23820 and the same applies for the default values of the options.
23822 @opindex mgas-isr-prologues
23823 @item -mgas-isr-prologues
23824 Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
23825 instruction supported by GNU Binutils.
23826 If this option is on, the feature can still be disabled for individual
23827 ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
23828 function attribute. This feature is activated per default
23829 if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
23830 and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
23834 Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
23835 @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
23836 and @code{long long} is 4 bytes. Please note that this option does not
23837 conform to the C standards, but it results in smaller code
23840 @opindex mmain-is-OS_task
23841 @item -mmain-is-OS_task
23842 Do not save registers in @code{main}. The effect is the same like
23843 attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
23844 to @code{main}. It is activated per default if optimization is on.
23846 @opindex mno-interrupts
23847 @item -mno-interrupts
23848 Generated code is not compatible with hardware interrupts.
23849 Code size is smaller.
23853 Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
23854 @code{RCALL} resp.@: @code{RJMP} instruction if applicable.
23855 Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
23856 the assembler's command line and the @option{--relax} option to the
23857 linker's command line.
23859 Jump relaxing is performed by the linker because jump offsets are not
23860 known before code is located. Therefore, the assembler code generated by the
23861 compiler is the same, but the instructions in the executable may
23862 differ from instructions in the assembler code.
23864 Relaxing must be turned on if linker stubs are needed, see the
23865 section on @code{EIND} and linker stubs below.
23867 @opindex mrodata-in-ram
23868 @item -mrodata-in-ram
23869 @itemx -mno-rodata-in-ram
23870 Locate the @code{.rodata} sections for read-only data in RAM resp.@:
23872 For most devices, there is no choice and this option acts rather
23875 Since v14 and for the AVR64* and AVR128* devices, @code{.rodata}
23876 is located in flash memory per default, provided the required GNU Binutils
23877 support (@w{@uref{https://sourceware.org/PR31124,PR31124}}) is available.
23878 In that case, @option{-mrodata-in-ram} can be used to return to the old
23879 layout with @code{.rodata} in RAM.
23883 Use address register @code{X} in a way proposed by the hardware. This means
23884 that @code{X} is only used in indirect, post-increment or
23885 pre-decrement addressing.
23887 Without this option, the @code{X} register may be used in the same way
23888 as @code{Y} or @code{Z} which then is emulated by additional
23890 For example, loading a value with @code{X+const} addressing with a
23891 small non-negative @code{const < 64} to a register @var{Rn} is
23895 adiw r26, const ; X += const
23896 ld @var{Rn}, X ; @var{Rn} = *X
23897 sbiw r26, const ; X -= const
23900 @opindex mtiny-stack
23902 Only change the lower 8@tie{}bits of the stack pointer.
23904 @opindex mfract-convert-truncate
23905 @item -mfract-convert-truncate
23906 Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
23908 @opindex nodevicelib
23910 Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
23912 @opindex nodevicespecs
23913 @item -nodevicespecs
23914 Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
23915 command line. The user takes responsibility for supplying the sub-processes
23916 like compiler proper, assembler and linker with appropriate command line
23917 options. This means that the user has to supply her private device specs
23918 file by means of @option{-specs=@var{path-to-specs-file}}. There is no
23919 more need for option @option{-mmcu=@var{mcu}}.
23921 This option can also serve as a replacement for the older way of
23922 specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
23923 which contains a folder named @code{device-specs} which contains a specs file named
23924 @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
23926 @opindex Waddr-space-convert
23927 @opindex Wno-addr-space-convert
23928 @item -Waddr-space-convert
23929 Warn about conversions between address spaces in the case where the
23930 resulting address space is not contained in the incoming address space.
23932 @opindex Wmisspelled-isr
23933 @opindex Wno-misspelled-isr
23934 @item -Wmisspelled-isr
23935 Warn if the ISR is misspelled, i.e.@: without __vector prefix.
23936 Enabled by default.
23940 @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
23941 @cindex @code{EIND}
23942 Pointers in the implementation are 16@tie{}bits wide.
23943 The address of a function or label is represented as word address so
23944 that indirect jumps and calls can target any code address in the
23945 range of 64@tie{}Ki words.
23947 In order to facilitate indirect jump on devices with more than 128@tie{}Ki
23948 bytes of program memory space, there is a special function register called
23949 @code{EIND} that serves as most significant part of the target address
23950 when @code{EICALL} or @code{EIJMP} instructions are used.
23952 Indirect jumps and calls on these devices are handled as follows by
23953 the compiler and are subject to some limitations:
23958 The compiler never sets @code{EIND}.
23961 The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
23962 instructions or might read @code{EIND} directly in order to emulate an
23963 indirect call/jump by means of a @code{RET} instruction.
23966 The compiler assumes that @code{EIND} never changes during the startup
23967 code or during the application. In particular, @code{EIND} is not
23968 saved/restored in function or interrupt service routine
23972 For indirect calls to functions and computed goto, the linker
23973 generates @emph{stubs}. Stubs are jump pads sometimes also called
23974 @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
23975 The stub contains a direct jump to the desired address.
23978 Linker relaxation must be turned on so that the linker generates
23979 the stubs correctly in all situations. See the compiler option
23980 @option{-mrelax} and the linker option @option{--relax}.
23981 There are corner cases where the linker is supposed to generate stubs
23982 but aborts without relaxation and without a helpful error message.
23985 The default linker script is arranged for code with @code{EIND = 0}.
23986 If code is supposed to work for a setup with @code{EIND != 0}, a custom
23987 linker script has to be used in order to place the sections whose
23988 name start with @code{.trampolines} into the segment where @code{EIND}
23992 The startup code from libgcc never sets @code{EIND}.
23993 Notice that startup code is a blend of code from libgcc and AVR-LibC.
23994 For the impact of AVR-LibC on @code{EIND}, see the
23995 @w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
23998 It is legitimate for user-specific startup code to set up @code{EIND}
23999 early, for example by means of initialization code located in
24000 section @code{.init3}. Such code runs prior to general startup code
24001 that initializes RAM and calls constructors, but after the bit
24002 of startup code from AVR-LibC that sets @code{EIND} to the segment
24003 where the vector table is located.
24005 #include <avr/io.h>
24008 __attribute__((section(".init3"),naked,used,no_instrument_function))
24009 init3_set_eind (void)
24011 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
24012 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
24017 The @code{__trampolines_start} symbol is defined in the linker script.
24020 Stubs are generated automatically by the linker if
24021 the following two conditions are met:
24024 @item The address of a label is taken by means of the @code{gs} modifier
24025 (short for @emph{generate stubs}) like so:
24027 LDI r24, lo8(gs(@var{func}))
24028 LDI r25, hi8(gs(@var{func}))
24030 @item The final location of that label is in a code segment
24031 @emph{outside} the segment where the stubs are located.
24035 The compiler emits such @code{gs} modifiers for code labels in the
24036 following situations:
24038 @item Taking address of a function or code label.
24039 @item Computed goto.
24040 @item If prologue-save function is used, see @option{-mcall-prologues}
24041 command-line option.
24042 @item Switch/case dispatch tables. If you do not want such dispatch
24043 tables you can specify the @option{-fno-jump-tables} command-line option.
24044 @item C and C++ constructors/destructors called during startup/shutdown.
24045 @item If the tools hit a @code{gs()} modifier explained above.
24049 Jumping to non-symbolic addresses like so is @emph{not} supported:
24054 /* Call function at word address 0x2 */
24055 return ((int(*)(void)) 0x2)();
24059 Instead, a stub has to be set up, i.e.@: the function has to be called
24060 through a symbol (@code{func_4} in the example):
24065 extern int func_4 (void);
24067 /* Call function at byte address 0x4 */
24072 and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
24073 Alternatively, @code{func_4} can be defined in the linker script.
24077 @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
24078 @cindex @code{RAMPD}
24079 @cindex @code{RAMPX}
24080 @cindex @code{RAMPY}
24081 @cindex @code{RAMPZ}
24082 Some AVR devices support memories larger than the 64@tie{}KiB range
24083 that can be accessed with 16-bit pointers. To access memory locations
24084 outside this 64@tie{}KiB range, the content of a @code{RAMP}
24085 register is used as high part of the address:
24086 The @code{X}, @code{Y}, @code{Z} address register is concatenated
24087 with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
24088 register, respectively, to get a wide address. Similarly,
24089 @code{RAMPD} is used together with direct addressing.
24093 The startup code initializes the @code{RAMP} special function
24094 registers with zero.
24097 If a @ref{AVR Named Address Spaces,named address space} other than
24098 generic or @code{__flash} is used, then @code{RAMPZ} is set
24099 as needed before the operation.
24102 If the device supports RAM larger than 64@tie{}KiB and the compiler
24103 needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
24104 is reset to zero after the operation.
24107 If the device comes with a specific @code{RAMP} register, the ISR
24108 prologue/epilogue saves/restores that SFR and initializes it with
24109 zero in case the ISR code might (implicitly) use it.
24112 RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
24113 If you use inline assembler to read from locations outside the
24114 16-bit address range and change one of the @code{RAMP} registers,
24115 you must reset it to zero after the access.
24119 @anchor{avr-macros}
24120 @subsubsection AVR Built-in Macros
24122 GCC defines several built-in macros so that the user code can test
24123 for the presence or absence of features. Almost any of the following
24124 built-in macros are deduced from device capabilities and thus
24125 triggered by the @option{-mmcu=} command-line option.
24127 For even more AVR-specific built-in macros see
24128 @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
24133 Build-in macro that resolves to a decimal number that identifies the
24134 architecture and depends on the @option{-mmcu=@var{mcu}} option.
24135 Possible values are:
24137 @code{2}, @code{25}, @code{3}, @code{31}, @code{35},
24138 @code{4}, @code{5}, @code{51}, @code{6}
24140 for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
24141 @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
24146 @code{102}, @code{103}, @code{104},
24147 @code{105}, @code{106}, @code{107}
24149 for @var{mcu}=@code{avrtiny},
24150 @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
24151 @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
24152 If @var{mcu} specifies a device, this built-in macro is set
24153 accordingly. For example, with @option{-mmcu=atmega8} the macro is
24154 defined to @code{4}.
24156 @item __AVR_@var{Device}__
24157 Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
24158 the device's name. For example, @option{-mmcu=atmega8} defines the
24159 built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
24160 @code{__AVR_ATtiny261A__}, etc.
24162 The built-in macros' names follow
24163 the scheme @code{__AVR_@var{Device}__} where @var{Device} is
24164 the device name as from the AVR user manual. The difference between
24165 @var{Device} in the built-in macro and @var{device} in
24166 @option{-mmcu=@var{device}} is that the latter is always lowercase.
24168 If @var{device} is not a device but only a core architecture like
24169 @samp{avr51}, this macro is not defined.
24171 @item __AVR_DEVICE_NAME__
24172 Setting @option{-mmcu=@var{device}} defines this built-in macro to
24173 the device's name. For example, with @option{-mmcu=atmega8} the macro
24174 is defined to @code{atmega8}.
24176 If @var{device} is not a device but only a core architecture like
24177 @samp{avr51}, this macro is not defined.
24179 @item __AVR_XMEGA__
24180 The device / architecture belongs to the XMEGA family of devices.
24182 @item __AVR_HAVE_ADIW__
24183 The device has the @code{ADIW} and @code{SBIW} instructions.
24185 @item __AVR_HAVE_ELPM__
24186 The device has the @code{ELPM} instruction.
24188 @item __AVR_HAVE_ELPMX__
24189 The device has the @code{ELPM R@var{n},Z} and @code{ELPM
24190 R@var{n},Z+} instructions.
24192 @item __AVR_HAVE_LPMX__
24193 The device has the @code{LPM R@var{n},Z} and
24194 @code{LPM R@var{n},Z+} instructions.
24196 @item __AVR_HAVE_MOVW__
24197 The device has the @code{MOVW} instruction to perform 16-bit
24198 register-register moves.
24200 @item __AVR_HAVE_MUL__
24201 The device has a hardware multiplier.
24203 @item __AVR_HAVE_JMP_CALL__
24204 The device has the @code{JMP} and @code{CALL} instructions.
24205 This is the case for devices with more than 8@tie{}KiB of program
24208 @item __AVR_HAVE_EIJMP_EICALL__
24209 @itemx __AVR_3_BYTE_PC__
24210 The device has the @code{EIJMP} and @code{EICALL} instructions.
24211 This is the case for devices with more than 128@tie{}KiB of program memory.
24212 This also means that the program counter
24213 (PC) is 3@tie{}bytes wide.
24215 @item __AVR_2_BYTE_PC__
24216 The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
24217 with up to 128@tie{}KiB of program memory.
24219 @item __AVR_HAVE_8BIT_SP__
24220 @itemx __AVR_HAVE_16BIT_SP__
24221 The stack pointer (SP) register is treated as 8-bit respectively
24222 16-bit register by the compiler.
24223 The definition of these macros is affected by @option{-mtiny-stack}.
24225 @item __AVR_HAVE_SPH__
24227 The device has the SPH (high part of stack pointer) special function
24228 register or has an 8-bit stack pointer, respectively.
24229 The definition of these macros is affected by @option{-mmcu=} and
24230 in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
24233 @item __AVR_HAVE_RAMPD__
24234 @itemx __AVR_HAVE_RAMPX__
24235 @itemx __AVR_HAVE_RAMPY__
24236 @itemx __AVR_HAVE_RAMPZ__
24237 The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
24238 @code{RAMPZ} special function register, respectively.
24240 @item __NO_INTERRUPTS__
24241 This macro reflects the @option{-mno-interrupts} command-line option.
24243 @item __AVR_ERRATA_SKIP__
24244 @itemx __AVR_ERRATA_SKIP_JMP_CALL__
24245 Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
24246 instructions because of a hardware erratum. Skip instructions are
24247 @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
24248 The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
24251 @item __AVR_ISA_RMW__
24252 The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
24254 @item __AVR_SFR_OFFSET__=@var{offset}
24255 Instructions that can address I/O special function registers directly
24256 like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
24257 address as if addressed by an instruction to access RAM like @code{LD}
24258 or @code{STS}. This offset depends on the device architecture and has
24259 to be subtracted from the RAM address in order to get the
24260 respective I/O@tie{}address.
24262 @item __AVR_SHORT_CALLS__
24263 The @option{-mshort-calls} command line option is set.
24265 @item __AVR_PM_BASE_ADDRESS__=@var{addr}
24266 Some devices support reading from flash memory by means of @code{LD*}
24267 instructions. The flash memory is seen in the data address space
24268 at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
24269 is not defined, this feature is not available. If defined,
24270 the address space is linear and there is no need to put
24271 @code{.rodata} into RAM. This is handled by the default linker
24272 description file, and is currently available for
24273 @code{avrtiny} and @code{avrxmega3}. Even more convenient,
24274 there is no need to use address spaces like @code{__flash} or
24275 features like attribute @code{progmem} and @code{pgm_read_*}.
24277 @item __AVR_HAVE_FLMAP__
24278 This macro is defined provided the following conditions are met:
24280 @item The device has the @code{NVMCTRL_CTRLB.FLMAP} bitfield.
24281 This applies to the AVR64* and AVR128* devices.
24282 @item It's not known at assembler-time which emulation will be used.
24284 This implies the compiler was configured with GNU Binutils that implement
24285 @w{@uref{https://sourceware.org/PR31124,PR31124}}.
24287 @item __AVR_RODATA_IN_RAM__
24288 This macro is undefined when the code is compiled for a core architecture.
24290 When the code is compiled for a device, the macro is defined to@tie{}1
24291 when the @code{.rodata} sections for read-only data is located in RAM;
24292 and defined to@tie{}0, otherwise.
24294 @item __WITH_AVRLIBC__
24295 The compiler is configured to be used together with AVR-Libc.
24296 See the @option{--with-avrlibc} configure option.
24298 @item __HAVE_DOUBLE_MULTILIB__
24299 Defined if @option{-mdouble=} acts as a multilib option.
24301 @item __HAVE_DOUBLE32__
24302 @itemx __HAVE_DOUBLE64__
24303 Defined if the compiler supports 32-bit double resp. 64-bit double.
24304 The actual layout is specified by option @option{-mdouble=}.
24306 @item __DEFAULT_DOUBLE__
24307 The size in bits of @code{double} if @option{-mdouble=} is not set.
24308 To test the layout of @code{double} in a program, use the built-in
24309 macro @code{__SIZEOF_DOUBLE__}.
24311 @item __HAVE_LONG_DOUBLE32__
24312 @itemx __HAVE_LONG_DOUBLE64__
24313 @itemx __HAVE_LONG_DOUBLE_MULTILIB__
24314 @itemx __DEFAULT_LONG_DOUBLE__
24315 Same as above, but for @code{long double} instead of @code{double}.
24317 @item __WITH_DOUBLE_COMPARISON__
24318 Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
24319 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
24320 and is defined to @code{2} or @code{3}.
24322 @item __WITH_LIBF7_LIBGCC__
24323 @itemx __WITH_LIBF7_MATH__
24324 @itemx __WITH_LIBF7_MATH_SYMBOLS__
24325 Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
24326 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
24330 @subsubsection AVR Internal Options
24331 The following options are used internally by the compiler and to communicate
24332 between device specs files and the compiler proper. You don't need to set these
24333 options by hand, in particular they are not optimization options.
24334 Using these options in the wrong way may lead to sub-optimal or wrong code.
24335 They are documented for completeness, and in order to get a better
24337 @w{@uref{https://gcc.gnu.org/wiki/avr-gcc#spec-files,device specs}}
24343 @item -mn-flash=@var{num}
24344 Assume that the flash memory has a size of @var{num} times 64@tie{}KiB.
24345 This determines which @code{__flash@var{N}} address spaces are available.
24349 The device has the @code{FLMAP} bit field located in special function
24350 register @code{NVMCTRL_CTRLB}.
24354 Assume that the device supports the Read-Modify-Write
24355 instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
24357 @opindex mshort-calls
24358 @item -mshort-calls
24360 Assume that @code{RJMP} and @code{RCALL} can target the whole
24361 program memory. This option is used for multilib generation and selection
24362 for the devices from architecture @code{avrxmega3}.
24367 Generate code without skips (@code{CPSE}, @code{SBRS},
24368 @code{SBRC}, @code{SBIS}, @code{SBIC}) over 32-bit instructions.
24372 Treat the stack pointer register as an 8-bit register,
24373 i.e.@: assume the high byte of the stack pointer is zero.
24374 This option is used by the compiler to select and
24375 build multilibs for architectures @code{avr2} and @code{avr25}.
24376 These architectures mix devices with and without @code{SPH}.
24380 @node Blackfin Options
24381 @subsection Blackfin Options
24382 @cindex Blackfin Options
24386 @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
24387 Specifies the name of the target Blackfin processor. Currently, @var{cpu}
24388 can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
24389 @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
24390 @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
24391 @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
24392 @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
24393 @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
24394 @samp{bf561}, @samp{bf592}.
24396 The optional @var{sirevision} specifies the silicon revision of the target
24397 Blackfin processor. Any workarounds available for the targeted silicon revision
24398 are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
24399 If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
24400 are enabled. The @code{__SILICON_REVISION__} macro is defined to two
24401 hexadecimal digits representing the major and minor numbers in the silicon
24402 revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
24403 is not defined. If @var{sirevision} is @samp{any}, the
24404 @code{__SILICON_REVISION__} is defined to be @code{0xffff}.
24405 If this optional @var{sirevision} is not used, GCC assumes the latest known
24406 silicon revision of the targeted Blackfin processor.
24408 GCC defines a preprocessor macro for the specified @var{cpu}.
24409 For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
24410 provided by libgloss to be linked in if @option{-msim} is not given.
24412 Without this option, @samp{bf532} is used as the processor by default.
24414 Note that support for @samp{bf561} is incomplete. For @samp{bf561},
24415 only the preprocessor macro is defined.
24419 Specifies that the program will be run on the simulator. This causes
24420 the simulator BSP provided by libgloss to be linked in. This option
24421 has effect only for @samp{bfin-elf} toolchain.
24422 Certain other options, such as @option{-mid-shared-library} and
24423 @option{-mfdpic}, imply @option{-msim}.
24425 @opindex momit-leaf-frame-pointer
24426 @item -momit-leaf-frame-pointer
24427 Don't keep the frame pointer in a register for leaf functions. This
24428 avoids the instructions to save, set up and restore frame pointers and
24429 makes an extra register available in leaf functions.
24431 @opindex mspecld-anomaly
24432 @item -mspecld-anomaly
24433 When enabled, the compiler ensures that the generated code does not
24434 contain speculative loads after jump instructions. If this option is used,
24435 @code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
24437 @opindex mno-specld-anomaly
24438 @opindex mspecld-anomaly
24439 @item -mno-specld-anomaly
24440 Don't generate extra code to prevent speculative loads from occurring.
24442 @opindex mcsync-anomaly
24443 @item -mcsync-anomaly
24444 When enabled, the compiler ensures that the generated code does not
24445 contain CSYNC or SSYNC instructions too soon after conditional branches.
24446 If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
24448 @opindex mno-csync-anomaly
24449 @opindex mcsync-anomaly
24450 @item -mno-csync-anomaly
24451 Don't generate extra code to prevent CSYNC or SSYNC instructions from
24452 occurring too soon after a conditional branch.
24456 When enabled, the compiler is free to take advantage of the knowledge that
24457 the entire program fits into the low 64k of memory.
24459 @opindex mno-low64k
24461 Assume that the program is arbitrarily large. This is the default.
24463 @opindex mstack-check-l1
24464 @item -mstack-check-l1
24465 Do stack checking using information placed into L1 scratchpad memory by the
24468 @opindex mid-shared-library
24469 @item -mid-shared-library
24470 Generate code that supports shared libraries via the library ID method.
24471 This allows for execute in place and shared libraries in an environment
24472 without virtual memory management. This option implies @option{-fPIC}.
24473 With a @samp{bfin-elf} target, this option implies @option{-msim}.
24475 @opindex mno-id-shared-library
24476 @opindex mid-shared-library
24477 @item -mno-id-shared-library
24478 Generate code that doesn't assume ID-based shared libraries are being used.
24479 This is the default.
24481 @opindex mleaf-id-shared-library
24482 @item -mleaf-id-shared-library
24483 Generate code that supports shared libraries via the library ID method,
24484 but assumes that this library or executable won't link against any other
24485 ID shared libraries. That allows the compiler to use faster code for jumps
24488 @opindex mno-leaf-id-shared-library
24489 @opindex mleaf-id-shared-library
24490 @item -mno-leaf-id-shared-library
24491 Do not assume that the code being compiled won't link against any ID shared
24492 libraries. Slower code is generated for jump and call insns.
24494 @opindex mshared-library-id
24495 @item -mshared-library-id=n
24496 Specifies the identification number of the ID-based shared library being
24497 compiled. Specifying a value of 0 generates more compact code; specifying
24498 other values forces the allocation of that number to the current
24499 library but is no more space- or time-efficient than omitting this option.
24503 Generate code that allows the data segment to be located in a different
24504 area of memory from the text segment. This allows for execute in place in
24505 an environment without virtual memory management by eliminating relocations
24506 against the text section.
24508 @opindex mno-sep-data
24510 @item -mno-sep-data
24511 Generate code that assumes that the data segment follows the text segment.
24512 This is the default.
24514 @opindex mlong-calls
24515 @opindex mno-long-calls
24517 @itemx -mno-long-calls
24518 Tells the compiler to perform function calls by first loading the
24519 address of the function into a register and then performing a subroutine
24520 call on this register. This switch is needed if the target function
24521 lies outside of the 24-bit addressing range of the offset-based
24522 version of subroutine call instruction.
24524 This feature is not enabled by default. Specifying
24525 @option{-mno-long-calls} restores the default behavior. Note these
24526 switches have no effect on how the compiler generates code to handle
24527 function calls via function pointers.
24531 Link with the fast floating-point library. This library relaxes some of
24532 the IEEE floating-point standard's rules for checking inputs against
24533 Not-a-Number (NAN), in the interest of performance.
24535 @opindex minline-plt
24537 Enable inlining of PLT entries in function calls to functions that are
24538 not known to bind locally. It has no effect without @option{-mfdpic}.
24540 @opindex mmulticore
24542 Build a standalone application for multicore Blackfin processors.
24543 This option causes proper start files and link scripts supporting
24544 multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
24545 It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
24547 This option can be used with @option{-mcorea} or @option{-mcoreb}, which
24548 selects the one-application-per-core programming model. Without
24549 @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
24550 programming model is used. In this model, the main function of Core B
24551 should be named as @code{coreb_main}.
24553 If this option is not used, the single-core application programming
24558 Build a standalone application for Core A of BF561 when using
24559 the one-application-per-core programming model. Proper start files
24560 and link scripts are used to support Core A, and the macro
24561 @code{__BFIN_COREA} is defined.
24562 This option can only be used in conjunction with @option{-mmulticore}.
24566 Build a standalone application for Core B of BF561 when using
24567 the one-application-per-core programming model. Proper start files
24568 and link scripts are used to support Core B, and the macro
24569 @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
24570 should be used instead of @code{main}.
24571 This option can only be used in conjunction with @option{-mmulticore}.
24575 Build a standalone application for SDRAM. Proper start files and
24576 link scripts are used to put the application into SDRAM, and the macro
24577 @code{__BFIN_SDRAM} is defined.
24578 The loader should initialize SDRAM before loading the application.
24582 Assume that ICPLBs are enabled at run time. This has an effect on certain
24583 anomaly workarounds. For Linux targets, the default is to assume ICPLBs
24584 are enabled; for standalone applications the default is off.
24588 @subsection C6X Options
24589 @cindex C6X Options
24593 @item -march=@var{name}
24594 This specifies the name of the target architecture. GCC uses this
24595 name to determine what kind of instructions it can emit when generating
24596 assembly code. Permissible names are: @samp{c62x},
24597 @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
24599 @opindex mbig-endian
24601 Generate code for a big-endian target.
24603 @opindex mlittle-endian
24604 @item -mlittle-endian
24605 Generate code for a little-endian target. This is the default.
24609 Choose startup files and linker script suitable for the simulator.
24611 @opindex msdata=default
24612 @item -msdata=default
24613 Put small global and static data in the @code{.neardata} section,
24614 which is pointed to by register @code{B14}. Put small uninitialized
24615 global and static data in the @code{.bss} section, which is adjacent
24616 to the @code{.neardata} section. Put small read-only data into the
24617 @code{.rodata} section. The corresponding sections used for large
24618 pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
24620 @opindex msdata=all
24622 Put all data, not just small objects, into the sections reserved for
24623 small data, and use addressing relative to the @code{B14} register to
24626 @opindex msdata=none
24628 Make no use of the sections reserved for small data, and use absolute
24629 addresses to access all data. Put all initialized global and static
24630 data in the @code{.fardata} section, and all uninitialized data in the
24631 @code{.far} section. Put all constant data into the @code{.const}
24636 @subsection CRIS Options
24637 @cindex CRIS Options
24639 These options are defined specifically for the CRIS ports.
24644 @item -march=@var{architecture-type}
24645 @itemx -mcpu=@var{architecture-type}
24646 Generate code for the specified architecture. The choices for
24647 @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
24648 respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
24649 Default is @samp{v0}.
24652 @item -mtune=@var{architecture-type}
24653 Tune to @var{architecture-type} everything applicable about the generated
24654 code, except for the ABI and the set of available instructions. The
24655 choices for @var{architecture-type} are the same as for
24656 @option{-march=@var{architecture-type}}.
24658 @opindex mmax-stack-frame
24659 @item -mmax-stack-frame=@var{n}
24660 Warn when the stack frame of a function exceeds @var{n} bytes.
24666 The options @option{-metrax4} and @option{-metrax100} are synonyms for
24667 @option{-march=v3} and @option{-march=v8} respectively.
24669 @opindex mmul-bug-workaround
24670 @opindex mno-mul-bug-workaround
24671 @item -mmul-bug-workaround
24672 @itemx -mno-mul-bug-workaround
24673 Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
24674 models where it applies. This option is disabled by default.
24678 Enable CRIS-specific verbose debug-related information in the assembly
24679 code. This option also has the effect of turning off the @samp{#NO_APP}
24680 formatted-code indicator to the assembler at the beginning of the
24685 Do not use condition-code results from previous instruction; always emit
24686 compare and test instructions before use of condition codes.
24688 @opindex mno-side-effects
24689 @opindex mside-effects
24690 @item -mno-side-effects
24691 Do not emit instructions with side effects in addressing modes other than
24694 @opindex mstack-align
24695 @opindex mno-stack-align
24696 @opindex mdata-align
24697 @opindex mno-data-align
24698 @opindex mconst-align
24699 @opindex mno-const-align
24700 @item -mstack-align
24701 @itemx -mno-stack-align
24702 @itemx -mdata-align
24703 @itemx -mno-data-align
24704 @itemx -mconst-align
24705 @itemx -mno-const-align
24706 These options (@samp{no-} options) arrange (eliminate arrangements) for the
24707 stack frame, individual data and constants to be aligned for the maximum
24708 single data access size for the chosen CPU model. The default is to
24709 arrange for 32-bit alignment. ABI details such as structure layout are
24710 not affected by these options.
24718 Similar to the stack- data- and const-align options above, these options
24719 arrange for stack frame, writable data and constants to all be 32-bit,
24720 16-bit or 8-bit aligned. The default is 32-bit alignment.
24722 @opindex mno-prologue-epilogue
24723 @opindex mprologue-epilogue
24724 @item -mno-prologue-epilogue
24725 @itemx -mprologue-epilogue
24726 With @option{-mno-prologue-epilogue}, the normal function prologue and
24727 epilogue which set up the stack frame are omitted and no return
24728 instructions or return sequences are generated in the code. Use this
24729 option only together with visual inspection of the compiled code: no
24730 warnings or errors are generated when call-saved registers must be saved,
24731 or storage for local variables needs to be allocated.
24735 Legacy no-op option.
24739 This option arranges
24740 to link with input-output functions from a simulator library. Code,
24741 initialized data and zero-initialized data are allocated consecutively.
24745 Like @option{-sim}, but pass linker options to locate initialized data at
24746 0x40000000 and zero-initialized data at 0x80000000.
24749 @node C-SKY Options
24750 @subsection C-SKY Options
24751 @cindex C-SKY Options
24753 GCC supports these options when compiling for C-SKY V2 processors.
24758 @item -march=@var{arch}
24759 Specify the C-SKY target architecture. Valid values for @var{arch} are:
24760 @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
24761 The default is @samp{ck810}.
24764 @item -mcpu=@var{cpu}
24765 Specify the C-SKY target processor. Valid values for @var{cpu} are:
24766 @samp{ck801}, @samp{ck801t},
24767 @samp{ck802}, @samp{ck802t}, @samp{ck802j},
24768 @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
24769 @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
24770 @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
24771 @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
24772 @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
24773 @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
24774 @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
24775 @samp{ck803eftr1}, @samp{ck803efhtr1},
24776 @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
24777 @samp{ck803sef}, @samp{ck803seft},
24778 @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
24779 @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
24780 @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
24781 @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
24783 @opindex mbig-endian
24785 @opindex mlittle-endian
24789 @itemx -mlittle-endian
24792 Select big- or little-endian code. The default is little-endian.
24794 @opindex mfloat-abi
24795 @item -mfloat-abi=@var{name}
24796 Specifies which floating-point ABI to use. Permissible values
24797 are: @samp{soft}, @samp{softfp} and @samp{hard}.
24799 Specifying @samp{soft} causes GCC to generate output containing
24800 library calls for floating-point operations.
24801 @samp{softfp} allows the generation of code using hardware floating-point
24802 instructions, but still uses the soft-float calling conventions.
24803 @samp{hard} allows generation of floating-point instructions
24804 and uses FPU-specific calling conventions.
24806 The default depends on the specific target configuration. Note that
24807 the hard-float and soft-float ABIs are not link-compatible; you must
24808 compile your entire program with the same ABI, and link with a
24809 compatible set of libraries.
24811 @opindex mhard-float
24812 @opindex msoft-float
24814 @itemx -msoft-float
24816 Select hardware or software floating-point implementations.
24817 The default is soft float.
24819 @opindex mdouble-float
24820 @item -mdouble-float
24821 @itemx -mno-double-float
24822 When @option{-mhard-float} is in effect, enable generation of
24823 double-precision float instructions. This is the default except
24824 when compiling for CK803.
24829 When @option{-mhard-float} is in effect, enable generation of
24830 @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
24831 This is the default except when compiling for CK803.
24834 @item -mfpu=@var{fpu}
24835 Select the floating-point processor. This option can only be used with
24836 @option{-mhard-float}.
24837 Values for @var{fpu} are
24838 @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
24839 @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
24840 @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
24845 Enable the extended @code{lrw} instruction. This option defaults to on
24846 for CK801 and off otherwise.
24851 Enable interrupt stack instructions; the default is off.
24853 The @option{-mistack} option is required to handle the
24854 @code{interrupt} and @code{isr} function attributes
24855 (@pxref{C-SKY Function Attributes}).
24859 Enable multiprocessor instructions; the default is off.
24863 Enable coprocessor instructions; the default is off.
24867 Enable coprocessor instructions; the default is off.
24871 Enable C-SKY security instructions; the default is off.
24875 Enable C-SKY trust instructions; the default is off.
24883 Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
24884 All of these options default to off.
24889 Generate divide instructions. Default is off.
24894 Generate code for Smart Mode, using only registers numbered 0-7 to allow
24895 use of 16-bit instructions. This option is ignored for CK801 where this
24896 is the required behavior, and it defaults to on for CK802.
24897 For other targets, the default is off.
24899 @opindex mhigh-registers
24900 @item -mhigh-registers
24901 @itemx -mno-high-registers
24902 Generate code using the high registers numbered 16-31. This option
24903 is not supported on CK801, CK802, or CK803, and is enabled by default
24904 for other processors.
24909 Generate code using global anchor symbol addresses.
24913 @itemx -mno-pushpop
24914 Generate code using @code{push} and @code{pop} instructions. This option
24917 @opindex mmultiple-stld
24918 @item -mmultiple-stld
24920 @itemx -mno-multiple-stld
24922 Generate code using @code{stm} and @code{ldm} instructions. This option
24923 isn't supported on CK801 but is enabled by default on other processors.
24925 @opindex mconstpool
24927 @itemx -mno-constpool
24928 Create constant pools in the compiler instead of deferring it to the
24929 assembler. This option is the default and required for correct code
24930 generation on CK801 and CK802, and is optional on other processors.
24932 @opindex mstack-size
24934 @item -mno-stack-size
24935 Emit @code{.stack_size} directives for each function in the assembly
24936 output. This option defaults to off.
24941 Generate code for the C-SKY compiler runtime instead of libgcc. This
24942 option defaults to off.
24944 @opindex mbranch-cost=
24945 @item -mbranch-cost=@var{n}
24946 Set the branch costs to roughly @code{n} instructions. The default is 1.
24948 @opindex msched-prolog
24949 @item -msched-prolog
24950 @itemx -mno-sched-prolog
24951 Permit scheduling of function prologue and epilogue sequences. Using
24952 this option can result in code that is not compliant with the C-SKY V2 ABI
24953 prologue requirements and that cannot be debugged or backtraced.
24954 It is disabled by default.
24958 Links the library libsemi.a which is in compatible with simulator. Applicable
24959 to ELF compiler only.
24963 @node Darwin Options
24964 @subsection Darwin Options
24965 @cindex Darwin options
24967 These options are defined for all architectures running the Darwin operating
24970 FSF GCC on Darwin does not create ``fat'' object files; it creates
24971 an object file for the single architecture that GCC was built to
24972 target. Apple's GCC on Darwin does create ``fat'' files if multiple
24973 @option{-arch} options are used; it does so by running the compiler or
24974 linker multiple times and joining the results together with
24977 The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
24978 @samp{i686}) is determined by the flags that specify the ISA
24979 that GCC is targeting, like @option{-mcpu} or @option{-march}. The
24980 @option{-force_cpusubtype_ALL} option can be used to override this.
24982 The Darwin tools vary in their behavior when presented with an ISA
24983 mismatch. The assembler, @file{as}, only permits instructions to
24984 be used that are valid for the subtype of the file it is generating,
24985 so you cannot put 64-bit instructions in a @samp{ppc750} object file.
24986 The linker for shared libraries, @file{/usr/bin/libtool}, fails
24987 and prints an error if asked to create a shared library with a less
24988 restrictive subtype than its input files (for instance, trying to put
24989 a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
24990 for executables, @command{ld}, quietly gives the executable the most
24991 restrictive subtype of any of its input files.
24996 Add the framework directory @var{dir} to the head of the list of
24997 directories to be searched for header files. These directories are
24998 interleaved with those specified by @option{-I} options and are
24999 scanned in a left-to-right order.
25001 A framework directory is a directory with frameworks in it. A
25002 framework is a directory with a @file{Headers} and/or
25003 @file{PrivateHeaders} directory contained directly in it that ends
25004 in @file{.framework}. The name of a framework is the name of this
25005 directory excluding the @file{.framework}. Headers associated with
25006 the framework are found in one of those two directories, with
25007 @file{Headers} being searched first. A subframework is a framework
25008 directory that is in a framework's @file{Frameworks} directory.
25009 Includes of subframework headers can only appear in a header of a
25010 framework that contains the subframework, or in a sibling subframework
25011 header. Two subframeworks are siblings if they occur in the same
25012 framework. A subframework should not have the same name as a
25013 framework; a warning is issued if this is violated. Currently a
25014 subframework cannot have subframeworks; in the future, the mechanism
25015 may be extended to support this. The standard frameworks can be found
25016 in @file{/System/Library/Frameworks} and
25017 @file{/Library/Frameworks}. An example include looks like
25018 @code{#include <Framework/header.h>}, where @file{Framework} denotes
25019 the name of the framework and @file{header.h} is found in the
25020 @file{PrivateHeaders} or @file{Headers} directory.
25022 @opindex iframework
25023 @item -iframework@var{dir}
25024 Like @option{-F} except the directory is a treated as a system
25025 directory. The main difference between this @option{-iframework} and
25026 @option{-F} is that with @option{-iframework} the compiler does not
25027 warn about constructs contained within header files found via
25028 @var{dir}. This option is valid only for the C family of languages.
25032 Emit debugging information for symbols that are used. For stabs
25033 debugging format, this enables @option{-feliminate-unused-debug-symbols}.
25034 This is by default ON@.
25038 Emit debugging information for all symbols and types.
25040 @opindex fconstant-cfstrings
25041 @item -fconstant-cfstrings
25042 The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}.
25044 @opindex mconstant-cfstrings
25045 @item -mconstant-cfstrings
25046 When the NeXT runtime is being used (the default on these systems), override
25047 any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"}
25048 literals to be laid out as constant CoreFoundation strings.
25050 @opindex mmacosx-version-min
25051 @item -mmacosx-version-min=@var{version}
25052 The earliest version of MacOS X that this executable will run on is
25053 @var{version}. Typical values supported for @var{version} include @code{12},
25054 @code{10.12}, and @code{10.5.8}.
25056 If the compiler was built to use the system's headers by default,
25057 then the default for this option is the system version on which the
25058 compiler is running, otherwise the default is to make choices that
25059 are compatible with as many systems and code bases as possible.
25063 Enable kernel development mode. The @option{-mkernel} option sets
25064 @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
25065 @option{-fno-exceptions}, @option{-fno-non-call-exceptions},
25066 @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
25067 applicable. This mode also sets @option{-mno-altivec},
25068 @option{-msoft-float}, @option{-fno-builtin} and
25069 @option{-mlong-branch} for PowerPC targets.
25071 @opindex mone-byte-bool
25072 @item -mone-byte-bool
25073 Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
25074 By default @code{sizeof(bool)} is @code{4} when compiling for
25075 Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
25076 option has no effect on x86.
25078 @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
25079 to generate code that is not binary compatible with code generated
25080 without that switch. Using this switch may require recompiling all
25081 other modules in a program, including system libraries. Use this
25082 switch to conform to a non-default data model.
25084 @opindex mfix-and-continue
25085 @opindex ffix-and-continue
25086 @opindex findirect-data
25087 @item -mfix-and-continue
25088 @itemx -ffix-and-continue
25089 @itemx -findirect-data
25090 Generate code suitable for fast turnaround development, such as to
25091 allow GDB to dynamically load @file{.o} files into already-running
25092 programs. @option{-findirect-data} and @option{-ffix-and-continue}
25093 are provided for backwards compatibility.
25097 Loads all members of static archive libraries.
25098 See man ld(1) for more information.
25100 @opindex arch_errors_fatal
25101 @item -arch_errors_fatal
25102 Cause the errors having to do with files that have the wrong architecture
25105 @opindex bind_at_load
25106 @item -bind_at_load
25107 Causes the output file to be marked such that the dynamic linker will
25108 bind all undefined references when the file is loaded or launched.
25112 Produce a Mach-o bundle format file.
25113 See man ld(1) for more information.
25115 @opindex bundle_loader
25116 @item -bundle_loader @var{executable}
25117 This option specifies the @var{executable} that will load the build
25118 output file being linked. See man ld(1) for more information.
25120 @opindex dynamiclib
25122 When passed this option, GCC produces a dynamic library instead of
25123 an executable when linking, using the Darwin @file{libtool} command.
25125 @opindex force_cpusubtype_ALL
25126 @item -force_cpusubtype_ALL
25127 This causes GCC's output file to have the @samp{ALL} subtype, instead of
25128 one controlled by the @option{-mcpu} or @option{-march} option.
25130 @opindex nodefaultrpaths
25131 @item -nodefaultrpaths
25132 Do not add default run paths for the compiler library directories to
25133 executables, modules or dynamic libraries. On macOS 10.5 and later,
25134 the embedded runpath is added by default unless the user adds
25135 @option{-nodefaultrpaths} to the link line. Run paths are needed
25136 (and therefore enforced) to build on macOS version 10.11 or later.
25138 @item -allowable_client @var{client_name}
25139 @itemx -client_name
25140 @itemx -compatibility_version
25141 @itemx -current_version
25143 @itemx -dependency-file
25145 @itemx -dylinker_install_name
25147 @itemx -exported_symbols_list
25150 @itemx -flat_namespace
25151 @itemx -force_flat_namespace
25152 @itemx -headerpad_max_install_names
25155 @itemx -install_name
25156 @itemx -keep_private_externs
25157 @itemx -multi_module
25158 @itemx -multiply_defined
25159 @itemx -multiply_defined_unused
25162 @itemx -no_dead_strip_inits_and_terms
25163 @itemx -nofixprebinding
25164 @itemx -nomultidefs
25166 @itemx -noseglinkedit
25167 @itemx -pagezero_size
25169 @itemx -prebind_all_twolevel_modules
25170 @itemx -private_bundle
25172 @itemx -read_only_relocs
25174 @itemx -sectobjectsymbols
25178 @itemx -sectobjectsymbols
25181 @itemx -segs_read_only_addr
25183 @itemx -segs_read_write_addr
25184 @itemx -seg_addr_table
25185 @itemx -seg_addr_table_filename
25186 @itemx -seglinkedit
25188 @itemx -segs_read_only_addr
25189 @itemx -segs_read_write_addr
25190 @itemx -single_module
25192 @itemx -sub_library
25194 @opindex allowable_client
25195 @opindex client_name
25196 @opindex compatibility_version
25197 @opindex current_version
25198 @opindex dead_strip
25199 @opindex dependency-file
25200 @opindex dylib_file
25201 @opindex dylinker_install_name
25203 @opindex exported_symbols_list
25205 @opindex flat_namespace
25206 @opindex force_flat_namespace
25207 @opindex headerpad_max_install_names
25208 @opindex image_base
25210 @opindex install_name
25211 @opindex keep_private_externs
25212 @opindex multi_module
25213 @opindex multiply_defined
25214 @opindex multiply_defined_unused
25215 @opindex noall_load
25216 @opindex no_dead_strip_inits_and_terms
25217 @opindex nofixprebinding
25218 @opindex nomultidefs
25220 @opindex noseglinkedit
25221 @opindex pagezero_size
25223 @opindex prebind_all_twolevel_modules
25224 @opindex private_bundle
25225 @opindex read_only_relocs
25227 @opindex sectobjectsymbols
25230 @opindex sectcreate
25231 @opindex sectobjectsymbols
25234 @opindex segs_read_only_addr
25235 @opindex segs_read_write_addr
25236 @opindex seg_addr_table
25237 @opindex seg_addr_table_filename
25238 @opindex seglinkedit
25240 @opindex segs_read_only_addr
25241 @opindex segs_read_write_addr
25242 @opindex single_module
25244 @opindex sub_library
25245 @opindex sub_umbrella
25246 @opindex twolevel_namespace
25249 @opindex unexported_symbols_list
25250 @opindex weak_reference_mismatches
25251 @opindex whatsloaded
25252 @itemx -sub_umbrella
25253 @itemx -twolevel_namespace
25256 @itemx -unexported_symbols_list
25257 @itemx -weak_reference_mismatches
25258 @itemx -whatsloaded
25259 These options are passed to the Darwin linker. The Darwin linker man page
25260 describes them in detail.
25263 @node DEC Alpha Options
25264 @subsection DEC Alpha Options
25266 These @samp{-m} options are defined for the DEC Alpha implementations:
25269 @opindex mno-soft-float
25270 @opindex msoft-float
25271 @item -mno-soft-float
25272 @itemx -msoft-float
25273 Use (do not use) the hardware floating-point instructions for
25274 floating-point operations. When @option{-msoft-float} is specified,
25275 functions in @file{libgcc.a} are used to perform floating-point
25276 operations. Unless they are replaced by routines that emulate the
25277 floating-point operations, or compiled in such a way as to call such
25278 emulations routines, these routines issue floating-point
25279 operations. If you are compiling for an Alpha without floating-point
25280 operations, you must ensure that the library is built so as not to call
25283 Note that Alpha implementations without floating-point operations are
25284 required to have floating-point registers.
25287 @opindex mno-fp-regs
25289 @itemx -mno-fp-regs
25290 Generate code that uses (does not use) the floating-point register set.
25291 @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
25292 register set is not used, floating-point operands are passed in integer
25293 registers as if they were integers and floating-point results are passed
25294 in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
25295 so any function with a floating-point argument or return value called by code
25296 compiled with @option{-mno-fp-regs} must also be compiled with that
25299 A typical use of this option is building a kernel that does not use,
25300 and hence need not save and restore, any floating-point registers.
25304 The Alpha architecture implements floating-point hardware optimized for
25305 maximum performance. It is mostly compliant with the IEEE floating-point
25306 standard. However, for full compliance, software assistance is
25307 required. This option generates code fully IEEE-compliant code
25308 @emph{except} that the @var{inexact-flag} is not maintained (see below).
25309 If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
25310 defined during compilation. The resulting code is less efficient but is
25311 able to correctly support denormalized numbers and exceptional IEEE
25312 values such as not-a-number and plus/minus infinity. Other Alpha
25313 compilers call this option @option{-ieee_with_no_inexact}.
25315 @opindex mieee-with-inexact
25316 @item -mieee-with-inexact
25317 This is like @option{-mieee} except the generated code also maintains
25318 the IEEE @var{inexact-flag}. Turning on this option causes the
25319 generated code to implement fully-compliant IEEE math. In addition to
25320 @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
25321 macro. On some Alpha implementations the resulting code may execute
25322 significantly slower than the code generated by default. Since there is
25323 very little code that depends on the @var{inexact-flag}, you should
25324 normally not specify this option. Other Alpha compilers call this
25325 option @option{-ieee_with_inexact}.
25327 @opindex mfp-trap-mode
25328 @item -mfp-trap-mode=@var{trap-mode}
25329 This option controls what floating-point related traps are enabled.
25330 Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
25331 The trap mode can be set to one of four values:
25335 This is the default (normal) setting. The only traps that are enabled
25336 are the ones that cannot be disabled in software (e.g., division by zero
25340 In addition to the traps enabled by @samp{n}, underflow traps are enabled
25344 Like @samp{u}, but the instructions are marked to be safe for software
25345 completion (see Alpha architecture manual for details).
25348 Like @samp{su}, but inexact traps are enabled as well.
25351 @opindex mfp-rounding-mode
25352 @item -mfp-rounding-mode=@var{rounding-mode}
25353 Selects the IEEE rounding mode. Other Alpha compilers call this option
25354 @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
25359 Normal IEEE rounding mode. Floating-point numbers are rounded towards
25360 the nearest machine number or towards the even machine number in case
25364 Round towards minus infinity.
25367 Chopped rounding mode. Floating-point numbers are rounded towards zero.
25370 Dynamic rounding mode. A field in the floating-point control register
25371 (@var{fpcr}, see Alpha architecture reference manual) controls the
25372 rounding mode in effect. The C library initializes this register for
25373 rounding towards plus infinity. Thus, unless your program modifies the
25374 @var{fpcr}, @samp{d} corresponds to round towards plus infinity.
25377 @opindex mtrap-precision
25378 @item -mtrap-precision=@var{trap-precision}
25379 In the Alpha architecture, floating-point traps are imprecise. This
25380 means without software assistance it is impossible to recover from a
25381 floating trap and program execution normally needs to be terminated.
25382 GCC can generate code that can assist operating system trap handlers
25383 in determining the exact location that caused a floating-point trap.
25384 Depending on the requirements of an application, different levels of
25385 precisions can be selected:
25389 Program precision. This option is the default and means a trap handler
25390 can only identify which program caused a floating-point exception.
25393 Function precision. The trap handler can determine the function that
25394 caused a floating-point exception.
25397 Instruction precision. The trap handler can determine the exact
25398 instruction that caused a floating-point exception.
25401 Other Alpha compilers provide the equivalent options called
25402 @option{-scope_safe} and @option{-resumption_safe}.
25404 @opindex mieee-conformant
25405 @item -mieee-conformant
25406 This option marks the generated code as IEEE conformant. You must not
25407 use this option unless you also specify @option{-mtrap-precision=i} and either
25408 @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
25409 is to emit the line @samp{.eflag 48} in the function prologue of the
25410 generated assembly file.
25412 @opindex mbuild-constants
25413 @item -mbuild-constants
25414 Normally GCC examines a 32- or 64-bit integer constant to
25415 see if it can construct it from smaller constants in two or three
25416 instructions. If it cannot, it outputs the constant as a literal and
25417 generates code to load it from the data segment at run time.
25419 Use this option to require GCC to construct @emph{all} integer constants
25420 using code, even if it takes more instructions (the maximum is six).
25422 You typically use this option to build a shared library dynamic
25423 loader. Itself a shared library, it must relocate itself in memory
25424 before it can find the variables and constants in its own data segment.
25442 Indicate whether GCC should generate code to use the optional BWX,
25443 CIX, FIX and MAX instruction sets. The default is to use the instruction
25444 sets supported by the CPU type specified via @option{-mcpu=} option or that
25445 of the CPU on which GCC was built if none is specified.
25447 @opindex mfloat-vax
25448 @opindex mfloat-ieee
25450 @itemx -mfloat-ieee
25451 Generate code that uses (does not use) VAX F and G floating-point
25452 arithmetic instead of IEEE single and double precision.
25454 @opindex mexplicit-relocs
25455 @opindex mno-explicit-relocs
25456 @item -mexplicit-relocs
25457 @itemx -mno-explicit-relocs
25458 Older Alpha assemblers provided no way to generate symbol relocations
25459 except via assembler macros. Use of these macros does not allow
25460 optimal instruction scheduling. GNU binutils as of version 2.12
25461 supports a new syntax that allows the compiler to explicitly mark
25462 which relocations should apply to which instructions. This option
25463 is mostly useful for debugging, as GCC detects the capabilities of
25464 the assembler when it is built and sets the default accordingly.
25466 @opindex msmall-data
25467 @opindex mlarge-data
25469 @itemx -mlarge-data
25470 When @option{-mexplicit-relocs} is in effect, static data is
25471 accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
25472 is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
25473 (the @code{.sdata} and @code{.sbss} sections) and are accessed via
25474 16-bit relocations off of the @code{$gp} register. This limits the
25475 size of the small data area to 64KB, but allows the variables to be
25476 directly accessed via a single instruction.
25478 The default is @option{-mlarge-data}. With this option the data area
25479 is limited to just below 2GB@. Programs that require more than 2GB of
25480 data must use @code{malloc} or @code{mmap} to allocate the data in the
25481 heap instead of in the program's data segment.
25483 When generating code for shared libraries, @option{-fpic} implies
25484 @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
25486 @opindex msmall-text
25487 @opindex mlarge-text
25489 @itemx -mlarge-text
25490 When @option{-msmall-text} is used, the compiler assumes that the
25491 code of the entire program (or shared library) fits in 4MB, and is
25492 thus reachable with a branch instruction. When @option{-msmall-data}
25493 is used, the compiler can assume that all local symbols share the
25494 same @code{$gp} value, and thus reduce the number of instructions
25495 required for a function call from 4 to 1.
25497 The default is @option{-mlarge-text}.
25500 @item -mcpu=@var{cpu_type}
25501 Set the instruction set and instruction scheduling parameters for
25502 machine type @var{cpu_type}. You can specify either the @samp{EV}
25503 style name or the corresponding chip number. GCC supports scheduling
25504 parameters for the EV4, EV5 and EV6 family of processors and
25505 chooses the default values for the instruction set from the processor
25506 you specify. If you do not specify a processor type, GCC defaults
25507 to the processor on which the compiler was built.
25509 Supported values for @var{cpu_type} are
25515 Schedules as an EV4 and has no instruction set extensions.
25519 Schedules as an EV5 and has no instruction set extensions.
25523 Schedules as an EV5 and supports the BWX extension.
25528 Schedules as an EV5 and supports the BWX and MAX extensions.
25532 Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
25536 Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
25539 Native toolchains also support the value @samp{native},
25540 which selects the best architecture option for the host processor.
25541 @option{-mcpu=native} has no effect if GCC does not recognize
25545 @item -mtune=@var{cpu_type}
25546 Set only the instruction scheduling parameters for machine type
25547 @var{cpu_type}. The instruction set is not changed.
25549 Native toolchains also support the value @samp{native},
25550 which selects the best architecture option for the host processor.
25551 @option{-mtune=native} has no effect if GCC does not recognize
25554 @opindex mmemory-latency
25555 @item -mmemory-latency=@var{time}
25556 Sets the latency the scheduler should assume for typical memory
25557 references as seen by the application. This number is highly
25558 dependent on the memory access patterns used by the application
25559 and the size of the external cache on the machine.
25561 Valid options for @var{time} are
25565 A decimal number representing clock cycles.
25571 The compiler contains estimates of the number of clock cycles for
25572 ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
25573 (also called Dcache, Scache, and Bcache), as well as to main memory.
25574 Note that L3 is only valid for EV5.
25580 @subsection eBPF Options
25581 @cindex eBPF Options
25584 @item -mframe-limit=@var{bytes}
25585 This specifies the hard limit for frame sizes, in bytes. Currently,
25586 the value that can be specified should be less than or equal to
25587 @samp{32767}. Defaults to whatever limit is imposed by the version of
25588 the Linux kernel targeted.
25590 @opindex mbig-endian
25592 Generate code for a big-endian target.
25594 @opindex mlittle-endian
25595 @item -mlittle-endian
25596 Generate code for a little-endian target. This is the default.
25601 Enable or disable generation of extra conditional-branch instructions.
25602 Enabled for CPU v2 and above.
25607 Enable or disable generation of 32-bit jump instructions.
25608 Enabled for CPU v3 and above.
25613 Enable or disable generation of 32-bit ALU instructions.
25614 Enabled for CPU v3 and above.
25616 @opindex mv3-atomics
25618 @itemx -mno-v3-atomics
25619 Enable or disable instructions for general atomic operations introduced
25620 in CPU v3. Enabled for CPU v3 and above.
25625 Enable or disable byte swap instructions. Enabled for CPU v4 and above.
25630 Enable or disable signed division and modulus instructions. Enabled for
25636 Enable or disable sign-extending move and memory load instructions.
25637 Enabled for CPU v4 and above.
25640 @item -mcpu=@var{version}
25641 This specifies which version of the eBPF ISA to target. Newer versions
25642 may not be supported by all kernels. The default is @samp{v4}.
25644 Supported values for @var{version} are:
25648 The first stable eBPF ISA with no special features or extensions.
25651 Supports the jump extensions, as in @option{-mjmpext}.
25654 All features of v2, plus:
25656 @item 32-bit jump operations, as in @option{-mjmp32}
25657 @item 32-bit ALU operations, as in @option{-malu32}
25658 @item general atomic operations, as in @option{-mv3-atomics}
25662 All features of v3, plus:
25664 @item Byte swap instructions, as in @option{-mbswap}
25665 @item Signed division and modulus instructions, as in @option{-msdiv}
25666 @item Sign-extending move and memory load instructions, as in @option{-msmov}
25672 Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
25673 is implied by @option{-gbtf}.
25677 Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
25678 support is enabled by default when generating BTF debug information for
25682 Generate code for an expanded version of BPF, which relaxes some of
25683 the restrictions imposed by the BPF architecture:
25685 @item Save and restore callee-saved registers at function entry and
25686 exit, respectively.
25689 @opindex masm=@var{dialect}
25690 @item -masm=@var{dialect}
25691 Outputs assembly instructions using eBPF selected @var{dialect}. The default
25694 Supported values for @var{dialect} are:
25698 Outputs normal assembly dialect.
25701 Outputs pseudo-c assembly dialect.
25705 @opindex -minline-memops-threshold
25706 @item -minline-memops-threshold=@var{bytes}
25707 Specifies a size threshold in bytes at or below which memmove, memcpy
25708 and memset shall always be expanded inline. Operations dealing with
25709 sizes larger than this threshold would have to be be implemented using
25710 a library call instead of being expanded inline, but since BPF doesn't
25711 allow libcalls, exceeding this threshold results in a compile-time
25712 error. The default is @samp{1024} bytes.
25717 @subsection FR30 Options
25718 @cindex FR30 Options
25720 These options are defined specifically for the FR30 port.
25724 @opindex msmall-model
25725 @item -msmall-model
25726 Use the small address space model. This can produce smaller code, but
25727 it does assume that all symbolic values and addresses fit into a
25732 Assume that runtime support has been provided and so there is no need
25733 to include the simulator library (@file{libsim.a}) on the linker
25739 @subsection FT32 Options
25740 @cindex FT32 Options
25742 These options are defined specifically for the FT32 port.
25748 Specifies that the program will be run on the simulator. This causes
25749 an alternate runtime startup and library to be linked.
25750 You must not use this option when generating programs that will run on
25751 real hardware; you must provide your own runtime library for whatever
25752 I/O functions are needed.
25756 Enable Local Register Allocation. This is still experimental for FT32,
25757 so by default the compiler uses standard reload.
25761 Do not use div and mod instructions.
25765 Enable use of the extended instructions of the FT32B processor.
25769 Compress all code using the Ft32B code compression scheme.
25773 Do not generate code that reads program memory.
25778 @subsection FRV Options
25779 @cindex FRV Options
25785 Only use the first 32 general-purpose registers.
25790 Use all 64 general-purpose registers.
25795 Use only the first 32 floating-point registers.
25800 Use all 64 floating-point registers.
25802 @opindex mhard-float
25805 Use hardware instructions for floating-point operations.
25807 @opindex msoft-float
25810 Use library routines for floating-point operations.
25815 Dynamically allocate condition code registers.
25820 Do not try to dynamically allocate condition code registers, only
25821 use @code{icc0} and @code{fcc0}.
25826 Change ABI to use double word insns.
25832 Do not use double word instructions.
25837 Use floating-point double instructions.
25839 @opindex mno-double
25842 Do not use floating-point double instructions.
25847 Use media instructions.
25852 Do not use media instructions.
25857 Use multiply and add/subtract instructions.
25859 @opindex mno-muladd
25862 Do not use multiply and add/subtract instructions.
25867 Select the FDPIC ABI, which uses function descriptors to represent
25868 pointers to functions. Without any PIC/PIE-related options, it
25869 implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
25870 assumes GOT entries and small data are within a 12-bit range from the
25871 GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
25872 are computed with 32 bits.
25873 With a @samp{bfin-elf} target, this option implies @option{-msim}.
25875 @opindex minline-plt
25878 Enable inlining of PLT entries in function calls to functions that are
25879 not known to bind locally. It has no effect without @option{-mfdpic}.
25880 It's enabled by default if optimizing for speed and compiling for
25881 shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
25882 optimization option such as @option{-O3} or above is present in the
25888 Assume a large TLS segment when generating thread-local code.
25893 Do not assume a large TLS segment when generating thread-local code.
25898 Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
25899 that is known to be in read-only sections. It's enabled by default,
25900 except for @option{-fpic} or @option{-fpie}: even though it may help
25901 make the global offset table smaller, it trades 1 instruction for 4.
25902 With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
25903 one of which may be shared by multiple symbols, and it avoids the need
25904 for a GOT entry for the referenced symbol, so it's more likely to be a
25905 win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
25907 @opindex multilib-library-pic
25908 @item -multilib-library-pic
25910 Link with the (library, not FD) pic libraries. It's implied by
25911 @option{-mlibrary-pic}, as well as by @option{-fPIC} and
25912 @option{-fpic} without @option{-mfdpic}. You should never have to use
25915 @opindex mlinked-fp
25918 Follow the EABI requirement of always creating a frame pointer whenever
25919 a stack frame is allocated. This option is enabled by default and can
25920 be disabled with @option{-mno-linked-fp}.
25922 @opindex mlong-calls
25925 Use indirect addressing to call functions outside the current
25926 compilation unit. This allows the functions to be placed anywhere
25927 within the 32-bit address space.
25929 @opindex malign-labels
25930 @item -malign-labels
25932 Try to align labels to an 8-byte boundary by inserting NOPs into the
25933 previous packet. This option only has an effect when VLIW packing
25934 is enabled. It doesn't create new packets; it merely adds NOPs to
25937 @opindex mlibrary-pic
25938 @item -mlibrary-pic
25940 Generate position-independent EABI code.
25945 Use only the first four media accumulator registers.
25950 Use all eight media accumulator registers.
25955 Pack VLIW instructions.
25960 Do not pack VLIW instructions.
25962 @opindex mno-eflags
25965 Do not mark ABI switches in e_flags.
25967 @opindex mcond-move
25970 Enable the use of conditional-move instructions (default).
25972 This switch is mainly for debugging the compiler and will likely be removed
25973 in a future version.
25975 @opindex mno-cond-move
25976 @item -mno-cond-move
25978 Disable the use of conditional-move instructions.
25980 This switch is mainly for debugging the compiler and will likely be removed
25981 in a future version.
25986 Enable the use of conditional set instructions (default).
25988 This switch is mainly for debugging the compiler and will likely be removed
25989 in a future version.
25994 Disable the use of conditional set instructions.
25996 This switch is mainly for debugging the compiler and will likely be removed
25997 in a future version.
25999 @opindex mcond-exec
26002 Enable the use of conditional execution (default).
26004 This switch is mainly for debugging the compiler and will likely be removed
26005 in a future version.
26007 @opindex mno-cond-exec
26008 @item -mno-cond-exec
26010 Disable the use of conditional execution.
26012 This switch is mainly for debugging the compiler and will likely be removed
26013 in a future version.
26015 @opindex mvliw-branch
26016 @item -mvliw-branch
26018 Run a pass to pack branches into VLIW instructions (default).
26020 This switch is mainly for debugging the compiler and will likely be removed
26021 in a future version.
26023 @opindex mno-vliw-branch
26024 @item -mno-vliw-branch
26026 Do not run a pass to pack branches into VLIW instructions.
26028 This switch is mainly for debugging the compiler and will likely be removed
26029 in a future version.
26031 @opindex mmulti-cond-exec
26032 @item -mmulti-cond-exec
26034 Enable optimization of @code{&&} and @code{||} in conditional execution
26037 This switch is mainly for debugging the compiler and will likely be removed
26038 in a future version.
26040 @opindex mno-multi-cond-exec
26041 @item -mno-multi-cond-exec
26043 Disable optimization of @code{&&} and @code{||} in conditional execution.
26045 This switch is mainly for debugging the compiler and will likely be removed
26046 in a future version.
26048 @opindex mnested-cond-exec
26049 @item -mnested-cond-exec
26051 Enable nested conditional execution optimizations (default).
26053 This switch is mainly for debugging the compiler and will likely be removed
26054 in a future version.
26056 @opindex mno-nested-cond-exec
26057 @item -mno-nested-cond-exec
26059 Disable nested conditional execution optimizations.
26061 This switch is mainly for debugging the compiler and will likely be removed
26062 in a future version.
26064 @opindex moptimize-membar
26065 @item -moptimize-membar
26067 This switch removes redundant @code{membar} instructions from the
26068 compiler-generated code. It is enabled by default.
26070 @opindex mno-optimize-membar
26071 @opindex moptimize-membar
26072 @item -mno-optimize-membar
26074 This switch disables the automatic removal of redundant @code{membar}
26075 instructions from the generated code.
26077 @opindex mtomcat-stats
26078 @item -mtomcat-stats
26080 Cause gas to print out tomcat statistics.
26083 @item -mcpu=@var{cpu}
26085 Select the processor type for which to generate code. Possible values are
26086 @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
26087 @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
26091 @node GNU/Linux Options
26092 @subsection GNU/Linux Options
26094 These @samp{-m} options are defined for GNU/Linux targets:
26099 Use the GNU C library. This is the default except
26100 on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
26101 @samp{*-*-linux-*android*} targets.
26105 Use uClibc C library. This is the default on
26106 @samp{*-*-linux-*uclibc*} targets.
26110 Use the musl C library. This is the default on
26111 @samp{*-*-linux-*musl*} targets.
26115 Use Bionic C library. This is the default on
26116 @samp{*-*-linux-*android*} targets.
26120 Compile code compatible with Android platform. This is the default on
26121 @samp{*-*-linux-*android*} targets.
26123 When compiling, this option enables @option{-mbionic}, @option{-fPIC},
26124 @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
26125 this option makes the GCC driver pass Android-specific options to the linker.
26126 Finally, this option causes the preprocessor macro @code{__ANDROID__}
26129 @opindex tno-android-cc
26130 @item -tno-android-cc
26131 Disable compilation effects of @option{-mandroid}, i.e., do not enable
26132 @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
26133 @option{-fno-rtti} by default.
26135 @opindex tno-android-ld
26136 @item -tno-android-ld
26137 Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
26138 linking options to the linker.
26142 @node H8/300 Options
26143 @subsection H8/300 Options
26145 These @samp{-m} options are defined for the H8/300 implementations:
26150 Shorten some address references at link time, when possible; uses the
26151 linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
26152 ld, Using ld}, for a fuller description.
26156 Generate code for the H8/300H@.
26160 Generate code for the H8S@.
26164 Generate code for the H8S and H8/300H in the normal mode. This switch
26165 must be used either with @option{-mh} or @option{-ms}.
26169 Generate code for the H8S/2600. This switch must be used with @option{-ms}.
26173 Extended registers are stored on stack before execution of function
26174 with monitor attribute. Default option is @option{-mexr}.
26175 This option is valid only for H8S targets.
26180 Extended registers are not stored on stack before execution of function
26181 with monitor attribute. Default option is @option{-mno-exr}.
26182 This option is valid only for H8S targets.
26186 Make @code{int} data 32 bits by default.
26188 @opindex malign-300
26190 On the H8/300H and H8S, use the same alignment rules as for the H8/300.
26191 The default for the H8/300H and H8S is to align longs and floats on
26193 @option{-malign-300} causes them to be aligned on 2-byte boundaries.
26194 This option has no effect on the H8/300.
26198 @subsection HPPA Options
26199 @cindex HPPA Options
26201 These @samp{-m} options are defined for the HPPA family of computers:
26205 @item -march=@var{architecture-type}
26206 Generate code for the specified architecture. The choices for
26207 @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
26208 1.1, and @samp{2.0} for PA 2.0 processors. Refer to
26209 @file{/usr/lib/sched.models} on an HP-UX system to determine the proper
26210 architecture option for your machine. Code compiled for lower numbered
26211 architectures runs on higher numbered architectures, but not the
26214 @opindex mpa-risc-1-0
26215 @opindex mpa-risc-1-1
26216 @opindex mpa-risc-2-0
26217 @item -mpa-risc-1-0
26218 @itemx -mpa-risc-1-1
26219 @itemx -mpa-risc-2-0
26220 Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
26222 @opindex matomic-libcalls
26223 @opindex mno-atomic-libcalls
26224 @item -matomic-libcalls
26225 Generate libcalls for atomic loads and stores when sync libcalls are disabled.
26226 This option is enabled by default. It only affects the generation of
26227 atomic libcalls by the HPPA backend.
26229 Both the sync and @file{libatomic} libcall implementations use locking.
26230 As a result, processor stores are not atomic with respect to other
26231 atomic operations. Processor loads up to DImode are atomic with
26232 respect to other atomic operations provided they are implemented as
26235 The PA-RISC architecture does not support any atomic operations in
26236 hardware except for the @code{ldcw} instruction. Thus, all atomic
26237 support is implemented using sync and atomic libcalls. Sync libcall
26238 support is in @file{libgcc.a}. Atomic libcall support is in
26241 This option generates @code{__atomic_exchange} calls for atomic stores.
26242 It also provides special handling for atomic DImode accesses on 32-bit
26245 @opindex mbig-switch
26247 Does nothing. Preserved for backward compatibility.
26249 @opindex mcaller-copies
26250 @item -mcaller-copies
26251 The caller copies function arguments passed by hidden reference. This
26252 option should be used with care as it is not compatible with the default
26253 32-bit runtime. However, only aggregates larger than eight bytes are
26254 passed by hidden reference and the option provides better compatibility
26257 @opindex mcoherent-ldcw
26258 @item -mcoherent-ldcw
26259 Use ldcw/ldcd coherent cache-control hint.
26261 @opindex mdisable-fpregs
26262 @item -mdisable-fpregs
26263 Disable floating-point registers. Equivalent to @code{-msoft-float}.
26265 @opindex mdisable-indexing
26266 @item -mdisable-indexing
26267 Prevent the compiler from using indexing address modes. This avoids some
26268 rather obscure problems when compiling MIG generated code under MACH@.
26270 @opindex mfast-indirect-calls
26271 @item -mfast-indirect-calls
26272 Generate code that assumes calls never cross space boundaries. This
26273 allows GCC to emit code that performs faster indirect calls.
26275 This option does not work in the presence of shared libraries or nested
26278 @opindex mfixed-range
26279 @item -mfixed-range=@var{register-range}
26280 Generate code treating the given register range as fixed registers.
26281 A fixed register is one that the register allocator cannot use. This is
26282 useful when compiling kernel code. A register range is specified as
26283 two registers separated by a dash. Multiple register ranges can be
26284 specified separated by a comma.
26288 Enable the use of assembler directives only GAS understands.
26292 Use options specific to GNU @command{ld}.
26293 This passes @option{-shared} to @command{ld} when
26294 building a shared library. It is the default when GCC is configured,
26295 explicitly or implicitly, with the GNU linker. This option does not
26296 affect which @command{ld} is called; it only changes what parameters
26297 are passed to that @command{ld}.
26298 The @command{ld} that is called is determined by the
26299 @option{--with-ld} configure option, GCC's program search path, and
26300 finally by the user's @env{PATH}. The linker used by GCC can be printed
26301 using @samp{which `gcc -print-prog-name=ld`}. This option is only available
26302 on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
26306 Use options specific to HP @command{ld}.
26307 This passes @option{-b} to @command{ld} when building
26308 a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
26309 links. It is the default when GCC is configured, explicitly or
26310 implicitly, with the HP linker. This option does not affect
26311 which @command{ld} is called; it only changes what parameters are passed to that
26313 The @command{ld} that is called is determined by the @option{--with-ld}
26314 configure option, GCC's program search path, and finally by the user's
26315 @env{PATH}. The linker used by GCC can be printed using @samp{which
26316 `gcc -print-prog-name=ld`}. This option is only available on the 64-bit
26317 HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
26319 @opindex mlinker-opt
26321 Enable the optimization pass in the HP-UX linker. Note this makes symbolic
26322 debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
26323 linkers in which they give bogus error messages when linking some programs.
26325 @opindex mno-long-calls
26326 @opindex mlong-calls
26328 Generate code that uses long call sequences. This ensures that a call
26329 is always able to reach linker generated stubs. The default is to generate
26330 long calls only when the distance from the call site to the beginning
26331 of the function or translation unit, as the case may be, exceeds a
26332 predefined limit set by the branch type being used. The limits for
26333 normal calls are 7,600,000 and 240,000 bytes, respectively for the
26334 PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
26337 Distances are measured from the beginning of functions when using the
26338 @option{-ffunction-sections} option, or when using the @option{-mgas}
26339 and @option{-mno-portable-runtime} options together under HP-UX with
26342 It is normally not desirable to use this option as it degrades
26343 performance. However, it may be useful in large applications,
26344 particularly when partial linking is used to build the application.
26346 The types of long calls used depends on the capabilities of the
26347 assembler and linker, and the type of code being generated. The
26348 impact on systems that support long absolute calls, and long pic
26349 symbol-difference or pc-relative calls should be relatively small.
26350 However, an indirect call is used on 32-bit ELF systems in pic code
26351 and it is quite long.
26353 @opindex mlong-load-store
26354 @item -mlong-load-store
26355 Generate 3-instruction load and store sequences as sometimes required by
26356 the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
26359 @opindex mjump-in-delay
26360 @item -mjump-in-delay
26361 This option is ignored and provided for compatibility purposes only.
26363 @opindex mno-space-regs
26364 @opindex mspace-regs
26365 @item -mno-space-regs
26366 Generate code that assumes the target has no space registers. This allows
26367 GCC to generate faster indirect calls and use unscaled index address modes.
26369 Such code is suitable for level 0 PA systems and kernels.
26373 Assume memory references are ordered and barriers are not needed.
26375 @opindex mportable-runtime
26376 @item -mportable-runtime
26377 Use the portable calling conventions proposed by HP for ELF systems.
26380 @item -mschedule=@var{cpu-type}
26381 Schedule code according to the constraints for the machine type
26382 @var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
26383 @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
26384 to @file{/usr/lib/sched.models} on an HP-UX system to determine the
26385 proper scheduling option for your machine. The default scheduling is
26390 Generate the predefine, @code{_SIO}, for server IO@. The default is
26391 @option{-mwsio}. This generates the predefines, @code{__hp9000s700},
26392 @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
26393 options are available under HP-UX and HI-UX@.
26395 @opindex msoft-float
26397 Generate output containing library calls for floating point.
26398 @strong{Warning:} the requisite libraries are not available for all HPPA
26399 targets. Normally the facilities of the machine's usual C compiler are
26400 used, but this cannot be done directly in cross-compilation. You must make
26401 your own arrangements to provide suitable library functions for
26404 @option{-msoft-float} changes the calling convention in the output file;
26405 therefore, it is only useful if you compile @emph{all} of a program with
26406 this option. In particular, you need to compile @file{libgcc.a}, the
26407 library that comes with GCC, with @option{-msoft-float} in order for
26410 @opindex msoft-mult
26412 Use software integer multiplication.
26414 This disables the use of the @code{xmpyu} instruction.
26417 @item -munix=@var{unix-std}
26418 Generate compiler predefines and select a startfile for the specified
26419 UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
26420 and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
26421 is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
26422 11.11 and later. The default values are @samp{93} for HP-UX 10.00,
26423 @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
26426 @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
26427 @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
26428 and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
26429 @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
26430 @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
26431 @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
26433 It is @emph{important} to note that this option changes the interfaces
26434 for various library routines. It also affects the operational behavior
26435 of the C library. Thus, @emph{extreme} care is needed in using this
26438 Library code that is intended to operate with more than one UNIX
26439 standard must test, set and restore the variable @code{__xpg4_extended_mask}
26440 as appropriate. Most GNU software doesn't provide this capability.
26444 Suppress the generation of link options to search libdld.sl when the
26445 @option{-static} option is specified on HP-UX 10 and later.
26449 The HP-UX implementation of setlocale in libc has a dependency on
26450 libdld.sl. There isn't an archive version of libdld.sl. Thus,
26451 when the @option{-static} option is specified, special link options
26452 are needed to resolve this dependency.
26454 On HP-UX 10 and later, the GCC driver adds the necessary options to
26455 link with libdld.sl when the @option{-static} option is specified.
26456 This causes the resulting binary to be dynamic. On the 64-bit port,
26457 the linkers generate dynamic binaries by default in any case. The
26458 @option{-nolibdld} option can be used to prevent the GCC driver from
26459 adding these link options.
26463 Add support for multithreading with the @dfn{dce thread} library
26464 under HP-UX@. This option sets flags for both the preprocessor and
26468 @node IA-64 Options
26469 @subsection IA-64 Options
26470 @cindex IA-64 Options
26472 These are the @samp{-m} options defined for the Intel IA-64 architecture.
26475 @opindex mbig-endian
26477 Generate code for a big-endian target. This is the default for HP-UX@.
26479 @opindex mlittle-endian
26480 @item -mlittle-endian
26481 Generate code for a little-endian target. This is the default for AIX5
26485 @opindex mno-gnu-as
26488 Generate (or don't) code for the GNU assembler. This is the default.
26489 @c Also, this is the default if the configure option @option{--with-gnu-as}
26493 @opindex mno-gnu-ld
26496 Generate (or don't) code for the GNU linker. This is the default.
26497 @c Also, this is the default if the configure option @option{--with-gnu-ld}
26502 Generate code that does not use a global pointer register. The result
26503 is not position independent code, and violates the IA-64 ABI@.
26505 @opindex mvolatile-asm-stop
26506 @opindex mno-volatile-asm-stop
26507 @item -mvolatile-asm-stop
26508 @itemx -mno-volatile-asm-stop
26509 Generate (or don't) a stop bit immediately before and after volatile asm
26512 @opindex mregister-names
26513 @opindex mno-register-names
26514 @item -mregister-names
26515 @itemx -mno-register-names
26516 Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
26517 the stacked registers. This may make assembler output more readable.
26523 Disable (or enable) optimizations that use the small data section. This may
26524 be useful for working around optimizer bugs.
26526 @opindex mconstant-gp
26527 @item -mconstant-gp
26528 Generate code that uses a single constant global pointer value. This is
26529 useful when compiling kernel code.
26533 Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
26534 This is useful when compiling firmware code.
26536 @opindex minline-float-divide-min-latency
26537 @item -minline-float-divide-min-latency
26538 Generate code for inline divides of floating-point values
26539 using the minimum latency algorithm.
26541 @opindex minline-float-divide-max-throughput
26542 @item -minline-float-divide-max-throughput
26543 Generate code for inline divides of floating-point values
26544 using the maximum throughput algorithm.
26546 @opindex mno-inline-float-divide
26547 @item -mno-inline-float-divide
26548 Do not generate inline code for divides of floating-point values.
26550 @opindex minline-int-divide-min-latency
26551 @item -minline-int-divide-min-latency
26552 Generate code for inline divides of integer values
26553 using the minimum latency algorithm.
26555 @opindex minline-int-divide-max-throughput
26556 @item -minline-int-divide-max-throughput
26557 Generate code for inline divides of integer values
26558 using the maximum throughput algorithm.
26560 @opindex mno-inline-int-divide
26561 @opindex minline-int-divide
26562 @item -mno-inline-int-divide
26563 Do not generate inline code for divides of integer values.
26565 @opindex minline-sqrt-min-latency
26566 @item -minline-sqrt-min-latency
26567 Generate code for inline square roots
26568 using the minimum latency algorithm.
26570 @opindex minline-sqrt-max-throughput
26571 @item -minline-sqrt-max-throughput
26572 Generate code for inline square roots
26573 using the maximum throughput algorithm.
26575 @opindex mno-inline-sqrt
26576 @item -mno-inline-sqrt
26577 Do not generate inline code for @code{sqrt}.
26579 @opindex mfused-madd
26580 @opindex mno-fused-madd
26582 @itemx -mno-fused-madd
26583 Do (don't) generate code that uses the fused multiply/add or multiply/subtract
26584 instructions. The default is to use these instructions.
26586 @opindex mno-dwarf2-asm
26587 @opindex mdwarf2-asm
26588 @item -mno-dwarf2-asm
26589 @itemx -mdwarf2-asm
26590 Don't (or do) generate assembler code for the DWARF line number debugging
26591 info. This may be useful when not using the GNU assembler.
26593 @opindex mearly-stop-bits
26594 @opindex mno-early-stop-bits
26595 @item -mearly-stop-bits
26596 @itemx -mno-early-stop-bits
26597 Allow stop bits to be placed earlier than immediately preceding the
26598 instruction that triggered the stop bit. This can improve instruction
26599 scheduling, but does not always do so.
26601 @opindex mfixed-range
26602 @item -mfixed-range=@var{register-range}
26603 Generate code treating the given register range as fixed registers.
26604 A fixed register is one that the register allocator cannot use. This is
26605 useful when compiling kernel code. A register range is specified as
26606 two registers separated by a dash. Multiple register ranges can be
26607 specified separated by a comma.
26610 @item -mtls-size=@var{tls-size}
26611 Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
26615 @item -mtune=@var{cpu-type}
26616 Tune the instruction scheduling for a particular CPU, Valid values are
26617 @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
26618 and @samp{mckinley}.
26624 Generate code for a 32-bit or 64-bit environment.
26625 The 32-bit environment sets int, long and pointer to 32 bits.
26626 The 64-bit environment sets int to 32 bits and long and pointer
26627 to 64 bits. These are HP-UX specific flags.
26629 @opindex mno-sched-br-data-spec
26630 @opindex msched-br-data-spec
26631 @item -mno-sched-br-data-spec
26632 @itemx -msched-br-data-spec
26633 (Dis/En)able data speculative scheduling before reload.
26634 This results in generation of @code{ld.a} instructions and
26635 the corresponding check instructions (@code{ld.c} / @code{chk.a}).
26636 The default setting is disabled.
26638 @opindex msched-ar-data-spec
26639 @opindex mno-sched-ar-data-spec
26640 @item -msched-ar-data-spec
26641 @itemx -mno-sched-ar-data-spec
26642 (En/Dis)able data speculative scheduling after reload.
26643 This results in generation of @code{ld.a} instructions and
26644 the corresponding check instructions (@code{ld.c} / @code{chk.a}).
26645 The default setting is enabled.
26647 @opindex mno-sched-control-spec
26648 @opindex msched-control-spec
26649 @item -mno-sched-control-spec
26650 @itemx -msched-control-spec
26651 (Dis/En)able control speculative scheduling. This feature is
26652 available only during region scheduling (i.e.@: before reload).
26653 This results in generation of the @code{ld.s} instructions and
26654 the corresponding check instructions @code{chk.s}.
26655 The default setting is disabled.
26657 @opindex msched-br-in-data-spec
26658 @opindex mno-sched-br-in-data-spec
26659 @item -msched-br-in-data-spec
26660 @itemx -mno-sched-br-in-data-spec
26661 (En/Dis)able speculative scheduling of the instructions that
26662 are dependent on the data speculative loads before reload.
26663 This is effective only with @option{-msched-br-data-spec} enabled.
26664 The default setting is enabled.
26666 @opindex msched-ar-in-data-spec
26667 @opindex mno-sched-ar-in-data-spec
26668 @item -msched-ar-in-data-spec
26669 @itemx -mno-sched-ar-in-data-spec
26670 (En/Dis)able speculative scheduling of the instructions that
26671 are dependent on the data speculative loads after reload.
26672 This is effective only with @option{-msched-ar-data-spec} enabled.
26673 The default setting is enabled.
26675 @opindex msched-in-control-spec
26676 @opindex mno-sched-in-control-spec
26677 @item -msched-in-control-spec
26678 @itemx -mno-sched-in-control-spec
26679 (En/Dis)able speculative scheduling of the instructions that
26680 are dependent on the control speculative loads.
26681 This is effective only with @option{-msched-control-spec} enabled.
26682 The default setting is enabled.
26684 @opindex mno-sched-prefer-non-data-spec-insns
26685 @opindex msched-prefer-non-data-spec-insns
26686 @item -mno-sched-prefer-non-data-spec-insns
26687 @itemx -msched-prefer-non-data-spec-insns
26688 If enabled, data-speculative instructions are chosen for schedule
26689 only if there are no other choices at the moment. This makes
26690 the use of the data speculation much more conservative.
26691 The default setting is disabled.
26693 @opindex mno-sched-prefer-non-control-spec-insns
26694 @opindex msched-prefer-non-control-spec-insns
26695 @item -mno-sched-prefer-non-control-spec-insns
26696 @itemx -msched-prefer-non-control-spec-insns
26697 If enabled, control-speculative instructions are chosen for schedule
26698 only if there are no other choices at the moment. This makes
26699 the use of the control speculation much more conservative.
26700 The default setting is disabled.
26702 @opindex mno-sched-count-spec-in-critical-path
26703 @opindex msched-count-spec-in-critical-path
26704 @item -mno-sched-count-spec-in-critical-path
26705 @itemx -msched-count-spec-in-critical-path
26706 If enabled, speculative dependencies are considered during
26707 computation of the instructions priorities. This makes the use of the
26708 speculation a bit more conservative.
26709 The default setting is disabled.
26711 @opindex msched-spec-ldc
26712 @item -msched-spec-ldc
26713 Use a simple data speculation check. This option is on by default.
26715 @opindex msched-spec-ldc
26716 @item -msched-control-spec-ldc
26717 Use a simple check for control speculation. This option is on by default.
26719 @opindex msched-stop-bits-after-every-cycle
26720 @item -msched-stop-bits-after-every-cycle
26721 Place a stop bit after every cycle when scheduling. This option is on
26724 @opindex msched-fp-mem-deps-zero-cost
26725 @item -msched-fp-mem-deps-zero-cost
26726 Assume that floating-point stores and loads are not likely to cause a conflict
26727 when placed into the same instruction group. This option is disabled by
26730 @opindex msel-sched-dont-check-control-spec
26731 @item -msel-sched-dont-check-control-spec
26732 Generate checks for control speculation in selective scheduling.
26733 This flag is disabled by default.
26735 @opindex msched-max-memory-insns
26736 @item -msched-max-memory-insns=@var{max-insns}
26737 Limit on the number of memory insns per instruction group, giving lower
26738 priority to subsequent memory insns attempting to schedule in the same
26739 instruction group. Frequently useful to prevent cache bank conflicts.
26740 The default value is 1.
26742 @opindex msched-max-memory-insns-hard-limit
26743 @item -msched-max-memory-insns-hard-limit
26744 Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
26745 disallowing more than that number in an instruction group.
26746 Otherwise, the limit is ``soft'', meaning that non-memory operations
26747 are preferred when the limit is reached, but memory operations may still
26753 @subsection LM32 Options
26754 @cindex LM32 options
26756 These @option{-m} options are defined for the LatticeMico32 architecture:
26759 @opindex mbarrel-shift-enabled
26760 @item -mbarrel-shift-enabled
26761 Enable barrel-shift instructions.
26763 @opindex mdivide-enabled
26764 @item -mdivide-enabled
26765 Enable divide and modulus instructions.
26767 @opindex multiply-enabled
26768 @item -mmultiply-enabled
26769 Enable multiply instructions.
26771 @opindex msign-extend-enabled
26772 @item -msign-extend-enabled
26773 Enable sign extend instructions.
26775 @opindex muser-enabled
26776 @item -muser-enabled
26777 Enable user-defined instructions.
26781 @node LoongArch Options
26782 @subsection LoongArch Options
26783 @cindex LoongArch Options
26785 These command-line options are defined for LoongArch targets:
26789 @item -march=@var{cpu-type}
26790 Generate instructions for the machine type @var{cpu-type}. In contrast to
26791 @option{-mtune=@var{cpu-type}}, which merely tunes the generated code
26792 for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
26793 to generate code that may not run at all on processors other than the one
26794 indicated. Specifying @option{-march=@var{cpu-type}} implies
26795 @option{-mtune=@var{cpu-type}}, except where noted otherwise.
26797 The choices for @var{cpu-type} are:
26801 This selects the CPU to generate code for at compilation time by determining
26802 the processor type of the compiling machine. Using @option{-march=native}
26803 enables all instruction subsets supported by the local machine (hence
26804 the result might not run on different machines). Using @option{-mtune=native}
26805 produces code optimized for the local machine under the constraints
26806 of the selected instruction set.
26808 A generic CPU with 64-bit extensions.
26810 LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
26814 @item -mtune=@var{cpu-type}
26815 Optimize the output for the given processor, specified by microarchitecture
26819 @item -mabi=@var{base-abi-type}
26820 Generate code for the specified calling convention.
26821 @var{base-abi-type} can be one of:
26824 Uses 64-bit general purpose registers and 32/64-bit floating-point
26825 registers for parameter passing. Data model is LP64, where @samp{int}
26826 is 32 bits, while @samp{long int} and pointers are 64 bits.
26828 Uses 64-bit general purpose registers and 32-bit floating-point
26829 registers for parameter passing. Data model is LP64, where @samp{int}
26830 is 32 bits, while @samp{long int} and pointers are 64 bits.
26832 Uses 64-bit general purpose registers and no floating-point
26833 registers for parameter passing. Data model is LP64, where @samp{int}
26834 is 32 bits, while @samp{long int} and pointers are 64 bits.
26838 @item -mfpu=@var{fpu-type}
26839 Generate code for the specified FPU type, which can be one of:
26842 Allow the use of hardware floating-point instructions for 32-bit
26843 and 64-bit operations.
26845 Allow the use of hardware floating-point instructions for 32-bit
26849 Prevent the use of hardware floating-point instructions.
26853 @item -msimd=@var{simd-type}
26854 Enable generation of LoongArch SIMD instructions for vectorization
26855 and via builtin functions. The value can be one of:
26858 Enable generating instructions from the 256-bit LoongArch Advanced
26859 SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX).
26861 Enable generating instructions from the 128-bit LoongArch SIMD
26864 No LoongArch SIMD instruction may be generated.
26867 @opindex msoft-float
26869 Force @option{-mfpu=none} and prevents the use of floating-point
26870 registers for parameter passing. This option may change the target
26873 @opindex msingle-float
26874 @item -msingle-float
26875 Force @option{-mfpu=32} and allow the use of 32-bit floating-point
26876 registers for parameter passing. This option may change the target
26879 @opindex mdouble-float
26880 @item -mdouble-float
26881 Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
26882 registers for parameter passing. This option may change the target
26890 Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX)
26891 that can be used by the compiler for code generation. Enabling LASX with
26892 @option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx}
26893 automatically disables LASX. These driver-only options act upon the final
26894 @option{msimd} configuration state and make incremental chagnes in the order
26895 they appear on the GCC driver's command line, deriving the final / canonicalized
26896 @option{msimd} option that is passed to the compiler proper.
26898 @opindex mbranch-cost
26899 @item -mbranch-cost=@var{n}
26900 Set the cost of branches to roughly @var{n} instructions.
26902 @opindex mcheck-zero-division
26903 @item -mcheck-zero-division
26904 @itemx -mno-check-zero-divison
26905 Trap (do not trap) on integer division by zero. The default is
26906 @option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
26907 @option{-mno-check-zero-division} for other optimization levels.
26909 @opindex mcond-move-int
26910 @item -mcond-move-int
26911 @itemx -mno-cond-move-int
26912 Conditional moves for integral data in general-purpose registers
26913 are enabled (disabled). The default is @option{-mcond-move-int}.
26915 @opindex mcond-move-float
26916 @item -mcond-move-float
26917 @itemx -mno-cond-move-float
26918 Conditional moves for floating-point registers are enabled (disabled).
26919 The default is @option{-mcond-move-float}.
26924 Force (do not force) the use of @code{memcpy} for non-trivial block moves.
26925 The default is @option{-mno-memcpy}, which allows GCC to inline most
26926 constant-sized copies. Setting optimization level to @option{-Os} also
26927 forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
26928 behavior if explicitly specified, regardless of the order these options on
26931 @opindex mstrict-align
26932 @item -mstrict-align
26933 @itemx -mno-strict-align
26934 Avoid or allow generating memory accesses that may not be aligned on a natural
26935 object boundary as described in the architecture specification. The default is
26936 @option{-mno-strict-align}.
26938 @opindex msmall-data-limit
26939 @item -msmall-data-limit=@var{number}
26940 Put global and static data smaller than @var{number} bytes into a special
26941 section (on some targets). The default value is 0.
26943 @opindex mmax-inline-memcpy-size
26944 @item -mmax-inline-memcpy-size=@var{n}
26945 Inline all block moves (such as calls to @code{memcpy} or structure copies)
26946 less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
26948 @item -mcmodel=@var{code-model}
26949 Set the code model to one of:
26951 @item tiny-static (Not implemented yet)
26952 @item tiny (Not implemented yet)
26955 The text segment must be within 128MB addressing space. The data segment must
26956 be within 2GB addressing space.
26959 The text segment and data segment must be within 2GB addressing space.
26961 @item large (Not implemented yet)
26964 This mode does not limit the size of the code segment and data segment.
26965 The @option{-mcmodel=extreme} option is incompatible with @option{-fplt}
26966 and/or @option{-mexplicit-relocs=none}.
26968 The default code model is @code{normal}.
26970 @item -mexplicit-relocs=@var{style}
26971 Set when to use assembler relocation operators when dealing with symbolic
26972 addresses. The alternative is to use assembler macros instead, which may
26973 limit instruction scheduling but allow linker relaxation.
26974 with @option{-mexplicit-relocs=none} the assembler macros are always used,
26975 with @option{-mexplicit-relocs=always} the assembler relocation operators
26976 are always used, with @option{-mexplicit-relocs=auto} the compiler will
26977 use the relocation operators where the linker relaxation is impossible to
26978 improve the code quality, and macros elsewhere. The default
26979 value for the option is determined with the assembler capability detected
26980 during GCC build-time and the setting of @option{-mrelax}:
26981 @option{-mexplicit-relocs=none} if the assembler does not support
26982 relocation operators at all,
26983 @option{-mexplicit-relocs=always} if the assembler supports relocation
26984 operators but @option{-mrelax} is not enabled,
26985 @option{-mexplicit-relocs=auto} if the assembler supports relocation
26986 operators and @option{-mrelax} is enabled.
26988 @opindex mexplicit-relocs
26989 @item -mexplicit-relocs
26990 An alias of @option{-mexplicit-relocs=always} for backward compatibility.
26992 @opindex mno-explicit-relocs
26993 @item -mno-explicit-relocs
26994 An alias of @option{-mexplicit-relocs=none} for backward compatibility.
26996 @opindex mdirect-extern-access
26997 @item -mdirect-extern-access
26998 @itemx -mno-direct-extern-access
26999 Do not use or use GOT to access external symbols. The default is
27000 @option{-mno-direct-extern-access}: GOT is used for external symbols with
27001 default visibility, but not used for other external symbols.
27003 With @option{-mdirect-extern-access}, GOT is not used and all external
27004 symbols are PC-relatively addressed. It is @strong{only} suitable for
27005 environments where no dynamic link is performed, like firmwares, OS
27006 kernels, executables linked with @option{-static} or @option{-static-pie}.
27007 @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
27012 Take (do not take) advantage of linker relaxations. If
27013 @option{-mpass-mrelax-to-as} is enabled, this option is also passed to
27014 the assembler. The default is determined during GCC build-time by
27015 detecting corresponding assembler support:
27016 @option{-mrelax} if the assembler supports both the @option{-mrelax}
27017 option and the conditional branch relaxation (it's required or the
27018 @code{.align} directives and conditional branch instructions in the
27019 assembly code outputted by GCC may be rejected by the assembler because
27020 of a relocation overflow), @option{-mno-relax} otherwise.
27022 @item -mpass-mrelax-to-as
27023 @itemx -mno-pass-mrelax-to-as
27024 Pass (do not pass) the @option{-mrelax} or @option{-mno-relax} option
27025 to the assembler. The default is determined during GCC build-time by
27026 detecting corresponding assembler support:
27027 @option{-mpass-mrelax-to-as} if the assembler supports the
27028 @option{-mrelax} option, @option{-mno-pass-mrelax-to-as} otherwise.
27029 This option is mostly useful for debugging, or interoperation with
27030 assemblers different from the build-time one.
27034 This option enables use of the reciprocal estimate and reciprocal square
27035 root estimate instructions with additional Newton-Raphson steps to increase
27036 precision instead of doing a divide or square root and divide for
27037 floating-point arguments.
27038 These instructions are generated only when @option{-funsafe-math-optimizations}
27039 is enabled together with @option{-ffinite-math-only} and
27040 @option{-fno-trapping-math}.
27041 This option is off by default. Before you can use this option, you must sure the
27042 target CPU supports frecipe and frsqrte instructions.
27043 Note that while the throughput of the sequence is higher than the throughput of
27044 the non-reciprocal instruction, the precision of the sequence can be decreased
27045 by up to 2 ulp (i.e. the inverse of 1.0 equals 0.99999994).
27047 @opindex mrecip=opt
27048 @item -mrecip=@var{opt}
27049 This option controls which reciprocal estimate instructions
27050 may be used. @var{opt} is a comma-separated list of options, which may
27051 be preceded by a @samp{!} to invert the option:
27055 Enable all estimate instructions.
27058 Enable the default instructions, equivalent to @option{-mrecip}.
27061 Disable all estimate instructions, equivalent to @option{-mno-recip}.
27064 Enable the approximation for scalar division.
27067 Enable the approximation for vectorized division.
27070 Enable the approximation for scalar square root.
27073 Enable the approximation for vectorized square root.
27076 Enable the approximation for scalar reciprocal square root.
27079 Enable the approximation for vectorized reciprocal square root.
27082 So, for example, @option{-mrecip=all,!sqrt} enables
27083 all of the reciprocal approximations, except for scalar square root.
27085 @item loongarch-vect-unroll-limit
27086 The vectorizer will use available tuning information to determine whether it
27087 would be beneficial to unroll the main vectorized loop and by how much. This
27088 parameter set's the upper bound of how much the vectorizer will unroll the main
27089 loop. The default value is six.
27095 @subsection M32C Options
27096 @cindex M32C options
27100 @item -mcpu=@var{name}
27101 Select the CPU for which code is generated. @var{name} may be one of
27102 @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
27103 /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
27104 the M32C/80 series.
27108 Specifies that the program will be run on the simulator. This causes
27109 an alternate runtime library to be linked in which supports, for
27110 example, file I/O@. You must not use this option when generating
27111 programs that will run on real hardware; you must provide your own
27112 runtime library for whatever I/O functions are needed.
27115 @item -memregs=@var{number}
27116 Specifies the number of memory-based pseudo-registers GCC uses
27117 during code generation. These pseudo-registers are used like real
27118 registers, so there is a tradeoff between GCC's ability to fit the
27119 code into available registers, and the performance penalty of using
27120 memory instead of registers. Note that all modules in a program must
27121 be compiled with the same value for this option. Because of that, you
27122 must not use this option with GCC's default runtime libraries.
27126 @node M32R/D Options
27127 @subsection M32R/D Options
27128 @cindex M32R/D options
27130 These @option{-m} options are defined for Renesas M32R/D architectures:
27135 Generate code for the M32R/2@.
27139 Generate code for the M32R/X@.
27143 Generate code for the M32R@. This is the default.
27145 @opindex mmodel=small
27146 @item -mmodel=small
27147 Assume all objects live in the lower 16MB of memory (so that their addresses
27148 can be loaded with the @code{ld24} instruction), and assume all subroutines
27149 are reachable with the @code{bl} instruction.
27150 This is the default.
27152 The addressability of a particular object can be set with the
27153 @code{model} attribute.
27155 @opindex mmodel=medium
27156 @item -mmodel=medium
27157 Assume objects may be anywhere in the 32-bit address space (the compiler
27158 generates @code{seth/add3} instructions to load their addresses), and
27159 assume all subroutines are reachable with the @code{bl} instruction.
27161 @opindex mmodel=large
27162 @item -mmodel=large
27163 Assume objects may be anywhere in the 32-bit address space (the compiler
27164 generates @code{seth/add3} instructions to load their addresses), and
27165 assume subroutines may not be reachable with the @code{bl} instruction
27166 (the compiler generates the much slower @code{seth/add3/jl}
27167 instruction sequence).
27169 @opindex msdata=none
27171 Disable use of the small data area. Variables are put into
27172 one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
27173 @code{section} attribute has been specified).
27174 This is the default.
27176 The small data area consists of sections @code{.sdata} and @code{.sbss}.
27177 Objects may be explicitly put in the small data area with the
27178 @code{section} attribute using one of these sections.
27180 @opindex msdata=sdata
27181 @item -msdata=sdata
27182 Put small global and static data in the small data area, but do not
27183 generate special code to reference them.
27185 @opindex msdata=use
27187 Put small global and static data in the small data area, and generate
27188 special instructions to reference them.
27191 @cindex smaller data references
27193 Put global and static objects less than or equal to @var{num} bytes
27194 into the small data or BSS sections instead of the normal data or BSS
27195 sections. The default value of @var{num} is 8.
27196 The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
27197 for this option to have any effect.
27199 All modules should be compiled with the same @option{-G @var{num}} value.
27200 Compiling with different values of @var{num} may or may not work; if it
27201 doesn't the linker gives an error message---incorrect code is not
27206 Makes the M32R-specific code in the compiler display some statistics
27207 that might help in debugging programs.
27209 @opindex malign-loops
27210 @item -malign-loops
27211 Align all loops to a 32-byte boundary.
27213 @opindex mno-align-loops
27214 @item -mno-align-loops
27215 Do not enforce a 32-byte alignment for loops. This is the default.
27217 @opindex missue-rate=@var{number}
27218 @item -missue-rate=@var{number}
27219 Issue @var{number} instructions per cycle. @var{number} can only be 1
27222 @opindex mbranch-cost=@var{number}
27223 @item -mbranch-cost=@var{number}
27224 @var{number} can only be 1 or 2. If it is 1 then branches are
27225 preferred over conditional code, if it is 2, then the opposite applies.
27227 @opindex mflush-trap=@var{number}
27228 @item -mflush-trap=@var{number}
27229 Specifies the trap number to use to flush the cache. The default is
27230 12. Valid numbers are between 0 and 15 inclusive.
27232 @opindex mno-flush-trap
27233 @item -mno-flush-trap
27234 Specifies that the cache cannot be flushed by using a trap.
27236 @opindex mflush-func=@var{name}
27237 @item -mflush-func=@var{name}
27238 Specifies the name of the operating system function to call to flush
27239 the cache. The default is @samp{_flush_cache}, but a function call
27240 is only used if a trap is not available.
27242 @opindex mno-flush-func
27243 @item -mno-flush-func
27244 Indicates that there is no OS function for flushing the cache.
27248 @node M680x0 Options
27249 @subsection M680x0 Options
27250 @cindex M680x0 options
27252 These are the @samp{-m} options defined for M680x0 and ColdFire processors.
27253 The default settings depend on which architecture was selected when
27254 the compiler was configured; the defaults for the most common choices
27259 @item -march=@var{arch}
27260 Generate code for a specific M680x0 or ColdFire instruction set
27261 architecture. Permissible values of @var{arch} for M680x0
27262 architectures are: @samp{68000}, @samp{68010}, @samp{68020},
27263 @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
27264 architectures are selected according to Freescale's ISA classification
27265 and the permissible values are: @samp{isaa}, @samp{isaaplus},
27266 @samp{isab} and @samp{isac}.
27268 GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
27269 code for a ColdFire target. The @var{arch} in this macro is one of the
27270 @option{-march} arguments given above.
27272 When used together, @option{-march} and @option{-mtune} select code
27273 that runs on a family of similar processors but that is optimized
27274 for a particular microarchitecture.
27277 @item -mcpu=@var{cpu}
27278 Generate code for a specific M680x0 or ColdFire processor.
27279 The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
27280 @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
27281 and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
27282 below, which also classifies the CPUs into families:
27284 @multitable @columnfractions 0.20 0.80
27285 @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
27286 @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}
27287 @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
27288 @item @samp{5206e} @tab @samp{5206e}
27289 @item @samp{5208} @tab @samp{5207} @samp{5208}
27290 @item @samp{5211a} @tab @samp{5210a} @samp{5211a}
27291 @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
27292 @item @samp{5216} @tab @samp{5214} @samp{5216}
27293 @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
27294 @item @samp{5225} @tab @samp{5224} @samp{5225}
27295 @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
27296 @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
27297 @item @samp{5249} @tab @samp{5249}
27298 @item @samp{5250} @tab @samp{5250}
27299 @item @samp{5271} @tab @samp{5270} @samp{5271}
27300 @item @samp{5272} @tab @samp{5272}
27301 @item @samp{5275} @tab @samp{5274} @samp{5275}
27302 @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
27303 @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
27304 @item @samp{5307} @tab @samp{5307}
27305 @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
27306 @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
27307 @item @samp{5407} @tab @samp{5407}
27308 @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}
27311 @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
27312 @var{arch} is compatible with @var{cpu}. Other combinations of
27313 @option{-mcpu} and @option{-march} are rejected.
27315 GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
27316 @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
27317 where the value of @var{family} is given by the table above.
27320 @item -mtune=@var{tune}
27321 Tune the code for a particular microarchitecture within the
27322 constraints set by @option{-march} and @option{-mcpu}.
27323 The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
27324 @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
27325 and @samp{cpu32}. The ColdFire microarchitectures
27326 are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
27328 You can also use @option{-mtune=68020-40} for code that needs
27329 to run relatively well on 68020, 68030 and 68040 targets.
27330 @option{-mtune=68020-60} is similar but includes 68060 targets
27331 as well. These two options select the same tuning decisions as
27332 @option{-m68020-40} and @option{-m68020-60} respectively.
27334 GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
27335 when tuning for 680x0 architecture @var{arch}. It also defines
27336 @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
27337 option is used. If GCC is tuning for a range of architectures,
27338 as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
27339 it defines the macros for every architecture in the range.
27341 GCC also defines the macro @code{__m@var{uarch}__} when tuning for
27342 ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
27343 of the arguments given above.
27349 Generate output for a 68000. This is the default
27350 when the compiler is configured for 68000-based systems.
27351 It is equivalent to @option{-march=68000}.
27353 Use this option for microcontrollers with a 68000 or EC000 core,
27354 including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
27358 Generate output for a 68010. This is the default
27359 when the compiler is configured for 68010-based systems.
27360 It is equivalent to @option{-march=68010}.
27366 Generate output for a 68020. This is the default
27367 when the compiler is configured for 68020-based systems.
27368 It is equivalent to @option{-march=68020}.
27372 Generate output for a 68030. This is the default when the compiler is
27373 configured for 68030-based systems. It is equivalent to
27374 @option{-march=68030}.
27378 Generate output for a 68040. This is the default when the compiler is
27379 configured for 68040-based systems. It is equivalent to
27380 @option{-march=68040}.
27382 This option inhibits the use of 68881/68882 instructions that have to be
27383 emulated by software on the 68040. Use this option if your 68040 does not
27384 have code to emulate those instructions.
27388 Generate output for a 68060. This is the default when the compiler is
27389 configured for 68060-based systems. It is equivalent to
27390 @option{-march=68060}.
27392 This option inhibits the use of 68020 and 68881/68882 instructions that
27393 have to be emulated by software on the 68060. Use this option if your 68060
27394 does not have code to emulate those instructions.
27398 Generate output for a CPU32. This is the default
27399 when the compiler is configured for CPU32-based systems.
27400 It is equivalent to @option{-march=cpu32}.
27402 Use this option for microcontrollers with a
27403 CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
27404 68336, 68340, 68341, 68349 and 68360.
27408 Generate output for a 520X ColdFire CPU@. This is the default
27409 when the compiler is configured for 520X-based systems.
27410 It is equivalent to @option{-mcpu=5206}, and is now deprecated
27411 in favor of that option.
27413 Use this option for microcontroller with a 5200 core, including
27414 the MCF5202, MCF5203, MCF5204 and MCF5206.
27418 Generate output for a 5206e ColdFire CPU@. The option is now
27419 deprecated in favor of the equivalent @option{-mcpu=5206e}.
27423 Generate output for a member of the ColdFire 528X family.
27424 The option is now deprecated in favor of the equivalent
27425 @option{-mcpu=528x}.
27429 Generate output for a ColdFire 5307 CPU@. The option is now deprecated
27430 in favor of the equivalent @option{-mcpu=5307}.
27434 Generate output for a ColdFire 5407 CPU@. The option is now deprecated
27435 in favor of the equivalent @option{-mcpu=5407}.
27439 Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
27440 This includes use of hardware floating-point instructions.
27441 The option is equivalent to @option{-mcpu=547x}, and is now
27442 deprecated in favor of that option.
27446 Generate output for a 68040, without using any of the new instructions.
27447 This results in code that can run relatively efficiently on either a
27448 68020/68881 or a 68030 or a 68040. The generated code does use the
27449 68881 instructions that are emulated on the 68040.
27451 The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
27455 Generate output for a 68060, without using any of the new instructions.
27456 This results in code that can run relatively efficiently on either a
27457 68020/68881 or a 68030 or a 68040. The generated code does use the
27458 68881 instructions that are emulated on the 68060.
27460 The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
27462 @opindex mhard-float
27466 Generate floating-point instructions. This is the default for 68020
27467 and above, and for ColdFire devices that have an FPU@. It defines the
27468 macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
27469 on ColdFire targets.
27471 @opindex msoft-float
27473 Do not generate floating-point instructions; use library calls instead.
27474 This is the default for 68000, 68010, and 68832 targets. It is also
27475 the default for ColdFire devices that have no FPU.
27481 Generate (do not generate) ColdFire hardware divide and remainder
27482 instructions. If @option{-march} is used without @option{-mcpu},
27483 the default is ``on'' for ColdFire architectures and ``off'' for M680x0
27484 architectures. Otherwise, the default is taken from the target CPU
27485 (either the default CPU, or the one specified by @option{-mcpu}). For
27486 example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
27487 @option{-mcpu=5206e}.
27489 GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
27493 Consider type @code{int} to be 16 bits wide, like @code{short int}.
27494 Additionally, parameters passed on the stack are also aligned to a
27495 16-bit boundary even on targets whose API mandates promotion to 32-bit.
27499 Do not consider type @code{int} to be 16 bits wide. This is the default.
27501 @opindex mnobitfield
27502 @opindex mno-bitfield
27504 @itemx -mno-bitfield
27505 Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
27506 and @option{-m5200} options imply @w{@option{-mnobitfield}}.
27510 Do use the bit-field instructions. The @option{-m68020} option implies
27511 @option{-mbitfield}. This is the default if you use a configuration
27512 designed for a 68020.
27516 Use a different function-calling convention, in which functions
27517 that take a fixed number of arguments return with the @code{rtd}
27518 instruction, which pops their arguments while returning. This
27519 saves one instruction in the caller since there is no need to pop
27520 the arguments there.
27522 This calling convention is incompatible with the one normally
27523 used on Unix, so you cannot use it if you need to call libraries
27524 compiled with the Unix compiler.
27526 Also, you must provide function prototypes for all functions that
27527 take variable numbers of arguments (including @code{printf});
27528 otherwise incorrect code is generated for calls to those
27531 In addition, seriously incorrect code results if you call a
27532 function with too many arguments. (Normally, extra arguments are
27533 harmlessly ignored.)
27535 The @code{rtd} instruction is supported by the 68010, 68020, 68030,
27536 68040, 68060 and CPU32 processors, but not by the 68000 or 5200.
27538 The default is @option{-mno-rtd}.
27540 @opindex malign-int
27541 @opindex mno-align-int
27543 @itemx -mno-align-int
27544 Control whether GCC aligns @code{int}, @code{long}, @code{long long},
27545 @code{float}, @code{double}, and @code{long double} variables on a 32-bit
27546 boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
27547 Aligning variables on 32-bit boundaries produces code that runs somewhat
27548 faster on processors with 32-bit busses at the expense of more memory.
27550 @strong{Warning:} if you use the @option{-malign-int} switch, GCC
27551 aligns structures containing the above types differently than
27552 most published application binary interface specifications for the m68k.
27555 Use the pc-relative addressing mode of the 68000 directly, instead of
27556 using a global offset table. At present, this option implies @option{-fpic},
27557 allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
27558 not presently supported with @option{-mpcrel}, though this could be supported for
27559 68020 and higher processors.
27561 @opindex mno-strict-align
27562 @opindex mstrict-align
27563 @item -mno-strict-align
27564 @itemx -mstrict-align
27565 Do not (do) assume that unaligned memory references are handled by
27569 Generate code that allows the data segment to be located in a different
27570 area of memory from the text segment. This allows for execute-in-place in
27571 an environment without virtual memory management. This option implies
27574 @item -mno-sep-data
27575 Generate code that assumes that the data segment follows the text segment.
27576 This is the default.
27578 @item -mid-shared-library
27579 Generate code that supports shared libraries via the library ID method.
27580 This allows for execute-in-place and shared libraries in an environment
27581 without virtual memory management. This option implies @option{-fPIC}.
27583 @item -mno-id-shared-library
27584 Generate code that doesn't assume ID-based shared libraries are being used.
27585 This is the default.
27587 @item -mshared-library-id=n
27588 Specifies the identification number of the ID-based shared library being
27589 compiled. Specifying a value of 0 generates more compact code; specifying
27590 other values forces the allocation of that number to the current
27591 library, but is no more space- or time-efficient than omitting this option.
27597 When generating position-independent code for ColdFire, generate code
27598 that works if the GOT has more than 8192 entries. This code is
27599 larger and slower than code generated without this option. On M680x0
27600 processors, this option is not needed; @option{-fPIC} suffices.
27602 GCC normally uses a single instruction to load values from the GOT@.
27603 While this is relatively efficient, it only works if the GOT
27604 is smaller than about 64k. Anything larger causes the linker
27605 to report an error such as:
27607 @cindex relocation truncated to fit (ColdFire)
27609 relocation truncated to fit: R_68K_GOT16O foobar
27612 If this happens, you should recompile your code with @option{-mxgot}.
27613 It should then work with very large GOTs. However, code generated with
27614 @option{-mxgot} is less efficient, since it takes 4 instructions to fetch
27615 the value of a global symbol.
27617 Note that some linkers, including newer versions of the GNU linker,
27618 can create multiple GOTs and sort GOT entries. If you have such a linker,
27619 you should only need to use @option{-mxgot} when compiling a single
27620 object file that accesses more than 8192 GOT entries. Very few do.
27622 These options have no effect unless GCC is generating
27623 position-independent code.
27625 @opindex mlong-jump-table-offsets
27626 @item -mlong-jump-table-offsets
27627 Use 32-bit offsets in @code{switch} tables. The default is to use
27632 @node MCore Options
27633 @subsection MCore Options
27634 @cindex MCore options
27636 These are the @samp{-m} options defined for the Motorola M*Core
27642 @opindex mno-hardlit
27644 @itemx -mno-hardlit
27645 Inline constants into the code stream if it can be done in two
27646 instructions or less.
27652 Use the divide instruction. (Enabled by default).
27654 @opindex mrelax-immediate
27655 @opindex mno-relax-immediate
27656 @item -mrelax-immediate
27657 @itemx -mno-relax-immediate
27658 Allow arbitrary-sized immediates in bit operations.
27660 @opindex mwide-bitfields
27661 @opindex mno-wide-bitfields
27662 @item -mwide-bitfields
27663 @itemx -mno-wide-bitfields
27664 Always treat bit-fields as @code{int}-sized.
27666 @opindex m4byte-functions
27667 @opindex mno-4byte-functions
27668 @item -m4byte-functions
27669 @itemx -mno-4byte-functions
27670 Force all functions to be aligned to a 4-byte boundary.
27672 @opindex mcallgraph-data
27673 @opindex mno-callgraph-data
27674 @item -mcallgraph-data
27675 @itemx -mno-callgraph-data
27676 Emit callgraph information.
27678 @opindex mslow-bytes
27679 @opindex mno-slow-bytes
27681 @itemx -mno-slow-bytes
27682 Prefer word access when reading byte quantities.
27684 @opindex mlittle-endian
27685 @opindex mbig-endian
27686 @item -mlittle-endian
27687 @itemx -mbig-endian
27688 Generate code for a little-endian target.
27694 Generate code for the 210 processor.
27698 Assume that runtime support has been provided and so omit the
27699 simulator library (@file{libsim.a)} from the linker command line.
27701 @opindex mstack-increment
27702 @item -mstack-increment=@var{size}
27703 Set the maximum amount for a single stack increment operation. Large
27704 values can increase the speed of programs that contain functions
27705 that need a large amount of stack space, but they can also trigger a
27706 segmentation fault if the stack is extended too much. The default
27711 @node MicroBlaze Options
27712 @subsection MicroBlaze Options
27713 @cindex MicroBlaze Options
27717 @opindex msoft-float
27719 Use software emulation for floating point (default).
27721 @opindex mhard-float
27723 Use hardware floating-point instructions.
27727 Do not optimize block moves, use @code{memcpy}.
27729 @opindex mno-clearbss
27730 @item -mno-clearbss
27731 This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
27734 @item -mcpu=@var{cpu-type}
27735 Use features of, and schedule code for, the given CPU.
27736 Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
27737 where @var{X} is a major version, @var{YY} is the minor version, and
27738 @var{Z} is compatibility code. Example values are @samp{v3.00.a},
27739 @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
27741 @opindex mxl-soft-mul
27742 @item -mxl-soft-mul
27743 Use software multiply emulation (default).
27745 @opindex mxl-soft-div
27746 @item -mxl-soft-div
27747 Use software emulation for divides (default).
27749 @opindex mxl-barrel-shift
27750 @item -mxl-barrel-shift
27751 Use the hardware barrel shifter.
27753 @opindex mxl-pattern-compare
27754 @item -mxl-pattern-compare
27755 Use pattern compare instructions.
27757 @opindex msmall-divides
27758 @item -msmall-divides
27759 Use table lookup optimization for small signed integer divisions.
27761 @opindex mxl-stack-check
27762 @item -mxl-stack-check
27763 This option is deprecated. Use @option{-fstack-check} instead.
27765 @opindex mxl-gp-opt
27767 Use GP-relative @code{.sdata}/@code{.sbss} sections.
27769 @opindex mxl-multiply-high
27770 @item -mxl-multiply-high
27771 Use multiply high instructions for high part of 32x32 multiply.
27773 @opindex mxl-float-convert
27774 @item -mxl-float-convert
27775 Use hardware floating-point conversion instructions.
27777 @opindex mxl-float-sqrt
27778 @item -mxl-float-sqrt
27779 Use hardware floating-point square root instruction.
27781 @opindex mbig-endian
27783 Generate code for a big-endian target.
27785 @opindex mlittle-endian
27786 @item -mlittle-endian
27787 Generate code for a little-endian target.
27789 @opindex mxl-reorder
27791 Use reorder instructions (swap and byte reversed load/store).
27793 @item -mxl-mode-@var{app-model}
27794 Select application model @var{app-model}. Valid models are
27797 normal executable (default), uses startup code @file{crt0.o}.
27800 for use with Xilinx Microprocessor Debugger (XMD) based
27801 software intrusive debug agent called xmdstub. This uses startup file
27802 @file{crt1.o} and sets the start address of the program to 0x800.
27805 for applications that are loaded using a bootloader.
27806 This model uses startup file @file{crt2.o} which does not contain a processor
27807 reset vector handler. This is suitable for transferring control on a
27808 processor reset to the bootloader rather than the application.
27811 for applications that do not require any of the
27812 MicroBlaze vectors. This option may be useful for applications running
27813 within a monitoring application. This model uses @file{crt3.o} as a startup file.
27816 Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
27817 @option{-mxl-mode-@var{app-model}}.
27819 @opindex mpic-data-is-text-relative
27820 @item -mpic-data-is-text-relative
27821 Assume that the displacement between the text and data segments is fixed
27822 at static link time. This allows data to be referenced by offset from start of
27823 text address instead of GOT since PC-relative addressing is not supported.
27828 @subsection MIPS Options
27829 @cindex MIPS options
27835 Generate big-endian code.
27839 Generate little-endian code. This is the default for @samp{mips*el-*-*}
27843 @item -march=@var{arch}
27844 Generate code that runs on @var{arch}, which can be the name of a
27845 generic MIPS ISA, or the name of a particular processor.
27847 @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
27848 @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
27849 @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
27850 @samp{mips64r5} and @samp{mips64r6}.
27851 The processor names are:
27852 @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
27853 @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
27854 @samp{5kc}, @samp{5kf},
27856 @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
27857 @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
27858 @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
27859 @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
27860 @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
27861 @samp{i6400}, @samp{i6500},
27863 @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
27864 @samp{gs464e}, @samp{gs264e},
27866 @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
27867 @samp{m5100}, @samp{m5101},
27868 @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
27870 @samp{p5600}, @samp{p6600},
27871 @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
27872 @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
27873 @samp{r6000}, @samp{r8000},
27874 @samp{rm7000}, @samp{rm9000},
27875 @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
27878 @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
27879 @samp{vr5000}, @samp{vr5400}, @samp{vr5500},
27880 @samp{xlr} and @samp{xlp}.
27881 The special value @samp{from-abi} selects the
27882 most compatible architecture for the selected ABI (that is,
27883 @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
27885 The native Linux/GNU toolchain also supports the value @samp{native},
27886 which selects the best architecture option for the host processor.
27887 @option{-march=native} has no effect if GCC does not recognize
27890 In processor names, a final @samp{000} can be abbreviated as @samp{k}
27891 (for example, @option{-march=r2k}). Prefixes are optional, and
27892 @samp{vr} may be written @samp{r}.
27894 Names of the form @samp{@var{n}f2_1} refer to processors with
27895 FPUs clocked at half the rate of the core, names of the form
27896 @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
27897 rate as the core, and names of the form @samp{@var{n}f3_2} refer to
27898 processors with FPUs clocked a ratio of 3:2 with respect to the core.
27899 For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
27900 for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
27901 accepted as synonyms for @samp{@var{n}f1_1}.
27903 GCC defines two macros based on the value of this option. The first
27904 is @code{_MIPS_ARCH}, which gives the name of target architecture, as
27905 a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
27906 where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
27907 For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
27908 to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
27910 Note that the @code{_MIPS_ARCH} macro uses the processor names given
27911 above. In other words, it has the full prefix and does not
27912 abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
27913 the macro names the resolved architecture (either @code{"mips1"} or
27914 @code{"mips3"}). It names the default architecture when no
27915 @option{-march} option is given.
27918 @item -mtune=@var{arch}
27919 Optimize for @var{arch}. Among other things, this option controls
27920 the way instructions are scheduled, and the perceived cost of arithmetic
27921 operations. The list of @var{arch} values is the same as for
27924 When this option is not used, GCC optimizes for the processor
27925 specified by @option{-march}. By using @option{-march} and
27926 @option{-mtune} together, it is possible to generate code that
27927 runs on a family of processors, but optimize the code for one
27928 particular member of that family.
27930 @option{-mtune} defines the macros @code{_MIPS_TUNE} and
27931 @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
27932 @option{-march} ones described above.
27936 Equivalent to @option{-march=mips1}.
27940 Equivalent to @option{-march=mips2}.
27944 Equivalent to @option{-march=mips3}.
27948 Equivalent to @option{-march=mips4}.
27952 Equivalent to @option{-march=mips32}.
27956 Equivalent to @option{-march=mips32r3}.
27960 Equivalent to @option{-march=mips32r5}.
27964 Equivalent to @option{-march=mips32r6}.
27968 Equivalent to @option{-march=mips64}.
27972 Equivalent to @option{-march=mips64r2}.
27976 Equivalent to @option{-march=mips64r3}.
27980 Equivalent to @option{-march=mips64r5}.
27984 Equivalent to @option{-march=mips64r6}.
27987 @opindex mno-mips16
27990 Generate (do not generate) MIPS16 code. If GCC is targeting a
27991 MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
27993 MIPS16 code generation can also be controlled on a per-function basis
27994 by means of @code{mips16} and @code{nomips16} attributes.
27995 @xref{Function Attributes}, for more information.
27998 @opindex mno-mips16e2
28000 @itemx -mno-mips16e2
28001 Use (do not use) the MIPS16e2 ASE. This option modifies the behavior
28002 of the @option{-mips16} option such that it targets the MIPS16e2 ASE@.
28004 @opindex mflip-mips16
28005 @item -mflip-mips16
28006 Generate MIPS16 code on alternating functions. This option is provided
28007 for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
28008 not intended for ordinary use in compiling user code.
28010 @opindex minterlink-compressed
28011 @opindex mno-interlink-compressed
28012 @item -minterlink-compressed
28013 @itemx -mno-interlink-compressed
28014 Require (do not require) that code using the standard (uncompressed) MIPS ISA
28015 be link-compatible with MIPS16 and microMIPS code, and vice versa.
28017 For example, code using the standard ISA encoding cannot jump directly
28018 to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
28019 @option{-minterlink-compressed} therefore disables direct jumps unless GCC
28020 knows that the target of the jump is not compressed.
28022 @opindex minterlink-mips16
28023 @opindex mno-interlink-mips16
28024 @item -minterlink-mips16
28025 @itemx -mno-interlink-mips16
28026 Aliases of @option{-minterlink-compressed} and
28027 @option{-mno-interlink-compressed}. These options predate the microMIPS ASE
28028 and are retained for backwards compatibility.
28036 Generate code for the given ABI@.
28038 Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
28039 generates 64-bit code when you select a 64-bit architecture, but you
28040 can use @option{-mgp32} to get 32-bit code instead.
28042 For information about the O64 ABI, see
28043 @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
28045 GCC supports a variant of the o32 ABI in which floating-point registers
28046 are 64 rather than 32 bits wide. You can select this combination with
28047 @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
28048 and @code{mfhc1} instructions and is therefore only supported for
28049 MIPS32R2, MIPS32R3 and MIPS32R5 processors.
28051 The register assignments for arguments and return values remain the
28052 same, but each scalar value is passed in a single 64-bit register
28053 rather than a pair of 32-bit registers. For example, scalar
28054 floating-point values are returned in @samp{$f0} only, not a
28055 @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
28056 remains the same in that the even-numbered double-precision registers
28059 Two additional variants of the o32 ABI are supported to enable
28060 a transition from 32-bit to 64-bit registers. These are FPXX
28061 (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
28062 The FPXX extension mandates that all code must execute correctly
28063 when run using 32-bit or 64-bit registers. The code can be interlinked
28064 with either FP32 or FP64, but not both.
28065 The FP64A extension is similar to the FP64 extension but forbids the
28066 use of odd-numbered single-precision registers. This can be used
28067 in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
28068 processors and allows both FP32 and FP64A code to interlink and
28069 run in the same process without changing FPU modes.
28072 @opindex mno-abicalls
28074 @itemx -mno-abicalls
28075 Generate (do not generate) code that is suitable for SVR4-style
28076 dynamic objects. @option{-mabicalls} is the default for SVR4-based
28081 Generate (do not generate) code that is fully position-independent,
28082 and that can therefore be linked into shared libraries. This option
28083 only affects @option{-mabicalls}.
28085 All @option{-mabicalls} code has traditionally been position-independent,
28086 regardless of options like @option{-fPIC} and @option{-fpic}. However,
28087 as an extension, the GNU toolchain allows executables to use absolute
28088 accesses for locally-binding symbols. It can also use shorter GP
28089 initialization sequences and generate direct calls to locally-defined
28090 functions. This mode is selected by @option{-mno-shared}.
28092 @option{-mno-shared} depends on binutils 2.16 or higher and generates
28093 objects that can only be linked by the GNU linker. However, the option
28094 does not affect the ABI of the final executable; it only affects the ABI
28095 of relocatable objects. Using @option{-mno-shared} generally makes
28096 executables both smaller and quicker.
28098 @option{-mshared} is the default.
28104 Assume (do not assume) that the static and dynamic linkers
28105 support PLTs and copy relocations. This option only affects
28106 @option{-mno-shared -mabicalls}. For the n64 ABI, this option
28107 has no effect without @option{-msym32}.
28109 You can make @option{-mplt} the default by configuring
28110 GCC with @option{--with-mips-plt}. The default is
28111 @option{-mno-plt} otherwise.
28117 Lift (do not lift) the usual restrictions on the size of the global
28120 GCC normally uses a single instruction to load values from the GOT@.
28121 While this is relatively efficient, it only works if the GOT
28122 is smaller than about 64k. Anything larger causes the linker
28123 to report an error such as:
28125 @cindex relocation truncated to fit (MIPS)
28127 relocation truncated to fit: R_MIPS_GOT16 foobar
28130 If this happens, you should recompile your code with @option{-mxgot}.
28131 This works with very large GOTs, although the code is also
28132 less efficient, since it takes three instructions to fetch the
28133 value of a global symbol.
28135 Note that some linkers can create multiple GOTs. If you have such a
28136 linker, you should only need to use @option{-mxgot} when a single object
28137 file accesses more than 64k's worth of GOT entries. Very few do.
28139 These options have no effect unless GCC is generating position
28144 Assume that general-purpose registers are 32 bits wide.
28148 Assume that general-purpose registers are 64 bits wide.
28152 Assume that floating-point registers are 32 bits wide.
28156 Assume that floating-point registers are 64 bits wide.
28160 Do not assume the width of floating-point registers.
28162 @opindex mhard-float
28164 Use floating-point coprocessor instructions.
28166 @opindex msoft-float
28168 Do not use floating-point coprocessor instructions. Implement
28169 floating-point calculations using library calls instead.
28173 Equivalent to @option{-msoft-float}, but additionally asserts that the
28174 program being compiled does not perform any floating-point operations.
28175 This option is presently supported only by some bare-metal MIPS
28176 configurations, where it may select a special set of libraries
28177 that lack all floating-point support (including, for example, the
28178 floating-point @code{printf} formats).
28179 If code compiled with @option{-mno-float} accidentally contains
28180 floating-point operations, it is likely to suffer a link-time
28181 or run-time failure.
28183 @opindex msingle-float
28184 @item -msingle-float
28185 Assume that the floating-point coprocessor only supports single-precision
28188 @opindex mdouble-float
28189 @item -mdouble-float
28190 Assume that the floating-point coprocessor supports double-precision
28191 operations. This is the default.
28193 @opindex modd-spreg
28194 @opindex mno-odd-spreg
28196 @itemx -mno-odd-spreg
28197 Enable the use of odd-numbered single-precision floating-point registers
28198 for the o32 ABI. This is the default for processors that are known to
28199 support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
28203 @opindex mabs=legacy
28205 @itemx -mabs=legacy
28206 These options control the treatment of the special not-a-number (NaN)
28207 IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
28208 @code{neg.@i{fmt}} machine instructions.
28210 By default or when @option{-mabs=legacy} is used the legacy
28211 treatment is selected. In this case these instructions are considered
28212 arithmetic and avoided where correct operation is required and the
28213 input operand might be a NaN. A longer sequence of instructions that
28214 manipulate the sign bit of floating-point datum manually is used
28215 instead unless the @option{-ffinite-math-only} option has also been
28218 The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
28219 this case these instructions are considered non-arithmetic and therefore
28220 operating correctly in all cases, including in particular where the
28221 input operand is a NaN. These instructions are therefore always used
28222 for the respective operations.
28225 @opindex mnan=legacy
28227 @itemx -mnan=legacy
28228 These options control the encoding of the special not-a-number (NaN)
28229 IEEE 754 floating-point data.
28231 The @option{-mnan=legacy} option selects the legacy encoding. In this
28232 case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
28233 significand field being 0, whereas signaling NaNs (sNaNs) are denoted
28234 by the first bit of their trailing significand field being 1.
28236 The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
28237 this case qNaNs are denoted by the first bit of their trailing
28238 significand field being 1, whereas sNaNs are denoted by the first bit of
28239 their trailing significand field being 0.
28241 The default is @option{-mnan=legacy} unless GCC has been configured with
28242 @option{--with-nan=2008}.
28248 Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
28249 implement atomic memory built-in functions. When neither option is
28250 specified, GCC uses the instructions if the target architecture
28253 @option{-mllsc} is useful if the runtime environment can emulate the
28254 instructions and @option{-mno-llsc} can be useful when compiling for
28255 nonstandard ISAs. You can make either option the default by
28256 configuring GCC with @option{--with-llsc} and @option{--without-llsc}
28257 respectively. @option{--with-llsc} is the default for some
28258 configurations; see the installation documentation for details.
28264 Use (do not use) revision 1 of the MIPS DSP ASE@.
28265 @xref{MIPS DSP Built-in Functions}. This option defines the
28266 preprocessor macro @code{__mips_dsp}. It also defines
28267 @code{__mips_dsp_rev} to 1.
28273 Use (do not use) revision 2 of the MIPS DSP ASE@.
28274 @xref{MIPS DSP Built-in Functions}. This option defines the
28275 preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
28276 It also defines @code{__mips_dsp_rev} to 2.
28278 @opindex msmartmips
28279 @opindex mno-smartmips
28281 @itemx -mno-smartmips
28282 Use (do not use) the MIPS SmartMIPS ASE.
28284 @opindex mpaired-single
28285 @opindex mno-paired-single
28286 @item -mpaired-single
28287 @itemx -mno-paired-single
28288 Use (do not use) paired-single floating-point instructions.
28289 @xref{MIPS Paired-Single Support}. This option requires
28290 hardware floating-point support to be enabled.
28296 Use (do not use) MIPS Digital Media Extension instructions.
28297 This option can only be used when generating 64-bit code and requires
28298 hardware floating-point support to be enabled.
28301 @opindex mno-mips3d
28304 Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
28305 The option @option{-mips3d} implies @option{-mpaired-single}.
28307 @opindex mmicromips
28308 @opindex mno-mmicromips
28310 @itemx -mno-micromips
28311 Generate (do not generate) microMIPS code.
28313 MicroMIPS code generation can also be controlled on a per-function basis
28314 by means of @code{micromips} and @code{nomicromips} attributes.
28315 @xref{Function Attributes}, for more information.
28321 Use (do not use) MT Multithreading instructions.
28327 Use (do not use) the MIPS MCU ASE instructions.
28333 Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
28339 Use (do not use) the MIPS Virtualization (VZ) instructions.
28345 Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
28351 Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
28357 Use (do not use) the MIPS Global INValidate (GINV) instructions.
28359 @opindex mloongson-mmi
28360 @opindex mno-loongson-mmi
28361 @item -mloongson-mmi
28362 @itemx -mno-loongson-mmi
28363 Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
28365 @opindex mloongson-ext
28366 @opindex mno-loongson-ext
28367 @item -mloongson-ext
28368 @itemx -mno-loongson-ext
28369 Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
28371 @opindex mloongson-ext2
28372 @opindex mno-loongson-ext2
28373 @item -mloongson-ext2
28374 @itemx -mno-loongson-ext2
28375 Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
28379 Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
28380 an explanation of the default and the way that the pointer size is
28385 Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
28387 The default size of @code{int}s, @code{long}s and pointers depends on
28388 the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
28389 uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
28390 32-bit @code{long}s. Pointers are the same size as @code{long}s,
28391 or the same size as integer registers, whichever is smaller.
28397 Assume (do not assume) that all symbols have 32-bit values, regardless
28398 of the selected ABI@. This option is useful in combination with
28399 @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
28400 to generate shorter and faster references to symbolic addresses.
28404 Put definitions of externally-visible data in a small data section
28405 if that data is no bigger than @var{num} bytes. GCC can then generate
28406 more efficient accesses to the data; see @option{-mgpopt} for details.
28408 The default @option{-G} option depends on the configuration.
28410 @opindex mlocal-sdata
28411 @opindex mno-local-sdata
28412 @item -mlocal-sdata
28413 @itemx -mno-local-sdata
28414 Extend (do not extend) the @option{-G} behavior to local data too,
28415 such as to static variables in C@. @option{-mlocal-sdata} is the
28416 default for all configurations.
28418 If the linker complains that an application is using too much small data,
28419 you might want to try rebuilding the less performance-critical parts with
28420 @option{-mno-local-sdata}. You might also want to build large
28421 libraries with @option{-mno-local-sdata}, so that the libraries leave
28422 more room for the main program.
28424 @opindex mextern-sdata
28425 @opindex mno-extern-sdata
28426 @item -mextern-sdata
28427 @itemx -mno-extern-sdata
28428 Assume (do not assume) that externally-defined data is in
28429 a small data section if the size of that data is within the @option{-G} limit.
28430 @option{-mextern-sdata} is the default for all configurations.
28432 If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
28433 @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
28434 that is no bigger than @var{num} bytes, you must make sure that @var{Var}
28435 is placed in a small data section. If @var{Var} is defined by another
28436 module, you must either compile that module with a high-enough
28437 @option{-G} setting or attach a @code{section} attribute to @var{Var}'s
28438 definition. If @var{Var} is common, you must link the application
28439 with a high-enough @option{-G} setting.
28441 The easiest way of satisfying these restrictions is to compile
28442 and link every module with the same @option{-G} option. However,
28443 you may wish to build a library that supports several different
28444 small data limits. You can do this by compiling the library with
28445 the highest supported @option{-G} setting and additionally using
28446 @option{-mno-extern-sdata} to stop the library from making assumptions
28447 about externally-defined data.
28453 Use (do not use) GP-relative accesses for symbols that are known to be
28454 in a small data section; see @option{-G}, @option{-mlocal-sdata} and
28455 @option{-mextern-sdata}. @option{-mgpopt} is the default for all
28458 @option{-mno-gpopt} is useful for cases where the @code{$gp} register
28459 might not hold the value of @code{_gp}. For example, if the code is
28460 part of a library that might be used in a boot monitor, programs that
28461 call boot monitor routines pass an unknown value in @code{$gp}.
28462 (In such situations, the boot monitor itself is usually compiled
28463 with @option{-G0}.)
28465 @option{-mno-gpopt} implies @option{-mno-local-sdata} and
28466 @option{-mno-extern-sdata}.
28468 @opindex membedded-data
28469 @opindex mno-embedded-data
28470 @item -membedded-data
28471 @itemx -mno-embedded-data
28472 Allocate variables to the read-only data section first if possible, then
28473 next in the small data section if possible, otherwise in data. This gives
28474 slightly slower code than the default, but reduces the amount of RAM required
28475 when executing, and thus may be preferred for some embedded systems.
28477 @opindex muninit-const-in-rodata
28478 @opindex mno-uninit-const-in-rodata
28479 @item -muninit-const-in-rodata
28480 @itemx -mno-uninit-const-in-rodata
28481 Put uninitialized @code{const} variables in the read-only data section.
28482 This option is only meaningful in conjunction with @option{-membedded-data}.
28484 @opindex mcode-readable
28485 @item -mcode-readable=@var{setting}
28486 Specify whether GCC may generate code that reads from executable sections.
28487 There are three possible settings:
28490 @item -mcode-readable=yes
28491 Instructions may freely access executable sections. This is the
28494 @item -mcode-readable=pcrel
28495 MIPS16 PC-relative load instructions can access executable sections,
28496 but other instructions must not do so. This option is useful on 4KSc
28497 and 4KSd processors when the code TLBs have the Read Inhibit bit set.
28498 It is also useful on processors that can be configured to have a dual
28499 instruction/data SRAM interface and that, like the M4K, automatically
28500 redirect PC-relative loads to the instruction RAM.
28502 @item -mcode-readable=no
28503 Instructions must not access executable sections. This option can be
28504 useful on targets that are configured to have a dual instruction/data
28505 SRAM interface but that (unlike the M4K) do not automatically redirect
28506 PC-relative loads to the instruction RAM.
28509 @opindex msplit-addresses
28510 @opindex mno-split-addresses
28511 @item -msplit-addresses
28512 @itemx -mno-split-addresses
28513 Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
28514 relocation operators. This option has been superseded by
28515 @option{-mexplicit-relocs} but is retained for backwards compatibility.
28517 @opindex mexplicit-relocs
28518 @opindex mno-explicit-relocs
28519 @item -mexplicit-relocs=none
28520 @itemx -mexplicit-relocs=base
28521 @itemx -mexplicit-relocs=pcrel
28522 @itemx -mexplicit-relocs
28523 @itemx -mno-explicit-relocs
28524 These options control whether explicit relocs (such as %gp_rel) are used.
28525 The default value depends on the version of GAS when GCC itself was built.
28527 The @code{base} explicit-relocs support introdunced into GAS in 2001.
28528 The @code{pcrel} explicit-relocs support introdunced into GAS in 2014,
28529 which supports @code{%pcrel_hi} and @code{%pcrel_lo}.
28531 @opindex mcheck-zero-division
28532 @opindex mno-check-zero-division
28533 @item -mcheck-zero-division
28534 @itemx -mno-check-zero-division
28535 Trap (do not trap) on integer division by zero.
28537 The default is @option{-mcheck-zero-division}.
28539 @opindex mdivide-traps
28540 @opindex mdivide-breaks
28541 @item -mdivide-traps
28542 @itemx -mdivide-breaks
28543 MIPS systems check for division by zero by generating either a
28544 conditional trap or a break instruction. Using traps results in
28545 smaller code, but is only supported on MIPS II and later. Also, some
28546 versions of the Linux kernel have a bug that prevents trap from
28547 generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
28548 allow conditional traps on architectures that support them and
28549 @option{-mdivide-breaks} to force the use of breaks.
28551 The default is usually @option{-mdivide-traps}, but this can be
28552 overridden at configure time using @option{--with-divide=breaks}.
28553 Divide-by-zero checks can be completely disabled using
28554 @option{-mno-check-zero-division}.
28556 @opindex mload-store-pairs
28557 @opindex mno-load-store-pairs
28558 @item -mload-store-pairs
28559 @itemx -mno-load-store-pairs
28560 Enable (disable) an optimization that pairs consecutive load or store
28561 instructions to enable load/store bonding. This option is enabled by
28562 default but only takes effect when the selected architecture is known
28563 to support bonding.
28565 @opindex mstrict-align
28566 @opindex mno-strict-align
28567 @opindex munaligned-access
28568 @opindex mno-unaligned-access
28569 @item -mstrict-align
28570 @itemx -mno-strict-align
28571 @itemx -munaligned-access
28572 @itemx -mno-unaligned-access
28573 Disable (enable) direct unaligned access for MIPS Release 6.
28574 MIPSr6 requires load/store unaligned-access support, by hardware or
28575 trap&emulate. So @option{-mstrict-align} may be needed by kernel. The
28576 options @option{-munaligned-access} and @option{-mno-unaligned-access}
28577 are obsoleted, and only for backward-compatible.
28580 @opindex mno-memcpy
28583 Force (do not force) the use of @code{memcpy} for non-trivial block
28584 moves. The default is @option{-mno-memcpy}, which allows GCC to inline
28585 most constant-sized copies.
28587 @opindex mlong-calls
28588 @opindex mno-long-calls
28590 @itemx -mno-long-calls
28591 Disable (do not disable) use of the @code{jal} instruction. Calling
28592 functions using @code{jal} is more efficient but requires the caller
28593 and callee to be in the same 256 megabyte segment.
28595 This option has no effect on abicalls code. The default is
28596 @option{-mno-long-calls}.
28602 Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
28603 instructions, as provided by the R4650 ISA@.
28609 Enable (disable) use of the @code{madd} and @code{msub} integer
28610 instructions. The default is @option{-mimadd} on architectures
28611 that support @code{madd} and @code{msub} except for the 74k
28612 architecture where it was found to generate slower code.
28614 @opindex mfused-madd
28615 @opindex mno-fused-madd
28617 @itemx -mno-fused-madd
28618 Enable (disable) use of the floating-point multiply-accumulate
28619 instructions, when they are available. The default is
28620 @option{-mfused-madd}.
28622 On the R8000 CPU when multiply-accumulate instructions are used,
28623 the intermediate product is calculated to infinite precision
28624 and is not subject to the FCSR Flush to Zero bit. This may be
28625 undesirable in some circumstances. On other processors the result
28626 is numerically identical to the equivalent computation using
28627 separate multiply, add, subtract and negate instructions.
28631 Tell the MIPS assembler to not run its preprocessor over user
28632 assembler files (with a @samp{.s} suffix) when assembling them.
28635 @opindex mno-fix-24k
28637 @itemx -mno-fix-24k
28638 Work around the 24K E48 (lost data on stores during refill) errata.
28639 The workarounds are implemented by the assembler rather than by GCC@.
28641 @opindex mfix-r4000
28642 @opindex mno-fix-r4000
28644 @itemx -mno-fix-r4000
28645 Work around certain R4000 CPU errata:
28648 A double-word or a variable shift may give an incorrect result if executed
28649 immediately after starting an integer division.
28651 A double-word or a variable shift may give an incorrect result if executed
28652 while an integer multiplication is in progress.
28654 An integer division may give an incorrect result if started in a delay slot
28655 of a taken branch or a jump.
28658 @opindex mfix-r4400
28659 @opindex mno-fix-r4400
28661 @itemx -mno-fix-r4400
28662 Work around certain R4400 CPU errata:
28665 A double-word or a variable shift may give an incorrect result if executed
28666 immediately after starting an integer division.
28669 @opindex mfix-r10000
28670 @opindex mno-fix-r10000
28672 @itemx -mno-fix-r10000
28673 Work around certain R10000 errata:
28676 @code{ll}/@code{sc} sequences may not behave atomically on revisions
28677 prior to 3.0. They may deadlock on revisions 2.6 and earlier.
28680 This option can only be used if the target architecture supports
28681 branch-likely instructions. @option{-mfix-r10000} is the default when
28682 @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
28685 @opindex mfix-r5900
28687 @itemx -mno-fix-r5900
28688 Do not attempt to schedule the preceding instruction into the delay slot
28689 of a branch instruction placed at the end of a short loop of six
28690 instructions or fewer and always schedule a @code{nop} instruction there
28691 instead. The short loop bug under certain conditions causes loops to
28692 execute only once or twice, due to a hardware bug in the R5900 chip. The
28693 workaround is implemented by the assembler rather than by GCC@.
28695 @opindex mfix-rm7000
28697 @itemx -mno-fix-rm7000
28698 Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
28699 workarounds are implemented by the assembler rather than by GCC@.
28701 @opindex mfix-vr4120
28703 @itemx -mno-fix-vr4120
28704 Work around certain VR4120 errata:
28707 @code{dmultu} does not always produce the correct result.
28709 @code{div} and @code{ddiv} do not always produce the correct result if one
28710 of the operands is negative.
28712 The workarounds for the division errata rely on special functions in
28713 @file{libgcc.a}. At present, these functions are only provided by
28714 the @code{mips64vr*-elf} configurations.
28716 Other VR4120 errata require a NOP to be inserted between certain pairs of
28717 instructions. These errata are handled by the assembler, not by GCC itself.
28719 @opindex mfix-vr4130
28721 Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
28722 workarounds are implemented by the assembler rather than by GCC,
28723 although GCC avoids using @code{mflo} and @code{mfhi} if the
28724 VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
28725 instructions are available instead.
28729 @itemx -mno-fix-sb1
28730 Work around certain SB-1 CPU core errata.
28731 (This flag currently works around the SB-1 revision 2
28732 ``F1'' and ``F2'' floating-point errata.)
28734 @opindex mr10k-cache-barrier
28735 @item -mr10k-cache-barrier=@var{setting}
28736 Specify whether GCC should insert cache barriers to avoid the
28737 side effects of speculation on R10K processors.
28739 In common with many processors, the R10K tries to predict the outcome
28740 of a conditional branch and speculatively executes instructions from
28741 the ``taken'' branch. It later aborts these instructions if the
28742 predicted outcome is wrong. However, on the R10K, even aborted
28743 instructions can have side effects.
28745 This problem only affects kernel stores and, depending on the system,
28746 kernel loads. As an example, a speculatively-executed store may load
28747 the target memory into cache and mark the cache line as dirty, even if
28748 the store itself is later aborted. If a DMA operation writes to the
28749 same area of memory before the ``dirty'' line is flushed, the cached
28750 data overwrites the DMA-ed data. See the R10K processor manual
28751 for a full description, including other potential problems.
28753 One workaround is to insert cache barrier instructions before every memory
28754 access that might be speculatively executed and that might have side
28755 effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
28756 controls GCC's implementation of this workaround. It assumes that
28757 aborted accesses to any byte in the following regions does not have
28762 the memory occupied by the current function's stack frame;
28765 the memory occupied by an incoming stack argument;
28768 the memory occupied by an object with a link-time-constant address.
28771 It is the kernel's responsibility to ensure that speculative
28772 accesses to these regions are indeed safe.
28774 If the input program contains a function declaration such as:
28780 then the implementation of @code{foo} must allow @code{j foo} and
28781 @code{jal foo} to be executed speculatively. GCC honors this
28782 restriction for functions it compiles itself. It expects non-GCC
28783 functions (such as hand-written assembly code) to do the same.
28785 The option has three forms:
28788 @item -mr10k-cache-barrier=load-store
28789 Insert a cache barrier before a load or store that might be
28790 speculatively executed and that might have side effects even
28793 @item -mr10k-cache-barrier=store
28794 Insert a cache barrier before a store that might be speculatively
28795 executed and that might have side effects even if aborted.
28797 @item -mr10k-cache-barrier=none
28798 Disable the insertion of cache barriers. This is the default setting.
28801 @opindex mflush-func
28802 @opindex mno-flush-func
28803 @item -mflush-func=@var{func}
28804 @itemx -mno-flush-func
28805 Specifies the function to call to flush the I and D caches, or to not
28806 call any such function. If called, the function must take the same
28807 arguments as the common @code{_flush_func}, that is, the address of the
28808 memory range for which the cache is being flushed, the size of the
28809 memory range, and the number 3 (to flush both caches). The default
28810 depends on the target GCC was configured for, but commonly is either
28811 @code{_flush_func} or @code{__cpu_flush}.
28813 @opindex mbranch-cost
28814 @item -mbranch-cost=@var{num}
28815 Set the cost of branches to roughly @var{num} ``simple'' instructions.
28816 This cost is only a heuristic and is not guaranteed to produce
28817 consistent results across releases. A zero cost redundantly selects
28818 the default, which is based on the @option{-mtune} setting.
28820 @opindex mbranch-likely
28821 @opindex mno-branch-likely
28822 @item -mbranch-likely
28823 @itemx -mno-branch-likely
28824 Enable or disable use of Branch Likely instructions, regardless of the
28825 default for the selected architecture. By default, Branch Likely
28826 instructions may be generated if they are supported by the selected
28827 architecture. An exception is for the MIPS32 and MIPS64 architectures
28828 and processors that implement those architectures; for those, Branch
28829 Likely instructions are not be generated by default because the MIPS32
28830 and MIPS64 architectures specifically deprecate their use.
28832 @opindex mcompact-branches=never
28833 @opindex mcompact-branches=optimal
28834 @opindex mcompact-branches=always
28835 @item -mcompact-branches=never
28836 @itemx -mcompact-branches=optimal
28837 @itemx -mcompact-branches=always
28838 These options control which form of branches will be generated. The
28839 default is @option{-mcompact-branches=optimal}.
28841 The @option{-mcompact-branches=never} option ensures that compact branch
28842 instructions will never be generated.
28844 The @option{-mcompact-branches=always} option ensures that a compact
28845 branch instruction will be generated if available for MIPS Release 6 onwards.
28846 If a compact branch instruction is not available (or pre-R6),
28847 a delay slot form of the branch will be used instead.
28849 If it is used for MIPS16/microMIPS targets, it will be just ignored now.
28850 The behaviour for MIPS16/microMIPS may change in future,
28851 since they do have some compact branch instructions.
28853 The @option{-mcompact-branches=optimal} option will cause a delay slot
28854 branch to be used if one is available in the current ISA and the delay
28855 slot is successfully filled. If the delay slot is not filled, a compact
28856 branch will be chosen if one is available.
28858 @opindex mfp-exceptions
28859 @item -mfp-exceptions
28860 @itemx -mno-fp-exceptions
28861 Specifies whether FP exceptions are enabled. This affects how
28862 FP instructions are scheduled for some processors.
28863 The default is that FP exceptions are
28866 For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
28867 64-bit code, then we can use both FP pipes. Otherwise, we can only use one
28870 @opindex mvr4130-align
28871 @item -mvr4130-align
28872 @itemx -mno-vr4130-align
28873 The VR4130 pipeline is two-way superscalar, but can only issue two
28874 instructions together if the first one is 8-byte aligned. When this
28875 option is enabled, GCC aligns pairs of instructions that it
28876 thinks should execute in parallel.
28878 This option only has an effect when optimizing for the VR4130.
28879 It normally makes code faster, but at the expense of making it bigger.
28880 It is enabled by default at optimization level @option{-O3}.
28885 Enable (disable) generation of @code{synci} instructions on
28886 architectures that support it. The @code{synci} instructions (if
28887 enabled) are generated when @code{__builtin___clear_cache} is
28890 This option defaults to @option{-mno-synci}, but the default can be
28891 overridden by configuring GCC with @option{--with-synci}.
28893 When compiling code for single processor systems, it is generally safe
28894 to use @code{synci}. However, on many multi-core (SMP) systems, it
28895 does not invalidate the instruction caches on all cores and may lead
28896 to undefined behavior.
28898 @opindex mrelax-pic-calls
28899 @item -mrelax-pic-calls
28900 @itemx -mno-relax-pic-calls
28901 Try to turn PIC calls that are normally dispatched via register
28902 @code{$25} into direct calls. This is only possible if the linker can
28903 resolve the destination at link time and if the destination is within
28904 range for a direct call.
28906 @option{-mrelax-pic-calls} is the default if GCC was configured to use
28907 an assembler and a linker that support the @code{.reloc} assembly
28908 directive and @option{-mexplicit-relocs} is in effect. With
28909 @option{-mno-explicit-relocs}, this optimization can be performed by the
28910 assembler and the linker alone without help from the compiler.
28912 @opindex mmcount-ra-address
28913 @opindex mno-mcount-ra-address
28914 @item -mmcount-ra-address
28915 @itemx -mno-mcount-ra-address
28916 Emit (do not emit) code that allows @code{_mcount} to modify the
28917 calling function's return address. When enabled, this option extends
28918 the usual @code{_mcount} interface with a new @var{ra-address}
28919 parameter, which has type @code{intptr_t *} and is passed in register
28920 @code{$12}. @code{_mcount} can then modify the return address by
28921 doing both of the following:
28924 Returning the new address in register @code{$31}.
28926 Storing the new address in @code{*@var{ra-address}},
28927 if @var{ra-address} is nonnull.
28930 The default is @option{-mno-mcount-ra-address}.
28932 @opindex mframe-header-opt
28933 @item -mframe-header-opt
28934 @itemx -mno-frame-header-opt
28935 Enable (disable) frame header optimization in the o32 ABI. When using the
28936 o32 ABI, calling functions will allocate 16 bytes on the stack for the called
28937 function to write out register arguments. When enabled, this optimization
28938 will suppress the allocation of the frame header if it can be determined that
28941 This optimization is off by default at all optimization levels.
28943 @opindex mlxc1-sxc1
28945 @itemx -mno-lxc1-sxc1
28946 When applicable, enable (disable) the generation of @code{lwxc1},
28947 @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
28952 When applicable, enable (disable) the generation of 4-operand @code{madd.s},
28953 @code{madd.d} and related instructions. Enabled by default.
28958 @subsection MMIX Options
28959 @cindex MMIX Options
28961 These options are defined for the MMIX:
28965 @opindex mno-libfuncs
28967 @itemx -mno-libfuncs
28968 Specify that intrinsic library functions are being compiled, passing all
28969 values in registers, no matter the size.
28972 @opindex mno-epsilon
28974 @itemx -mno-epsilon
28975 Generate floating-point comparison instructions that compare with respect
28976 to the @code{rE} epsilon register.
28978 @opindex mabi=mmixware
28980 @item -mabi=mmixware
28982 Generate code that passes function parameters and return values that (in
28983 the called function) are seen as registers @code{$0} and up, as opposed to
28984 the GNU ABI which uses global registers @code{$231} and up.
28986 @opindex mzero-extend
28987 @opindex mno-zero-extend
28988 @item -mzero-extend
28989 @itemx -mno-zero-extend
28990 When reading data from memory in sizes shorter than 64 bits, use (do not
28991 use) zero-extending load instructions by default, rather than
28992 sign-extending ones.
28995 @opindex mno-knuthdiv
28997 @itemx -mno-knuthdiv
28998 Make the result of a division yielding a remainder have the same sign as
28999 the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
29000 remainder follows the sign of the dividend. Both methods are
29001 arithmetically valid, the latter being almost exclusively used.
29003 @opindex mtoplevel-symbols
29004 @opindex mno-toplevel-symbols
29005 @item -mtoplevel-symbols
29006 @itemx -mno-toplevel-symbols
29007 Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
29008 code can be used with the @code{PREFIX} assembly directive.
29012 Generate an executable in the ELF format, rather than the default
29013 @samp{mmo} format used by the @command{mmix} simulator.
29015 @opindex mbranch-predict
29016 @opindex mno-branch-predict
29017 @item -mbranch-predict
29018 @itemx -mno-branch-predict
29019 Use (do not use) the probable-branch instructions, when static branch
29020 prediction indicates a probable branch.
29022 @opindex mbase-addresses
29023 @opindex mno-base-addresses
29024 @item -mbase-addresses
29025 @itemx -mno-base-addresses
29026 Generate (do not generate) code that uses @emph{base addresses}. Using a
29027 base address automatically generates a request (handled by the assembler
29028 and the linker) for a constant to be set up in a global register. The
29029 register is used for one or more base address requests within the range 0
29030 to 255 from the value held in the register. The generally leads to short
29031 and fast code, but the number of different data items that can be
29032 addressed is limited. This means that a program that uses lots of static
29033 data may require @option{-mno-base-addresses}.
29035 @opindex msingle-exit
29036 @opindex mno-single-exit
29037 @item -msingle-exit
29038 @itemx -mno-single-exit
29039 Force (do not force) generated code to have a single exit point in each
29043 @node MN10300 Options
29044 @subsection MN10300 Options
29045 @cindex MN10300 options
29047 These @option{-m} options are defined for Matsushita MN10300 architectures:
29052 Generate code to avoid bugs in the multiply instructions for the MN10300
29053 processors. This is the default.
29055 @opindex mno-mult-bug
29056 @item -mno-mult-bug
29057 Do not generate code to avoid bugs in the multiply instructions for the
29058 MN10300 processors.
29062 Generate code using features specific to the AM33 processor.
29066 Do not generate code using features specific to the AM33 processor. This
29071 Generate code using features specific to the AM33/2.0 processor.
29075 Generate code using features specific to the AM34 processor.
29078 @item -mtune=@var{cpu-type}
29079 Use the timing characteristics of the indicated CPU type when
29080 scheduling instructions. This does not change the targeted processor
29081 type. The CPU type must be one of @samp{mn10300}, @samp{am33},
29082 @samp{am33-2} or @samp{am34}.
29084 @opindex mreturn-pointer-on-d0
29085 @item -mreturn-pointer-on-d0
29086 When generating a function that returns a pointer, return the pointer
29087 in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
29088 only in @code{a0}, and attempts to call such functions without a prototype
29089 result in errors. Note that this option is on by default; use
29090 @option{-mno-return-pointer-on-d0} to disable it.
29094 Do not link in the C run-time initialization object file.
29098 Indicate to the linker that it should perform a relaxation optimization pass
29099 to shorten branches, calls and absolute memory addresses. This option only
29100 has an effect when used on the command line for the final link step.
29102 This option makes symbolic debugging impossible.
29106 Allow the compiler to generate @emph{Long Instruction Word}
29107 instructions if the target is the @samp{AM33} or later. This is the
29108 default. This option defines the preprocessor macro @code{__LIW__}.
29112 Do not allow the compiler to generate @emph{Long Instruction Word}
29113 instructions. This option defines the preprocessor macro
29118 Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
29119 instructions if the target is the @samp{AM33} or later. This is the
29120 default. This option defines the preprocessor macro @code{__SETLB__}.
29124 Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
29125 instructions. This option defines the preprocessor macro
29126 @code{__NO_SETLB__}.
29130 @node Moxie Options
29131 @subsection Moxie Options
29132 @cindex Moxie Options
29138 Generate big-endian code. This is the default for @samp{moxie-*-*}
29143 Generate little-endian code.
29147 Generate mul.x and umul.x instructions. This is the default for
29148 @samp{moxiebox-*-*} configurations.
29152 Do not link in the C run-time initialization object file.
29156 @node MSP430 Options
29157 @subsection MSP430 Options
29158 @cindex MSP430 Options
29160 These options are defined for the MSP430:
29166 Force assembly output to always use hex constants. Normally such
29167 constants are signed decimals, but this option is available for
29168 testsuite and/or aesthetic purposes.
29172 Select the MCU to target. This is used to create a C preprocessor
29173 symbol based upon the MCU name, converted to upper case and pre- and
29174 post-fixed with @samp{__}. This in turn is used by the
29175 @file{msp430.h} header file to select an MCU-specific supplementary
29178 The option also sets the ISA to use. If the MCU name is one that is
29179 known to only support the 430 ISA then that is selected, otherwise the
29180 430X ISA is selected. A generic MCU name of @samp{msp430} can also be
29181 used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
29182 name selects the 430X ISA.
29184 In addition an MCU-specific linker script is added to the linker
29185 command line. The script's name is the name of the MCU with
29186 @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
29187 command line defines the C preprocessor symbol @code{__XXX__} and
29188 cause the linker to search for a script called @file{xxx.ld}.
29190 The ISA and hardware multiply supported for the different MCUs is hard-coded
29191 into GCC. However, an external @samp{devices.csv} file can be used to
29192 extend device support beyond those that have been hard-coded.
29194 GCC searches for the @samp{devices.csv} file using the following methods in the
29195 given precedence order, where the first method takes precendence over the
29196 second which takes precedence over the third.
29199 @item Include path specified with @code{-I} and @code{-L}
29200 @samp{devices.csv} will be searched for in each of the directories specified by
29201 include paths and linker library search paths.
29202 @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
29203 Define the value of the global environment variable
29204 @samp{MSP430_GCC_INCLUDE_DIR}
29205 to the full path to the directory containing devices.csv, and GCC will search
29206 this directory for devices.csv. If devices.csv is found, this directory will
29207 also be registered as an include path, and linker library path. Header files
29208 and linker scripts in this directory can therefore be used without manually
29209 specifying @code{-I} and @code{-L} on the command line.
29210 @item The @samp{msp430-elf@{,bare@}/include/devices} directory
29211 Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
29212 toolchain root directory. This directory does not exist in a default
29213 installation, but if the user has created it and copied @samp{devices.csv}
29214 there, then the MCU data will be read. As above, this directory will
29215 also be registered as an include path, and linker library path.
29218 If none of the above search methods find @samp{devices.csv}, then the
29219 hard-coded MCU data is used.
29223 @opindex mno-warn-mcu
29225 @itemx -mno-warn-mcu
29226 This option enables or disables warnings about conflicts between the
29227 MCU name specified by the @option{-mmcu} option and the ISA set by the
29228 @option{-mcpu} option and/or the hardware multiply support set by the
29229 @option{-mhwmult} option. It also toggles warnings about unrecognized
29230 MCU names. This option is on by default.
29234 Specifies the ISA to use. Accepted values are @samp{msp430},
29235 @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
29236 @option{-mmcu=} option should be used to select the ISA.
29240 Link to the simulator runtime libraries and linker script. Overrides
29241 any scripts that would be selected by the @option{-mmcu=} option.
29245 Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
29249 Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
29253 This option is passed to the assembler and linker, and allows the
29254 linker to perform certain optimizations that cannot be done until
29259 Describes the type of hardware multiply supported by the target.
29260 Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
29261 for the original 16-bit-only multiply supported by early MCUs.
29262 @samp{32bit} for the 16/32-bit multiply supported by later MCUs and
29263 @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
29264 A value of @samp{auto} can also be given. This tells GCC to deduce
29265 the hardware multiply support based upon the MCU name provided by the
29266 @option{-mmcu} option. If no @option{-mmcu} option is specified or if
29267 the MCU name is not recognized then no hardware multiply support is
29268 assumed. @code{auto} is the default setting.
29270 Hardware multiplies are normally performed by calling a library
29271 routine. This saves space in the generated code. When compiling at
29272 @option{-O3} or higher however the hardware multiplier is invoked
29273 inline. This makes for bigger, but faster code.
29275 The hardware multiply routines disable interrupts whilst running and
29276 restore the previous interrupt state when they finish. This makes
29277 them safe to use inside interrupt handlers as well as in normal code.
29281 Enable the use of a minimum runtime environment - no static
29282 initializers or constructors. This is intended for memory-constrained
29283 devices. The compiler includes special symbols in some objects
29284 that tell the linker and runtime which code fragments are required.
29286 @opindex mtiny-printf
29287 @item -mtiny-printf
29288 Enable reduced code size @code{printf} and @code{puts} library functions.
29289 The @samp{tiny} implementations of these functions are not reentrant, so
29290 must be used with caution in multi-threaded applications.
29292 Support for streams has been removed and the string to be printed will
29293 always be sent to stdout via the @code{write} syscall. The string is not
29294 buffered before it is sent to write.
29296 This option requires Newlib Nano IO, so GCC must be configured with
29297 @samp{--enable-newlib-nano-formatted-io}.
29299 @opindex mmax-inline-shift=
29300 @item -mmax-inline-shift=
29301 This option takes an integer between 0 and 64 inclusive, and sets
29302 the maximum number of inline shift instructions which should be emitted to
29303 perform a shift operation by a constant amount. When this value needs to be
29304 exceeded, an mspabi helper function is used instead. The default value is 4.
29306 This only affects cases where a shift by multiple positions cannot be
29307 completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
29309 Shifts of a 32-bit value are at least twice as costly, so the value passed for
29310 this option is divided by 2 and the resulting value used instead.
29312 @opindex mcode-region
29313 @opindex mdata-region
29314 @item -mcode-region=
29315 @itemx -mdata-region=
29316 These options tell the compiler where to place functions and data that
29317 do not have one of the @code{lower}, @code{upper}, @code{either} or
29318 @code{section} attributes. Possible values are @code{lower},
29319 @code{upper}, @code{either} or @code{any}. The first three behave
29320 like the corresponding attribute. The fourth possible value -
29321 @code{any} - is the default. It leaves placement entirely up to the
29322 linker script and how it assigns the standard sections
29323 (@code{.text}, @code{.data}, etc) to the memory regions.
29325 @opindex msilicon-errata
29326 @item -msilicon-errata=
29327 This option passes on a request to assembler to enable the fixes for
29328 the named silicon errata.
29330 @opindex msilicon-errata-warn
29331 @item -msilicon-errata-warn=
29332 This option passes on a request to the assembler to enable warning
29333 messages when a silicon errata might need to be applied.
29335 @opindex mwarn-devices-csv
29336 @opindex mno-warn-devices-csv
29337 @item -mwarn-devices-csv
29338 @itemx -mno-warn-devices-csv
29339 Warn if @samp{devices.csv} is not found or there are problem parsing it
29344 @node NDS32 Options
29345 @subsection NDS32 Options
29346 @cindex NDS32 Options
29348 These options are defined for NDS32 implementations:
29352 @opindex mbig-endian
29354 Generate code in big-endian mode.
29356 @opindex mlittle-endian
29357 @item -mlittle-endian
29358 Generate code in little-endian mode.
29360 @opindex mreduced-regs
29361 @item -mreduced-regs
29362 Use reduced-set registers for register allocation.
29364 @opindex mfull-regs
29366 Use full-set registers for register allocation.
29370 Generate conditional move instructions.
29374 Do not generate conditional move instructions.
29378 Generate performance extension instructions.
29380 @opindex mno-ext-perf
29381 @item -mno-ext-perf
29382 Do not generate performance extension instructions.
29384 @opindex mext-perf2
29386 Generate performance extension 2 instructions.
29388 @opindex mno-ext-perf2
29389 @item -mno-ext-perf2
29390 Do not generate performance extension 2 instructions.
29392 @opindex mext-string
29394 Generate string extension instructions.
29396 @opindex mno-ext-string
29397 @item -mno-ext-string
29398 Do not generate string extension instructions.
29402 Generate v3 push25/pop25 instructions.
29404 @opindex mno-v3push
29406 Do not generate v3 push25/pop25 instructions.
29410 Generate 16-bit instructions.
29412 @opindex mno-16-bit
29414 Do not generate 16-bit instructions.
29416 @opindex misr-vector-size
29417 @item -misr-vector-size=@var{num}
29418 Specify the size of each interrupt vector, which must be 4 or 16.
29420 @opindex mcache-block-size
29421 @item -mcache-block-size=@var{num}
29422 Specify the size of each cache block,
29423 which must be a power of 2 between 4 and 512.
29426 @item -march=@var{arch}
29427 Specify the name of the target architecture.
29430 @item -mcmodel=@var{code-model}
29431 Set the code model to one of
29434 All the data and read-only data segments must be within 512KB addressing space.
29435 The text segment must be within 16MB addressing space.
29436 @item @samp{medium}
29437 The data segment must be within 512KB while the read-only data segment can be
29438 within 4GB addressing space. The text segment should be still within 16MB
29441 All the text and data segments can be within 4GB addressing space.
29444 @opindex mctor-dtor
29446 Enable constructor/destructor feature.
29450 Guide linker to relax instructions.
29454 @node Nios II Options
29455 @subsection Nios II Options
29456 @cindex Nios II options
29457 @cindex Altera Nios II options
29459 These are the options defined for the Altera Nios II processor.
29464 @cindex smaller data references
29466 Put global and static objects less than or equal to @var{num} bytes
29467 into the small data or BSS sections instead of the normal data or BSS
29468 sections. The default value of @var{num} is 8.
29472 @item -mgpopt=@var{option}
29475 Generate (do not generate) GP-relative accesses. The following
29476 @var{option} names are recognized:
29481 Do not generate GP-relative accesses.
29484 Generate GP-relative accesses for small data objects that are not
29485 external, weak, or uninitialized common symbols.
29486 Also use GP-relative addressing for objects that
29487 have been explicitly placed in a small data section via a @code{section}
29491 As for @samp{local}, but also generate GP-relative accesses for
29492 small data objects that are external, weak, or common. If you use this option,
29493 you must ensure that all parts of your program (including libraries) are
29494 compiled with the same @option{-G} setting.
29497 Generate GP-relative accesses for all data objects in the program. If you
29498 use this option, the entire data and BSS segments
29499 of your program must fit in 64K of memory and you must use an appropriate
29500 linker script to allocate them within the addressable range of the
29504 Generate GP-relative addresses for function pointers as well as data
29505 pointers. If you use this option, the entire text, data, and BSS segments
29506 of your program must fit in 64K of memory and you must use an appropriate
29507 linker script to allocate them within the addressable range of the
29512 @option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
29513 @option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
29515 The default is @option{-mgpopt} except when @option{-fpic} or
29516 @option{-fPIC} is specified to generate position-independent code.
29517 Note that the Nios II ABI does not permit GP-relative accesses from
29520 You may need to specify @option{-mno-gpopt} explicitly when building
29521 programs that include large amounts of small data, including large
29522 GOT data sections. In this case, the 16-bit offset for GP-relative
29523 addressing may not be large enough to allow access to the entire
29524 small data section.
29526 @opindex mgprel-sec
29527 @item -mgprel-sec=@var{regexp}
29528 This option specifies additional section names that can be accessed via
29529 GP-relative addressing. It is most useful in conjunction with
29530 @code{section} attributes on variable declarations
29531 (@pxref{Common Variable Attributes}) and a custom linker script.
29532 The @var{regexp} is a POSIX Extended Regular Expression.
29534 This option does not affect the behavior of the @option{-G} option, and
29535 the specified sections are in addition to the standard @code{.sdata}
29536 and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
29538 @opindex mr0rel-sec
29539 @item -mr0rel-sec=@var{regexp}
29540 This option specifies names of sections that can be accessed via a
29541 16-bit offset from @code{r0}; that is, in the low 32K or high 32K
29542 of the 32-bit address space. It is most useful in conjunction with
29543 @code{section} attributes on variable declarations
29544 (@pxref{Common Variable Attributes}) and a custom linker script.
29545 The @var{regexp} is a POSIX Extended Regular Expression.
29547 In contrast to the use of GP-relative addressing for small data,
29548 zero-based addressing is never generated by default and there are no
29549 conventional section names used in standard linker scripts for sections
29550 in the low or high areas of memory.
29556 Generate little-endian (default) or big-endian (experimental) code,
29560 @item -march=@var{arch}
29561 This specifies the name of the target Nios II architecture. GCC uses this
29562 name to determine what kind of instructions it can emit when generating
29563 assembly code. Permissible names are: @samp{r1}, @samp{r2}.
29565 The preprocessor macro @code{__nios2_arch__} is available to programs,
29566 with value 1 or 2, indicating the targeted ISA level.
29568 @opindex mno-bypass-cache
29569 @opindex mbypass-cache
29570 @item -mbypass-cache
29571 @itemx -mno-bypass-cache
29572 Force all load and store instructions to always bypass cache by
29573 using I/O variants of the instructions. The default is not to
29576 @opindex mcache-volatile
29577 @opindex mno-cache-volatile
29578 @item -mno-cache-volatile
29579 @itemx -mcache-volatile
29580 Volatile memory access bypass the cache using the I/O variants of
29581 the load and store instructions. The default is not to bypass the cache.
29583 @opindex mno-fast-sw-div
29584 @opindex mfast-sw-div
29585 @item -mno-fast-sw-div
29586 @itemx -mfast-sw-div
29587 Do not use table-based fast divide for small numbers. The default
29588 is to use the fast divide at @option{-O3} and above.
29590 @opindex mno-hw-mul
29592 @opindex mno-hw-mulx
29594 @opindex mno-hw-div
29598 @itemx -mno-hw-mulx
29602 Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
29603 instructions by the compiler. The default is to emit @code{mul}
29604 and not emit @code{div} and @code{mulx}.
29610 Enable or disable generation of Nios II R2 BMX (bit manipulation) and
29611 CDX (code density) instructions. Enabling these instructions also
29612 requires @option{-march=r2}. Since these instructions are optional
29613 extensions to the R2 architecture, the default is not to emit them.
29615 @opindex mcustom-@var{insn}
29616 @opindex mno-custom-@var{insn}
29617 @item -mcustom-@var{insn}=@var{N}
29618 @itemx -mno-custom-@var{insn}
29619 Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
29620 custom instruction with encoding @var{N} when generating code that uses
29621 @var{insn}. For example, @option{-mcustom-fadds=253} generates custom
29622 instruction 253 for single-precision floating-point add operations instead
29623 of the default behavior of using a library call.
29625 The following values of @var{insn} are supported. Except as otherwise
29626 noted, floating-point operations are expected to be implemented with
29627 normal IEEE 754 semantics and correspond directly to the C operators or the
29628 equivalent GCC built-in functions (@pxref{Other Builtins}).
29630 Single-precision floating point:
29633 @item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
29634 Binary arithmetic operations.
29640 Unary absolute value.
29642 @item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
29643 Comparison operations.
29645 @item @samp{fmins}, @samp{fmaxs}
29646 Floating-point minimum and maximum. These instructions are only
29647 generated if @option{-ffinite-math-only} is specified.
29649 @item @samp{fsqrts}
29650 Unary square root operation.
29652 @item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
29653 Floating-point trigonometric and exponential functions. These instructions
29654 are only generated if @option{-funsafe-math-optimizations} is also specified.
29658 Double-precision floating point:
29661 @item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
29662 Binary arithmetic operations.
29668 Unary absolute value.
29670 @item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
29671 Comparison operations.
29673 @item @samp{fmind}, @samp{fmaxd}
29674 Double-precision minimum and maximum. These instructions are only
29675 generated if @option{-ffinite-math-only} is specified.
29677 @item @samp{fsqrtd}
29678 Unary square root operation.
29680 @item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
29681 Double-precision trigonometric and exponential functions. These instructions
29682 are only generated if @option{-funsafe-math-optimizations} is also specified.
29688 @item @samp{fextsd}
29689 Conversion from single precision to double precision.
29691 @item @samp{ftruncds}
29692 Conversion from double precision to single precision.
29694 @item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
29695 Conversion from floating point to signed or unsigned integer types, with
29696 truncation towards zero.
29699 Conversion from single-precision floating point to signed integer,
29700 rounding to the nearest integer and ties away from zero.
29701 This corresponds to the @code{__builtin_lroundf} function when
29702 @option{-fno-math-errno} is used.
29704 @item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
29705 Conversion from signed or unsigned integer types to floating-point types.
29709 In addition, all of the following transfer instructions for internal
29710 registers X and Y must be provided to use any of the double-precision
29711 floating-point instructions. Custom instructions taking two
29712 double-precision source operands expect the first operand in the
29713 64-bit register X. The other operand (or only operand of a unary
29714 operation) is given to the custom arithmetic instruction with the
29715 least significant half in source register @var{src1} and the most
29716 significant half in @var{src2}. A custom instruction that returns a
29717 double-precision result returns the most significant 32 bits in the
29718 destination register and the other half in 32-bit register Y.
29719 GCC automatically generates the necessary code sequences to write
29720 register X and/or read register Y when double-precision floating-point
29721 instructions are used.
29726 Write @var{src1} into the least significant half of X and @var{src2} into
29727 the most significant half of X.
29730 Write @var{src1} into Y.
29732 @item @samp{frdxhi}, @samp{frdxlo}
29733 Read the most or least (respectively) significant half of X and store it in
29737 Read the value of Y and store it into @var{dest}.
29740 Note that you can gain more local control over generation of Nios II custom
29741 instructions by using the @code{target("custom-@var{insn}=@var{N}")}
29742 and @code{target("no-custom-@var{insn}")} function attributes
29743 (@pxref{Function Attributes})
29744 or pragmas (@pxref{Function Specific Option Pragmas}).
29746 @opindex mcustom-fpu-cfg
29747 @item -mcustom-fpu-cfg=@var{name}
29749 This option enables a predefined, named set of custom instruction encodings
29750 (see @option{-mcustom-@var{insn}} above).
29751 Currently, the following sets are defined:
29753 @option{-mcustom-fpu-cfg=60-1} is equivalent to:
29754 @gccoptlist{-mcustom-fmuls=252
29757 -fsingle-precision-constant}
29759 @option{-mcustom-fpu-cfg=60-2} is equivalent to:
29760 @gccoptlist{-mcustom-fmuls=252
29764 -fsingle-precision-constant}
29766 @option{-mcustom-fpu-cfg=72-3} is equivalent to:
29767 @gccoptlist{-mcustom-floatus=243
29769 -mcustom-floatis=245
29770 -mcustom-fcmpgts=246
29771 -mcustom-fcmples=249
29772 -mcustom-fcmpeqs=250
29773 -mcustom-fcmpnes=251
29778 -fsingle-precision-constant}
29780 @option{-mcustom-fpu-cfg=fph2} is equivalent to:
29781 @gccoptlist{-mcustom-fabss=224
29783 -mcustom-fcmpnes=226
29784 -mcustom-fcmpeqs=227
29785 -mcustom-fcmpges=228
29786 -mcustom-fcmpgts=229
29787 -mcustom-fcmples=230
29788 -mcustom-fcmplts=231
29793 -mcustom-floatis=250
29794 -mcustom-fsqrts=251
29798 -mcustom-fdivs=255}
29800 Custom instruction assignments given by individual
29801 @option{-mcustom-@var{insn}=} options override those given by
29802 @option{-mcustom-fpu-cfg=}, regardless of the
29803 order of the options on the command line.
29805 Note that you can gain more local control over selection of a FPU
29806 configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
29807 function attribute (@pxref{Function Attributes})
29808 or pragma (@pxref{Function Specific Option Pragmas}).
29810 The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
29811 Hardware 2 Component}. Please note that the custom instructions enabled by
29812 @option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
29813 if @option{-ffinite-math-only} is specified. The custom instruction enabled by
29814 @option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
29815 specified. In contrast to the other configurations,
29816 @option{-fsingle-precision-constant} is not set.
29820 These additional @samp{-m} options are available for the Altera Nios II
29821 ELF (bare-metal) target:
29827 Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
29828 startup and termination code, and is typically used in conjunction with
29829 @option{-msys-crt0=} to specify the location of the alternate startup code
29830 provided by the HAL BSP.
29834 Link with a limited version of the C library, @option{-lsmallc}, rather than
29838 @item -msys-crt0=@var{startfile}
29839 @var{startfile} is the file name of the startfile (crt0) to use
29840 when linking. This option is only useful in conjunction with @option{-mhal}.
29843 @item -msys-lib=@var{systemlib}
29844 @var{systemlib} is the library name of the library that provides
29845 low-level system calls required by the C library,
29846 e.g.@: @code{read} and @code{write}.
29847 This option is typically used to link with a library provided by a HAL BSP.
29851 @node Nvidia PTX Options
29852 @subsection Nvidia PTX Options
29853 @cindex Nvidia PTX options
29854 @cindex nvptx options
29856 These options are defined for Nvidia PTX:
29862 Ignored, but preserved for backward compatibility. Only 64-bit ABI is
29866 @item -march=@var{architecture-string}
29867 Generate code for the specified PTX ISA target architecture
29868 (e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
29869 @samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
29871 The default depends on how the compiler has been configured, see
29872 @option{--with-arch}.
29874 This option sets the value of the preprocessor macro
29875 @code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
29879 @item -misa=@var{architecture-string}
29880 Alias of @option{-march=}.
29883 @item -march-map=@var{architecture-string}
29884 Select the closest available @option{-march=} value that is not more
29885 capable. For instance, for @option{-march-map=sm_50} select
29886 @option{-march=sm_35}, and for @option{-march-map=sm_53} select
29887 @option{-march=sm_53}.
29890 @item -mptx=@var{version-string}
29891 Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
29892 Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
29893 @samp{7.0}. The default PTX ISA version is 6.0, unless a higher
29894 version is required for specified PTX ISA target architecture via
29895 option @option{-march=}.
29897 This option sets the values of the preprocessor macros
29898 @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
29899 for instance, for @samp{3.1} the macros have the values @samp{3} and
29900 @samp{1}, respectively.
29902 @opindex mmainkernel
29904 Link in code for a __main kernel. This is for stand-alone instead of
29905 offloading execution.
29909 Apply partitioned execution optimizations. This is the default when any
29910 level of optimization is selected.
29912 @opindex msoft-stack
29914 Generate code that does not use @code{.local} memory
29915 directly for stack storage. Instead, a per-warp stack pointer is
29916 maintained explicitly. This enables variable-length stack allocation (with
29917 variable-length arrays or @code{alloca}), and when global memory is used for
29918 underlying storage, makes it possible to access automatic variables from other
29919 threads, or with atomic instructions. This code generation variant is used
29920 for OpenMP offloading, but the option is exposed on its own for the purpose
29921 of testing the compiler; to generate code suitable for linking into programs
29922 using OpenMP offloading, use option @option{-mgomp}.
29924 @opindex muniform-simt
29925 @item -muniform-simt
29926 Switch to code generation variant that allows to execute all threads in each
29927 warp, while maintaining memory state and side effects as if only one thread
29928 in each warp was active outside of OpenMP SIMD regions. All atomic operations
29929 and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
29930 current lane index equals the master lane index), and the register being
29931 assigned is copied via a shuffle instruction from the master lane. Outside of
29932 SIMD regions lane 0 is the master; inside, each thread sees itself as the
29933 master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
29934 all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
29935 regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
29936 with current lane index to compute the master lane index.
29940 Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
29941 @option{-muniform-simt} options, and selects corresponding multilib variant.
29945 @node OpenRISC Options
29946 @subsection OpenRISC Options
29947 @cindex OpenRISC Options
29949 These options are defined for OpenRISC:
29954 @item -mboard=@var{name}
29955 Configure a board specific runtime. This will be passed to the linker for
29956 newlib board library linking. The default is @code{or1ksim}.
29960 This option is ignored; it is for compatibility purposes only. This used to
29961 select linker and preprocessor options for use with newlib.
29967 Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
29968 This default is hardware divide.
29974 Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
29975 This default is hardware multiply.
29977 @opindex msoft-float
29978 @opindex mhard-float
29980 @itemx -mhard-float
29981 Select software or hardware for floating point operations.
29982 The default is software.
29984 @opindex mdouble-float
29985 @item -mdouble-float
29986 When @option{-mhard-float} is selected, enables generation of double-precision
29987 floating point instructions. By default functions from @file{libgcc} are used
29988 to perform double-precision floating point operations.
29990 @opindex munordered-float
29991 @item -munordered-float
29992 When @option{-mhard-float} is selected, enables generation of unordered
29993 floating point compare and set flag (@code{lf.sfun*}) instructions. By default
29994 functions from @file{libgcc} are used to perform unordered floating point
29995 compare and set flag operations.
29999 Enable generation of conditional move (@code{l.cmov}) instructions. By
30000 default the equivalent will be generated using set and branch.
30004 Enable generation of rotate right (@code{l.ror}) instructions. By default
30005 functions from @file{libgcc} are used to perform rotate right operations.
30009 Enable generation of rotate right with immediate (@code{l.rori}) instructions.
30010 By default functions from @file{libgcc} are used to perform rotate right with
30011 immediate operations.
30015 Enable generation of sign extension (@code{l.ext*}) instructions. By default
30016 memory loads are used to perform sign extension.
30020 Enable generation of compare and set flag with immediate (@code{l.sf*i})
30021 instructions. By default extra instructions will be generated to store the
30022 immediate to a register first.
30026 Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
30027 @code{l.slli}) instructions. By default extra instructions will be generated
30028 to store the immediate to a register first.
30030 @opindex mcmodel=small
30031 @item -mcmodel=small
30032 Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
30035 @opindex mcmodel=large
30036 @item -mcmodel=large
30037 Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
30042 @node PDP-11 Options
30043 @subsection PDP-11 Options
30044 @cindex PDP-11 Options
30046 These options are defined for the PDP-11:
30051 Use hardware FPP floating point. This is the default. (FIS floating
30052 point on the PDP-11/40 is not supported.) Implies -m45.
30054 @opindex msoft-float
30056 Do not use hardware floating point.
30060 Return floating-point results in ac0 (fr0 in Unix assembler syntax).
30064 Return floating-point results in memory. This is the default.
30068 Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
30072 Generate code for a PDP-11/45. This is the default.
30076 Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
30082 Use 16-bit @code{int}. This is the default.
30088 Use 32-bit @code{int}.
30092 Target has split instruction and data space. Implies -m45.
30096 Use Unix assembler syntax.
30100 Use DEC assembler syntax.
30104 Use GNU assembler syntax. This is the default.
30108 Use the new LRA register allocator. By default, the old ``reload''
30112 @node PowerPC Options
30113 @subsection PowerPC Options
30114 @cindex PowerPC options
30116 These are listed under @xref{RS/6000 and PowerPC Options}.
30119 @subsection PRU Options
30120 @cindex PRU Options
30122 These command-line options are defined for PRU target:
30127 Link with a minimum runtime environment. This can significantly reduce
30128 the size of the final ELF binary, but some standard C runtime features
30131 This option disables support for static initializers and constructors.
30132 Beware that the compiler could still generate code with static initializers
30133 and constructors. It is up to the programmer to ensure that the source
30134 program will not use those features.
30136 The minimal startup code would not pass @code{argc} and @code{argv} arguments
30137 to @code{main}, so the latter must be declared as @code{int main (void)}.
30138 This is already the norm for most firmware projects.
30141 @item -mmcu=@var{mcu}
30142 Specify the PRU hardware variant to use. A correspondingly named
30143 spec file would be loaded, passing the memory region sizes to
30144 the linker and defining hardware-specific C macros.
30146 Newlib provides only the @code{sim} spec, intended for running
30147 regression tests using a simulator. Specs for real hardware can be
30148 obtained by installing the
30149 @w{@uref{https://github.com/dinuxbg/gnuprumcu/,GnuPruMcu}} package.
30153 Make GCC pass the @option{--no-relax} command-line option to the linker
30154 instead of the @option{--relax} option.
30158 Allow (or do not allow) GCC to use the LOOP instruction.
30161 @item -mabi=@var{variant}
30162 Specify the ABI variant to output code for. @option{-mabi=ti} selects the
30163 unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
30164 more naturally with certain GCC assumptions. These are the differences:
30167 @item Function Pointer Size
30168 TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
30169 supports only 32-bit data and code pointers.
30171 @item Optional Return Value Pointer
30172 Function return values larger than 64 bits are passed by using a hidden
30173 pointer as the first argument of the function. TI ABI, though, mandates that
30174 the pointer can be NULL in case the caller is not using the returned value.
30175 GNU always passes and expects a valid return value pointer.
30179 The current @option{-mabi=ti} implementation simply raises a compile error
30180 when any of the above code constructs is detected. As a consequence
30181 the standard C library cannot be built and it is omitted when linking with
30184 Relaxation is a GNU feature and for safety reasons is disabled when using
30185 @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
30186 instructions, so the GNU linker cannot adjust them when shortening adjacent
30187 LDI32 pseudo instructions.
30191 @node RISC-V Options
30192 @subsection RISC-V Options
30193 @cindex RISC-V Options
30195 These command-line options are defined for RISC-V targets:
30198 @opindex mbranch-cost
30199 @item -mbranch-cost=@var{n}
30200 Set the cost of branches to roughly @var{n} instructions.
30205 When generating PIC code, do or don't allow the use of PLTs. Ignored for
30206 non-PIC. The default is @option{-mplt}.
30209 @item -mabi=@var{ABI-string}
30210 Specify integer and floating-point calling convention. @var{ABI-string}
30211 contains two parts: the size of integer types and the registers used for
30212 floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
30213 @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
30214 32-bit), and that floating-point values up to 64 bits wide are passed in F
30215 registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
30216 allows the compiler to generate code that uses the F and D extensions but only
30217 allows floating-point values up to 32 bits long to be passed in registers; or
30218 @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
30219 passed in registers.
30221 The default for this argument is system dependent, users who want a specific
30222 calling convention should specify one explicitly. The valid calling
30223 conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
30224 @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
30225 implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
30226 invalid because the ABI requires 64-bit values be passed in F registers, but F
30227 registers are only 32 bits wide. There are also the @samp{ilp32e} ABI that can
30228 only be used with the @samp{rv32e} architecture and the @samp{lp64e} ABI that
30229 can only be used with the @samp{rv64e}. Those ABIs are not well specified at
30230 present, and are subject to change.
30235 Do or don't use hardware floating-point divide and square root instructions.
30236 This requires the F or D extensions for floating-point registers. The default
30237 is to use them if the specified architecture has these instructions.
30242 Do or don't use hardware instructions for integer division. This requires the
30243 M extension. The default is to use them if the specified architecture has
30244 these instructions.
30247 @item -misa-spec=@var{ISA-spec-string}
30248 Specify the version of the RISC-V Unprivileged (formerly User-Level)
30249 ISA specification to produce code conforming to. The possibilities
30250 for @var{ISA-spec-string} are:
30253 Produce code conforming to version 2.2.
30255 Produce code conforming to version 20190608.
30257 Produce code conforming to version 20191213.
30259 The default is @option{-misa-spec=20191213} unless GCC has been configured
30260 with @option{--with-isa-spec=} specifying a different default version.
30263 @item -march=@var{ISA-string}
30264 Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
30265 lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
30266 @samp{rv32imaf}. Additionally, a special value @option{help}
30267 (@option{-march=help}) is accepted to list all supported extensions.
30269 The syntax of the ISA string is defined as follows:
30272 @item The string must start with @samp{rv32} or @samp{rv64}, followed by
30273 @samp{i}, @samp{e}, or @samp{g}, referred to as the base ISA.
30274 @item The subsequent part of the string is a list of extension names. Extension
30275 names can be categorized as multi-letter (e.g.@: @samp{zba}) and single-letter
30276 (e.g.@: @samp{v}). Single-letter extensions can appear consecutively,
30277 but multi-letter extensions must be separated by underscores.
30278 @item An underscore can appear anywhere after the base ISA. It has no specific
30279 effect but is used to improve readability and can act as a separator.
30280 @item Extension names may include an optional version number, following the
30281 syntax @samp{<major>p<minor>} or @samp{<major>}, (e.g.@: @samp{m2p1} or
30285 Supported extension are listed below:
30286 @multitable @columnfractions .10 .10 .80
30287 @headitem Extension Name @tab Supported Version @tab Description
30290 @tab Base integer extension.
30294 @tab Reduced base integer extension.
30298 @tab General-purpose computing base extension, @samp{g} will expand to
30299 @samp{i}, @samp{m}, @samp{a}, @samp{f}, @samp{d}, @samp{zicsr} and
30304 @tab Integer multiplication and division extension.
30308 @tab Atomic extension.
30312 @tab Single-precision floating-point extension.
30316 @tab Double-precision floating-point extension.
30320 @tab Compressed extension.
30324 @tab Hypervisor extension.
30328 @tab Vector extension.
30332 @tab Control and status register access extension.
30336 @tab Instruction-fetch fence extension.
30340 @tab Integer conditional operations extension.
30344 @tab Reservation set size of 64 bytes.
30348 @tab Reservation set size of 128 bytes.
30352 @tab Wait-on-reservation-set extension.
30356 @tab Address calculation extension.
30360 @tab Basic bit manipulation extension.
30364 @tab Carry-less multiplication extension.
30368 @tab Single-bit operation extension.
30372 @tab Single-precision floating-point in integer registers extension.
30376 @tab Double-precision floating-point in integer registers extension.
30380 @tab Half-precision floating-point in integer registers extension.
30384 @tab Minimal half-precision floating-point in integer registers extension.
30388 @tab Cryptography bit-manipulation extension.
30392 @tab Cryptography carry-less multiply extension.
30396 @tab Cryptography crossbar permutation extension.
30400 @tab AES Encryption extension.
30404 @tab AES Decryption extension.
30408 @tab Hash function extension.
30412 @tab Entropy source extension.
30416 @tab SM4 block cipher extension.
30420 @tab SM3 hash function extension.
30424 @tab Data independent execution latency extension.
30428 @tab Standard scalar cryptography extension.
30432 @tab NIST algorithm suite extension.
30436 @tab ShangMi algorithm suite extension.
30440 @tab Non-temporal locality hints extension.
30444 @tab Pause hint extension.
30448 @tab Cache-block zero extension.
30452 @tab Cache-block management extension.
30456 @tab Cache-block prefetch extension.
30460 @tab Cache block size isf 64 bytes.
30464 @tab Main memory supports all atomics in A.
30468 @tab Main memory supports instruction fetch with atomicity requirement.
30472 @tab Main memory supports misaligned loads/stores.
30476 @tab Main memory supports forward progress on LR/SC sequences.
30480 @tab Standard extension for base counters and timers.
30484 @tab Standard extension for hardware performance counters.
30488 @tab Total store ordering extension.
30492 @tab Vector extensions for embedded processors.
30496 @tab Vector extensions for embedded processors.
30500 @tab Vector extensions for embedded processors.
30504 @tab Vector extensions for embedded processors.
30508 @tab Vector extensions for embedded processors.
30512 @tab Minimum vector length standard extensions
30516 @tab Minimum vector length standard extensions
30520 @tab Minimum vector length standard extensions
30524 @tab Minimum vector length standard extensions
30528 @tab Minimum vector length standard extensions
30532 @tab Minimum vector length standard extensions
30536 @tab Minimum vector length standard extensions
30540 @tab Minimum vector length standard extensions
30544 @tab Vector basic bit-manipulation extension.
30548 @tab Vector carryless multiplication extension.
30552 @tab Vector cryptography bit-manipulation extension.
30556 @tab Vector GCM/GMAC extension.
30560 @tab Vector AES block cipher extension.
30564 @tab Vector SHA-2 secure hash extension.
30568 @tab Vector SHA-2 secure hash extension.
30572 @tab Vector SM4 Block Cipher extension.
30576 @tab Vector SM3 Secure Hash extension.
30580 @tab Vector NIST Algorithm Suite extension, @samp{zvkn} will expand to
30581 @samp{zvkned}, @samp{zvknhb}, @samp{zvkb} and @samp{zvkt}.
30585 @tab Vector NIST Algorithm Suite with carryless multiply extension, @samp{zvknc}
30586 will expand to @samp{zvkn} and @samp{zvbc}.
30590 @tab Vector NIST Algorithm Suite with GCM extension, @samp{zvkng} will expand
30591 to @samp{zvkn} and @samp{zvkg}.
30595 @tab Vector ShangMi algorithm suite extension, @samp{zvks} will expand
30596 to @samp{zvksed}, @samp{zvksh}, @samp{zvkb} and @samp{zvkt}.
30600 @tab Vector ShangMi algorithm suite with carryless multiplication extension,
30601 @samp{zvksc} will expand to @samp{zvks} and @samp{zvbc}.
30605 @tab Vector ShangMi algorithm suite with GCM extension, @samp{zvksg} will expand
30606 to @samp{zvks} and @samp{zvkg}.
30610 @tab Vector data independent execution latency extension.
30614 @tab Half-precision floating-point extension.
30618 @tab Minimal half-precision floating-point extension.
30622 @tab Vector half-precision floating-point extension.
30626 @tab Vector minimal half-precision floating-point extension.
30630 @tab Vector BF16 converts extension.
30634 @tab Additional floating-point extension.
30638 @tab Integer multiplication extension.
30642 @tab Integer compressed instruction extension.
30646 @tab Compressed single-precision floating point loads and stores extension.
30650 @tab Compressed double-precision floating point loads and stores extension.
30654 @tab Simple compressed instruction extension.
30658 @tab Compressed instruction extensions for embedded processors.
30662 @tab Compressed push pop extension.
30666 @tab Table jump instruction extension.
30670 @tab Advanced interrupt architecture extension.
30674 @tab PMP Enhancements for memory access and execution prevention on Machine mode.
30678 @tab State enable extension.
30682 @tab Advanced interrupt architecture extension for supervisor-mode.
30686 @tab Count overflow & filtering extension.
30690 @tab State-enable extension for supervisor-mode.
30694 @tab Supervisor-mode timer interrupts extension.
30698 @tab Fine-grained address-translation cache invalidation extension.
30702 @tab NAPOT translation contiguity extension.
30706 @tab Page-based memory types extension.
30710 @tab Core-V multiply-accumulate extension.
30714 @tab Core-V miscellaneous ALU extension.
30718 @tab Core-V event load word extension.
30722 @tab T-head address calculation extension.
30726 @tab T-head basic bit-manipulation extension.
30730 @tab T-head single-bit instructions extension.
30734 @tab T-head cache management operations extension.
30736 @item xtheadcondmov
30738 @tab T-head conditional move extension.
30740 @item xtheadfmemidx
30742 @tab T-head indexed memory operations for floating-point registers extension.
30746 @tab T-head double floating-point high-bit data transmission extension.
30750 @tab T-head acceleration interruption extension.
30754 @tab T-head multiply-accumulate extension.
30758 @tab T-head indexed memory operation extension.
30760 @item xtheadmempair
30762 @tab T-head two-GPR memory operation extension.
30766 @tab T-head multi-core synchronization extension.
30768 @item xventanacondops
30770 @tab Ventana integer conditional operations extension.
30774 When @option{-march=} is not specified, use the setting from @option{-mcpu}.
30776 If both @option{-march} and @option{-mcpu=} are not specified, the default for
30777 this argument is system dependent, users who want a specific architecture
30778 extensions should specify one explicitly.
30781 @item -mcpu=@var{processor-string}
30782 Use architecture of and optimize the output for the given processor, specified
30783 by particular CPU name.
30784 Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
30785 @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
30786 @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
30787 @samp{sifive-u54}, @samp{sifive-u74}, @samp{sifive-x280}, @samp{sifive-xp450},
30788 @samp{sifive-x670}.
30790 Note that @option{-mcpu} does not override @option{-march} or @option{-mtune}.
30793 @item -mtune=@var{processor-string}
30794 Optimize the output for the given processor, specified by microarchitecture or
30795 particular CPU name. Permissible values for this option are: @samp{rocket},
30796 @samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
30797 @samp{thead-c906}, @samp{size}, @samp{sifive-p400-series},
30798 @samp{sifive-p600-series}, and all valid options for @option{-mcpu=}.
30800 When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
30801 the default is @samp{rocket} if both are not specified.
30803 The @samp{size} choice is not intended for use by end-users. This is used
30804 when @option{-Os} is specified. It overrides the instruction cost info
30805 provided by @option{-mtune=}, but does not override the pipeline info. This
30806 helps reduce code size while still giving good performance.
30808 @opindex mpreferred-stack-boundary
30809 @item -mpreferred-stack-boundary=@var{num}
30810 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
30811 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
30812 the default is 4 (16 bytes or 128-bits).
30814 @strong{Warning:} If you use this switch, then you must build all modules with
30815 the same value, including any libraries. This includes the system libraries
30816 and startup modules.
30818 @opindex msmall-data-limit
30819 @item -msmall-data-limit=@var{n}
30820 Put global and static data smaller than @var{n} bytes into a special section
30823 @opindex msave-restore
30824 @item -msave-restore
30825 @itemx -mno-save-restore
30826 Do or don't use smaller but slower prologue and epilogue code that uses
30827 library function calls. The default is to use fast inline prologues and
30833 Do or don't produce branchless conditional-move code sequences even with
30834 targets that do not have specific instructions for conditional operations.
30835 If enabled, sequences of ALU operations are produced using base integer
30836 ISA instructions where profitable.
30838 @opindex minline-atomics
30839 @item -minline-atomics
30840 @itemx -mno-inline-atomics
30841 Do or don't use smaller but slower subword atomic emulation code that uses
30842 libatomic function calls. The default is to use fast inline subword atomics
30843 that do not require libatomic.
30845 @opindex minline-strlen
30846 @item -minline-strlen
30847 @itemx -mno-inline-strlen
30848 Do or do not attempt to inline strlen calls if possible.
30849 Inlining will only be done if the string is properly aligned
30850 and instructions for accelerated processing are available.
30851 The default is to not inline strlen calls.
30853 @opindex minline-strcmp
30854 @item -minline-strcmp
30855 @itemx -mno-inline-strcmp
30856 Do or do not attempt to inline strcmp calls if possible.
30857 Inlining will only be done if the strings are properly aligned
30858 and instructions for accelerated processing are available.
30859 The default is to not inline strcmp calls.
30861 The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls
30862 the maximum number of bytes compared by the inlined code.
30863 The default value is 64.
30865 @opindex minline-strncmp
30866 @item -minline-strncmp
30867 @itemx -mno-inline-strncmp
30868 Do or do not attempt to inline strncmp calls if possible.
30869 Inlining will only be done if the strings are properly aligned
30870 and instructions for accelerated processing are available.
30871 The default is to not inline strncmp calls.
30873 The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls
30874 the maximum number of bytes compared by the inlined code.
30875 The default value is 64.
30877 @opindex mshorten-memrefs
30878 @item -mshorten-memrefs
30879 @itemx -mno-shorten-memrefs
30880 Do or do not attempt to make more use of compressed load/store instructions by
30881 replacing a load/store of 'base register + large offset' with a new load/store
30882 of 'new base + small offset'. If the new base gets stored in a compressed
30883 register, then the new load/store can be compressed. Currently targets 32-bit
30884 integer load/stores only.
30886 @opindex mstrict-align
30887 @item -mstrict-align
30888 @itemx -mno-strict-align
30889 Do not or do generate unaligned memory accesses. The default is set depending
30890 on whether the processor we are optimizing for supports fast unaligned access
30893 @opindex mcmodel=medlow
30894 @item -mcmodel=medlow
30895 Generate code for the medium-low code model. The program and its statically
30896 defined symbols must lie within a single 2 GiB address range and must lie
30897 between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
30898 statically or dynamically linked. This is the default code model.
30900 @opindex mcmodel=medany
30901 @item -mcmodel=medany
30902 Generate code for the medium-any code model. The program and its statically
30903 defined symbols must be within any single 2 GiB address range. Programs can be
30904 statically or dynamically linked.
30906 The code generated by the medium-any code model is position-independent, but is
30907 not guaranteed to function correctly when linked into position-independent
30908 executables or libraries.
30910 @item -mexplicit-relocs
30911 @itemx -mno-exlicit-relocs
30912 Use or do not use assembler relocation operators when dealing with symbolic
30913 addresses. The alternative is to use assembler macros instead, which may
30914 limit optimization.
30919 Take advantage of linker relaxations to reduce the number of instructions
30920 required to materialize symbol addresses. The default is to take advantage of
30921 linker relaxations.
30923 @opindex mriscv-attribute
30924 @item -mriscv-attribute
30925 @itemx -mno-riscv-attribute
30926 Emit (do not emit) RISC-V attribute to record extra information into ELF
30927 objects. This feature requires at least binutils 2.32.
30929 @opindex mcsr-check
30931 @itemx -mno-csr-check
30932 Enables or disables the CSR checking.
30934 @opindex malign-data
30935 @item -malign-data=@var{type}
30936 Control how GCC aligns variables and constants of array, structure, or union
30937 types. Supported values for @var{type} are @samp{xlen} which uses x register
30938 width as the alignment value, and @samp{natural} which uses natural alignment.
30939 @samp{xlen} is the default.
30941 @opindex mbig-endian
30943 Generate big-endian code. This is the default when GCC is configured for a
30944 @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
30946 @opindex mlittle-endian
30947 @item -mlittle-endian
30948 Generate little-endian code. This is the default when GCC is configured for a
30949 @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
30950 @samp{riscv32be-*-*} target.
30952 @opindex mstack-protector-guard
30953 @opindex mstack-protector-guard-reg
30954 @opindex mstack-protector-guard-offset
30955 @item -mstack-protector-guard=@var{guard}
30956 @itemx -mstack-protector-guard-reg=@var{reg}
30957 @itemx -mstack-protector-guard-offset=@var{offset}
30958 Generate stack protection code using canary at @var{guard}. Supported
30959 locations are @samp{global} for a global canary or @samp{tls} for per-thread
30960 canary in the TLS block.
30962 With the latter choice the options
30963 @option{-mstack-protector-guard-reg=@var{reg}} and
30964 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30965 which register to use as base register for reading the canary,
30966 and from what offset from that base register. There is no default
30967 register or offset as this is entirely for use within the Linux
30972 @subsection RL78 Options
30973 @cindex RL78 Options
30979 Links in additional target libraries to support operation within a
30988 Specifies the type of hardware multiplication and division support to
30989 be used. The simplest is @code{none}, which uses software for both
30990 multiplication and division. This is the default. The @code{g13}
30991 value is for the hardware multiply/divide peripheral found on the
30992 RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
30993 the multiplication and division instructions supported by the RL78/G14
30994 (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
30995 the value @code{mg10} is an alias for @code{none}.
30997 In addition a C preprocessor macro is defined, based upon the setting
30998 of this option. Possible values are: @code{__RL78_MUL_NONE__},
30999 @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
31006 Specifies the RL78 core to target. The default is the G14 core, also
31007 known as an S3 core or just RL78. The G13 or S2 core does not have
31008 multiply or divide instructions, instead it uses a hardware peripheral
31009 for these operations. The G10 or S1 core does not have register
31010 banks, so it uses a different calling convention.
31012 If this option is set it also selects the type of hardware multiply
31013 support to use, unless this is overridden by an explicit
31014 @option{-mmul=none} option on the command line. Thus specifying
31015 @option{-mcpu=g13} enables the use of the G13 hardware multiply
31016 peripheral and specifying @option{-mcpu=g10} disables the use of
31017 hardware multiplications altogether.
31019 Note, although the RL78/G14 core is the default target, specifying
31020 @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
31021 change the behavior of the toolchain since it also enables G14
31022 hardware multiply support. If these options are not specified on the
31023 command line then software multiplication routines will be used even
31024 though the code targets the RL78 core. This is for backwards
31025 compatibility with older toolchains which did not have hardware
31026 multiply and divide support.
31028 In addition a C preprocessor macro is defined, based upon the setting
31029 of this option. Possible values are: @code{__RL78_G10__},
31030 @code{__RL78_G13__} or @code{__RL78_G14__}.
31040 These are aliases for the corresponding @option{-mcpu=} option. They
31041 are provided for backwards compatibility.
31045 Allow the compiler to use all of the available registers. By default
31046 registers @code{r24..r31} are reserved for use in interrupt handlers.
31047 With this option enabled these registers can be used in ordinary
31050 @opindex m64bit-doubles
31051 @opindex m32bit-doubles
31052 @item -m64bit-doubles
31053 @itemx -m32bit-doubles
31054 Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
31055 or 32 bits (@option{-m32bit-doubles}) in size. The default is
31056 @option{-m32bit-doubles}.
31058 @opindex msave-mduc-in-interrupts
31059 @opindex mno-save-mduc-in-interrupts
31060 @item -msave-mduc-in-interrupts
31061 @itemx -mno-save-mduc-in-interrupts
31062 Specifies that interrupt handler functions should preserve the
31063 MDUC registers. This is only necessary if normal code might use
31064 the MDUC registers, for example because it performs multiplication
31065 and division operations. The default is to ignore the MDUC registers
31066 as this makes the interrupt handlers faster. The target option -mg13
31067 needs to be passed for this to work as this feature is only available
31068 on the G13 target (S2 core). The MDUC registers will only be saved
31069 if the interrupt handler performs a multiplication or division
31070 operation or it calls another function.
31074 @node RS/6000 and PowerPC Options
31075 @subsection IBM RS/6000 and PowerPC Options
31076 @cindex RS/6000 and PowerPC Options
31077 @cindex IBM RS/6000 and PowerPC Options
31079 These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
31081 @item -mpowerpc-gpopt
31082 @itemx -mno-powerpc-gpopt
31083 @itemx -mpowerpc-gfxopt
31084 @itemx -mno-powerpc-gfxopt
31087 @itemx -mno-powerpc64
31091 @itemx -mno-popcntb
31093 @itemx -mno-popcntd
31097 @opindex mpowerpc-gpopt
31098 @opindex mno-powerpc-gpopt
31099 @opindex mpowerpc-gfxopt
31100 @opindex mno-powerpc-gfxopt
31101 @opindex mpowerpc64
31102 @opindex mno-powerpc64
31106 @opindex mno-popcntb
31108 @opindex mno-popcntd
31114 @opindex mno-hard-dfp
31118 @itemx -mno-hard-dfp
31119 You use these options to specify which instructions are available on the
31120 processor you are using. The default value of these options is
31121 determined when configuring GCC@. Specifying the
31122 @option{-mcpu=@var{cpu_type}} overrides the specification of these
31123 options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
31124 rather than the options listed above.
31126 Specifying @option{-mpowerpc-gpopt} allows
31127 GCC to use the optional PowerPC architecture instructions in the
31128 General Purpose group, including floating-point square root. Specifying
31129 @option{-mpowerpc-gfxopt} allows GCC to
31130 use the optional PowerPC architecture instructions in the Graphics
31131 group, including floating-point select.
31133 The @option{-mmfcrf} option allows GCC to generate the move from
31134 condition register field instruction implemented on the POWER4
31135 processor and other processors that support the PowerPC V2.01
31137 The @option{-mpopcntb} option allows GCC to generate the popcount and
31138 double-precision FP reciprocal estimate instruction implemented on the
31139 POWER5 processor and other processors that support the PowerPC V2.02
31141 The @option{-mpopcntd} option allows GCC to generate the popcount
31142 instruction implemented on the POWER7 processor and other processors
31143 that support the PowerPC V2.06 architecture.
31144 The @option{-mfprnd} option allows GCC to generate the FP round to
31145 integer instructions implemented on the POWER5+ processor and other
31146 processors that support the PowerPC V2.03 architecture.
31147 The @option{-mcmpb} option allows GCC to generate the compare bytes
31148 instruction implemented on the POWER6 processor and other processors
31149 that support the PowerPC V2.05 architecture.
31150 The @option{-mhard-dfp} option allows GCC to generate the decimal
31151 floating-point instructions implemented on some POWER processors.
31153 The @option{-mpowerpc64} option allows GCC to generate the additional
31154 64-bit instructions that are found in the full PowerPC64 architecture
31155 and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
31156 @option{-mno-powerpc64}.
31159 @item -mcpu=@var{cpu_type}
31160 Set architecture type, register usage, and
31161 instruction scheduling parameters for machine type @var{cpu_type}.
31162 Supported values for @var{cpu_type} are @samp{401}, @samp{403},
31163 @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
31164 @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
31165 @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
31166 @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
31167 @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
31168 @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
31169 @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
31170 @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
31171 @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
31172 @samp{power9}, @samp{power10}, @samp{power11},
31173 @samp{powerpc}, @samp{powerpc64}, @samp{powerpc64le},
31174 @samp{rs64}, and @samp{native}.
31176 @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
31177 @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
31178 endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
31179 architecture machine types, with an appropriate, generic processor
31180 model assumed for scheduling purposes.
31182 Specifying @samp{native} as cpu type detects and selects the
31183 architecture option that corresponds to the host processor of the
31184 system performing the compilation.
31185 @option{-mcpu=native} has no effect if GCC does not recognize the
31188 The other options specify a specific processor. Code generated under
31189 those options runs best on that processor, and may not run at all on
31192 The @option{-mcpu} options automatically enable or disable the
31195 @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple
31196 -mpopcntb -mpopcntd -mpowerpc64
31197 -mpowerpc-gpopt -mpowerpc-gfxopt
31198 -mmulhw -mdlmzb -mmfpgpr -mvsx
31199 -mcrypto -mhtm -mpower8-fusion
31200 -mquad-memory -mquad-memory-atomic -mfloat128
31201 -mfloat128-hardware -mprefixed -mpcrel -mmma
31204 The particular options set for any particular CPU varies between
31205 compiler versions, depending on what setting seems to produce optimal
31206 code for that CPU; it doesn't necessarily reflect the actual hardware's
31207 capabilities. If you wish to set an individual option to a particular
31208 value, you may specify it after the @option{-mcpu} option, like
31209 @option{-mcpu=970 -mno-altivec}.
31211 On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
31212 not enabled or disabled by the @option{-mcpu} option at present because
31213 AIX does not have full support for these options. You may still
31214 enable or disable them individually if you're sure it'll work in your
31218 @item -mtune=@var{cpu_type}
31219 Set the instruction scheduling parameters for machine type
31220 @var{cpu_type}, but do not set the architecture type or register usage,
31221 as @option{-mcpu=@var{cpu_type}} does. The same
31222 values for @var{cpu_type} are used for @option{-mtune} as for
31223 @option{-mcpu}. If both are specified, the code generated uses the
31224 architecture and registers set by @option{-mcpu}, but the
31225 scheduling parameters set by @option{-mtune}.
31227 @opindex mcmodel=small
31228 @item -mcmodel=small
31229 Generate PowerPC64 code for the small model: The TOC is limited to
31232 @opindex mcmodel=medium
31233 @item -mcmodel=medium
31234 Generate PowerPC64 code for the medium model: The TOC and other static
31235 data may be up to a total of 4G in size. This is the default for 64-bit
31238 @opindex mcmodel=large
31239 @item -mcmodel=large
31240 Generate PowerPC64 code for the large model: The TOC may be up to 4G
31241 in size. Other data and code is only limited by the 64-bit address
31245 @opindex mno-altivec
31247 @itemx -mno-altivec
31248 Generate code that uses (does not use) AltiVec instructions, and also
31249 enable the use of built-in functions that allow more direct access to
31250 the AltiVec instruction set. You may also need to set
31251 @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
31254 When @option{-maltivec} is used, the element order for AltiVec intrinsics
31255 such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
31256 match array element order corresponding to the endianness of the
31257 target. That is, element zero identifies the leftmost element in a
31258 vector register when targeting a big-endian platform, and identifies
31259 the rightmost element in a vector register when targeting a
31260 little-endian platform.
31263 @opindex mno-vrsave
31266 Generate VRSAVE instructions when generating AltiVec code.
31268 @opindex msecure-plt
31270 Generate code that allows @command{ld} and @command{ld.so}
31271 to build executables and shared
31272 libraries with non-executable @code{.plt} and @code{.got} sections.
31274 32-bit SYSV ABI option.
31278 Generate code that uses a BSS @code{.plt} section that @command{ld.so}
31280 requires @code{.plt} and @code{.got}
31281 sections that are both writable and executable.
31282 This is a PowerPC 32-bit SYSV ABI option.
31288 This switch enables or disables the generation of ISEL instructions.
31294 Generate code that uses (does not use) vector/scalar (VSX)
31295 instructions, and also enable the use of built-in functions that allow
31296 more direct access to the VSX instruction set.
31299 @opindex mno-crypto
31302 Enable the use (disable) of the built-in functions that allow direct
31303 access to the cryptographic instructions that were added in version
31304 2.07 of the PowerPC ISA.
31310 Enable (disable) the use of the built-in functions that allow direct
31311 access to the Hardware Transactional Memory (HTM) instructions that
31312 were added in version 2.07 of the PowerPC ISA.
31314 @opindex mpower8-fusion
31315 @opindex mno-power8-fusion
31316 @item -mpower8-fusion
31317 @itemx -mno-power8-fusion
31318 Generate code that keeps (does not keeps) some integer operations
31319 adjacent so that the instructions can be fused together on power8 and
31322 @opindex mquad-memory
31323 @opindex mno-quad-memory
31324 @item -mquad-memory
31325 @itemx -mno-quad-memory
31326 Generate code that uses (does not use) the non-atomic quad word memory
31327 instructions. The @option{-mquad-memory} option requires use of
31330 @opindex mquad-memory-atomic
31331 @opindex mno-quad-memory-atomic
31332 @item -mquad-memory-atomic
31333 @itemx -mno-quad-memory-atomic
31334 Generate code that uses (does not use) the atomic quad word memory
31335 instructions. The @option{-mquad-memory-atomic} option requires use of
31339 @opindex mno-float128
31341 @itemx -mno-float128
31342 Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
31343 and use either software emulation for IEEE 128-bit floating point or
31344 hardware instructions.
31346 The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
31347 128-bit floating point support. The IEEE 128-bit floating point is only
31348 supported on Linux.
31350 The default for @option{-mfloat128} is enabled on PowerPC Linux
31351 systems using the VSX instruction set, and disabled on other systems.
31353 If you use the ISA 3.0 instruction set (@option{-mcpu=power9}) on a
31354 64-bit system, the IEEE 128-bit floating point support will also enable
31355 the generation of ISA 3.0 IEEE 128-bit floating point instructions.
31356 Otherwise, if you do not specify to generate ISA 3.0 instructions or you
31357 are targeting a 32-bit big endian system, IEEE 128-bit floating point
31358 will be done with software emulation.
31360 @opindex mfloat128-hardware
31361 @opindex mno-float128-hardware
31362 @item -mfloat128-hardware
31363 @itemx -mno-float128-hardware
31364 Enable/disable using ISA 3.0 hardware instructions to support the
31365 @var{__float128} data type.
31367 The default for @option{-mfloat128-hardware} is enabled on PowerPC
31368 Linux systems using the ISA 3.0 instruction set, and disabled on other
31375 Generate code for 32-bit or 64-bit environments of Darwin and SVR4
31376 targets (including GNU/Linux). The 32-bit environment sets int, long
31377 and pointer to 32 bits and generates code that runs on any PowerPC
31378 variant. The 64-bit environment sets int to 32 bits and long and
31379 pointer to 64 bits, and generates code for PowerPC64, as for
31380 @option{-mpowerpc64}.
31383 @opindex mno-fp-in-toc
31384 @opindex mno-sum-in-toc
31385 @opindex mminimal-toc
31387 @itemx -mno-fp-in-toc
31388 @itemx -mno-sum-in-toc
31389 @itemx -mminimal-toc
31390 Modify generation of the TOC (Table Of Contents), which is created for
31391 every executable file. The @option{-mfull-toc} option is selected by
31392 default. In that case, GCC allocates at least one TOC entry for
31393 each unique non-automatic variable reference in your program. GCC
31394 also places floating-point constants in the TOC@. However, only
31395 16,384 entries are available in the TOC@.
31397 If you receive a linker error message that saying you have overflowed
31398 the available TOC space, you can reduce the amount of TOC space used
31399 with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
31400 @option{-mno-fp-in-toc} prevents GCC from putting floating-point
31401 constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
31402 generate code to calculate the sum of an address and a constant at
31403 run time instead of putting that sum into the TOC@. You may specify one
31404 or both of these options. Each causes GCC to produce very slightly
31405 slower and larger code at the expense of conserving TOC space.
31407 If you still run out of space in the TOC even when you specify both of
31408 these options, specify @option{-mminimal-toc} instead. This option causes
31409 GCC to make only one TOC entry for every file. When you specify this
31410 option, GCC produces code that is slower and larger but which
31411 uses extremely little TOC space. You may wish to use this option
31412 only on files that contain less frequently-executed code.
31418 Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
31419 @code{long} type, and the infrastructure needed to support them.
31420 Specifying @option{-maix64} implies @option{-mpowerpc64},
31421 while @option{-maix32} disables the 64-bit ABI and
31422 implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
31424 @opindex mxl-compat
31425 @opindex mno-xl-compat
31427 @itemx -mno-xl-compat
31428 Produce code that conforms more closely to IBM XL compiler semantics
31429 when using AIX-compatible ABI@. Pass floating-point arguments to
31430 prototyped functions beyond the register save area (RSA) on the stack
31431 in addition to argument FPRs. Do not assume that most significant
31432 double in 128-bit long double value is properly rounded when comparing
31433 values and converting to double. Use XL symbol names for long double
31436 The AIX calling convention was extended but not initially documented to
31437 handle an obscure K&R C case of calling a function that takes the
31438 address of its arguments with fewer arguments than declared. IBM XL
31439 compilers access floating-point arguments that do not fit in the
31440 RSA from the stack when a subroutine is compiled without
31441 optimization. Because always storing floating-point arguments on the
31442 stack is inefficient and rarely needed, this option is not enabled by
31443 default and only is necessary when calling subroutines compiled by IBM
31444 XL compilers without optimization.
31448 Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
31449 application written to use message passing with special startup code to
31450 enable the application to run. The system must have PE installed in the
31451 standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
31452 must be overridden with the @option{-specs=} option to specify the
31453 appropriate directory location. The Parallel Environment does not
31454 support threads, so the @option{-mpe} option and the @option{-pthread}
31455 option are incompatible.
31457 @opindex malign-natural
31458 @opindex malign-power
31459 @item -malign-natural
31460 @itemx -malign-power
31461 On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
31462 @option{-malign-natural} overrides the ABI-defined alignment of larger
31463 types, such as floating-point doubles, on their natural size-based boundary.
31464 The option @option{-malign-power} instructs GCC to follow the ABI-specified
31465 alignment rules. GCC defaults to the standard alignment defined in the ABI@.
31467 On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
31470 @opindex msoft-float
31471 @opindex mhard-float
31473 @itemx -mhard-float
31474 Generate code that does not use (uses) the floating-point register set.
31475 Software floating-point emulation is provided if you use the
31476 @option{-msoft-float} option, and pass the option to GCC when linking.
31479 @opindex mno-multiple
31481 @itemx -mno-multiple
31482 Generate code that uses (does not use) the load multiple word
31483 instructions and the store multiple word instructions. These
31484 instructions are generated by default on POWER systems, and not
31485 generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
31486 PowerPC systems, since those instructions do not work when the
31487 processor is in little-endian mode. The exceptions are PPC740 and
31488 PPC750 which permit these instructions in little-endian mode.
31491 @opindex mno-update
31494 Generate code that uses (does not use) the load or store instructions
31495 that update the base register to the address of the calculated memory
31496 location. These instructions are generated by default. If you use
31497 @option{-mno-update}, there is a small window between the time that the
31498 stack pointer is updated and the address of the previous frame is
31499 stored, which means code that walks the stack frame across interrupts or
31500 signals may get corrupted data.
31502 @opindex mavoid-indexed-addresses
31503 @opindex mno-avoid-indexed-addresses
31504 @item -mavoid-indexed-addresses
31505 @itemx -mno-avoid-indexed-addresses
31506 Generate code that tries to avoid (not avoid) the use of indexed load
31507 or store instructions. These instructions can incur a performance
31508 penalty on Power6 processors in certain situations, such as when
31509 stepping through large arrays that cross a 16M boundary. This option
31510 is enabled by default when targeting Power6 and disabled otherwise.
31512 @opindex mfused-madd
31513 @opindex mno-fused-madd
31515 @itemx -mno-fused-madd
31516 Generate code that uses (does not use) the floating-point multiply and
31517 accumulate instructions. These instructions are generated by default
31518 if hardware floating point is used. The machine-dependent
31519 @option{-mfused-madd} option is now mapped to the machine-independent
31520 @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31521 mapped to @option{-ffp-contract=off}.
31527 Generate code that uses (does not use) the half-word multiply and
31528 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
31529 These instructions are generated by default when targeting those
31536 Generate code that uses (does not use) the string-search @samp{dlmzb}
31537 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
31538 generated by default when targeting those processors.
31540 @opindex mno-bit-align
31541 @opindex mbit-align
31542 @item -mno-bit-align
31544 On System V.4 and embedded PowerPC systems do not (do) force structures
31545 and unions that contain bit-fields to be aligned to the base type of the
31548 For example, by default a structure containing nothing but 8
31549 @code{unsigned} bit-fields of length 1 is aligned to a 4-byte
31550 boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
31551 the structure is aligned to a 1-byte boundary and is 1 byte in
31554 @opindex mno-strict-align
31555 @opindex mstrict-align
31556 @item -mno-strict-align
31557 @itemx -mstrict-align
31558 On System V.4 and embedded PowerPC systems do not (do) assume that
31559 unaligned memory references are handled by the system.
31561 @opindex mrelocatable
31562 @opindex mno-relocatable
31563 @item -mrelocatable
31564 @itemx -mno-relocatable
31565 Generate code that allows (does not allow) a static executable to be
31566 relocated to a different address at run time. A simple embedded
31567 PowerPC system loader should relocate the entire contents of
31568 @code{.got2} and 4-byte locations listed in the @code{.fixup} section,
31569 a table of 32-bit addresses generated by this option. For this to
31570 work, all objects linked together must be compiled with
31571 @option{-mrelocatable} or @option{-mrelocatable-lib}.
31572 @option{-mrelocatable} code aligns the stack to an 8-byte boundary.
31574 @opindex mrelocatable-lib
31575 @opindex mno-relocatable-lib
31576 @item -mrelocatable-lib
31577 @itemx -mno-relocatable-lib
31578 Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
31579 @code{.fixup} section to allow static executables to be relocated at
31580 run time, but @option{-mrelocatable-lib} does not use the smaller stack
31581 alignment of @option{-mrelocatable}. Objects compiled with
31582 @option{-mrelocatable-lib} may be linked with objects compiled with
31583 any combination of the @option{-mrelocatable} options.
31589 On System V.4 and embedded PowerPC systems do not (do) assume that
31590 register 2 contains a pointer to a global area pointing to the addresses
31591 used in the program.
31594 @opindex mlittle-endian
31596 @itemx -mlittle-endian
31597 On System V.4 and embedded PowerPC systems compile code for the
31598 processor in little-endian mode. The @option{-mlittle-endian} option is
31599 the same as @option{-mlittle}.
31602 @opindex mbig-endian
31604 @itemx -mbig-endian
31605 On System V.4 and embedded PowerPC systems compile code for the
31606 processor in big-endian mode. The @option{-mbig-endian} option is
31607 the same as @option{-mbig}.
31609 @opindex mdynamic-no-pic
31610 @item -mdynamic-no-pic
31611 On Darwin / macOS systems, compile code so that it is not
31612 relocatable, but that its external references are relocatable. The
31613 resulting code is suitable for applications, but not shared
31616 @opindex msingle-pic-base
31617 @item -msingle-pic-base
31618 Treat the register used for PIC addressing as read-only, rather than
31619 loading it in the prologue for each function. The runtime system is
31620 responsible for initializing this register with an appropriate value
31621 before execution begins.
31623 @opindex mprioritize-restricted-insns
31624 @item -mprioritize-restricted-insns=@var{priority}
31625 This option controls the priority that is assigned to
31626 dispatch-slot restricted instructions during the second scheduling
31627 pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
31628 or @samp{2} to assign no, highest, or second-highest (respectively)
31629 priority to dispatch-slot restricted
31632 @opindex msched-costly-dep
31633 @item -msched-costly-dep=@var{dependence_type}
31634 This option controls which dependences are considered costly
31635 by the target during instruction scheduling. The argument
31636 @var{dependence_type} takes one of the following values:
31640 No dependence is costly.
31643 All dependences are costly.
31645 @item @samp{true_store_to_load}
31646 A true dependence from store to load is costly.
31648 @item @samp{store_to_load}
31649 Any dependence from store to load is costly.
31652 Any dependence for which the latency is greater than or equal to
31653 @var{number} is costly.
31656 @opindex minsert-sched-nops
31657 @item -minsert-sched-nops=@var{scheme}
31658 This option controls which NOP insertion scheme is used during
31659 the second scheduling pass. The argument @var{scheme} takes one of the
31667 Pad with NOPs any dispatch group that has vacant issue slots,
31668 according to the scheduler's grouping.
31670 @item @samp{regroup_exact}
31671 Insert NOPs to force costly dependent insns into
31672 separate groups. Insert exactly as many NOPs as needed to force an insn
31673 to a new group, according to the estimated processor grouping.
31676 Insert NOPs to force costly dependent insns into
31677 separate groups. Insert @var{number} NOPs to force an insn to a new group.
31680 @opindex mcall-sysv
31682 On System V.4 and embedded PowerPC systems compile code using calling
31683 conventions that adhere to the March 1995 draft of the System V
31684 Application Binary Interface, PowerPC processor supplement. This is the
31685 default unless you configured GCC using @samp{powerpc-*-eabiaix}.
31687 @opindex mcall-sysv-eabi
31688 @opindex mcall-eabi
31689 @item -mcall-sysv-eabi
31691 Specify both @option{-mcall-sysv} and @option{-meabi} options.
31693 @opindex mcall-sysv-noeabi
31694 @item -mcall-sysv-noeabi
31695 Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
31697 @opindex mcall-aixdesc
31698 @item -mcall-aixdesc
31699 On System V.4 and embedded PowerPC systems compile code for the AIX
31702 @opindex mcall-linux
31704 On System V.4 and embedded PowerPC systems compile code for the
31705 Linux-based GNU system.
31707 @opindex mcall-freebsd
31708 @item -mcall-freebsd
31709 On System V.4 and embedded PowerPC systems compile code for the
31710 FreeBSD operating system.
31712 @opindex mcall-netbsd
31713 @item -mcall-netbsd
31714 On System V.4 and embedded PowerPC systems compile code for the
31715 NetBSD operating system.
31717 @opindex mcall-openbsd
31718 @item -mcall-openbsd
31719 On System V.4 and embedded PowerPC systems compile code for the
31720 OpenBSD operating system.
31722 @opindex mtraceback
31723 @item -mtraceback=@var{traceback_type}
31724 Select the type of traceback table. Valid values for @var{traceback_type}
31725 are @samp{full}, @samp{part}, and @samp{no}.
31727 @opindex maix-struct-return
31728 @item -maix-struct-return
31729 Return all structures in memory (as specified by the AIX ABI)@.
31731 @opindex msvr4-struct-return
31732 @item -msvr4-struct-return
31733 Return structures smaller than 8 bytes in registers (as specified by the
31737 @item -mabi=@var{abi-type}
31738 Extend the current ABI with a particular extension, or remove such extension.
31739 Valid values are: @samp{altivec}, @samp{no-altivec},
31740 @samp{ibmlongdouble}, @samp{ieeelongdouble},
31741 @samp{elfv1}, @samp{elfv2},
31742 and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
31744 @opindex mabi=ibmlongdouble
31745 @item -mabi=ibmlongdouble
31746 Change the current ABI to use IBM extended-precision long double.
31747 This is not likely to work if your system defaults to using IEEE
31748 extended-precision long double. If you change the long double type
31749 from IEEE extended-precision, the compiler will issue a warning unless
31750 you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
31753 @opindex mabi=ieeelongdouble
31754 @item -mabi=ieeelongdouble
31755 Change the current ABI to use IEEE extended-precision long double.
31756 This is not likely to work if your system defaults to using IBM
31757 extended-precision long double. If you change the long double type
31758 from IBM extended-precision, the compiler will issue a warning unless
31759 you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
31762 @opindex mabi=elfv1
31764 Change the current ABI to use the ELFv1 ABI.
31765 This is the default ABI for big-endian PowerPC 64-bit Linux.
31766 Overriding the default ABI requires special system support and is
31767 likely to fail in spectacular ways.
31769 @opindex mabi=elfv2
31771 Change the current ABI to use the ELFv2 ABI.
31772 This is the default ABI for little-endian PowerPC 64-bit Linux.
31773 Overriding the default ABI requires special system support and is
31774 likely to fail in spectacular ways.
31776 @opindex mgnu-attribute
31777 @opindex mno-gnu-attribute
31778 @item -mgnu-attribute
31779 @itemx -mno-gnu-attribute
31780 Emit .gnu_attribute assembly directives to set tag/value pairs in a
31781 .gnu.attributes section that specify ABI variations in function
31782 parameters or return values.
31784 @opindex mprototype
31785 @opindex mno-prototype
31787 @itemx -mno-prototype
31788 On System V.4 and embedded PowerPC systems assume that all calls to
31789 variable argument functions are properly prototyped. Otherwise, the
31790 compiler must insert an instruction before every non-prototyped call to
31791 set or clear bit 6 of the condition code register (@code{CR}) to
31792 indicate whether floating-point values are passed in the floating-point
31793 registers in case the function takes variable arguments. With
31794 @option{-mprototype}, only calls to prototyped variable argument functions
31795 set or clear the bit.
31799 On embedded PowerPC systems, assume that the startup module is called
31800 @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
31801 @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
31806 On embedded PowerPC systems, assume that the startup module is called
31807 @file{crt0.o} and the standard C libraries are @file{libmvme.a} and
31812 On embedded PowerPC systems, assume that the startup module is called
31813 @file{crt0.o} and the standard C libraries are @file{libads.a} and
31816 @opindex myellowknife
31817 @item -myellowknife
31818 On embedded PowerPC systems, assume that the startup module is called
31819 @file{crt0.o} and the standard C libraries are @file{libyk.a} and
31824 On System V.4 and embedded PowerPC systems, specify that you are
31825 compiling for a VxWorks system.
31829 On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
31830 header to indicate that @samp{eabi} extended relocations are used.
31836 On System V.4 and embedded PowerPC systems do (do not) adhere to the
31837 Embedded Applications Binary Interface (EABI), which is a set of
31838 modifications to the System V.4 specifications. Selecting @option{-meabi}
31839 means that the stack is aligned to an 8-byte boundary, a function
31840 @code{__eabi} is called from @code{main} to set up the EABI
31841 environment, and the @option{-msdata} option can use both @code{r2} and
31842 @code{r13} to point to two separate small data areas. Selecting
31843 @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
31844 no EABI initialization function is called from @code{main}, and the
31845 @option{-msdata} option only uses @code{r13} to point to a single
31846 small data area. The @option{-meabi} option is on by default if you
31847 configured GCC using one of the @samp{powerpc*-*-eabi*} options.
31849 @opindex msdata=eabi
31851 On System V.4 and embedded PowerPC systems, put small initialized
31852 @code{const} global and static data in the @code{.sdata2} section, which
31853 is pointed to by register @code{r2}. Put small initialized
31854 non-@code{const} global and static data in the @code{.sdata} section,
31855 which is pointed to by register @code{r13}. Put small uninitialized
31856 global and static data in the @code{.sbss} section, which is adjacent to
31857 the @code{.sdata} section. The @option{-msdata=eabi} option is
31858 incompatible with the @option{-mrelocatable} option. The
31859 @option{-msdata=eabi} option also sets the @option{-memb} option.
31861 @opindex msdata=sysv
31863 On System V.4 and embedded PowerPC systems, put small global and static
31864 data in the @code{.sdata} section, which is pointed to by register
31865 @code{r13}. Put small uninitialized global and static data in the
31866 @code{.sbss} section, which is adjacent to the @code{.sdata} section.
31867 The @option{-msdata=sysv} option is incompatible with the
31868 @option{-mrelocatable} option.
31870 @opindex msdata=default
31872 @item -msdata=default
31874 On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
31875 compile code the same as @option{-msdata=eabi}, otherwise compile code the
31876 same as @option{-msdata=sysv}.
31878 @opindex msdata=data
31880 On System V.4 and embedded PowerPC systems, put small global
31881 data in the @code{.sdata} section. Put small uninitialized global
31882 data in the @code{.sbss} section. Do not use register @code{r13}
31883 to address small data however. This is the default behavior unless
31884 other @option{-msdata} options are used.
31886 @opindex msdata=none
31890 On embedded PowerPC systems, put all initialized global and static data
31891 in the @code{.data} section, and all uninitialized data in the
31892 @code{.bss} section.
31894 @opindex mreadonly-in-sdata
31895 @opindex mno-readonly-in-sdata
31896 @item -mreadonly-in-sdata
31897 Put read-only objects in the @code{.sdata} section as well. This is the
31900 @opindex mblock-move-inline-limit
31901 @item -mblock-move-inline-limit=@var{num}
31902 Inline all block moves (such as calls to @code{memcpy} or structure
31903 copies) less than or equal to @var{num} bytes. The minimum value for
31904 @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
31905 targets. The default value is target-specific.
31907 @opindex mblock-compare-inline-limit
31908 @item -mblock-compare-inline-limit=@var{num}
31909 Generate non-looping inline code for all block compares (such as calls
31910 to @code{memcmp} or structure compares) less than or equal to @var{num}
31911 bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
31912 block compare is disabled. The default value is target-specific.
31914 @opindex mblock-compare-inline-loop-limit
31915 @item -mblock-compare-inline-loop-limit=@var{num}
31916 Generate an inline expansion using loop code for all block compares that
31917 are less than or equal to @var{num} bytes, but greater than the limit
31918 for non-loop inline block compare expansion. If the block length is not
31919 constant, at most @var{num} bytes will be compared before @code{memcmp}
31920 is called to compare the remainder of the block. The default value is
31923 @opindex mstring-compare-inline-limit
31924 @item -mstring-compare-inline-limit=@var{num}
31925 Compare at most @var{num} string bytes with inline code.
31926 If the difference or end of string is not found at the
31927 end of the inline compare a call to @code{strcmp} or @code{strncmp} will
31928 take care of the rest of the comparison. The default is 64 bytes.
31931 @cindex smaller data references (PowerPC)
31932 @cindex .sdata/.sdata2 references (PowerPC)
31934 On embedded PowerPC systems, put global and static items less than or
31935 equal to @var{num} bytes into the small data or BSS sections instead of
31936 the normal data or BSS section. By default, @var{num} is 8. The
31937 @option{-G @var{num}} switch is also passed to the linker.
31938 All modules should be compiled with the same @option{-G @var{num}} value.
31941 @opindex mno-regnames
31943 @itemx -mno-regnames
31944 On System V.4 and embedded PowerPC systems do (do not) emit register
31945 names in the assembly language output using symbolic forms.
31948 @opindex mno-longcall
31950 @itemx -mno-longcall
31951 By default assume that all calls are far away so that a longer and more
31952 expensive calling sequence is required. This is required for calls
31953 farther than 32 megabytes (33,554,432 bytes) from the current location.
31954 A short call is generated if the compiler knows
31955 the call cannot be that far away. This setting can be overridden by
31956 the @code{shortcall} function attribute, or by @code{#pragma
31959 Some linkers are capable of detecting out-of-range calls and generating
31960 glue code on the fly. On these systems, long calls are unnecessary and
31961 generate slower code. As of this writing, the AIX linker can do this,
31962 as can the GNU linker for PowerPC/64. It is planned to add this feature
31963 to the GNU linker for 32-bit PowerPC systems as well.
31965 On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
31966 GCC can generate long calls using an inline PLT call sequence (see
31967 @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
31968 ELFv1 (big-endian) do not support inline PLT calls.
31970 On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
31971 callee, L42}, plus a @dfn{branch island} (glue code). The two target
31972 addresses represent the callee and the branch island. The
31973 Darwin/PPC linker prefers the first address and generates a @code{bl
31974 callee} if the PPC @code{bl} instruction reaches the callee directly;
31975 otherwise, the linker generates @code{bl L42} to call the branch
31976 island. The branch island is appended to the body of the
31977 calling function; it computes the full 32-bit address of the callee
31980 On Mach-O (Darwin) systems, this option directs the compiler emit to
31981 the glue for every direct call, and the Darwin linker decides whether
31982 to use or discard it.
31984 In the future, GCC may ignore all longcall specifications
31985 when the linker is known to generate glue.
31988 @opindex mno-pltseq
31991 Implement (do not implement) -fno-plt and long calls using an inline
31992 PLT call sequence that supports lazy linking and long calls to
31993 functions in dlopen'd shared libraries. Inline PLT calls are only
31994 supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
31995 linkers, and are enabled by default if the support is detected when
31996 configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
31997 configured with @option{--enable-secureplt}. @option{-mpltseq} code
31998 and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
32001 @opindex mtls-markers
32002 @opindex mno-tls-markers
32003 @item -mtls-markers
32004 @itemx -mno-tls-markers
32005 Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
32006 specifying the function argument. The relocation allows the linker to
32007 reliably associate function call with argument setup instructions for
32008 TLS optimization, which in turn allows GCC to better schedule the
32014 This option enables use of the reciprocal estimate and
32015 reciprocal square root estimate instructions with additional
32016 Newton-Raphson steps to increase precision instead of doing a divide or
32017 square root and divide for floating-point arguments. You should use
32018 the @option{-ffast-math} option when using @option{-mrecip} (or at
32019 least @option{-funsafe-math-optimizations},
32020 @option{-ffinite-math-only}, @option{-freciprocal-math} and
32021 @option{-fno-trapping-math}). Note that while the throughput of the
32022 sequence is generally higher than the throughput of the non-reciprocal
32023 instruction, the precision of the sequence can be decreased by up to 2
32024 ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
32027 @opindex mrecip=opt
32028 @item -mrecip=@var{opt}
32029 This option controls which reciprocal estimate instructions
32030 may be used. @var{opt} is a comma-separated list of options, which may
32031 be preceded by a @code{!} to invert the option:
32036 Enable all estimate instructions.
32039 Enable the default instructions, equivalent to @option{-mrecip}.
32042 Disable all estimate instructions, equivalent to @option{-mno-recip}.
32045 Enable the reciprocal approximation instructions for both
32046 single and double precision.
32049 Enable the single-precision reciprocal approximation instructions.
32052 Enable the double-precision reciprocal approximation instructions.
32055 Enable the reciprocal square root approximation instructions for both
32056 single and double precision.
32059 Enable the single-precision reciprocal square root approximation instructions.
32062 Enable the double-precision reciprocal square root approximation instructions.
32066 So, for example, @option{-mrecip=all,!rsqrtd} enables
32067 all of the reciprocal estimate instructions, except for the
32068 @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
32069 which handle the double-precision reciprocal square root calculations.
32071 @opindex mrecip-precision
32072 @item -mrecip-precision
32073 @itemx -mno-recip-precision
32074 Assume (do not assume) that the reciprocal estimate instructions
32075 provide higher-precision estimates than is mandated by the PowerPC
32076 ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
32077 @option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
32078 The double-precision square root estimate instructions are not generated by
32079 default on low-precision machines, since they do not provide an
32080 estimate that converges after three steps.
32082 @opindex mveclibabi
32083 @item -mveclibabi=@var{type}
32084 Specifies the ABI type to use for vectorizing intrinsics using an
32085 external library. The only type supported at present is @samp{mass},
32086 which specifies to use IBM's Mathematical Acceleration Subsystem
32087 (MASS) libraries for vectorizing intrinsics using external libraries.
32088 GCC currently emits calls to @code{acosd2}, @code{acosf4},
32089 @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
32090 @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
32091 @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
32092 @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
32093 @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
32094 @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
32095 @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
32096 @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
32097 @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
32098 @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
32099 @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
32100 @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
32101 @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
32102 for power7. Both @option{-ftree-vectorize} and
32103 @option{-funsafe-math-optimizations} must also be enabled. The MASS
32104 libraries must be specified at link time.
32109 Generate (do not generate) the @code{friz} instruction when the
32110 @option{-funsafe-math-optimizations} option is used to optimize
32111 rounding of floating-point values to 64-bit integer and back to floating
32112 point. The @code{friz} instruction does not return the same value if
32113 the floating-point number is too large to fit in an integer.
32115 @opindex mpointers-to-nested-functions
32116 @item -mpointers-to-nested-functions
32117 @itemx -mno-pointers-to-nested-functions
32118 Generate (do not generate) code to load up the static chain register
32119 (@code{r11}) when calling through a pointer on AIX and 64-bit Linux
32120 systems where a function pointer points to a 3-word descriptor giving
32121 the function address, TOC value to be loaded in register @code{r2}, and
32122 static chain value to be loaded in register @code{r11}. The
32123 @option{-mpointers-to-nested-functions} is on by default. You cannot
32124 call through pointers to nested functions or pointers
32125 to functions compiled in other languages that use the static chain if
32126 you use @option{-mno-pointers-to-nested-functions}.
32128 @opindex msave-toc-indirect
32129 @item -msave-toc-indirect
32130 @itemx -mno-save-toc-indirect
32131 Generate (do not generate) code to save the TOC value in the reserved
32132 stack location in the function prologue if the function calls through
32133 a pointer on AIX and 64-bit Linux systems. If the TOC value is not
32134 saved in the prologue, it is saved just before the call through the
32135 pointer. The @option{-mno-save-toc-indirect} option is the default.
32137 @opindex mcompat-align-parm
32138 @item -mcompat-align-parm
32139 @itemx -mno-compat-align-parm
32140 Generate (do not generate) code to pass structure parameters with a
32141 maximum alignment of 64 bits, for compatibility with older versions
32144 Older versions of GCC (prior to 4.9.0) incorrectly did not align a
32145 structure parameter on a 128-bit boundary when that structure contained
32146 a member requiring 128-bit alignment. This is corrected in more
32147 recent versions of GCC. This option may be used to generate code
32148 that is compatible with functions compiled with older versions of
32151 The @option{-mno-compat-align-parm} option is the default.
32153 @opindex mstack-protector-guard
32154 @opindex mstack-protector-guard-reg
32155 @opindex mstack-protector-guard-offset
32156 @opindex mstack-protector-guard-symbol
32157 @item -mstack-protector-guard=@var{guard}
32158 @itemx -mstack-protector-guard-reg=@var{reg}
32159 @itemx -mstack-protector-guard-offset=@var{offset}
32160 @itemx -mstack-protector-guard-symbol=@var{symbol}
32161 Generate stack protection code using canary at @var{guard}. Supported
32162 locations are @samp{global} for global canary or @samp{tls} for per-thread
32163 canary in the TLS block (the default with GNU libc version 2.4 or later).
32165 With the latter choice the options
32166 @option{-mstack-protector-guard-reg=@var{reg}} and
32167 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
32168 which register to use as base register for reading the canary, and from what
32169 offset from that base register. The default for those is as specified in the
32170 relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
32171 the offset with a symbol reference to a canary in the TLS block.
32177 Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
32178 option requires that the medium code model (@option{-mcmodel=medium})
32179 and prefixed addressing (@option{-mprefixed}) options are enabled.
32182 @opindex mno-prefixed
32184 @itemx -mno-prefixed
32185 Generate (do not generate) addressing modes using prefixed load and
32186 store instructions. The @option{-mprefixed} option requires that
32187 the option @option{-mcpu=power10} (or later) is enabled.
32193 Generate (do not generate) the MMA instructions. The @option{-mma}
32194 option requires that the option @option{-mcpu=power10} (or later)
32197 @opindex mrop-protect
32198 @opindex mno-rop-protect
32199 @item -mrop-protect
32200 @itemx -mno-rop-protect
32201 Generate (do not generate) ROP protection instructions when the target
32202 processor supports them. Currently this option disables the shrink-wrap
32203 optimization (@option{-fshrink-wrap}).
32205 @opindex mprivileged
32206 @opindex mno-privileged
32208 @itemx -mno-privileged
32209 Generate (do not generate) code that will run in privileged state.
32211 @opindex block-ops-unaligned-vsx
32212 @opindex no-block-ops-unaligned-vsx
32213 @item -mblock-ops-unaligned-vsx
32214 @itemx -mno-block-ops-unaligned-vsx
32215 Generate (do not generate) unaligned vsx loads and stores for
32216 inline expansion of @code{memcpy} and @code{memmove}.
32218 @item --param rs6000-vect-unroll-limit=
32219 The vectorizer will check with target information to determine whether it
32220 would be beneficial to unroll the main vectorized loop and by how much. This
32221 parameter sets the upper bound of how much the vectorizer will unroll the main
32222 loop. The default value is four.
32227 @subsection RX Options
32230 These command-line options are defined for RX targets:
32233 @opindex m64bit-doubles
32234 @opindex m32bit-doubles
32235 @item -m64bit-doubles
32236 @itemx -m32bit-doubles
32237 Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
32238 or 32 bits (@option{-m32bit-doubles}) in size. The default is
32239 @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
32240 works on 32-bit values, which is why the default is
32241 @option{-m32bit-doubles}.
32247 Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
32248 floating-point hardware. The default is enabled for the RX600
32249 series and disabled for the RX200 series.
32251 Floating-point instructions are only generated for 32-bit floating-point
32252 values, however, so the FPU hardware is not used for doubles if the
32253 @option{-m64bit-doubles} option is used.
32255 @emph{Note} If the @option{-fpu} option is enabled then
32256 @option{-funsafe-math-optimizations} is also enabled automatically.
32257 This is because the RX FPU instructions are themselves unsafe.
32260 @item -mcpu=@var{name}
32261 Selects the type of RX CPU to be targeted. Currently three types are
32262 supported, the generic @samp{RX600} and @samp{RX200} series hardware and
32263 the specific @samp{RX610} CPU. The default is @samp{RX600}.
32265 The only difference between @samp{RX600} and @samp{RX610} is that the
32266 @samp{RX610} does not support the @code{MVTIPL} instruction.
32268 The @samp{RX200} series does not have a hardware floating-point unit
32269 and so @option{-nofpu} is enabled by default when this type is
32272 @opindex mbig-endian-data
32273 @opindex mlittle-endian-data
32274 @item -mbig-endian-data
32275 @itemx -mlittle-endian-data
32276 Store data (but not code) in the big-endian format. The default is
32277 @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
32280 @opindex msmall-data-limit
32281 @item -msmall-data-limit=@var{N}
32282 Specifies the maximum size in bytes of global and static variables
32283 which can be placed into the small data area. Using the small data
32284 area can lead to smaller and faster code, but the size of area is
32285 limited and it is up to the programmer to ensure that the area does
32286 not overflow. Also when the small data area is used one of the RX's
32287 registers (usually @code{r13}) is reserved for use pointing to this
32288 area, so it is no longer available for use by the compiler. This
32289 could result in slower and/or larger code if variables are pushed onto
32290 the stack instead of being held in this register.
32292 Note, common variables (variables that have not been initialized) and
32293 constants are not placed into the small data area as they are assigned
32294 to other sections in the output executable.
32296 The default value is zero, which disables this feature. Note, this
32297 feature is not enabled by default with higher optimization levels
32298 (@option{-O2} etc) because of the potentially detrimental effects of
32299 reserving a register. It is up to the programmer to experiment and
32300 discover whether this feature is of benefit to their program. See the
32301 description of the @option{-mpid} option for a description of how the
32302 actual register to hold the small data area pointer is chosen.
32308 Use the simulator runtime. The default is to use the libgloss
32309 board-specific runtime.
32311 @opindex mas100-syntax
32312 @opindex mno-as100-syntax
32313 @item -mas100-syntax
32314 @itemx -mno-as100-syntax
32315 When generating assembler output use a syntax that is compatible with
32316 Renesas's AS100 assembler. This syntax can also be handled by the GAS
32317 assembler, but it has some restrictions so it is not generated by default.
32319 @opindex mmax-constant-size
32320 @item -mmax-constant-size=@var{N}
32321 Specifies the maximum size, in bytes, of a constant that can be used as
32322 an operand in a RX instruction. Although the RX instruction set does
32323 allow constants of up to 4 bytes in length to be used in instructions,
32324 a longer value equates to a longer instruction. Thus in some
32325 circumstances it can be beneficial to restrict the size of constants
32326 that are used in instructions. Constants that are too big are instead
32327 placed into a constant pool and referenced via register indirection.
32329 The value @var{N} can be between 0 and 4. A value of 0 (the default)
32330 or 4 means that constants of any size are allowed.
32334 Enable linker relaxation. Linker relaxation is a process whereby the
32335 linker attempts to reduce the size of a program by finding shorter
32336 versions of various instructions. Disabled by default.
32338 @opindex mint-register
32339 @item -mint-register=@var{N}
32340 Specify the number of registers to reserve for fast interrupt handler
32341 functions. The value @var{N} can be between 0 and 4. A value of 1
32342 means that register @code{r13} is reserved for the exclusive use
32343 of fast interrupt handlers. A value of 2 reserves @code{r13} and
32344 @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
32345 @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
32346 A value of 0, the default, does not reserve any registers.
32348 @opindex msave-acc-in-interrupts
32349 @item -msave-acc-in-interrupts
32350 Specifies that interrupt handler functions should preserve the
32351 accumulator register. This is only necessary if normal code might use
32352 the accumulator register, for example because it performs 64-bit
32353 multiplications. The default is to ignore the accumulator as this
32354 makes the interrupt handlers faster.
32360 Enables the generation of position independent data. When enabled any
32361 access to constant data is done via an offset from a base address
32362 held in a register. This allows the location of constant data to be
32363 determined at run time without requiring the executable to be
32364 relocated, which is a benefit to embedded applications with tight
32365 memory constraints. Data that can be modified is not affected by this
32368 Note, using this feature reserves a register, usually @code{r13}, for
32369 the constant data base address. This can result in slower and/or
32370 larger code, especially in complicated functions.
32372 The actual register chosen to hold the constant data base address
32373 depends upon whether the @option{-msmall-data-limit} and/or the
32374 @option{-mint-register} command-line options are enabled. Starting
32375 with register @code{r13} and proceeding downwards, registers are
32376 allocated first to satisfy the requirements of @option{-mint-register},
32377 then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
32378 is possible for the small data area register to be @code{r8} if both
32379 @option{-mint-register=4} and @option{-mpid} are specified on the
32382 By default this feature is not enabled. The default can be restored
32383 via the @option{-mno-pid} command-line option.
32385 @opindex mno-warn-multiple-fast-interrupts
32386 @opindex mwarn-multiple-fast-interrupts
32387 @item -mno-warn-multiple-fast-interrupts
32388 @itemx -mwarn-multiple-fast-interrupts
32389 Prevents GCC from issuing a warning message if it finds more than one
32390 fast interrupt handler when it is compiling a file. The default is to
32391 issue a warning for each extra fast interrupt handler found, as the RX
32392 only supports one such interrupt.
32394 @opindex mallow-string-insns
32395 @opindex mno-allow-string-insns
32396 @item -mallow-string-insns
32397 @itemx -mno-allow-string-insns
32398 Enables or disables the use of the string manipulation instructions
32399 @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
32400 @code{SWHILE} and also the @code{RMPA} instruction. These
32401 instructions may prefetch data, which is not safe to do if accessing
32402 an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
32403 for more information).
32405 The default is to allow these instructions, but it is not possible for
32406 GCC to reliably detect all circumstances where a string instruction
32407 might be used to access an I/O register, so their use cannot be
32408 disabled automatically. Instead it is reliant upon the programmer to
32409 use the @option{-mno-allow-string-insns} option if their program
32410 accesses I/O space.
32412 When the instructions are enabled GCC defines the C preprocessor
32413 symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
32414 symbol @code{__RX_DISALLOW_STRING_INSNS__}.
32420 Use only (or not only) @code{JSR} instructions to access functions.
32421 This option can be used when code size exceeds the range of @code{BSR}
32422 instructions. Note that @option{-mno-jsr} does not mean to not use
32423 @code{JSR} but instead means that any type of branch may be used.
32426 @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
32427 has special significance to the RX port when used with the
32428 @code{interrupt} function attribute. This attribute indicates a
32429 function intended to process fast interrupts. GCC ensures
32430 that it only uses the registers @code{r10}, @code{r11}, @code{r12}
32431 and/or @code{r13} and only provided that the normal use of the
32432 corresponding registers have been restricted via the
32433 @option{-ffixed-@var{reg}} or @option{-mint-register} command-line
32436 @node S/390 and zSeries Options
32437 @subsection S/390 and zSeries Options
32438 @cindex S/390 and zSeries Options
32440 These are the @samp{-m} options defined for the S/390 and zSeries architecture.
32443 @opindex mhard-float
32444 @opindex msoft-float
32446 @itemx -msoft-float
32447 Use (do not use) the hardware floating-point instructions and registers
32448 for floating-point operations. When @option{-msoft-float} is specified,
32449 functions in @file{libgcc.a} are used to perform floating-point
32450 operations. When @option{-mhard-float} is specified, the compiler
32451 generates IEEE floating-point instructions. This is the default.
32454 @opindex mno-hard-dfp
32456 @itemx -mno-hard-dfp
32457 Use (do not use) the hardware decimal-floating-point instructions for
32458 decimal-floating-point operations. When @option{-mno-hard-dfp} is
32459 specified, functions in @file{libgcc.a} are used to perform
32460 decimal-floating-point operations. When @option{-mhard-dfp} is
32461 specified, the compiler generates decimal-floating-point hardware
32462 instructions. This is the default for @option{-march=z9-ec} or higher.
32464 @opindex mlong-double-64
32465 @opindex mlong-double-128
32466 @item -mlong-double-64
32467 @itemx -mlong-double-128
32468 These switches control the size of @code{long double} type. A size
32469 of 64 bits makes the @code{long double} type equivalent to the @code{double}
32470 type. This is the default.
32472 @opindex mbackchain
32473 @opindex mno-backchain
32475 @itemx -mno-backchain
32476 Store (do not store) the address of the caller's frame as backchain pointer
32477 into the callee's stack frame.
32478 A backchain may be needed to allow debugging using tools that do not understand
32479 DWARF call frame information.
32480 When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
32481 at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
32482 the backchain is placed into the topmost word of the 96/160 byte register
32485 In general, code compiled with @option{-mbackchain} is call-compatible with
32486 code compiled with @option{-mno-backchain}; however, use of the backchain
32487 for debugging purposes usually requires that the whole binary is built with
32488 @option{-mbackchain}. Note that the combination of @option{-mbackchain},
32489 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
32490 to build a linux kernel use @option{-msoft-float}.
32492 The default is to not maintain the backchain.
32494 @opindex mpacked-stack
32495 @opindex mno-packed-stack
32496 @item -mpacked-stack
32497 @itemx -mno-packed-stack
32498 Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
32499 specified, the compiler uses the all fields of the 96/160 byte register save
32500 area only for their default purpose; unused fields still take up stack space.
32501 When @option{-mpacked-stack} is specified, register save slots are densely
32502 packed at the top of the register save area; unused space is reused for other
32503 purposes, allowing for more efficient use of the available stack space.
32504 However, when @option{-mbackchain} is also in effect, the topmost word of
32505 the save area is always used to store the backchain, and the return address
32506 register is always saved two words below the backchain.
32508 As long as the stack frame backchain is not used, code generated with
32509 @option{-mpacked-stack} is call-compatible with code generated with
32510 @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
32511 S/390 or zSeries generated code that uses the stack frame backchain at run
32512 time, not just for debugging purposes. Such code is not call-compatible
32513 with code compiled with @option{-mpacked-stack}. Also, note that the
32514 combination of @option{-mbackchain},
32515 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
32516 to build a linux kernel use @option{-msoft-float}.
32518 The default is to not use the packed stack layout.
32520 @opindex msmall-exec
32521 @opindex mno-small-exec
32523 @itemx -mno-small-exec
32524 Generate (or do not generate) code using the @code{bras} instruction
32525 to do subroutine calls.
32526 This only works reliably if the total executable size does not
32527 exceed 64k. The default is to use the @code{basr} instruction instead,
32528 which does not have this limitation.
32534 When @option{-m31} is specified, generate code compliant to the
32535 GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
32536 code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
32537 particular to generate 64-bit instructions. For the @samp{s390}
32538 targets, the default is @option{-m31}, while the @samp{s390x}
32539 targets default to @option{-m64}.
32545 When @option{-mzarch} is specified, generate code using the
32546 instructions available on z/Architecture.
32547 When @option{-mesa} is specified, generate code using the
32548 instructions available on ESA/390. Note that @option{-mesa} is
32549 not possible with @option{-m64}.
32550 When generating code compliant to the GNU/Linux for S/390 ABI,
32551 the default is @option{-mesa}. When generating code compliant
32552 to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
32558 The @option{-mhtm} option enables a set of builtins making use of
32559 instructions available with the transactional execution facility
32560 introduced with the IBM zEnterprise EC12 machine generation
32561 @ref{S/390 System z Built-in Functions}.
32562 @option{-mhtm} is enabled by default when using @option{-march=zEC12}.
32568 When @option{-mvx} is specified, generate code using the instructions
32569 available with the vector extension facility introduced with the IBM
32570 z13 machine generation.
32571 This option changes the ABI for some vector type values with regard to
32572 alignment and calling conventions. In case vector type values are
32573 being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
32574 command will be added to mark the resulting binary with the ABI used.
32575 @option{-mvx} is enabled by default when using @option{-march=z13}.
32578 @opindex mno-zvector
32580 @itemx -mno-zvector
32581 The @option{-mzvector} option enables vector language extensions and
32582 builtins using instructions available with the vector extension
32583 facility introduced with the IBM z13 machine generation.
32584 This option adds support for @samp{vector} to be used as a keyword to
32585 define vector type variables and arguments. @samp{vector} is only
32586 available when GNU extensions are enabled. It will not be expanded
32587 when requesting strict standard compliance e.g.@: with @option{-std=c99}.
32588 In addition to the GCC low-level builtins @option{-mzvector} enables
32589 a set of builtins added for compatibility with AltiVec-style
32590 implementations like Power and Cell. In order to make use of these
32591 builtins the header file @file{vecintrin.h} needs to be included.
32592 @option{-mzvector} is disabled by default.
32598 Generate (or do not generate) code using the @code{mvcle} instruction
32599 to perform block moves. When @option{-mno-mvcle} is specified,
32600 use a @code{mvc} loop instead. This is the default unless optimizing for
32607 Print (or do not print) additional debug information when compiling.
32608 The default is to not print debug information.
32611 @item -march=@var{cpu-type}
32612 Generate code that runs on @var{cpu-type}, which is the name of a
32613 system representing a certain processor type. Possible values for
32614 @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
32615 @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
32616 @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
32617 @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
32618 @samp{z16}/@samp{arch14}, and @samp{native}.
32620 The default is @option{-march=z900}.
32622 Specifying @samp{native} as cpu type can be used to select the best
32623 architecture option for the host processor.
32624 @option{-march=native} has no effect if GCC does not recognize the
32628 @item -mtune=@var{cpu-type}
32629 Tune to @var{cpu-type} everything applicable about the generated code,
32630 except for the ABI and the set of available instructions.
32631 The list of @var{cpu-type} values is the same as for @option{-march}.
32632 The default is the value used for @option{-march}.
32634 @opindex mtpf-trace
32635 @opindex mno-tpf-trace
32637 @itemx -mno-tpf-trace
32638 Generate code that adds (does not add) in TPF OS specific branches to trace
32639 routines in the operating system. This option is off by default, even
32640 when compiling for the TPF OS@.
32642 @opindex mtpf-trace-skip
32643 @opindex mno-tpf-trace-skip
32644 @item -mtpf-trace-skip
32645 @itemx -mno-tpf-trace-skip
32646 Generate code that changes (does not change) the default branch
32647 targets enabled by @option{-mtpf-trace} to point to specialized trace
32648 routines providing the ability of selectively skipping function trace
32649 entries for the TPF OS. This option is off by default, even when
32650 compiling for the TPF OS and specifying @option{-mtpf-trace}.
32652 @opindex mfused-madd
32653 @opindex mno-fused-madd
32655 @itemx -mno-fused-madd
32656 Generate code that uses (does not use) the floating-point multiply and
32657 accumulate instructions. These instructions are generated by default if
32658 hardware floating point is used.
32660 @opindex mwarn-framesize
32661 @item -mwarn-framesize=@var{framesize}
32662 Emit a warning if the current function exceeds the given frame size. Because
32663 this is a compile-time check it doesn't need to be a real problem when the program
32664 runs. It is intended to identify functions that most probably cause
32665 a stack overflow. It is useful to be used in an environment with limited stack
32666 size e.g.@: the linux kernel.
32668 @opindex mwarn-dynamicstack
32669 @item -mwarn-dynamicstack
32670 Emit a warning if the function calls @code{alloca} or uses dynamically-sized
32671 arrays. This is generally a bad idea with a limited stack size.
32673 @opindex mstack-guard
32674 @opindex mstack-size
32675 @item -mstack-guard=@var{stack-guard}
32676 @itemx -mstack-size=@var{stack-size}
32677 If these options are provided the S/390 back end emits additional instructions in
32678 the function prologue that trigger a trap if the stack size is @var{stack-guard}
32679 bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
32680 If the @var{stack-guard} option is omitted the smallest power of 2 larger than
32681 the frame size of the compiled function is chosen.
32682 These options are intended to be used to help debugging stack overflow problems.
32683 The additionally emitted code causes only little overhead and hence can also be
32684 used in production-like systems without greater performance degradation. The given
32685 values have to be exact powers of 2 and @var{stack-size} has to be greater than
32686 @var{stack-guard} without exceeding 64k.
32687 In order to be efficient the extra code makes the assumption that the stack starts
32688 at an address aligned to the value given by @var{stack-size}.
32689 The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
32692 @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
32693 If the hotpatch option is enabled, a ``hot-patching'' function
32694 prologue is generated for all functions in the compilation unit.
32695 The funtion label is prepended with the given number of two-byte
32696 NOP instructions (@var{pre-halfwords}, maximum 1000000). After
32697 the label, 2 * @var{post-halfwords} bytes are appended, using the
32698 largest NOP like instructions the architecture allows (maximum
32701 If both arguments are zero, hotpatching is disabled.
32703 This option can be overridden for individual functions with the
32704 @code{hotpatch} attribute.
32708 @subsection SH Options
32710 These @samp{-m} options are defined for the SH implementations:
32715 Generate code for the SH1.
32719 Generate code for the SH2.
32722 Generate code for the SH2e.
32726 Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
32727 that the floating-point unit is not used.
32729 @opindex m2a-single-only
32730 @item -m2a-single-only
32731 Generate code for the SH2a-FPU, in such a way that no double-precision
32732 floating-point operations are used.
32734 @opindex m2a-single
32736 Generate code for the SH2a-FPU assuming the floating-point unit is in
32737 single-precision mode by default.
32741 Generate code for the SH2a-FPU assuming the floating-point unit is in
32742 double-precision mode by default.
32746 Generate code for the SH3.
32750 Generate code for the SH3e.
32754 Generate code for the SH4 without a floating-point unit.
32756 @opindex m4-single-only
32757 @item -m4-single-only
32758 Generate code for the SH4 with a floating-point unit that only
32759 supports single-precision arithmetic.
32763 Generate code for the SH4 assuming the floating-point unit is in
32764 single-precision mode by default.
32768 Generate code for the SH4.
32772 Generate code for SH4-100.
32774 @opindex m4-100-nofpu
32775 @item -m4-100-nofpu
32776 Generate code for SH4-100 in such a way that the
32777 floating-point unit is not used.
32779 @opindex m4-100-single
32780 @item -m4-100-single
32781 Generate code for SH4-100 assuming the floating-point unit is in
32782 single-precision mode by default.
32784 @opindex m4-100-single-only
32785 @item -m4-100-single-only
32786 Generate code for SH4-100 in such a way that no double-precision
32787 floating-point operations are used.
32791 Generate code for SH4-200.
32793 @opindex m4-200-nofpu
32794 @item -m4-200-nofpu
32795 Generate code for SH4-200 without in such a way that the
32796 floating-point unit is not used.
32798 @opindex m4-200-single
32799 @item -m4-200-single
32800 Generate code for SH4-200 assuming the floating-point unit is in
32801 single-precision mode by default.
32803 @opindex m4-200-single-only
32804 @item -m4-200-single-only
32805 Generate code for SH4-200 in such a way that no double-precision
32806 floating-point operations are used.
32810 Generate code for SH4-300.
32812 @opindex m4-300-nofpu
32813 @item -m4-300-nofpu
32814 Generate code for SH4-300 without in such a way that the
32815 floating-point unit is not used.
32817 @opindex m4-300-single
32818 @item -m4-300-single
32819 Generate code for SH4-300 in such a way that no double-precision
32820 floating-point operations are used.
32822 @opindex m4-300-single-only
32823 @item -m4-300-single-only
32824 Generate code for SH4-300 in such a way that no double-precision
32825 floating-point operations are used.
32829 Generate code for SH4-340 (no MMU, no FPU).
32833 Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
32838 Generate code for the SH4al-dsp, or for a SH4a in such a way that the
32839 floating-point unit is not used.
32841 @opindex m4a-single-only
32842 @item -m4a-single-only
32843 Generate code for the SH4a, in such a way that no double-precision
32844 floating-point operations are used.
32846 @opindex m4a-single
32848 Generate code for the SH4a assuming the floating-point unit is in
32849 single-precision mode by default.
32853 Generate code for the SH4a.
32857 Same as @option{-m4a-nofpu}, except that it implicitly passes
32858 @option{-dsp} to the assembler. GCC doesn't generate any DSP
32859 instructions at the moment.
32863 Compile code for the processor in big-endian mode.
32867 Compile code for the processor in little-endian mode.
32871 Align doubles at 64-bit boundaries. Note that this changes the calling
32872 conventions, and thus some functions from the standard C library do
32873 not work unless you recompile it first with @option{-mdalign}.
32877 Shorten some address references at link time, when possible; uses the
32878 linker option @option{-relax}.
32882 Use 32-bit offsets in @code{switch} tables. The default is to use
32887 Enable the use of bit manipulation instructions on SH2A.
32891 Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
32892 alignment constraints.
32896 Comply with the calling conventions defined by Renesas.
32898 @opindex mno-renesas
32900 Comply with the calling conventions defined for GCC before the Renesas
32901 conventions were available. This option is the default for all
32902 targets of the SH toolchain.
32904 @opindex mnomacsave
32906 Mark the @code{MAC} register as call-clobbered, even if
32907 @option{-mrenesas} is given.
32913 Control the IEEE compliance of floating-point comparisons, which affects the
32914 handling of cases where the result of a comparison is unordered. By default
32915 @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
32916 enabled @option{-mno-ieee} is implicitly set, which results in faster
32917 floating-point greater-equal and less-equal comparisons. The implicit settings
32918 can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
32920 @opindex minline-ic_invalidate
32921 @item -minline-ic_invalidate
32922 Inline code to invalidate instruction cache entries after setting up
32923 nested function trampolines.
32924 This option has no effect if @option{-musermode} is in effect and the selected
32925 code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
32927 If the selected code generation option does not allow the use of the @code{icbi}
32928 instruction, and @option{-musermode} is not in effect, the inlined code
32929 manipulates the instruction cache address array directly with an associative
32930 write. This not only requires privileged mode at run time, but it also
32931 fails if the cache line had been mapped via the TLB and has become unmapped.
32935 Dump instruction size and location in the assembly code.
32937 @opindex mpadstruct
32939 This option is deprecated. It pads structures to multiple of 4 bytes,
32940 which is incompatible with the SH ABI@.
32942 @opindex matomic-model=@var{model}
32943 @item -matomic-model=@var{model}
32944 Sets the model of atomic operations and additional parameters as a comma
32945 separated list. For details on the atomic built-in functions see
32946 @ref{__atomic Builtins}. The following models and parameters are supported:
32951 Disable compiler generated atomic sequences and emit library calls for atomic
32952 operations. This is the default if the target is not @code{sh*-*-linux*}.
32955 Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
32956 built-in functions. The generated atomic sequences require additional support
32957 from the interrupt/exception handling code of the system and are only suitable
32958 for SH3* and SH4* single-core systems. This option is enabled by default when
32959 the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
32960 this option also partially utilizes the hardware atomic instructions
32961 @code{movli.l} and @code{movco.l} to create more efficient code, unless
32962 @samp{strict} is specified.
32965 Generate software atomic sequences that use a variable in the thread control
32966 block. This is a variation of the gUSA sequences which can also be used on
32967 SH1* and SH2* targets. The generated atomic sequences require additional
32968 support from the interrupt/exception handling code of the system and are only
32969 suitable for single-core systems. When using this model, the @samp{gbr-offset=}
32970 parameter has to be specified as well.
32973 Generate software atomic sequences that temporarily disable interrupts by
32974 setting @code{SR.IMASK = 1111}. This model works only when the program runs
32975 in privileged mode and is only suitable for single-core systems. Additional
32976 support from the interrupt/exception handling code of the system is not
32977 required. This model is enabled by default when the target is
32978 @code{sh*-*-linux*} and SH1* or SH2*.
32981 Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
32982 instructions only. This is only available on SH4A and is suitable for
32983 multi-core systems. Since the hardware instructions support only 32 bit atomic
32984 variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
32985 Code compiled with this option is also compatible with other software
32986 atomic model interrupt/exception handling systems if executed on an SH4A
32987 system. Additional support from the interrupt/exception handling code of the
32988 system is not required for this model.
32991 This parameter specifies the offset in bytes of the variable in the thread
32992 control block structure that should be used by the generated atomic sequences
32993 when the @samp{soft-tcb} model has been selected. For other models this
32994 parameter is ignored. The specified value must be an integer multiple of four
32995 and in the range 0-1020.
32998 This parameter prevents mixed usage of multiple atomic models, even if they
32999 are compatible, and makes the compiler generate atomic sequences of the
33000 specified model only.
33006 Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
33007 Notice that depending on the particular hardware and software configuration
33008 this can degrade overall performance due to the operand cache line flushes
33009 that are implied by the @code{tas.b} instruction. On multi-core SH4A
33010 processors the @code{tas.b} instruction must be used with caution since it
33011 can result in data corruption for certain cache configurations.
33013 @opindex mprefergot
33015 When generating position-independent code, emit function calls using
33016 the Global Offset Table instead of the Procedure Linkage Table.
33019 @opindex mno-usermode
33021 @itemx -mno-usermode
33022 Don't allow (allow) the compiler generating privileged mode code. Specifying
33023 @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
33024 inlined code would not work in user mode. @option{-musermode} is the default
33025 when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
33026 @option{-musermode} has no effect, since there is no user mode.
33028 @opindex multcost=@var{number}
33029 @item -multcost=@var{number}
33030 Set the cost to assume for a multiply insn.
33032 @opindex mdiv=@var{strategy}
33033 @item -mdiv=@var{strategy}
33034 Set the division strategy to be used for integer division operations.
33035 @var{strategy} can be one of:
33040 Calls a library function that uses the single-step division instruction
33041 @code{div1} to perform the operation. Division by zero calculates an
33042 unspecified result and does not trap. This is the default except for SH4,
33043 SH2A and SHcompact.
33046 Calls a library function that performs the operation in double precision
33047 floating point. Division by zero causes a floating-point exception. This is
33048 the default for SHcompact with FPU. Specifying this for targets that do not
33049 have a double precision FPU defaults to @code{call-div1}.
33052 Calls a library function that uses a lookup table for small divisors and
33053 the @code{div1} instruction with case distinction for larger divisors. Division
33054 by zero calculates an unspecified result and does not trap. This is the default
33055 for SH4. Specifying this for targets that do not have dynamic shift
33056 instructions defaults to @code{call-div1}.
33060 When a division strategy has not been specified the default strategy is
33061 selected based on the current target. For SH2A the default strategy is to
33062 use the @code{divs} and @code{divu} instructions instead of library function
33065 @opindex maccumulate-outgoing-args
33066 @item -maccumulate-outgoing-args
33067 Reserve space once for outgoing arguments in the function prologue rather
33068 than around each call. Generally beneficial for performance and size. Also
33069 needed for unwinding to avoid changing the stack frame around conditional code.
33071 @opindex mdivsi3_libfunc=@var{name}
33072 @item -mdivsi3_libfunc=@var{name}
33073 Set the name of the library function used for 32-bit signed division to
33075 This only affects the name used in the @samp{call} division strategies, and
33076 the compiler still expects the same sets of input/output/clobbered registers as
33077 if this option were not present.
33079 @opindex mfixed-range
33080 @item -mfixed-range=@var{register-range}
33081 Generate code treating the given register range as fixed registers.
33082 A fixed register is one that the register allocator cannot use. This is
33083 useful when compiling kernel code. A register range is specified as
33084 two registers separated by a dash. Multiple register ranges can be
33085 specified separated by a comma.
33087 @opindex mbranch-cost=@var{num}
33088 @item -mbranch-cost=@var{num}
33089 Assume @var{num} to be the cost for a branch instruction. Higher numbers
33090 make the compiler try to generate more branch-free code if possible.
33091 If not specified the value is selected depending on the processor type that
33092 is being compiled for.
33094 @opindex mzdcbranch
33095 @opindex mno-zdcbranch
33097 @itemx -mno-zdcbranch
33098 Assume (do not assume) that zero displacement conditional branch instructions
33099 @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
33100 compiler prefers zero displacement branch code sequences. This is
33101 enabled by default when generating code for SH4 and SH4A. It can be explicitly
33102 disabled by specifying @option{-mno-zdcbranch}.
33104 @opindex mcbranch-force-delay-slot
33105 @item -mcbranch-force-delay-slot
33106 Force the usage of delay slots for conditional branches, which stuffs the delay
33107 slot with a @code{nop} if a suitable instruction cannot be found. By default
33108 this option is disabled. It can be enabled to work around hardware bugs as
33109 found in the original SH7055.
33111 @opindex mfused-madd
33112 @opindex mno-fused-madd
33114 @itemx -mno-fused-madd
33115 Generate code that uses (does not use) the floating-point multiply and
33116 accumulate instructions. These instructions are generated by default
33117 if hardware floating point is used. The machine-dependent
33118 @option{-mfused-madd} option is now mapped to the machine-independent
33119 @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
33120 mapped to @option{-ffp-contract=off}.
33126 Allow or disallow the compiler to emit the @code{fsca} instruction for sine
33127 and cosine approximations. The option @option{-mfsca} must be used in
33128 combination with @option{-funsafe-math-optimizations}. It is enabled by default
33129 when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
33130 approximations even if @option{-funsafe-math-optimizations} is in effect.
33136 Allow or disallow the compiler to emit the @code{fsrra} instruction for
33137 reciprocal square root approximations. The option @option{-mfsrra} must be used
33138 in combination with @option{-funsafe-math-optimizations} and
33139 @option{-ffinite-math-only}. It is enabled by default when generating code for
33140 SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
33141 even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
33144 @opindex mpretend-cmove
33145 @item -mpretend-cmove
33146 Prefer zero-displacement conditional branches for conditional move instruction
33147 patterns. This can result in faster code on the SH4 processor.
33151 Generate code using the FDPIC ABI.
33155 @node Solaris 2 Options
33156 @subsection Solaris 2 Options
33157 @cindex Solaris 2 options
33159 These @samp{-m} options are supported on Solaris 2:
33162 @opindex mclear-hwcap
33163 @item -mclear-hwcap
33164 @option{-mclear-hwcap} tells the compiler to remove the hardware
33165 capabilities generated by the Solaris assembler. This is only necessary
33166 when object files use ISA extensions not supported by the current
33167 machine, but check at runtime whether or not to use them.
33169 @opindex mimpure-text
33170 @item -mimpure-text
33171 @option{-mimpure-text}, used in addition to @option{-shared}, tells
33172 the compiler to not pass @option{-z text} to the linker when linking a
33173 shared object. Using this option, you can link position-dependent
33174 code into a shared object.
33176 @option{-mimpure-text} suppresses the ``relocations remain against
33177 allocatable but non-writable sections'' linker error message.
33178 However, the necessary relocations trigger copy-on-write, and the
33179 shared object is not actually shared across processes. Instead of
33180 using @option{-mimpure-text}, you should compile all source code with
33181 @option{-fpic} or @option{-fPIC}.
33185 These switches are supported in addition to the above on Solaris 2:
33190 This is a synonym for @option{-pthread}.
33193 @node SPARC Options
33194 @subsection SPARC Options
33195 @cindex SPARC options
33197 These @samp{-m} options are supported on the SPARC:
33200 @opindex mno-app-regs
33202 @item -mno-app-regs
33204 Specify @option{-mapp-regs} to generate output using the global registers
33205 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
33206 global register 1, each global register 2 through 4 is then treated as an
33207 allocable register that is clobbered by function calls. This is the default.
33209 To be fully SVR4 ABI-compliant at the cost of some performance loss,
33210 specify @option{-mno-app-regs}. You should compile libraries and system
33211 software with this option.
33217 With @option{-mflat}, the compiler does not generate save/restore instructions
33218 and uses a ``flat'' or single register window model. This model is compatible
33219 with the regular register window model. The local registers and the input
33220 registers (0--5) are still treated as ``call-saved'' registers and are
33221 saved on the stack as needed.
33223 With @option{-mno-flat} (the default), the compiler generates save/restore
33224 instructions (except for leaf functions). This is the normal operating mode.
33227 @opindex mhard-float
33229 @itemx -mhard-float
33230 Generate output containing floating-point instructions. This is the
33234 @opindex msoft-float
33236 @itemx -msoft-float
33237 Generate output containing library calls for floating point.
33238 @strong{Warning:} the requisite libraries are not available for all SPARC
33239 targets. Normally the facilities of the machine's usual C compiler are
33240 used, but this cannot be done directly in cross-compilation. You must make
33241 your own arrangements to provide suitable library functions for
33242 cross-compilation. The embedded targets @samp{sparc-*-aout} and
33243 @samp{sparclite-*-*} do provide software floating-point support.
33245 @option{-msoft-float} changes the calling convention in the output file;
33246 therefore, it is only useful if you compile @emph{all} of a program with
33247 this option. In particular, you need to compile @file{libgcc.a}, the
33248 library that comes with GCC, with @option{-msoft-float} in order for
33251 @opindex mhard-quad-float
33252 @item -mhard-quad-float
33253 Generate output containing quad-word (long double) floating-point
33256 @opindex msoft-quad-float
33257 @item -msoft-quad-float
33258 Generate output containing library calls for quad-word (long double)
33259 floating-point instructions. The functions called are those specified
33260 in the SPARC ABI@. This is the default.
33262 As of this writing, there are no SPARC implementations that have hardware
33263 support for the quad-word floating-point instructions. They all invoke
33264 a trap handler for one of these instructions, and then the trap handler
33265 emulates the effect of the instruction. Because of the trap handler overhead,
33266 this is much slower than calling the ABI library routines. Thus the
33267 @option{-msoft-quad-float} option is the default.
33269 @opindex mno-unaligned-doubles
33270 @opindex munaligned-doubles
33271 @item -mno-unaligned-doubles
33272 @itemx -munaligned-doubles
33273 Assume that doubles have 8-byte alignment. This is the default.
33275 With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
33276 alignment only if they are contained in another type, or if they have an
33277 absolute address. Otherwise, it assumes they have 4-byte alignment.
33278 Specifying this option avoids some rare compatibility problems with code
33279 generated by other compilers. It is not the default because it results
33280 in a performance loss, especially for floating-point code.
33282 @opindex muser-mode
33283 @opindex mno-user-mode
33285 @itemx -mno-user-mode
33286 Do not generate code that can only run in supervisor mode. This is relevant
33287 only for the @code{casa} instruction emitted for the LEON3 processor. This
33290 @opindex mfaster-structs
33291 @opindex mno-faster-structs
33292 @item -mfaster-structs
33293 @itemx -mno-faster-structs
33294 With @option{-mfaster-structs}, the compiler assumes that structures
33295 should have 8-byte alignment. This enables the use of pairs of
33296 @code{ldd} and @code{std} instructions for copies in structure
33297 assignment, in place of twice as many @code{ld} and @code{st} pairs.
33298 However, the use of this changed alignment directly violates the SPARC
33299 ABI@. Thus, it's intended only for use on targets where the developer
33300 acknowledges that their resulting code is not directly in line with
33301 the rules of the ABI@.
33303 @opindex mstd-struct-return
33304 @opindex mno-std-struct-return
33305 @item -mstd-struct-return
33306 @itemx -mno-std-struct-return
33307 With @option{-mstd-struct-return}, the compiler generates checking code
33308 in functions returning structures or unions to detect size mismatches
33309 between the two sides of function calls, as per the 32-bit ABI@.
33311 The default is @option{-mno-std-struct-return}. This option has no effect
33318 Enable Local Register Allocation. This is the default for SPARC since GCC 7
33319 so @option{-mno-lra} needs to be passed to get old Reload.
33322 @item -mcpu=@var{cpu_type}
33323 Set the instruction set, register set, and instruction scheduling parameters
33324 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
33325 @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
33326 @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
33327 @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
33328 @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
33329 @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
33332 Native Solaris and GNU/Linux toolchains also support the value @samp{native},
33333 which selects the best architecture option for the host processor.
33334 @option{-mcpu=native} has no effect if GCC does not recognize
33337 Default instruction scheduling parameters are used for values that select
33338 an architecture and not an implementation. These are @samp{v7}, @samp{v8},
33339 @samp{sparclite}, @samp{sparclet}, @samp{v9}.
33341 Here is a list of each supported architecture and their supported
33349 supersparc, hypersparc, leon, leon3, leon5
33352 f930, f934, sparclite86x
33358 ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
33362 By default (unless configured otherwise), GCC generates code for the V7
33363 variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
33364 additionally optimizes it for the Cypress CY7C602 chip, as used in the
33365 SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
33366 SPARCStation 1, 2, IPX etc.
33368 With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
33369 architecture. The only difference from V7 code is that the compiler emits
33370 the integer multiply and integer divide instructions which exist in SPARC-V8
33371 but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
33372 optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
33375 With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
33376 the SPARC architecture. This adds the integer multiply, integer divide step
33377 and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
33378 With @option{-mcpu=f930}, the compiler additionally optimizes it for the
33379 Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
33380 @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
33381 MB86934 chip, which is the more recent SPARClite with FPU@.
33383 With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
33384 the SPARC architecture. This adds the integer multiply, multiply/accumulate,
33385 integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
33386 but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
33387 optimizes it for the TEMIC SPARClet chip.
33389 With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
33390 architecture. This adds 64-bit integer and floating-point move instructions,
33391 3 additional floating-point condition code registers and conditional move
33392 instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
33393 optimizes it for the Sun UltraSPARC I/II/IIi chips. With
33394 @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
33395 Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
33396 @option{-mcpu=niagara}, the compiler additionally optimizes it for
33397 Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
33398 additionally optimizes it for Sun UltraSPARC T2 chips. With
33399 @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
33400 UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
33401 additionally optimizes it for Sun UltraSPARC T4 chips. With
33402 @option{-mcpu=niagara7}, the compiler additionally optimizes it for
33403 Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
33404 additionally optimizes it for Oracle M8 chips.
33407 @item -mtune=@var{cpu_type}
33408 Set the instruction scheduling parameters for machine type
33409 @var{cpu_type}, but do not set the instruction set or register set that the
33410 option @option{-mcpu=@var{cpu_type}} does.
33412 The same values for @option{-mcpu=@var{cpu_type}} can be used for
33413 @option{-mtune=@var{cpu_type}}, but the only useful values are those
33414 that select a particular CPU implementation. Those are
33415 @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
33416 @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
33417 @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
33418 @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
33419 @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
33420 and GNU/Linux toolchains, @samp{native} can also be used.
33423 @opindex mno-v8plus
33426 With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
33427 difference from the V8 ABI is that the global and out registers are
33428 considered 64 bits wide. This is enabled by default on Solaris in 32-bit
33429 mode for all SPARC-V9 processors.
33435 With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
33436 Visual Instruction Set extensions. The default is @option{-mno-vis}.
33442 With @option{-mvis2}, GCC generates code that takes advantage of
33443 version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
33444 default is @option{-mvis2} when targeting a cpu that supports such
33445 instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
33446 also sets @option{-mvis}.
33452 With @option{-mvis3}, GCC generates code that takes advantage of
33453 version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
33454 default is @option{-mvis3} when targeting a cpu that supports such
33455 instructions, such as niagara-3 and later. Setting @option{-mvis3}
33456 also sets @option{-mvis2} and @option{-mvis}.
33462 With @option{-mvis4}, GCC generates code that takes advantage of
33463 version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
33464 default is @option{-mvis4} when targeting a cpu that supports such
33465 instructions, such as niagara-7 and later. Setting @option{-mvis4}
33466 also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
33472 With @option{-mvis4b}, GCC generates code that takes advantage of
33473 version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
33474 the additional VIS instructions introduced in the Oracle SPARC
33475 Architecture 2017. The default is @option{-mvis4b} when targeting a
33476 cpu that supports such instructions, such as m8 and later. Setting
33477 @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
33478 @option{-mvis2} and @option{-mvis}.
33481 @opindex mno-cbcond
33484 With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
33485 Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
33486 when targeting a CPU that supports such instructions, such as Niagara-4 and
33493 With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
33494 Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
33495 when targeting a CPU that supports such instructions, such as Niagara-3 and
33499 @opindex mno-fsmuld
33502 With @option{-mfsmuld}, GCC generates code that takes advantage of the
33503 Floating-point Multiply Single to Double (FsMULd) instruction. The default is
33504 @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
33505 or V9 with FPU except @option{-mcpu=leon}.
33511 With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
33512 Population Count instruction. The default is @option{-mpopc}
33513 when targeting a CPU that supports such an instruction, such as Niagara-2 and
33520 With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
33521 Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
33522 when targeting a CPU that supports such an instruction, such as Niagara-7 and
33525 @opindex mfix-at697f
33527 Enable the documented workaround for the single erratum of the Atmel AT697F
33528 processor (which corresponds to erratum #13 of the AT697E processor).
33530 @opindex mfix-ut699
33532 Enable the documented workarounds for the floating-point errata and the data
33533 cache nullify errata of the UT699 processor.
33535 @opindex mfix-ut700
33537 Enable the documented workaround for the back-to-back store errata of
33538 the UT699E/UT700 processor.
33540 @opindex mfix-gr712rc
33541 @item -mfix-gr712rc
33542 Enable the documented workaround for the back-to-back store errata of
33543 the GR712RC processor.
33546 These @samp{-m} options are supported in addition to the above
33547 on SPARC-V9 processors in 64-bit environments:
33554 Generate code for a 32-bit or 64-bit environment.
33555 The 32-bit environment sets int, long and pointer to 32 bits.
33556 The 64-bit environment sets int to 32 bits and long and pointer
33560 @item -mcmodel=@var{which}
33561 Set the code model to one of
33565 The Medium/Low code model: 64-bit addresses, programs
33566 must be linked in the low 32 bits of memory. Programs can be statically
33567 or dynamically linked.
33570 The Medium/Middle code model: 64-bit addresses, programs
33571 must be linked in the low 44 bits of memory, the text and data segments must
33572 be less than 2GB in size and the data segment must be located within 2GB of
33576 The Medium/Anywhere code model: 64-bit addresses, programs
33577 may be linked anywhere in memory, the text and data segments must be less
33578 than 2GB in size and the data segment must be located within 2GB of the
33582 The Medium/Anywhere code model for embedded systems:
33583 64-bit addresses, the text and data segments must be less than 2GB in
33584 size, both starting anywhere in memory (determined at link time). The
33585 global register %g4 points to the base of the data segment. Programs
33586 are statically linked and PIC is not supported.
33589 @opindex mmemory-model
33590 @item -mmemory-model=@var{mem-model}
33591 Set the memory model in force on the processor to one of
33595 The default memory model for the processor and operating system.
33598 Relaxed Memory Order
33601 Partial Store Order
33607 Sequential Consistency
33610 These memory models are formally defined in Appendix D of the SPARC-V9
33611 architecture manual, as set in the processor's @code{PSTATE.MM} field.
33613 @opindex mstack-bias
33614 @opindex mno-stack-bias
33616 @itemx -mno-stack-bias
33617 With @option{-mstack-bias}, GCC assumes that the stack pointer, and
33618 frame pointer if present, are offset by @minus{}2047 which must be added back
33619 when making stack frame references. This is the default in 64-bit mode.
33620 Otherwise, assume no such offset is present.
33623 @node System V Options
33624 @subsection Options for System V
33626 These additional options are available on System V Release 4 for
33627 compatibility with other compilers on those systems:
33632 Create a shared object.
33633 It is recommended that @option{-symbolic} or @option{-shared} be used instead.
33637 Identify the versions of each tool used by the compiler, in a
33638 @code{.ident} assembler directive in the output.
33642 Refrain from adding @code{.ident} directives to the output file (this is
33646 @item -YP,@var{dirs}
33647 Search the directories @var{dirs}, and no others, for libraries
33648 specified with @option{-l}.
33651 @item -Ym,@var{dir}
33652 Look in the directory @var{dir} to find the M4 preprocessor.
33653 The assembler uses this option.
33654 @c This is supposed to go with a -Yd for predefined M4 macro files, but
33655 @c the generic assembler that comes with Solaris takes just -Ym.
33659 @subsection V850 Options
33660 @cindex V850 Options
33662 These @samp{-m} options are defined for V850 implementations:
33665 @opindex mlong-calls
33666 @opindex mno-long-calls
33668 @itemx -mno-long-calls
33669 Treat all calls as being far away (near). If calls are assumed to be
33670 far away, the compiler always loads the function's address into a
33671 register, and calls indirect through the pointer.
33677 Do not optimize (do optimize) basic blocks that use the same index
33678 pointer 4 or more times to copy pointer into the @code{ep} register, and
33679 use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
33680 option is on by default if you optimize.
33682 @opindex mno-prolog-function
33683 @opindex mprolog-function
33684 @item -mno-prolog-function
33685 @itemx -mprolog-function
33686 Do not use (do use) external functions to save and restore registers
33687 at the prologue and epilogue of a function. The external functions
33688 are slower, but use less code space if more than one function saves
33689 the same number of registers. The @option{-mprolog-function} option
33690 is on by default if you optimize.
33694 Try to make the code as small as possible. At present, this just turns
33695 on the @option{-mep} and @option{-mprolog-function} options.
33698 @item -mtda=@var{n}
33699 Put static or global variables whose size is @var{n} bytes or less into
33700 the tiny data area that register @code{ep} points to. The tiny data
33701 area can hold up to 256 bytes in total (128 bytes for byte references).
33704 @item -msda=@var{n}
33705 Put static or global variables whose size is @var{n} bytes or less into
33706 the small data area that register @code{gp} points to. The small data
33707 area can hold up to 64 kilobytes.
33710 @item -mzda=@var{n}
33711 Put static or global variables whose size is @var{n} bytes or less into
33712 the first 32 kilobytes of memory.
33716 Specify that the target processor is the V850.
33720 Specify that the target processor is the V850E3V5. The preprocessor
33721 constant @code{__v850e3v5__} is defined if this option is used.
33725 Specify that the target processor is the V850E3V5. This is an alias for
33726 the @option{-mv850e3v5} option.
33730 Specify that the target processor is the V850E2V3. The preprocessor
33731 constant @code{__v850e2v3__} is defined if this option is used.
33735 Specify that the target processor is the V850E2. The preprocessor
33736 constant @code{__v850e2__} is defined if this option is used.
33740 Specify that the target processor is the V850E1. The preprocessor
33741 constants @code{__v850e1__} and @code{__v850e__} are defined if
33742 this option is used.
33746 Specify that the target processor is the V850ES. This is an alias for
33747 the @option{-mv850e1} option.
33751 Specify that the target processor is the V850E@. The preprocessor
33752 constant @code{__v850e__} is defined if this option is used.
33754 If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
33755 nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
33756 are defined then a default target processor is chosen and the
33757 relevant @samp{__v850*__} preprocessor constant is defined.
33759 The preprocessor constants @code{__v850} and @code{__v851__} are always
33760 defined, regardless of which processor variant is the target.
33762 @opindex mdisable-callt
33763 @opindex mno-disable-callt
33764 @item -mdisable-callt
33765 @itemx -mno-disable-callt
33766 This option suppresses generation of the @code{CALLT} instruction for the
33767 v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
33770 This option is enabled by default when the RH850 ABI is
33771 in use (see @option{-mrh850-abi}), and disabled by default when the
33772 GCC ABI is in use. If @code{CALLT} instructions are being generated
33773 then the C preprocessor symbol @code{__V850_CALLT__} is defined.
33779 Pass on (or do not pass on) the @option{-mrelax} command-line option
33782 @opindex mlong-jumps
33783 @opindex mno-long-jumps
33785 @itemx -mno-long-jumps
33786 Disable (or re-enable) the generation of PC-relative jump instructions.
33788 @opindex msoft-float
33789 @opindex mhard-float
33791 @itemx -mhard-float
33792 Disable (or re-enable) the generation of hardware floating point
33793 instructions. This option is only significant when the target
33794 architecture is @samp{V850E2V3} or higher. If hardware floating point
33795 instructions are being generated then the C preprocessor symbol
33796 @code{__FPU_OK__} is defined, otherwise the symbol
33797 @code{__NO_FPU__} is defined.
33801 Enables the use of the e3v5 LOOP instruction. The use of this
33802 instruction is not enabled by default when the e3v5 architecture is
33803 selected because its use is still experimental.
33805 @opindex mrh850-abi
33809 Enables support for the RH850 version of the V850 ABI. This is the
33810 default. With this version of the ABI the following rules apply:
33814 Integer sized structures and unions are returned via a memory pointer
33815 rather than a register.
33818 Large structures and unions (more than 8 bytes in size) are passed by
33822 Functions are aligned to 16-bit boundaries.
33825 The @option{-m8byte-align} command-line option is supported.
33828 The @option{-mdisable-callt} command-line option is enabled by
33829 default. The @option{-mno-disable-callt} command-line option is not
33833 When this version of the ABI is enabled the C preprocessor symbol
33834 @code{__V850_RH850_ABI__} is defined.
33838 Enables support for the old GCC version of the V850 ABI. With this
33839 version of the ABI the following rules apply:
33843 Integer sized structures and unions are returned in register @code{r10}.
33846 Large structures and unions (more than 8 bytes in size) are passed by
33850 Functions are aligned to 32-bit boundaries, unless optimizing for
33854 The @option{-m8byte-align} command-line option is not supported.
33857 The @option{-mdisable-callt} command-line option is supported but not
33858 enabled by default.
33861 When this version of the ABI is enabled the C preprocessor symbol
33862 @code{__V850_GCC_ABI__} is defined.
33864 @opindex m8byte-align
33865 @opindex mno-8byte-align
33866 @item -m8byte-align
33867 @itemx -mno-8byte-align
33868 Enables support for @code{double} and @code{long long} types to be
33869 aligned on 8-byte boundaries. The default is to restrict the
33870 alignment of all objects to at most 4-bytes. When
33871 @option{-m8byte-align} is in effect the C preprocessor symbol
33872 @code{__V850_8BYTE_ALIGN__} is defined.
33874 @opindex mbig-switch
33876 Generate code suitable for big switch tables. Use this option only if
33877 the assembler/linker complain about out of range branches within a switch
33882 This option causes r2 and r5 to be used in the code generated by
33883 the compiler. This setting is the default.
33885 @opindex mno-app-regs
33886 @item -mno-app-regs
33887 This option causes r2 and r5 to be treated as fixed registers.
33892 @subsection VAX Options
33893 @cindex VAX options
33895 These @samp{-m} options are defined for the VAX:
33900 Do not output certain jump instructions (@code{aobleq} and so on)
33901 that the Unix assembler for the VAX cannot handle across long
33906 Do output those jump instructions, on the assumption that the
33907 GNU assembler is being used.
33911 Output code for G-format floating-point numbers instead of D-format.
33917 Enable Local Register Allocation. This is still experimental for the VAX,
33918 so by default the compiler uses standard reload.
33921 @node Visium Options
33922 @subsection Visium Options
33923 @cindex Visium options
33929 A program which performs file I/O and is destined to run on an MCM target
33930 should be linked with this option. It causes the libraries libc.a and
33931 libdebug.a to be linked. The program should be run on the target under
33932 the control of the GDB remote debugging stub.
33936 A program which performs file I/O and is destined to run on the simulator
33937 should be linked with option. This causes libraries libc.a and libsim.a to
33941 @opindex mhard-float
33943 @itemx -mhard-float
33944 Generate code containing floating-point instructions. This is the
33948 @opindex msoft-float
33950 @itemx -msoft-float
33951 Generate code containing library calls for floating-point.
33953 @option{-msoft-float} changes the calling convention in the output file;
33954 therefore, it is only useful if you compile @emph{all} of a program with
33955 this option. In particular, you need to compile @file{libgcc.a}, the
33956 library that comes with GCC, with @option{-msoft-float} in order for
33960 @item -mcpu=@var{cpu_type}
33961 Set the instruction set, register set, and instruction scheduling parameters
33962 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
33963 @samp{mcm}, @samp{gr5} and @samp{gr6}.
33965 @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
33967 By default (unless configured otherwise), GCC generates code for the GR5
33968 variant of the Visium architecture.
33970 With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
33971 architecture. The only difference from GR5 code is that the compiler will
33972 generate block move instructions.
33975 @item -mtune=@var{cpu_type}
33976 Set the instruction scheduling parameters for machine type @var{cpu_type},
33977 but do not set the instruction set or register set that the option
33978 @option{-mcpu=@var{cpu_type}} would.
33982 Generate code for the supervisor mode, where there are no restrictions on
33983 the access to general registers. This is the default.
33985 @opindex muser-mode
33987 Generate code for the user mode, where the access to some general registers
33988 is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
33989 mode; on the GR6, only registers r29 to r31 are affected.
33993 @subsection VMS Options
33995 These @samp{-m} options are defined for the VMS implementations:
33998 @opindex mvms-return-codes
33999 @item -mvms-return-codes
34000 Return VMS condition codes from @code{main}. The default is to return POSIX-style
34001 condition (e.g.@: error) codes.
34003 @opindex mdebug-main=@var{prefix}
34004 @item -mdebug-main=@var{prefix}
34005 Flag the first routine whose name starts with @var{prefix} as the main
34006 routine for the debugger.
34010 Default to 64-bit memory allocation routines.
34012 @opindex mpointer-size=@var{size}
34013 @item -mpointer-size=@var{size}
34014 Set the default size of pointers. Possible options for @var{size} are
34015 @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
34016 for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
34017 The later option disables @code{pragma pointer_size}.
34020 @node VxWorks Options
34021 @subsection VxWorks Options
34022 @cindex VxWorks Options
34024 The options in this section are defined for all VxWorks targets.
34025 Options specific to the target hardware are listed with the other
34026 options for that target.
34031 GCC can generate code for both VxWorks kernels and real time processes
34032 (RTPs). This option switches from the former to the latter. It also
34033 defines the preprocessor macro @code{__RTP__}.
34037 Select SMP runtimes for linking. Not available on architectures other
34038 than PowerPC, nor on VxWorks version 7 or later, in which the selection
34039 is part of the VxWorks build configuration and the library paths are the
34040 same for either choice.
34042 @opindex non-static
34044 Link an RTP executable against shared libraries rather than static
34045 libraries. The options @option{-static} and @option{-shared} can
34046 also be used for RTPs (@pxref{Link Options}); @option{-static}
34053 These options are passed down to the linker. They are defined for
34054 compatibility with Diab.
34056 @opindex Xbind-lazy
34058 Enable lazy binding of function calls. This option is equivalent to
34059 @option{-Wl,-z,now} and is defined for compatibility with Diab.
34063 Disable lazy binding of function calls. This option is the default and
34064 is defined for compatibility with Diab.
34068 @subsection x86 Options
34069 @cindex x86 Options
34071 These @samp{-m} options are defined for the x86 family of computers.
34076 @item -march=@var{cpu-type}
34077 Generate instructions for the machine type @var{cpu-type}. In contrast to
34078 @option{-mtune=@var{cpu-type}}, which merely tunes the generated code
34079 for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
34080 to generate code that may not run at all on processors other than the one
34081 indicated. Specifying @option{-march=@var{cpu-type}} implies
34082 @option{-mtune=@var{cpu-type}}, except where noted otherwise.
34084 The choices for @var{cpu-type} are:
34088 This selects the CPU to generate code for at compilation time by determining
34089 the processor type of the compiling machine. Using @option{-march=native}
34090 enables all instruction subsets supported by the local machine (hence
34091 the result might not run on different machines). Using @option{-mtune=native}
34092 produces code optimized for the local machine under the constraints
34093 of the selected instruction set.
34096 A generic CPU with 64-bit extensions.
34101 These choices for @var{cpu-type} select the corresponding
34102 micro-architecture level from the x86-64 psABI. On ABIs other than
34103 the x86-64 psABI they select the same CPU features as the x86-64 psABI
34104 documents for the particular micro-architecture level.
34106 Since these @var{cpu-type} values do not have a corresponding
34107 @option{-mtune} setting, using @option{-march} with these values enables
34108 generic tuning. Specific tuning can be enabled using the
34109 @option{-mtune=@var{other-cpu-type}} option with an appropriate
34110 @var{other-cpu-type} value.
34113 Original Intel i386 CPU@.
34116 Intel i486 CPU@. (No scheduling is implemented for this chip.)
34120 Intel Pentium CPU with no MMX support.
34123 Intel Lakemont MCU, based on Intel Pentium CPU.
34126 Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
34129 Intel Pentium Pro CPU@.
34132 When used with @option{-march}, the Pentium Pro
34133 instruction set is used, so the code runs on all i686 family chips.
34134 When used with @option{-mtune}, it has the same meaning as @samp{generic}.
34137 Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
34142 Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
34143 instruction set support.
34146 Intel Pentium M; low-power version of Intel Pentium III CPU
34147 with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
34152 Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
34155 Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
34156 instruction set support.
34159 Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
34160 SSE2, SSE3 and FXSR instruction set support.
34163 Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
34164 SAHF and FXSR instruction set support.
34167 Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34168 SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
34171 Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34172 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
34175 Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34176 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
34180 Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34181 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
34182 and F16C instruction set support.
34185 Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34186 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34187 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
34190 Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34191 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34192 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
34193 instruction set support.
34196 Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34197 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34198 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34199 CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
34202 Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
34203 instruction set support.
34206 Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34207 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
34208 instruction set support.
34211 Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34212 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
34213 RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
34216 @item goldmont-plus
34217 Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34218 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
34219 SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
34220 RDPID and SGX instruction set support.
34223 Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34224 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
34225 RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
34226 SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
34230 Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34231 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34232 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34233 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34234 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34235 AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
34239 Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34240 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34241 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34242 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34243 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34244 AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
34247 @item clearwaterforest
34248 Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
34249 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE,
34250 XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
34251 MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA,
34252 LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34253 ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16,
34254 SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support.
34257 Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34258 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34259 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34260 AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
34263 Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34264 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34265 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34266 AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
34267 AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
34269 @item skylake-avx512
34270 Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34271 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34272 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34273 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
34274 AVX512DQ and AVX512CD instruction set support.
34277 Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
34278 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
34279 FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
34280 PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
34281 AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
34284 @item icelake-client
34285 Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34286 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34287 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34288 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34289 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
34290 , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
34292 @item icelake-server
34293 Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34294 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34295 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34296 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34297 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
34298 , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
34299 instruction set support.
34302 Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34303 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34304 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34305 CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
34306 AVX512CD and AVX512VNNI instruction set support.
34309 Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34310 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34311 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34312 CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
34313 AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
34316 Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34317 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34318 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34319 CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
34320 PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34321 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
34322 AVX512VP2INTERSECT and KEYLOCKER instruction set support.
34324 @item sapphirerapids
34325 Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34326 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34327 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34328 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34329 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34330 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
34331 MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34332 UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
34333 instruction set support.
34336 Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34337 SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
34338 XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
34339 CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
34340 VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
34344 Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
34345 , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34346 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34347 CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
34348 PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34349 VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
34351 @item graniterapids
34352 Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34353 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34354 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34355 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34356 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34357 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
34358 MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34359 UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16
34360 and PREFETCHI instruction set support.
34362 @item graniterapids-d
34363 Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34364 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34365 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34366 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34367 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34368 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
34369 MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34370 UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16,
34371 PREFETCHI and AMX-COMPLEX instruction set support.
34374 Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34375 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34376 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34377 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34378 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34379 UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set
34383 Intel Arrow Lake S CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34384 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34385 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34386 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34387 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34388 UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
34389 SM3 and SM4 instruction set support.
34392 Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34393 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34394 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34395 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34396 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34397 UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
34398 SM3, SM4 and PREFETCHI instruction set support.
34401 AMD K6 CPU with MMX instruction set support.
34405 Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
34408 @itemx athlon-tbird
34409 AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
34415 Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
34416 instruction set support.
34422 Processors based on the AMD K8 core with x86-64 instruction set support,
34423 including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
34424 (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
34425 instruction set extensions.)
34428 @itemx opteron-sse3
34429 @itemx athlon64-sse3
34430 Improved versions of AMD K8 cores with SSE3 instruction set support.
34434 CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
34435 supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
34436 instruction set extensions.)
34439 CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
34440 supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
34441 SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
34444 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
34445 supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
34446 SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
34450 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
34451 supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
34452 PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
34453 64-bit instruction set extensions.)
34456 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
34457 supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
34458 AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
34459 SSE4.2, ABM and 64-bit instruction set extensions.)
34462 AMD Family 17h core based CPUs with x86-64 instruction set support. (This
34463 supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
34464 SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
34465 SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
34466 instruction set extensions.)
34469 AMD Family 17h core based CPUs with x86-64 instruction set support. (This
34470 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
34471 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
34472 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
34473 WBNOINVD, and 64-bit instruction set extensions.)
34476 AMD Family 19h core based CPUs with x86-64 instruction set support. (This
34477 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
34478 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
34479 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
34480 WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
34483 AMD Family 19h core based CPUs with x86-64 instruction set support. (This
34484 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
34485 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
34486 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
34487 WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
34488 AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
34489 AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
34492 AMD Family 1ah core based CPUs with x86-64 instruction set support. (This
34493 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
34494 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
34495 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
34496 WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
34497 AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
34498 AVX512BITALG, AVX512VPOPCNTDQ, GFNI, AVXVNNI, MOVDIRI, MOVDIR64B,
34499 AVX512VP2INTERSECT, PREFETCHI and 64-bit instruction set extensions.)
34502 CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
34503 supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
34504 instruction set extensions.)
34507 CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
34508 includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
34509 SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
34512 IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
34516 IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
34517 instruction set support.
34520 VIA C3 CPU with MMX and 3DNow!@: instruction set support.
34521 (No scheduling is implemented for this chip.)
34524 VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
34525 (No scheduling is implemented for this chip.)
34528 VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
34529 (No scheduling is implemented for this chip.)
34532 VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
34533 (No scheduling is implemented for this chip.)
34536 VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
34537 (No scheduling is implemented for this chip.)
34540 VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
34541 (No scheduling is implemented for this chip.)
34544 VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
34545 (No scheduling is implemented for this chip.)
34548 VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
34549 AVX and AVX2 instruction set support.
34550 (No scheduling is implemented for this chip.)
34553 Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
34554 instruction set support.
34555 (No scheduling is implemented for this chip.)
34558 VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
34559 instruction set support.
34560 (No scheduling is implemented for this chip.)
34563 VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
34564 instruction set support.
34565 (No scheduling is implemented for this chip.)
34568 VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
34569 instruction set support.
34570 (No scheduling is implemented for this chip.)
34573 VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
34574 instruction set support.
34575 (No scheduling is implemented for this chip.)
34578 VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
34579 instruction set support.
34580 (No scheduling is implemented for this chip.)
34583 ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
34584 SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
34585 ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
34588 ZHAOXIN yongfeng CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
34589 SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
34590 ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT
34591 instruction set support.
34594 AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
34598 @item -mtune=@var{cpu-type}
34599 Tune to @var{cpu-type} everything applicable about the generated code, except
34600 for the ABI and the set of available instructions.
34601 While picking a specific @var{cpu-type} schedules things appropriately
34602 for that particular chip, the compiler does not generate any code that
34603 cannot run on the default machine type unless you use a
34604 @option{-march=@var{cpu-type}} option.
34605 For example, if GCC is configured for i686-pc-linux-gnu
34606 then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
34607 but still runs on i686 machines.
34609 The choices for @var{cpu-type} are the same as for @option{-march}.
34610 In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
34614 Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
34615 If you know the CPU on which your code will run, then you should use
34616 the corresponding @option{-mtune} or @option{-march} option instead of
34617 @option{-mtune=generic}. But, if you do not know exactly what CPU users
34618 of your application will have, then you should use this option.
34620 As new processors are deployed in the marketplace, the behavior of this
34621 option will change. Therefore, if you upgrade to a newer version of
34622 GCC, code generation controlled by this option will change to reflect
34624 that are most common at the time that version of GCC is released.
34626 There is no @option{-march=generic} option because @option{-march}
34627 indicates the instruction set the compiler can use, and there is no
34628 generic instruction set applicable to all processors. In contrast,
34629 @option{-mtune} indicates the processor (or, in this case, collection of
34630 processors) for which the code is optimized.
34633 Produce code optimized for the most current Intel processors, which are
34634 Haswell and Silvermont for this version of GCC. If you know the CPU
34635 on which your code will run, then you should use the corresponding
34636 @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
34637 But, if you want your application performs better on both Haswell and
34638 Silvermont, then you should use this option.
34640 As new Intel processors are deployed in the marketplace, the behavior of
34641 this option will change. Therefore, if you upgrade to a newer version of
34642 GCC, code generation controlled by this option will change to reflect
34643 the most current Intel processors at the time that version of GCC is
34646 There is no @option{-march=intel} option because @option{-march} indicates
34647 the instruction set the compiler can use, and there is no common
34648 instruction set applicable to all processors. In contrast,
34649 @option{-mtune} indicates the processor (or, in this case, collection of
34650 processors) for which the code is optimized.
34654 @item -mcpu=@var{cpu-type}
34655 A deprecated synonym for @option{-mtune}.
34658 @item -mfpmath=@var{unit}
34659 Generate floating-point arithmetic for selected unit @var{unit}. The choices
34660 for @var{unit} are:
34664 Use the standard 387 floating-point coprocessor present on the majority of chips and
34665 emulated otherwise. Code compiled with this option runs almost everywhere.
34666 The temporary results are computed in 80-bit precision instead of the precision
34667 specified by the type, resulting in slightly different results compared to most
34668 of other chips. See @option{-ffloat-store} for more detailed description.
34670 This is the default choice for non-Darwin x86-32 targets.
34673 Use scalar floating-point instructions present in the SSE instruction set.
34674 This instruction set is supported by Pentium III and newer chips,
34675 and in the AMD line
34676 by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
34677 instruction set supports only single-precision arithmetic, thus the double and
34678 extended-precision arithmetic are still done using 387. A later version, present
34679 only in Pentium 4 and AMD x86-64 chips, supports double-precision
34682 For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
34683 or @option{-msse2} switches to enable SSE extensions and make this option
34684 effective. For the x86-64 compiler, these extensions are enabled by default.
34686 The resulting code should be considerably faster in the majority of cases and avoid
34687 the numerical instability problems of 387 code, but may break some existing
34688 code that expects temporaries to be 80 bits.
34690 This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
34691 and the default choice for x86-32 targets with the SSE2 instruction set
34692 when @option{-ffast-math} is enabled.
34697 Attempt to utilize both instruction sets at once. This effectively doubles the
34698 amount of available registers, and on chips with separate execution units for
34699 387 and SSE the execution resources too. Use this option with care, as it is
34700 still experimental, because the GCC register allocator does not model separate
34701 functional units well, resulting in unstable performance.
34704 @opindex masm=@var{dialect}
34705 @item -masm=@var{dialect}
34706 Output assembly instructions using selected @var{dialect}. Also affects
34707 which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
34708 extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
34709 order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
34710 not support @samp{intel}.
34713 @opindex mno-ieee-fp
34715 @itemx -mno-ieee-fp
34716 Control whether or not the compiler uses IEEE floating-point
34717 comparisons. These correctly handle the case where the result of a
34718 comparison is unordered.
34721 @opindex mhard-float
34723 @itemx -mhard-float
34724 Generate output containing 80387 instructions for floating point.
34727 @opindex msoft-float
34729 @itemx -msoft-float
34730 Generate output containing library calls for floating point.
34732 @strong{Warning:} the requisite libraries are not part of GCC@.
34733 Normally the facilities of the machine's usual C compiler are used, but
34734 this cannot be done directly in cross-compilation. You must make your
34735 own arrangements to provide suitable library functions for
34738 On machines where a function returns floating-point results in the 80387
34739 register stack, some floating-point opcodes may be emitted even if
34740 @option{-msoft-float} is used.
34742 @opindex mno-fp-ret-in-387
34743 @opindex mfp-ret-in-387
34744 @item -mno-fp-ret-in-387
34745 Do not use the FPU registers for return values of functions.
34747 The usual calling convention has functions return values of types
34748 @code{float} and @code{double} in an FPU register, even if there
34749 is no FPU@. The idea is that the operating system should emulate
34752 The option @option{-mno-fp-ret-in-387} causes such values to be returned
34753 in ordinary CPU registers instead.
34755 @opindex mno-fancy-math-387
34756 @opindex mfancy-math-387
34757 @item -mno-fancy-math-387
34758 Some 387 emulators do not support the @code{sin}, @code{cos} and
34759 @code{sqrt} instructions for the 387. Specify this option to avoid
34760 generating those instructions.
34761 This option is overridden when @option{-march}
34762 indicates that the target CPU always has an FPU and so the
34763 instruction does not need emulation. These
34764 instructions are not generated unless you also use the
34765 @option{-funsafe-math-optimizations} switch.
34767 @opindex malign-double
34768 @opindex mno-align-double
34769 @item -malign-double
34770 @itemx -mno-align-double
34771 Control whether GCC aligns @code{double}, @code{long double}, and
34772 @code{long long} variables on a two-word boundary or a one-word
34773 boundary. Aligning @code{double} variables on a two-word boundary
34774 produces code that runs somewhat faster on a Pentium at the
34775 expense of more memory.
34777 On x86-64, @option{-malign-double} is enabled by default.
34779 @strong{Warning:} if you use the @option{-malign-double} switch,
34780 structures containing the above types are aligned differently than
34781 the published application binary interface specifications for the x86-32
34782 and are not binary compatible with structures in code compiled
34783 without that switch.
34785 @opindex m96bit-long-double
34786 @opindex m128bit-long-double
34787 @item -m96bit-long-double
34788 @itemx -m128bit-long-double
34789 These switches control the size of @code{long double} type. The x86-32
34790 application binary interface specifies the size to be 96 bits,
34791 so @option{-m96bit-long-double} is the default in 32-bit mode.
34793 Modern architectures (Pentium and newer) prefer @code{long double}
34794 to be aligned to an 8- or 16-byte boundary. In arrays or structures
34795 conforming to the ABI, this is not possible. So specifying
34796 @option{-m128bit-long-double} aligns @code{long double}
34797 to a 16-byte boundary by padding the @code{long double} with an additional
34800 In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
34801 its ABI specifies that @code{long double} is aligned on 16-byte boundary.
34803 Notice that neither of these options enable any extra precision over the x87
34804 standard of 80 bits for a @code{long double}.
34806 @strong{Warning:} if you override the default value for your target ABI, this
34807 changes the size of
34808 structures and arrays containing @code{long double} variables,
34809 as well as modifying the function calling convention for functions taking
34810 @code{long double}. Hence they are not binary-compatible
34811 with code compiled without that switch.
34813 @opindex mlong-double-64
34814 @opindex mlong-double-80
34815 @opindex mlong-double-128
34816 @item -mlong-double-64
34817 @itemx -mlong-double-80
34818 @itemx -mlong-double-128
34819 These switches control the size of @code{long double} type. A size
34820 of 64 bits makes the @code{long double} type equivalent to the @code{double}
34821 type. This is the default for 32-bit Bionic C library. A size
34822 of 128 bits makes the @code{long double} type equivalent to the
34823 @code{__float128} type. This is the default for 64-bit Bionic C library.
34825 @strong{Warning:} if you override the default value for your target ABI, this
34826 changes the size of
34827 structures and arrays containing @code{long double} variables,
34828 as well as modifying the function calling convention for functions taking
34829 @code{long double}. Hence they are not binary-compatible
34830 with code compiled without that switch.
34832 @opindex malign-data
34833 @item -malign-data=@var{type}
34834 Control how GCC aligns variables. Supported values for @var{type} are
34835 @samp{compat} uses increased alignment value compatible uses GCC 4.8
34836 and earlier, @samp{abi} uses alignment value as specified by the
34837 psABI, and @samp{cacheline} uses increased alignment value to match
34838 the cache line size. @samp{compat} is the default.
34840 @opindex mlarge-data-threshold
34841 @item -mlarge-data-threshold=@var{threshold}
34842 When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data
34843 objects larger than @var{threshold} are placed in large data sections. The
34848 Use a different function-calling convention, in which functions that
34849 take a fixed number of arguments return with the @code{ret @var{num}}
34850 instruction, which pops their arguments while returning. This saves one
34851 instruction in the caller since there is no need to pop the arguments
34854 You can specify that an individual function is called with this calling
34855 sequence with the function attribute @code{stdcall}. You can also
34856 override the @option{-mrtd} option by using the function attribute
34857 @code{cdecl}. @xref{Function Attributes}.
34859 @strong{Warning:} this calling convention is incompatible with the one
34860 normally used on Unix, so you cannot use it if you need to call
34861 libraries compiled with the Unix compiler.
34863 Also, you must provide function prototypes for all functions that
34864 take variable numbers of arguments (including @code{printf});
34865 otherwise incorrect code is generated for calls to those
34868 In addition, seriously incorrect code results if you call a
34869 function with too many arguments. (Normally, extra arguments are
34870 harmlessly ignored.)
34873 @item -mregparm=@var{num}
34874 Control how many registers are used to pass integer arguments. By
34875 default, no registers are used to pass arguments, and at most 3
34876 registers can be used. You can control this behavior for a specific
34877 function by using the function attribute @code{regparm}.
34878 @xref{Function Attributes}.
34880 @strong{Warning:} if you use this switch, and
34881 @var{num} is nonzero, then you must build all modules with the same
34882 value, including any libraries. This includes the system libraries and
34885 @opindex msseregparm
34887 Use SSE register passing conventions for float and double arguments
34888 and return values. You can control this behavior for a specific
34889 function by using the function attribute @code{sseregparm}.
34890 @xref{Function Attributes}.
34892 @strong{Warning:} if you use this switch then you must build all
34893 modules with the same value, including any libraries. This includes
34894 the system libraries and startup modules.
34896 @opindex mvect8-ret-in-mem
34897 @item -mvect8-ret-in-mem
34898 Return 8-byte vectors in memory instead of MMX registers. This is the
34899 default on VxWorks to match the ABI of the Sun Studio compilers until
34900 version 12. @emph{Only} use this option if you need to remain
34901 compatible with existing code produced by those previous compiler
34902 versions or older versions of GCC@.
34911 Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
34912 is specified, the significands of results of floating-point operations are
34913 rounded to 24 bits (single precision); @option{-mpc64} rounds the
34914 significands of results of floating-point operations to 53 bits (double
34915 precision) and @option{-mpc80} rounds the significands of results of
34916 floating-point operations to 64 bits (extended double precision), which is
34917 the default. When this option is used, floating-point operations in higher
34918 precisions are not available to the programmer without setting the FPU
34919 control word explicitly.
34921 Setting the rounding of floating-point operations to less than the default
34922 80 bits can speed some programs by 2% or more. Note that some mathematical
34923 libraries assume that extended-precision (80-bit) floating-point operations
34924 are enabled by default; routines in such libraries could suffer significant
34925 loss of accuracy, typically through so-called ``catastrophic cancellation'',
34926 when this option is used to set the precision to less than extended precision.
34931 The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
34932 are used to control floating-point calculations.SSE and AVX instructions
34933 including scalar and vector instructions could benefit from enabling the FTZ
34934 and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
34935 when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
34936 will set FTZ/DAZ flags even with @option{-shared}.
34938 @opindex mstackrealign
34939 @item -mstackrealign
34940 Realign the stack at entry. On the x86, the @option{-mstackrealign}
34941 option generates an alternate prologue and epilogue that realigns the
34942 run-time stack if necessary. This supports mixing legacy codes that keep
34943 4-byte stack alignment with modern codes that keep 16-byte stack alignment for
34944 SSE compatibility. See also the attribute @code{force_align_arg_pointer},
34945 applicable to individual functions.
34947 @opindex mpreferred-stack-boundary
34948 @item -mpreferred-stack-boundary=@var{num}
34949 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
34950 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
34951 the default is 4 (16 bytes or 128 bits).
34953 @strong{Warning:} When generating code for the x86-64 architecture with
34954 SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
34955 used to keep the stack boundary aligned to 8 byte boundary. Since
34956 x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
34957 intended to be used in controlled environment where stack space is
34958 important limitation. This option leads to wrong code when functions
34959 compiled with 16 byte stack alignment (such as functions from a standard
34960 library) are called with misaligned stack. In this case, SSE
34961 instructions may lead to misaligned memory access traps. In addition,
34962 variable arguments are handled incorrectly for 16 byte aligned
34963 objects (including x87 long double and __int128), leading to wrong
34964 results. You must build all modules with
34965 @option{-mpreferred-stack-boundary=3}, including any libraries. This
34966 includes the system libraries and startup modules.
34968 @opindex mincoming-stack-boundary
34969 @item -mincoming-stack-boundary=@var{num}
34970 Assume the incoming stack is aligned to a 2 raised to @var{num} byte
34971 boundary. If @option{-mincoming-stack-boundary} is not specified,
34972 the one specified by @option{-mpreferred-stack-boundary} is used.
34974 On Pentium and Pentium Pro, @code{double} and @code{long double} values
34975 should be aligned to an 8-byte boundary (see @option{-malign-double}) or
34976 suffer significant run time performance penalties. On Pentium III, the
34977 Streaming SIMD Extension (SSE) data type @code{__m128} may not work
34978 properly if it is not 16-byte aligned.
34980 To ensure proper alignment of this values on the stack, the stack boundary
34981 must be as aligned as that required by any value stored on the stack.
34982 Further, every function must be generated such that it keeps the stack
34983 aligned. Thus calling a function compiled with a higher preferred
34984 stack boundary from a function compiled with a lower preferred stack
34985 boundary most likely misaligns the stack. It is recommended that
34986 libraries that use callbacks always use the default setting.
34988 This extra alignment does consume extra stack space, and generally
34989 increases code size. Code that is sensitive to stack space usage, such
34990 as embedded systems and operating system kernels, may want to reduce the
34991 preferred alignment to @option{-mpreferred-stack-boundary=2}.
35048 @opindex mavx512ifma
35049 @itemx -mavx512ifma
35051 @opindex mavx512vbmi
35052 @itemx -mavx512vbmi
35063 @opindex mclflushopt
35064 @itemx -mclflushopt
35099 @opindex mprefetchwt1
35100 @itemx -mprefetchwt1
35171 @opindex mavx512vbmi2
35172 @itemx -mavx512vbmi2
35174 @opindex mavx512bf16
35175 @itemx -mavx512bf16
35177 @opindex mavx512fp16
35178 @itemx -mavx512fp16
35189 @opindex mvpclmulqdq
35190 @itemx -mvpclmulqdq
35192 @opindex mavx512bitalg
35193 @itemx -mavx512bitalg
35198 @opindex mmovdir64b
35209 @opindex mavx512vpopcntdq
35210 @itemx -mavx512vpopcntdq
35212 @opindex mavx512vp2intersect
35213 @itemx -mavx512vp2intersect
35215 @opindex mavx5124fmaps
35216 @itemx -mavx5124fmaps
35218 @opindex mavx512vnni
35219 @itemx -mavx512vnni
35224 @opindex mavx5124vnniw
35225 @itemx -mavx5124vnniw
35230 @opindex mserialize
35253 @opindex mavxvnniint8
35254 @itemx -mavxvnniint8
35256 @opindex mavxneconvert
35257 @itemx -mavxneconvert
35259 @opindex mcmpccxadd
35265 @opindex mprefetchi
35271 @opindex mamx-complex
35272 @itemx -mamx-complex
35274 @opindex mavxvnniint16
35275 @itemx -mavxvnniint16
35295 @opindex mavx10.1-256
35296 @itemx -mavx10.1-256
35298 @opindex mavx10.1-512
35299 @itemx -mavx10.1-512
35300 These switches enable the use of instructions in the MMX, SSE,
35301 AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
35302 AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
35303 WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
35304 3DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
35305 XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
35306 GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
35307 ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
35308 UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
35309 AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT,
35310 AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512, SM4, APX_F, USER_MSR, AVX10.1 or
35311 CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-}
35312 option to disable use of these instructions.
35314 These extensions are also available as built-in functions: see
35315 @ref{x86 Built-in Functions}, for details of the functions enabled and
35316 disabled by these switches.
35318 To generate SSE/SSE2 instructions automatically from floating-point
35319 code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
35321 GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
35322 generates new AVX instructions or AVX equivalence for all SSEx instructions
35325 These options enable GCC to use these extended instructions in
35326 generated code, even without @option{-mfpmath=sse}. Applications that
35327 perform run-time CPU detection must compile separate files for each
35328 supported architecture, using the appropriate flags. In particular,
35329 the file containing the CPU detection code should be compiled without
35332 @opindex mdump-tune-features
35333 @item -mdump-tune-features
35334 This option instructs GCC to dump the names of the x86 performance
35335 tuning features and default settings. The names can be used in
35336 @option{-mtune-ctrl=@var{feature-list}}.
35338 @opindex mtune-ctrl=@var{feature-list}
35339 @item -mtune-ctrl=@var{feature-list}
35340 This option is used to do fine grain control of x86 code generation features.
35341 @var{feature-list} is a comma separated list of @var{feature} names. See also
35342 @option{-mdump-tune-features}. When specified, the @var{feature} is turned
35343 on if it is not preceded with @samp{^}, otherwise, it is turned off.
35344 @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
35345 developers. Using it may lead to code paths not covered by testing and can
35346 potentially result in compiler ICEs or runtime errors.
35348 @opindex mno-default
35350 This option instructs GCC to turn off all tunable features. See also
35351 @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
35355 This option instructs GCC to emit a @code{cld} instruction in the prologue
35356 of functions that use string instructions. String instructions depend on
35357 the DF flag to select between autoincrement or autodecrement mode. While the
35358 ABI specifies the DF flag to be cleared on function entry, some operating
35359 systems violate this specification by not clearing the DF flag in their
35360 exception dispatchers. The exception handler can be invoked with the DF flag
35361 set, which leads to wrong direction mode when string instructions are used.
35362 This option can be enabled by default on 32-bit x86 targets by configuring
35363 GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
35364 instructions can be suppressed with the @option{-mno-cld} compiler option
35367 @opindex mvzeroupper
35369 This option instructs GCC to emit a @code{vzeroupper} instruction
35370 before a transfer of control flow out of the function to minimize
35371 the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
35374 @opindex mprefer-avx128
35375 @item -mprefer-avx128
35376 This option instructs GCC to use 128-bit AVX instructions instead of
35377 256-bit AVX instructions in the auto-vectorizer.
35379 @opindex mprefer-vector-width
35380 @item -mprefer-vector-width=@var{opt}
35381 This option instructs GCC to use @var{opt}-bit vector width in instructions
35382 instead of default on the selected platform.
35384 @opindex mpartial-vector-fp-math
35385 @item -mpartial-vector-fp-math
35386 This option enables GCC to generate floating-point operations that might
35387 affect the set of floating-point status flags on partial vectors, where
35388 vector elements reside in the low part of the 128-bit SSE register. Unless
35389 @option{-fno-trapping-math} is specified, the compiler guarantees correct
35390 behavior by sanitizing all input operands to have zeroes in the unused
35391 upper part of the vector register. Note that by using built-in functions
35392 or inline assembly with partial vector arguments, NaNs, denormal or invalid
35393 values can leak into the upper part of the vector, causing possible
35394 performance issues when @option{-fno-trapping-math} is in effect. These
35395 issues can be mitigated by manually sanitizing the upper part of the partial
35396 vector argument register or by using @option{-mdaz-ftz} to set
35397 denormals-are-zero (DAZ) flag in the MXCSR register.
35399 This option is enabled by default.
35402 @item -mmove-max=@var{bits}
35403 This option instructs GCC to set the maximum number of bits can be
35404 moved from memory to memory efficiently to @var{bits}. The valid
35405 @var{bits} are 128, 256 and 512.
35407 @opindex mstore-max
35408 @item -mstore-max=@var{bits}
35409 This option instructs GCC to set the maximum number of bits can be
35410 stored to memory efficiently to @var{bits}. The valid @var{bits} are
35415 No extra limitations applied to GCC other than defined by the selected platform.
35418 Prefer 128-bit vector width for instructions.
35421 Prefer 256-bit vector width for instructions.
35424 Prefer 512-bit vector width for instructions.
35427 @opindex mnoreturn-no-callee-saved-registers
35428 @item -mnoreturn-no-callee-saved-registers
35429 This option optimizes functions with @code{noreturn} attribute or
35430 @code{_Noreturn} specifier by not saving in the function prologue callee-saved
35431 registers which are used in the function (except for the @code{BP}
35432 register). This option can interfere with debugging of the caller of the
35433 @code{noreturn} function or any function further up in the call stack, so it
35434 is not enabled by default.
35438 This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
35439 code to implement compare-and-exchange operations on 16-byte aligned 128-bit
35440 objects. This is useful for atomic updates of data structures exceeding one
35441 machine word in size. The compiler uses this instruction to implement
35442 @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
35443 128-bit integers, a library call is always used.
35447 This option enables generation of @code{SAHF} instructions in 64-bit code.
35448 Early Intel Pentium 4 CPUs with Intel 64 support,
35449 prior to the introduction of Pentium 4 G1 step in December 2005,
35450 lacked the @code{LAHF} and @code{SAHF} instructions
35451 which are supported by AMD64.
35452 These are load and store instructions, respectively, for certain status flags.
35453 In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
35454 @code{drem}, and @code{remainder} built-in functions;
35455 see @ref{Other Builtins} for details.
35459 This option enables use of the @code{movbe} instruction to optimize
35460 byte swapping of four and eight byte entities.
35464 The @option{-mshstk} option enables shadow stack built-in functions
35465 from x86 Control-flow Enforcement Technology (CET).
35469 This option enables built-in functions @code{__builtin_ia32_crc32qi},
35470 @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
35471 @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
35475 This option enables built-in functions @code{__builtin_ia32_monitor},
35476 and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
35477 @code{mwait} machine instructions.
35481 This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
35482 (and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
35483 with an additional Newton-Raphson step
35484 to increase precision instead of @code{DIVSS} and @code{SQRTSS}
35485 (and their vectorized
35486 variants) for single-precision floating-point arguments. These instructions
35487 are generated only when @option{-funsafe-math-optimizations} is enabled
35488 together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
35489 Note that while the throughput of the sequence is higher than the throughput
35490 of the non-reciprocal instruction, the precision of the sequence can be
35491 decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
35493 Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
35494 (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
35495 combination), and doesn't need @option{-mrecip}.
35497 Also note that GCC emits the above sequence with additional Newton-Raphson step
35498 for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
35499 already with @option{-ffast-math} (or the above option combination), and
35500 doesn't need @option{-mrecip}.
35502 @opindex mrecip=opt
35503 @item -mrecip=@var{opt}
35504 This option controls which reciprocal estimate instructions
35505 may be used. @var{opt} is a comma-separated list of options, which may
35506 be preceded by a @samp{!} to invert the option:
35510 Enable all estimate instructions.
35513 Enable the default instructions, equivalent to @option{-mrecip}.
35516 Disable all estimate instructions, equivalent to @option{-mno-recip}.
35519 Enable the approximation for scalar division.
35522 Enable the approximation for vectorized division.
35525 Enable the approximation for scalar square root.
35528 Enable the approximation for vectorized square root.
35531 So, for example, @option{-mrecip=all,!sqrt} enables
35532 all of the reciprocal approximations, except for square root.
35534 @opindex mveclibabi
35535 @item -mveclibabi=@var{type}
35536 Specifies the ABI type to use for vectorizing intrinsics using an
35537 external library. Supported values for @var{type} are @samp{svml}
35538 for the Intel short
35539 vector math library and @samp{acml} for the AMD math core library.
35540 To use this option, both @option{-ftree-vectorize} and
35541 @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
35542 ABI-compatible library must be specified at link time.
35544 GCC currently emits calls to @code{vmldExp2},
35545 @code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
35546 @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
35547 @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
35548 @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
35549 @code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
35550 @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
35551 @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
35552 @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
35553 @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
35554 function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
35555 @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
35556 @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
35557 @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
35558 @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
35559 when @option{-mveclibabi=acml} is used.
35562 @item -mabi=@var{name}
35563 Generate code for the specified calling convention. Permissible values
35564 are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
35565 @samp{ms} for the Microsoft ABI. The default is to use the Microsoft
35566 ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
35567 You can control this behavior for specific functions by
35568 using the function attributes @code{ms_abi} and @code{sysv_abi}.
35569 @xref{Function Attributes}.
35571 @opindex mforce-indirect-call
35572 @item -mforce-indirect-call
35573 Force all calls to functions to be indirect. This is useful
35574 when using Intel Processor Trace where it generates more precise timing
35575 information for function calls.
35577 @opindex mmanual-endbr
35578 @item -mmanual-endbr
35579 Insert ENDBR instruction at function entry only via the @code{cf_check}
35580 function attribute. This is useful when used with the option
35581 @option{-fcf-protection=branch} to control ENDBR insertion at the
35584 @opindex mcet-switch
35586 By default, CET instrumentation is turned off on switch statements that
35587 use a jump table and indirect branch track is disabled. Since jump
35588 tables are stored in read-only memory, this does not result in a direct
35589 loss of hardening. But if the jump table index is attacker-controlled,
35590 the indirect jump may not be constrained by CET. This option turns on
35591 CET instrumentation to enable indirect branch track for switch statements
35592 with jump tables which leads to the jump targets reachable via any indirect
35595 @opindex mcall-ms2sysv-xlogues
35596 @opindex mno-call-ms2sysv-xlogues
35597 @item -mcall-ms2sysv-xlogues
35598 Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
35599 System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
35600 default, the code for saving and restoring these registers is emitted inline,
35601 resulting in fairly lengthy prologues and epilogues. Using
35602 @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
35603 use stubs in the static portion of libgcc to perform these saves and restores,
35604 thus reducing function size at the cost of a few extra instructions.
35606 @opindex mtls-dialect
35607 @item -mtls-dialect=@var{type}
35608 Generate code to access thread-local storage using the @samp{gnu} or
35609 @samp{gnu2} conventions. @samp{gnu} is the conservative default;
35610 @samp{gnu2} is more efficient, but it may add compile- and run-time
35611 requirements that cannot be satisfied on all systems.
35613 @opindex mpush-args
35614 @opindex mno-push-args
35616 @itemx -mno-push-args
35617 Use PUSH operations to store outgoing parameters. This method is shorter
35618 and usually equally fast as method using SUB/MOV operations and is enabled
35619 by default. In some cases disabling it may improve performance because of
35620 improved scheduling and reduced dependencies.
35622 @opindex maccumulate-outgoing-args
35623 @item -maccumulate-outgoing-args
35624 If enabled, the maximum amount of space required for outgoing arguments is
35625 computed in the function prologue. This is faster on most modern CPUs
35626 because of reduced dependencies, improved scheduling and reduced stack usage
35627 when the preferred stack boundary is not equal to 2. The drawback is a notable
35628 increase in code size. This switch implies @option{-mno-push-args}.
35632 Support thread-safe exception handling on MinGW. Programs that rely
35633 on thread-safe exception handling must compile and link all code with the
35634 @option{-mthreads} option. When compiling, @option{-mthreads} defines
35635 @option{-D_MT}; when linking, it links in a special thread helper library
35636 @option{-lmingwthrd} which cleans up per-thread exception-handling data.
35638 @opindex mms-bitfields
35639 @opindex mno-ms-bitfields
35640 @item -mms-bitfields
35641 @itemx -mno-ms-bitfields
35643 Enable/disable bit-field layout compatible with the native Microsoft
35646 If @code{packed} is used on a structure, or if bit-fields are used,
35647 it may be that the Microsoft ABI lays out the structure differently
35648 than the way GCC normally does. Particularly when moving packed
35649 data between functions compiled with GCC and the native Microsoft compiler
35650 (either via function call or as data in a file), it may be necessary to access
35653 This option is enabled by default for Microsoft Windows
35654 targets. This behavior can also be controlled locally by use of variable
35655 or type attributes. For more information, see @ref{x86 Variable Attributes}
35656 and @ref{x86 Type Attributes}.
35658 The Microsoft structure layout algorithm is fairly simple with the exception
35659 of the bit-field packing.
35660 The padding and alignment of members of structures and whether a bit-field
35661 can straddle a storage-unit boundary are determine by these rules:
35664 @item Structure members are stored sequentially in the order in which they are
35665 declared: the first member has the lowest memory address and the last member
35668 @item Every data object has an alignment requirement. The alignment requirement
35669 for all data except structures, unions, and arrays is either the size of the
35670 object or the current packing size (specified with either the
35671 @code{aligned} attribute or the @code{pack} pragma),
35672 whichever is less. For structures, unions, and arrays,
35673 the alignment requirement is the largest alignment requirement of its members.
35674 Every object is allocated an offset so that:
35677 offset % alignment_requirement == 0
35680 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
35681 unit if the integral types are the same size and if the next bit-field fits
35682 into the current allocation unit without crossing the boundary imposed by the
35683 common alignment requirements of the bit-fields.
35686 MSVC interprets zero-length bit-fields in the following ways:
35689 @item If a zero-length bit-field is inserted between two bit-fields that
35690 are normally coalesced, the bit-fields are not coalesced.
35697 unsigned long bf_1 : 12;
35699 unsigned long bf_2 : 12;
35704 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
35705 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
35707 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
35708 alignment of the zero-length bit-field is greater than the member that follows it,
35709 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
35730 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
35731 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
35732 bit-field does not affect the alignment of @code{bar} or, as a result, the size
35735 Taking this into account, it is important to note the following:
35738 @item If a zero-length bit-field follows a normal bit-field, the type of the
35739 zero-length bit-field may affect the alignment of the structure as whole. For
35740 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
35741 normal bit-field, and is of type short.
35743 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
35744 still affect the alignment of the structure:
35755 Here, @code{t4} takes up 4 bytes.
35758 @item Zero-length bit-fields following non-bit-field members are ignored:
35770 Here, @code{t5} takes up 2 bytes.
35774 @opindex mno-align-stringops
35775 @opindex malign-stringops
35776 @item -mno-align-stringops
35777 Do not align the destination of inlined string operations. This switch reduces
35778 code size and improves performance in case the destination is already aligned,
35779 but GCC doesn't know about it.
35781 @opindex minline-all-stringops
35782 @item -minline-all-stringops
35783 By default GCC inlines string operations only when the destination is
35784 known to be aligned to least a 4-byte boundary.
35785 This enables more inlining and increases code
35786 size, but may improve performance of code that depends on fast
35787 @code{memcpy} and @code{memset} for short lengths.
35788 The option enables inline expansion of @code{strlen} for all
35789 pointer alignments.
35791 @opindex minline-stringops-dynamically
35792 @item -minline-stringops-dynamically
35793 For string operations of unknown size, use run-time checks with
35794 inline code for small blocks and a library call for large blocks.
35796 @opindex mstringop-strategy=@var{alg}
35797 @item -mstringop-strategy=@var{alg}
35798 Override the internal decision heuristic for the particular algorithm to use
35799 for inlining string operations. The allowed values for @var{alg} are:
35805 Expand using i386 @code{rep} prefix of the specified size.
35809 @itemx unrolled_loop
35810 Expand into an inline loop.
35813 Always use a library call.
35816 @opindex mmemcpy-strategy=@var{strategy}
35817 @item -mmemcpy-strategy=@var{strategy}
35818 Override the internal decision heuristic to decide if @code{__builtin_memcpy}
35819 should be inlined and what inline algorithm to use when the expected size
35820 of the copy operation is known. @var{strategy}
35821 is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
35822 @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
35823 the max byte size with which inline algorithm @var{alg} is allowed. For the last
35824 triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
35825 in the list must be specified in increasing order. The minimal byte size for
35826 @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
35829 @opindex mmemset-strategy=@var{strategy}
35830 @item -mmemset-strategy=@var{strategy}
35831 The option is similar to @option{-mmemcpy-strategy=} except that it is to control
35832 @code{__builtin_memset} expansion.
35834 @opindex momit-leaf-frame-pointer
35835 @item -momit-leaf-frame-pointer
35836 Don't keep the frame pointer in a register for leaf functions. This
35837 avoids the instructions to save, set up, and restore frame pointers and
35838 makes an extra register available in leaf functions. The option
35839 @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
35840 which might make debugging harder.
35842 @opindex mtls-direct-seg-refs
35843 @item -mtls-direct-seg-refs
35844 @itemx -mno-tls-direct-seg-refs
35845 Controls whether TLS variables may be accessed with offsets from the
35846 TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
35847 or whether the thread base pointer must be added. Whether or not this
35848 is valid depends on the operating system, and whether it maps the
35849 segment to cover the entire TLS area.
35851 For systems that use the GNU C Library, the default is on.
35855 @itemx -mno-sse2avx
35856 Specify that the assembler should encode SSE instructions with VEX
35857 prefix. The option @option{-mavx} turns this on by default.
35862 If profiling is active (@option{-pg}), put the profiling
35863 counter call before the prologue.
35864 Note: On x86 architectures the attribute @code{ms_hook_prologue}
35865 isn't possible at the moment for @option{-mfentry} and @option{-pg}.
35867 @opindex mrecord-mcount
35868 @item -mrecord-mcount
35869 @itemx -mno-record-mcount
35870 If profiling is active (@option{-pg}), generate a __mcount_loc section
35871 that contains pointers to each profiling call. This is useful for
35872 automatically patching and out calls.
35874 @opindex mnop-mcount
35876 @itemx -mno-nop-mcount
35877 If profiling is active (@option{-pg}), generate the calls to
35878 the profiling functions as NOPs. This is useful when they
35879 should be patched in later dynamically. This is likely only
35880 useful together with @option{-mrecord-mcount}.
35882 @opindex minstrument-return
35883 @item -minstrument-return=@var{type}
35884 Instrument function exit in -pg -mfentry instrumented functions with
35885 call to specified function. This only instruments true returns ending
35886 with ret, but not sibling calls ending with jump. Valid types
35887 are @var{none} to not instrument, @var{call} to generate a call to __return__,
35888 or @var{nop5} to generate a 5 byte nop.
35890 @opindex mrecord-return
35891 @item -mrecord-return
35892 @itemx -mno-record-return
35893 Generate a __return_loc section pointing to all return instrumentation code.
35895 @opindex mfentry-name
35896 @item -mfentry-name=@var{name}
35897 Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
35899 @opindex mfentry-section
35900 @item -mfentry-section=@var{name}
35901 Set name of section to record -mrecord-mcount calls (default __mcount_loc).
35903 @opindex mskip-rax-setup
35904 @item -mskip-rax-setup
35905 @itemx -mno-skip-rax-setup
35906 When generating code for the x86-64 architecture with SSE extensions
35907 disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
35908 register when there are no variable arguments passed in vector registers.
35910 @strong{Warning:} Since RAX register is used to avoid unnecessarily
35911 saving vector registers on stack when passing variable arguments, the
35912 impacts of this option are callees may waste some stack space,
35913 misbehave or jump to a random location. GCC 4.4 or newer don't have
35914 those issues, regardless the RAX register value.
35916 @opindex m8bit-idiv
35918 @itemx -mno-8bit-idiv
35919 On some processors, like Intel Atom, 8-bit unsigned integer divide is
35920 much faster than 32-bit/64-bit integer divide. This option generates a
35921 run-time check. If both dividend and divisor are within range of 0
35922 to 255, 8-bit unsigned integer divide is used instead of
35923 32-bit/64-bit integer divide.
35925 @opindex mavx256-split-unaligned-load
35926 @opindex mavx256-split-unaligned-store
35927 @item -mavx256-split-unaligned-load
35928 @itemx -mavx256-split-unaligned-store
35929 Split 32-byte AVX unaligned load and store.
35931 @opindex mstack-protector-guard
35932 @opindex mstack-protector-guard-reg
35933 @opindex mstack-protector-guard-offset
35934 @item -mstack-protector-guard=@var{guard}
35935 @itemx -mstack-protector-guard-reg=@var{reg}
35936 @itemx -mstack-protector-guard-offset=@var{offset}
35937 Generate stack protection code using canary at @var{guard}. Supported
35938 locations are @samp{global} for global canary or @samp{tls} for per-thread
35939 canary in the TLS block (the default). This option has effect only when
35940 @option{-fstack-protector} or @option{-fstack-protector-all} is specified.
35942 With the latter choice the options
35943 @option{-mstack-protector-guard-reg=@var{reg}} and
35944 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
35945 which segment register (@code{%fs} or @code{%gs}) to use as base register
35946 for reading the canary, and from what offset from that base register.
35947 The default for those is as specified in the relevant ABI.
35949 @opindex mgeneral-regs-only
35950 @item -mgeneral-regs-only
35951 Generate code that uses only the general-purpose registers. This
35952 prevents the compiler from using floating-point, vector, mask and bound
35955 @opindex mrelax-cmpxchg-loop
35956 @item -mrelax-cmpxchg-loop
35957 When emitting a compare-and-swap loop for @ref{__sync Builtins}
35958 and @ref{__atomic Builtins} lacking a native instruction, optimize
35959 for the highly contended case by issuing an atomic load before the
35960 @code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
35961 to save CPU power when restarting the loop.
35963 @opindex mindirect-branch
35964 @item -mindirect-branch=@var{choice}
35965 Convert indirect call and jump with @var{choice}. The default is
35966 @samp{keep}, which keeps indirect call and jump unmodified.
35967 @samp{thunk} converts indirect call and jump to call and return thunk.
35968 @samp{thunk-inline} converts indirect call and jump to inlined call
35969 and return thunk. @samp{thunk-extern} converts indirect call and jump
35970 to external call and return thunk provided in a separate object file.
35971 You can control this behavior for a specific function by using the
35972 function attribute @code{indirect_branch}. @xref{Function Attributes}.
35974 Note that @option{-mcmodel=large} is incompatible with
35975 @option{-mindirect-branch=thunk} and
35976 @option{-mindirect-branch=thunk-extern} since the thunk function may
35977 not be reachable in the large code model.
35979 Note that @option{-mindirect-branch=thunk-extern} is compatible with
35980 @option{-fcf-protection=branch} since the external thunk can be made
35981 to enable control-flow check.
35983 @opindex mfunction-return
35984 @item -mfunction-return=@var{choice}
35985 Convert function return with @var{choice}. The default is @samp{keep},
35986 which keeps function return unmodified. @samp{thunk} converts function
35987 return to call and return thunk. @samp{thunk-inline} converts function
35988 return to inlined call and return thunk. @samp{thunk-extern} converts
35989 function return to external call and return thunk provided in a separate
35990 object file. You can control this behavior for a specific function by
35991 using the function attribute @code{function_return}.
35992 @xref{Function Attributes}.
35994 Note that @option{-mindirect-return=thunk-extern} is compatible with
35995 @option{-fcf-protection=branch} since the external thunk can be made
35996 to enable control-flow check.
35998 Note that @option{-mcmodel=large} is incompatible with
35999 @option{-mfunction-return=thunk} and
36000 @option{-mfunction-return=thunk-extern} since the thunk function may
36001 not be reachable in the large code model.
36004 @opindex mindirect-branch-register
36005 @item -mindirect-branch-register
36006 Force indirect call and jump via register.
36008 @opindex mharden-sls
36009 @item -mharden-sls=@var{choice}
36010 Generate code to mitigate against straight line speculation (SLS) with
36011 @var{choice}. The default is @samp{none} which disables all SLS
36012 hardening. @samp{return} enables SLS hardening for function returns.
36013 @samp{indirect-jmp} enables SLS hardening for indirect jumps.
36014 @samp{all} enables all SLS hardening.
36016 @opindex mindirect-branch-cs-prefix
36017 @item -mindirect-branch-cs-prefix
36018 Add CS prefix to call and jmp to indirect thunk with branch target in
36019 r8-r15 registers so that the call and jmp instruction length is 6 bytes
36020 to allow them to be replaced with @samp{lfence; call *%r8-r15} or
36021 @samp{lfence; jmp *%r8-r15} at run-time.
36023 @opindex mapx-inline-asm-use-gpr32
36024 @item -mapx-inline-asm-use-gpr32
36025 For inline asm support with APX, by default the EGPR feature was
36026 disabled to prevent potential illegal instruction with EGPR occurs.
36027 To invoke egpr usage in inline asm, use new compiler option
36028 -mapx-inline-asm-use-gpr32 and user should ensure the instruction
36033 @itemx -mno-evex512
36034 Enables/disables 512-bit vector. It will be default on if AVX512F is enabled.
36038 These @samp{-m} switches are supported in addition to the above
36039 on x86-64 processors in 64-bit environments.
36052 Generate code for a 16-bit, 32-bit or 64-bit environment.
36053 The @option{-m32} option sets @code{int}, @code{long}, and pointer types
36055 generates code that runs in 32-bit mode.
36057 The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
36058 types to 64 bits, and generates code for the x86-64 architecture.
36059 For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
36060 and @option{-mdynamic-no-pic} options.
36062 The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
36064 generates code for the x86-64 architecture.
36066 The @option{-m16} option is the same as @option{-m32}, except for that
36067 it outputs the @code{.code16gcc} assembly directive at the beginning of
36068 the assembly output so that the binary can run in 16-bit mode.
36070 The @option{-miamcu} option generates code which conforms to Intel MCU
36071 psABI. It requires the @option{-m32} option to be turned on.
36073 @opindex mno-red-zone
36075 @item -mno-red-zone
36076 Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
36077 by the x86-64 ABI; it is a 128-byte area beyond the location of the
36078 stack pointer that is not modified by signal or interrupt handlers
36079 and therefore can be used for temporary data without adjusting the stack
36080 pointer. The flag @option{-mno-red-zone} disables this red zone.
36082 @opindex mcmodel=small
36083 @item -mcmodel=small
36084 Generate code for the small code model: the program and its symbols must
36085 be linked in the lower 2 GB of the address space. Pointers are 64 bits.
36086 Programs can be statically or dynamically linked. This is the default
36089 @opindex mcmodel=kernel
36090 @item -mcmodel=kernel
36091 Generate code for the kernel code model. The kernel runs in the
36092 negative 2 GB of the address space.
36093 This model has to be used for Linux kernel code.
36095 @opindex mcmodel=medium
36096 @item -mcmodel=medium
36097 Generate code for the medium model: the program is linked in the lower 2
36098 GB of the address space. Small symbols are also placed there. Symbols
36099 with sizes larger than @option{-mlarge-data-threshold} are put into
36100 large data or BSS sections and can be located above 2GB. Programs can
36101 be statically or dynamically linked.
36103 @opindex mcmodel=large
36104 @item -mcmodel=large
36105 Generate code for the large model. This model makes no assumptions
36106 about addresses and sizes of sections.
36108 @opindex maddress-mode=long
36109 @item -maddress-mode=long
36110 Generate code for long address mode. This is only supported for 64-bit
36111 and x32 environments. It is the default address mode for 64-bit
36114 @opindex maddress-mode=short
36115 @item -maddress-mode=short
36116 Generate code for short address mode. This is only supported for 32-bit
36117 and x32 environments. It is the default address mode for 32-bit and
36123 Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
36124 indicate the micro-architecture ISA level required to execute the binary.
36126 @opindex mno-direct-extern-access
36127 @opindex mdirect-extern-access
36128 @item -mno-direct-extern-access
36129 Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
36130 to access external symbols. With @option{-fpic} or @option{-fPIC},
36131 treat access to protected symbols as local symbols. The default is
36132 @option{-mdirect-extern-access}.
36134 @strong{Warning:} shared libraries compiled with
36135 @option{-mno-direct-extern-access} and executable compiled with
36136 @option{-mdirect-extern-access} may not be binary compatible if
36137 protected symbols are used in shared libraries and executable.
36139 @opindex munroll-only-small-loops
36140 @opindex mno-unroll-only-small-loops
36141 @item -munroll-only-small-loops
36142 Controls conservative small loop unrolling. It is default enabled by
36143 O2, and unrolls loop with less than 4 insns by 1 time. Explicit
36144 -f[no-]unroll-[all-]loops would disable this flag to avoid any
36145 unintended unrolling behavior that user does not want.
36148 @item -mlam=@var{choice}
36149 LAM(linear-address masking) allows special bits in the pointer to be used
36150 for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
36151 positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
36152 positions 62:57 can be used for metadata.
36155 @node x86 Windows Options
36156 @subsection x86 Windows Options
36157 @cindex x86 Windows Options
36158 @cindex Windows Options for x86
36160 These additional options are available for Microsoft Windows targets:
36166 specifies that a console application is to be generated, by
36167 instructing the linker to set the PE header subsystem type
36168 required for console applications.
36169 This option is available for Cygwin and MinGW targets and is
36170 enabled by default on those targets.
36173 @item -mcrtdll=@var{library}
36174 Preprocess, compile or link with specified C RunTime DLL @var{library}.
36175 This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__}
36176 and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose
36177 start file for CRT @var{library} and link with CRT @var{library}.
36178 Recognized CRT library names for proprocessor are:
36179 @code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40},
36180 @code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90},
36181 @code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}.
36182 If this options is not specified then the default MinGW import library
36183 @code{msvcrt} is used for linking and no other adjustment for
36184 preprocessor is done. MinGW import library @code{msvcrt} is just a
36185 symlink to (or a copy of) another MinGW CRT import library
36186 chosen during MinGW compilation. MinGW import library @code{msvcrt-os}
36187 is for Windows system CRT DLL library @code{msvcrt.dll} and
36188 in most cases is the default MinGW import library.
36189 Generally speaking, changing the CRT DLL requires recompiling
36190 the entire MinGW CRT. This option is for experimental and testing
36192 This option is available for MinGW targets.
36196 This option is available for Cygwin and MinGW targets. It
36197 specifies that a DLL---a dynamic link library---is to be
36198 generated, enabling the selection of the required runtime
36199 startup object and entry point.
36201 @opindex mnop-fun-dllimport
36202 @item -mnop-fun-dllimport
36203 This option is available for Cygwin and MinGW targets. It
36204 specifies that the @code{dllimport} attribute should be ignored.
36208 This option is available for MinGW targets. It specifies
36209 that MinGW-specific thread support is to be used.
36213 This option is available for MinGW-w64 targets. It causes
36214 the @code{UNICODE} preprocessor macro to be predefined, and
36215 chooses Unicode-capable runtime startup code.
36219 This option is available for Cygwin and MinGW targets. It
36220 specifies that the typical Microsoft Windows predefined macros are to
36221 be set in the pre-processor, but does not influence the choice
36222 of runtime library/startup code.
36226 This option is available for Cygwin and MinGW targets. It
36227 specifies that a GUI application is to be generated by
36228 instructing the linker to set the PE header subsystem type
36231 @opindex fno-set-stack-executable
36232 @opindex fset-stack-executable
36233 @item -fno-set-stack-executable
36234 This option is available for MinGW targets. It specifies that
36235 the executable flag for the stack used by nested functions isn't
36236 set. This is necessary for binaries running in kernel mode of
36237 Microsoft Windows, as there the User32 API, which is used to set executable
36238 privileges, isn't available.
36240 @opindex fno-writable-relocated-rdata
36241 @opindex fwritable-relocated-rdata
36242 @item -fwritable-relocated-rdata
36243 This option is available for MinGW and Cygwin targets. It specifies
36244 that relocated-data in read-only section is put into the @code{.data}
36245 section. This is a necessary for older runtimes not supporting
36246 modification of @code{.rdata} sections for pseudo-relocation.
36248 @opindex mpe-aligned-commons
36249 @item -mpe-aligned-commons
36250 This option is available for Cygwin and MinGW targets. It
36251 specifies that the GNU extension to the PE file format that
36252 permits the correct alignment of COMMON variables should be
36253 used when generating code. It is enabled by default if
36254 GCC detects that the target assembler found during configuration
36255 supports the feature.
36258 See also under @ref{x86 Options} for standard options.
36260 @node Xstormy16 Options
36261 @subsection Xstormy16 Options
36262 @cindex Xstormy16 Options
36264 These options are defined for Xstormy16:
36269 Choose startup files and linker script suitable for the simulator.
36272 @node Xtensa Options
36273 @subsection Xtensa Options
36274 @cindex Xtensa Options
36276 These options are supported for Xtensa targets:
36280 @opindex mno-const16
36282 @itemx -mno-const16
36283 Enable or disable use of @code{CONST16} instructions for loading
36284 constant values. The @code{CONST16} instruction is currently not a
36285 standard option from Tensilica. When enabled, @code{CONST16}
36286 instructions are always used in place of the standard @code{L32R}
36287 instructions. The use of @code{CONST16} is enabled by default only if
36288 the @code{L32R} instruction is not available.
36290 @opindex mfused-madd
36291 @opindex mno-fused-madd
36293 @itemx -mno-fused-madd
36294 Enable or disable use of fused multiply/add and multiply/subtract
36295 instructions in the floating-point option. This has no effect if the
36296 floating-point option is not also enabled. Disabling fused multiply/add
36297 and multiply/subtract instructions forces the compiler to use separate
36298 instructions for the multiply and add/subtract operations. This may be
36299 desirable in some cases where strict IEEE 754-compliant results are
36300 required: the fused multiply add/subtract instructions do not round the
36301 intermediate result, thereby producing results with @emph{more} bits of
36302 precision than specified by the IEEE standard. Disabling fused multiply
36303 add/subtract instructions also ensures that the program output is not
36304 sensitive to the compiler's ability to combine multiply and add/subtract
36307 @opindex mserialize-volatile
36308 @opindex mno-serialize-volatile
36309 @item -mserialize-volatile
36310 @itemx -mno-serialize-volatile
36311 When this option is enabled, GCC inserts @code{MEMW} instructions before
36312 @code{volatile} memory references to guarantee sequential consistency.
36313 The default is @option{-mserialize-volatile}. Use
36314 @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
36316 @opindex mforce-no-pic
36317 @item -mforce-no-pic
36318 For targets, like GNU/Linux, where all user-mode Xtensa code must be
36319 position-independent code (PIC), this option disables PIC for compiling
36322 @opindex mtext-section-literals
36323 @opindex mno-text-section-literals
36324 @item -mtext-section-literals
36325 @itemx -mno-text-section-literals
36326 These options control the treatment of literal pools. The default is
36327 @option{-mno-text-section-literals}, which places literals in a separate
36328 section in the output file. This allows the literal pool to be placed
36329 in a data RAM/ROM, and it also allows the linker to combine literal
36330 pools from separate object files to remove redundant literals and
36331 improve code size. With @option{-mtext-section-literals}, the literals
36332 are interspersed in the text section in order to keep them as close as
36333 possible to their references. This may be necessary for large assembly
36334 files. Literals for each function are placed right before that function.
36336 @opindex mauto-litpools
36337 @opindex mno-auto-litpools
36338 @item -mauto-litpools
36339 @itemx -mno-auto-litpools
36340 These options control the treatment of literal pools. The default is
36341 @option{-mno-auto-litpools}, which places literals in a separate
36342 section in the output file unless @option{-mtext-section-literals} is
36343 used. With @option{-mauto-litpools} the literals are interspersed in
36344 the text section by the assembler. Compiler does not produce explicit
36345 @code{.literal} directives and loads literals into registers with
36346 @code{MOVI} instructions instead of @code{L32R} to let the assembler
36347 do relaxation and place literals as necessary. This option allows
36348 assembler to create several literal pools per function and assemble
36349 very big functions, which may not be possible with
36350 @option{-mtext-section-literals}.
36352 @opindex mtarget-align
36353 @opindex mno-target-align
36354 @item -mtarget-align
36355 @itemx -mno-target-align
36356 When this option is enabled, GCC instructs the assembler to
36357 automatically align instructions to reduce branch penalties at the
36358 expense of some code density. The assembler attempts to widen density
36359 instructions to align branch targets and the instructions following call
36360 instructions. If there are not enough preceding safe density
36361 instructions to align a target, no widening is performed. The
36362 default is @option{-mtarget-align}. These options do not affect the
36363 treatment of auto-aligned instructions like @code{LOOP}, which the
36364 assembler always aligns, either by widening density instructions or
36365 by inserting NOP instructions.
36367 @opindex mlongcalls
36368 @opindex mno-longcalls
36370 @itemx -mno-longcalls
36371 When this option is enabled, GCC instructs the assembler to translate
36372 direct calls to indirect calls unless it can determine that the target
36373 of a direct call is in the range allowed by the call instruction. This
36374 translation typically occurs for calls to functions in other source
36375 files. Specifically, the assembler translates a direct @code{CALL}
36376 instruction into an @code{L32R} followed by a @code{CALLX} instruction.
36377 The default is @option{-mno-longcalls}. This option should be used in
36378 programs where the call target can potentially be out of range. This
36379 option is implemented in the assembler, not the compiler, so the
36380 assembly code generated by GCC still shows direct call
36381 instructions---look at the disassembled object code to see the actual
36382 instructions. Note that the assembler uses an indirect call for
36383 every cross-file call, not just those that really are out of range.
36386 @item -mabi=@var{name}
36387 Generate code for the specified ABI@. Permissible values are: @samp{call0},
36388 @samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
36390 @opindex mabi=call0
36392 When this option is enabled function parameters are passed in registers
36393 @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
36394 caller-saved, and register @code{a15} may be used as a frame pointer.
36395 When this version of the ABI is enabled the C preprocessor symbol
36396 @code{__XTENSA_CALL0_ABI__} is defined.
36398 @opindex mabi=windowed
36399 @item -mabi=windowed
36400 When this option is enabled function parameters are passed in registers
36401 @code{a10} through @code{a15}, and called function rotates register window
36402 by 8 registers on entry so that its arguments are found in registers
36403 @code{a2} through @code{a7}. Register @code{a7} may be used as a frame
36404 pointer. Register window is rotated 8 registers back upon return.
36405 When this version of the ABI is enabled the C preprocessor symbol
36406 @code{__XTENSA_WINDOWED_ABI__} is defined.
36408 @opindex mextra-l32r-costs
36409 @item -mextra-l32r-costs=@var{n}
36410 Specify an extra cost of instruction RAM/ROM access for @code{L32R}
36411 instructions, in clock cycles. This affects, when optimizing for speed,
36412 whether loading a constant from literal pool using @code{L32R} or
36413 synthesizing the constant from a small one with a couple of arithmetic
36414 instructions. The default value is 0.
36416 @opindex mstrict-align
36417 @opindex mno-strict-align
36418 @item -mstrict-align
36419 @itemx -mno-strict-align
36420 Avoid or allow generating memory accesses that may not be aligned on a natural
36421 object boundary as described in the architecture specification.
36422 The default is @option{-mno-strict-align} for cores that support both
36423 unaligned loads and stores in hardware and @option{-mstrict-align} for all
36428 @node zSeries Options
36429 @subsection zSeries Options
36430 @cindex zSeries options
36432 These are listed under @xref{S/390 and zSeries Options}.
36438 @section Specifying Subprocesses and the Switches to Pass to Them
36441 @command{gcc} is a driver program. It performs its job by invoking a
36442 sequence of other programs to do the work of compiling, assembling and
36443 linking. GCC interprets its command-line parameters and uses these to
36444 deduce which programs it should invoke, and which command-line options
36445 it ought to place on their command lines. This behavior is controlled
36446 by @dfn{spec strings}. In most cases there is one spec string for each
36447 program that GCC can invoke, but a few programs have multiple spec
36448 strings to control their behavior. The spec strings built into GCC can
36449 be overridden by using the @option{-specs=} command-line switch to specify
36452 @dfn{Spec files} are plain-text files that are used to construct spec
36453 strings. They consist of a sequence of directives separated by blank
36454 lines. The type of directive is determined by the first non-whitespace
36455 character on the line, which can be one of the following:
36458 @item %@var{command}
36459 Issues a @var{command} to the spec file processor. The commands that can
36463 @cindex @code{%include}
36464 @item %include <@var{file}>
36465 Search for @var{file} and insert its text at the current point in the
36468 @cindex @code{%include_noerr}
36469 @item %include_noerr <@var{file}>
36470 Just like @samp{%include}, but do not generate an error message if the include
36471 file cannot be found.
36473 @cindex @code{%rename}
36474 @item %rename @var{old_name} @var{new_name}
36475 Rename the spec string @var{old_name} to @var{new_name}.
36479 @item *[@var{spec_name}]:
36480 This tells the compiler to create, override or delete the named spec
36481 string. All lines after this directive up to the next directive or
36482 blank line are considered to be the text for the spec string. If this
36483 results in an empty string then the spec is deleted. (Or, if the
36484 spec did not exist, then nothing happens.) Otherwise, if the spec
36485 does not currently exist a new spec is created. If the spec does
36486 exist then its contents are overridden by the text of this
36487 directive, unless the first character of that text is the @samp{+}
36488 character, in which case the text is appended to the spec.
36490 @item [@var{suffix}]:
36491 Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
36492 and up to the next directive or blank line are considered to make up the
36493 spec string for the indicated suffix. When the compiler encounters an
36494 input file with the named suffix, it processes the spec string in
36495 order to work out how to compile that file. For example:
36499 z-compile -input %i
36502 This says that any input file whose name ends in @samp{.ZZ} should be
36503 passed to the program @samp{z-compile}, which should be invoked with the
36504 command-line switch @option{-input} and with the result of performing the
36505 @samp{%i} substitution. (See below.)
36507 As an alternative to providing a spec string, the text following a
36508 suffix directive can be one of the following:
36511 @item @@@var{language}
36512 This says that the suffix is an alias for a known @var{language}. This is
36513 similar to using the @option{-x} command-line switch to GCC to specify a
36514 language explicitly. For example:
36521 Says that .ZZ files are, in fact, C++ source files.
36524 This causes an error messages saying:
36527 @var{name} compiler not installed on this system.
36531 GCC already has an extensive list of suffixes built into it.
36532 This directive adds an entry to the end of the list of suffixes, but
36533 since the list is searched from the end backwards, it is effectively
36534 possible to override earlier entries using this technique.
36538 GCC has the following spec strings built into it. Spec files can
36539 override these strings or create their own. Note that individual
36540 targets can also add their own spec strings to this list.
36543 asm Options to pass to the assembler
36544 asm_final Options to pass to the assembler post-processor
36545 cpp Options to pass to the C preprocessor
36546 cc1 Options to pass to the C compiler
36547 cc1plus Options to pass to the C++ compiler
36548 endfile Object files to include at the end of the link
36549 link Options to pass to the linker
36550 lib Libraries to include on the command line to the linker
36551 libgcc Decides which GCC support library to pass to the linker
36552 linker Sets the name of the linker
36553 predefines Defines to be passed to the C preprocessor
36554 signed_char Defines to pass to CPP to say whether @code{char} is signed
36556 startfile Object files to include at the start of the link
36559 Here is a small example of a spec file:
36562 %rename lib old_lib
36565 --start-group -lgcc -lc -leval1 --end-group %(old_lib)
36568 This example renames the spec called @samp{lib} to @samp{old_lib} and
36569 then overrides the previous definition of @samp{lib} with a new one.
36570 The new definition adds in some extra command-line options before
36571 including the text of the old definition.
36573 @dfn{Spec strings} are a list of command-line options to be passed to their
36574 corresponding program. In addition, the spec strings can contain
36575 @samp{%}-prefixed sequences to substitute variable text or to
36576 conditionally insert text into the command line. Using these constructs
36577 it is possible to generate quite complex command lines.
36579 Here is a table of all defined @samp{%}-sequences for spec
36580 strings. Note that spaces are not generated automatically around the
36581 results of expanding these sequences. Therefore you can concatenate them
36582 together or combine them with constant text in a single argument.
36586 Substitute one @samp{%} into the program name or argument.
36589 Substitute an empty argument.
36592 Substitute the name of the input file being processed.
36595 Substitute the basename for outputs related with the input file being
36596 processed. This is often the substring up to (and not including) the
36597 last period and not including the directory but, unless %w is active, it
36598 expands to the basename for auxiliary outputs, which may be influenced
36599 by an explicit output name, and by various other options that control
36600 how auxiliary outputs are named.
36603 This is the same as @samp{%b}, but include the file suffix (text after
36604 the last period). Without %w, it expands to the basename for dump
36608 Marks the argument containing or following the @samp{%d} as a
36609 temporary file name, so that that file is deleted if GCC exits
36610 successfully. Unlike @samp{%g}, this contributes no text to the
36613 @item %g@var{suffix}
36614 Substitute a file name that has suffix @var{suffix} and is chosen
36615 once per compilation, and mark the argument in the same way as
36616 @samp{%d}. To reduce exposure to denial-of-service attacks, the file
36617 name is now chosen in a way that is hard to predict even when previously
36618 chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
36619 might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
36620 the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
36621 treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
36622 was simply substituted with a file name chosen once per compilation,
36623 without regard to any appended suffix (which was therefore treated
36624 just like ordinary text), making such attacks more likely to succeed.
36626 @item %u@var{suffix}
36627 Like @samp{%g}, but generates a new temporary file name
36628 each time it appears instead of once per compilation.
36630 @item %U@var{suffix}
36631 Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
36632 new one if there is no such last file name. In the absence of any
36633 @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
36634 the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
36635 involves the generation of two distinct file names, one
36636 for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
36637 simply substituted with a file name chosen for the previous @samp{%u},
36638 without regard to any appended suffix.
36640 @item %j@var{suffix}
36641 Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
36642 writable, and if @option{-save-temps} is not used;
36643 otherwise, substitute the name
36644 of a temporary file, just like @samp{%u}. This temporary file is not
36645 meant for communication between processes, but rather as a junk
36646 disposal mechanism.
36648 @item %|@var{suffix}
36649 @itemx %m@var{suffix}
36650 Like @samp{%g}, except if @option{-pipe} is in effect. In that case
36651 @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
36652 all. These are the two most common ways to instruct a program that it
36653 should read from standard input or write to standard output. If you
36654 need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
36655 construct: see for example @file{gcc/fortran/lang-specs.h}.
36657 @item %.@var{SUFFIX}
36658 Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
36659 when it is subsequently output with @samp{%*}. @var{SUFFIX} is
36660 terminated by the next space or %.
36663 Marks the argument containing or following the @samp{%w} as the
36664 designated output file of this compilation. This puts the argument
36665 into the sequence of arguments that @samp{%o} substitutes.
36668 Indicates that this compilation produces no output file.
36671 Substitutes the names of all the output files, with spaces
36672 automatically placed around them. You should write spaces
36673 around the @samp{%o} as well or the results are undefined.
36674 @samp{%o} is for use in the specs for running the linker.
36675 Input files whose names have no recognized suffix are not compiled
36676 at all, but they are included among the output files, so they are
36680 Substitutes the suffix for object files. Note that this is
36681 handled specially when it immediately follows @samp{%g, %u, or %U},
36682 because of the need for those to form complete file names. The
36683 handling is such that @samp{%O} is treated exactly as if it had already
36684 been substituted, except that @samp{%g, %u, and %U} do not currently
36685 support additional @var{suffix} characters following @samp{%O} as they do
36686 following, for example, @samp{.o}.
36689 Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
36690 @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
36691 @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
36692 and @option{-imultilib} as necessary.
36695 Current argument is the name of a library or startup file of some sort.
36696 Search for that file in a standard list of directories and substitute
36697 the full name found. The current working directory is included in the
36698 list of directories scanned.
36701 Current argument is the name of a linker script. Search for that file
36702 in the current list of directories to scan for libraries. If the file
36703 is located insert a @option{--script} option into the command line
36704 followed by the full path name found. If the file is not found then
36705 generate an error message. Note: the current working directory is not
36709 Print @var{str} as an error message. @var{str} is terminated by a newline.
36710 Use this when inconsistent options are detected.
36713 Print @var{str} as a notice. @var{str} is terminated by a newline.
36715 @item %(@var{name})
36716 Substitute the contents of spec string @var{name} at this point.
36718 @item %x@{@var{option}@}
36719 Accumulate an option for @samp{%X}.
36722 Output the accumulated linker options specified by a @samp{%x} spec string.
36725 Output the accumulated assembler options specified by @option{-Wa}.
36728 Output the accumulated preprocessor options specified by @option{-Wp}.
36731 Output @code{multilib_os_dir}.
36734 Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
36737 Process the @code{asm} spec. This is used to compute the
36738 switches to be passed to the assembler.
36741 Process the @code{asm_final} spec. This is a spec string for
36742 passing switches to an assembler post-processor, if such a program is
36746 Process the @code{link} spec. This is the spec for computing the
36747 command line passed to the linker. Typically it makes use of the
36748 @samp{%L %G %S %D and %E} sequences.
36751 Dump out a @option{-L} option for each directory that GCC believes might
36752 contain startup files. If the target supports multilibs then the
36753 current multilib directory is prepended to each of these paths.
36756 Process the @code{lib} spec. This is a spec string for deciding which
36757 libraries are included on the command line to the linker.
36760 Process the @code{libgcc} spec. This is a spec string for deciding
36761 which GCC support library is included on the command line to the linker.
36764 Process the @code{startfile} spec. This is a spec for deciding which
36765 object files are the first ones passed to the linker. Typically
36766 this might be a file named @file{crt0.o}.
36769 Process the @code{endfile} spec. This is a spec string that specifies
36770 the last object files that are passed to the linker.
36773 Process the @code{cpp} spec. This is used to construct the arguments
36774 to be passed to the C preprocessor.
36777 Process the @code{cc1} spec. This is used to construct the options to be
36778 passed to the actual C compiler (@command{cc1}).
36781 Process the @code{cc1plus} spec. This is used to construct the options to be
36782 passed to the actual C++ compiler (@command{cc1plus}).
36785 Substitute the variable part of a matched option. See below.
36786 Note that each comma in the substituted string is replaced by
36790 Remove all occurrences of @code{-S} from the command line. Note---this
36791 command is position dependent. @samp{%} commands in the spec string
36792 before this one see @code{-S}, @samp{%} commands in the spec string
36793 after this one do not.
36796 Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
36799 Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
36801 @item %:@var{function}(@var{args})
36802 Call the named function @var{function}, passing it @var{args}.
36803 @var{args} is first processed as a nested spec string, then split
36804 into an argument vector in the usual fashion. The function returns
36805 a string which is processed as if it had appeared literally as part
36806 of the current spec.
36808 The following built-in spec functions are provided:
36811 @item @code{getenv}
36812 The @code{getenv} spec function takes two arguments: an environment
36813 variable name and a string. If the environment variable is not
36814 defined, a fatal error is issued. Otherwise, the return value is the
36815 value of the environment variable concatenated with the string. For
36816 example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
36819 %:getenv(TOPDIR /include)
36822 expands to @file{/path/to/top/include}.
36824 @item @code{if-exists}
36825 The @code{if-exists} spec function takes one argument, an absolute
36826 pathname to a file. If the file exists, @code{if-exists} returns the
36827 pathname. Here is a small example of its usage:
36831 crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
36834 @item @code{if-exists-else}
36835 The @code{if-exists-else} spec function is similar to the @code{if-exists}
36836 spec function, except that it takes two arguments. The first argument is
36837 an absolute pathname to a file. If the file exists, @code{if-exists-else}
36838 returns the pathname. If it does not exist, it returns the second argument.
36839 This way, @code{if-exists-else} can be used to select one file or another,
36840 based on the existence of the first. Here is a small example of its usage:
36844 crt0%O%s %:if-exists(crti%O%s) \
36845 %:if-exists-else(crtbeginT%O%s crtbegin%O%s)
36848 @item @code{if-exists-then-else}
36849 The @code{if-exists-then-else} spec function takes at least two arguments
36850 and an optional third one. The first argument is an absolute pathname to a
36851 file. If the file exists, the function returns the second argument.
36852 If the file does not exist, the function returns the third argument if there
36853 is one, or NULL otherwise. This can be used to expand one text, or optionally
36854 another, based on the existence of a file. Here is a small example of its
36858 -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
36861 @item @code{sanitize}
36862 The @code{sanitize} spec function takes no arguments. It returns non-NULL if
36863 any address, thread or undefined behavior sanitizers are active.
36866 %@{%:sanitize(address):-funwind-tables@}
36869 @item @code{replace-outfile}
36870 The @code{replace-outfile} spec function takes two arguments. It looks for the
36871 first argument in the outfiles array and replaces it with the second argument. Here
36872 is a small example of its usage:
36875 %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
36878 @item @code{remove-outfile}
36879 The @code{remove-outfile} spec function takes one argument. It looks for the
36880 first argument in the outfiles array and removes it. Here is a small example
36884 %:remove-outfile(-lm)
36887 @item @code{version-compare}
36888 The @code{version-compare} spec function takes four or five arguments of the following
36892 <comparison-op> <arg1> [<arg2>] <switch> <result>
36895 It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
36896 The supported @code{comparison-op} values are:
36900 True if @code{switch} is a later (or same) version than @code{arg1}
36903 Opposite of @code{>=}
36906 True if @code{switch} is an earlier version than @code{arg1}
36909 Opposite of @code{<}
36912 True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
36915 True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
36918 If the @code{switch} is not present at all, the condition is false unless the first character
36919 of the @code{comparison-op} is @code{!}.
36922 %:version-compare(>= 10.3 mmacosx-version-min= -lmx)
36925 The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
36928 @item @code{include}
36929 The @code{include} spec function behaves much like @code{%include}, with the advantage
36930 that it can be nested inside a spec and thus be conditionalized. It takes one argument,
36931 the filename, and looks for it in the startfile path. It always returns NULL.
36934 %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
36937 @item @code{pass-through-libs}
36938 The @code{pass-through-libs} spec function takes any number of arguments. It
36939 finds any @option{-l} options and any non-options ending in @file{.a} (which it
36940 assumes are the names of linker input library archive files) and returns a
36941 result containing all the found arguments each prepended by
36942 @option{-plugin-opt=-pass-through=} and joined by spaces. This list is
36943 intended to be passed to the LTO linker plugin.
36946 %:pass-through-libs(%G %L %G)
36949 @item @code{print-asm-header}
36950 The @code{print-asm-header} function takes no arguments and simply
36951 prints a banner like:
36957 Use "-Wa,OPTION" to pass "OPTION" to the assembler.
36960 It is used to separate compiler options from assembler options
36961 in the @option{--target-help} output.
36964 The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
36965 empty string) if the second-to-last argument is greater than the last argument, and NULL
36966 otherwise. The following example inserts the @code{link_gomp} spec if the last
36967 @option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
36970 %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
36973 @item @code{debug-level-gt}
36974 The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
36975 empty string) if @code{debug_info_level} is greater than the specified number, and NULL
36979 %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
36984 Substitutes the @code{-S} switch, if that switch is given to GCC@.
36985 If that switch is not specified, this substitutes nothing. Note that
36986 the leading dash is omitted when specifying this option, and it is
36987 automatically inserted if the substitution is performed. Thus the spec
36988 string @samp{%@{foo@}} matches the command-line option @option{-foo}
36989 and outputs the command-line option @option{-foo}.
36992 Like %@{@code{S}@} but mark last argument supplied within as a file to be
36993 deleted on failure.
36996 Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
36997 @code{@@FILE} if an @code{@@file} argument has been supplied.
37000 Substitutes all the switches specified to GCC whose names start
37001 with @code{-S}, but which also take an argument. This is used for
37002 switches like @option{-o}, @option{-D}, @option{-I}, etc.
37003 GCC considers @option{-o foo} as being
37004 one switch whose name starts with @samp{o}. %@{o*@} substitutes this
37005 text, including the space. Thus two arguments are generated.
37008 Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
37009 (the order of @code{S} and @code{T} in the spec is not significant).
37010 There can be any number of ampersand-separated variables; for each the
37011 wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
37014 Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
37017 Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
37020 Substitutes @code{X} if one or more switches whose names start with
37021 @code{-S} are specified to GCC@. Normally @code{X} is substituted only
37022 once, no matter how many such switches appeared. However, if @code{%*}
37023 appears somewhere in @code{X}, then @code{X} is substituted once
37024 for each matching switch, with the @code{%*} replaced by the part of
37025 that switch matching the @code{*}.
37027 If @code{%*} appears as the last part of a spec sequence then a space
37028 is added after the end of the last substitution. If there is more
37029 text in the sequence, however, then a space is not generated. This
37030 allows the @code{%*} substitution to be used as part of a larger
37031 string. For example, a spec string like this:
37034 %@{mcu=*:--script=%*/memory.ld@}
37038 when matching an option like @option{-mcu=newchip} produces:
37041 --script=newchip/memory.ld
37045 Substitutes @code{X}, if processing a file with suffix @code{S}.
37048 Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
37051 Substitutes @code{X}, if processing a file for language @code{S}.
37054 Substitutes @code{X}, if not processing a file for language @code{S}.
37057 Substitutes @code{X} if either @code{-S} or @code{-P} is given to
37058 GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
37059 @code{*} sequences as well, although they have a stronger binding than
37060 the @samp{|}. If @code{%*} appears in @code{X}, all of the
37061 alternatives must be starred, and only the first matching alternative
37064 For example, a spec string like this:
37067 %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
37071 outputs the following command-line options from the following input
37072 command-line options:
37077 -d fred.c -foo -baz -boggle
37078 -d jim.d -bar -baz -boggle
37081 @item %@{%:@var{function}(@var{args}):X@}
37083 Call function named @var{function} with args @var{args}. If the
37084 function returns non-NULL, then @code{X} is substituted, if it returns
37085 NULL, it isn't substituted.
37087 @item %@{S:X; T:Y; :D@}
37089 If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
37090 given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
37091 be as many clauses as you need. This may be combined with @code{.},
37092 @code{,}, @code{!}, @code{|}, and @code{*} as needed.
37097 The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
37098 or similar construct can use a backslash to ignore the special meaning
37099 of the character following it, thus allowing literal matching of a
37100 character that is otherwise specially treated. For example,
37101 @samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
37102 @option{-std=iso9899:1999} option is given.
37104 The conditional text @code{X} in a @samp{%@{S:X@}} or similar
37105 construct may contain other nested @samp{%} constructs or spaces, or
37106 even newlines. They are processed as usual, as described above.
37107 Trailing white space in @code{X} is ignored. White space may also
37108 appear anywhere on the left side of the colon in these constructs,
37109 except between @code{.} or @code{*} and the corresponding word.
37111 The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
37112 handled specifically in these constructs. If another value of
37113 @option{-O} or the negated form of a @option{-f}, @option{-m}, or
37114 @option{-W} switch is found later in the command line, the earlier
37115 switch value is ignored, except with @{@code{S}*@} where @code{S} is
37116 just one letter, which passes all matching options.
37118 The character @samp{|} at the beginning of the predicate text is used to
37119 indicate that a command should be piped to the following command, but
37120 only if @option{-pipe} is specified.
37122 It is built into GCC which switches take arguments and which do not.
37123 (You might think it would be useful to generalize this to allow each
37124 compiler's spec to say which switches take arguments. But this cannot
37125 be done in a consistent fashion. GCC cannot even decide which input
37126 files have been specified without knowing which switches take arguments,
37127 and it must know which input files to compile in order to tell which
37130 GCC also knows implicitly that arguments starting in @option{-l} are to be
37131 treated as compiler output files, and passed to the linker in their
37132 proper position among the other output files.
37134 @node Environment Variables
37135 @section Environment Variables Affecting GCC
37136 @cindex environment variables
37138 @c man begin ENVIRONMENT
37139 This section describes several environment variables that affect how GCC
37140 operates. Some of them work by specifying directories or prefixes to use
37141 when searching for various kinds of files. Some are used to specify other
37142 aspects of the compilation environment.
37144 Note that you can also specify places to search using options such as
37145 @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
37146 take precedence over places specified using environment variables, which
37147 in turn take precedence over those specified by the configuration of GCC@.
37148 @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
37149 GNU Compiler Collection (GCC) Internals}.
37154 @c @vindex LC_COLLATE
37155 @vindex LC_MESSAGES
37156 @c @vindex LC_MONETARY
37157 @c @vindex LC_NUMERIC
37163 @c @itemx LC_COLLATE
37165 @c @itemx LC_MONETARY
37166 @c @itemx LC_NUMERIC
37169 These environment variables control the way that GCC uses
37170 localization information which allows GCC to work with different
37171 national conventions. GCC inspects the locale categories
37172 @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
37173 so. These locale categories can be set to any value supported by your
37174 installation. A typical value is @samp{en_GB.UTF-8} for English in the United
37175 Kingdom encoded in UTF-8.
37177 The @env{LC_CTYPE} environment variable specifies character
37178 classification. GCC uses it to determine the character boundaries in
37179 a string; this is needed for some multibyte encodings that contain quote
37180 and escape characters that are otherwise interpreted as a string
37183 The @env{LC_MESSAGES} environment variable specifies the language to
37184 use in diagnostic messages.
37186 If the @env{LC_ALL} environment variable is set, it overrides the value
37187 of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
37188 and @env{LC_MESSAGES} default to the value of the @env{LANG}
37189 environment variable. If none of these variables are set, GCC
37190 defaults to traditional C English behavior.
37194 If @env{TMPDIR} is set, it specifies the directory to use for temporary
37195 files. GCC uses temporary files to hold the output of one stage of
37196 compilation which is to be used as input to the next stage: for example,
37197 the output of the preprocessor, which is the input to the compiler
37200 @vindex GCC_COMPARE_DEBUG
37201 @item GCC_COMPARE_DEBUG
37202 Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
37203 @option{-fcompare-debug} to the compiler driver. See the documentation
37204 of this option for more details.
37206 @vindex GCC_EXEC_PREFIX
37207 @item GCC_EXEC_PREFIX
37208 If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
37209 names of the subprograms executed by the compiler. No slash is added
37210 when this prefix is combined with the name of a subprogram, but you can
37211 specify a prefix that ends with a slash if you wish.
37213 If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
37214 an appropriate prefix to use based on the pathname it is invoked with.
37216 If GCC cannot find the subprogram using the specified prefix, it
37217 tries looking in the usual places for the subprogram.
37219 The default value of @env{GCC_EXEC_PREFIX} is
37220 @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
37221 the installed compiler. In many cases @var{prefix} is the value
37222 of @code{prefix} when you ran the @file{configure} script.
37224 Other prefixes specified with @option{-B} take precedence over this prefix.
37226 This prefix is also used for finding files such as @file{crt0.o} that are
37229 In addition, the prefix is used in an unusual way in finding the
37230 directories to search for header files. For each of the standard
37231 directories whose name normally begins with @samp{/usr/local/lib/gcc}
37232 (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
37233 replacing that beginning with the specified prefix to produce an
37234 alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
37235 @file{foo/bar} just before it searches the standard directory
37236 @file{/usr/local/lib/bar}.
37237 If a standard directory begins with the configured
37238 @var{prefix} then the value of @var{prefix} is replaced by
37239 @env{GCC_EXEC_PREFIX} when looking for header files.
37241 @vindex COMPILER_PATH
37242 @item COMPILER_PATH
37243 The value of @env{COMPILER_PATH} is a colon-separated list of
37244 directories, much like @env{PATH}. GCC tries the directories thus
37245 specified when searching for subprograms, if it cannot find the
37246 subprograms using @env{GCC_EXEC_PREFIX}.
37248 @vindex LIBRARY_PATH
37250 The value of @env{LIBRARY_PATH} is a colon-separated list of
37251 directories, much like @env{PATH}. When configured as a native compiler,
37252 GCC tries the directories thus specified when searching for special
37253 linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
37254 using GCC also uses these directories when searching for ordinary
37255 libraries for the @option{-l} option (but directories specified with
37256 @option{-L} come first).
37259 @cindex locale definition
37261 This variable is used to pass locale information to the compiler. One way in
37262 which this information is used is to determine the character set to be used
37263 when character literals, string literals and comments are parsed in C and C++.
37264 When the compiler is configured to allow multibyte characters,
37265 the following values for @env{LANG} are recognized:
37269 Recognize JIS characters.
37271 Recognize SJIS characters.
37273 Recognize EUCJP characters.
37276 If @env{LANG} is not defined, or if it has some other value, then the
37277 compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
37278 recognize and translate multibyte characters.
37280 @vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
37281 @item GCC_EXTRA_DIAGNOSTIC_OUTPUT
37282 If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
37283 then additional text will be emitted to stderr when fix-it hints are
37284 emitted. @option{-fdiagnostics-parseable-fixits} and
37285 @option{-fno-diagnostics-parseable-fixits} take precedence over this
37286 environment variable.
37290 Emit parseable fix-it hints, equivalent to
37291 @option{-fdiagnostics-parseable-fixits}. In particular, columns are
37292 expressed as a count of bytes, starting at byte 1 for the initial column.
37295 As @code{fixits-v1}, but columns are expressed as display columns,
37296 as per @option{-fdiagnostics-column-unit=display}.
37302 Some additional environment variables affect the behavior of the
37305 @include cppenv.texi
37309 @node Precompiled Headers
37310 @section Using Precompiled Headers
37311 @cindex precompiled headers
37312 @cindex speed of compilation
37314 Often large projects have many header files that are included in every
37315 source file. The time the compiler takes to process these header files
37316 over and over again can account for nearly all of the time required to
37317 build the project. To make builds faster, GCC allows you to
37318 @dfn{precompile} a header file.
37320 To create a precompiled header file, simply compile it as you would any
37321 other file, if necessary using the @option{-x} option to make the driver
37322 treat it as a C or C++ header file. You may want to use a
37323 tool like @command{make} to keep the precompiled header up-to-date when
37324 the headers it contains change.
37326 A precompiled header file is searched for when @code{#include} is
37327 seen in the compilation. As it searches for the included file
37328 (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
37329 compiler looks for a precompiled header in each directory just before it
37330 looks for the include file in that directory. The name searched for is
37331 the name specified in the @code{#include} with @samp{.gch} appended. If
37332 the precompiled header file cannot be used, it is ignored.
37334 For instance, if you have @code{#include "all.h"}, and you have
37335 @file{all.h.gch} in the same directory as @file{all.h}, then the
37336 precompiled header file is used if possible, and the original
37337 header is used otherwise.
37339 Alternatively, you might decide to put the precompiled header file in a
37340 directory and use @option{-I} to ensure that directory is searched
37341 before (or instead of) the directory containing the original header.
37342 Then, if you want to check that the precompiled header file is always
37343 used, you can put a file of the same name as the original header in this
37344 directory containing an @code{#error} command.
37346 This also works with @option{-include}. So yet another way to use
37347 precompiled headers, good for projects not designed with precompiled
37348 header files in mind, is to simply take most of the header files used by
37349 a project, include them from another header file, precompile that header
37350 file, and @option{-include} the precompiled header. If the header files
37351 have guards against multiple inclusion, they are skipped because
37352 they've already been included (in the precompiled header).
37354 If you need to precompile the same header file for different
37355 languages, targets, or compiler options, you can instead make a
37356 @emph{directory} named like @file{all.h.gch}, and put each precompiled
37357 header in the directory, perhaps using @option{-o}. It doesn't matter
37358 what you call the files in the directory; every precompiled header in
37359 the directory is considered. The first precompiled header
37360 encountered in the directory that is valid for this compilation is
37361 used; they're searched in no particular order.
37363 There are many other possibilities, limited only by your imagination,
37364 good sense, and the constraints of your build system.
37366 A precompiled header file can be used only when these conditions apply:
37370 Only one precompiled header can be used in a particular compilation.
37373 A precompiled header cannot be used once the first C token is seen. You
37374 can have preprocessor directives before a precompiled header; you cannot
37375 include a precompiled header from inside another header.
37378 The precompiled header file must be produced for the same language as
37379 the current compilation. You cannot use a C precompiled header for a C++
37383 The precompiled header file must have been produced by the same compiler
37384 binary as the current compilation is using.
37387 Any macros defined before the precompiled header is included must
37388 either be defined in the same way as when the precompiled header was
37389 generated, or must not affect the precompiled header, which usually
37390 means that they don't appear in the precompiled header at all.
37392 The @option{-D} option is one way to define a macro before a
37393 precompiled header is included; using a @code{#define} can also do it.
37394 There are also some options that define macros implicitly, like
37395 @option{-O} and @option{-Wdeprecated}; the same rule applies to macros
37398 @item If debugging information is output when using the precompiled
37399 header, using @option{-g} or similar, the same kind of debugging information
37400 must have been output when building the precompiled header. However,
37401 a precompiled header built using @option{-g} can be used in a compilation
37402 when no debugging information is being output.
37404 @item The same @option{-m} options must generally be used when building
37405 and using the precompiled header. @xref{Submodel Options},
37406 for any cases where this rule is relaxed.
37408 @item Each of the following options must be the same when building and using
37409 the precompiled header:
37411 @gccoptlist{-fexceptions}
37414 Some other command-line options starting with @option{-f},
37415 @option{-p}, or @option{-O} must be defined in the same way as when
37416 the precompiled header was generated. At present, it's not clear
37417 which options are safe to change and which are not; the safest choice
37418 is to use exactly the same options when generating and using the
37419 precompiled header. The following are known to be safe:
37421 @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock
37422 -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
37423 -fsched-verbose=@var{number} -fschedule-insns -fvisibility=
37426 @item Address space layout randomization (ASLR) can lead to not binary identical
37427 PCH files. If you rely on stable PCH file contents disable ASLR when generating
37432 For all of these except the last, the compiler automatically
37433 ignores the precompiled header if the conditions aren't met. If you
37434 find an option combination that doesn't work and doesn't cause the
37435 precompiled header to be ignored, please consider filing a bug report,
37438 If you do use differing options when generating and using the
37439 precompiled header, the actual behavior is a mixture of the
37440 behavior for the options. For instance, if you use @option{-g} to
37441 generate the precompiled header but not when using it, you may or may
37442 not get debugging information for routines in the precompiled header.
37445 @section C++ Modules
37446 @cindex speed of compilation
37448 Modules are a C++20 language feature. As the name suggests, they
37449 provides a modular compilation system, intending to provide both
37450 faster builds and better library isolation. The ``Merging Modules''
37451 paper @uref{https://wg21.link/p1103}, provides the easiest to read set
37452 of changes to the standard, although it does not capture later
37455 @emph{G++'s modules support is not complete.} Other than bugs, the
37456 known missing pieces are:
37460 @item Private Module Fragment
37461 The Private Module Fragment is recognized, but an error is emitted.
37463 @item Partition definition visibility rules
37464 Entities may be defined in implementation partitions, and those
37465 definitions are not available outside of the module. This is not
37466 implemented, and the definitions are available to extra-module use.
37468 @item Textual merging of reachable GM entities
37469 Entities may be multiply defined across different header-units.
37470 These must be de-duplicated, and this is implemented across imports,
37471 or when an import redefines a textually-defined entity. However the
37472 reverse is not implemented---textually redefining an entity that has
37473 been defined in an imported header-unit. A redefinition error is
37476 @item Translation-Unit local referencing rules
37477 Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
37478 (@uref{https://wg21.link/p2003}) add limitations on which entities an
37479 exported region may reference (for instance, the entities an exported
37480 template definition may reference). These are not fully implemented.
37482 @item Standard Library Header Units
37483 The Standard Library is not provided as importable header units. If
37484 you want to import such units, you must explicitly build them first.
37485 If you do not do this with care, you may have multiple declarations,
37486 which the module machinery must merge---compiler resource usage can be
37487 affected by how you partition header files into header units.
37491 Modular compilation is @emph{not} enabled with just the
37492 @option{-std=c++20} option. You must explicitly enable it with the
37493 @option{-fmodules-ts} option. It is independent of the language
37494 version selected, although in pre-C++20 versions, it is of course an
37497 No new source file suffixes are required or supported. If you wish to
37498 use a non-standard suffix (@pxref{Overall Options}), you also need
37499 to provide a @option{-x c++} option too.@footnote{Some users like to
37500 distinguish module interface files with a new suffix, such as naming
37501 the source @code{module.cppm}, which involves
37502 teaching all tools about the new suffix. A different scheme, such as
37503 naming @code{module-m.cpp} would be less invasive.}
37505 Compiling a module interface unit produces an additional output (to
37506 the assembly or object file), called a Compiled Module Interface
37507 (CMI). This encodes the exported declarations of the module.
37508 Importing a module reads in the CMI. The import graph is a Directed
37509 Acyclic Graph (DAG). You must build imports before the importer.
37511 Header files may themselves be compiled to header units, which are a
37512 transitional ability aiming at faster compilation. The
37513 @option{-fmodule-header} option is used to enable this, and implies
37514 the @option{-fmodules-ts} option. These CMIs are named by the fully
37515 resolved underlying header file, and thus may be a complete pathname
37516 containing subdirectories. If the header file is found at an absolute
37517 pathname, the CMI location is still relative to a CMI root directory.
37519 As header files often have no suffix, you commonly have to specify a
37520 @option{-x} option to tell the compiler the source is a header file.
37521 You may use @option{-x c++-header}, @option{-x c++-user-header} or
37522 @option{-x c++-system-header}. When used in conjunction with
37523 @option{-fmodules-ts}, these all imply an appropriate
37524 @option{-fmodule-header} option. The latter two variants use the
37525 user or system include path to search for the file specified. This
37526 allows you to, for instance, compile standard library header files as
37527 header units, without needing to know exactly where they are
37528 installed. Specifying the language as one of these variants also
37529 inhibits output of the object file, as header files have no associated
37532 The @option{-fmodule-only} option disables generation of the
37533 associated object file for compiling a module interface. Only the CMI
37534 is generated. This option is implied when using the
37535 @option{-fmodule-header} option.
37537 The @option{-flang-info-include-translate} and
37538 @option{-flang-info-include-translate-not} options notes whether
37539 include translation occurs or not. With no argument, the first will
37540 note all include translation. The second will note all
37541 non-translations of include files not known to intentionally be
37542 textual. With an argument, queries about include translation of a
37543 header files with that particular trailing pathname are noted. You
37544 may repeat this form to cover several different header files. This
37545 option may be helpful in determining whether include translation is
37546 happening---if it is working correctly, it behaves as if it isn't
37549 The @option{-flang-info-module-cmi} option can be used to determine
37550 where the compiler is reading a CMI from. Without the option, the
37551 compiler is silent when such a read is successful. This option has an
37552 optional argument, which will restrict the notification to just the
37553 set of named modules or header units specified.
37555 The @option{-Winvalid-imported-macros} option causes all imported macros
37556 to be resolved at the end of compilation. Without this, imported
37557 macros are only resolved when expanded or (re)defined. This option
37558 detects conflicting import definitions for all macros.
37560 For details of the @option{-fmodule-mapper} family of options,
37561 @pxref{C++ Module Mapper}.
37564 * C++ Module Mapper:: Module Mapper
37565 * C++ Module Preprocessing:: Module Preprocessing
37566 * C++ Compiled Module Interface:: Compiled Module Interface
37569 @node C++ Module Mapper
37570 @subsection Module Mapper
37571 @cindex C++ Module Mapper
37573 A module mapper provides a server or file that the compiler queries to
37574 determine the mapping between module names and CMI files. It is also
37575 used to build CMIs on demand. @emph{Mapper functionality is in its
37576 infancy and is intended for experimentation with build system
37579 You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
37580 option or @env{CXX_MODULE_MAPPER} environment variable. The value may
37581 have one of the following forms:
37585 @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
37586 An optional hostname and a numeric port number to connect to. If the
37587 hostname is omitted, the loopback address is used. If the hostname
37588 corresponds to multiple IPV6 addresses, these are tried in turn, until
37589 one is successful. If your host lacks IPv6, this form is
37590 non-functional. If you must use IPv4 use
37591 @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
37593 @item =@var{socket}@r{[}?@var{ident}@r{]}
37594 A local domain socket. If your host lacks local domain sockets, this
37595 form is non-functional.
37597 @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
37598 A program to spawn, and communicate with on its stdin/stdout streams.
37599 Your @var{PATH} environment variable is searched for the program.
37600 Arguments are separated by space characters, (it is not possible for
37601 one of the arguments delivered to the program to contain a space). An
37602 exception is if @var{program} begins with @@. In that case
37603 @var{program} (sans @@) is looked for in the compiler's internal
37604 binary directory. Thus the sample mapper-server can be specified
37605 with @code{@@g++-mapper-server}.
37607 @item <>@r{[}?@var{ident}@r{]}
37608 @item <>@var{inout}@r{[}?@var{ident}@r{]}
37609 @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
37610 Named pipes or file descriptors to communicate over. The first form,
37611 @option{<>}, communicates over stdin and stdout. The other forms
37612 allow you to specify a file descriptor or name a pipe. A numeric value
37613 is interpreted as a file descriptor, otherwise named pipe is opened.
37614 The second form specifies a bidirectional pipe and the last form
37615 allows specifying two independent pipes. Using file descriptors
37616 directly in this manner is fragile in general, as it can require the
37617 cooperation of intermediate processes. In particular using stdin &
37618 stdout is fraught with danger as other compiler options might also
37619 cause the compiler to read stdin or write stdout, and it can have
37620 unfortunate interactions with signal delivery from the terminal.
37622 @item @var{file}@r{[}?@var{ident}@r{]}
37623 A mapping file consisting of space-separated module-name, filename
37624 pairs, one per line. Only the mappings for the direct imports and any
37625 module export name need be provided. If other mappings are provided,
37626 they override those stored in any imported CMI files. A repository
37627 root may be specified in the mapping file by using @samp{$root} as the
37628 module name in the first active line. Use of this option will disable
37629 any default module->CMI name mapping.
37633 As shown, an optional @var{ident} may suffix the first word of the
37634 option, indicated by a @samp{?} prefix. The value is used in the
37635 initial handshake with the module server, or to specify a prefix on
37636 mapping file lines. In the server case, the main source file name is
37637 used if no @var{ident} is specified. In the file case, all non-blank
37638 lines are significant, unless a value is specified, in which case only
37639 lines beginning with @var{ident} are significant. The @var{ident}
37640 must be separated by whitespace from the module name. Be aware that
37641 @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
37642 significant to the shell, and therefore may need quoting.
37644 The mapper is connected to or loaded lazily, when the first module
37645 mapping is required. The networking protocols are only supported on
37646 hosts that provide networking. If no mapper is specified a default is
37649 A project-specific mapper is expected to be provided by the build
37650 system that invokes the compiler. It is not expected that a
37651 general-purpose server is provided for all compilations. As such, the
37652 server will know the build configuration, the compiler it invoked, and
37653 the environment (such as working directory) in which that is
37654 operating. As it may parallelize builds, several compilations may
37655 connect to the same socket.
37657 The default mapper generates CMI files in a @samp{gcm.cache}
37658 directory. CMI files have a @samp{.gcm} suffix. The module unit name
37659 is used directly to provide the basename. Header units construct a
37660 relative path using the underlying header file name. If the path is
37661 already relative, a @samp{,} directory is prepended. Internal
37662 @samp{..} components are translated to @samp{,,}. No attempt is made
37663 to canonicalize these filenames beyond that done by the preprocessor's
37664 include search algorithm, as in general it is ambiguous when symbolic
37667 The mapper protocol was published as ``A Module Mapper''
37668 @uref{https://wg21.link/p1184}. The implementation is provided by
37669 @command{libcody}, @uref{https://github.com/urnathan/libcody},
37670 which specifies the canonical protocol definition. A proof of concept
37671 server implementation embedded in @command{make} was described in
37672 ''Make Me A Module'', @uref{https://wg21.link/p1602}.
37674 @node C++ Module Preprocessing
37675 @subsection Module Preprocessing
37676 @cindex C++ Module Preprocessing
37678 Modules affect preprocessing because of header units and include
37679 translation. Some uses of the preprocessor as a separate step either
37680 do not produce a correct output, or require CMIs to be available.
37682 Header units import macros. These macros can affect later conditional
37683 inclusion, which therefore can cascade to differing import sets. When
37684 preprocessing, it is necessary to load the CMI. If a header unit is
37685 unavailable, the preprocessor issues a warning and continue (when
37686 not just preprocessing, an error is emitted). Detecting such imports
37687 requires preprocessor tokenization of the input stream to phase 4
37690 Include translation converts @code{#include}, @code{#include_next} and
37691 @code{#import} directives to internal @code{import} declarations.
37692 Whether a particular directive is translated is controlled by the
37693 module mapper. Header unit names are canonicalized during
37696 Dependency information can be emitted for macro import, extending the
37697 functionality of @option{-MD} and @option{-MMD} options. Detection of
37698 import declarations also requires phase 4 preprocessing, and thus
37699 requires full preprocessing (or compilation).
37701 The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
37702 preprocessing before phase 4.
37704 The @option{-save-temps} option uses @option{-fdirectives-only} for
37705 preprocessing, and preserve the macro definitions in the preprocessed
37706 output. Usually you also want to use this option when explicitly
37707 preprocessing a header-unit, or consuming such preprocessed output:
37710 g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
37711 g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
37714 @node C++ Compiled Module Interface
37715 @subsection Compiled Module Interface
37716 @cindex C++ Compiled Module Interface
37718 CMIs are an additional artifact when compiling named module
37719 interfaces, partitions or header units. These are read when
37720 importing. CMI contents are implementation-specific, and in GCC's
37721 case tied to the compiler version. Consider them a rebuildable cache
37722 artifact, not a distributable object.
37724 When creating an output CMI, any missing directory components are
37725 created in a manner that is safe for concurrent builds creating
37726 multiple, different, CMIs within a common subdirectory tree.
37728 CMI contents are written to a temporary file, which is then atomically
37729 renamed. Observers either see old contents (if there is an
37730 existing file), or complete new contents. They do not observe the
37731 CMI during its creation. This is unlike object file writing, which
37732 may be observed by an external process.
37734 CMIs are read in lazily, if the host OS provides @code{mmap}
37735 functionality. Generally blocks are read when name lookup or template
37736 instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
37737 option may be used.
37739 The @option{--param lazy-modules=@var{n}} parameter controls the limit
37740 on the number of concurrently open module files during lazy loading.
37741 Should more modules be imported, an LRU algorithm is used to determine
37742 which files to close---until that file is needed again. This limit
37743 may be exceeded with deep module dependency hierarchies. With large
37744 code bases there may be more imports than the process limit of file
37745 descriptors. By default, the limit is a few less than the per-process
37746 file descriptor hard limit, if that is determinable.@footnote{Where
37747 applicable the soft limit is incremented as needed towards the hard limit.}
37749 GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
37750 You may use @command{readelf} to inspect them, although section
37751 contents are largely undecipherable. There is a section named
37752 @code{.gnu.c++.README}, which contains human-readable text. Other
37753 than the first line, each line consists of @code{@var{tag}: @code{value}}
37757 > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
37759 String dump of section '.gnu.c++.README':
37760 [ 0] GNU C++ primary module interface
37761 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
37762 [ 6f] version: 2020/11/16-04:54
37764 [ 95] source: c_b.ii
37765 [ a4] dialect: C++20/coroutines
37766 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
37767 [ ee] repository: gcm.cache
37768 [ 104] buildtime: 2020/11/16 15:03:21 UTC
37769 [ 127] localtime: 2020/11/16 07:03:21 PST
37770 [ 14a] export: foo:part1 foo-part1.gcm
37773 Amongst other things, this lists the source that was built, C++
37774 dialect used and imports of the module.@footnote{The precise contents
37775 of this output may change.} The timestamp is the same value as that
37776 provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
37777 explicitly specified with the environment variable
37778 @code{SOURCE_DATE_EPOCH}. For further details
37779 @pxref{Environment Variables}.
37781 A set of related CMIs may be copied, provided the relative pathnames
37784 The @code{.gnu.c++.README} contents do not affect CMI integrity, and
37785 it may be removed or altered. The section numbering of the sections
37786 whose names do not begin with @code{.gnu.c++.}, or are not the string
37787 section is significant and must not be altered.