]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/invoke.texi
7640e7d88671ed823ac6771d116e8d248ff6b249
[thirdparty/gcc.git] / gcc / doc / invoke.texi
1 @c Copyright (C) 1988-2025 Free Software Foundation, Inc.
2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi.
4
5 @ignore
6 @c man begin INCLUDE
7 @include gcc-vers.texi
8 @c man end
9
10 @c man begin COPYRIGHT
11 Copyright @copyright{} 1988-2025 Free Software Foundation, Inc.
12
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.
20
21 (a) The FSF's Front-Cover Text is:
22
23 A GNU Manual
24
25 (b) The FSF's Back-Cover Text is:
26
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.
30 @c man end
31 @c Set file name and title for the man page.
32 @setfilename gcc
33 @settitle GNU project C and C++ compiler
34 @c man begin SYNOPSIS
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{}
42
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}.
45 @c man end
46 @c man begin SEEALSO
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}.
51 @c man end
52 @c man begin BUGS
53 For instructions on reporting bugs, see
54 @w{@value{BUGURL}}.
55 @c man end
56 @c man begin AUTHOR
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@.
60 @c man end
61 @end ignore
62
63 @node Invoking GCC
64 @chapter GCC Command Options
65 @cindex GCC command options
66 @cindex command options
67 @cindex options, GCC command
68
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}.
76
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.
81
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.
88
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.
101
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
107 -v}}.
108
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.
116
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.
123
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.
138
139 @c man end
140
141 @xref{Option Index}, for an index to GCC's options.
142
143 @menu
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
152 and Objective-C++.
153 * OpenMP and OpenACC Options:: Controlling multiprocessing and offloading.
154 * Diagnostic Message Formatting Options:: Controlling how diagnostics should
155 be formatted.
156 * Warning Options:: How picky should the compiler be?
157 * Static Analyzer Options:: More expensive warnings.
158 * Debugging Options:: Producing debuggable code.
159 * Optimize Options:: How much optimization?
160 * Instrumentation Options:: Enabling profiling and extra run-time error checking.
161 * Preprocessor Options:: Controlling header files and macro definitions.
162 Also, getting dependency information for Make.
163 * Assembler Options:: Passing options to the assembler.
164 * Link Options:: Specifying libraries and so on.
165 * Directory Options:: Where to find header files and libraries.
166 Where to find the compiler executable files.
167 * Code Gen Options:: Specifying conventions for function calls, data layout
168 and register usage.
169 * Developer Options:: Printing GCC configuration info, statistics, and
170 debugging dumps.
171 * Submodel Options:: Target-specific options, such as compiling for a
172 specific processor variant.
173 * Spec Files:: How to pass switches to sub-processes.
174 * Environment Variables:: Env vars that affect GCC.
175 * Precompiled Headers:: Compiling a header once, and using it many times.
176 * C++ Modules:: Experimental C++20 module system.
177 @end menu
178
179 @c man begin OPTIONS
180
181 @node Option Summary
182 @section Option Summary
183
184 Here is a summary of all the options, grouped by type. Explanations are
185 in the following sections.
186
187 @table @emph
188 @item Overall Options
189 @xref{Overall Options,,Options Controlling the Kind of Output}.
190 @gccoptlist{-c -S -E -o @var{file}
191 -dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf}
192 -dumpdir @var{dumppfx} -x @var{language}
193 -v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version
194 -pass-exit-codes -pipe -specs=@var{file} -wrapper
195 @@@var{file} -ffile-prefix-map=@var{old}=@var{new} -fcanon-prefix-map
196 -fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg}
197 -fdump-ada-spec@r{[}-slim@r{]} -fada-spec-parent=@var{unit} -fdump-go-spec=@var{file}}
198
199 @item C Language Options
200 @xref{C Dialect Options,,Options Controlling C Dialect}.
201 @gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename}
202 -fno-asm
203 -fno-builtin -fno-builtin-@var{function} -fcond-mismatch
204 -ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted
205 -flax-vector-conversions -fms-extensions
206 -fpermitted-flt-eval-methods=@var{standard}
207 -fplan9-extensions -fsigned-bitfields -funsigned-bitfields
208 -fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}]
209 -fsso-struct=@var{endianness}}
210
211 @item C++ Language Options
212 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
213 @gccoptlist{-fabi-version=@var{n} -fno-access-control
214 -faligned-new=@var{n} -fno-assume-sane-operators-new-delete
215 -fchar8_t -fcheck-new
216 -fconcepts -fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n}
217 -fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n}
218 -fno-elide-constructors
219 -fno-enforce-eh-specs
220 -fno-gnu-keywords
221 -fno-immediate-escalation
222 -fno-implicit-templates
223 -fno-implicit-inline-templates
224 -fno-implement-inlines
225 -fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules
226 -fmodule-implicit-inline
227 -fno-module-lazy
228 -fmodule-mapper=@var{specification}
229 -fmodule-version-ignore
230 -fms-extensions
231 -fnew-inheriting-ctors
232 -fnew-ttp-matching
233 -fno-nonansi-builtins -fnothrow-opt -fno-operator-names
234 -fno-optional-diags
235 -fno-pretty-templates -frange-for-ext-temps
236 -fno-rtti -fsized-deallocation
237 -fstrong-eval-order@r{[}=@var{kind}@r{]}
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-defaulted-function-deleted
255 -Wno-delete-incomplete
256 -Wdelete-non-virtual-dtor -Wno-deprecated-array-compare
257 -Wdeprecated-copy -Wdeprecated-copy-dtor
258 -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion
259 -Weffc++ -Wno-elaborated-enum-base
260 -Wno-exceptions -Wextra-semi -Wno-global-module -Wno-inaccessible-base
261 -Wno-inherited-variadic-ctor -Wno-init-list-lifetime
262 -Winvalid-constexpr -Winvalid-imported-macros
263 -Wno-invalid-offsetof -Wno-literal-suffix
264 -Wmismatched-new-delete -Wmismatched-tags
265 -Wmultiple-inheritance -Wnamespaces -Wnarrowing
266 -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor
267 -Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n}
268 -Wrange-loop-construct -Wredundant-move -Wredundant-tags
269 -Wreorder -Wregister -Wno-sfinae-incomplete
270 -Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates
271 -Wno-non-template-friend -Wold-style-cast
272 -Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo
273 -Wsized-deallocation -Wsuggest-final-methods
274 -Wsuggest-final-types -Wsuggest-override -Wno-template-body
275 -Wno-template-id-cdtor -Wtemplate-names-tu-local
276 -Wno-terminate -Wno-vexing-parse -Wvirtual-inheritance
277 -Wno-virtual-move-assign -Wvolatile}
278
279 @item Objective-C and Objective-C++ Language Options
280 @xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling
281 Objective-C and Objective-C++ Dialects}.
282 @gccoptlist{-fconstant-string-class=@var{class-name}
283 -fgnu-runtime -fnext-runtime
284 -fno-nil-receivers
285 -fobjc-abi-version=@var{n}
286 -fobjc-call-cxx-cdtors
287 -fobjc-direct-dispatch
288 -fobjc-exceptions
289 -fobjc-gc
290 -fobjc-nilcheck
291 -fobjc-std=objc1
292 -fno-local-ivars
293 -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
294 -freplace-objc-classes
295 -fzero-link
296 -gen-decls
297 -Wassign-intercept -Wno-property-assign-default
298 -Wno-protocol -Wobjc-root-class -Wselector
299 -Wstrict-selector-match
300 -Wundeclared-selector}
301
302 @item OpenMP and OpenACC Options
303 @xref{OpenMP and OpenACC Options,,Options Controlling OpenMP and OpenACC}.
304 @gccoptlist{-foffload=@var{arg} -foffload-options=@var{arg}
305 -fopenacc -fopenacc-dim=@var{geom}
306 -fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]}}
307
308 @item Diagnostic Message Formatting Options
309 @xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
310 @gccoptlist{-fmessage-length=@var{n}
311 -fdiagnostics-plain-output
312 -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}
313 -fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]}
314 -fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]}
315 -fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{]}
316 -fdiagnostics-add-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
317 -fdiagnostics-set-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
318 -fno-diagnostics-json-formatting
319 -fno-diagnostics-show-option -fno-diagnostics-show-caret
320 -fno-diagnostics-show-event-links
321 -fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers
322 -fno-diagnostics-show-cwe
323 -fno-diagnostics-show-rules
324 -fno-diagnostics-show-highlight-colors
325 -fdiagnostics-minimum-margin-width=@var{width}
326 -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
327 -fdiagnostics-show-template-tree -fno-elide-type
328 -fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]}
329 -fdiagnostics-show-path-depths
330 -fno-show-column
331 -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]}
332 -fdiagnostics-column-origin=@var{origin}
333 -fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}
334 -fdiagnostics-text-art-charset=@r{[}none@r{|}ascii@r{|}unicode@r{|}emoji@r{]}}
335
336 @item Warning Options
337 @xref{Warning Options,,Options to Request or Suppress Warnings}.
338 @gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic
339 -pedantic-errors -fpermissive
340 -w -Wextra -Wall -Wabi=@var{n}
341 -Waddress -Wno-address-of-packed-member -Waggregate-return
342 -Walloc-size -Walloc-size-larger-than=@var{byte-size} -Walloc-zero
343 -Walloca -Walloca-larger-than=@var{byte-size} -Wauto-profile
344 -Wno-aggressive-loop-optimizations
345 -Warith-conversion
346 -Warray-bounds -Warray-bounds=@var{n} -Warray-compare
347 -Warray-parameter -Warray-parameter=@var{n}
348 -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias
349 -Wno-attribute-warning
350 -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
351 -Wbool-compare -Wbool-operation
352 -Wno-builtin-declaration-mismatch
353 -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat
354 -Wc11-c23-compat -Wc23-c2y-compat
355 -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat
356 -Wc++20-compat
357 -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions
358 -Wno-c++20-extensions -Wno-c++23-extensions
359 -Wcalloc-transposed-args
360 -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual
361 -Wchar-subscripts
362 -Wclobbered -Wcomment
363 -Wcompare-distinct-pointer-types
364 -Wno-complain-wrong-lang
365 -Wconversion -Wno-coverage-mismatch -Wno-cpp
366 -Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n}
367 -Wdate-time
368 -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init
369 -Wdisabled-optimization
370 -Wno-discarded-array-qualifiers -Wno-discarded-qualifiers
371 -Wno-div-by-zero -Wdouble-promotion
372 -Wduplicated-branches -Wduplicated-cond
373 -Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion
374 -Wenum-int-mismatch
375 -Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors
376 -Wflex-array-member-not-at-end
377 -Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2
378 -Wno-format-contains-nul -Wno-format-extra-args
379 -Wformat-nonliteral -Wformat-overflow=@var{n}
380 -Wformat-security -Wformat-signedness -Wformat-truncation=@var{n}
381 -Wformat-y2k -Wframe-address
382 -Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object
383 -Wheader-guard -Wno-if-not-aligned -Wno-ignored-attributes
384 -Wignored-qualifiers -Wno-incompatible-pointer-types -Whardened
385 -Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n}
386 -Wno-implicit-function-declaration -Wno-implicit-int
387 -Winfinite-recursion
388 -Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context
389 -Wno-int-to-pointer-cast -Wno-invalid-memory-model
390 -Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init
391 -Wlarger-than=@var{byte-size} -Wleading-whitespace=@var{kind}
392 -Wlogical-not-parentheses -Wlogical-op
393 -Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized
394 -Wmemset-elt-size -Wmemset-transposed-args
395 -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces
396 -Wmissing-field-initializers -Wmissing-format-attribute
397 -Wmissing-include-dirs -Wmissing-noreturn -Wmusttail-local-addr
398 -Wmaybe-musttail-local-addr -Wno-missing-profile
399 -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare
400 -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
401 -Wnull-dereference -Wno-odr
402 -Wopenacc-parallelism
403 -Wopenmp -Wopenmp-simd
404 -Wno-overflow -Woverlength-strings -Wno-override-init-side-effects
405 -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
406 -Wparentheses -Wno-pedantic-ms-format
407 -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
408 -Wno-pragmas -Wno-pragma-once-outside-header -Wno-prio-ctor-dtor
409 -Wno-psabi
410 -Wredundant-decls -Wrestrict
411 -Wno-return-local-addr -Wreturn-type
412 -Wno-scalar-storage-order -Wsequence-point
413 -Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local
414 -Wno-shadow-ivar
415 -Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value
416 -Wno-shift-overflow -Wshift-overflow=@var{n}
417 -Wsign-compare -Wsign-conversion
418 -Wno-sizeof-array-argument
419 -Wsizeof-array-div
420 -Wsizeof-pointer-div -Wsizeof-pointer-memaccess
421 -Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing
422 -Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n}
423 -Wstring-compare
424 -Wno-stringop-overflow -Wno-stringop-overread
425 -Wno-stringop-truncation -Wstrict-flex-arrays
426 -Wsuggest-attribute=@var{attribute-name}
427 -Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum
428 -Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand
429 -Wsystem-headers -Wtautological-compare -Wtrailing-whitespace
430 -Wtrailing-whitespace=@var{kind} -Wtrampolines -Wtrigraphs
431 -Wtrivial-auto-var-init -Wno-tsan -Wtype-limits -Wundef
432 -Wuninitialized -Wunknown-pragmas
433 -Wunsuffixed-float-constants
434 -Wunterminated-string-initialization
435 -Wunused
436 -Wunused-but-set-parameter -Wunused-but-set-variable
437 -Wunused-const-variable -Wunused-const-variable=@var{n}
438 -Wunused-function -Wunused-label -Wunused-local-typedefs
439 -Wunused-macros
440 -Wunused-parameter -Wno-unused-result
441 -Wunused-value -Wunused-variable
442 -Wuse-after-free -Wuse-after-free=@var{n} -Wuseless-cast
443 -Wno-varargs -Wvariadic-macros
444 -Wvector-operation-performance
445 -Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than
446 -Wvolatile-register-var -Wwrite-strings
447 -Wno-xor-used-as-pow
448 -Wzero-as-null-pointer-constant
449 -Wzero-length-bounds}
450
451 @item Static Analyzer Options
452 @gccoptlist{
453 -fanalyzer
454 -fanalyzer-call-summaries
455 -fanalyzer-checker=@var{name}
456 -fno-analyzer-feasibility
457 -fanalyzer-fine-grained
458 -fanalyzer-show-events-in-system-headers
459 -fno-analyzer-state-merge
460 -fno-analyzer-state-purge
461 -fno-analyzer-suppress-followups
462 -fanalyzer-transitivity
463 -fno-analyzer-undo-inlining
464 -fanalyzer-verbose-edges
465 -fanalyzer-verbose-state-changes
466 -fanalyzer-verbosity=@var{level}
467 -fdump-analyzer
468 -fdump-analyzer-callgraph
469 -fdump-analyzer-exploded-graph
470 -fdump-analyzer-exploded-nodes
471 -fdump-analyzer-exploded-nodes-2
472 -fdump-analyzer-exploded-nodes-3
473 -fdump-analyzer-exploded-paths
474 -fdump-analyzer-feasibility
475 -fdump-analyzer-infinite-loop
476 -fdump-analyzer-json
477 -fdump-analyzer-state-purge
478 -fdump-analyzer-stderr
479 -fdump-analyzer-supergraph
480 -fdump-analyzer-untracked
481 -Wno-analyzer-double-fclose
482 -Wno-analyzer-double-free
483 -Wno-analyzer-exposure-through-output-file
484 -Wno-analyzer-exposure-through-uninit-copy
485 -Wno-analyzer-fd-access-mode-mismatch
486 -Wno-analyzer-fd-double-close
487 -Wno-analyzer-fd-leak
488 -Wno-analyzer-fd-phase-mismatch
489 -Wno-analyzer-fd-type-mismatch
490 -Wno-analyzer-fd-use-after-close
491 -Wno-analyzer-fd-use-without-check
492 -Wno-analyzer-file-leak
493 -Wno-analyzer-free-of-non-heap
494 -Wno-analyzer-imprecise-fp-arithmetic
495 -Wno-analyzer-infinite-loop
496 -Wno-analyzer-infinite-recursion
497 -Wno-analyzer-jump-through-null
498 -Wno-analyzer-malloc-leak
499 -Wno-analyzer-mismatching-deallocation
500 -Wno-analyzer-null-argument
501 -Wno-analyzer-null-dereference
502 -Wno-analyzer-out-of-bounds
503 -Wno-analyzer-overlapping-buffers
504 -Wno-analyzer-possible-null-argument
505 -Wno-analyzer-possible-null-dereference
506 -Wno-analyzer-putenv-of-auto-var
507 -Wno-analyzer-shift-count-negative
508 -Wno-analyzer-shift-count-overflow
509 -Wno-analyzer-stale-setjmp-buffer
510 -Wno-analyzer-tainted-allocation-size
511 -Wno-analyzer-tainted-assertion
512 -Wno-analyzer-tainted-array-index
513 -Wno-analyzer-tainted-divisor
514 -Wno-analyzer-tainted-offset
515 -Wno-analyzer-tainted-size
516 -Wno-analyzer-throw-of-unexpected-type
517 -Wanalyzer-symbol-too-complex
518 -Wanalyzer-too-complex
519 -Wno-analyzer-undefined-behavior-ptrdiff
520 -Wno-analyzer-undefined-behavior-strtok
521 -Wno-analyzer-unsafe-call-within-signal-handler
522 -Wno-analyzer-use-after-free
523 -Wno-analyzer-use-of-pointer-in-stale-stack-frame
524 -Wno-analyzer-use-of-uninitialized-value
525 -Wno-analyzer-va-arg-type-mismatch
526 -Wno-analyzer-va-list-exhausted
527 -Wno-analyzer-va-list-leak
528 -Wno-analyzer-va-list-use-after-va-end
529 -Wno-analyzer-write-to-const
530 -Wno-analyzer-write-to-string-literal
531 }
532
533 @item C and Objective-C-only Warning Options
534 @gccoptlist{-Wbad-function-cast -Wdeprecated-non-prototype -Wfree-labels
535 -Wmissing-declarations -Wmissing-parameter-name -Wmissing-parameter-type
536 -Wdeclaration-missing-parameter-type -Wmissing-prototypes
537 -Wmissing-variable-declarations -Wnested-externs -Wold-style-declaration
538 -Wold-style-definition -Wstrict-prototypes -Wtraditional
539 -Wtraditional-conversion -Wdeclaration-after-statement -Wpointer-sign}
540
541 @item Debugging Options
542 @xref{Debugging Options,,Options for Debugging Your Program}.
543 @gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version}
544 -gbtf -gctf -gctf@var{level}
545 -gprune-btf -gno-prune-btf
546 -ggdb -grecord-gcc-switches -gno-record-gcc-switches
547 -gstrict-dwarf -gno-strict-dwarf
548 -gas-loc-support -gno-as-loc-support
549 -gas-locview-support -gno-as-locview-support
550 -gcodeview
551 -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64
552 -gstatement-frontiers -gno-statement-frontiers
553 -gvariable-location-views -gno-variable-location-views
554 -ginternal-reset-location-views -gno-internal-reset-location-views
555 -ginline-points -gno-inline-points
556 -gvms -gz@r{[}=@var{type}@r{]}
557 -gsplit-dwarf -gdescribe-dies -gno-describe-dies
558 -fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section
559 -fno-eliminate-unused-debug-types
560 -femit-struct-debug-baseonly -femit-struct-debug-reduced
561 -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
562 -fno-eliminate-unused-debug-symbols -femit-class-debug-always
563 -fno-merge-debug-strings -fno-dwarf2-cfi-asm
564 -fvar-tracking -fvar-tracking-assignments}
565
566 @item Optimization Options
567 @xref{Optimize Options,,Options that Control Optimization}.
568 @gccoptlist{-faggressive-loop-optimizations
569 -falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
570 -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
571 -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
572 -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
573 -fmin-function-alignment=[@var{n}]
574 -fno-allocation-dce -fallow-store-data-races
575 -fassociative-math -fauto-profile -fauto-profile[=@var{path}]
576 -fauto-profile-inlining -fauto-inc-dec -fbranch-probabilities
577 -fcaller-saves
578 -fcombine-stack-adjustments -fconserve-stack
579 -ffold-mem-offsets
580 -fcompare-elim -fcprop-registers -fcrossjumping
581 -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules
582 -fcx-limited-range -fcx-method
583 -fdata-sections -fdce -fdelayed-branch
584 -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively
585 -fdevirtualize-at-ltrans -fdse
586 -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects
587 -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style}
588 -ffinite-loops
589 -fforward-propagate -ffp-contract=@var{style} -ffunction-sections
590 -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity
591 -fgcse-sm -fhoist-adjacent-loads -fif-conversion
592 -fif-conversion2 -findirect-inlining
593 -finline-stringops[=@var{fn}]
594 -finline-functions -finline-functions-called-once -finline-limit=@var{n}
595 -finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone
596 -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const
597 -fipa-reference -fipa-reference-addressable -fipa-reorder-for-locality
598 -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm}
599 -flate-combine-instructions -flifetime-dse -flive-patching=@var{level}
600 -fira-region=@var{region} -fira-hoist-pressure
601 -fira-loop-pressure -fno-ira-share-save-slots
602 -fno-ira-share-spill-slots
603 -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute
604 -fivopts -fkeep-inline-functions -fkeep-static-functions
605 -fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage
606 -floop-block -floop-interchange -floop-strip-mine
607 -floop-unroll-and-jam -floop-nest-optimize
608 -floop-parallelize-all -flra-remat -flto -flto-compression-level
609 -flto-partition=@var{alg} -flto-incremental=@var{path}
610 -flto-incremental-cache-size=@var{n} -fmalloc-dce -fmerge-all-constants
611 -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
612 -fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg
613 -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
614 -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole
615 -fno-peephole2 -fno-printf-return-value -fno-sched-interblock
616 -fno-sched-spec -fno-signed-zeros
617 -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
618 -fomit-frame-pointer -foptimize-crc -foptimize-sibling-calls
619 -fpartial-inlining -fpeel-loops -fpredictive-commoning
620 -fprefetch-loop-arrays
621 -fprofile-correction
622 -fprofile-use -fprofile-use=@var{path} -fprofile-partial-training
623 -fprofile-values -fprofile-reorder-functions
624 -freciprocal-math -free -frename-registers -freorder-blocks
625 -freorder-blocks-algorithm=@var{algorithm}
626 -freorder-blocks-and-partition -freorder-functions
627 -frerun-cse-after-loop -freschedule-modulo-scheduled-loops
628 -frounding-math -fsave-optimization-record
629 -fsched2-use-superblocks -fsched-pressure
630 -fsched-spec-load -fsched-spec-load-dangerous
631 -fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}]
632 -fsched-group-heuristic -fsched-critical-path-heuristic
633 -fsched-spec-insn-heuristic -fsched-rank-heuristic
634 -fsched-last-insn-heuristic -fsched-dep-count-heuristic
635 -fschedule-fusion
636 -fschedule-insns -fschedule-insns2 -fsection-anchors
637 -fselective-scheduling -fselective-scheduling2
638 -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
639 -fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate
640 -fsignaling-nans
641 -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops
642 -fsplit-paths
643 -fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt
644 -fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing
645 -fthread-jumps -ftracer -ftree-bit-ccp
646 -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-coalesce-vars
647 -ftree-copy-prop -ftree-cselim -ftree-dce -ftree-dominator-opts
648 -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting
649 -ftree-loop-if-convert -ftree-loop-im
650 -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns
651 -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
652 -ftree-loop-vectorize
653 -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta
654 -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra
655 -ftree-switch-conversion -ftree-tail-merge
656 -ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init
657 -funconstrained-commons -funit-at-a-time -funroll-all-loops
658 -funroll-loops -funsafe-math-optimizations -funswitch-loops
659 -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt
660 -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs
661 --param @var{name}=@var{value}
662 -O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
663
664 @item Program Instrumentation Options
665 @xref{Instrumentation Options,,Program Instrumentation Options}.
666 @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage
667 -fcondition-coverage
668 -fpath-coverage
669 -fprofile-abs-path
670 -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path}
671 -fprofile-info-section -fprofile-info-section=@var{name}
672 -fprofile-note=@var{path} -fprofile-prefix-path=@var{path}
673 -fprofile-update=@var{method} -fprofile-filter-files=@var{regex}
674 -fprofile-exclude-files=@var{regex}
675 -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
676 -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style}
677 -fsanitize-trap -fsanitize-trap=@var{style}
678 -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},...
679 -fsanitize-undefined-trap-on-error -fbounds-check -fcf-protection
680 -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
681 -fharden-compares -fharden-conditional-branches -fhardened
682 -fharden-control-flow-redundancy -fhardcfr-skip-leaf
683 -fhardcfr-check-exceptions -fhardcfr-check-returning-calls
684 -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
685 -fstack-protector -fstack-protector-all -fstack-protector-strong
686 -fstack-protector-explicit -fstack-check
687 -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym}
688 -fno-stack-limit -fsplit-stack
689 -fstrub=disable -fstrub=strict -fstrub=relaxed
690 -fstrub=all -fstrub=at-calls -fstrub=internal
691 -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
692 -fvtv-counts -fvtv-debug
693 -finstrument-functions -finstrument-functions-once
694 -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
695 -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
696 -fprofile-prefix-map=@var{old}=@var{new}
697 -fpatchable-function-entry=@var{N}@r{[},@var{M}@r{]}}
698
699 @item Preprocessor Options
700 @xref{Preprocessor Options,,Options Controlling the Preprocessor}.
701 @gccoptlist{-A@var{question}=@var{answer}
702 -A-@var{question}@r{[}=@var{answer}@r{]}
703 -C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
704 -dD -dI -dM -dN -dU
705 -fdebug-cpp -fdirectives-only -fdollars-in-identifiers
706 -fexec-charset=@var{charset} -fextended-identifiers
707 -finput-charset=@var{charset}
708 -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth}
709 -fno-canonical-system-headers -fpch-deps -fpch-preprocess
710 -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion
711 -fwide-exec-charset=@var{charset} -fworking-directory
712 -H -imacros @var{file} -include @var{file}
713 -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules
714 -no-integrated-cpp -P -pthread -remap
715 -traditional -traditional-cpp -trigraphs
716 -U@var{macro} -undef
717 -Wp,@var{option} -Xpreprocessor @var{option}}
718
719 @item Assembler Options
720 @xref{Assembler Options,,Passing Options to the Assembler}.
721 @gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
722
723 @item Linker Options
724 @xref{Link Options,,Options for Linking}.
725 @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library}
726 -nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++
727 -e @var{entry} --entry=@var{entry}
728 -pie -pthread -r -rdynamic
729 -s -static -static-pie -static-libgcc -static-libstdc++
730 -static-libasan -static-libtsan -static-liblsan -static-libubsan
731 -shared -shared-libgcc -symbolic
732 -T @var{script} -Wl,@var{option} -Xlinker @var{option}
733 -u @var{symbol} -z @var{keyword}}
734
735 @item Directory Options
736 @xref{Directory Options,,Options for Directory Search}.
737 @gccoptlist{-B@var{prefix} -I@var{dir} -I-
738 -idirafter @var{dir}
739 -imacros @var{file} -imultilib @var{dir}
740 -iplugindir=@var{dir} -iprefix @var{file}
741 -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir}
742 -iwithprefix @var{dir} -iwithprefixbefore @var{dir}
743 --embed-dir=@var{dir}
744 -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix
745 -nostdinc -nostdinc++ --sysroot=@var{dir}}
746
747 @item Code Generation Options
748 @xref{Code Gen Options,,Options for Code Generation Conventions}.
749 @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg}
750 -ffixed-@var{reg} -fexceptions
751 -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
752 -fasynchronous-unwind-tables
753 -fno-gnu-unique
754 -finhibit-size-directive -fcommon -fno-ident
755 -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt
756 -fno-jump-tables -fno-bit-tests
757 -frecord-gcc-switches
758 -freg-struct-return -fshort-enums -fshort-wchar
759 -fverbose-asm -fpack-struct[=@var{n}]
760 -fleading-underscore -ftls-model=@var{model}
761 -fstack-reuse=@var{reuse_level}
762 -ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
763 -ftrapv -fwrapv
764 -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
765 -fstrict-volatile-bitfields -fsync-libcalls
766 -fzero-init-padding-bits=@var{value}}
767
768 @item Developer Options
769 @xref{Developer Options,,GCC Developer Options}.
770 @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion
771 -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
772 -fchecking -fchecking=@var{n}
773 -fdbg-cnt-list -fdbg-cnt=@var{counter-value-list}
774 -fdisable-ipa-@var{pass_name}
775 -fdisable-rtl-@var{pass_name}
776 -fdisable-rtl-@var{pass-name}=@var{range-list}
777 -fdisable-tree-@var{pass_name}
778 -fdisable-tree-@var{pass-name}=@var{range-list}
779 -fdump-debug -fdump-earlydebug
780 -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links
781 -fdump-final-insns@r{[}=@var{file}@r{]}
782 -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
783 -fdump-lang-all
784 -fdump-lang-@var{switch}
785 -fdump-lang-@var{switch}-@var{options}
786 -fdump-lang-@var{switch}-@var{options}=@var{filename}
787 -fdump-passes
788 -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename}
789 -fdump-statistics
790 -fdump-tree-all
791 -fdump-tree-@var{switch}
792 -fdump-tree-@var{switch}-@var{options}
793 -fdump-tree-@var{switch}-@var{options}=@var{filename}
794 -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second
795 -fenable-@var{kind}-@var{pass}
796 -fenable-@var{kind}-@var{pass}=@var{range-list}
797 -fira-verbose=@var{n}
798 -flto-report -flto-report-wpa -fmem-report-wpa
799 -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report
800 -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]}
801 -fmultiflags -fprofile-report
802 -frandom-seed=@var{string} -fsched-verbose=@var{n}
803 -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
804 -fstats -fstack-usage -ftime-report -ftime-report-details
805 -fvar-tracking-assignments-toggle -gtoggle
806 -print-file-name=@var{library} -print-libgcc-file-name
807 -print-multi-directory -print-multi-lib -print-multi-os-directory
808 -print-prog-name=@var{program} -print-search-dirs -Q
809 -print-sysroot -print-sysroot-headers-suffix
810 -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
811
812 @item Machine-Dependent Options
813 @xref{Submodel Options,,Machine-Dependent Options}.
814 @c This list is ordered alphanumerically by subsection name.
815 @c Try and put the significant identifier (CPU or system) first,
816 @c so users have a clue at guessing where the ones they want will be.
817
818 @emph{AArch64 Options} (@ref{AArch64 Options})
819 @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian
820 -mgeneral-regs-only
821 -mcmodel=tiny -mcmodel=small -mcmodel=large
822 -mstrict-align -mno-strict-align
823 -momit-leaf-frame-pointer
824 -mtls-dialect=desc -mtls-dialect=traditional
825 -mtls-size=@var{size}
826 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419
827 -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div
828 -mpc-relative-literal-loads
829 -msign-return-address=@var{scope}
830 -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
831 +@var{b-key}]|@var{bti}|@var{gcs}
832 -mharden-sls=@var{opts}
833 -march=@var{name} -mcpu=@var{name} -mtune=@var{name}
834 -moverride=@var{string} -mverbose-cost-dump
835 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg}
836 -mstack-protector-guard-offset=@var{offset} -mtrack-speculation
837 -moutline-atomics -mearly-ldp-fusion -mlate-ldp-fusion
838 -Wexperimental-fmv-target}
839
840 @emph{Adapteva Epiphany Options} (@ref{Adapteva Epiphany Options})
841 @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs
842 -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf
843 -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num}
844 -mround-nearest -mlong-calls -mshort-calls -msmall16
845 -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num}
846 -msplit-vecmove-early -m1reg-@var{reg}}
847
848 @emph{AMD GCN Options} (@ref{AMD GCN Options})
849 @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
850
851 @emph{ARC Options} (@ref{ARC Options})
852 @gccoptlist{-mbarrel-shifter -mjli-always
853 -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700
854 -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr
855 -mea -mno-mpy -mmul32x16 -mmul64 -matomic
856 -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap
857 -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape
858 -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof
859 -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved
860 -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num}
861 -mvolatile-cache -mtp-regno=@var{regno}
862 -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc
863 -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi
864 -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none
865 -mlra-priority-compact -mlra-priority-noncompact -mmillicode
866 -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level}
867 -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame
868 -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo}
869 -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
870
871 @emph{ARM Options} (@ref{ARM Options})
872 @gccoptlist{-mapcs-frame -mno-apcs-frame
873 -mabi=@var{name}
874 -mapcs-stack-check -mno-apcs-stack-check
875 -mapcs-reentrant -mno-apcs-reentrant
876 -mgeneral-regs-only
877 -msched-prolog -mno-sched-prolog
878 -mlittle-endian -mbig-endian
879 -mbe8 -mbe32
880 -mfloat-abi=@var{name}
881 -mfp16-format=@var{name}
882 -mthumb-interwork -mno-thumb-interwork
883 -mcpu=@var{name} -march=@var{name} -mfpu=@var{name}
884 -mtune=@var{name} -mprint-tune-info
885 -mstructure-size-boundary=@var{n}
886 -mabort-on-noreturn
887 -mlong-calls -mno-long-calls
888 -msingle-pic-base -mno-single-pic-base
889 -mpic-register=@var{reg}
890 -mnop-fun-dllimport
891 -mpoke-function-name
892 -mthumb -marm -mflip-thumb
893 -mtpcs-frame -mtpcs-leaf-frame
894 -mcaller-super-interworking -mcallee-super-interworking
895 -mtp=@var{name} -mtls-dialect=@var{dialect}
896 -mword-relocations
897 -mfix-cortex-m3-ldrd
898 -mfix-cortex-a57-aes-1742098
899 -mfix-cortex-a72-aes-1655431
900 -munaligned-access
901 -mneon-for-64bits
902 -mslow-flash-data
903 -masm-syntax-unified
904 -mrestrict-it
905 -mverbose-cost-dump
906 -mpure-code
907 -mcmse
908 -mfix-cmse-cve-2021-35465
909 -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset}
910 -mfdpic
911 -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
912 [+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
913
914 @emph{AVR Options} (@ref{AVR Options})
915 @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args -mcvt
916 -mbranch-cost=@var{cost} -mfuse-add=@var{level} -mfuse-move=@var{level}
917 -mcall-prologues -mgas-isr-prologues -mint8 -mflmap
918 -mdouble=@var{bits} -mlong-double=@var{bits} -mno-call-main
919 -mn_flash=@var{size} -mfract-convert-truncate -mno-interrupts
920 -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack
921 -mrodata-in-ram -msplit-bit-shift -msplit-ldst -mshort-calls
922 -mskip-bug -muse-nonzero-bits -nodevicelib -nodevicespecs
923 -Waddr-space-convert -Wmisspelled-isr}
924
925 @emph{Blackfin Options} (@ref{Blackfin Options})
926 @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
927 -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer
928 -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly
929 -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
930 -mno-id-shared-library -mshared-library-id=@var{n}
931 -mleaf-id-shared-library -mno-leaf-id-shared-library
932 -msep-data -mno-sep-data -mlong-calls -mno-long-calls
933 -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram
934 -micplb}
935
936 @emph{C6X Options} (@ref{C6X Options})
937 @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu}
938 -msim -msdata=@var{sdata-type}}
939
940 @emph{CRIS Options} (@ref{CRIS Options})
941 @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
942 -mtune=@var{cpu} -mmax-stack-frame=@var{n}
943 -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects
944 -mstack-align -mdata-align -mconst-align
945 -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
946 -melf -maout -sim -sim2
947 -mmul-bug-workaround -mno-mul-bug-workaround}
948
949 @emph{C-SKY Options} (@ref{C-SKY Options})
950 @gccoptlist{-march=@var{arch} -mcpu=@var{cpu}
951 -mbig-endian -EB -mlittle-endian -EL
952 -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu
953 -mfloat-abi=@var{name}
954 -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust
955 -mdsp -medsp -mvdsp
956 -mdiv -msmart -mhigh-registers -manchor
957 -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt
958 -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
959
960 @emph{Cygwin and MinGW Options} (@ref{Cygwin and MinGW Options})
961 @gccoptlist{-mconsole -mcrtdll=@var{library} -mdll
962 -mnop-fun-dllimport -mthread
963 -municode -mwin32 -mwindows -fno-set-stack-executable}
964
965 @emph{Darwin Options} (@ref{Darwin Options})
966 @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal
967 -arch_only -bind_at_load -bundle -bundle_loader
968 -client_name -compatibility_version -current_version
969 -dead_strip
970 -dependency-file -dylib_file -dylinker_install_name
971 -dynamic -dynamiclib -exported_symbols_list
972 -filelist -flat_namespace -force_cpusubtype_ALL
973 -force_flat_namespace -headerpad_max_install_names
974 -iframework
975 -image_base -init -install_name -keep_private_externs
976 -multi_module -multiply_defined -multiply_defined_unused
977 -noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths
978 -nofixprebinding -nomultidefs -noprebind -noseglinkedit
979 -pagezero_size -prebind -prebind_all_twolevel_modules
980 -private_bundle -read_only_relocs -sectalign
981 -sectobjectsymbols -whyload -seg1addr
982 -sectcreate -sectobjectsymbols -sectorder
983 -segaddr -segs_read_only_addr -segs_read_write_addr
984 -seg_addr_table -seg_addr_table_filename -seglinkedit
985 -segprot -segs_read_only_addr -segs_read_write_addr
986 -single_module -static -sub_library -sub_umbrella
987 -twolevel_namespace -umbrella -undefined
988 -unexported_symbols_list -weak_reference_mismatches
989 -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version}
990 -mkernel -mone-byte-bool}
991
992 @emph{DEC Alpha Options} (@ref{DEC Alpha Options})
993 @gccoptlist{-mno-fp-regs -msoft-float
994 -mieee -mieee-with-inexact -mieee-conformant
995 -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
996 -mtrap-precision=@var{mode} -mbuild-constants
997 -mcpu=@var{cpu-type} -mtune=@var{cpu-type}
998 -mbwx -mmax -mfix -mcix
999 -msafe-bwa -msafe-partial
1000 -mfloat-vax -mfloat-ieee
1001 -mexplicit-relocs -msmall-data -mlarge-data
1002 -msmall-text -mlarge-text
1003 -mmemory-latency=@var{time}}
1004
1005 @emph{eBPF Options} (@ref{eBPF Options})
1006 @gccoptlist{-mbig-endian -mlittle-endian
1007 -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext
1008 -mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version}
1009 -masm=@var{dialect} -minline-memops-threshold=@var{bytes}}
1010
1011 @emph{FR30 Options} (@ref{FR30 Options})
1012 @gccoptlist{-msmall-model -mno-lsim}
1013
1014 @emph{FT32 Options} (@ref{FT32 Options})
1015 @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
1016
1017 @emph{FRV Options} (@ref{FRV Options})
1018 @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64
1019 -mhard-float -msoft-float
1020 -malloc-cc -mfixed-cc -mdword -mno-dword
1021 -mdouble -mno-double
1022 -mmedia -mno-media -mmuladd -mno-muladd
1023 -mfdpic -minline-plt -mgprel-ro -multilib-library-pic
1024 -mlinked-fp -mlong-calls -malign-labels
1025 -mlibrary-pic -macc-4 -macc-8
1026 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move
1027 -moptimize-membar -mno-optimize-membar
1028 -mscc -mno-scc -mcond-exec -mno-cond-exec
1029 -mvliw-branch -mno-vliw-branch
1030 -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec
1031 -mno-nested-cond-exec -mtomcat-stats
1032 -mTLS -mtls
1033 -mcpu=@var{cpu}}
1034
1035 @emph{GNU/Linux Options} (@ref{GNU/Linux Options})
1036 @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid
1037 -tno-android-cc -tno-android-ld}
1038
1039 @emph{H8/300 Options} (@ref{H8/300 Options})
1040 @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
1041
1042 @emph{HPPA Options} (@ref{HPPA Options})
1043 @gccoptlist{-march=@var{architecture-type}
1044 -matomic-libcalls -mbig-switch
1045 -mcaller-copies -mdisable-fpregs -mdisable-indexing
1046 -mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld
1047 -mfixed-range=@var{register-range}
1048 -mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls
1049 -mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs
1050 -mno-disable-indexing -mno-fast-indirect-calls -mno-gas
1051 -mno-jump-in-delay -mno-long-load-store
1052 -mno-portable-runtime -mno-soft-float
1053 -mno-space-regs -msoft-float -mpa-risc-1-0
1054 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime
1055 -mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio
1056 -munix=@var{unix-std} -nolibdld -static -threads}
1057
1058 @emph{IA-64 Options} (@ref{IA-64 Options})
1059 @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic
1060 -mvolatile-asm-stop -mregister-names -msdata -mno-sdata
1061 -mconstant-gp -mauto-pic -mfused-madd
1062 -minline-float-divide-min-latency
1063 -minline-float-divide-max-throughput
1064 -mno-inline-float-divide
1065 -minline-int-divide-min-latency
1066 -minline-int-divide-max-throughput
1067 -mno-inline-int-divide
1068 -minline-sqrt-min-latency -minline-sqrt-max-throughput
1069 -mno-inline-sqrt
1070 -mdwarf2-asm -mearly-stop-bits
1071 -mfixed-range=@var{register-range} -mtls-size=@var{tls-size}
1072 -mtune=@var{cpu-type} -milp32 -mlp64
1073 -msched-br-data-spec -msched-ar-data-spec -msched-control-spec
1074 -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec
1075 -msched-spec-ldc -msched-spec-control-ldc
1076 -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns
1077 -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path
1078 -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
1079 -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1080
1081 @emph{LM32 Options} (@ref{LM32 Options})
1082 @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled
1083 -msign-extend-enabled -muser-enabled}
1084
1085 @emph{LoongArch Options} (@ref{LoongArch Options})
1086 @gccoptlist{-march=@var{arch-type} -mtune=@var{tune-type} -mabi=@var{base-abi-type}
1087 -mfpu=@var{fpu-type} -msimd=@var{simd-type}
1088 -msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx
1089 -mbranch-cost=@var{n} -maddr-reg-reg-cost=@var{n} -mcheck-zero-division
1090 -mno-check-zero-division
1091 -mcond-move-int -mno-cond-move-int
1092 -mcond-move-float -mno-cond-move-float
1093 -memcpy -mno-memcpy -mstrict-align -mno-strict-align -G @var{num}
1094 -mmax-inline-memcpy-size=@var{n}
1095 -mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs
1096 -mdirect-extern-access -mno-direct-extern-access
1097 -mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as
1098 -mrecip -mrecip=@var{opt} -mfrecipe -mno-frecipe -mdiv32 -mno-div32
1099 -mlam-bh -mno-lam-bh -mlamcas -mno-lamcas -mld-seq-sa -mno-ld-seq-sa
1100 -mtls-dialect=@var{opt} -mannotate-tablejump -mno-annotate-tablejump}
1101
1102 @emph{M32C Options} (@ref{M32C Options})
1103 @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1104
1105 @emph{M32R/D Options} (@ref{M32R/D Options})
1106 @gccoptlist{-m32r2 -m32rx -m32r
1107 -mdebug
1108 -malign-loops -mno-align-loops
1109 -missue-rate=@var{number}
1110 -mbranch-cost=@var{number}
1111 -mmodel=@var{code-size-model-type}
1112 -msdata=@var{sdata-type}
1113 -mno-flush-func -mflush-func=@var{name}
1114 -mno-flush-trap -mflush-trap=@var{number}
1115 -G @var{num}}
1116
1117 @emph{M680x0 Options} (@ref{M680x0 Options})
1118 @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune}
1119 -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
1120 -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407
1121 -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020
1122 -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort
1123 -mno-short -mhard-float -m68881 -msoft-float -mpcrel
1124 -malign-int -mstrict-align -msep-data -mno-sep-data
1125 -mshared-library-id=n -mid-shared-library -mno-id-shared-library
1126 -mxgot -mno-xgot -mlong-jump-table-offsets}
1127
1128 @emph{MCore Options} (@ref{MCore Options})
1129 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates
1130 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields
1131 -m4byte-functions -mno-4byte-functions -mcallgraph-data
1132 -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim
1133 -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1134
1135 @emph{MicroBlaze Options} (@ref{MicroBlaze Options})
1136 @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu}
1137 -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift
1138 -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss
1139 -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt
1140 -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model}
1141 -mpic-data-is-text-relative}
1142
1143 @emph{MIPS Options} (@ref{MIPS Options})
1144 @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch}
1145 -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
1146 -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6
1147 -mips16 -mno-mips16 -mflip-mips16
1148 -minterlink-compressed -mno-interlink-compressed
1149 -minterlink-mips16 -mno-interlink-mips16
1150 -mabi=@var{abi} -mabicalls -mno-abicalls
1151 -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot
1152 -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float
1153 -mno-float -msingle-float -mdouble-float
1154 -modd-spreg -mno-odd-spreg
1155 -mabs=@var{mode} -mnan=@var{encoding}
1156 -mdsp -mno-dsp -mdspr2 -mno-dspr2
1157 -mmcu -mmno-mcu
1158 -meva -mno-eva
1159 -mvirt -mno-virt
1160 -mxpa -mno-xpa
1161 -mcrc -mno-crc
1162 -mginv -mno-ginv
1163 -mmicromips -mno-micromips
1164 -mmsa -mno-msa
1165 -mloongson-mmi -mno-loongson-mmi
1166 -mloongson-ext -mno-loongson-ext
1167 -mloongson-ext2 -mno-loongson-ext2
1168 -mfpu=@var{fpu-type}
1169 -msmartmips -mno-smartmips
1170 -mpaired-single -mno-paired-single -mdmx -mno-mdmx
1171 -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc
1172 -mlong64 -mlong32 -msym32 -mno-sym32
1173 -G@var{num} -mlocal-sdata -mno-local-sdata
1174 -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt
1175 -membedded-data -mno-embedded-data
1176 -muninit-const-in-rodata -mno-uninit-const-in-rodata
1177 -mcode-readable=@var{setting}
1178 -msplit-addresses -mno-split-addresses
1179 -mexplicit-relocs -mno-explicit-relocs
1180 -mexplicit-relocs=@var{release}
1181 -mcheck-zero-division -mno-check-zero-division
1182 -mdivide-traps -mdivide-breaks
1183 -mload-store-pairs -mno-load-store-pairs
1184 -mstrict-align -mno-strict-align
1185 -mno-unaligned-access -munaligned-access
1186 -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls
1187 -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp
1188 -mfix-24k -mno-fix-24k
1189 -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400
1190 -mfix-r5900 -mno-fix-r5900
1191 -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000
1192 -mfix-vr4120 -mno-fix-vr4120
1193 -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1
1194 -mflush-func=@var{func} -mno-flush-func
1195 -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely
1196 -mcompact-branches=@var{policy}
1197 -mfp-exceptions -mno-fp-exceptions
1198 -mvr4130-align -mno-vr4130-align -msynci -mno-synci
1199 -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4
1200 -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
1201 -mframe-header-opt -mno-frame-header-opt}
1202
1203 @emph{MMIX Options} (@ref{MMIX Options})
1204 @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu
1205 -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols
1206 -melf -mbranch-predict -mno-branch-predict -mbase-addresses
1207 -mno-base-addresses -msingle-exit -mno-single-exit}
1208
1209 @emph{MN10300 Options} (@ref{MN10300 Options})
1210 @gccoptlist{-mmult-bug -mno-mult-bug
1211 -mno-am33 -mam33 -mam33-2 -mam34
1212 -mtune=@var{cpu-type}
1213 -mreturn-pointer-on-d0
1214 -mno-crt0 -mrelax -mliw -msetlb}
1215
1216 @emph{Moxie Options} (@ref{Moxie Options})
1217 @gccoptlist{-meb -mel -mmul.x -mno-crt0}
1218
1219 @emph{MSP430 Options} (@ref{MSP430 Options})
1220 @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax
1221 -mwarn-mcu
1222 -mcode-region= -mdata-region=
1223 -msilicon-errata= -msilicon-errata-warn=
1224 -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1225
1226 @emph{NDS32 Options} (@ref{NDS32 Options})
1227 @gccoptlist{-mbig-endian -mlittle-endian
1228 -mreduced-regs -mfull-regs
1229 -mcmov -mno-cmov
1230 -mext-perf -mno-ext-perf
1231 -mext-perf2 -mno-ext-perf2
1232 -mext-string -mno-ext-string
1233 -mv3push -mno-v3push
1234 -m16bit -mno-16bit
1235 -misr-vector-size=@var{num}
1236 -mcache-block-size=@var{num}
1237 -march=@var{arch}
1238 -mcmodel=@var{code-model}
1239 -mctor-dtor -mrelax}
1240
1241 @emph{Nvidia PTX Options} (@ref{Nvidia PTX Options})
1242 @gccoptlist{-m64 -mmainkernel -moptimize}
1243
1244 @emph{OpenRISC Options} (@ref{OpenRISC Options})
1245 @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div
1246 -msoft-mul -msoft-div
1247 -msoft-float -mhard-float -mdouble-float -munordered-float
1248 -mcmov -mror -mrori -msext -msfimm -mshftimm
1249 -mcmodel=@var{code-model}}
1250
1251 @emph{PDP-11 Options} (@ref{PDP-11 Options})
1252 @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10
1253 -mint32 -mno-int16 -mint16 -mno-int32
1254 -msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1255
1256 @emph{PowerPC Options}
1257 See RS/6000 and PowerPC Options.
1258
1259 @emph{PRU Options} (@ref{PRU Options})
1260 @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop
1261 -mabi=@var{variant}}
1262
1263 @emph{RISC-V Options} (@ref{RISC-V Options})
1264 @gccoptlist{-mbranch-cost=@var{N-instruction}
1265 -mplt -mno-plt
1266 -mabi=@var{ABI-string}
1267 -mfdiv -mno-fdiv
1268 -mfence-tso -mno-fence-tso
1269 -mdiv -mno-div
1270 -misa-spec=@var{ISA-spec-string}
1271 -march=@var{ISA-string|Profiles|Profiles_ISA-string|CPU/processor string}
1272 -mtune=@var{processor-string}
1273 -mpreferred-stack-boundary=@var{num}
1274 -msmall-data-limit=@var{N-bytes}
1275 -msave-restore -mno-save-restore
1276 -mshorten-memrefs -mno-shorten-memrefs
1277 -mstrict-align -mno-strict-align
1278 -mcmodel=medlow -mcmodel=medany -mcmodel=large
1279 -mexplicit-relocs -mno-explicit-relocs
1280 -mrelax -mno-relax
1281 -mriscv-attribute -mno-riscv-attribute
1282 -malign-data=@var{type}
1283 -mbig-endian -mlittle-endian
1284 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1285 -mstack-protector-guard-offset=@var{offset}
1286 -mcsr-check -mno-csr-check
1287 -mmovcc -mno-movcc
1288 -minline-atomics -mno-inline-atomics
1289 -minline-strlen -mno-inline-strlen
1290 -minline-strcmp -mno-inline-strcmp
1291 -minline-strncmp -mno-inline-strncmp
1292 -mtls-dialect=desc -mtls-dialect=trad}
1293
1294 @emph{RL78 Options} (@ref{RL78 Options})
1295 @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs
1296 -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
1297 -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1298
1299 @emph{RS/6000 and PowerPC Options} (@ref{RS/6000 and PowerPC Options})
1300 @gccoptlist{-mcpu=@var{cpu-type}
1301 -mtune=@var{cpu-type}
1302 -mcmodel=@var{code-model}
1303 -mpowerpc64
1304 -maltivec -mno-altivec
1305 -mpowerpc-gpopt -mno-powerpc-gpopt
1306 -mpowerpc-gfxopt -mno-powerpc-gfxopt
1307 -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd
1308 -mfprnd -mno-fprnd
1309 -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp
1310 -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc
1311 -m64 -m32 -mxl-compat -mno-xl-compat -mpe
1312 -malign-power -malign-natural
1313 -msoft-float -mhard-float -mmultiple -mno-multiple
1314 -mupdate -mno-update
1315 -mavoid-indexed-addresses -mno-avoid-indexed-addresses
1316 -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
1317 -mstrict-align -mno-strict-align -mrelocatable
1318 -mno-relocatable -mrelocatable-lib -mno-relocatable-lib
1319 -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
1320 -mdynamic-no-pic -mswdiv -msingle-pic-base
1321 -mprioritize-restricted-insns=@var{priority}
1322 -msched-costly-dep=@var{dependence_type}
1323 -minsert-sched-nops=@var{scheme}
1324 -mcall-aixdesc -mcall-eabi -mcall-freebsd
1325 -mcall-linux -mcall-netbsd -mcall-openbsd
1326 -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi
1327 -mtraceback=@var{traceback_type}
1328 -maix-struct-return -msvr4-struct-return
1329 -mabi=@var{abi-type} -msecure-plt -mbss-plt
1330 -msplit-patch-nops
1331 -mlongcall -mno-longcall -mpltseq -mno-pltseq
1332 -mblock-move-inline-limit=@var{num}
1333 -mblock-compare-inline-limit=@var{num}
1334 -mblock-compare-inline-loop-limit=@var{num}
1335 -mno-block-ops-unaligned-vsx
1336 -mstring-compare-inline-limit=@var{num}
1337 -misel -mno-isel
1338 -mvrsave -mno-vrsave
1339 -mmulhw -mno-mulhw
1340 -mdlmzb -mno-dlmzb
1341 -mprototype -mno-prototype
1342 -msim -mmvme -mads -myellowknife -memb -msdata
1343 -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num}
1344 -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision
1345 -mno-recip-precision
1346 -mveclibabi=@var{type} -mfriz -mno-friz
1347 -mpointers-to-nested-functions -mno-pointers-to-nested-functions
1348 -msave-toc-indirect -mno-save-toc-indirect
1349 -mpower8-fusion -mno-mpower8-fusion
1350 -mcrypto -mno-crypto -mhtm -mno-htm
1351 -mquad-memory -mno-quad-memory
1352 -mquad-memory-atomic -mno-quad-memory-atomic
1353 -mcompat-align-parm -mno-compat-align-parm
1354 -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware
1355 -mgnu-attribute -mno-gnu-attribute
1356 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1357 -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed
1358 -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect
1359 -mprivileged -mno-privileged}
1360
1361 @emph{RX Options} (@ref{RX Options})
1362 @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu
1363 -mcpu=
1364 -mbig-endian-data -mlittle-endian-data
1365 -msmall-data
1366 -msim -mno-sim
1367 -mas100-syntax -mno-as100-syntax
1368 -mrelax
1369 -mmax-constant-size=
1370 -mint-register=
1371 -mpid
1372 -mallow-string-insns -mno-allow-string-insns
1373 -mjsr
1374 -mno-warn-multiple-fast-interrupts
1375 -msave-acc-in-interrupts}
1376
1377 @emph{S/390 and zSeries Options} (@ref{S/390 and zSeries Options})
1378 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1379 -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp
1380 -mlong-double-64 -mlong-double-128
1381 -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack
1382 -msmall-exec -mno-small-exec -mmvcle -mno-mvcle
1383 -m64 -m31 -mdebug -mno-debug -mesa -mzarch
1384 -mhtm -mvx -mzvector
1385 -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip
1386 -mfused-madd -mno-fused-madd
1387 -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard
1388 -mhotpatch=@var{halfwords},@var{halfwords}}
1389
1390 @emph{SH Options} (@ref{SH Options})
1391 @gccoptlist{-m1 -m2 -m2e
1392 -m2a-nofpu -m2a-single-only -m2a-single -m2a
1393 -m3 -m3e
1394 -m4-nofpu -m4-single-only -m4-single -m4
1395 -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al
1396 -mb -ml -mdalign -mrelax
1397 -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave
1398 -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct
1399 -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy}
1400 -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range}
1401 -maccumulate-outgoing-args
1402 -matomic-model=@var{atomic-model}
1403 -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch
1404 -mcbranch-force-delay-slot
1405 -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra
1406 -mpretend-cmove -mtas}
1407
1408 @emph{Solaris 2 Options} (@ref{Solaris 2 Options})
1409 @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text
1410 -pthreads}
1411
1412 @emph{SPARC Options} (@ref{SPARC Options})
1413 @gccoptlist{-mcpu=@var{cpu-type}
1414 -mtune=@var{cpu-type}
1415 -mcmodel=@var{code-model}
1416 -mmemory-model=@var{mem-model}
1417 -m32 -m64 -mapp-regs -mno-app-regs
1418 -mfaster-structs -mno-faster-structs -mflat -mno-flat
1419 -mfpu -mno-fpu -mhard-float -msoft-float
1420 -mhard-quad-float -msoft-quad-float
1421 -mstack-bias -mno-stack-bias
1422 -mstd-struct-return -mno-std-struct-return
1423 -munaligned-doubles -mno-unaligned-doubles
1424 -muser-mode -mno-user-mode
1425 -mv8plus -mno-v8plus -mvis -mno-vis
1426 -mvis2 -mno-vis2
1427 -mvis3 -mno-vis3 -mvis3b -mno-vis3b
1428 -mvis4 -mno-vis4 -mvis4b -mno-vis4b
1429 -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld
1430 -mpopc -mno-popc -msubxc -mno-subxc
1431 -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc}
1432
1433 @emph{System V Options} (@ref{System V Options})
1434 @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1435
1436 @emph{V850 Options} (@ref{V850 Options})
1437 @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep
1438 -mprolog-function -mno-prolog-function -mspace
1439 -mtda=@var{n} -msda=@var{n} -mzda=@var{n}
1440 -mapp-regs -mno-app-regs
1441 -mdisable-callt -mno-disable-callt
1442 -mv850e2v3 -mv850e2 -mv850e1 -mv850es
1443 -mv850e -mv850 -mv850e3v5
1444 -mloop
1445 -mrelax
1446 -mlong-jumps
1447 -msoft-float
1448 -mhard-float
1449 -mgcc-abi
1450 -mrh850-abi
1451 -mbig-switch}
1452
1453 @emph{VAX Options} (@ref{VAX Options})
1454 @gccoptlist{-munix -mgnu -md -md-float -mg -mg-float -mlra}
1455
1456 @emph{Visium Options} (@ref{Visium Options})
1457 @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float
1458 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1459
1460 @emph{VMS Options} (@ref{VMS Options})
1461 @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64
1462 -mpointer-size=@var{size}}
1463
1464 @emph{VxWorks Options} (@ref{VxWorks Options})
1465 @gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic
1466 -Xbind-lazy -Xbind-now}
1467
1468 @emph{x86 Options} (@ref{x86 Options})
1469 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1470 -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default
1471 -mfpmath=@var{unit}
1472 -masm=@var{dialect} -mno-fancy-math-387
1473 -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float
1474 -mno-wide-multiply -mrtd -malign-double
1475 -mpreferred-stack-boundary=@var{num}
1476 -mincoming-stack-boundary=@var{num}
1477 -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait
1478 -mrecip -mrecip=@var{opt}
1479 -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt}
1480 -mpartial-vector-fp-math
1481 -mmove-max=@var{bits} -mstore-max=@var{bits}
1482 -mnoreturn-no-callee-saved-registers
1483 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx
1484 -mavx2 -mavx512f -mavx512cd -mavx512vl
1485 -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
1486 -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd
1487 -mptwrite -mclflushopt -mclwb -mxsavec -mxsaves
1488 -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop
1489 -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp
1490 -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg
1491 -mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call
1492 -mavx512vbmi2 -mavx512bf16 -menqcmd
1493 -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
1494 -mavx512vnni -mprfchw -mrdpid
1495 -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk
1496 -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni -mamx-fp8
1497 -mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16
1498 -mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf
1499 -musermsr -mavx10.1 -mavx10.2 -mamx-avx512 -mamx-tf32 -mamx-transpose -mmovrs
1500 -mamx-movrs
1501 -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops
1502 -minline-stringops-dynamically -mstringop-strategy=@var{alg}
1503 -mkl -mwidekl
1504 -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy}
1505 -mpush-args -maccumulate-outgoing-args -m128bit-long-double
1506 -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128
1507 -mregparm=@var{num} -msseregparm
1508 -mveclibabi=@var{type} -mvect8-ret-in-mem
1509 -mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign
1510 -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
1511 -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode}
1512 -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num}
1513 -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv
1514 -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name}
1515 -mavx256-split-unaligned-load -mavx256-split-unaligned-store
1516 -malign-data=@var{type} -mstack-protector-guard=@var{guard}
1517 -mstack-protector-guard-reg=@var{reg}
1518 -mstack-protector-guard-offset=@var{offset}
1519 -mstack-protector-guard-symbol=@var{symbol}
1520 -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop
1521 -mindirect-branch=@var{choice} -mfunction-return=@var{choice}
1522 -mindirect-branch-register -mharden-sls=@var{choice}
1523 -mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access
1524 -munroll-only-small-loops -mlam=@var{choice}}
1525
1526 @emph{x86 Windows Options}
1527 See Cygwin and MinGW Options.
1528
1529 @emph{Xstormy16 Options} (@ref{Xstormy16 Options})
1530 @gccoptlist{-msim}
1531
1532 @emph{Xtensa Options} (@ref{Xtensa Options})
1533 @gccoptlist{-mconst16 -mno-const16
1534 -mfused-madd -mno-fused-madd
1535 -mforce-no-pic
1536 -mserialize-volatile -mno-serialize-volatile
1537 -mtext-section-literals -mno-text-section-literals
1538 -mauto-litpools -mno-auto-litpools
1539 -mtarget-align -mno-target-align
1540 -mlongcalls -mno-longcalls
1541 -mabi=@var{abi-type}
1542 -mextra-l32r-costs=@var{cycles}
1543 -mstrict-align -mno-strict-align}
1544
1545 @emph{zSeries Options}
1546 See S/390 and zSeries Options.
1547 @end table
1548
1549
1550 @node Overall Options
1551 @section Options Controlling the Kind of Output
1552
1553 Compilation can involve up to four stages: preprocessing, compilation
1554 proper, assembly and linking, always in that order. GCC is capable of
1555 preprocessing and compiling several files either into several
1556 assembler input files, or into one assembler input file; then each
1557 assembler input file produces an object file, and linking combines all
1558 the object files (those newly compiled, and those specified as input)
1559 into an executable file.
1560
1561 @cindex file name suffix
1562 For any given input file, the file name suffix determines what kind of
1563 compilation is done:
1564
1565 @table @gcctabopt
1566 @item @var{file}.c
1567 C source code that must be preprocessed.
1568
1569 @item @var{file}.i
1570 C source code that should not be preprocessed.
1571
1572 @item @var{file}.ii
1573 C++ source code that should not be preprocessed.
1574
1575 @item @var{file}.m
1576 Objective-C source code. Note that you must link with the @file{libobjc}
1577 library to make an Objective-C program work.
1578
1579 @item @var{file}.mi
1580 Objective-C source code that should not be preprocessed.
1581
1582 @item @var{file}.mm
1583 @itemx @var{file}.M
1584 Objective-C++ source code. Note that you must link with the @file{libobjc}
1585 library to make an Objective-C++ program work. Note that @samp{.M} refers
1586 to a literal capital M@.
1587
1588 @item @var{file}.mii
1589 Objective-C++ source code that should not be preprocessed.
1590
1591 @item @var{file}.h
1592 C, C++, Objective-C or Objective-C++ header file to be turned into a
1593 precompiled header (default), or C, C++ header file to be turned into an
1594 Ada spec (via the @option{-fdump-ada-spec} switch).
1595
1596 @item @var{file}.cc
1597 @itemx @var{file}.cp
1598 @itemx @var{file}.cxx
1599 @itemx @var{file}.cpp
1600 @itemx @var{file}.CPP
1601 @itemx @var{file}.c++
1602 @itemx @var{file}.C
1603 C++ source code that must be preprocessed. Note that in @samp{.cxx},
1604 the last two letters must both be literally @samp{x}. Likewise,
1605 @samp{.C} refers to a literal capital C@.
1606
1607 @item @var{file}.mm
1608 @itemx @var{file}.M
1609 Objective-C++ source code that must be preprocessed.
1610
1611 @item @var{file}.mii
1612 Objective-C++ source code that should not be preprocessed.
1613
1614 @item @var{file}.hh
1615 @itemx @var{file}.H
1616 @itemx @var{file}.hp
1617 @itemx @var{file}.hxx
1618 @itemx @var{file}.hpp
1619 @itemx @var{file}.HPP
1620 @itemx @var{file}.h++
1621 @itemx @var{file}.tcc
1622 C++ header file to be turned into a precompiled header or Ada spec.
1623
1624 @item @var{file}.f
1625 @itemx @var{file}.for
1626 @itemx @var{file}.ftn
1627 @itemx @var{file}.fi
1628 Fixed form Fortran source code that should not be preprocessed.
1629
1630 @item @var{file}.F
1631 @itemx @var{file}.FOR
1632 @itemx @var{file}.fpp
1633 @itemx @var{file}.FPP
1634 @itemx @var{file}.FTN
1635 Fixed form Fortran source code that must be preprocessed (with the traditional
1636 preprocessor).
1637
1638 @item @var{file}.f90
1639 @itemx @var{file}.f95
1640 @itemx @var{file}.f03
1641 @itemx @var{file}.f08
1642 @itemx @var{file}.fii
1643 Free form Fortran source code that should not be preprocessed.
1644
1645 @item @var{file}.F90
1646 @itemx @var{file}.F95
1647 @itemx @var{file}.F03
1648 @itemx @var{file}.F08
1649 Free form Fortran source code that must be preprocessed (with the
1650 traditional preprocessor).
1651
1652 @item @var{file}.cob
1653 @item @var{file}.COB
1654 @item @var{file}.cbl
1655 @item @var{file}.CBL
1656 COBOL source code.
1657
1658 @item @var{file}.go
1659 Go source code.
1660
1661 @item @var{file}.d
1662 D source code.
1663
1664 @item @var{file}.di
1665 D interface file.
1666
1667 @item @var{file}.dd
1668 D documentation code (Ddoc).
1669
1670 @item @var{file}.ads
1671 Ada source code file that contains a library unit declaration (a
1672 declaration of a package, subprogram, or generic, or a generic
1673 instantiation), or a library unit renaming declaration (a package,
1674 generic, or subprogram renaming declaration). Such files are also
1675 called @dfn{specs}.
1676
1677 @item @var{file}.adb
1678 Ada source code file containing a library unit body (a subprogram or
1679 package body). Such files are also called @dfn{bodies}.
1680
1681 @c GCC also knows about some suffixes for languages not yet included:
1682 @c Ratfor:
1683 @c @var{file}.r
1684
1685 @item @var{file}.s
1686 Assembler code.
1687
1688 @item @var{file}.S
1689 @itemx @var{file}.sx
1690 Assembler code that must be preprocessed.
1691
1692 @item @var{other}
1693 An object file to be fed straight into linking.
1694 Any file name with no recognized suffix is treated this way.
1695 @end table
1696
1697 @opindex x
1698 You can specify the input language explicitly with the @option{-x} option:
1699
1700 @table @gcctabopt
1701 @item -x @var{language}
1702 Specify explicitly the @var{language} for the following input files
1703 (rather than letting the compiler choose a default based on the file
1704 name suffix). This option applies to all following input files until
1705 the next @option{-x} option. Possible values for @var{language} are:
1706 @smallexample
1707 c c-header cpp-output
1708 c++ c++-header c++-system-header c++-user-header c++-cpp-output
1709 objective-c objective-c-header objective-c-cpp-output
1710 objective-c++ objective-c++-header objective-c++-cpp-output
1711 assembler assembler-with-cpp
1712 ada
1713 cobol
1714 d
1715 f77 f77-cpp-input f95 f95-cpp-input
1716 go
1717 @end smallexample
1718
1719 Note that @option{-x} does not imply a particular language standard.
1720 For example @option{-x f77} may also require @option{-std=legacy} for some older
1721 source codes.
1722
1723 @item -x none
1724 Turn off any specification of a language, so that subsequent files are
1725 handled according to their file name suffixes (as if @option{-x}
1726 has not been used at all).
1727 @end table
1728
1729 If you only want some of the stages of compilation, you can use
1730 @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1731 one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1732 @command{gcc} is to stop. Note that some combinations (for example,
1733 @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1734
1735 @table @gcctabopt
1736 @opindex c
1737 @item -c
1738 Compile or assemble the source files, but do not link. The linking
1739 stage simply is not done. The ultimate output is in the form of an
1740 object file for each source file.
1741
1742 By default, the object file name for a source file is made by replacing
1743 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1744
1745 Unrecognized input files, not requiring compilation or assembly, are
1746 ignored.
1747
1748 @opindex S
1749 @item -S
1750 Stop after the stage of compilation proper; do not assemble. The output
1751 is in the form of an assembler code file for each non-assembler input
1752 file specified.
1753
1754 By default, the assembler file name for a source file is made by
1755 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1756
1757 Input files that don't require compilation are ignored.
1758
1759 @opindex E
1760 @item -E
1761 Stop after the preprocessing stage; do not run the compiler proper. The
1762 output is in the form of preprocessed source code, which is sent to the
1763 standard output.
1764
1765 Input files that don't require preprocessing are ignored.
1766
1767 @cindex output file option
1768 @opindex o
1769 @item -o @var{file}
1770 Place the primary output in file @var{file}. This applies to whatever
1771 sort of output is being produced, whether it be an executable file, an
1772 object file, an assembler file or preprocessed C code.
1773
1774 If @option{-o} is not specified, the default is to put an executable
1775 file in @file{a.out}, the object file for
1776 @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1777 assembler file in @file{@var{source}.s}, a precompiled header file in
1778 @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1779 standard output.
1780
1781 Though @option{-o} names only the primary output, it also affects the
1782 naming of auxiliary and dump outputs. See the examples below. Unless
1783 overridden, both auxiliary outputs and dump outputs are placed in the
1784 same directory as the primary output. In auxiliary outputs, the suffix
1785 of the input file is replaced with that of the auxiliary output file
1786 type; in dump outputs, the suffix of the dump file is appended to the
1787 input file suffix. In compilation commands, the base name of both
1788 auxiliary and dump outputs is that of the primary output; in compile and
1789 link commands, the primary output name, minus the executable suffix, is
1790 combined with the input file name. If both share the same base name,
1791 disregarding the suffix, the result of the combination is that base
1792 name, otherwise, they are concatenated, separated by a dash.
1793
1794 @smallexample
1795 gcc -c foo.c ...
1796 @end smallexample
1797
1798 will use @file{foo.o} as the primary output, and place aux outputs and
1799 dumps next to it, e.g., aux file @file{foo.dwo} for
1800 @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1801 @option{-fdump-rtl-final}.
1802
1803 If a non-linker output file is explicitly specified, aux and dump files
1804 by default take the same base name:
1805
1806 @smallexample
1807 gcc -c foo.c -o dir/foobar.o ...
1808 @end smallexample
1809
1810 will name aux outputs @file{dir/foobar.*} and dump outputs
1811 @file{dir/foobar.c.*}.
1812
1813 A linker output will instead prefix aux and dump outputs:
1814
1815 @smallexample
1816 gcc foo.c bar.c -o dir/foobar ...
1817 @end smallexample
1818
1819 will generally name aux outputs @file{dir/foobar-foo.*} and
1820 @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1821 @file{dir/foobar-bar.c.*}.
1822
1823 The one exception to the above is when the executable shares the base
1824 name with the single input:
1825
1826 @smallexample
1827 gcc foo.c -o dir/foo ...
1828 @end smallexample
1829
1830 in which case aux outputs are named @file{dir/foo.*} and dump outputs
1831 named @file{dir/foo.c.*}.
1832
1833 The location and the names of auxiliary and dump outputs can be adjusted
1834 by the options @option{-dumpbase}, @option{-dumpbase-ext},
1835 @option{-dumpdir}, @option{-save-temps=cwd}, and
1836 @option{-save-temps=obj}.
1837
1838
1839 @opindex dumpbase
1840 @item -dumpbase @var{dumpbase}
1841 This option sets the base name for auxiliary and dump output files. It
1842 does not affect the name of the primary output file. Intermediate
1843 outputs, when preserved, are not regarded as primary outputs, but as
1844 auxiliary outputs:
1845
1846 @smallexample
1847 gcc -save-temps -S foo.c
1848 @end smallexample
1849
1850 saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1851 then compiles to the (implied) output file @file{foo.s}, whereas:
1852
1853 @smallexample
1854 gcc -save-temps -dumpbase save-foo -c foo.c
1855 @end smallexample
1856
1857 preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1858 an intermediate, thus auxiliary output), and then assembles to the
1859 (implied) output file @file{foo.o}.
1860
1861 Absent this option, dump and aux files take their names from the input
1862 file, or from the (non-linker) output file, if one is explicitly
1863 specified: dump output files (e.g. those requested by @option{-fdump-*}
1864 options) with the input name suffix, and aux output files (those
1865 requested by other non-dump options, e.g. @code{-save-temps},
1866 @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1867
1868 Similar suffix differentiation of dump and aux outputs can be attained
1869 for explicitly-given @option{-dumpbase basename.suf} by also specifying
1870 @option{-dumpbase-ext .suf}.
1871
1872 If @var{dumpbase} is explicitly specified with any directory component,
1873 any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1874 @option{-save-temps=*}) is ignored, and instead of appending to it,
1875 @var{dumpbase} fully overrides it:
1876
1877 @smallexample
1878 gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1879 -dumpdir pfx- -save-temps=cwd ...
1880 @end smallexample
1881
1882 creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1883 @file{dir/} in @option{-o}, the @file{./} prefix implied by
1884 @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1885
1886 When @option{-dumpbase} is specified in a command that compiles multiple
1887 inputs, or that compiles and then links, it may be combined with
1888 @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1889 file is compiled using the combined @var{dumppfx}, and default values
1890 for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1891 file:
1892
1893 @smallexample
1894 gcc foo.c bar.c -c -dumpbase main ...
1895 @end smallexample
1896
1897 creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1898 overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1899 as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1900 and @file{main-bar.*}.
1901
1902 An empty string specified as @var{dumpbase} avoids the influence of the
1903 output basename in the naming of auxiliary and dump outputs during
1904 compilation, computing default values :
1905
1906 @smallexample
1907 gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1908 @end smallexample
1909
1910 will name aux outputs @file{dir/foo.*} and dump outputs
1911 @file{dir/foo.c.*}. Note how their basenames are taken from the input
1912 name, but the directory still defaults to that of the output.
1913
1914 The empty-string dumpbase does not prevent the use of the output
1915 basename for outputs during linking:
1916
1917 @smallexample
1918 gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1919 @end smallexample
1920
1921 The compilation of the source files will name auxiliary outputs
1922 @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1923 @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1924 linking will use @file{dir/foobar.} as the prefix for dumps and
1925 auxiliary files.
1926
1927
1928 @opindex dumpbase-ext
1929 @item -dumpbase-ext @var{auxdropsuf}
1930 When forming the name of an auxiliary (but not a dump) output file, drop
1931 trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1932 suffixes. If not specified, this option defaults to the suffix of a
1933 default @var{dumpbase}, i.e., the suffix of the input file when
1934 @option{-dumpbase} is not present in the command line, or @var{dumpbase}
1935 is combined with @var{dumppfx}.
1936
1937 @smallexample
1938 gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1939 @end smallexample
1940
1941 creates @file{dir/foo.o} as the main output, and generates auxiliary
1942 outputs in @file{dir/x-foo.*}, taking the location of the primary
1943 output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1944 outputs retain the suffix: @file{dir/x-foo.c.*}.
1945
1946 This option is disregarded if it does not match the suffix of a
1947 specified @var{dumpbase}, except as an alternative to the executable
1948 suffix when appending the linker output base name to @var{dumppfx}, as
1949 specified below:
1950
1951 @smallexample
1952 gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1953 @end smallexample
1954
1955 creates @file{main.out} as the primary output, and avoids overwriting
1956 the auxiliary and dump outputs by using the executable name minus
1957 @var{auxdropsuf} as a prefix, creating auxiliary outputs named
1958 @file{main-foo.*} and @file{main-bar.*} and dump outputs named
1959 @file{main-foo.c.*} and @file{main-bar.c.*}.
1960
1961
1962 @opindex dumpdir
1963 @item -dumpdir @var{dumppfx}
1964 When forming the name of an auxiliary or dump output file, use
1965 @var{dumppfx} as a prefix:
1966
1967 @smallexample
1968 gcc -dumpdir pfx- -c foo.c ...
1969 @end smallexample
1970
1971 creates @file{foo.o} as the primary output, and auxiliary outputs named
1972 @file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1973 @var{dumpbase} derived from the default primary output, derived in turn
1974 from the input name. Dump outputs also take the input name suffix:
1975 @file{pfx-foo.c.*}.
1976
1977 If @var{dumppfx} is to be used as a directory name, it must end with a
1978 directory separator:
1979
1980 @smallexample
1981 gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1982 @end smallexample
1983
1984 creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1985 named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1986 default @var{dumpbase} derived from the primary output name. Dump
1987 outputs also take the input name suffix: @file{dir/bar.c.*}.
1988
1989 It defaults to the location of the output file, unless the output
1990 file is a special file like @code{/dev/null}. Options
1991 @option{-save-temps=cwd} and @option{-save-temps=obj} override this
1992 default, just like an explicit @option{-dumpdir} option. In case
1993 multiple such options are given, the last one prevails:
1994
1995 @smallexample
1996 gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1997 @end smallexample
1998
1999 outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
2000 @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
2001 @option{-dumpdir} option. It does not matter that @option{=obj} is the
2002 default for @option{-save-temps}, nor that the output directory is
2003 implicitly the current directory. Dump outputs are named
2004 @file{foo.c.*}.
2005
2006 When compiling from multiple input files, if @option{-dumpbase} is
2007 specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
2008 are appended to (or override, if containing any directory components) an
2009 explicit or defaulted @var{dumppfx}, so that each of the multiple
2010 compilations gets differently-named aux and dump outputs.
2011
2012 @smallexample
2013 gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
2014 @end smallexample
2015
2016 outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
2017 @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
2018 Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
2019 and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
2020 single-input compilation:
2021
2022 @smallexample
2023 gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
2024 @end smallexample
2025
2026 that, applying @option{-dumpbase} to a single source, does not compute
2027 and append a separate @var{dumpbase} per input file. Its auxiliary and
2028 dump outputs go in @file{dir/pfx-main.*}.
2029
2030 When compiling and then linking from multiple input files, a defaulted
2031 or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
2032 transformation above (e.g. the compilation of @file{foo.c} and
2033 @file{bar.c} above, but without @option{-c}). If neither
2034 @option{-dumpdir} nor @option{-dumpbase} are given, the linker output
2035 base name, minus @var{auxdropsuf}, if specified, or the executable
2036 suffix otherwise, plus a dash is appended to the default @var{dumppfx}
2037 instead. Note, however, that unlike earlier cases of linking:
2038
2039 @smallexample
2040 gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
2041 @end smallexample
2042
2043 does not append the output name @file{main} to @var{dumppfx}, because
2044 @option{-dumpdir} is explicitly specified. The goal is that the
2045 explicitly-specified @var{dumppfx} may contain the specified output name
2046 as part of the prefix, if desired; only an explicitly-specified
2047 @option{-dumpbase} would be combined with it, in order to avoid simply
2048 discarding a meaningful option.
2049
2050 When compiling and then linking from a single input file, the linker
2051 output base name will only be appended to the default @var{dumppfx} as
2052 above if it does not share the base name with the single input file
2053 name. This has been covered in single-input linking cases above, but
2054 not with an explicit @option{-dumpdir} that inhibits the combination,
2055 even if overridden by @option{-save-temps=*}:
2056
2057 @smallexample
2058 gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
2059 @end smallexample
2060
2061 Auxiliary outputs are named @file{foo.*}, and dump outputs
2062 @file{foo.c.*}, in the current working directory as ultimately requested
2063 by @option{-save-temps=cwd}.
2064
2065 Summing it all up for an intuitive though slightly imprecise data flow:
2066 the primary output name is broken into a directory part and a basename
2067 part; @var{dumppfx} is set to the former, unless overridden by
2068 @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
2069 to the latter, unless overriden by @option{-dumpbase}. If there are
2070 multiple inputs or linking, this @var{dumpbase} may be combined with
2071 @var{dumppfx} and taken from each input file. Auxiliary output names
2072 for each input are formed by combining @var{dumppfx}, @var{dumpbase}
2073 minus suffix, and the auxiliary output suffix; dump output names are
2074 only different in that the suffix from @var{dumpbase} is retained.
2075
2076 When it comes to auxiliary and dump outputs created during LTO
2077 recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
2078 given or as derived from the linker output name but not from inputs,
2079 even in cases in which this combination would not otherwise be used as
2080 such, is passed down with a trailing period replacing the compiler-added
2081 dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2082 being involved in linking, this program does not normally get any
2083 @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2084
2085 When running sub-compilers, @command{lto-wrapper} appends LTO stage
2086 names to the received @var{dumppfx}, ensures it contains a directory
2087 component so that it overrides any @option{-dumpdir}, and passes that as
2088 @option{-dumpbase} to sub-compilers.
2089
2090 @opindex v
2091 @item -v
2092 Print (on standard error output) the commands executed to run the stages
2093 of compilation. Also print the version number of the compiler driver
2094 program and of the preprocessor and the compiler proper.
2095
2096 @opindex ###
2097 @item -###
2098 Like @option{-v} except the commands are not executed and arguments
2099 are quoted unless they contain only alphanumeric characters or @code{./-_}.
2100 This is useful for shell scripts to capture the driver-generated command lines.
2101
2102 @opindex help
2103 @item --help
2104 Print (on the standard output) a description of the command-line options
2105 understood by @command{gcc}. If the @option{-v} option is also specified
2106 then @option{--help} is also passed on to the various processes
2107 invoked by @command{gcc}, so that they can display the command-line options
2108 they accept. If the @option{-Wextra} option has also been specified
2109 (prior to the @option{--help} option), then command-line options that
2110 have no documentation associated with them are also displayed.
2111
2112 @opindex target-help
2113 @item --target-help
2114 Print (on the standard output) a description of target-specific command-line
2115 options for each tool. For some targets extra target-specific
2116 information may also be printed.
2117
2118 @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2119 Print (on the standard output) a description of the command-line
2120 options understood by the compiler that fit into all specified classes
2121 and qualifiers. These are the supported classes:
2122
2123 @table @asis
2124 @item @samp{optimizers}
2125 Display all of the optimization options supported by the
2126 compiler.
2127
2128 @item @samp{warnings}
2129 Display all of the options controlling warning messages
2130 produced by the compiler.
2131
2132 @item @samp{target}
2133 Display target-specific options. Unlike the
2134 @option{--target-help} option however, target-specific options of the
2135 linker and assembler are not displayed. This is because those
2136 tools do not currently support the extended @option{--help=} syntax.
2137
2138 @item @samp{params}
2139 Display the values recognized by the @option{--param}
2140 option.
2141
2142 @item @var{language}
2143 Display the options supported for @var{language}, where
2144 @var{language} is the name of one of the languages supported in this
2145 version of GCC@. If an option is supported by all languages, one needs
2146 to select @samp{common} class.
2147
2148 @item @samp{common}
2149 Display the options that are common to all languages.
2150 @end table
2151
2152 These are the supported qualifiers:
2153
2154 @table @asis
2155 @item @samp{undocumented}
2156 Display only those options that are undocumented.
2157
2158 @item @samp{joined}
2159 Display options taking an argument that appears after an equal
2160 sign in the same continuous piece of text, such as:
2161 @samp{--help=target}.
2162
2163 @item @samp{separate}
2164 Display options taking an argument that appears as a separate word
2165 following the original option, such as: @samp{-o output-file}.
2166 @end table
2167
2168 Thus for example to display all the undocumented target-specific
2169 switches supported by the compiler, use:
2170
2171 @smallexample
2172 --help=target,undocumented
2173 @end smallexample
2174
2175 The sense of a qualifier can be inverted by prefixing it with the
2176 @samp{^} character, so for example to display all binary warning
2177 options (i.e., ones that are either on or off and that do not take an
2178 argument) that have a description, use:
2179
2180 @smallexample
2181 --help=warnings,^joined,^undocumented
2182 @end smallexample
2183
2184 The argument to @option{--help=} should not consist solely of inverted
2185 qualifiers.
2186
2187 Combining several classes is possible, although this usually
2188 restricts the output so much that there is nothing to display. One
2189 case where it does work, however, is when one of the classes is
2190 @var{target}. For example, to display all the target-specific
2191 optimization options, use:
2192
2193 @smallexample
2194 --help=target,optimizers
2195 @end smallexample
2196
2197 The @option{--help=} option can be repeated on the command line. Each
2198 successive use displays its requested class of options, skipping
2199 those that have already been displayed. If @option{--help} is also
2200 specified anywhere on the command line then this takes precedence
2201 over any @option{--help=} option.
2202
2203 @opindex Q
2204 If the @option{-Q} option appears on the command line before the
2205 @option{--help=} option, then the descriptive text displayed by
2206 @option{--help=} is changed. Instead of describing the displayed
2207 options, an indication is given as to whether the option is enabled,
2208 disabled or set to a specific value (assuming that the compiler
2209 knows this at the point where the @option{--help=} option is used).
2210
2211 Here is a truncated example from the ARM port of @command{gcc}:
2212
2213 @smallexample
2214 % gcc -Q -mabi=2 --help=target -c
2215 The following options are target specific:
2216 -mabi= 2
2217 -mabort-on-noreturn [disabled]
2218 -mapcs [disabled]
2219 @end smallexample
2220
2221 The output is sensitive to the effects of previous command-line
2222 options, so for example it is possible to find out which optimizations
2223 are enabled at @option{-O2} by using:
2224
2225 @smallexample
2226 -Q -O2 --help=optimizers
2227 @end smallexample
2228
2229 Alternatively you can discover which binary optimizations are enabled
2230 by @option{-O3} by using:
2231
2232 @smallexample
2233 gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2234 gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2235 diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2236 @end smallexample
2237
2238 @opindex version
2239 @item --version
2240 Display the version number and copyrights of the invoked GCC@.
2241
2242 @opindex pass-exit-codes
2243 @item -pass-exit-codes
2244 Normally the @command{gcc} program exits with the code of 1 if any
2245 phase of the compiler returns a non-success return code. If you specify
2246 @option{-pass-exit-codes}, the @command{gcc} program instead returns with
2247 the numerically highest error produced by any phase returning an error
2248 indication. The C, C++, and Fortran front ends return 4 if an internal
2249 compiler error is encountered.
2250
2251 @opindex pipe
2252 @item -pipe
2253 Use pipes rather than temporary files for communication between the
2254 various stages of compilation. This fails to work on some systems where
2255 the assembler is unable to read from a pipe; but the GNU assembler has
2256 no trouble.
2257
2258 @opindex specs
2259 @item -specs=@var{file}
2260 Process @var{file} after the compiler reads in the standard @file{specs}
2261 file, in order to override the defaults which the @command{gcc} driver
2262 program uses when determining what switches to pass to @command{cc1},
2263 @command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2264 @option{-specs=@var{file}} can be specified on the command line, and they
2265 are processed in order, from left to right. @xref{Spec Files}, for
2266 information about the format of the @var{file}.
2267
2268 @opindex wrapper
2269 @item -wrapper
2270 Invoke all subcommands under a wrapper program. The name of the
2271 wrapper program and its parameters are passed as a comma separated
2272 list.
2273
2274 @smallexample
2275 gcc -c t.c -wrapper gdb,--args
2276 @end smallexample
2277
2278 @noindent
2279 This invokes all subprograms of @command{gcc} under
2280 @samp{gdb --args}, thus the invocation of @command{cc1} is
2281 @samp{gdb --args cc1 @dots{}}.
2282
2283 @opindex ffile-prefix-map
2284 @item -ffile-prefix-map=@var{old}=@var{new}
2285 When compiling files residing in directory @file{@var{old}}, record
2286 any references to them in the result of the compilation as if the
2287 files resided in directory @file{@var{new}} instead. Specifying this
2288 option is equivalent to specifying all the individual
2289 @option{-f*-prefix-map} options. This can be used to make reproducible
2290 builds that are location independent. Directories referenced by
2291 directives are not affected by these options. See also
2292 @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map},
2293 @option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}.
2294
2295 @opindex fcanon-prefix-map
2296 @item -fcanon-prefix-map
2297 For the @option{-f*-prefix-map} options normally comparison
2298 of @file{@var{old}} prefix against the filename that would be normally
2299 referenced in the result of the compilation is done using textual
2300 comparison of the prefixes, or ignoring character case for case insensitive
2301 filesystems and considering slashes and backslashes as equal on DOS based
2302 filesystems. The @option{-fcanon-prefix-map} causes such comparisons
2303 to be done on canonicalized paths of @file{@var{old}}
2304 and the referenced filename.
2305
2306 @opindex fplugin
2307 @item -fplugin=@var{name}.so
2308 Load the plugin code in file @var{name}.so, assumed to be a
2309 shared object to be dlopen'd by the compiler. The base name of
2310 the shared object file is used to identify the plugin for the
2311 purposes of argument parsing (See
2312 @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2313 Each plugin should define the callback functions specified in the
2314 Plugins API.
2315
2316 @opindex fplugin-arg
2317 @item -fplugin-arg-@var{name}-@var{key}=@var{value}
2318 Define an argument called @var{key} with a value of @var{value}
2319 for the plugin called @var{name}.
2320
2321 @opindex fdump-ada-spec
2322 @item -fdump-ada-spec@r{[}-slim@r{]}
2323 For C and C++ source and include files, generate corresponding Ada specs.
2324 @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2325 GNAT User's Guide}, which provides detailed documentation on this feature.
2326
2327 @opindex fada-spec-parent
2328 @item -fada-spec-parent=@var{unit}
2329 In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2330 Ada specs as child units of parent @var{unit}.
2331
2332 @opindex fdump-go-spec
2333 @item -fdump-go-spec=@var{file}
2334 For input files in any language, generate corresponding Go
2335 declarations in @var{file}. This generates Go @code{const},
2336 @code{type}, @code{var}, and @code{func} declarations which may be a
2337 useful way to start writing a Go interface to code written in some
2338 other language.
2339
2340 @include @value{srcdir}/../libiberty/at-file.texi
2341 @end table
2342
2343 @node Invoking G++
2344 @section Compiling C++ Programs
2345
2346 @cindex suffixes for C++ source
2347 @cindex C++ source file suffixes
2348 C++ source files conventionally use one of the suffixes @samp{.C},
2349 @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2350 @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2351 @samp{.H}, or (for shared template code) @samp{.tcc};
2352 preprocessed C++ files use the suffix @samp{.ii}; and C++20 module interface
2353 units sometimes use @samp{.ixx}, @samp{.cppm}, @samp{.cxxm}, @samp{.c++m},
2354 or @samp{.ccm}.
2355
2356 GCC recognizes files with these names and compiles them as C++ programs even if you
2357 call the compiler the same way as for compiling C programs (usually
2358 with the name @command{gcc}).
2359
2360 @findex g++
2361 @findex c++
2362 However, the use of @command{gcc} does not add the C++ library.
2363 @command{g++} is a program that calls GCC and automatically specifies linking
2364 against the C++ library. It treats @samp{.c},
2365 @samp{.h} and @samp{.i} files as C++ source files instead of C source
2366 files unless @option{-x} is used. This program is also useful when
2367 precompiling a C header file with a @samp{.h} extension for use in C++
2368 compilations. On many systems, @command{g++} is also installed with
2369 the name @command{c++}.
2370
2371 @cindex invoking @command{g++}
2372 When you compile C++ programs, you may specify many of the same
2373 command-line options that you use for compiling programs in any
2374 language; or command-line options meaningful for C and related
2375 languages; or options that are meaningful only for C++ programs.
2376 @xref{C Dialect Options,,Options Controlling C Dialect}, for
2377 explanations of options for languages related to C@.
2378 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2379 explanations of options that are meaningful only for C++ programs.
2380
2381 @node C Dialect Options
2382 @section Options Controlling C Dialect
2383 @cindex dialect options
2384 @cindex language dialect options
2385 @cindex options, dialect
2386
2387 The following options control the dialect of C (or languages derived
2388 from C, such as C++, Objective-C and Objective-C++) that the compiler
2389 accepts:
2390
2391 @table @gcctabopt
2392 @cindex ANSI support
2393 @cindex ISO support
2394 @opindex ansi
2395 @item -ansi
2396 In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2397 equivalent to @option{-std=c++98}.
2398
2399 @opindex std
2400 @item -std=
2401 Determine the language standard. @xref{Standards,,Language Standards
2402 Supported by GCC}, for details of these standard versions. This option
2403 is currently only supported when compiling C or C++.
2404
2405 The compiler can accept several base standards, such as @samp{c90} or
2406 @samp{c++98}, and GNU dialects of those standards, such as
2407 @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2408 compiler accepts all programs following that standard plus those
2409 using GNU extensions that do not contradict it. For example,
2410 @option{-std=c90} turns off certain features of GCC that are
2411 incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2412 keywords, but not other GNU extensions that do not have a meaning in
2413 ISO C90, such as omitting the middle term of a @code{?:}
2414 expression. On the other hand, when a GNU dialect of a standard is
2415 specified, all features supported by the compiler are enabled, even when
2416 those features change the meaning of the base standard. As a result, some
2417 strict-conforming programs may be rejected. The particular standard
2418 is used by @option{-Wpedantic} to identify which features are GNU
2419 extensions given that version of the standard. For example
2420 @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2421 comments, while @option{-std=gnu99 -Wpedantic} does not.
2422
2423 A value for this option must be provided; possible values are
2424
2425 @table @samp
2426 @item c90
2427 @itemx c89
2428 @itemx iso9899:1990
2429 Support all ISO C90 programs (certain GNU extensions that conflict
2430 with ISO C90 are disabled). Same as @option{-ansi} for C code.
2431
2432 @item iso9899:199409
2433 ISO C90 as modified in amendment 1.
2434
2435 @item c99
2436 @itemx c9x
2437 @itemx iso9899:1999
2438 @itemx iso9899:199x
2439 ISO C99. This standard is substantially completely supported, modulo
2440 bugs and floating-point issues
2441 (mainly but not entirely relating to optional C99 features from
2442 Annexes F and G). See
2443 @w{@uref{https://gcc.gnu.org/projects/c-status.html}} for more information.
2444 The names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2445
2446 @item c11
2447 @itemx c1x
2448 @itemx iso9899:2011
2449 ISO C11, the 2011 revision of the ISO C standard. This standard is
2450 substantially completely supported, modulo bugs, floating-point issues
2451 (mainly but not entirely relating to optional C11 features from
2452 Annexes F and G) and the optional Annexes K (Bounds-checking
2453 interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2454
2455 @item c17
2456 @itemx c18
2457 @itemx iso9899:2017
2458 @itemx iso9899:2018
2459 ISO C17, the 2017 revision of the ISO C standard
2460 (published in 2018). This standard is
2461 same as C11 except for corrections of defects (all of which are also
2462 applied with @option{-std=c11}) and a new value of
2463 @code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2464
2465 @item c23
2466 @itemx c2x
2467 @itemx iso9899:2024
2468 ISO C23, the 2023 revision of the ISO C standard (published in 2024). The
2469 name @samp{c2x} is deprecated.
2470
2471 @item c2y
2472 The next version of the ISO C standard, still under development. The
2473 support for this version is experimental and incomplete.
2474
2475 @item gnu90
2476 @itemx gnu89
2477 GNU dialect of ISO C90 (including some C99 features).
2478
2479 @item gnu99
2480 @itemx gnu9x
2481 GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2482
2483 @item gnu11
2484 @itemx gnu1x
2485 GNU dialect of ISO C11.
2486 The name @samp{gnu1x} is deprecated.
2487
2488 @item gnu17
2489 @itemx gnu18
2490 GNU dialect of ISO C17.
2491
2492 @item gnu23
2493 @itemx gnu2x
2494 GNU dialect of ISO C23. This is the default for C code. The name
2495 @samp{gnu2x} is deprecated.
2496
2497 @item gnu2y
2498 The next version of the ISO C standard, still under development, plus
2499 GNU extensions. The support for this version is experimental and
2500 incomplete. The name @samp{gnu2x} is deprecated.
2501
2502 @item c++98
2503 @itemx c++03
2504 The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2505 additional defect reports. Same as @option{-ansi} for C++ code.
2506
2507 @item gnu++98
2508 @itemx gnu++03
2509 GNU dialect of @option{-std=c++98}.
2510
2511 @item c++11
2512 @itemx c++0x
2513 The 2011 ISO C++ standard plus amendments.
2514 The name @samp{c++0x} is deprecated.
2515
2516 @item gnu++11
2517 @itemx gnu++0x
2518 GNU dialect of @option{-std=c++11}.
2519 The name @samp{gnu++0x} is deprecated.
2520
2521 @item c++14
2522 @itemx c++1y
2523 The 2014 ISO C++ standard plus amendments.
2524 The name @samp{c++1y} is deprecated.
2525
2526 @item gnu++14
2527 @itemx gnu++1y
2528 GNU dialect of @option{-std=c++14}.
2529 The name @samp{gnu++1y} is deprecated.
2530
2531 @item c++17
2532 @itemx c++1z
2533 The 2017 ISO C++ standard plus amendments.
2534 The name @samp{c++1z} is deprecated.
2535
2536 @item gnu++17
2537 @itemx gnu++1z
2538 GNU dialect of @option{-std=c++17}.
2539 This is the default for C++ code.
2540 The name @samp{gnu++1z} is deprecated.
2541
2542 @item c++20
2543 @itemx c++2a
2544 The 2020 ISO C++ standard plus amendments.
2545 Support is experimental, and could change in incompatible ways in
2546 future releases.
2547 The name @samp{c++2a} is deprecated.
2548
2549 @item gnu++20
2550 @itemx gnu++2a
2551 GNU dialect of @option{-std=c++20}.
2552 Support is experimental, and could change in incompatible ways in
2553 future releases.
2554 The name @samp{gnu++2a} is deprecated.
2555
2556 @item c++23
2557 @itemx c++2b
2558 The 2023 ISO C++ standard plus amendments (published in 2024).
2559 Support is experimental, and could change in incompatible ways in
2560 future releases.
2561 The name @samp{c++2b} is deprecated.
2562
2563 @item gnu++23
2564 @itemx gnu++2b
2565 GNU dialect of @option{-std=c++23}.
2566 Support is experimental, and could change in incompatible ways in
2567 future releases.
2568 The name @samp{gnu++2b} is deprecated.
2569
2570 @item c++2c
2571 @itemx c++26
2572 The next revision of the ISO C++ standard, planned for
2573 2026. Support is highly experimental, and will almost certainly
2574 change in incompatible ways in future releases.
2575
2576 @item gnu++2c
2577 @itemx gnu++26
2578 GNU dialect of @option{-std=c++2c}. Support is highly experimental,
2579 and will almost certainly change in incompatible ways in future
2580 releases.
2581 @end table
2582
2583 @opindex aux-info
2584 @item -aux-info @var{filename}
2585 Output to the given filename prototyped declarations for all functions
2586 declared and/or defined in a translation unit, including those in header
2587 files. This option is silently ignored in any language other than C@.
2588
2589 Besides declarations, the file indicates, in comments, the origin of
2590 each declaration (source file and line), whether the declaration was
2591 implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2592 @samp{O} for old, respectively, in the first character after the line
2593 number and the colon), and whether it came from a declaration or a
2594 definition (@samp{C} or @samp{F}, respectively, in the following
2595 character). In the case of function definitions, a K&R-style list of
2596 arguments followed by their declarations is also provided, inside
2597 comments, after the declaration.
2598
2599 @opindex fno-asm
2600 @opindex fasm
2601 @item -fno-asm
2602 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2603 keyword, so that code can use these words as identifiers. You can use
2604 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2605 instead. In C, @option{-ansi} implies @option{-fno-asm}.
2606
2607 In C++, @code{inline} is a standard keyword and is not affected by
2608 this switch. You may want to use the @option{-fno-gnu-keywords} flag
2609 instead, which disables @code{typeof} but not @code{asm} and
2610 @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2611 this switch only affects the @code{asm} and @code{typeof} keywords,
2612 since @code{inline} is a standard keyword in ISO C99. In C23 mode
2613 (@option{-std=c23} or @option{-std=gnu23}), this switch only affects
2614 the @code{asm} keyword, since @code{typeof} is a standard keyword in
2615 ISO C23.
2616
2617 @opindex fno-builtin
2618 @opindex fbuiltin
2619 @cindex built-in functions
2620 @item -fno-builtin
2621 @itemx -fno-builtin-@var{function}
2622 Don't recognize built-in functions that do not begin with
2623 @samp{__builtin_} as prefix. @xref{Library Builtins},
2624 for details of the functions affected,
2625 including those which are not built-in functions when @option{-ansi} or
2626 @option{-std} options for strict ISO C conformance are used because they
2627 do not have an ISO standard meaning.
2628
2629 GCC normally generates special code to handle certain built-in functions
2630 more efficiently; for instance, calls to @code{alloca} may become single
2631 instructions which adjust the stack directly, and calls to @code{memcpy}
2632 may become inline copy loops. The resulting code is often both smaller
2633 and faster, but since the function calls no longer appear as such, you
2634 cannot set a breakpoint on those calls, nor can you change the behavior
2635 of the functions by linking with a different library. In addition,
2636 when a function is recognized as a built-in function, GCC may use
2637 information about that function to warn about problems with calls to
2638 that function, or to generate more efficient code, even if the
2639 resulting code still contains calls to that function. For example,
2640 warnings are given with @option{-Wformat} for bad calls to
2641 @code{printf} when @code{printf} is built in and @code{strlen} is
2642 known not to modify global memory.
2643
2644 With the @option{-fno-builtin-@var{function}} option
2645 only the built-in function @var{function} is
2646 disabled. @var{function} must not begin with @samp{__builtin_}. If a
2647 function is named that is not built-in in this version of GCC, this
2648 option is ignored. There is no corresponding
2649 @option{-fbuiltin-@var{function}} option; if you wish to enable
2650 built-in functions selectively when using @option{-fno-builtin} or
2651 @option{-ffreestanding}, you may define macros such as:
2652
2653 @smallexample
2654 #define abs(n) __builtin_abs ((n))
2655 #define strcpy(d, s) __builtin_strcpy ((d), (s))
2656 @end smallexample
2657
2658 @opindex fcond-mismatch
2659 @item -fcond-mismatch
2660 Allow conditional expressions with mismatched types in the second and
2661 third arguments. The value of such an expression is void. This option
2662 is not supported for C++.
2663
2664 @opindex ffreestanding
2665 @cindex hosted environment
2666 @item -ffreestanding
2667
2668 Assert that compilation targets a freestanding environment. This
2669 implies @option{-fno-builtin}. A freestanding environment
2670 is one in which the standard library may not exist, and program startup may
2671 not necessarily be at @code{main}. The most obvious example is an OS kernel.
2672 This is equivalent to @option{-fno-hosted}.
2673
2674 @xref{Standards,,Language Standards Supported by GCC}, for details of
2675 freestanding and hosted environments.
2676
2677 @opindex fgimple
2678 @item -fgimple
2679
2680 Enable parsing of function definitions marked with @code{__GIMPLE}.
2681 This is an experimental feature that allows unit testing of GIMPLE
2682 passes.
2683
2684 @opindex fgnu-tm
2685 @item -fgnu-tm
2686 When the option @option{-fgnu-tm} is specified, the compiler
2687 generates code for the Linux variant of Intel's current Transactional
2688 Memory ABI specification document (Revision 1.1, May 6 2009). This is
2689 an experimental feature whose interface may change in future versions
2690 of GCC, as the official specification changes. Please note that not
2691 all architectures are supported for this feature.
2692
2693 For more information on GCC's support for transactional memory,
2694 @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2695 Transactional Memory Library}.
2696
2697 Note that the transactional memory feature is not supported with
2698 non-call exceptions (@option{-fnon-call-exceptions}).
2699
2700 @opindex fgnu89-inline
2701 @item -fgnu89-inline
2702 The option @option{-fgnu89-inline} tells GCC to use the traditional
2703 GNU semantics for @code{inline} functions when in C99 mode.
2704 @xref{Inline,,An Inline Function is As Fast As a Macro}.
2705 Using this option is roughly equivalent to adding the
2706 @code{gnu_inline} function attribute to all inline functions
2707 (@pxref{Function Attributes}).
2708
2709 The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2710 C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2711 specifies the default behavior).
2712 This option is not supported in @option{-std=c90} or
2713 @option{-std=gnu90} mode.
2714
2715 The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2716 @code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2717 in effect for @code{inline} functions. @xref{Common Predefined
2718 Macros,,,cpp,The C Preprocessor}.
2719
2720 @opindex fhosted
2721 @cindex hosted environment
2722 @item -fhosted
2723
2724 Assert that compilation targets a hosted environment. This implies
2725 @option{-fbuiltin}. A hosted environment is one in which the
2726 entire standard library is available, and in which @code{main} has a return
2727 type of @code{int}. Examples are nearly everything except a kernel.
2728 This is equivalent to @option{-fno-freestanding}.
2729
2730 @opindex flax-vector-conversions
2731 @item -flax-vector-conversions
2732 Allow implicit conversions between vectors with differing numbers of
2733 elements and/or incompatible element types. This option should not be
2734 used for new code.
2735
2736 @opindex fms-extensions
2737 @item -fms-extensions
2738 Accept some non-standard constructs used in Microsoft header files.
2739
2740 In C++ code, this allows member names in structures to be similar
2741 to previous types declarations.
2742
2743 @smallexample
2744 typedef int UOW;
2745 struct ABC @{
2746 UOW UOW;
2747 @};
2748 @end smallexample
2749
2750 Some cases of unnamed fields in structures and unions are only
2751 accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2752 fields within structs/unions}, for details.
2753
2754 Note that this option is off for all targets except for x86
2755 targets using ms-abi.
2756
2757 @opindex fpermitted-flt-eval-methods
2758 @opindex fpermitted-flt-eval-methods=c11
2759 @opindex fpermitted-flt-eval-methods=ts-18661-3
2760 @item -fpermitted-flt-eval-methods=@var{style}
2761 ISO/IEC TS 18661-3 defines new permissible values for
2762 @code{FLT_EVAL_METHOD} that indicate that operations and constants with
2763 a semantic type that is an interchange or extended format should be
2764 evaluated to the precision and range of that type. These new values are
2765 a superset of those permitted under C99/C11, which does not specify the
2766 meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2767 conforming to C11 may not have been written expecting the possibility of
2768 the new values.
2769
2770 @option{-fpermitted-flt-eval-methods} specifies whether the compiler
2771 should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2772 or the extended set of values specified in ISO/IEC TS 18661-3.
2773
2774 @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2775
2776 The default when in a standards compliant mode (@option{-std=c11} or similar)
2777 is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2778 dialect (@option{-std=gnu11} or similar) is
2779 @option{-fpermitted-flt-eval-methods=ts-18661-3}.
2780
2781 @opindex fdeps-
2782 The @samp{-fdeps-*} options are used to extract structured dependency
2783 information for a source. This involves determining what resources provided by
2784 other source files will be required to compile the source as well as what
2785 resources are provided by the source. This information can be used to add
2786 required dependencies between compilation rules of dependent sources based on
2787 their contents rather than requiring such information be reflected within the
2788 build tools as well.
2789
2790 @opindex fdeps-file
2791 @item -fdeps-file=@var{file}
2792 Where to write structured dependency information.
2793
2794 @opindex fdeps-format
2795 @item -fdeps-format=@var{format}
2796 The format to use for structured dependency information. @samp{p1689r5} is the
2797 only supported format right now. Note that when this argument is specified, the
2798 output of @samp{-MF} is stripped of some information (namely C++ modules) so
2799 that it does not use extended makefile syntax not understood by most tools.
2800
2801 @opindex fdeps-target
2802 @item -fdeps-target=@var{file}
2803 Analogous to @option{-MT} but for structured dependency information. This
2804 indicates the target which will ultimately need any required resources and
2805 provide any resources extracted from the source that may be required by other
2806 sources.
2807
2808 @opindex fplan9-extensions
2809 @item -fplan9-extensions
2810 Accept some non-standard constructs used in Plan 9 code.
2811
2812 This enables @option{-fms-extensions}, permits passing pointers to
2813 structures with anonymous fields to functions that expect pointers to
2814 elements of the type of the field, and permits referring to anonymous
2815 fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2816 struct/union fields within structs/unions}, for details. This is only
2817 supported for C, not C++.
2818
2819 @opindex fsigned-bitfields
2820 @opindex funsigned-bitfields
2821 @opindex fno-signed-bitfields
2822 @opindex fno-unsigned-bitfields
2823 @item -fsigned-bitfields
2824 @itemx -funsigned-bitfields
2825 @itemx -fno-signed-bitfields
2826 @itemx -fno-unsigned-bitfields
2827 These options control whether a bit-field is signed or unsigned, when the
2828 declaration does not use either @code{signed} or @code{unsigned}. By
2829 default, such a bit-field is signed, because this is consistent: the
2830 basic integer types such as @code{int} are signed types.
2831
2832 @opindex fsigned-char
2833 @item -fsigned-char
2834 Let the type @code{char} be signed, like @code{signed char}.
2835
2836 Note that this is equivalent to @option{-fno-unsigned-char}, which is
2837 the negative form of @option{-funsigned-char}. Likewise, the option
2838 @option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2839
2840 @opindex funsigned-char
2841 @item -funsigned-char
2842 Let the type @code{char} be unsigned, like @code{unsigned char}.
2843
2844 Each kind of machine has a default for what @code{char} should
2845 be. It is either like @code{unsigned char} by default or like
2846 @code{signed char} by default.
2847
2848 Ideally, a portable program should always use @code{signed char} or
2849 @code{unsigned char} when it depends on the signedness of an object.
2850 But many programs have been written to use plain @code{char} and
2851 expect it to be signed, or expect it to be unsigned, depending on the
2852 machines they were written for. This option, and its inverse, let you
2853 make such a program work with the opposite default.
2854
2855 The type @code{char} is always a distinct type from each of
2856 @code{signed char} or @code{unsigned char}, even though its behavior
2857 is always just like one of those two.
2858
2859 @opindex fstrict-flex-arrays
2860 @opindex fno-strict-flex-arrays
2861 @opindex fstrict-flex-arrays=@var{level}
2862 @item -fstrict-flex-arrays @r{(C and C++ only)}
2863 @itemx -fstrict-flex-arrays=@var{level} @r{(C and C++ only)}
2864 Control when to treat the trailing array of a structure as a flexible array
2865 member for the purpose of accessing the elements of such an array. The value
2866 of @var{level} controls the level of strictness.
2867
2868 @option{-fstrict-flex-arrays} is equivalent to
2869 @option{-fstrict-flex-arrays=3}, which is the strictest;
2870 a trailing array is treated as a flexible array member only when
2871 it is declared as a flexible array member per C99 standard onwards.
2872
2873 The negative form @option{-fno-strict-flex-arrays} is equivalent to
2874 @option{-fstrict-flex-arrays=0}, which is the least strict. In this
2875 case all trailing arrays of structures are treated as flexible array members.
2876
2877 There are two more levels in between 0 and 3, which are provided to
2878 support older code that uses the GCC zero-length array extension
2879 (@samp{[0]}) or one-element array as flexible array members
2880 (@samp{[1]}). When @var{level} is 1, the trailing array is treated as
2881 a flexible array member when it is declared as either @samp{[]},
2882 @samp{[0]}, or @samp{[1]}. When @var{level} is 2, the trailing array
2883 is treated as a flexible array member when it is declared as either
2884 @samp{[]}, or @samp{[0]}.
2885
2886 You can control this behavior for a specific trailing array field of a
2887 structure by using the variable attribute @code{strict_flex_array} attribute
2888 (@pxref{Variable Attributes}).
2889
2890 The @option{-fstrict_flex_arrays} option interacts with the
2891 @option{-Wstrict-flex-arrays} option. @xref{Warning Options}, for more
2892 information.
2893
2894 @opindex fsso-struct
2895 @item -fsso-struct=@var{endianness}
2896 Set the default scalar storage order of structures and unions to the
2897 specified endianness. The accepted values are @samp{big-endian},
2898 @samp{little-endian} and @samp{native} for the native endianness of
2899 the target (the default). This option is not supported for C++.
2900
2901 @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2902 code that is not binary compatible with code generated without it if the
2903 specified endianness is not the native endianness of the target.
2904 @end table
2905
2906 @node C++ Dialect Options
2907 @section Options Controlling C++ Dialect
2908
2909 @cindex compiler options, C++
2910 @cindex C++ options, command-line
2911 @cindex options, C++
2912 This section describes the command-line options that are only meaningful
2913 for C++ programs. You can also use most of the GNU compiler options
2914 regardless of what language your program is in. For example, you
2915 might compile a file @file{firstClass.C} like this:
2916
2917 @smallexample
2918 g++ -g -fstrict-enums -O -c firstClass.C
2919 @end smallexample
2920
2921 @noindent
2922 In this example, only @option{-fstrict-enums} is an option meant
2923 only for C++ programs; you can use the other options with any
2924 language supported by GCC@.
2925
2926 Some options for compiling C programs, such as @option{-std}, are also
2927 relevant for C++ programs.
2928 @xref{C Dialect Options,,Options Controlling C Dialect}.
2929
2930 Here is a list of options that are @emph{only} for compiling C++ programs:
2931
2932 @table @gcctabopt
2933
2934 @opindex fabi-version
2935 @item -fabi-version=@var{n}
2936 Use version @var{n} of the C++ ABI@. The default is version 0.
2937
2938 Version 0 refers to the version conforming most closely to
2939 the C++ ABI specification. Therefore, the ABI obtained using version 0
2940 will change in different versions of G++ as ABI bugs are fixed.
2941
2942 Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2943
2944 Version 2 is the version of the C++ ABI that first appeared in G++
2945 3.4, and was the default through G++ 4.9.
2946
2947 Version 3 corrects an error in mangling a constant address as a
2948 template argument.
2949
2950 Version 4, which first appeared in G++ 4.5, implements a standard
2951 mangling for vector types.
2952
2953 Version 5, which first appeared in G++ 4.6, corrects the mangling of
2954 attribute const/volatile on function pointer types, decltype of a
2955 plain decl, and use of a function parameter in the declaration of
2956 another parameter.
2957
2958 Version 6, which first appeared in G++ 4.7, corrects the promotion
2959 behavior of C++11 scoped enums and the mangling of template argument
2960 packs, const/static_cast, prefix ++ and --, and a class scope function
2961 used as a template argument.
2962
2963 Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2964 builtin type and corrects the mangling of lambdas in default argument
2965 scope.
2966
2967 Version 8, which first appeared in G++ 4.9, corrects the substitution
2968 behavior of function types with function-cv-qualifiers.
2969
2970 Version 9, which first appeared in G++ 5.2, corrects the alignment of
2971 @code{nullptr_t}.
2972
2973 Version 10, which first appeared in G++ 6.1, adds mangling of
2974 attributes that affect type identity, such as ia32 calling convention
2975 attributes (e.g.@: @samp{stdcall}).
2976
2977 Version 11, which first appeared in G++ 7, corrects the mangling of
2978 sizeof... expressions and operator names. For multiple entities with
2979 the same name within a function, that are declared in different scopes,
2980 the mangling now changes starting with the twelfth occurrence. It also
2981 implies @option{-fnew-inheriting-ctors}.
2982
2983 Version 12, which first appeared in G++ 8, corrects the calling
2984 conventions for empty classes on the x86_64 target and for classes
2985 with only deleted copy/move constructors. It accidentally changes the
2986 calling convention for classes with a deleted copy constructor and a
2987 trivial move constructor.
2988
2989 Version 13, which first appeared in G++ 8.2, fixes the accidental
2990 change in version 12.
2991
2992 Version 14, which first appeared in G++ 10, corrects the mangling of
2993 the nullptr expression.
2994
2995 Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
2996 tag regression.
2997
2998 Version 16, which first appeared in G++ 11, changes the mangling of
2999 @code{__alignof__} to be distinct from that of @code{alignof}, and
3000 dependent operator names.
3001
3002 Version 17, which first appeared in G++ 12, fixes layout of classes
3003 that inherit from aggregate classes with default member initializers
3004 in C++14 and up.
3005
3006 Version 18, which first appeared in G++ 13, fixes manglings of lambdas
3007 that have additional context.
3008
3009 Version 19, which first appeared in G++ 14, fixes manglings of
3010 structured bindings to include ABI tags, handling of cv-qualified
3011 [[no_unique_address]] members, and adds mangling of C++20 constraints
3012 on function templates.
3013
3014 Version 20, which first appeared in G++ 15, fixes manglings of lambdas
3015 in static data member initializers.
3016
3017 Version 21, which first appeared in G++ 16, fixes unnecessary captures
3018 in noexcept lambdas (c++/119764) and layout of a base class
3019 with all explicitly defaulted constructors (c++/120012).
3020
3021 See also @option{-Wabi}.
3022
3023 @opindex fabi-compat-version
3024 @item -fabi-compat-version=@var{n}
3025 On targets that support strong aliases, G++
3026 works around mangling changes by creating an alias with the correct
3027 mangled name when defining a symbol with an incorrect mangled name.
3028 This switch specifies which ABI version to use for the alias.
3029
3030 With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
3031 compatibility). If another ABI version is explicitly selected, this
3032 defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
3033 use @option{-fabi-compat-version=2}.
3034
3035 If this option is not provided but @option{-Wabi=@var{n}} is, that
3036 version is used for compatibility aliases. If this option is provided
3037 along with @option{-Wabi} (without the version), the version from this
3038 option is used for the warning.
3039
3040 @opindex fno-access-control
3041 @opindex faccess-control
3042 @item -fno-access-control
3043 Turn off all access checking. This switch is mainly useful for working
3044 around bugs in the access control code.
3045
3046 @opindex faligned-new
3047 @item -faligned-new
3048 Enable support for C++17 @code{new} of types that require more
3049 alignment than @code{void* ::operator new(std::size_t)} provides. A
3050 numeric argument such as @code{-faligned-new=32} can be used to
3051 specify how much alignment (in bytes) is provided by that function,
3052 but few users will need to override the default of
3053 @code{alignof(std::max_align_t)}.
3054
3055 This flag is enabled by default for @option{-std=c++17}.
3056
3057 @opindex fno-assume-sane-operators-new-delete
3058 @opindex fassume-sane-operators-new-delete
3059 @item -fno-assume-sane-operators-new
3060 The C++ standard allows replacing the global @code{new}, @code{new[]},
3061 @code{delete} and @code{delete[]} operators, though a lot of C++ programs
3062 don't replace them and just use the implementation provided version.
3063 Furthermore, the C++ standard allows omitting those calls if they are
3064 made from new or delete expressions (and by extension the same is
3065 assumed if @code{__builtin_operator_new} or @code{__builtin_operator_delete}
3066 functions are used).
3067 This option allows control over some optimizations around calls
3068 to those operators.
3069 With @code{-fassume-sane-operators-new-delete} option GCC may assume that
3070 calls to the replaceable global operators from new or delete expressions or
3071 from @code{__builtin_operator_new} or @code{__builtin_operator_delete} calls
3072 don't read or modify any global variables or variables whose address could
3073 escape to the operators (global state; except for @code{errno} for the
3074 @code{new} and @code{new[]} operators).
3075 This allows most optimizations across those calls and is something that
3076 the implementation provided operators satisfy unless @code{malloc}
3077 implementation details are observable in the code or unless @code{malloc}
3078 hooks are used, but might not be satisfied if a program replaces those
3079 operators. This behavior is enabled by default.
3080 With @code{-fno-assume-sane-operators-new-delete} option GCC must
3081 assume all these calls (whether from new or delete expressions or called
3082 directly) may read and write global state unless proven otherwise (e.g.@:
3083 when GCC compiles their implementation). Use this option if those
3084 operators are or may be replaced and code needs to expect such behavior.
3085
3086 @opindex fchar8_t
3087 @opindex fno-char8_t
3088 @item -fchar8_t
3089 @itemx -fno-char8_t
3090 Enable support for @code{char8_t} as adopted for C++20. This includes
3091 the addition of a new @code{char8_t} fundamental type, changes to the
3092 types of UTF-8 string and character literals, new signatures for
3093 user-defined literals, associated standard library updates, and new
3094 @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3095
3096 This option enables functions to be overloaded for ordinary and UTF-8
3097 strings:
3098
3099 @smallexample
3100 int f(const char *); // #1
3101 int f(const char8_t *); // #2
3102 int v1 = f("text"); // Calls #1
3103 int v2 = f(u8"text"); // Calls #2
3104 @end smallexample
3105
3106 @noindent
3107 and introduces new signatures for user-defined literals:
3108
3109 @smallexample
3110 int operator""_udl1(char8_t);
3111 int v3 = u8'x'_udl1;
3112 int operator""_udl2(const char8_t*, std::size_t);
3113 int v4 = u8"text"_udl2;
3114 template<typename T, T...> int operator""_udl3();
3115 int v5 = u8"text"_udl3;
3116 @end smallexample
3117
3118 @noindent
3119 The change to the types of UTF-8 string and character literals introduces
3120 incompatibilities with ISO C++11 and later standards. For example, the
3121 following code is well-formed under ISO C++11, but is ill-formed when
3122 @option{-fchar8_t} is specified.
3123
3124 @smallexample
3125 const char *cp = u8"xx";// error: invalid conversion from
3126 // `const char8_t*' to `const char*'
3127 int f(const char*);
3128 auto v = f(u8"xx"); // error: invalid conversion from
3129 // `const char8_t*' to `const char*'
3130 std::string s@{u8"xx"@}; // error: no matching function for call to
3131 // `std::basic_string<char>::basic_string()'
3132 using namespace std::literals;
3133 s = u8"xx"s; // error: conversion from
3134 // `basic_string<char8_t>' to non-scalar
3135 // type `basic_string<char>' requested
3136 @end smallexample
3137
3138 @opindex fcheck-new
3139 @item -fcheck-new
3140 Check that the pointer returned by @code{operator new} is non-null
3141 before attempting to modify the storage allocated. This check is
3142 normally unnecessary because the C++ standard specifies that
3143 @code{operator new} only returns @code{0} if it is declared
3144 @code{throw()}, in which case the compiler always checks the
3145 return value even without this option. In all other cases, when
3146 @code{operator new} has a non-empty exception specification, memory
3147 exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3148 @samp{new (nothrow)}.
3149
3150 @opindex fconcepts
3151 @item -fconcepts
3152 Enable support for the C++ Concepts feature for constraining template
3153 arguments. With @option{-std=c++20} and above, Concepts are part of
3154 the language standard, so @option{-fconcepts} defaults to on.
3155
3156 Some constructs that were allowed by the earlier C++ Extensions for
3157 Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3158 into the standard, could additionally be enabled by
3159 @option{-fconcepts-ts}. The option @option{-fconcepts-ts} was deprecated
3160 in GCC 14 and removed in GCC 15; users are expected to convert their code
3161 to C++20 concepts.
3162
3163 @opindex fconstexpr-depth
3164 @item -fconstexpr-depth=@var{n}
3165 Set the maximum nested evaluation depth for C++11 constexpr functions
3166 to @var{n}. A limit is needed to detect endless recursion during
3167 constant expression evaluation. The minimum specified by the standard
3168 is 512.
3169
3170 @opindex fconstexpr-cache-depth
3171 @item -fconstexpr-cache-depth=@var{n}
3172 Set the maximum level of nested evaluation depth for C++11 constexpr
3173 functions that will be cached to @var{n}. This is a heuristic that
3174 trades off compilation speed (when the cache avoids repeated
3175 calculations) against memory consumption (when the cache grows very
3176 large from highly recursive evaluations). The default is 8. Very few
3177 users are likely to want to adjust it, but if your code does heavy
3178 constexpr calculations you might want to experiment to find which
3179 value works best for you.
3180
3181 @opindex fconstexpr-fp-except
3182 @item -fconstexpr-fp-except
3183 Annex F of the C standard specifies that IEC559 floating point
3184 exceptions encountered at compile time should not stop compilation.
3185 C++ compilers have historically not followed this guidance, instead
3186 treating floating point division by zero as non-constant even though
3187 it has a well defined value. This flag tells the compiler to give
3188 Annex F priority over other rules saying that a particular operation
3189 is undefined.
3190
3191 @smallexample
3192 constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3193 @end smallexample
3194
3195 @opindex fconstexpr-loop-limit
3196 @item -fconstexpr-loop-limit=@var{n}
3197 Set the maximum number of iterations for a loop in C++14 constexpr functions
3198 to @var{n}. A limit is needed to detect infinite loops during
3199 constant expression evaluation. The default is 262144 (1<<18).
3200
3201 @opindex fconstexpr-ops-limit
3202 @item -fconstexpr-ops-limit=@var{n}
3203 Set the maximum number of operations during a single constexpr evaluation.
3204 Even when number of iterations of a single loop is limited with the above limit,
3205 if there are several nested loops and each of them has many iterations but still
3206 smaller than the above limit, or if in a body of some loop or even outside
3207 of a loop too many expressions need to be evaluated, the resulting constexpr
3208 evaluation might take too long.
3209 The default is 33554432 (1<<25).
3210
3211 @opindex fcontracts
3212 @item -fcontracts
3213 Enable experimental support for the C++ Contracts feature, as briefly
3214 added to and then removed from the C++20 working paper (N4820). The
3215 implementation also includes proposed enhancements from papers P1290,
3216 P1332, and P1429. This functionality is intended mostly for those
3217 interested in experimentation towards refining the feature to get it
3218 into shape for a future C++ standard.
3219
3220 On violation of a checked contract, the violation handler is called.
3221 Users can replace the violation handler by defining
3222 @smallexample
3223 void
3224 handle_contract_violation (const std::experimental::contract_violation&);
3225 @end smallexample
3226
3227 There are different sets of additional flags that can be used together
3228 to specify which contracts will be checked and how, for N4820
3229 contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3230 used together.
3231
3232 @table @gcctabopt
3233 @opindex fcontract-mode
3234 @item -fcontract-mode=[on|off]
3235 Control whether any contracts have any semantics at all. Defaults to on.
3236
3237 @opindex fcontract-assumption-mode
3238 @item -fcontract-assumption-mode=[on|off]
3239 [N4820] Control whether contracts with level @samp{axiom}
3240 should have the assume semantic. Defaults to on.
3241
3242 @opindex fcontract-build-level
3243 @item -fcontract-build-level=[off|default|audit]
3244 [N4820] Specify which level of contracts to generate checks
3245 for. Defaults to @samp{default}.
3246
3247 @opindex fcontract-continuation-mode
3248 @item -fcontract-continuation-mode=[on|off]
3249 [N4820] Control whether to allow the program to continue executing
3250 after a contract violation. That is, do checked contracts have the
3251 @samp{maybe} semantic described below rather than the @samp{never}
3252 semantic. Defaults to off.
3253
3254 @opindex fcontract-role
3255 @item -fcontract-role=<name>:<default>,<audit>,<axiom>
3256 [P1332] Specify the concrete semantics for each contract level
3257 of a particular contract role.
3258
3259 @item -fcontract-semantic=[default|audit|axiom]:<semantic>
3260 [P1429] Specify the concrete semantic for a particular
3261 contract level.
3262
3263 @opindex fcontract-strict-declarations
3264 @item -fcontract-strict-declarations=[on|off]
3265 Control whether to reject adding contracts to a function after its
3266 first declaration. Defaults to off.
3267 @end table
3268
3269 The possible concrete semantics for that can be specified with
3270 @samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3271
3272 @table @code
3273 @item ignore
3274 This contract has no effect.
3275
3276 @item assume
3277 This contract is treated like C++23 @code{[[assume]]}.
3278
3279 @item check_never_continue
3280 @itemx never
3281 @itemx abort
3282 This contract is checked. If it fails, the violation handler is
3283 called. If the handler returns, @code{std::terminate} is called.
3284
3285 @item check_maybe_continue
3286 @itemx maybe
3287 This contract is checked. If it fails, the violation handler is
3288 called. If the handler returns, execution continues normally.
3289 @end table
3290
3291 @opindex fcoroutines
3292 @item -fcoroutines
3293 Enable support for the C++ coroutines extension (experimental).
3294
3295 @opindex fdiagnostics-all-candidates
3296 @item -fdiagnostics-all-candidates
3297 Permit the C++ front end to note all candidates during overload resolution
3298 failure, including when a deleted function is selected.
3299
3300 @item -fdump-lang-
3301 @itemx -fdump-lang-@var{switch}
3302 @itemx -fdump-lang-@var{switch}-@var{options}
3303 @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
3304 Control the dumping of C++-specific information. The @var{options}
3305 and @var{filename} portions behave as described in the
3306 @option{-fdump-tree} option. The following @var{switch} values are
3307 accepted:
3308
3309 @table @samp
3310 @item all
3311 Enable all of the below.
3312
3313 @opindex fdump-lang-class
3314 @item class
3315 Dump class hierarchy information. Virtual table information is emitted
3316 unless '@option{slim}' is specified.
3317
3318 @opindex fdump-lang-module
3319 @item module
3320 Dump module information. Options @option{lineno} (locations),
3321 @option{graph} (reachability), @option{blocks} (clusters),
3322 @option{uid} (serialization), @option{alias} (mergeable),
3323 @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
3324 (macros) may provide additional information.
3325
3326 @opindex fdump-lang-raw
3327 @item raw
3328 Dump the raw internal tree data.
3329
3330 @opindex fdump-lang-tinst
3331 @item tinst
3332 Dump the sequence of template instantiations, indented to show the
3333 depth of recursion. The @option{lineno} option adds the source
3334 location where the instantiation was triggered, and the
3335 @option{details} option also dumps pre-instantiation substitutions
3336 such as those performed during template argument deduction.
3337
3338 Lines in the .tinst dump start with @samp{I} for an instantiation,
3339 @samp{S} for another substitution, and @samp{R[IS]} for the reopened
3340 context of a deferred instantiation.
3341
3342 @end table
3343
3344 @opindex fno-elide-constructors
3345 @opindex felide-constructors
3346 @item -fno-elide-constructors
3347 The C++ standard allows an implementation to omit creating a temporary
3348 that is only used to initialize another object of the same type.
3349 Specifying this option disables that optimization, and forces G++ to
3350 call the copy constructor in all cases. This option also causes G++
3351 to call trivial member functions which otherwise would be expanded inline.
3352
3353 In C++17, the compiler is required to omit these temporaries, but this
3354 option still affects trivial member functions.
3355
3356 @opindex fno-enforce-eh-specs
3357 @opindex fenforce-eh-specs
3358 @item -fno-enforce-eh-specs
3359 Don't generate code to check for violation of exception specifications
3360 at run time. This option violates the C++ standard, but may be useful
3361 for reducing code size in production builds, much like defining
3362 @code{NDEBUG}. This does not give user code permission to throw
3363 exceptions in violation of the exception specifications; the compiler
3364 still optimizes based on the specifications, so throwing an
3365 unexpected exception results in undefined behavior at run time.
3366
3367 @opindex fextern-tls-init
3368 @opindex fno-extern-tls-init
3369 @item -fextern-tls-init
3370 @itemx -fno-extern-tls-init
3371 The C++11 and OpenMP standards allow @code{thread_local} and
3372 @code{threadprivate} variables to have dynamic (runtime)
3373 initialization. To support this, any use of such a variable goes
3374 through a wrapper function that performs any necessary initialization.
3375 When the use and definition of the variable are in the same
3376 translation unit, this overhead can be optimized away, but when the
3377 use is in a different translation unit there is significant overhead
3378 even if the variable doesn't actually need dynamic initialization. If
3379 the programmer can be sure that no use of the variable in a
3380 non-defining TU needs to trigger dynamic initialization (either
3381 because the variable is statically initialized, or a use of the
3382 variable in the defining TU will be executed before any uses in
3383 another TU), they can avoid this overhead with the
3384 @option{-fno-extern-tls-init} option.
3385
3386 On targets that support symbol aliases, the default is
3387 @option{-fextern-tls-init}. On targets that do not support symbol
3388 aliases, the default is @option{-fno-extern-tls-init}.
3389
3390 @opindex ffold-simple-inlines
3391 @opindex fno-fold-simple-inlines
3392 @item -ffold-simple-inlines
3393 @itemx -fno-fold-simple-inlines
3394 Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3395 @code{std::addressof}, @code{std::to_underlying}
3396 and @code{std::as_const}. In contrast to inlining, this
3397 means no debug information will be generated for such calls. Since these
3398 functions are rarely interesting to debug, this flag is enabled by default
3399 unless @option{-fno-inline} is active.
3400
3401 @opindex fno-gnu-keywords
3402 @opindex fgnu-keywords
3403 @item -fno-gnu-keywords
3404 Do not recognize @code{typeof} as a keyword, so that code can use this
3405 word as an identifier. You can use the keyword @code{__typeof__} instead.
3406 This option is implied by the strict ISO C++ dialects: @option{-ansi},
3407 @option{-std=c++98}, @option{-std=c++11}, etc.
3408
3409 @opindex fno-immediate-escalation
3410 @opindex fimmediate-escalation
3411 @item -fno-immediate-escalation
3412 Do not enable immediate function escalation whereby certain functions
3413 can be promoted to consteval, as specified in P2564R3. For example:
3414
3415 @example
3416 consteval int id(int i) @{ return i; @}
3417
3418 constexpr int f(auto t)
3419 @{
3420 return t + id(t); // id causes f<int> to be promoted to consteval
3421 @}
3422
3423 void g(int i)
3424 @{
3425 f (3);
3426 @}
3427 @end example
3428
3429 compiles in C++20: @code{f} is an immediate-escalating function (due to
3430 the @code{auto} it is a function template and is declared @code{constexpr})
3431 and @code{id(t)} is an immediate-escalating expression, so @code{f} is
3432 promoted to @code{consteval}. Consequently, the call to @code{id(t)}
3433 is in an immediate context, so doesn't have to produce a constant (that
3434 is the mechanism allowing consteval function composition). However,
3435 with @option{-fno-immediate-escalation}, @code{f} is not promoted to
3436 @code{consteval}, and since the call to consteval function @code{id(t)}
3437 is not a constant expression, the compiler rejects the code.
3438
3439 This option is turned on by default; it is only effective in C++20 mode
3440 or later.
3441
3442 @opindex fimplicit-constexpr
3443 @item -fimplicit-constexpr
3444 Make inline functions implicitly constexpr, if they satisfy the
3445 requirements for a constexpr function. This option can be used in
3446 C++14 mode or later. This can result in initialization changing from
3447 dynamic to static and other optimizations.
3448
3449 @opindex fno-implicit-templates
3450 @opindex fimplicit-templates
3451 @item -fno-implicit-templates
3452 Never emit code for non-inline templates that are instantiated
3453 implicitly (i.e.@: by use); only emit code for explicit instantiations.
3454 If you use this option, you must take care to structure your code to
3455 include all the necessary explicit instantiations to avoid getting
3456 undefined symbols at link time.
3457 @xref{Template Instantiation}, for more information.
3458
3459 @opindex fno-implicit-inline-templates
3460 @opindex fimplicit-inline-templates
3461 @item -fno-implicit-inline-templates
3462 Don't emit code for implicit instantiations of inline templates, either.
3463 The default is to handle inlines differently so that compiles with and
3464 without optimization need the same set of explicit instantiations.
3465
3466 @opindex fno-implement-inlines
3467 @opindex fimplement-inlines
3468 @item -fno-implement-inlines
3469 To save space, do not emit out-of-line copies of inline functions
3470 controlled by @code{#pragma implementation}. This causes linker
3471 errors if these functions are not inlined everywhere they are called.
3472
3473 @opindex fmodules
3474 @opindex fno-modules
3475 @item -fmodules
3476 @itemx -fno-modules
3477 Enable support for C++20 modules (@pxref{C++ Modules}). The
3478 @option{-fno-modules} is usually not needed, as that is the
3479 default. Even though this is a C++20 feature, it is not currently
3480 implicitly enabled by selecting that standard version.
3481
3482 @opindex fmodule-header
3483 @item -fmodule-header
3484 @itemx -fmodule-header=user
3485 @itemx -fmodule-header=system
3486 Compile a header file to create an importable header unit.
3487
3488 @opindex fmodule-implicit-inline
3489 @item -fmodule-implicit-inline
3490 Member functions defined in their class definitions are not implicitly
3491 inline for modular code. This is different to traditional C++
3492 behavior, for good reasons. However, it may result in a difficulty
3493 during code porting. This option makes such function definitions
3494 implicitly inline. It does however generate an ABI incompatibility,
3495 so you must use it everywhere or nowhere. (Such definitions outside
3496 of a named module remain implicitly inline, regardless.)
3497
3498 @opindex fno-module-lazy
3499 @opindex fmodule-lazy
3500 @item -fno-module-lazy
3501 Disable lazy module importing and module mapper creation.
3502
3503 @vindex CXX_MODULE_MAPPER @r{environment variable}
3504 @opindex fmodule-mapper
3505 @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3506 @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3507 @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3508 @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3509 @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3510 @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
3511 An oracle to query for module name to filename mappings. If
3512 unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3513 and if that is unset, an in-process default is provided.
3514
3515 @opindex fmodule-only
3516 @item -fmodule-only
3517 Only emit the Compiled Module Interface, inhibiting any object file.
3518
3519 @opindex fms-extensions
3520 @item -fms-extensions
3521 Disable Wpedantic warnings about constructs used in MFC, such as implicit
3522 int and getting a pointer to member function via non-standard syntax.
3523
3524 @opindex fnew-inheriting-ctors
3525 @item -fnew-inheriting-ctors
3526 Enable the P0136 adjustment to the semantics of C++11 constructor
3527 inheritance. This is part of C++17 but also considered to be a Defect
3528 Report against C++11 and C++14. This flag is enabled by default
3529 unless @option{-fabi-version=10} or lower is specified.
3530
3531 @opindex fnew-ttp-matching
3532 @item -fnew-ttp-matching
3533 Enable the P0522 resolution to Core issue 150, template template
3534 parameters and default arguments: this allows a template with default
3535 template arguments as an argument for a template template parameter
3536 with fewer template parameters. This flag is enabled by default for
3537 @option{-std=c++17}.
3538
3539 @opindex fno-nonansi-builtins
3540 @opindex fnonansi-builtins
3541 @item -fno-nonansi-builtins
3542 Disable built-in declarations of functions that are not mandated by
3543 ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3544 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
3545
3546 @opindex fnothrow-opt
3547 @item -fnothrow-opt
3548 Treat a @code{throw()} exception specification as if it were a
3549 @code{noexcept} specification to reduce or eliminate the text size
3550 overhead relative to a function with no exception specification. If
3551 the function has local variables of types with non-trivial
3552 destructors, the exception specification actually makes the
3553 function smaller because the EH cleanups for those variables can be
3554 optimized away. The semantic effect is that an exception thrown out of
3555 a function with such an exception specification results in a call
3556 to @code{terminate} rather than @code{unexpected}.
3557
3558 @opindex fno-operator-names
3559 @opindex foperator-names
3560 @item -fno-operator-names
3561 Do not treat the operator name keywords @code{and}, @code{bitand},
3562 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3563 synonyms as keywords.
3564
3565 @opindex fno-optional-diags
3566 @opindex foptional-diags
3567 @item -fno-optional-diags
3568 Disable diagnostics that the standard says a compiler does not need to
3569 issue. Currently, the only such diagnostic issued by G++ is the one for
3570 a name having multiple meanings within a class.
3571
3572 @opindex fno-pretty-templates
3573 @opindex fpretty-templates
3574 @item -fno-pretty-templates
3575 When an error message refers to a specialization of a function
3576 template, the compiler normally prints the signature of the
3577 template followed by the template arguments and any typedefs or
3578 typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3579 rather than @code{void f(int)}) so that it's clear which template is
3580 involved. When an error message refers to a specialization of a class
3581 template, the compiler omits any template arguments that match
3582 the default template arguments for that template. If either of these
3583 behaviors make it harder to understand the error message rather than
3584 easier, you can use @option{-fno-pretty-templates} to disable them.
3585
3586 @opindex frange-for-ext-temps
3587 @item -frange-for-ext-temps
3588 Enable lifetime extension of C++ range based for temporaries.
3589 With @option{-std=c++23} and above this is part of the language standard,
3590 so lifetime of the temporaries is extended until the end of the loop
3591 by default. This option allows enabling that behavior also
3592 in earlier versions of the standard.
3593
3594 @opindex fno-rtti
3595 @opindex frtti
3596 @item -fno-rtti
3597 Disable generation of information about every class with virtual
3598 functions for use by the C++ run-time type identification features
3599 (@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3600 of the language, you can save some space by using this flag. Note that
3601 exception handling uses the same information, but G++ generates it as
3602 needed. The @code{dynamic_cast} operator can still be used for casts that
3603 do not require run-time type information, i.e.@: casts to @code{void *} or to
3604 unambiguous base classes.
3605
3606 Mixing code compiled with @option{-frtti} with that compiled with
3607 @option{-fno-rtti} may not work. For example, programs may
3608 fail to link if a class compiled with @option{-fno-rtti} is used as a base
3609 for a class compiled with @option{-frtti}.
3610
3611 @opindex fsized-deallocation
3612 @item -fsized-deallocation
3613 Enable the built-in global declarations
3614 @smallexample
3615 void operator delete (void *, std::size_t) noexcept;
3616 void operator delete[] (void *, std::size_t) noexcept;
3617 @end smallexample
3618 as introduced in C++14. This is useful for user-defined replacement
3619 deallocation functions that, for example, use the size of the object
3620 to make deallocation faster. Enabled by default under
3621 @option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3622 warns about places that might want to add a definition.
3623
3624 @opindex fstrict-enums
3625 @item -fstrict-enums
3626 Allow the compiler to optimize using the assumption that a value of
3627 enumerated type can only be one of the values of the enumeration (as
3628 defined in the C++ standard; basically, a value that can be
3629 represented in the minimum number of bits needed to represent all the
3630 enumerators). This assumption may not be valid if the program uses a
3631 cast to convert an arbitrary integer value to the enumerated type.
3632 This option has no effect for an enumeration type with a fixed underlying
3633 type.
3634
3635 @opindex fstrong-eval-order
3636 @item -fstrong-eval-order
3637 @itemx -fstrong-eval-order=@var{kind}
3638 Evaluate member access, array subscripting, and shift expressions in
3639 left-to-right order, and evaluate assignment in right-to-left order,
3640 as adopted for C++17. @option{-fstrong-eval-order} is equivalent to
3641 @option{-fstrong-eval-order=all},
3642 and is enabled by default with @option{-std=c++17} or later.
3643
3644 @option{-fstrong-eval-order=some} enables just the ordering of member
3645 access and shift expressions, and is the default for C++ dialects prior to
3646 C++17.
3647
3648 @option{-fstrong-eval-order=none} is equivalent to
3649 @option{-fno-strong-eval-order}.
3650
3651 @opindex ftemplate-backtrace-limit
3652 @item -ftemplate-backtrace-limit=@var{n}
3653 Set the maximum number of template instantiation notes for a single
3654 warning or error to @var{n}. The default value is 10.
3655
3656 @opindex ftemplate-depth
3657 @item -ftemplate-depth=@var{n}
3658 Set the maximum instantiation depth for template classes to @var{n}.
3659 A limit on the template instantiation depth is needed to detect
3660 endless recursions during template class instantiation. ANSI/ISO C++
3661 conforming programs must not rely on a maximum depth greater than 17
3662 (changed to 1024 in C++11). The default value is 900, as the compiler
3663 can run out of stack space before hitting 1024 in some situations.
3664
3665 @opindex fno-threadsafe-statics
3666 @opindex fthreadsafe-statics
3667 @item -fno-threadsafe-statics
3668 Do not emit the extra code to use the routines specified in the C++
3669 ABI for thread-safe initialization of local statics. You can use this
3670 option to reduce code size slightly in code that doesn't need to be
3671 thread-safe.
3672
3673 @opindex fuse-cxa-atexit
3674 @item -fuse-cxa-atexit
3675 Register destructors for objects with static storage duration with the
3676 @code{__cxa_atexit} function rather than the @code{atexit} function.
3677 This option is required for fully standards-compliant handling of static
3678 destructors, but only works if your C library supports
3679 @code{__cxa_atexit}.
3680
3681 @opindex fno-use-cxa-get-exception-ptr
3682 @opindex fuse-cxa-get-exception-ptr
3683 @item -fno-use-cxa-get-exception-ptr
3684 Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3685 causes @code{std::uncaught_exception} to be incorrect, but is necessary
3686 if the runtime routine is not available.
3687
3688 @opindex fvisibility-inlines-hidden
3689 @item -fvisibility-inlines-hidden
3690 This switch declares that the user does not attempt to compare
3691 pointers to inline functions or methods where the addresses of the two functions
3692 are taken in different shared objects.
3693
3694 The effect of this is that GCC may, effectively, mark inline methods with
3695 @code{__attribute__ ((visibility ("hidden")))} so that they do not
3696 appear in the export table of a DSO and do not require a PLT indirection
3697 when used within the DSO@. Enabling this option can have a dramatic effect
3698 on load and link times of a DSO as it massively reduces the size of the
3699 dynamic export table when the library makes heavy use of templates.
3700
3701 The behavior of this switch is not quite the same as marking the
3702 methods as hidden directly, because it does not affect static variables
3703 local to the function or cause the compiler to deduce that
3704 the function is defined in only one shared object.
3705
3706 You may mark a method as having a visibility explicitly to negate the
3707 effect of the switch for that method. For example, if you do want to
3708 compare pointers to a particular inline method, you might mark it as
3709 having default visibility. Marking the enclosing class with explicit
3710 visibility has no effect.
3711
3712 Explicitly instantiated inline methods are unaffected by this option
3713 as their linkage might otherwise cross a shared library boundary.
3714 @xref{Template Instantiation}.
3715
3716 @opindex fvisibility-ms-compat
3717 @item -fvisibility-ms-compat
3718 This flag attempts to use visibility settings to make GCC's C++
3719 linkage model compatible with that of Microsoft Visual Studio.
3720
3721 The flag makes these changes to GCC's linkage model:
3722
3723 @enumerate
3724 @item
3725 It sets the default visibility to @code{hidden}, like
3726 @option{-fvisibility=hidden}.
3727
3728 @item
3729 Types, but not their members, are not hidden by default.
3730
3731 @item
3732 The One Definition Rule is relaxed for types without explicit
3733 visibility specifications that are defined in more than one
3734 shared object: those declarations are permitted if they are
3735 permitted when this option is not used.
3736 @end enumerate
3737
3738 In new code it is better to use @option{-fvisibility=hidden} and
3739 export those classes that are intended to be externally visible.
3740 Unfortunately it is possible for code to rely, perhaps accidentally,
3741 on the Visual Studio behavior.
3742
3743 Among the consequences of these changes are that static data members
3744 of the same type with the same name but defined in different shared
3745 objects are different, so changing one does not change the other;
3746 and that pointers to function members defined in different shared
3747 objects may not compare equal. When this flag is given, it is a
3748 violation of the ODR to define types with the same name differently.
3749
3750 @opindex fno-weak
3751 @opindex fweak
3752 @item -fno-weak
3753 Do not use weak symbol support, even if it is provided by the linker.
3754 By default, G++ uses weak symbols if they are available. This
3755 option exists only for testing, and should not be used by end-users;
3756 it results in inferior code and has no benefits. This option may
3757 be removed in a future release of G++.
3758
3759 @opindex fext-numeric-literals
3760 @opindex fno-ext-numeric-literals
3761 @item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
3762 Accept imaginary, fixed-point, or machine-defined
3763 literal number suffixes as GNU extensions.
3764 When this option is turned off these suffixes are treated
3765 as C++11 user-defined literal numeric suffixes.
3766 This is on by default for all pre-C++11 dialects and all GNU dialects:
3767 @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3768 @option{-std=gnu++14}.
3769 This option is off by default
3770 for ISO C++11 onwards (@option{-std=c++11}, ...).
3771
3772 @opindex nostdinc++
3773 @item -nostdinc++
3774 Do not search for header files in the standard directories specific to
3775 C++, but do still search the other standard directories. (This option
3776 is used when building the C++ library.)
3777
3778 @opindex flang-info-include-translate
3779 @opindex flang-info-include-translate-not
3780 @item -flang-info-include-translate
3781 @itemx -flang-info-include-translate-not
3782 @itemx -flang-info-include-translate=@var{header}
3783 Inform of include translation events. The first will note accepted
3784 include translations, the second will note declined include
3785 translations. The @var{header} form will inform of include
3786 translations relating to that specific header. If @var{header} is of
3787 the form @code{"user"} or @code{<system>} it will be resolved to a
3788 specific user or system header using the include path.
3789
3790 @opindex flang-info-module-cmi
3791 @item -flang-info-module-cmi
3792 @itemx -flang-info-module-cmi=@var{module}
3793 Inform of Compiled Module Interface pathnames. The first will note
3794 all read CMI pathnames. The @var{module} form will not reading a
3795 specific module's CMI. @var{module} may be a named module or a
3796 header-unit (the latter indicated by either being a pathname containing
3797 directory separators or enclosed in @code{<>} or @code{""}).
3798
3799 @opindex stdlib
3800 @item -stdlib=@var{libstdc++,libc++}
3801 When G++ is configured to support this option, it allows specification of
3802 alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3803 (the default, native C++ runtime for G++) and @var{libc++} which is the
3804 C++ runtime installed on some operating systems (e.g. Darwin versions from
3805 Darwin11 onwards). The option switches G++ to use the headers from the
3806 specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3807 when a C++ runtime is required for linking.
3808 @end table
3809
3810 In addition, these warning options have meanings only for C++ programs:
3811
3812 @table @gcctabopt
3813 @opindex Wabi-tag
3814 @item -Wabi-tag @r{(C++ and Objective-C++ only)}
3815 Warn when a type with an ABI tag is used in a context that does not
3816 have that ABI tag. See @ref{C++ Attributes} for more information
3817 about ABI tags.
3818
3819 @opindex Wcomma-subscript
3820 @opindex Wno-comma-subscript
3821 @item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
3822 Warn about uses of a comma expression within a subscripting expression.
3823 This usage was deprecated in C++20 and is going to be removed in C++23.
3824 However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3825
3826 @smallexample
3827 @group
3828 void f(int *a, int b, int c) @{
3829 a[b,c]; // deprecated in C++20, invalid in C++23
3830 a[(b,c)]; // OK
3831 @}
3832 @end group
3833 @end smallexample
3834
3835 In C++23 it is valid to have comma separated expressions in a subscript
3836 when an overloaded subscript operator is found and supports the right
3837 number and types of arguments. G++ will accept the formerly valid syntax
3838 for code that is not valid in C++23 but used to be valid but deprecated
3839 in C++20 with a pedantic warning that can be disabled with
3840 @option{-Wno-comma-subscript}.
3841
3842 Enabled by default with @option{-std=c++20} unless
3843 @option{-Wno-deprecated}, and after @option{-std=c++23} regardless of
3844 @option{-Wno-deprecated}. Before @option{-std=c++20}, enabled with
3845 explicit @option{-Wdeprecated}.
3846
3847 This warning is upgraded to an error by @option{-pedantic-errors} in
3848 C++23 mode or later.
3849
3850 @opindex Wctad-maybe-unsupported
3851 @opindex Wno-ctad-maybe-unsupported
3852 @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
3853 Warn when performing class template argument deduction (CTAD) on a type with
3854 no explicitly written deduction guides. This warning will point out cases
3855 where CTAD succeeded only because the compiler synthesized the implicit
3856 deduction guides, which might not be what the programmer intended. Certain
3857 style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3858 types that are designed to support CTAD. This warning can be suppressed with
3859 the following pattern:
3860
3861 @smallexample
3862 struct allow_ctad_t; // any name works
3863 template <typename T> struct S @{
3864 S(T) @{ @}
3865 @};
3866 // Guide with incomplete parameter type will never be considered.
3867 S(allow_ctad_t) -> S<void>;
3868 @end smallexample
3869
3870 @opindex Wctor-dtor-privacy
3871 @opindex Wno-ctor-dtor-privacy
3872 @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
3873 Warn when a class seems unusable because all the constructors or
3874 destructors in that class are private, and it has neither friends nor
3875 public static member functions. Also warn if there are no non-private
3876 methods, and there's at least one private member function that isn't
3877 a constructor or destructor.
3878
3879 @opindex Wdangling-reference
3880 @opindex Wno-dangling-reference
3881 @item -Wdangling-reference @r{(C++ and Objective-C++ only)}
3882 Warn when a reference is bound to a temporary whose lifetime has ended.
3883 For example:
3884
3885 @smallexample
3886 int n = 1;
3887 const int& r = std::max(n - 1, n + 1); // r is dangling
3888 @end smallexample
3889
3890 In the example above, two temporaries are created, one for each
3891 argument, and a reference to one of the temporaries is returned.
3892 However, both temporaries are destroyed at the end of the full
3893 expression, so the reference @code{r} is dangling. This warning
3894 also detects dangling references in member initializer lists:
3895
3896 @smallexample
3897 const int& f(const int& i) @{ return i; @}
3898 struct S @{
3899 const int &r; // r is dangling
3900 S() : r(f(10)) @{ @}
3901 @};
3902 @end smallexample
3903
3904 Member functions are checked as well, but only their object argument:
3905
3906 @smallexample
3907 struct S @{
3908 const S& self () @{ return *this; @}
3909 @};
3910 const S& s = S().self(); // s is dangling
3911 @end smallexample
3912
3913 Certain functions are safe in this respect, for example @code{std::use_facet}:
3914 they take and return a reference, but they don't return one of its arguments,
3915 which can fool the warning. Such functions can be excluded from the warning
3916 by wrapping them in a @code{#pragma}:
3917
3918 @smallexample
3919 #pragma GCC diagnostic push
3920 #pragma GCC diagnostic ignored "-Wdangling-reference"
3921 const T& foo (const T&) @{ @dots{} @}
3922 #pragma GCC diagnostic pop
3923 @end smallexample
3924
3925 The @code{#pragma} can also surround the class; in that case, the warning
3926 will be disabled for all the member functions.
3927
3928 @option{-Wdangling-reference} also warns about code like
3929
3930 @smallexample
3931 auto p = std::minmax(1, 2);
3932 @end smallexample
3933
3934 where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3935 both references dangle after the end of the full expression that contains
3936 the call to @code{std::minmax}.
3937
3938 The warning does not warn for @code{std::span}-like classes. We consider
3939 classes of the form:
3940
3941 @smallexample
3942 template<typename T>
3943 struct Span @{
3944 T* data_;
3945 std::size len_;
3946 @};
3947 @end smallexample
3948
3949 as @code{std::span}-like; that is, the class is a non-union class
3950 that has a pointer data member and a trivial destructor.
3951
3952 The warning can be disabled by using the @code{gnu::no_dangling} attribute
3953 (@pxref{C++ Attributes}).
3954
3955 This warning is enabled by @option{-Wextra}.
3956
3957 @opindex Wdelete-non-virtual-dtor
3958 @opindex Wno-delete-non-virtual-dtor
3959 @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
3960 Warn when @code{delete} is used to destroy an instance of a class that
3961 has virtual functions and non-virtual destructor. It is unsafe to delete
3962 an instance of a derived class through a pointer to a base class if the
3963 base class does not have a virtual destructor. This warning is enabled
3964 by @option{-Wall}.
3965
3966 @opindex Wdeprecated-copy
3967 @opindex Wno-deprecated-copy
3968 @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
3969 Warn that the implicit declaration of a copy constructor or copy
3970 assignment operator is deprecated if the class has a user-provided
3971 copy constructor or copy assignment operator, in C++11 and up. This
3972 warning is enabled by @option{-Wextra}. With
3973 @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3974 user-provided destructor.
3975
3976 @opindex Wdeprecated-enum-enum-conversion
3977 @opindex Wno-deprecated-enum-enum-conversion
3978 @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
3979 Disable the warning about the case when the usual arithmetic conversions
3980 are applied on operands where one is of enumeration type and the other is
3981 of a different enumeration type. This conversion was deprecated in C++20.
3982 For example:
3983
3984 @smallexample
3985 enum E1 @{ e @};
3986 enum E2 @{ f @};
3987 int k = f - e;
3988 @end smallexample
3989
3990 @option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3991 @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3992 by @option{-Wenum-conversion} or @option{-Wdeprecated}.
3993
3994 @opindex Wdeprecated-enum-float-conversion
3995 @opindex Wno-deprecated-enum-float-conversion
3996 @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
3997 Disable the warning about the case when the usual arithmetic conversions
3998 are applied on operands where one is of enumeration type and the other is
3999 of a floating-point type. This conversion was deprecated in C++20. For
4000 example:
4001
4002 @smallexample
4003 enum E1 @{ e @};
4004 enum E2 @{ f @};
4005 bool b = e <= 3.7;
4006 @end smallexample
4007
4008 @option{-Wdeprecated-enum-float-conversion} is enabled by default with
4009 @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
4010 by @option{-Wenum-conversion} or @option{-Wdeprecated}.
4011
4012 @opindex Wdeprecated-literal-operator
4013 @opindex Wno-deprecated-literal-operator
4014 @item -Wdeprecated-literal-operator @r{(C++ and Objective-C++ only)}
4015 Warn that the declaration of a user-defined literal operator with a
4016 space before the suffix is deprecated. This warning is enabled by
4017 default in C++23, or with explicit @option{-Wdeprecated}.
4018
4019 @smallexample
4020 string operator "" _i18n(const char*, std::size_t); // deprecated
4021 string operator ""_i18n(const char*, std::size_t); // preferred
4022 @end smallexample
4023
4024 @opindex Wdeprecated-variadic-comma-omission
4025 @opindex Wno-deprecated-variadic-comma-omission
4026 @item -Wdeprecated-variadic-comma-omission @r{(C++ and Objective-C++ only)}
4027 Warn that omitting a comma before the varargs @code{...} at the end of
4028 a function parameter list is deprecated. This warning is enabled by
4029 default in C++26, or with explicit @option{-Wdeprecated}.
4030
4031 @smallexample
4032 void f1(int...); // deprecated
4033 void f1(int, ...); // preferred
4034 template <typename ...T>
4035 void f2(T...); // ok
4036 template <typename ...T>
4037 void f3(T......); // deprecated
4038 @end smallexample
4039
4040 @opindex Welaborated-enum-base
4041 @opindex Wno-elaborated-enum-base
4042 @item -Wno-elaborated-enum-base
4043 For C++11 and above, warn if an (invalid) additional enum-base is used
4044 in an elaborated-type-specifier. That is, if an enum with given
4045 underlying type and no enumerator list is used in a declaration other
4046 than just a standalone declaration of the enum. Enabled by default. This
4047 warning is upgraded to an error with -pedantic-errors.
4048
4049 @opindex Winit-list-lifetime
4050 @opindex Wno-init-list-lifetime
4051 @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
4052 Do not warn about uses of @code{std::initializer_list} that are likely
4053 to result in dangling pointers. Since the underlying array for an
4054 @code{initializer_list} is handled like a normal C++ temporary object,
4055 it is easy to inadvertently keep a pointer to the array past the end
4056 of the array's lifetime. For example:
4057
4058 @itemize @bullet
4059 @item
4060 If a function returns a temporary @code{initializer_list}, or a local
4061 @code{initializer_list} variable, the array's lifetime ends at the end
4062 of the return statement, so the value returned has a dangling pointer.
4063
4064 @item
4065 If a new-expression creates an @code{initializer_list}, the array only
4066 lives until the end of the enclosing full-expression, so the
4067 @code{initializer_list} in the heap has a dangling pointer.
4068
4069 @item
4070 When an @code{initializer_list} variable is assigned from a
4071 brace-enclosed initializer list, the temporary array created for the
4072 right side of the assignment only lives until the end of the
4073 full-expression, so at the next statement the @code{initializer_list}
4074 variable has a dangling pointer.
4075
4076 @smallexample
4077 // li's initial underlying array lives as long as li
4078 std::initializer_list<int> li = @{ 1,2,3 @};
4079 // assignment changes li to point to a temporary array
4080 li = @{ 4, 5 @};
4081 // now the temporary is gone and li has a dangling pointer
4082 int i = li.begin()[0] // undefined behavior
4083 @end smallexample
4084
4085 @item
4086 When a list constructor stores the @code{begin} pointer from the
4087 @code{initializer_list} argument, this doesn't extend the lifetime of
4088 the array, so if a class variable is constructed from a temporary
4089 @code{initializer_list}, the pointer is left dangling by the end of
4090 the variable declaration statement.
4091
4092 @end itemize
4093
4094 @opindex Winvalid-constexpr
4095 @opindex Wno-invalid-constexpr
4096 @item -Winvalid-constexpr
4097
4098 Warn when a function never produces a constant expression. In C++20
4099 and earlier, for every @code{constexpr} function and function template,
4100 there must be at least one set of function arguments in at least one
4101 instantiation such that an invocation of the function or constructor
4102 could be an evaluated subexpression of a core constant expression.
4103 C++23 removed this restriction, so it's possible to have a function
4104 or a function template marked @code{constexpr} for which no invocation
4105 satisfies the requirements of a core constant expression.
4106
4107 This warning is enabled as a pedantic warning by default in C++20 and
4108 earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
4109 which case it will be an ordinary warning. For example:
4110
4111 @smallexample
4112 void f (int& i);
4113 constexpr void
4114 g (int& i)
4115 @{
4116 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
4117 f(i);
4118 @}
4119 @end smallexample
4120
4121 @opindex Winvalid-imported-macros
4122 @opindex Wno-invalid-imported-macros
4123 @item -Winvalid-imported-macros
4124 Verify all imported macro definitions are valid at the end of
4125 compilation. This is not enabled by default, as it requires
4126 additional processing to determine. It may be useful when preparing
4127 sets of header-units to ensure consistent macros.
4128
4129 @opindex Wliteral-suffix
4130 @opindex Wno-literal-suffix
4131 @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
4132 Do not warn when a string or character literal is followed by a
4133 ud-suffix which does not begin with an underscore. As a conforming
4134 extension, GCC treats such suffixes as separate preprocessing tokens
4135 in order to maintain backwards compatibility with code that uses
4136 formatting macros from @code{<inttypes.h>}. For example:
4137
4138 @smallexample
4139 #define __STDC_FORMAT_MACROS
4140 #include <inttypes.h>
4141 #include <stdio.h>
4142
4143 int main() @{
4144 int64_t i64 = 123;
4145 printf("My int64: %" PRId64"\n", i64);
4146 @}
4147 @end smallexample
4148
4149 In this case, @code{PRId64} is treated as a separate preprocessing token.
4150
4151 This option also controls warnings when a user-defined literal
4152 operator is declared with a literal suffix identifier that doesn't
4153 begin with an underscore. Literal suffix identifiers that don't begin
4154 with an underscore are reserved for future standardization.
4155
4156 These warnings are enabled by default.
4157
4158 @opindex Wnarrowing
4159 @opindex Wno-narrowing
4160 @item -Wno-narrowing @r{(C++ and Objective-C++ only)}
4161 For C++11 and later standards, narrowing conversions are diagnosed by default,
4162 as required by the standard. A narrowing conversion from a constant produces
4163 an error, and a narrowing conversion from a non-constant produces a warning,
4164 but @option{-Wno-narrowing} suppresses the diagnostic.
4165 Note that this does not affect the meaning of well-formed code;
4166 narrowing conversions are still considered ill-formed in SFINAE contexts.
4167
4168 With @option{-Wnarrowing} in C++98, warn when a narrowing
4169 conversion prohibited by C++11 occurs within
4170 @samp{@{ @}}, e.g.
4171
4172 @smallexample
4173 int i = @{ 2.2 @}; // error: narrowing from double to int
4174 @end smallexample
4175
4176 This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
4177
4178 @opindex Wnoexcept
4179 @opindex Wno-noexcept
4180 @item -Wnoexcept @r{(C++ and Objective-C++ only)}
4181 Warn when a noexcept-expression evaluates to false because of a call
4182 to a function that does not have a non-throwing exception
4183 specification (i.e. @code{throw()} or @code{noexcept}) but is known by
4184 the compiler to never throw an exception.
4185
4186 @opindex Wnoexcept-type
4187 @opindex Wno-noexcept-type
4188 @item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
4189 Warn if the C++17 feature making @code{noexcept} part of a function
4190 type changes the mangled name of a symbol relative to C++14. Enabled
4191 by @option{-Wabi} and @option{-Wc++17-compat}.
4192
4193 As an example:
4194
4195 @smallexample
4196 template <class T> void f(T t) @{ t(); @};
4197 void g() noexcept;
4198 void h() @{ f(g); @}
4199 @end smallexample
4200
4201 @noindent
4202 In C++14, @code{f} calls @code{f<void(*)()>}, but in
4203 C++17 it calls @code{f<void(*)()noexcept>}.
4204
4205 @opindex Wclass-memaccess
4206 @opindex Wno-class-memaccess
4207 @item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
4208 Warn when the destination of a call to a raw memory function such as
4209 @code{memset} or @code{memcpy} is an object of class type, and when writing
4210 into such an object might bypass the class non-trivial or deleted constructor
4211 or copy assignment, violate const-correctness or encapsulation, or corrupt
4212 virtual table pointers. Modifying the representation of such objects may
4213 violate invariants maintained by member functions of the class. For example,
4214 the call to @code{memset} below is undefined because it modifies a non-trivial
4215 class object and is, therefore, diagnosed. The safe way to either initialize
4216 or clear the storage of objects of such types is by using the appropriate
4217 constructor or assignment operator, if one is available.
4218 @smallexample
4219 std::string str = "abc";
4220 memset (&str, 0, sizeof str);
4221 @end smallexample
4222 The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4223 Explicitly casting the pointer to the class object to @code{void *} or
4224 to a type that can be safely accessed by the raw memory function suppresses
4225 the warning.
4226
4227 @opindex Wnon-virtual-dtor
4228 @opindex Wno-non-virtual-dtor
4229 @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
4230 Warn when a class has virtual functions and an accessible non-virtual
4231 destructor itself or in an accessible polymorphic base class, in which
4232 case it is possible but unsafe to delete an instance of a derived
4233 class through a pointer to the class itself or base class. This
4234 warning is automatically enabled if @option{-Weffc++} is specified.
4235 The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4236 should be preferred because it warns about the unsafe cases without false
4237 positives.
4238
4239 @opindex Wregister
4240 @opindex Wno-register
4241 @item -Wregister @r{(C++ and Objective-C++ only)}
4242 Warn on uses of the @code{register} storage class specifier, except
4243 when it is part of the GNU @ref{Explicit Register Variables} extension.
4244 The use of the @code{register} keyword as storage class specifier has
4245 been deprecated in C++11 and removed in C++17.
4246 Enabled by default with @option{-std=c++17}.
4247
4248 @opindex Wreorder
4249 @opindex Wno-reorder
4250 @cindex reordering, warning
4251 @cindex warning for reordering of member initializers
4252 @item -Wreorder @r{(C++ and Objective-C++ only)}
4253 Warn when the order of member initializers given in the code does not
4254 match the order in which they must be executed. For instance:
4255
4256 @smallexample
4257 struct A @{
4258 int i;
4259 int j;
4260 A(): j (0), i (1) @{ @}
4261 @};
4262 @end smallexample
4263
4264 @noindent
4265 The compiler rearranges the member initializers for @code{i}
4266 and @code{j} to match the declaration order of the members, emitting
4267 a warning to that effect. This warning is enabled by @option{-Wall}.
4268
4269 @opindex Wpessimizing-move
4270 @opindex Wno-pessimizing-move
4271 @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
4272 This warning warns when a call to @code{std::move} prevents copy
4273 elision. A typical scenario when copy elision can occur is when returning in
4274 a function with a class return type, when the expression being returned is the
4275 name of a non-volatile automatic object, and is not a function parameter, and
4276 has the same type as the function return type.
4277
4278 @smallexample
4279 struct T @{
4280 @dots{}
4281 @};
4282 T fn()
4283 @{
4284 T t;
4285 @dots{}
4286 return std::move (t);
4287 @}
4288 @end smallexample
4289
4290 But in this example, the @code{std::move} call prevents copy elision.
4291
4292 This warning is enabled by @option{-Wall}.
4293
4294 @opindex Wredundant-move
4295 @opindex Wno-redundant-move
4296 @item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
4297 This warning warns about redundant calls to @code{std::move}; that is, when
4298 a move operation would have been performed even without the @code{std::move}
4299 call. This happens because the compiler is forced to treat the object as if
4300 it were an rvalue in certain situations such as returning a local variable,
4301 where copy elision isn't applicable. Consider:
4302
4303 @smallexample
4304 struct T @{
4305 @dots{}
4306 @};
4307 T fn(T t)
4308 @{
4309 @dots{}
4310 return std::move (t);
4311 @}
4312 @end smallexample
4313
4314 Here, the @code{std::move} call is redundant. Because G++ implements Core
4315 Issue 1579, another example is:
4316
4317 @smallexample
4318 struct T @{ // convertible to U
4319 @dots{}
4320 @};
4321 struct U @{
4322 @dots{}
4323 @};
4324 U fn()
4325 @{
4326 T t;
4327 @dots{}
4328 return std::move (t);
4329 @}
4330 @end smallexample
4331 In this example, copy elision isn't applicable because the type of the
4332 expression being returned and the function return type differ, yet G++
4333 treats the return value as if it were designated by an rvalue.
4334
4335 This warning is enabled by @option{-Wextra}.
4336
4337 @opindex Wrange-loop-construct
4338 @opindex Wno-range-loop-construct
4339 @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
4340 This warning warns when a C++ range-based for-loop is creating an unnecessary
4341 copy. This can happen when the range declaration is not a reference, but
4342 probably should be. For example:
4343
4344 @smallexample
4345 struct S @{ char arr[128]; @};
4346 void fn () @{
4347 S arr[5];
4348 for (const auto x : arr) @{ @dots{} @}
4349 @}
4350 @end smallexample
4351
4352 It does not warn when the type being copied is a trivially-copyable type whose
4353 size is less than 64 bytes.
4354
4355 This warning also warns when a loop variable in a range-based for-loop is
4356 initialized with a value of a different type resulting in a copy. For example:
4357
4358 @smallexample
4359 void fn() @{
4360 int arr[10];
4361 for (const double &x : arr) @{ @dots{} @}
4362 @}
4363 @end smallexample
4364
4365 In the example above, in every iteration of the loop a temporary value of
4366 type @code{double} is created and destroyed, to which the reference
4367 @code{const double &} is bound.
4368
4369 This warning is enabled by @option{-Wall}.
4370
4371 @opindex Wredundant-tags
4372 @opindex Wno-redundant-tags
4373 @item -Wredundant-tags @r{(C++ and Objective-C++ only)}
4374 Warn about redundant class-key and enum-key in references to class types
4375 and enumerated types in contexts where the key can be eliminated without
4376 causing an ambiguity. For example:
4377
4378 @smallexample
4379 struct foo;
4380 struct foo *p; // warn that keyword struct can be eliminated
4381 @end smallexample
4382
4383 @noindent
4384 On the other hand, in this example there is no warning:
4385
4386 @smallexample
4387 struct foo;
4388 void foo (); // "hides" struct foo
4389 void bar (struct foo&); // no warning, keyword struct is necessary
4390 @end smallexample
4391
4392 @opindex Wsubobject-linkage
4393 @opindex Wno-subobject-linkage
4394 @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
4395 Do not warn
4396 if a class type has a base or a field whose type uses the anonymous
4397 namespace or depends on a type with no linkage. If a type A depends on
4398 a type B with no or internal linkage, defining it in multiple
4399 translation units would be an ODR violation because the meaning of B
4400 is different in each translation unit. If A only appears in a single
4401 translation unit, the best way to silence the warning is to give it
4402 internal linkage by putting it in an anonymous namespace as well. The
4403 compiler doesn't give this warning for types defined in the main .C
4404 file, as those are unlikely to have multiple definitions.
4405 @option{-Wsubobject-linkage} is enabled by default.
4406
4407 @opindex Weffc++
4408 @opindex Wno-effc++
4409 @item -Weffc++ @r{(C++ and Objective-C++ only)}
4410 Warn about violations of the following style guidelines from Scott Meyers'
4411 @cite{Effective C++} series of books:
4412
4413 @itemize @bullet
4414 @item
4415 Define a copy constructor and an assignment operator for classes
4416 with dynamically-allocated memory.
4417
4418 @item
4419 Prefer initialization to assignment in constructors.
4420
4421 @item
4422 Have @code{operator=} return a reference to @code{*this}.
4423
4424 @item
4425 Don't try to return a reference when you must return an object.
4426
4427 @item
4428 Distinguish between prefix and postfix forms of increment and
4429 decrement operators.
4430
4431 @item
4432 Never overload @code{&&}, @code{||}, or @code{,}.
4433
4434 @end itemize
4435
4436 This option also enables @option{-Wnon-virtual-dtor}, which is also
4437 one of the effective C++ recommendations. However, the check is
4438 extended to warn about the lack of virtual destructor in accessible
4439 non-polymorphic bases classes too.
4440
4441 When selecting this option, be aware that the standard library
4442 headers do not obey all of these guidelines; use @samp{grep -v}
4443 to filter out those warnings.
4444
4445 @opindex Wexceptions
4446 @opindex Wno-exceptions
4447 @item -Wno-exceptions @r{(C++ and Objective-C++ only)}
4448 Disable the warning about the case when an exception handler is shadowed by
4449 another handler, which can point out a wrong ordering of exception handlers.
4450
4451 @opindex Wsfinae-incomplete
4452 @opindex Wno-sfinae-incomplete
4453 Warn about a class that is found to be incomplete, or a function with
4454 auto return type that has not yet been deduced, in a context where
4455 that causes substitution failure rather than an error, and then the
4456 class or function is defined later in the translation unit. This is
4457 problematic because template instantiations or concept checks could
4458 have different results if they first occur either before or after the
4459 definition.
4460
4461 This warning is enabled by default. @option{-Wsfinae-incomplete=2}
4462 adds a warning at the point of substitution failure, to make it easier
4463 to track down problems flagged by the default mode.
4464
4465 @opindex Wstrict-null-sentinel
4466 @opindex Wno-strict-null-sentinel
4467 @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
4468 Warn about the use of an uncasted @code{NULL} as sentinel. When
4469 compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4470 to @code{__null}. Although it is a null pointer constant rather than a
4471 null pointer, it is guaranteed to be of the same size as a pointer.
4472 But this use is not portable across different compilers.
4473
4474 @opindex Wno-non-template-friend
4475 @opindex Wnon-template-friend
4476 @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
4477 Disable warnings when non-template friend functions are declared
4478 within a template. In very old versions of GCC that predate implementation
4479 of the ISO standard, declarations such as
4480 @samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4481 could be interpreted as a particular specialization of a template
4482 function; the warning exists to diagnose compatibility problems,
4483 and is enabled by default.
4484
4485 @opindex Wold-style-cast
4486 @opindex Wno-old-style-cast
4487 @item -Wold-style-cast @r{(C++ and Objective-C++ only)}
4488 Warn if an old-style (C-style) cast to a non-void type is used within
4489 a C++ program. The new-style casts (@code{dynamic_cast},
4490 @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4491 less vulnerable to unintended effects and much easier to search for.
4492
4493 @opindex Woverloaded-virtual
4494 @opindex Wno-overloaded-virtual
4495 @cindex overloaded virtual function, warning
4496 @cindex warning for overloaded virtual function
4497 @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4498 @itemx -Woverloaded-virtual=@var{n}
4499 Warn when a function declaration hides virtual functions from a
4500 base class. For example, in:
4501
4502 @smallexample
4503 struct A @{
4504 virtual void f();
4505 @};
4506
4507 struct B: public A @{
4508 void f(int); // does not override
4509 @};
4510 @end smallexample
4511
4512 the @code{A} class version of @code{f} is hidden in @code{B}, and code
4513 like:
4514
4515 @smallexample
4516 B* b;
4517 b->f();
4518 @end smallexample
4519
4520 @noindent
4521 fails to compile.
4522
4523 In cases where the different signatures are not an accident, the
4524 simplest solution is to add a using-declaration to the derived class
4525 to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4526
4527 The optional level suffix controls the behavior when all the
4528 declarations in the derived class override virtual functions in the
4529 base class, even if not all of the base functions are overridden:
4530
4531 @smallexample
4532 struct C @{
4533 virtual void f();
4534 virtual void f(int);
4535 @};
4536
4537 struct D: public C @{
4538 void f(int); // does override
4539 @}
4540 @end smallexample
4541
4542 This pattern is less likely to be a mistake; if D is only used
4543 virtually, the user might have decided that the base class semantics
4544 for some of the overloads are fine.
4545
4546 At level 1, this case does not warn; at level 2, it does.
4547 @option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4548 included in @option{-Wall}.
4549
4550 @opindex Wno-pmf-conversions
4551 @opindex Wpmf-conversions
4552 @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
4553 Disable the diagnostic for converting a bound pointer to member function
4554 to a plain pointer.
4555
4556 @opindex Wsign-promo
4557 @opindex Wno-sign-promo
4558 @item -Wsign-promo @r{(C++ and Objective-C++ only)}
4559 Warn when overload resolution chooses a promotion from unsigned or
4560 enumerated type to a signed type, over a conversion to an unsigned type of
4561 the same size. Previous versions of G++ tried to preserve
4562 unsignedness, but the standard mandates the current behavior.
4563
4564 @opindex Wtemplates
4565 @opindex Wno-templates
4566 @item -Wtemplates @r{(C++ and Objective-C++ only)}
4567 Warn when a primary template declaration is encountered. Some coding
4568 rules disallow templates, and this may be used to enforce that rule.
4569 The warning is inactive inside a system header file, such as the STL, so
4570 one can still use the STL. One may also instantiate or specialize
4571 templates.
4572
4573 @opindex Wmismatched-new-delete
4574 @opindex Wno-mismatched-new-delete
4575 @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
4576 Warn for mismatches between calls to @code{operator new} or @code{operator
4577 delete} and the corresponding call to the allocation or deallocation function.
4578 This includes invocations of C++ @code{operator delete} with pointers
4579 returned from either mismatched forms of @code{operator new}, or from other
4580 functions that allocate objects for which the @code{operator delete} isn't
4581 a suitable deallocator, as well as calls to other deallocation functions
4582 with pointers returned from @code{operator new} for which the deallocation
4583 function isn't suitable.
4584
4585 For example, the @code{delete} expression in the function below is diagnosed
4586 because it doesn't match the array form of the @code{new} expression
4587 the pointer argument was returned from. Similarly, the call to @code{free}
4588 is also diagnosed.
4589
4590 @smallexample
4591 void f ()
4592 @{
4593 int *a = new int[n];
4594 delete a; // warning: mismatch in array forms of expressions
4595
4596 char *p = new char[n];
4597 free (p); // warning: mismatch between new and free
4598 @}
4599 @end smallexample
4600
4601 The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4602 involving allocation and deallocation functions other than @code{operator
4603 new} and @code{operator delete}.
4604
4605 @option{-Wmismatched-new-delete} is included in @option{-Wall}.
4606
4607 @opindex Wmismatched-tags
4608 @opindex Wno-mismatched-tags
4609 @item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
4610 Warn for declarations of structs, classes, and class templates and their
4611 specializations with a class-key that does not match either the definition
4612 or the first declaration if no definition is provided.
4613
4614 For example, the declaration of @code{struct Object} in the argument list
4615 of @code{draw} triggers the warning. To avoid it, either remove the redundant
4616 class-key @code{struct} or replace it with @code{class} to match its definition.
4617 @smallexample
4618 class Object @{
4619 public:
4620 virtual ~Object () = 0;
4621 @};
4622 void draw (struct Object*);
4623 @end smallexample
4624
4625 It is not wrong to declare a class with the class-key @code{struct} as
4626 the example above shows. The @option{-Wmismatched-tags} option is intended
4627 to help achieve a consistent style of class declarations. In code that is
4628 intended to be portable to Windows-based compilers the warning helps prevent
4629 unresolved references due to the difference in the mangling of symbols
4630 declared with different class-keys. The option can be used either on its
4631 own or in conjunction with @option{-Wredundant-tags}.
4632
4633 @opindex Wmultiple-inheritance
4634 @opindex Wno-multiple-inheritance
4635 @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
4636 Warn when a class is defined with multiple direct base classes. Some
4637 coding rules disallow multiple inheritance, and this may be used to
4638 enforce that rule. The warning is inactive inside a system header file,
4639 such as the STL, so one can still use the STL. One may also define
4640 classes that indirectly use multiple inheritance.
4641
4642 @opindex Wvirtual-inheritance
4643 @opindex Wno-virtual-inheritance
4644 @item -Wvirtual-inheritance
4645 Warn when a class is defined with a virtual direct base class. Some
4646 coding rules disallow multiple inheritance, and this may be used to
4647 enforce that rule. The warning is inactive inside a system header file,
4648 such as the STL, so one can still use the STL. One may also define
4649 classes that indirectly use virtual inheritance.
4650
4651 @opindex Wvirtual-move-assign
4652 @opindex Wno-virtual-move-assign
4653 @item -Wno-virtual-move-assign
4654 Suppress warnings about inheriting from a virtual base with a
4655 non-trivial C++11 move assignment operator. This is dangerous because
4656 if the virtual base is reachable along more than one path, it is
4657 moved multiple times, which can mean both objects end up in the
4658 moved-from state. If the move assignment operator is written to avoid
4659 moving from a moved-from object, this warning can be disabled.
4660
4661 @opindex Wnamespaces
4662 @opindex Wno-namespaces
4663 @item -Wnamespaces
4664 Warn when a namespace definition is opened. Some coding rules disallow
4665 namespaces, and this may be used to enforce that rule. The warning is
4666 inactive inside a system header file, such as the STL, so one can still
4667 use the STL. One may also use using directives and qualified names.
4668
4669 @opindex Wtemplate-body
4670 @opindex Wno-template-body
4671 @item -Wno-template-body @r{(C++ and Objective-C++ only)}
4672 Disable diagnosing errors when parsing a template, and instead issue an
4673 error only upon instantiation of the template. This flag can also be
4674 used to downgrade such errors into warnings with @option{Wno-error=} or
4675 @option{-fpermissive}.
4676
4677 @opindex Wtemplate-id-cdtor
4678 @opindex Wno-template-id-cdtor
4679 @item -Wno-template-id-cdtor @r{(C++ and Objective-C++ only)}
4680 Disable the warning about the use of simple-template-id as the declarator-id
4681 of a constructor or destructor, which became invalid in C++20 via DR 2237.
4682 For example:
4683
4684 @smallexample
4685 template<typename T> struct S @{
4686 S<T>(); // should be S();
4687 ~S<T>(); // should be ~S();
4688 @};
4689 @end smallexample
4690
4691 @option{-Wtemplate-id-cdtor} is enabled by default with
4692 @option{-std=c++20}; it is also enabled by @option{-Wc++20-compat}.
4693
4694 @opindex Wtemplate-names-tu-local
4695 @opindex Wno-template-names-tu-local
4696 @item -Wtemplate-names-tu-local
4697 Warn when a template body hides an exposure of a translation-unit-local
4698 entity. In most cases, referring to a translation-unit-local entity
4699 (such as an internal linkage declaration) within an entity that is
4700 emitted into a module's CMI is an error. However, within the
4701 initializer of a variable, or in the body of a non-inline function,
4702 this is not an exposure and no error is emitted.
4703
4704 This can cause variable or function templates to accidentally become
4705 unusable if they reference such an entity, because other translation
4706 units that import the template will never be able to instantiate it.
4707 This warning attempts to detect cases where this might occur.
4708 The presence of an explicit instantiation silences the warning.
4709
4710 This flag is enabled by @option{-Wextra}.
4711
4712 @opindex Wterminate
4713 @opindex Wno-terminate
4714 @item -Wno-terminate @r{(C++ and Objective-C++ only)}
4715 Disable the warning about a throw-expression that will immediately
4716 result in a call to @code{terminate}.
4717
4718 @opindex Wvexing-parse
4719 @opindex Wno-vexing-parse
4720 @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
4721 Warn about the most vexing parse syntactic ambiguity. This warns about
4722 the cases when a declaration looks like a variable definition, but the
4723 C++ language requires it to be interpreted as a function declaration.
4724 For instance:
4725
4726 @smallexample
4727 void f(double a) @{
4728 int i(); // extern int i (void);
4729 int n(int(a)); // extern int n (int);
4730 @}
4731 @end smallexample
4732
4733 Another example:
4734
4735 @smallexample
4736 struct S @{ S(int); @};
4737 void f(double a) @{
4738 S x(int(a)); // extern struct S x (int);
4739 S y(int()); // extern struct S y (int (*) (void));
4740 S z(); // extern struct S z (void);
4741 @}
4742 @end smallexample
4743
4744 The warning will suggest options how to deal with such an ambiguity; e.g.,
4745 it can suggest removing the parentheses or using braces instead.
4746
4747 This warning is enabled by default.
4748
4749 @opindex Wno-class-conversion
4750 @opindex Wclass-conversion
4751 @item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
4752 Do not warn when a conversion function converts an
4753 object to the same type, to a base class of that type, or to void; such
4754 a conversion function will never be called.
4755
4756 @opindex Wvolatile
4757 @opindex Wno-volatile
4758 @item -Wvolatile @r{(C++ and Objective-C++ only)}
4759 Warn about deprecated uses of the @code{volatile} qualifier. This includes
4760 postfix and prefix @code{++} and @code{--} expressions of
4761 @code{volatile}-qualified types, using simple assignments where the left
4762 operand is a @code{volatile}-qualified non-class type for their value,
4763 compound assignments where the left operand is a @code{volatile}-qualified
4764 non-class type, @code{volatile}-qualified function return type,
4765 @code{volatile}-qualified parameter type, and structured bindings of a
4766 @code{volatile}-qualified type. This usage was deprecated in C++20.
4767
4768 Enabled by default with @option{-std=c++20}. Before
4769 @option{-std=c++20}, enabled with explicit @option{-Wdeprecated}.
4770
4771 @opindex Waligned-new
4772 @opindex Wno-aligned-new
4773 @item -Waligned-new
4774 Warn about a new-expression of a type that requires greater alignment
4775 than the @code{alignof(std::max_align_t)} but uses an allocation
4776 function without an explicit alignment parameter. This option is
4777 enabled by @option{-Wall}.
4778
4779 Normally this only warns about global allocation functions, but
4780 @option{-Waligned-new=all} also warns about class member allocation
4781 functions.
4782
4783 @opindex Wplacement-new
4784 @opindex Wno-placement-new
4785 @item -Wno-placement-new
4786 @itemx -Wplacement-new=@var{n}
4787 Warn about placement new expressions with undefined behavior, such as
4788 constructing an object in a buffer that is smaller than the type of
4789 the object. For example, the placement new expression below is diagnosed
4790 because it attempts to construct an array of 64 integers in a buffer only
4791 64 bytes large.
4792 @smallexample
4793 char buf [64];
4794 new (buf) int[64];
4795 @end smallexample
4796 This warning is enabled by default.
4797
4798 @table @gcctabopt
4799 @item -Wplacement-new=1
4800 This is the default warning level of @option{-Wplacement-new}. At this
4801 level the warning is not issued for some strictly undefined constructs that
4802 GCC allows as extensions for compatibility with legacy code. For example,
4803 the following @code{new} expression is not diagnosed at this level even
4804 though it has undefined behavior according to the C++ standard because
4805 it writes past the end of the one-element array.
4806 @smallexample
4807 struct S @{ int n, a[1]; @};
4808 S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4809 new (s->a)int [32]();
4810 @end smallexample
4811
4812 @item -Wplacement-new=2
4813 At this level, in addition to diagnosing all the same constructs as at level
4814 1, a diagnostic is also issued for placement new expressions that construct
4815 an object in the last member of structure whose type is an array of a single
4816 element and whose size is less than the size of the object being constructed.
4817 While the previous example would be diagnosed, the following construct makes
4818 use of the flexible member array extension to avoid the warning at level 2.
4819 @smallexample
4820 struct S @{ int n, a[]; @};
4821 S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4822 new (s->a)int [32]();
4823 @end smallexample
4824
4825 @end table
4826
4827 @opindex Wcatch-value
4828 @opindex Wno-catch-value
4829 @item -Wcatch-value
4830 @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
4831 Warn about catch handlers that do not catch via reference.
4832 With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4833 warn about polymorphic class types that are caught by value.
4834 With @option{-Wcatch-value=2} warn about all class types that are caught
4835 by value. With @option{-Wcatch-value=3} warn about all types that are
4836 not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4837
4838 @opindex Wconditionally-supported
4839 @opindex Wno-conditionally-supported
4840 @item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
4841 Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4842
4843 @opindex Wdefaulted-function-deleted
4844 @opindex Wno-defaulted-function-deleted
4845 @item -Wno-defaulted-function-deleted @r{(C++ and Objective-C++ only)}
4846 Warn when an explicitly defaulted function is deleted by the compiler.
4847 That can occur when the function's declared type does not match the type
4848 of the function that would have been implicitly declared. This warning
4849 is enabled by default.
4850
4851 @opindex Wdelete-incomplete
4852 @opindex Wno-delete-incomplete
4853 @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
4854 Do not warn when deleting a pointer to incomplete type, which may cause
4855 undefined behavior at runtime. This warning is enabled by default.
4856
4857 @opindex Wextra-semi
4858 @opindex Wno-extra-semi
4859 @item -Wextra-semi @r{(C++, Objective-C++ only)}
4860 Warn about redundant semicolons. There are various contexts in which an extra
4861 semicolon can occur. One is a semicolon after in-class function definitions,
4862 which is valid in all C++ dialects (and is never a pedwarn):
4863
4864 @smallexample
4865 struct S @{
4866 void foo () @{@};
4867 @};
4868 @end smallexample
4869
4870 Another is an extra semicolon at namespace scope, which has been allowed
4871 since C++11 (therefore is a pedwarn in C++98):
4872
4873 @smallexample
4874 struct S @{
4875 @};
4876 ;
4877 @end smallexample
4878
4879 And yet another is an extra semicolon in class definitions, which has been
4880 allowed since C++11 (therefore is a pedwarn in C++98):
4881
4882 @smallexample
4883 struct S @{
4884 int a;
4885 ;
4886 @};
4887 @end smallexample
4888
4889 @opindex Wno-global-module
4890 @opindex Wglobal-module
4891 @item -Wno-global-module @r{(C++ and Objective-C++ only)}
4892 Disable the diagnostic for when the global module fragment of a module
4893 unit does not consist only of preprocessor directives.
4894
4895 @opindex Winaccessible-base
4896 @opindex Wno-inaccessible-base
4897 @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
4898 This option controls warnings
4899 when a base class is inaccessible in a class derived from it due to
4900 ambiguity. The warning is enabled by default.
4901 Note that the warning for ambiguous virtual
4902 bases is enabled by the @option{-Wextra} option.
4903 @smallexample
4904 @group
4905 struct A @{ int a; @};
4906
4907 struct B : A @{ @};
4908
4909 struct C : B, A @{ @};
4910 @end group
4911 @end smallexample
4912
4913 @opindex Winherited-variadic-ctor
4914 @opindex Wno-inherited-variadic-ctor
4915 @item -Wno-inherited-variadic-ctor
4916 Suppress warnings about use of C++11 inheriting constructors when the
4917 base class inherited from has a C variadic constructor; the warning is
4918 on by default because the ellipsis is not inherited.
4919
4920 @opindex Wno-invalid-offsetof
4921 @opindex Winvalid-offsetof
4922 @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
4923 Suppress warnings from applying the @code{offsetof} macro to a non-POD
4924 type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4925 to a non-standard-layout type is undefined. In existing C++ implementations,
4926 however, @code{offsetof} typically gives meaningful results.
4927 This flag is for users who are aware that they are
4928 writing nonportable code and who have deliberately chosen to ignore the
4929 warning about it.
4930
4931 The restrictions on @code{offsetof} may be relaxed in a future version
4932 of the C++ standard.
4933
4934 @opindex Wsized-deallocation
4935 @opindex Wno-sized-deallocation
4936 @item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
4937 Warn about a definition of an unsized deallocation function
4938 @smallexample
4939 void operator delete (void *) noexcept;
4940 void operator delete[] (void *) noexcept;
4941 @end smallexample
4942 without a definition of the corresponding sized deallocation function
4943 @smallexample
4944 void operator delete (void *, std::size_t) noexcept;
4945 void operator delete[] (void *, std::size_t) noexcept;
4946 @end smallexample
4947 or vice versa. Enabled by @option{-Wextra} along with
4948 @option{-fsized-deallocation}.
4949
4950 @opindex Wno-suggest-final-types
4951 @opindex Wsuggest-final-types
4952 @item -Wsuggest-final-types
4953 Warn about types with virtual methods where code quality would be improved
4954 if the type were declared with the C++11 @code{final} specifier,
4955 or, if possible,
4956 declared in an anonymous namespace. This allows GCC to more aggressively
4957 devirtualize the polymorphic calls. This warning is more effective with
4958 link-time optimization,
4959 where the information about the class hierarchy graph is
4960 more complete.
4961
4962 @opindex Wno-suggest-final-methods
4963 @opindex Wsuggest-final-methods
4964 @item -Wsuggest-final-methods
4965 Warn about virtual methods where code quality would be improved if the method
4966 were declared with the C++11 @code{final} specifier,
4967 or, if possible, its type were
4968 declared in an anonymous namespace or with the @code{final} specifier.
4969 This warning is
4970 more effective with link-time optimization, where the information about the
4971 class hierarchy graph is more complete. It is recommended to first consider
4972 suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4973 annotations.
4974
4975 @opindex Wsuggest-override
4976 @opindex Wno-suggest-override
4977 @item -Wsuggest-override
4978 Warn about overriding virtual functions that are not marked with the
4979 @code{override} keyword.
4980
4981 @opindex Wconversion-null
4982 @opindex Wno-conversion-null
4983 @item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
4984 Do not warn for conversions between @code{NULL} and non-pointer
4985 types. @option{-Wconversion-null} is enabled by default.
4986
4987 @end table
4988
4989 @node Objective-C and Objective-C++ Dialect Options
4990 @section Options Controlling Objective-C and Objective-C++ Dialects
4991
4992 @cindex compiler options, Objective-C and Objective-C++
4993 @cindex Objective-C and Objective-C++ options, command-line
4994 @cindex options, Objective-C and Objective-C++
4995 (NOTE: This manual does not describe the Objective-C and Objective-C++
4996 languages themselves. @xref{Standards,,Language Standards
4997 Supported by GCC}, for references.)
4998
4999 This section describes the command-line options that are only meaningful
5000 for Objective-C and Objective-C++ programs. You can also use most of
5001 the language-independent GNU compiler options.
5002 For example, you might compile a file @file{some_class.m} like this:
5003
5004 @smallexample
5005 gcc -g -fgnu-runtime -O -c some_class.m
5006 @end smallexample
5007
5008 @noindent
5009 In this example, @option{-fgnu-runtime} is an option meant only for
5010 Objective-C and Objective-C++ programs; you can use the other options with
5011 any language supported by GCC@.
5012
5013 Note that since Objective-C is an extension of the C language, Objective-C
5014 compilations may also use options specific to the C front-end (e.g.,
5015 @option{-Wtraditional}). Similarly, Objective-C++ compilations may use
5016 C++-specific options (e.g., @option{-Wabi}).
5017
5018 Here is a list of options that are @emph{only} for compiling Objective-C
5019 and Objective-C++ programs:
5020
5021 @table @gcctabopt
5022 @opindex fconstant-string-class
5023 @item -fconstant-string-class=@var{class-name}
5024 Use @var{class-name} as the name of the class to instantiate for each
5025 literal string specified with the syntax @code{@@"@dots{}"}. The default
5026 class name is @code{NXConstantString} if the GNU runtime is being used, and
5027 @code{NSConstantString} if the NeXT runtime is being used (see below). On
5028 Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if
5029 also present, overrides the @option{-fconstant-string-class} setting and cause
5030 @code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings.
5031 Note that @option{-fconstant-cfstrings} is an alias for the target-specific
5032 @option{-mconstant-cfstrings} equivalent.
5033
5034 @opindex fgnu-runtime
5035 @item -fgnu-runtime
5036 Generate object code compatible with the standard GNU Objective-C
5037 runtime. This is the default for most types of systems.
5038
5039 @opindex fnext-runtime
5040 @item -fnext-runtime
5041 Generate output compatible with the NeXT runtime. This is the default
5042 for NeXT-based systems, including Darwin / macOS. The macro
5043 @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
5044 used.
5045
5046 @opindex fno-nil-receivers
5047 @opindex fnil-receivers
5048 @item -fno-nil-receivers
5049 Assume that all Objective-C message dispatches (@code{[receiver
5050 message:arg]}) in this translation unit ensure that the receiver is
5051 not @code{nil}. This allows for more efficient entry points in the
5052 runtime to be used. This option is only available in conjunction with
5053 the NeXT runtime and ABI version 0 or 1.
5054
5055 @opindex fobjc-abi-version
5056 @item -fobjc-abi-version=@var{n}
5057 Use version @var{n} of the Objective-C ABI for the selected runtime.
5058 This option is currently supported only for the NeXT runtime. In that
5059 case, Version 0 is the traditional (32-bit) ABI without support for
5060 properties and other Objective-C 2.0 additions. Version 1 is the
5061 traditional (32-bit) ABI with support for properties and other
5062 Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
5063 nothing is specified, the default is Version 0 on 32-bit target
5064 machines, and Version 2 on 64-bit target machines.
5065
5066 @opindex fobjc-call-cxx-cdtors
5067 @item -fobjc-call-cxx-cdtors
5068 For each Objective-C class, check if any of its instance variables is a
5069 C++ object with a non-trivial default constructor. If so, synthesize a
5070 special @code{- (id) .cxx_construct} instance method which runs
5071 non-trivial default constructors on any such instance variables, in order,
5072 and then return @code{self}. Similarly, check if any instance variable
5073 is a C++ object with a non-trivial destructor, and if so, synthesize a
5074 special @code{- (void) .cxx_destruct} method which runs
5075 all such default destructors, in reverse order.
5076
5077 The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
5078 methods thusly generated only operate on instance variables
5079 declared in the current Objective-C class, and not those inherited
5080 from superclasses. It is the responsibility of the Objective-C
5081 runtime to invoke all such methods in an object's inheritance
5082 hierarchy. The @code{- (id) .cxx_construct} methods are invoked
5083 by the runtime immediately after a new object instance is allocated;
5084 the @code{- (void) .cxx_destruct} methods are invoked immediately
5085 before the runtime deallocates an object instance.
5086
5087 As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
5088 support for invoking the @code{- (id) .cxx_construct} and
5089 @code{- (void) .cxx_destruct} methods.
5090
5091 @opindex fobjc-direct-dispatch
5092 @item -fobjc-direct-dispatch
5093 Allow fast jumps to the message dispatcher. On Darwin this is
5094 accomplished via the comm page.
5095
5096 @opindex fobjc-exceptions
5097 @item -fobjc-exceptions
5098 Enable syntactic support for structured exception handling in
5099 Objective-C, similar to what is offered by C++. This option
5100 is required to use the Objective-C keywords @code{@@try},
5101 @code{@@throw}, @code{@@catch}, @code{@@finally} and
5102 @code{@@synchronized}. This option is available with both the GNU
5103 runtime and the NeXT runtime (but not available in conjunction with
5104 the NeXT runtime on Mac OS X 10.2 and earlier).
5105
5106 @opindex fobjc-gc
5107 @item -fobjc-gc
5108 Enable garbage collection (GC) in Objective-C and Objective-C++
5109 programs. This option is only available with the NeXT runtime; the
5110 GNU runtime has a different garbage collection implementation that
5111 does not require special compiler flags.
5112
5113 @opindex fobjc-nilcheck
5114 @item -fobjc-nilcheck
5115 For the NeXT runtime with version 2 of the ABI, check for a nil
5116 receiver in method invocations before doing the actual method call.
5117 This is the default and can be disabled using
5118 @option{-fno-objc-nilcheck}. Class methods and super calls are never
5119 checked for nil in this way no matter what this flag is set to.
5120 Currently this flag does nothing when the GNU runtime, or an older
5121 version of the NeXT runtime ABI, is used.
5122
5123 @opindex fobjc-std
5124 @item -fobjc-std=objc1
5125 Conform to the language syntax of Objective-C 1.0, the language
5126 recognized by GCC 4.0. This only affects the Objective-C additions to
5127 the C/C++ language; it does not affect conformance to C/C++ standards,
5128 which is controlled by the separate C/C++ dialect option flags. When
5129 this option is used with the Objective-C or Objective-C++ compiler,
5130 any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
5131 This is useful if you need to make sure that your Objective-C code can
5132 be compiled with older versions of GCC@.
5133
5134 @opindex freplace-objc-classes
5135 @item -freplace-objc-classes
5136 Emit a special marker instructing @command{ld(1)} not to statically link in
5137 the resulting object file, and allow @command{dyld(1)} to load it in at
5138 run time instead. This is used in conjunction with the Fix-and-Continue
5139 debugging mode, where the object file in question may be recompiled and
5140 dynamically reloaded in the course of program execution, without the need
5141 to restart the program itself. Currently, Fix-and-Continue functionality
5142 is only available in conjunction with the NeXT runtime on Mac OS X 10.3
5143 and later.
5144
5145 @opindex fzero-link
5146 @item -fzero-link
5147 When compiling for the NeXT runtime, the compiler ordinarily replaces calls
5148 to @code{objc_getClass("@dots{}")} (when the name of the class is known at
5149 compile time) with static class references that get initialized at load time,
5150 which improves run-time performance. Specifying the @option{-fzero-link} flag
5151 suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
5152 to be retained. This is useful in Zero-Link debugging mode, since it allows
5153 for individual class implementations to be modified during program execution.
5154 The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
5155 regardless of command-line options.
5156
5157 @opindex fno-local-ivars
5158 @opindex flocal-ivars
5159 @item -fno-local-ivars
5160 By default instance variables in Objective-C can be accessed as if
5161 they were local variables from within the methods of the class they're
5162 declared in. This can lead to shadowing between instance variables
5163 and other variables declared either locally inside a class method or
5164 globally with the same name. Specifying the @option{-fno-local-ivars}
5165 flag disables this behavior thus avoiding variable shadowing issues.
5166
5167 @opindex fivar-visibility
5168 @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
5169 Set the default instance variable visibility to the specified option
5170 so that instance variables declared outside the scope of any access
5171 modifier directives default to the specified visibility.
5172
5173 @opindex gen-decls
5174 @item -gen-decls
5175 Dump interface declarations for all classes seen in the source file to a
5176 file named @file{@var{sourcename}.decl}.
5177
5178 @opindex Wassign-intercept
5179 @opindex Wno-assign-intercept
5180 @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
5181 Warn whenever an Objective-C assignment is being intercepted by the
5182 garbage collector.
5183
5184 @opindex Wproperty-assign-default
5185 @opindex Wno-property-assign-default
5186 @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
5187 Do not warn if a property for an Objective-C object has no assign
5188 semantics specified.
5189
5190 @opindex Wno-protocol
5191 @opindex Wprotocol
5192 @item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
5193 If a class is declared to implement a protocol, a warning is issued for
5194 every method in the protocol that is not implemented by the class. The
5195 default behavior is to issue a warning for every method not explicitly
5196 implemented in the class, even if a method implementation is inherited
5197 from the superclass. If you use the @option{-Wno-protocol} option, then
5198 methods inherited from the superclass are considered to be implemented,
5199 and no warning is issued for them.
5200
5201 @opindex Wobjc-root-class
5202 @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
5203 Warn if a class interface lacks a superclass. Most classes will inherit
5204 from @code{NSObject} (or @code{Object}) for example. When declaring
5205 classes intended to be root classes, the warning can be suppressed by
5206 marking their interfaces with @code{__attribute__((objc_root_class))}.
5207
5208 @opindex Wselector
5209 @opindex Wno-selector
5210 @item -Wselector @r{(Objective-C and Objective-C++ only)}
5211 Warn if multiple methods of different types for the same selector are
5212 found during compilation. The check is performed on the list of methods
5213 in the final stage of compilation. Additionally, a check is performed
5214 for each selector appearing in a @code{@@selector(@dots{})}
5215 expression, and a corresponding method for that selector has been found
5216 during compilation. Because these checks scan the method table only at
5217 the end of compilation, these warnings are not produced if the final
5218 stage of compilation is not reached, for example because an error is
5219 found during compilation, or because the @option{-fsyntax-only} option is
5220 being used.
5221
5222 @opindex Wstrict-selector-match
5223 @opindex Wno-strict-selector-match
5224 @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
5225 Warn if multiple methods with differing argument and/or return types are
5226 found for a given selector when attempting to send a message using this
5227 selector to a receiver of type @code{id} or @code{Class}. When this flag
5228 is off (which is the default behavior), the compiler omits such warnings
5229 if any differences found are confined to types that share the same size
5230 and alignment.
5231
5232 @opindex Wundeclared-selector
5233 @opindex Wno-undeclared-selector
5234 @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
5235 Warn if a @code{@@selector(@dots{})} expression referring to an
5236 undeclared selector is found. A selector is considered undeclared if no
5237 method with that name has been declared before the
5238 @code{@@selector(@dots{})} expression, either explicitly in an
5239 @code{@@interface} or @code{@@protocol} declaration, or implicitly in
5240 an @code{@@implementation} section. This option always performs its
5241 checks as soon as a @code{@@selector(@dots{})} expression is found,
5242 while @option{-Wselector} only performs its checks in the final stage of
5243 compilation. This also enforces the coding style convention
5244 that methods and selectors must be declared before being used.
5245
5246 @opindex print-objc-runtime-info
5247 @item -print-objc-runtime-info
5248 Generate C header describing the largest structure that is passed by
5249 value, if any.
5250
5251 @end table
5252
5253 @node OpenMP and OpenACC Options
5254 @section Options Controlling OpenMP and OpenACC
5255 @cindex OpenMP options
5256 @cindex OpenACC options
5257
5258 GCC supports OpenMP extensions to the C, C++, and Fortran languages
5259 with the @option{-fopenmp} option. Similarly, OpenACC extensions are
5260 supported in all three languages with @option{-fopenacc}.
5261 @xref{OpenMP} and @ref{OpenACC} for an overview of these extensions.
5262
5263 @table @gcctabopt
5264 @opindex foffload
5265 @cindex Offloading targets
5266 @cindex OpenACC offloading targets
5267 @cindex OpenMP offloading targets
5268 @item -foffload=disable
5269 @itemx -foffload=default
5270 @itemx -foffload=@var{target-list}
5271 Specify for which OpenMP and OpenACC offload targets code should be generated.
5272 The default behavior, equivalent to @option{-foffload=default}, is to generate
5273 code for all supported offload targets. The @option{-foffload=disable} form
5274 generates code only for the host fallback, while
5275 @option{-foffload=@var{target-list}} generates code only for the specified
5276 comma-separated list of offload targets.
5277
5278 Offload targets are specified in GCC's internal target-triplet format. You can
5279 run the compiler with @option{-v} to show the list of configured offload targets
5280 under @code{OFFLOAD_TARGET_NAMES}.
5281
5282 @opindex foffload-options
5283 @cindex Offloading options
5284 @cindex OpenACC offloading options
5285 @cindex OpenMP offloading options
5286 @item -foffload-options=@var{options}
5287 @itemx -foffload-options=@var{target-triplet-list}=@var{options}
5288
5289 With @option{-foffload-options=@var{options}}, GCC passes the specified
5290 @var{options} to the compilers for all enabled offloading targets. You can
5291 specify options that apply only to a specific target or targets by using
5292 the @option{-foffload-options=@var{target-list}=@var{options}} form. The
5293 @var{target-list} is a comma-separated list in the same format as for the
5294 @option{-foffload=} option.
5295
5296 Typical command lines are
5297
5298 @smallexample
5299 -foffload-options='-fno-math-errno -ffinite-math-only' \
5300 -foffload-options=nvptx-none=-latomic
5301 -foffload-options=amdgcn-amdhsa=-march=gfx906
5302 @end smallexample
5303
5304 @opindex fopenacc
5305 @cindex OpenACC accelerator programming
5306 @item -fopenacc
5307 Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and
5308 @samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and
5309 @samp{*$acc} in fixed-form Fortran. This option
5310 implies @option{-pthread}, and thus is only supported on targets that
5311 have support for @option{-pthread}.
5312
5313 @opindex fopenacc-dim
5314 @item -fopenacc-dim=@var{geom}
5315 Specify default compute dimensions for parallel offload regions that do
5316 not explicitly specify them. The @var{geom} value is a triple of
5317 @samp{:}-separated sizes, in order @var{gang}, @var{worker}, and @var{vector}.
5318 A size can be omitted, to use a target-specific default value.
5319
5320 @opindex fopenmp
5321 @cindex OpenMP parallel
5322 @item -fopenmp
5323 Enable handling of OpenMP directives @samp{#pragma omp},
5324 @samp{[[omp::directive(...)]]}, @samp{[[omp::decl(...)]]},
5325 and @samp{[[omp::sequence(...)]]} in C/C++. In Fortran, it enables
5326 @samp{!$omp} and the conditional compilation sentinel @samp{!$}.
5327 In fixed source form Fortran, the sentinels can also start with
5328 @samp{c} or @samp{*}.
5329
5330 This option implies @option{-pthread}, and thus is only supported on
5331 targets that have support for @option{-pthread}. @option{-fopenmp}
5332 implies @option{-fopenmp-simd}.
5333
5334 @opindex fopenmp-simd
5335 @cindex OpenMP SIMD
5336 @cindex SIMD
5337 @item -fopenmp-simd
5338 Enable handling of OpenMP's @code{simd}, @code{declare simd},
5339 @code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}
5340 and @code{loop} directive, and of combined or composite directives with
5341 @code{simd} as constituent with @code{#pragma omp},
5342 @code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and
5343 @code{[[omp::decl(...)]]} in C/C++ and @code{!$omp} in Fortran. It
5344 additionally enables the conditional compilation sentinel @samp{!$} in
5345 Fortran. In fixed source form Fortran, the sentinels can also start with
5346 @samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless
5347 @option{-fopenmp} is additionally specified, the @code{loop} region binds
5348 to the current task region, independent of the specified @code{bind} clause.
5349
5350 @opindex fopenmp-target-simd-clone
5351 @cindex OpenMP target SIMD clone
5352 @item -fopenmp-target-simd-clone
5353 @item -fopenmp-target-simd-clone=@var{device-type}
5354 In addition to generating SIMD clones for functions marked with the
5355 @code{declare simd} directive, GCC also generates clones
5356 for functions marked with the OpenMP @code{declare target} directive
5357 that are suitable for vectorization when this option is in effect. The
5358 @var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
5359 and @code{any}, which correspond to keywords for the @code{device_type}
5360 clause of the @code{declare target} directive; clones are generated for
5361 the intersection of devices specified.
5362 @option{-fopenmp-target-simd-clone} is equivalent to
5363 @option{-fopenmp-target-simd-clone=any} and
5364 @option{-fno-openmp-target-simd-clone} is equivalent to
5365 @option{-fopenmp-target-simd-clone=none}.
5366
5367 At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
5368 optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
5369 it is disabled by default.
5370
5371 @end table
5372
5373 @node Diagnostic Message Formatting Options
5374 @section Options to Control Diagnostic Messages Formatting
5375 @cindex options to control diagnostics formatting
5376 @cindex diagnostic messages
5377 @cindex message formatting
5378
5379 Traditionally, diagnostic messages have been formatted irrespective of
5380 the output device's aspect (e.g.@: its width, @dots{}). You can use the
5381 options described below
5382 to control the formatting algorithm for diagnostic messages,
5383 e.g.@: how many characters per line, how often source location
5384 information should be reported. Note that some language front ends may not
5385 honor these options.
5386
5387 @table @gcctabopt
5388 @opindex fmessage-length
5389 @item -fmessage-length=@var{n}
5390 Try to format error messages so that they fit on lines of about
5391 @var{n} characters. If @var{n} is zero, then no line-wrapping is
5392 done; each error message appears on a single line. This is the
5393 default for all front ends.
5394
5395 Note - this option also affects the display of the @samp{#error} and
5396 @samp{#warning} pre-processor directives, and the @samp{deprecated}
5397 function/type/variable attribute. It does not however affect the
5398 @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5399
5400 @item -fdiagnostics-plain-output
5401 This option requests that diagnostic output look as plain as possible, which
5402 may be useful when running @command{dejagnu} or other utilities that need to
5403 parse diagnostics output and prefer that it remain more stable over time.
5404 @option{-fdiagnostics-plain-output} is currently equivalent to the following
5405 options:
5406 @gccoptlist{-fno-diagnostics-show-caret
5407 -fno-diagnostics-show-line-numbers
5408 -fdiagnostics-color=never
5409 -fdiagnostics-urls=never
5410 -fdiagnostics-path-format=separate-events
5411 -fdiagnostics-text-art-charset=none
5412 -fno-diagnostics-show-event-links}
5413 In the future, if GCC changes the default appearance of its diagnostics, the
5414 corresponding option to disable the new behavior will be added to this list.
5415
5416 @opindex fdiagnostics-show-location
5417 @item -fdiagnostics-show-location=once
5418 Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5419 reporter to emit source location information @emph{once}; that is, in
5420 case the message is too long to fit on a single physical line and has to
5421 be wrapped, the source location won't be emitted (as prefix) again,
5422 over and over, in subsequent continuation lines. This is the default
5423 behavior.
5424
5425 @item -fdiagnostics-show-location=every-line
5426 Only meaningful in line-wrapping mode. Instructs the diagnostic
5427 messages reporter to emit the same source location information (as
5428 prefix) for physical lines that result from the process of breaking
5429 a message which is too long to fit on a single line.
5430
5431 @opindex fdiagnostics-color
5432 @cindex highlight, color
5433 @vindex GCC_COLORS @r{environment variable}
5434 @item -fdiagnostics-color[=@var{WHEN}]
5435 @itemx -fno-diagnostics-color
5436 Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5437 or @samp{auto}. The default depends on how the compiler has been configured,
5438 it can be any of the above @var{WHEN} options or also @samp{never}
5439 if @env{GCC_COLORS} environment variable isn't present in the environment,
5440 and @samp{auto} otherwise.
5441 @samp{auto} makes GCC use color only when the standard error is a terminal,
5442 and when not executing in an emacs shell.
5443 The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5444 aliases for @option{-fdiagnostics-color=always} and
5445 @option{-fdiagnostics-color=never}, respectively.
5446
5447 The colors are defined by the environment variable @env{GCC_COLORS}.
5448 Its value is a colon-separated list of capabilities and Select Graphic
5449 Rendition (SGR) substrings. SGR commands are interpreted by the
5450 terminal or terminal emulator. (See the section in the documentation
5451 of your text terminal for permitted values and their meanings as
5452 character attributes.) These substring values are integers in decimal
5453 representation and can be concatenated with semicolons.
5454 Common values to concatenate include
5455 @samp{1} for bold,
5456 @samp{4} for underline,
5457 @samp{5} for blink,
5458 @samp{7} for inverse,
5459 @samp{39} for default foreground color,
5460 @samp{30} to @samp{37} for foreground colors,
5461 @samp{90} to @samp{97} for 16-color mode foreground colors,
5462 @samp{38;5;0} to @samp{38;5;255}
5463 for 88-color and 256-color modes foreground colors,
5464 @samp{49} for default background color,
5465 @samp{40} to @samp{47} for background colors,
5466 @samp{100} to @samp{107} for 16-color mode background colors,
5467 and @samp{48;5;0} to @samp{48;5;255}
5468 for 88-color and 256-color modes background colors.
5469
5470 The default @env{GCC_COLORS} is
5471 @smallexample
5472 error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5473 quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5474 diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5475 type-diff=01;32:fnname=01;32:targs=35:valid=01;31:invalid=01;32\
5476 highlight-a=01;32:highlight-b=01;34
5477 @end smallexample
5478 @noindent
5479 where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5480 @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5481 @samp{01} is bold, and @samp{31} is red.
5482 Setting @env{GCC_COLORS} to the empty string disables colors.
5483 Supported capabilities are as follows.
5484
5485 @table @code
5486 @vindex error GCC_COLORS @r{capability}
5487 @item error=
5488 SGR substring for error: markers.
5489
5490 @vindex warning GCC_COLORS @r{capability}
5491 @item warning=
5492 SGR substring for warning: markers.
5493
5494 @vindex note GCC_COLORS @r{capability}
5495 @item note=
5496 SGR substring for note: markers.
5497
5498 @vindex path GCC_COLORS @r{capability}
5499 @item path=
5500 SGR substring for colorizing paths of control-flow events as printed
5501 via @option{-fdiagnostics-path-format=}, such as the identifiers of
5502 individual events and lines indicating interprocedural calls and returns.
5503
5504 @vindex range1 GCC_COLORS @r{capability}
5505 @item range1=
5506 SGR substring for first additional range.
5507
5508 @vindex range2 GCC_COLORS @r{capability}
5509 @item range2=
5510 SGR substring for second additional range.
5511
5512 @vindex locus GCC_COLORS @r{capability}
5513 @item locus=
5514 SGR substring for location information, @samp{file:line} or
5515 @samp{file:line:column} etc.
5516
5517 @vindex quote GCC_COLORS @r{capability}
5518 @item quote=
5519 SGR substring for information printed within quotes.
5520
5521 @vindex fnname GCC_COLORS @r{capability}
5522 @item fnname=
5523 SGR substring for names of C++ functions.
5524
5525 @vindex targs GCC_COLORS @r{capability}
5526 @item targs=
5527 SGR substring for C++ function template parameter bindings.
5528
5529 @vindex fixit-insert GCC_COLORS @r{capability}
5530 @item fixit-insert=
5531 SGR substring for fix-it hints suggesting text to
5532 be inserted or replaced.
5533
5534 @vindex fixit-delete GCC_COLORS @r{capability}
5535 @item fixit-delete=
5536 SGR substring for fix-it hints suggesting text to
5537 be deleted.
5538
5539 @vindex diff-filename GCC_COLORS @r{capability}
5540 @item diff-filename=
5541 SGR substring for filename headers within generated patches.
5542
5543 @vindex diff-hunk GCC_COLORS @r{capability}
5544 @item diff-hunk=
5545 SGR substring for the starts of hunks within generated patches.
5546
5547 @vindex diff-delete GCC_COLORS @r{capability}
5548 @item diff-delete=
5549 SGR substring for deleted lines within generated patches.
5550
5551 @vindex diff-insert GCC_COLORS @r{capability}
5552 @item diff-insert=
5553 SGR substring for inserted lines within generated patches.
5554
5555 @vindex type-diff GCC_COLORS @r{capability}
5556 @item type-diff=
5557 SGR substring for highlighting mismatching types within template
5558 arguments in the C++ frontend.
5559
5560 @vindex valid GCC_COLORS @r{capability}
5561 @item valid=
5562 SGR substring for highlighting valid elements within text art diagrams.
5563
5564 @vindex invalid GCC_COLORS @r{capability}
5565 @item invalid=
5566 SGR substring for highlighting invalid elements within text art diagrams.
5567
5568 @vindex highlight-a GCC_COLORS @r{capability}
5569 @vindex highlight-b GCC_COLORS @r{capability}
5570 @item highlight-a=
5571 @item highlight-b=
5572 SGR substrings for contrasting two different things within diagnostics,
5573 such as a pair of mismatching types.
5574 See @option{-fdiagnostics-show-highlight-colors}.
5575 @end table
5576
5577 @opindex fdiagnostics-urls
5578 @cindex urls
5579 @vindex GCC_URLS @r{environment variable}
5580 @vindex TERM_URLS @r{environment variable}
5581 @item -fdiagnostics-urls[=@var{WHEN}]
5582 Use escape sequences to embed URLs in diagnostics. For example, when
5583 @option{-fdiagnostics-show-option} emits text showing the command-line
5584 option controlling a diagnostic, embed a URL for documentation of that
5585 option.
5586
5587 @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5588 @samp{auto} makes GCC use URL escape sequences only when the standard error
5589 is a terminal, and when not executing in an emacs shell or any graphical
5590 terminal which is known to be incompatible with this feature, see below.
5591
5592 The default depends on how the compiler has been configured.
5593 It can be any of the above @var{WHEN} options.
5594
5595 GCC can also be configured (via the
5596 @option{--with-diagnostics-urls=auto-if-env} configure-time option)
5597 so that the default is affected by environment variables.
5598 Under such a configuration, GCC defaults to using @samp{auto}
5599 if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5600 present and non-empty in the environment of the compiler, or @samp{never}
5601 if neither are.
5602
5603 However, even with @option{-fdiagnostics-urls=always} the behavior is
5604 dependent on those environment variables:
5605 If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5606 diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5607 If set to @samp{bel}, the default, URLs use BEL escape sequences.
5608 Any other non-empty value enables the feature.
5609 If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5610 Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5611 BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5612
5613 At this time GCC tries to detect also a few terminals that are known to
5614 not implement the URL feature, and have bugs or at least had bugs in
5615 some versions that are still in use, where the URL escapes are likely
5616 to misbehave, i.e. print garbage on the screen.
5617 That list is currently xfce4-terminal, certain known to be buggy
5618 gnome-terminal versions, the linux console, and mingw.
5619 This check can be skipped with the @option{-fdiagnostics-urls=always}.
5620
5621 @opindex fno-diagnostics-show-option
5622 @opindex fdiagnostics-show-option
5623 @item -fno-diagnostics-show-option
5624 By default, each diagnostic emitted includes text indicating the
5625 command-line option that directly controls the diagnostic (if such an
5626 option is known to the diagnostic machinery). Specifying the
5627 @option{-fno-diagnostics-show-option} flag suppresses that behavior.
5628
5629 @opindex fno-diagnostics-show-caret
5630 @opindex fdiagnostics-show-caret
5631 @item -fno-diagnostics-show-caret
5632 By default, each diagnostic emitted includes the original source line
5633 and a caret @samp{^} indicating the column. This option suppresses this
5634 information. The source line is truncated to @var{n} characters, if
5635 the @option{-fmessage-length=n} option is given. When the output is done
5636 to the terminal, the width is limited to the width given by the
5637 @env{COLUMNS} environment variable or, if not set, to the terminal width.
5638
5639 @opindex fno-diagnostics-show-labels
5640 @opindex fdiagnostics-show-labels
5641 @item -fno-diagnostics-show-labels
5642 By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5643 diagnostics can label ranges of source code with pertinent information, such
5644 as the types of expressions:
5645
5646 @smallexample
5647 printf ("foo %s bar", long_i + long_j);
5648 ~^ ~~~~~~~~~~~~~~~
5649 | |
5650 char * long int
5651 @end smallexample
5652
5653 This option suppresses the printing of these labels (in the example above,
5654 the vertical bars and the ``char *'' and ``long int'' text).
5655
5656 @opindex fno-diagnostics-show-event-links
5657 @opindex fdiagnostics-show-event-links
5658 @item -fno-diagnostics-show-event-links
5659 By default, when printing execution paths (via
5660 @option{-fdiagnostics-path-format=inline-events}), GCC will print lines
5661 connecting related events, such as the line connecting events 1 and 2 in:
5662
5663 @smallexample
5664 3 | if (p)
5665 | ^
5666 | |
5667 | (1) following `false' branch (when `p' is NULL)... ->-+
5668 | |
5669 | |
5670 |+------------------------------------------------------------+
5671 4 || return 0;
5672 5 || return *p;
5673 || ~
5674 || |
5675 |+-------->(2) ...to here
5676 | (3) dereference of NULL `p'
5677 @end smallexample
5678
5679 This option suppresses the printing of such connector lines.
5680
5681 @opindex fno-diagnostics-show-cwe
5682 @opindex fdiagnostics-show-cwe
5683 @item -fno-diagnostics-show-cwe
5684 Diagnostic messages can optionally have an associated
5685 @uref{https://cwe.mitre.org/index.html, CWE} identifier.
5686 GCC itself only provides such metadata for some of the @option{-fanalyzer}
5687 diagnostics. GCC plugins may also provide diagnostics with such metadata.
5688 By default, if this information is present, it will be printed with
5689 the diagnostic. This option suppresses the printing of this metadata.
5690
5691 @opindex fno-diagnostics-show-rules
5692 @opindex fdiagnostics-show-rules
5693 @item -fno-diagnostics-show-rules
5694 Diagnostic messages can optionally have rules associated with them, such
5695 as from a coding standard, or a specification.
5696 GCC itself does not do this for any of its diagnostics, but plugins may do so.
5697 By default, if this information is present, it will be printed with
5698 the diagnostic. This option suppresses the printing of this metadata.
5699
5700 @opindex fno-diagnostics-show-highlight-colors
5701 @opindex fdiagnostics-show-highlight-colors
5702 @item -fno-diagnostics-show-highlight-colors
5703
5704 GCC can use color for emphasis and contrast when printing diagnostic
5705 messages and quoting the user's source.
5706
5707 For example, in
5708
5709 @smallexample
5710 demo.c: In function `test_bad_format_string_args':
5711 ../../src/demo.c:25:18: warning: format `%i' expects argument of type `int', but argument 2 has type `const char *' [-Wformat=]
5712 25 | printf("hello %i", msg);
5713 | ~^ ~~~
5714 | | |
5715 | int const char *
5716 | %s
5717 @end smallexample
5718
5719 @itemize @bullet
5720 @item
5721 the @code{%i} and @code{int} in the message and the @code{int} in the
5722 quoted source are colored using @code{highlight-a} (bold green by default),
5723 and
5724 @item
5725 the @code{const char *} in the message and in the quoted source are both
5726 colored using @code{highlight-b} (bold blue by default).
5727 @end itemize
5728
5729 The intent is to draw the reader's eyes to the relationships between the
5730 various aspects of the diagnostic message and the source, using color
5731 to group related elements and distinguish between mismatching ones.
5732
5733 This additional colorization is enabled by default if color printing
5734 is enabled (as per @option{-fdiagnostics-color=}), but it can be separately
5735 disabled via @option{-fno-diagnostics-show-highlight-colors}.
5736
5737 @opindex fno-diagnostics-show-line-numbers
5738 @opindex fdiagnostics-show-line-numbers
5739 @item -fno-diagnostics-show-line-numbers
5740 By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5741 a left margin is printed, showing line numbers. This option suppresses this
5742 left margin.
5743
5744 @opindex fdiagnostics-minimum-margin-width
5745 @item -fdiagnostics-minimum-margin-width=@var{width}
5746 This option controls the minimum width of the left margin printed by
5747 @option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5748
5749 @opindex fdiagnostics-parseable-fixits
5750 @item -fdiagnostics-parseable-fixits
5751 Emit fix-it hints in a machine-parseable format, suitable for consumption
5752 by IDEs. For each fix-it, a line will be printed after the relevant
5753 diagnostic, starting with the string ``fix-it:''. For example:
5754
5755 @smallexample
5756 fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5757 @end smallexample
5758
5759 The location is expressed as a half-open range, expressed as a count of
5760 bytes, starting at byte 1 for the initial column. In the above example,
5761 bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5762 given string:
5763
5764 @smallexample
5765 00000000011111111112222222222
5766 12345678901234567890123456789
5767 gtk_widget_showall (dlg);
5768 ^^^^^^^^^^^^^^^^^^
5769 gtk_widget_show_all
5770 @end smallexample
5771
5772 The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5773 newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5774 (e.g. vertical tab as ``\013'').
5775
5776 An empty replacement string indicates that the given range is to be removed.
5777 An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5778 be inserted at the given position.
5779
5780 @opindex fdiagnostics-generate-patch
5781 @item -fdiagnostics-generate-patch
5782 Print fix-it hints to stderr in unified diff format, after any diagnostics
5783 are printed. For example:
5784
5785 @smallexample
5786 --- test.c
5787 +++ test.c
5788 @@ -42,5 +42,5 @@
5789
5790 void show_cb(GtkDialog *dlg)
5791 @{
5792 - gtk_widget_showall(dlg);
5793 + gtk_widget_show_all(dlg);
5794 @}
5795
5796 @end smallexample
5797
5798 The diff may or may not be colorized, following the same rules
5799 as for diagnostics (see @option{-fdiagnostics-color}).
5800
5801 @opindex fdiagnostics-show-template-tree
5802 @item -fdiagnostics-show-template-tree
5803
5804 In the C++ frontend, when printing diagnostics showing mismatching
5805 template types, such as:
5806
5807 @smallexample
5808 could not convert 'std::map<int, std::vector<double> >()'
5809 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5810 @end smallexample
5811
5812 the @option{-fdiagnostics-show-template-tree} flag enables printing a
5813 tree-like structure showing the common and differing parts of the types,
5814 such as:
5815
5816 @smallexample
5817 map<
5818 [...],
5819 vector<
5820 [double != float]>>
5821 @end smallexample
5822
5823 The parts that differ are highlighted with color (``double'' and
5824 ``float'' in this case).
5825
5826 @opindex fno-elide-type
5827 @opindex felide-type
5828 @item -fno-elide-type
5829 By default when the C++ frontend prints diagnostics showing mismatching
5830 template types, common parts of the types are printed as ``[...]'' to
5831 simplify the error message. For example:
5832
5833 @smallexample
5834 could not convert 'std::map<int, std::vector<double> >()'
5835 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5836 @end smallexample
5837
5838 Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5839 This flag also affects the output of the
5840 @option{-fdiagnostics-show-template-tree} flag.
5841
5842 @opindex fdiagnostics-path-format
5843 @item -fdiagnostics-path-format=@var{KIND}
5844 Specify how to print paths of control-flow events for diagnostics that
5845 have such a path associated with them.
5846
5847 @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5848 the default.
5849
5850 @samp{none} means to not print diagnostic paths.
5851
5852 @samp{separate-events} means to print a separate ``note'' diagnostic for
5853 each event within the diagnostic. For example:
5854
5855 @smallexample
5856 test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5857 test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5858 test.c:27:3: note: (2) when 'i < count'
5859 test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5860 @end smallexample
5861
5862 @samp{inline-events} means to print the events ``inline'' within the source
5863 code. This view attempts to consolidate the events into runs of
5864 sufficiently-close events, printing them as labelled ranges within the source.
5865
5866 For example, the same events as above might be printed as:
5867
5868 @smallexample
5869 'test': events 1-3
5870 25 | list = PyList_New(0);
5871 | ^~~~~~~~~~~~~
5872 | |
5873 | (1) when 'PyList_New' fails, returning NULL
5874 26 |
5875 27 | for (i = 0; i < count; i++) @{
5876 | ~~~
5877 | |
5878 | (2) when 'i < count'
5879 28 | item = PyLong_FromLong(random());
5880 29 | PyList_Append(list, item);
5881 | ~~~~~~~~~~~~~~~~~~~~~~~~~
5882 | |
5883 | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5884 @end smallexample
5885
5886 Interprocedural control flow is shown by grouping the events by stack frame,
5887 and using indentation to show how stack frames are nested, pushed, and popped.
5888
5889 For example:
5890
5891 @smallexample
5892 'test': events 1-2
5893 |
5894 | 133 | @{
5895 | | ^
5896 | | |
5897 | | (1) entering 'test'
5898 | 134 | boxed_int *obj = make_boxed_int (i);
5899 | | ~~~~~~~~~~~~~~~~~~
5900 | | |
5901 | | (2) calling 'make_boxed_int'
5902 |
5903 +--> 'make_boxed_int': events 3-4
5904 |
5905 | 120 | @{
5906 | | ^
5907 | | |
5908 | | (3) entering 'make_boxed_int'
5909 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5910 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5911 | | |
5912 | | (4) calling 'wrapped_malloc'
5913 |
5914 +--> 'wrapped_malloc': events 5-6
5915 |
5916 | 7 | @{
5917 | | ^
5918 | | |
5919 | | (5) entering 'wrapped_malloc'
5920 | 8 | return malloc (size);
5921 | | ~~~~~~~~~~~~~
5922 | | |
5923 | | (6) calling 'malloc'
5924 |
5925 <-------------+
5926 |
5927 'test': event 7
5928 |
5929 | 138 | free_boxed_int (obj);
5930 | | ^~~~~~~~~~~~~~~~~~~~
5931 | | |
5932 | | (7) calling 'free_boxed_int'
5933 |
5934 (etc)
5935 @end smallexample
5936
5937 @opindex fdiagnostics-show-path-depths
5938 @item -fdiagnostics-show-path-depths
5939 This option provides additional information when printing control-flow paths
5940 associated with a diagnostic.
5941
5942 If this is option is provided then the stack depth will be printed for
5943 each run of events within @option{-fdiagnostics-path-format=inline-events}.
5944 If provided with @option{-fdiagnostics-path-format=separate-events}, then
5945 the stack depth and function declaration will be appended when printing
5946 each event.
5947
5948 This is intended for use by GCC developers and plugin developers when
5949 debugging diagnostics that report interprocedural control flow.
5950
5951 @opindex fno-show-column
5952 @opindex fshow-column
5953 @item -fno-show-column
5954 Do not print column numbers in diagnostics. This may be necessary if
5955 diagnostics are being scanned by a program that does not understand the
5956 column numbers, such as @command{dejagnu}.
5957
5958 @opindex fdiagnostics-column-unit
5959 @item -fdiagnostics-column-unit=@var{UNIT}
5960 Select the units for the column number. This affects traditional diagnostics
5961 (in the absence of @option{-fno-show-column}).
5962
5963 The default @var{UNIT}, @samp{display}, considers the number of display
5964 columns occupied by each character. This may be larger than the number
5965 of bytes required to encode the character, in the case of tab
5966 characters, or it may be smaller, in the case of multibyte characters.
5967 For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5968 display column, and its UTF-8 encoding requires two bytes; the character
5969 ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5970 its UTF-8 encoding requires four bytes.
5971
5972 Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5973 count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5974
5975 @opindex fdiagnostics-column-origin
5976 @item -fdiagnostics-column-origin=@var{ORIGIN}
5977 Select the origin for column numbers, i.e. the column number assigned to the
5978 first column. The default value of 1 corresponds to traditional GCC
5979 behavior and to the GNU style guide. Some utilities may perform better with an
5980 origin of 0; any non-negative value may be specified.
5981
5982 @opindex fdiagnostics-escape-format
5983 @item -fdiagnostics-escape-format=@var{FORMAT}
5984 When GCC prints pertinent source lines for a diagnostic it normally attempts
5985 to print the source bytes directly. However, some diagnostics relate to encoding
5986 issues in the source file, such as malformed UTF-8, or issues with Unicode
5987 normalization. These diagnostics are flagged so that GCC will escape bytes
5988 that are not printable ASCII when printing their pertinent source lines.
5989
5990 This option controls how such bytes should be escaped.
5991
5992 The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5993 are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5994 correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5995 displayed as hexadecimal in the form @samp{<XX>}.
5996
5997 For example, a source line containing the string @samp{before} followed by the
5998 Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
5999 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
6000 the string @samp{after} will be printed for such a diagnostic as:
6001
6002 @smallexample
6003 before<U+03C0><BF>after
6004 @end smallexample
6005
6006 Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
6007 in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
6008 Unicode characters. For the example above, the following will be printed:
6009
6010 @smallexample
6011 before<CF><80><BF>after
6012 @end smallexample
6013
6014 @opindex fdiagnostics-text-art-charset
6015 @item -fdiagnostics-text-art-charset=@var{CHARSET}
6016 Some diagnostics can contain ``text art'' diagrams: visualizations created
6017 from text, intended to be viewed in a monospaced font.
6018
6019 This option selects which characters should be used for printing such
6020 diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode},
6021 or @samp{emoji}.
6022
6023 The @samp{none} value suppresses the printing of such diagrams.
6024 The @samp{ascii} value will ensure that such diagrams are pure ASCII
6025 (``ASCII art''). The @samp{unicode} value will allow for conservative use of
6026 unicode drawing characters (such as box-drawing characters). The @samp{emoji}
6027 value further adds the possibility of emoji in the output (such as emitting
6028 U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the
6029 emoji variant of the character).
6030
6031 The default is @samp{emoji}, except when the environment variable @env{LANG}
6032 is set to @samp{C}, in which case the default is @samp{ascii}.
6033
6034 @opindex fdiagnostics-format
6035 @item -fdiagnostics-format=@var{FORMAT}
6036 Select a different format for printing diagnostics.
6037 @var{FORMAT} is @samp{text}, @samp{sarif-stderr} or @samp{sarif-file}.
6038
6039 Using this option replaces any additional ``output sinks'' added by
6040 @option{-fdiagnostics-add-output=}, or that set by
6041 @option{-fdiagnostics-set-output=}.
6042
6043 The default is @samp{text}.
6044
6045 The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
6046 diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
6047 named @file{@var{source}.sarif}, respectively.
6048
6049 @opindex fdiagnostics-add-output
6050 @item -fdiagnostics-add-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
6051 Add an additional ``output sink'' for emitting diagnostics.
6052
6053 @var{DIAGNOSTICS-OUTPUT-SPEC} should specify a scheme, optionally followed
6054 by @code{:} and one or more @var{KEY}=@var{VALUE} pairs, in this form:
6055
6056 @smallexample
6057 @var{SCHEME}
6058 @var{SCHEME}:@var{KEY}=@var{VALUE}
6059 @var{SCHEME}:@var{KEY}=@var{VALUE},@var{KEY2}=@var{VALUE2}
6060 @end smallexample
6061
6062 etc.
6063
6064 Schemes, keys, or values with a name prefixed ``experimental'' may change
6065 or be removed without notice.
6066
6067 @var{SCHEME} can be
6068
6069 @table @gcctabopt
6070
6071 @item text
6072 Emit diagnostics to stderr using GCC's classic text output format.
6073
6074 Supported keys are:
6075
6076 @table @gcctabopt
6077
6078 @item color=@r{[}yes@r{|}no@r{]}
6079 Override colorization settings from @option{-fdiagnostics-color} for this
6080 text output.
6081
6082 @item experimental-nesting=@r{[}yes@r{|}no@r{]}
6083 Enable an experimental mode that emphasizes hierarchical relationships
6084 within diagnostics messages, displaying location information on separate
6085 lines.
6086
6087 @item experimental-nesting-show-locations=@r{[}yes@r{|}no@r{]}
6088 If @code{experimental-nesting=yes}, then by default locations are
6089 shown; set this key to @code{no} to disable printing such locations.
6090 This exists for use by GCC developers, for writing DejaGnu test cases.
6091
6092 @item experimental-nesting-show-levels=@r{[}yes@r{|}no@r{]}
6093 This is a debugging option for use with @code{experimental-nesting=yes}.
6094 Set this key to @code{yes} to print explicit nesting levels in the output.
6095 This exists for use by GCC developers.
6096
6097 @end table
6098
6099 @item sarif
6100 Emit diagnostics to a file in SARIF format.
6101
6102 Supported keys are:
6103
6104 @table @gcctabopt
6105
6106 @item file=@var{FILENAME}
6107 Specify the filename to write the SARIF output to, potentially with a
6108 leading absolute or relative path. If not specified, it defaults to
6109 @file{@var{source}.sarif}.
6110
6111 @item serialization=@r{[}json@r{]}
6112 Specify the serialization format to use when writing out the SARIF.
6113 Currently this can only be @code{json}, but is present as an
6114 extension point for experimenting with other serializations.
6115
6116 @item version=@r{[}2.1@r{|}2.2-prerelease@r{]}
6117 Specify the version of SARIF to use for the output. If not specified,
6118 defaults to 2.1. @code{2.2-prerelease} uses an unofficial draft of the
6119 future SARIF 2.2 specification and should only be used for experimentation
6120 in this release.
6121
6122 @end table
6123
6124 There is also this key intended for use by GCC developers, rather than
6125 end-users, and subject to change or removal without notice:
6126
6127 @table @gcctabopt
6128
6129 @item xml-state=@r{[}yes@r{|}no@r{]}
6130 This is a debugging feature and defaults to @code{no}.
6131 If @code{xml-state=yes}, then attempt to capture detailed state information
6132 from @option{-fanalyzer} in the generated SARIF.
6133
6134 @end table
6135
6136 @item experimental-html
6137 Emit diagnostics to a file in HTML format. This scheme is experimental,
6138 and may go away in future GCC releases. The keys and details of the output
6139 are also subject to change.
6140
6141 Supported keys are:
6142
6143 @table @gcctabopt
6144
6145 @item css=@r{[}yes@r{|}no@r{]}
6146 Add an embedded <style> to the generated HTML. Defaults to yes.
6147
6148 @item file=@var{FILENAME}
6149 Specify the filename to write the HTML output to, potentially with a
6150 leading absolute or relative path. If not specified, it defaults to
6151 @file{@var{source}.html}.
6152
6153 @item javascript=@r{[}yes@r{|}no@r{]}
6154 Add an embedded <script> to the generated HTML providing a barebones UI
6155 for viewing results. Defaults to yes.
6156
6157 @end table
6158
6159 There are also these keys intended for use by GCC developers, rather than
6160 end-users, and subject to change or removal without notice:
6161
6162 @table @gcctabopt
6163
6164 @item show-state-diagrams=@r{[}yes@r{|}no@r{]}
6165 This is a debugging feature and defaults to @code{no}.
6166 If @code{show-state-diagrams=yes}, then attempt to use @command{dot} to
6167 generate SVG diagrams in the generated HTML, visualizing the state at each
6168 event in a diagnostic path.
6169 These are visible by pressing ``j'' and ``k'' to single-step forward and
6170 backward through events. Enabling this option will slow down
6171 HTML generation.
6172
6173 @item show-state-diagrams-dot-src=@r{[}yes@r{|}no@r{]}
6174 This is a debugging feature and defaults to @code{no}.
6175 If @code{show-state-diagrams-dot-src=yes}
6176 then if @code{show-state-diagrams=yes},
6177 the generated state diagrams will also show the .dot source input to
6178 GraphViz used for the diagram.
6179
6180 @item show-state-diagrams-xml=@r{[}yes@r{|}no@r{]}
6181 This is a debugging feature and defaults to @code{no}.
6182 If @code{show-state-diagrams-xml=yes}
6183 then if @code{show-state-diagrams=yes}, the generated state diagrams will
6184 also show an XML representation of the state.
6185
6186 @end table
6187
6188 @end table
6189
6190 For example,
6191
6192 @smallexample
6193 -fdiagnostics-add-output=sarif:version=2.1,file=foo.2.1.sarif
6194 -fdiagnostics-add-output=sarif:version=2.2-prerelease,file=foo.2.2.sarif
6195 @end smallexample
6196
6197 would add a pair of outputs, each writing to a different file, using
6198 versions 2.1 and 2.2 of the SARIF standard respectively.
6199
6200 In EBNF:
6201
6202 @smallexample
6203
6204 @var{diagnostics-output-specifier} = @var{diagnostics-output-name}
6205 | @var{diagnostics-output-name}, ":", @var{key-value-pairs};
6206
6207 @var{diagnostics-output-name} = "text" | "sarif" | "experimental-html";
6208
6209 @var{key-value-pairs} = @var{key-value-pair}
6210 | @var{key-value-pair} "," @var{key-value-pairs};
6211
6212 @var{key-value-pair} = @var{key} "=" @var{value};
6213
6214 @var{key} = ? string without a '=' ? ;
6215 @var{value} = ? string without a ',' ? ;
6216
6217 @end smallexample
6218
6219 @opindex fdiagnostics-set-output
6220 @item -fdiagnostics-set-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
6221 This works in a similar way to @option{-fdiagnostics-add-output=} except
6222 that instead of adding an additional ``output sink'' for diagnostics, it
6223 replaces all existing output sinks, such as from @option{-fdiagnostics-format=},
6224 @option{-fdiagnostics-add-output=}, or a prior call to
6225 @option{-fdiagnostics-set-output=}.
6226
6227 @opindex fno-diagnostics-json-formatting
6228 @opindex fdiagnostics-json-formatting
6229 @item -fno-diagnostics-json-formatting
6230 By default, when JSON is emitted for diagnostics (via
6231 @option{-fdiagnostics-format=sarif-stderr} or
6232 @option{-fdiagnostics-format=sarif-file}),
6233 GCC will add newlines and indentation to visually emphasize the
6234 hierarchical structure of the JSON.
6235
6236 Use @option{-fno-diagnostics-json-formatting} to suppress this whitespace.
6237 It must be passed before the option it is to affect.
6238
6239 This is intended for compatibility with tools that do not expect the output
6240 to contain newlines, such as that emitted by older GCC releases.
6241
6242 @end table
6243
6244 @node Warning Options
6245 @section Options to Request or Suppress Warnings
6246 @cindex options to control warnings
6247 @cindex warning messages
6248 @cindex messages, warning
6249 @cindex suppressing warnings
6250
6251 Warnings are diagnostic messages that report constructions that
6252 are not inherently erroneous but that are risky or suggest there
6253 may have been an error.
6254
6255 The following language-independent options do not enable specific
6256 warnings but control the kinds of diagnostics produced by GCC@.
6257
6258 @table @gcctabopt
6259 @cindex syntax checking
6260 @opindex fsyntax-only
6261 @item -fsyntax-only
6262 Check the code for syntax errors, but don't do anything beyond that.
6263
6264 @opindex fmax-errors
6265 @item -fmax-errors=@var{n}
6266 Limits the maximum number of error messages to @var{n}, at which point
6267 GCC bails out rather than attempting to continue processing the source
6268 code. If @var{n} is 0 (the default), there is no limit on the number
6269 of error messages produced. If @option{-Wfatal-errors} is also
6270 specified, then @option{-Wfatal-errors} takes precedence over this
6271 option.
6272
6273 @opindex w
6274 @item -w
6275 Inhibit all warning messages.
6276
6277 @opindex Werror
6278 @opindex Wno-error
6279 @item -Werror
6280 Turn all warnings into errors.
6281
6282 @opindex Werror=
6283 @opindex Wno-error=
6284 @item -Werror=
6285 Turn the specified warning into an error. The specifier for a warning
6286 is appended; for example @option{-Werror=switch} turns the warnings
6287 controlled by @option{-Wswitch} into errors. This switch takes a
6288 negative form, to be used to negate @option{-Werror} for specific
6289 warnings; for example @option{-Wno-error=switch} makes
6290 @option{-Wswitch} warnings not be errors, even when @option{-Werror}
6291 is in effect.
6292
6293 The warning message for each controllable warning includes the
6294 option that controls the warning. That option can then be used with
6295 @option{-Werror=} and @option{-Wno-error=} as described above.
6296 (Printing of the option in the warning message can be disabled using the
6297 @option{-fno-diagnostics-show-option} flag.)
6298
6299 Note that specifying @option{-Werror=}@var{foo} automatically implies
6300 @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
6301 imply anything.
6302
6303 @opindex Wfatal-errors
6304 @opindex Wno-fatal-errors
6305 @item -Wfatal-errors
6306 This option causes the compiler to abort compilation on the first error
6307 occurred rather than trying to keep going and printing further error
6308 messages.
6309
6310 @end table
6311
6312 You can request many specific warnings with options beginning with
6313 @samp{-W}, for example @option{-Wunused-variable} to request warnings on
6314 declarations of variables that are never used.
6315 Each of these specific warning options also
6316 has a negative form beginning with @samp{-Wno-} to turn off warnings; for
6317 example, @option{-Wno-unused-variable}. This manual lists only one of the
6318 two forms, whichever is not the default. For further
6319 language-specific options also refer to @ref{C++ Dialect Options} and
6320 @ref{Objective-C and Objective-C++ Dialect Options}.
6321 Additional warnings can be produced by enabling the static analyzer;
6322 @xref{Static Analyzer Options}.
6323
6324 Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
6325 options, such as @option{-Wunused}, which may turn on further options,
6326 such as @option{-Wunused-variable}. The combined effect of positive and
6327 negative forms is that more specific options have priority over less
6328 specific ones, independently of their position in the command line. For
6329 options of the same specificity, the last one takes effect. Options
6330 enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
6331 as if they appeared at the end of the command line.
6332
6333 When an unrecognized warning option is requested (e.g.,
6334 @option{-Wunknown-warning}), GCC gives an error stating
6335 that the option is not recognized. However, if the @option{-Wno-} form
6336 is used, the behavior is slightly different: no diagnostic is
6337 produced for @option{-Wno-unknown-warning} unless other diagnostics
6338 are being produced. This allows the use of new @option{-Wno-} options
6339 with old compilers, but if something goes wrong, the compiler
6340 warns that an unrecognized option is present.
6341
6342 The effectiveness of some warnings depends on optimizations also being
6343 enabled. For example, @option{-Wsuggest-final-types} is more effective
6344 with link-time optimization. Some other warnings may
6345 not be issued at all unless optimization is enabled. While optimization
6346 in general improves the efficacy of warnings about control and data-flow
6347 problems, in some cases it may also cause false positives.
6348
6349 @table @gcctabopt
6350 @opindex pedantic
6351 @opindex Wpedantic
6352 @opindex Wno-pedantic
6353 @item -Wpedantic
6354 @itemx -pedantic
6355 Issue all the warnings demanded by strict ISO C and ISO C++;
6356 diagnose all programs that use forbidden extensions, and some other
6357 programs that do not follow ISO C and ISO C++. This follows the version
6358 of the ISO C or C++ standard specified by any @option{-std} option used.
6359
6360 Valid ISO C and ISO C++ programs should compile properly with or without
6361 this option (though a rare few require @option{-ansi} or a
6362 @option{-std} option specifying the version of the standard)@. However,
6363 without this option, certain GNU extensions and traditional C and C++
6364 features are supported as well. With this option, they are diagnosed
6365 (or rejected with @option{-pedantic-errors}).
6366
6367 @option{-Wpedantic} does not cause warning messages for use of the
6368 alternate keywords whose names begin and end with @samp{__}. This alternate
6369 format can also be used to disable warnings for non-ISO @samp{__intN} types,
6370 i.e. @samp{__intN__}.
6371 Pedantic warnings are also disabled in the expression that follows
6372 @code{__extension__}. However, only system header files should use
6373 these escape routes; application programs should avoid them.
6374 @xref{Alternate Keywords}.
6375
6376 Some warnings about non-conforming programs are controlled by options
6377 other than @option{-Wpedantic}; in many cases they are implied by
6378 @option{-Wpedantic} but can be disabled separately by their specific
6379 option, e.g. @option{-Wpedantic -Wno-pointer-sign}.
6380
6381 Where the standard specified with @option{-std} represents a GNU
6382 extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6383 corresponding @dfn{base standard}, the version of ISO C on which the GNU
6384 extended dialect is based. Warnings from @option{-Wpedantic} are given
6385 where they are required by the base standard. (It does not make sense
6386 for such warnings to be given only for features not in the specified GNU
6387 C dialect, since by definition the GNU dialects of C include all
6388 features the compiler supports with the given option, and there would be
6389 nothing to warn about.)
6390
6391 @opindex pedantic-errors
6392 @item -pedantic-errors
6393 Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6394 requires a diagnostic, in some cases where there is undefined behavior
6395 at compile-time and in some other cases that do not prevent compilation
6396 of programs that are valid according to the standard. This is not
6397 equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be
6398 useful, as it only makes errors of the diagnostics that are controlled by
6399 @option{-Wpedantic}, whereas this option also affects required diagnostics that
6400 are always enabled or controlled by options other than @option{-Wpedantic}.
6401
6402 If you want the required diagnostics that are warnings by default to
6403 be errors instead, but don't also want to enable the @option{-Wpedantic}
6404 diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic}
6405 (or @option{-pedantic-errors -Wno-error=pedantic} to enable them but
6406 only as warnings).
6407
6408 Some required diagnostics are errors by default, but can be reduced to
6409 warnings using @option{-fpermissive} or their specific warning option,
6410 e.g. @option{-Wno-error=narrowing}.
6411
6412 Some diagnostics for non-ISO practices are controlled by specific
6413 warning options other than @option{-Wpedantic}, but are also made
6414 errors by @option{-pedantic-errors}. For instance:
6415
6416 @gccoptlist{
6417 -Wattributes @r{(for standard attributes)}
6418 -Wchanges-meaning @r{(C++)}
6419 -Wcomma-subscript @r{(C++23 or later)}
6420 -Wdeclaration-after-statement @r{(C90 or earlier)}
6421 -Welaborated-enum-base @r{(C++11 or later)}
6422 -Wimplicit-int @r{(C99 or later)}
6423 -Wimplicit-function-declaration @r{(C99 or later)}
6424 -Wincompatible-pointer-types
6425 -Wint-conversion
6426 -Wlong-long @r{(C90 or earlier)}
6427 -Wmain
6428 -Wnarrowing @r{(C++11 or later)}
6429 -Wpointer-arith
6430 -Wpointer-sign
6431 -Wincompatible-pointer-types
6432 -Wregister @r{(C++17 or later)}
6433 -Wvla @r{(C90 or earlier)}
6434 -Wwrite-strings @r{(C++11 or later)}
6435 }
6436
6437 @opindex fpermissive
6438 @item -fpermissive
6439 Downgrade some required diagnostics about nonconformant code from
6440 errors to warnings. Thus, using @option{-fpermissive} allows some
6441 nonconforming code to compile. Some C++ diagnostics are controlled
6442 only by this flag, but it also downgrades some C and C++ diagnostics
6443 that have their own flag:
6444
6445 @gccoptlist{
6446 -Wdeclaration-missing-parameter-type @r{(C and Objective-C only)}
6447 -Wimplicit-function-declaration @r{(C and Objective-C only)}
6448 -Wimplicit-int @r{(C and Objective-C only)}
6449 -Wincompatible-pointer-types @r{(C and Objective-C only)}
6450 -Wint-conversion @r{(C and Objective-C only)}
6451 -Wnarrowing @r{(C++ and Objective-C++ only)}
6452 -Wreturn-mismatch @r{(C and Objective-C only)}
6453 -Wtemplate-body @r{(C++ and Objective-C++ only)}
6454 }
6455
6456 The @option{-fpermissive} option is the default for historic C language
6457 modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90},
6458 @option{-std=gnu90}).
6459
6460 @opindex Wall
6461 @opindex Wno-all
6462 @item -Wall
6463 This enables all the warnings about constructions that some users
6464 consider questionable, and that are easy to avoid (or modify to
6465 prevent the warning), even in conjunction with macros. This also
6466 enables some language-specific warnings described in @ref{C++ Dialect
6467 Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6468
6469 @option{-Wall} turns on the following warning flags:
6470
6471 @gccoptlist{-Waddress
6472 -Waligned-new @r{(C++ and Objective-C++ only)}
6473 -Warray-bounds=1 @r{(only with} @option{-O2}@r{)}
6474 -Warray-compare
6475 -Warray-parameter=2
6476 -Wbool-compare
6477 -Wbool-operation
6478 -Wc++11-compat -Wc++14-compat -Wc++17compat -Wc++20compat
6479 -Wcatch-value @r{(C++ and Objective-C++ only)}
6480 -Wchar-subscripts
6481 -Wclass-memaccess @r{(C++ and Objective-C++ only)}
6482 -Wcomment
6483 -Wdangling-else
6484 -Wdangling-pointer=2
6485 -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
6486 -Wduplicate-decl-specifier @r{(C and Objective-C only)}
6487 -Wenum-compare @r{(in C/ObjC; this is on by default in C++)}
6488 -Wenum-int-mismatch @r{(C and Objective-C only)}
6489 -Wformat=1
6490 -Wformat-contains-nul
6491 -Wformat-diag
6492 -Wformat-extra-args
6493 -Wformat-overflow=1
6494 -Wformat-truncation=1
6495 -Wformat-zero-length
6496 -Wframe-address
6497 -Wimplicit @r{(C and Objective-C only)}
6498 -Wimplicit-function-declaration @r{(C and Objective-C only)}
6499 -Wimplicit-int @r{(C and Objective-C only)}
6500 -Winfinite-recursion
6501 -Winit-self @r{(C++ and Objective-C++ only)}
6502 -Wint-in-bool-context
6503 -Wlogical-not-parentheses
6504 -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}
6505 -Wmaybe-uninitialized
6506 -Wmemset-elt-size
6507 -Wmemset-transposed-args
6508 -Wmisleading-indentation @r{(only for C/C++)}
6509 -Wmismatched-dealloc
6510 -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
6511 -Wmissing-attributes
6512 -Wmissing-braces @r{(only for C/ObjC)}
6513 -Wmultistatement-macros
6514 -Wnarrowing @r{(C++ and Objective-C++ only)}
6515 -Wnonnull
6516 -Wnonnull-compare
6517 -Wopenmp-simd @r{(C and C++ only)}
6518 -Woverloaded-virtual=1 @r{(C++ and Objective-C++ only)}
6519 -Wpacked-not-aligned
6520 -Wparentheses
6521 -Wpessimizing-move @r{(C++ and Objective-C++ only)}
6522 -Wpointer-sign @r{(only for C/ObjC)}
6523 -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
6524 -Wreorder @r{(C++ and Objective-C++ only)}
6525 -Wrestrict
6526 -Wreturn-type
6527 -Wself-move @r{(C++ and Objective-C++ only)}
6528 -Wsequence-point
6529 -Wsign-compare @r{(C++ and Objective-C++ only)}
6530 -Wsizeof-array-div
6531 -Wsizeof-pointer-div
6532 -Wsizeof-pointer-memaccess
6533 -Wstrict-aliasing
6534 -Wstrict-overflow=1
6535 -Wswitch
6536 -Wtautological-compare
6537 -Wtrigraphs
6538 -Wuninitialized
6539 -Wunknown-pragmas
6540 -Wunused
6541 -Wunused-but-set-variable
6542 -Wunused-const-variable=1 @r{(only for C/ObjC)}
6543 -Wunused-function
6544 -Wunused-label
6545 -Wunused-local-typedefs
6546 -Wunused-value
6547 -Wunused-variable
6548 -Wuse-after-free=2
6549 -Wvla-parameter
6550 -Wvolatile-register-var
6551 -Wzero-length-bounds}
6552
6553 Note that some warning flags are not implied by @option{-Wall}. Some of
6554 them warn about constructions that users generally do not consider
6555 questionable, but which occasionally you might wish to check for;
6556 others warn about constructions that are necessary or hard to avoid in
6557 some cases, and there is no simple way to modify the code to suppress
6558 the warning. Some of them are enabled by @option{-Wextra} but many of
6559 them must be enabled individually.
6560
6561 @opindex W
6562 @opindex Wextra
6563 @opindex Wno-extra
6564 @item -Wextra
6565 This enables some extra warning flags that are not enabled by
6566 @option{-Wall}. (This option used to be called @option{-W}. The older
6567 name is still supported, but the newer name is more descriptive.)
6568
6569 @gccoptlist{-Wabsolute-value @r{(only for C/ObjC)}
6570 -Walloc-size
6571 -Wcalloc-transposed-args
6572 -Wcast-function-type
6573 -Wclobbered
6574 -Wdangling-reference @r{(C++ only)}
6575 -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
6576 -Wempty-body
6577 -Wenum-conversion @r{(only for C/ObjC)}
6578 -Wexpansion-to-defined
6579 -Wignored-qualifiers @r{(only for C/C++)}
6580 -Wimplicit-fallthrough=3
6581 -Wmaybe-uninitialized
6582 -Wmissing-field-initializers
6583 -Wmissing-parameter-name @r{(C/ObjC only)}
6584 -Wmissing-parameter-type @r{(C/ObjC only)}
6585 -Wold-style-declaration @r{(C/ObjC only)}
6586 -Woverride-init @r{(C/ObjC only)}
6587 -Wredundant-move @r{(C++ and Objective-C++ only)}
6588 -Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
6589 -Wsign-compare @r{(C++ and Objective-C++ only)}
6590 -Wsized-deallocation @r{(C++ and Objective-C++ only)}
6591 -Wstring-compare
6592 -Wtype-limits
6593 -Wuninitialized
6594 -Wunterminated-string-initialization
6595 -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
6596 -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6597
6598 The option @option{-Wextra} also prints warning messages for the
6599 following cases:
6600
6601 @itemize @bullet
6602
6603 @item
6604 A pointer is compared against integer zero with @code{<}, @code{<=},
6605 @code{>}, or @code{>=}.
6606
6607 @item
6608 (C++ only) An enumerator and a non-enumerator both appear in a
6609 conditional expression.
6610
6611 @item
6612 (C++ only) Ambiguous virtual bases.
6613
6614 @item
6615 (C++ only) Subscripting an array that has been declared @code{register}.
6616
6617 @item
6618 (C++ only) Taking the address of a variable that has been declared
6619 @code{register}.
6620
6621 @item
6622 (C++ only) A base class is not initialized in the copy constructor
6623 of a derived class.
6624
6625 @end itemize
6626
6627 @opindex Wabi
6628 @opindex Wno-abi
6629 @item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
6630
6631 Warn about code affected by ABI changes. This includes code that may
6632 not be compatible with the vendor-neutral C++ ABI as well as the psABI
6633 for the particular target. The latter warnings are also controlled
6634 separately by @option{-Wpsabi}, which is implied by @option{-Wabi}.
6635
6636 Since G++ now defaults to updating the ABI with each major release,
6637 normally @option{-Wabi} warns only about C++ ABI compatibility
6638 problems if there is a check added later in a release series for an
6639 ABI issue discovered since the initial release. @option{-Wabi} warns
6640 about more things if an older ABI version is selected (with
6641 @option{-fabi-version=@var{n}}).
6642
6643 @option{-Wabi} can also be used with an explicit version number to
6644 warn about C++ ABI compatibility with a particular @option{-fabi-version}
6645 level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6646 @option{-fabi-version=2}.
6647
6648 If an explicit version number is provided and
6649 @option{-fabi-compat-version} is not specified, the version number
6650 from this option is used for compatibility aliases. If no explicit
6651 version number is provided with this option, but
6652 @option{-fabi-compat-version} is specified, that version number is
6653 used for C++ ABI warnings.
6654
6655 Although an effort has been made to warn about
6656 all such cases, there are probably some cases that are not warned about,
6657 even though G++ is generating incompatible code. There may also be
6658 cases where warnings are emitted even though the code that is generated
6659 is compatible.
6660
6661 You should rewrite your code to avoid these warnings if you are
6662 concerned about the fact that code generated by G++ may not be binary
6663 compatible with code generated by other compilers.
6664
6665 Known incompatibilities in @option{-fabi-version=2} (which was the
6666 default from GCC 3.4 to 4.9) include:
6667
6668 @itemize @bullet
6669
6670 @item
6671 A template with a non-type template parameter of reference type was
6672 mangled incorrectly:
6673 @smallexample
6674 extern int N;
6675 template <int &> struct S @{@};
6676 void n (S<N>) @{2@}
6677 @end smallexample
6678
6679 This was fixed in @option{-fabi-version=3}.
6680
6681 @item
6682 SIMD vector types declared using @code{__attribute ((vector_size))} were
6683 mangled in a non-standard way that does not allow for overloading of
6684 functions taking vectors of different sizes.
6685
6686 The mangling was changed in @option{-fabi-version=4}.
6687
6688 @item
6689 @code{__attribute ((const))} and @code{noreturn} were mangled as type
6690 qualifiers, and @code{decltype} of a plain declaration was folded away.
6691
6692 These mangling issues were fixed in @option{-fabi-version=5}.
6693
6694 @item
6695 Scoped enumerators passed as arguments to a variadic function are
6696 promoted like unscoped enumerators, causing @code{va_arg} to complain.
6697 On most targets this does not actually affect the parameter passing
6698 ABI, as there is no way to pass an argument smaller than @code{int}.
6699
6700 Also, the ABI changed the mangling of template argument packs,
6701 @code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6702 a class scope function used as a template argument.
6703
6704 These issues were corrected in @option{-fabi-version=6}.
6705
6706 @item
6707 Lambdas in default argument scope were mangled incorrectly, and the
6708 ABI changed the mangling of @code{nullptr_t}.
6709
6710 These issues were corrected in @option{-fabi-version=7}.
6711
6712 @item
6713 When mangling a function type with function-cv-qualifiers, the
6714 un-qualified function type was incorrectly treated as a substitution
6715 candidate.
6716
6717 This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6718
6719 @item
6720 @code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6721 unaligned accesses. Note that this did not affect the ABI of a
6722 function with a @code{nullptr_t} parameter, as parameters have a
6723 minimum alignment.
6724
6725 This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6726
6727 @item
6728 Target-specific attributes that affect the identity of a type, such as
6729 ia32 calling conventions on a function type (stdcall, regparm, etc.),
6730 did not affect the mangled name, leading to name collisions when
6731 function pointers were used as template arguments.
6732
6733 This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6734
6735 @end itemize
6736
6737 @opindex Wpsabi
6738 @opindex Wno-psabi
6739 @item -Wpsabi @r{(C, Objective-C, C++ and Objective-C++ only)}
6740
6741 @option{-Wpsabi} enables warnings about processor-specific ABI
6742 changes, such as changes in alignment requirements or how function
6743 arguments are passed. On several targets, including AArch64, ARM,
6744 x86, MIPS, RS6000/PowerPC, and S/390, these details have changed
6745 between different versions of GCC and/or different versions of the C
6746 or C++ language standards in ways that affect binary compatibility of
6747 compiled code. With @option{-Wpsabi}, GCC can detect potentially
6748 incompatible usages and warn you about them.
6749
6750 @option{-Wpsabi} is enabled by default, and is also implied by
6751 @option{-Wabi}.
6752
6753 @opindex Wchanges-meaning
6754 @opindex Wno-changes-meaning
6755 @item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6756 C++ requires that unqualified uses of a name within a class have the
6757 same meaning in the complete scope of the class, so declaring the name
6758 after using it is ill-formed:
6759 @smallexample
6760 struct A;
6761 struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6762 struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6763 @end smallexample
6764 By default, the B1 case is only a warning because the two declarations
6765 have the same type, while the B2 case is an error. Both diagnostics
6766 can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6767 error case can be reduced to a warning with
6768 @option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6769
6770 Both diagnostics are also suppressed by @option{-fms-extensions}.
6771
6772 @opindex Wchar-subscripts
6773 @opindex Wno-char-subscripts
6774 @item -Wchar-subscripts
6775 Warn if an array subscript has type @code{char}. This is a common cause
6776 of error, as programmers often forget that this type is signed on some
6777 machines.
6778 This warning is enabled by @option{-Wall}.
6779
6780 @opindex Wno-coverage-mismatch
6781 @opindex Wcoverage-mismatch
6782 @item -Wno-coverage-mismatch
6783 Warn if feedback profiles do not match when using the
6784 @option{-fprofile-use} option.
6785 If a source file is changed between compiling with @option{-fprofile-generate}
6786 and with @option{-fprofile-use}, the files with the profile feedback can fail
6787 to match the source file and GCC cannot use the profile feedback
6788 information. By default, this warning is enabled and is treated as an
6789 error. @option{-Wno-coverage-mismatch} can be used to disable the
6790 warning or @option{-Wno-error=coverage-mismatch} can be used to
6791 disable the error. Disabling the error for this warning can result in
6792 poorly optimized code and is useful only in the
6793 case of very minor changes such as bug fixes to an existing code-base.
6794 Completely disabling the warning is not recommended.
6795
6796 @opindex Wno-coverage-too-many-conditions
6797 @opindex Wcoverage-too-many-conditions
6798 @item -Wno-coverage-too-many-conditions
6799 Warn if @option{-fcondition-coverage} is used and an expression have too many
6800 terms and GCC gives up coverage. Coverage is given up when there are more
6801 terms in the conditional than there are bits in a @code{gcov_type_unsigned}.
6802 This warning is enabled by default.
6803
6804 @opindex Wno-coverage-too-many-paths
6805 @opindex Wcoverage-too-many-paths
6806 @item -Wno-coverage-too-many-paths
6807 Warn if @option{-fpath-coverage} is used and a function has too many
6808 paths and GCC gives up coverage. Giving up is controlled by
6809 @option{-fpath-coverage-limit}. This warning is enabled by default.
6810
6811 @opindex Wno-coverage-invalid-line-number
6812 @opindex Wcoverage-invalid-line-number
6813 @item -Wno-coverage-invalid-line-number
6814 Warn in case a function ends earlier than it begins due
6815 to an invalid linenum macros. The warning is emitted only
6816 with @option{--coverage} enabled.
6817
6818 By default, this warning is enabled and is treated as an
6819 error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6820 warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6821 disable the error.
6822
6823 @opindex Wno-cpp
6824 @opindex Wcpp
6825 @item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
6826 Suppress warning messages emitted by @code{#warning} directives.
6827
6828 @opindex Wdouble-promotion
6829 @opindex Wno-double-promotion
6830 @item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
6831 Give a warning when a value of type @code{float} is implicitly
6832 promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6833 floating-point unit implement @code{float} in hardware, but emulate
6834 @code{double} in software. On such a machine, doing computations
6835 using @code{double} values is much more expensive because of the
6836 overhead required for software emulation.
6837
6838 It is easy to accidentally do computations with @code{double} because
6839 floating-point literals are implicitly of type @code{double}. For
6840 example, in:
6841 @smallexample
6842 @group
6843 float area(float radius)
6844 @{
6845 return 3.14159 * radius * radius;
6846 @}
6847 @end group
6848 @end smallexample
6849 the compiler performs the entire computation with @code{double}
6850 because the floating-point literal is a @code{double}.
6851
6852 @opindex Wduplicate-decl-specifier
6853 @opindex Wno-duplicate-decl-specifier
6854 @item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
6855 Warn if a declaration has duplicate @code{const}, @code{volatile},
6856 @code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6857 @option{-Wall}.
6858
6859 @opindex Wformat
6860 @opindex Wno-format
6861 @opindex ffreestanding
6862 @opindex fno-builtin
6863 @opindex Wformat=
6864 @item -Wformat
6865 @itemx -Wformat=@var{n}
6866 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6867 the arguments supplied have types appropriate to the format string
6868 specified, and that the conversions specified in the format string make
6869 sense. This includes standard functions, and others specified by format
6870 attributes (@pxref{Function Attributes}), in the @code{printf},
6871 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6872 not in the C standard) families (or other target-specific families).
6873 Which functions are checked without format attributes having been
6874 specified depends on the standard version selected, and such checks of
6875 functions without the attribute specified are disabled by
6876 @option{-ffreestanding} or @option{-fno-builtin}.
6877
6878 The formats are checked against the format features supported by GNU
6879 libc version 2.2. These include all ISO C90 and C99 features, as well
6880 as features from the Single Unix Specification and some BSD and GNU
6881 extensions. Other library implementations may not support all these
6882 features; GCC does not support warning about features that go beyond a
6883 particular library's limitations. However, if @option{-Wpedantic} is used
6884 with @option{-Wformat}, warnings are given about format features not
6885 in the selected standard version (but not for @code{strfmon} formats,
6886 since those are not in any version of the C standard). @xref{C Dialect
6887 Options,,Options Controlling C Dialect}.
6888
6889 @table @gcctabopt
6890 @opindex Wformat
6891 @opindex Wformat=1
6892 @item -Wformat=1
6893 @itemx -Wformat
6894 Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6895 @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6896 @option{-Wformat} also checks for null format arguments for several
6897 functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6898 aspects of this level of format checking can be disabled by the
6899 options: @option{-Wno-format-contains-nul},
6900 @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6901 @option{-Wformat} is enabled by @option{-Wall}.
6902
6903 @opindex Wformat=2
6904 @item -Wformat=2
6905 Enable @option{-Wformat} plus additional format checks. Currently
6906 equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6907 -Wformat-y2k}.
6908 @end table
6909
6910 @opindex Wno-format-contains-nul
6911 @opindex Wformat-contains-nul
6912 @item -Wno-format-contains-nul
6913 If @option{-Wformat} is specified, do not warn about format strings that
6914 contain NUL bytes.
6915
6916 @opindex Wno-format-extra-args
6917 @opindex Wformat-extra-args
6918 @item -Wno-format-extra-args
6919 If @option{-Wformat} is specified, do not warn about excess arguments to a
6920 @code{printf} or @code{scanf} format function. The C standard specifies
6921 that such arguments are ignored.
6922
6923 Where the unused arguments lie between used arguments that are
6924 specified with @samp{$} operand number specifications, normally
6925 warnings are still given, since the implementation could not know what
6926 type to pass to @code{va_arg} to skip the unused arguments. However,
6927 in the case of @code{scanf} formats, this option suppresses the
6928 warning if the unused arguments are all pointers, since the Single
6929 Unix Specification says that such unused arguments are allowed.
6930
6931 @opindex Wformat-overflow
6932 @opindex Wno-format-overflow
6933 @item -Wformat-overflow
6934 @itemx -Wformat-overflow=@var{level}
6935 Warn about calls to formatted input/output functions such as @code{sprintf}
6936 and @code{vsprintf} that might overflow the destination buffer. When the
6937 exact number of bytes written by a format directive cannot be determined
6938 at compile-time it is estimated based on heuristics that depend on the
6939 @var{level} argument and on optimization. While enabling optimization
6940 will in most cases improve the accuracy of the warning, it may also
6941 result in false positives.
6942
6943 @table @gcctabopt
6944 @opindex Wformat-overflow
6945 @opindex Wno-format-overflow
6946 @item -Wformat-overflow
6947 @itemx -Wformat-overflow=1
6948 Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6949 employs a conservative approach that warns only about calls that most
6950 likely overflow the buffer. At this level, numeric arguments to format
6951 directives with unknown values are assumed to have the value of one, and
6952 strings of unknown length to be empty. Numeric arguments that are known
6953 to be bounded to a subrange of their type, or string arguments whose output
6954 is bounded either by their directive's precision or by a finite set of
6955 string literals, are assumed to take on the value within the range that
6956 results in the most bytes on output. For example, the call to @code{sprintf}
6957 below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6958 the terminating NUL character (@code{'\0'}) appended by the function
6959 to the destination buffer will be written past its end. Increasing
6960 the size of the buffer by a single byte is sufficient to avoid the
6961 warning, though it may not be sufficient to avoid the overflow.
6962
6963 @smallexample
6964 void f (int a, int b)
6965 @{
6966 char buf [13];
6967 sprintf (buf, "a = %i, b = %i\n", a, b);
6968 @}
6969 @end smallexample
6970
6971 @item -Wformat-overflow=2
6972 Level @var{2} warns also about calls that might overflow the destination
6973 buffer given an argument of sufficient length or magnitude. At level
6974 @var{2}, unknown numeric arguments are assumed to have the minimum
6975 representable value for signed types with a precision greater than 1, and
6976 the maximum representable value otherwise. Unknown string arguments whose
6977 length cannot be assumed to be bounded either by the directive's precision,
6978 or by a finite set of string literals they may evaluate to, or the character
6979 array they may point to, are assumed to be 1 character long.
6980
6981 At level @var{2}, the call in the example above is again diagnosed, but
6982 this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6983 @code{%i} directive will write some of its digits beyond the end of
6984 the destination buffer. To make the call safe regardless of the values
6985 of the two variables, the size of the destination buffer must be increased
6986 to at least 34 bytes. GCC includes the minimum size of the buffer in
6987 an informational note following the warning.
6988
6989 An alternative to increasing the size of the destination buffer is to
6990 constrain the range of formatted values. The maximum length of string
6991 arguments can be bounded by specifying the precision in the format
6992 directive. When numeric arguments of format directives can be assumed
6993 to be bounded by less than the precision of their type, choosing
6994 an appropriate length modifier to the format specifier will reduce
6995 the required buffer size. For example, if @var{a} and @var{b} in the
6996 example above can be assumed to be within the precision of
6997 the @code{short int} type then using either the @code{%hi} format
6998 directive or casting the argument to @code{short} reduces the maximum
6999 required size of the buffer to 24 bytes.
7000
7001 @smallexample
7002 void f (int a, int b)
7003 @{
7004 char buf [23];
7005 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
7006 @}
7007 @end smallexample
7008 @end table
7009
7010 @opindex Wno-format-zero-length
7011 @opindex Wformat-zero-length
7012 @item -Wno-format-zero-length
7013 If @option{-Wformat} is specified, do not warn about zero-length formats.
7014 The C standard specifies that zero-length formats are allowed.
7015
7016 @opindex Wformat-nonliteral
7017 @opindex Wno-format-nonliteral
7018 @item -Wformat-nonliteral
7019 If @option{-Wformat} is specified, also warn if the format string is not a
7020 string literal and so cannot be checked, unless the format function
7021 takes its format arguments as a @code{va_list}.
7022
7023 @opindex Wformat-security
7024 @opindex Wno-format-security
7025 @item -Wformat-security
7026 If @option{-Wformat} is specified, also warn about uses of format
7027 functions that represent possible security problems. At present, this
7028 warns about calls to @code{printf} and @code{scanf} functions where the
7029 format string is not a string literal and there are no format arguments,
7030 as in @code{printf (foo);}. This may be a security hole if the format
7031 string came from untrusted input and contains @samp{%n}. (This is
7032 currently a subset of what @option{-Wformat-nonliteral} warns about, but
7033 in future warnings may be added to @option{-Wformat-security} that are not
7034 included in @option{-Wformat-nonliteral}.)
7035
7036 @opindex Wformat-signedness
7037 @opindex Wno-format-signedness
7038 @item -Wformat-signedness
7039 If @option{-Wformat} is specified, also warn if the format string
7040 requires an unsigned argument and the argument is signed and vice versa.
7041
7042 @opindex Wformat-truncation
7043 @opindex Wno-format-truncation
7044 @item -Wformat-truncation
7045 @itemx -Wformat-truncation=@var{level}
7046 Warn about calls to formatted input/output functions such as @code{snprintf}
7047 and @code{vsnprintf} that might result in output truncation. When the exact
7048 number of bytes written by a format directive cannot be determined at
7049 compile-time it is estimated based on heuristics that depend on
7050 the @var{level} argument and on optimization. While enabling optimization
7051 will in most cases improve the accuracy of the warning, it may also result
7052 in false positives. Except as noted otherwise, the option uses the same
7053 logic @option{-Wformat-overflow}.
7054
7055 @table @gcctabopt
7056 @opindex Wformat-truncation
7057 @opindex Wno-format-truncation
7058 @item -Wformat-truncation
7059 @itemx -Wformat-truncation=1
7060 Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
7061 employs a conservative approach that warns only about calls to bounded
7062 functions whose return value is unused and that will most likely result
7063 in output truncation.
7064
7065 @item -Wformat-truncation=2
7066 Level @var{2} warns also about calls to bounded functions whose return
7067 value is used and that might result in truncation given an argument of
7068 sufficient length or magnitude.
7069 @end table
7070
7071 @opindex Wformat-y2k
7072 @opindex Wno-format-y2k
7073 @item -Wformat-y2k
7074 If @option{-Wformat} is specified, also warn about @code{strftime}
7075 formats that may yield only a two-digit year.
7076
7077 @opindex Wnonnull
7078 @opindex Wno-nonnull
7079 @item -Wnonnull
7080 Warn about passing a null pointer for arguments marked as
7081 requiring a non-null value by the @code{nonnull} function attribute.
7082
7083 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
7084 can be disabled with the @option{-Wno-nonnull} option.
7085
7086 @opindex Wnonnull-compare
7087 @opindex Wno-nonnull-compare
7088 @item -Wnonnull-compare
7089 Warn when comparing an argument marked with the @code{nonnull}
7090 function attribute against null inside the function.
7091
7092 @option{-Wnonnull-compare} is included in @option{-Wall}. It
7093 can be disabled with the @option{-Wno-nonnull-compare} option.
7094
7095 @opindex Wnull-dereference
7096 @opindex Wno-null-dereference
7097 @item -Wnull-dereference
7098 Warn if the compiler detects paths that trigger erroneous or
7099 undefined behavior due to dereferencing a null pointer. This option
7100 is only active when @option{-fdelete-null-pointer-checks} is active,
7101 which is enabled by optimizations in most targets. The precision of
7102 the warnings depends on the optimization options used.
7103
7104 @opindex Wno-musttail-local-addr
7105 @opindex Wmusttail-local-addr
7106 @item -Wno-musttail-local-addr
7107 Do not warn about passing a pointer (or in C++, a reference) to a
7108 local variable or label to argument of a @code{musttail} call. Those
7109 variables go out of scope before the tail call instruction.
7110
7111 @opindex Wmaybe-musttail-local-addr
7112 @opindex Wno-maybe-musttail-local-addr
7113 @item -Wmaybe-musttail-local-addr
7114 Warn when address of a local variable can escape to a @code{musttail}
7115 call, unless it goes out of scope already before the @code{musttail}
7116 call.
7117
7118 @smallexample
7119 int foo (int *);
7120
7121 int
7122 bar (int *x)
7123 @{
7124 if (x[0] == 1)
7125 @{
7126 int a = 42;
7127 foo (&a);
7128 /* Without the @code{musttail} attribute this call would not
7129 be tail called, because address of the @code{a} variable escapes
7130 and the second foo call could dereference it. With the attribute
7131 the local variables are assumed to go out of scope immediately
7132 before the tail call instruction and the compiler warns about
7133 this. */
7134 [[gnu::musttail]] return foo (nullptr);
7135 @}
7136 else
7137 @{
7138 @{
7139 int a = 42;
7140 foo (&a);
7141 @}
7142 /* The @code{a} variable isn't already in scope, so even when it
7143 escaped, even without @code{musttail} attribute it would be
7144 undefined behavior to dereference it and the compiler could
7145 turn this into a tail call. No warning is diagnosed here. */
7146 [[gnu::musttail]] return foo (nullptr);
7147 @}
7148 @}
7149 @end smallexample
7150
7151 This warning is enabled by @option{-Wextra}.
7152
7153 @opindex Wnrvo
7154 @opindex Wno-nrvo
7155 @item -Wnrvo @r{(C++ and Objective-C++ only)}
7156 Warn if the compiler does not elide the copy from a local variable to
7157 the return value of a function in a context where it is allowed by
7158 [class.copy.elision]. This elision is commonly known as the Named
7159 Return Value Optimization. For instance, in the example below the
7160 compiler cannot elide copies from both v1 and v2, so it elides neither.
7161
7162 @smallexample
7163 std::vector<int> f()
7164 @{
7165 std::vector<int> v1, v2;
7166 // ...
7167 if (cond) return v1;
7168 else return v2; // warning: not eliding copy
7169 @}
7170 @end smallexample
7171
7172 @opindex Winfinite-recursion
7173 @opindex Wno-infinite-recursion
7174 @item -Winfinite-recursion
7175 Warn about infinitely recursive calls. The warning is effective at all
7176 optimization levels but requires optimization in order to detect infinite
7177 recursion in calls between two or more functions.
7178 @option{-Winfinite-recursion} is included in @option{-Wall}.
7179
7180 Compare with @option{-Wanalyzer-infinite-recursion} which provides a
7181 similar diagnostic, but is implemented in a different way (as part of
7182 @option{-fanalyzer}).
7183
7184 @opindex Winit-self
7185 @opindex Wno-init-self
7186 @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
7187 Warn about uninitialized variables that are initialized with themselves.
7188 Note this option can only be used with the @option{-Wuninitialized} option.
7189
7190 For example, GCC warns about @code{i} being uninitialized in the
7191 following snippet only when @option{-Winit-self} has been specified:
7192 @smallexample
7193 @group
7194 int f()
7195 @{
7196 int i = i;
7197 return i;
7198 @}
7199 @end group
7200 @end smallexample
7201
7202 This warning is enabled by @option{-Wall} in C++.
7203
7204 @opindex Wimplicit-int
7205 @opindex Wno-implicit-int
7206 @item -Wno-implicit-int @r{(C and Objective-C only)}
7207 This option controls warnings when a declaration does not specify a type.
7208 This warning is enabled by default, as an error, in C99 and later
7209 dialects of C, and also by @option{-Wall}. The error can be downgraded
7210 to a warning using @option{-fpermissive} (along with certain other
7211 errors), or for this error alone, with @option{-Wno-error=implicit-int}.
7212
7213 This warning is upgraded to an error by @option{-pedantic-errors}.
7214
7215 @opindex Wimplicit-function-declaration
7216 @opindex Wno-implicit-function-declaration
7217 @item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
7218 This option controls warnings when a function is used before being declared.
7219 This warning is enabled by default, as an error, in C99 and later
7220 dialects of C, and also by @option{-Wall}. The error can be downgraded
7221 to a warning using @option{-fpermissive} (along with certain other
7222 errors), or for this error alone, with
7223 @option{-Wno-error=implicit-function-declaration}.
7224
7225 This warning is upgraded to an error by @option{-pedantic-errors}.
7226
7227 @opindex Wimplicit
7228 @opindex Wno-implicit
7229 @item -Wimplicit @r{(C and Objective-C only)}
7230 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
7231 This warning is enabled by @option{-Wall}.
7232
7233 @opindex Whardened
7234 @opindex Wno-hardened
7235 @item -Whardened
7236 Warn when @option{-fhardened} did not enable an option from its set (for
7237 which see @option{-fhardened}). For instance, using @option{-fhardened}
7238 and @option{-fstack-protector} at the same time on the command line causes
7239 @option{-Whardened} to warn because @option{-fstack-protector-strong} will
7240 not be enabled by @option{-fhardened}.
7241
7242 This warning is enabled by default and has effect only when @option{-fhardened}
7243 is enabled.
7244
7245 @opindex Wimplicit-fallthrough
7246 @opindex Wno-implicit-fallthrough
7247 @item -Wimplicit-fallthrough
7248 @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
7249 and @option{-Wno-implicit-fallthrough} is the same as
7250 @option{-Wimplicit-fallthrough=0}.
7251
7252 @opindex Wimplicit-fallthrough=
7253 @item -Wimplicit-fallthrough=@var{n}
7254 Warn when a switch case falls through. For example:
7255
7256 @smallexample
7257 @group
7258 switch (cond)
7259 @{
7260 case 1:
7261 a = 1;
7262 break;
7263 case 2:
7264 a = 2;
7265 case 3:
7266 a = 3;
7267 break;
7268 @}
7269 @end group
7270 @end smallexample
7271
7272 This warning does not warn when the last statement of a case cannot
7273 fall through, e.g. when there is a return statement or a call to function
7274 declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
7275 also takes into account control flow statements, such as ifs, and only
7276 warns when appropriate. E.g.@:
7277
7278 @smallexample
7279 @group
7280 switch (cond)
7281 @{
7282 case 1:
7283 if (i > 3) @{
7284 bar (5);
7285 break;
7286 @} else if (i < 1) @{
7287 bar (0);
7288 @} else
7289 return;
7290 default:
7291 @dots{}
7292 @}
7293 @end group
7294 @end smallexample
7295
7296 Since there are occasions where a switch case fall through is desirable,
7297 GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
7298 to be used along with a null statement to suppress this warning that
7299 would normally occur:
7300
7301 @smallexample
7302 @group
7303 switch (cond)
7304 @{
7305 case 1:
7306 bar (0);
7307 __attribute__ ((fallthrough));
7308 default:
7309 @dots{}
7310 @}
7311 @end group
7312 @end smallexample
7313
7314 C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
7315 warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
7316 or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
7317 Instead of these attributes, it is also possible to add a fallthrough comment
7318 to silence the warning. The whole body of the C or C++ style comment should
7319 match the given regular expressions listed below. The option argument @var{n}
7320 specifies what kind of comments are accepted:
7321
7322 @itemize @bullet
7323
7324 @item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
7325
7326 @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
7327 expression, any comment is used as fallthrough comment.
7328
7329 @item @option{-Wimplicit-fallthrough=2} case insensitively matches
7330 @code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
7331
7332 @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
7333 following regular expressions:
7334
7335 @itemize @bullet
7336
7337 @item @code{-fallthrough}
7338
7339 @item @code{@@fallthrough@@}
7340
7341 @item @code{lint -fallthrough[ \t]*}
7342
7343 @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
7344
7345 @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
7346
7347 @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
7348
7349 @end itemize
7350
7351 @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
7352 following regular expressions:
7353
7354 @itemize @bullet
7355
7356 @item @code{-fallthrough}
7357
7358 @item @code{@@fallthrough@@}
7359
7360 @item @code{lint -fallthrough[ \t]*}
7361
7362 @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
7363
7364 @end itemize
7365
7366 @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
7367 fallthrough comments, only attributes disable the warning.
7368
7369 @end itemize
7370
7371 The comment needs to be followed after optional whitespace and other comments
7372 by @code{case} or @code{default} keywords or by a user label that precedes some
7373 @code{case} or @code{default} label.
7374
7375 @smallexample
7376 @group
7377 switch (cond)
7378 @{
7379 case 1:
7380 bar (0);
7381 /* FALLTHRU */
7382 default:
7383 @dots{}
7384 @}
7385 @end group
7386 @end smallexample
7387
7388 The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
7389
7390 @opindex Wif-not-aligned
7391 @opindex Wno-if-not-aligned
7392 @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
7393 Control if warnings triggered by the @code{warn_if_not_aligned} attribute
7394 should be issued. These warnings are enabled by default.
7395
7396 @opindex Wignored-qualifiers
7397 @opindex Wno-ignored-qualifiers
7398 @item -Wignored-qualifiers @r{(C and C++ only)}
7399 Warn if the return type of a function has a type qualifier
7400 such as @code{const}. For ISO C such a type qualifier has no effect,
7401 since the value returned by a function is not an lvalue.
7402 For C++, the warning is only emitted for scalar types or @code{void}.
7403 ISO C prohibits qualified @code{void} return types on function
7404 definitions, so such return types always receive a warning
7405 even without this option.
7406
7407 This warning is also enabled by @option{-Wextra}.
7408
7409 @opindex Wignored-attributes
7410 @opindex Wno-ignored-attributes
7411 @item -Wno-ignored-attributes @r{(C and C++ only)}
7412 This option controls warnings when an attribute is ignored.
7413 This is different from the
7414 @option{-Wattributes} option in that it warns whenever the compiler decides
7415 to drop an attribute, not that the attribute is either unknown, used in a
7416 wrong place, etc. This warning is enabled by default.
7417
7418 @opindex Wmain
7419 @opindex Wno-main
7420 @item -Wmain
7421 Warn if the type of @code{main} is suspicious. @code{main} should be
7422 a function with external linkage, returning int, taking either zero
7423 arguments, two, or three arguments of appropriate types. This warning
7424 is enabled by default in C++ and is enabled by either @option{-Wall}
7425 or @option{-Wpedantic}.
7426
7427 This warning is upgraded to an error by @option{-pedantic-errors}.
7428
7429 @opindex Wmisleading-indentation
7430 @opindex Wno-misleading-indentation
7431 @item -Wmisleading-indentation @r{(C and C++ only)}
7432 Warn when the indentation of the code does not reflect the block structure.
7433 Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
7434 @code{for} clauses with a guarded statement that does not use braces,
7435 followed by an unguarded statement with the same indentation.
7436
7437 In the following example, the call to ``bar'' is misleadingly indented as
7438 if it were guarded by the ``if'' conditional.
7439
7440 @smallexample
7441 if (some_condition ())
7442 foo ();
7443 bar (); /* Gotcha: this is not guarded by the "if". */
7444 @end smallexample
7445
7446 In the case of mixed tabs and spaces, the warning uses the
7447 @option{-ftabstop=} option to determine if the statements line up
7448 (defaulting to 8).
7449
7450 The warning is not issued for code involving multiline preprocessor logic
7451 such as the following example.
7452
7453 @smallexample
7454 if (flagA)
7455 foo (0);
7456 #if SOME_CONDITION_THAT_DOES_NOT_HOLD
7457 if (flagB)
7458 #endif
7459 foo (1);
7460 @end smallexample
7461
7462 The warning is not issued after a @code{#line} directive, since this
7463 typically indicates autogenerated code, and no assumptions can be made
7464 about the layout of the file that the directive references.
7465
7466 This warning is enabled by @option{-Wall} in C and C++.
7467
7468 @opindex Wmissing-attributes
7469 @opindex Wno-missing-attributes
7470 @item -Wmissing-attributes
7471 Warn when a declaration of a function is missing one or more attributes
7472 that a related function is declared with and whose absence may adversely
7473 affect the correctness or efficiency of generated code. For example,
7474 the warning is issued for declarations of aliases that use attributes
7475 to specify less restrictive requirements than those of their targets.
7476 This typically represents a potential optimization opportunity.
7477 By contrast, the @option{-Wattribute-alias=2} option controls warnings
7478 issued when the alias is more restrictive than the target, which could
7479 lead to incorrect code generation.
7480 Attributes considered include @code{alloc_align}, @code{alloc_size},
7481 @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
7482 @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
7483 @code{returns_nonnull}, and @code{returns_twice}.
7484
7485 In C++, the warning is issued when an explicit specialization of a primary
7486 template declared with attribute @code{alloc_align}, @code{alloc_size},
7487 @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
7488 or @code{nonnull} is declared without it. Attributes @code{deprecated},
7489 @code{error}, and @code{warning} suppress the warning.
7490 (@pxref{Function Attributes}).
7491
7492 You can use the @code{copy} attribute to apply the same
7493 set of attributes to a declaration as that on another declaration without
7494 explicitly enumerating the attributes. This attribute can be applied
7495 to declarations of functions (@pxref{Common Function Attributes}),
7496 variables (@pxref{Common Variable Attributes}), or types
7497 (@pxref{Common Type Attributes}).
7498
7499 @option{-Wmissing-attributes} is enabled by @option{-Wall}.
7500
7501 For example, since the declaration of the primary function template
7502 below makes use of both attribute @code{malloc} and @code{alloc_size}
7503 the declaration of the explicit specialization of the template is
7504 diagnosed because it is missing one of the attributes.
7505
7506 @smallexample
7507 template <class T>
7508 T* __attribute__ ((malloc, alloc_size (1)))
7509 allocate (size_t);
7510
7511 template <>
7512 void* __attribute__ ((malloc)) // missing alloc_size
7513 allocate<void> (size_t);
7514 @end smallexample
7515
7516 @opindex Wmissing-braces
7517 @opindex Wno-missing-braces
7518 @item -Wmissing-braces
7519 Warn if an aggregate or union initializer is not fully bracketed. In
7520 the following example, the initializer for @code{a} is not fully
7521 bracketed, but that for @code{b} is fully bracketed.
7522
7523 @smallexample
7524 int a[2][2] = @{ 0, 1, 2, 3 @};
7525 int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
7526 @end smallexample
7527
7528 This warning is enabled by @option{-Wall}.
7529
7530 @opindex Wmissing-include-dirs
7531 @opindex Wno-missing-include-dirs
7532 @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
7533 Warn if a user-supplied include directory does not exist. This option is disabled
7534 by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
7535 enabled by default by warning for -I and -J, only.
7536
7537 @opindex Wmissing-profile
7538 @opindex Wno-missing-profile
7539 @item -Wno-missing-profile
7540 This option controls warnings if feedback profiles are missing when using the
7541 @option{-fprofile-use} option.
7542 This option diagnoses those cases where a new function or a new file is added
7543 between compiling with @option{-fprofile-generate} and with
7544 @option{-fprofile-use}, without regenerating the profiles.
7545 In these cases, the profile feedback data files do not contain any
7546 profile feedback information for
7547 the newly added function or file respectively. Also, in the case when profile
7548 count data (.gcda) files are removed, GCC cannot use any profile feedback
7549 information. In all these cases, warnings are issued to inform you that a
7550 profile generation step is due.
7551 Ignoring the warning can result in poorly optimized code.
7552 @option{-Wno-missing-profile} can be used to
7553 disable the warning, but this is not recommended and should be done only
7554 when non-existent profile data is justified.
7555
7556 @opindex Wmismatched-dealloc
7557 @opindex Wno-mismatched-dealloc
7558 @item -Wmismatched-dealloc
7559
7560 Warn for calls to deallocation functions with pointer arguments returned
7561 from allocation functions for which the former isn't a suitable
7562 deallocator. A pair of functions can be associated as matching allocators
7563 and deallocators by use of attribute @code{malloc}. Unless disabled by
7564 the @option{-fno-builtin} option the standard functions @code{calloc},
7565 @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7566 forms of C++ @code{operator new} and @code{operator delete} are implicitly
7567 associated as matching allocators and deallocators. In the following
7568 example @code{mydealloc} is the deallocator for pointers returned from
7569 @code{myalloc}.
7570
7571 @smallexample
7572 void mydealloc (void*);
7573
7574 __attribute__ ((malloc (mydealloc, 1))) void*
7575 myalloc (size_t);
7576
7577 void f (void)
7578 @{
7579 void *p = myalloc (32);
7580 // @dots{}use p@dots{}
7581 free (p); // warning: not a matching deallocator for myalloc
7582 mydealloc (p); // ok
7583 @}
7584 @end smallexample
7585
7586 In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7587 mismatches involving either @code{operator new} or @code{operator delete}.
7588
7589 Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7590
7591 @opindex Wmultistatement-macros
7592 @opindex Wno-multistatement-macros
7593 @item -Wmultistatement-macros
7594 Warn about unsafe multiple statement macros that appear to be guarded
7595 by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7596 @code{while}, in which only the first statement is actually guarded after
7597 the macro is expanded.
7598
7599 For example:
7600
7601 @smallexample
7602 #define DOIT x++; y++
7603 if (c)
7604 DOIT;
7605 @end smallexample
7606
7607 will increment @code{y} unconditionally, not just when @code{c} holds.
7608 The can usually be fixed by wrapping the macro in a do-while loop:
7609 @smallexample
7610 #define DOIT do @{ x++; y++; @} while (0)
7611 if (c)
7612 DOIT;
7613 @end smallexample
7614
7615 This warning is enabled by @option{-Wall} in C and C++.
7616
7617 @opindex Wparentheses
7618 @opindex Wno-parentheses
7619 @item -Wparentheses
7620 Warn if parentheses are omitted in certain contexts, such
7621 as when there is an assignment in a context where a truth value
7622 is expected, or when operators are nested whose precedence people
7623 often get confused about.
7624
7625 Also warn if a comparison like @code{x<=y<=z} appears; this is
7626 equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7627 interpretation from that of ordinary mathematical notation.
7628
7629 Also warn for dangerous uses of the GNU extension to
7630 @code{?:} with omitted middle operand. When the condition
7631 in the @code{?}: operator is a boolean expression, the omitted value is
7632 always 1. Often programmers expect it to be a value computed
7633 inside the conditional expression instead.
7634
7635 For C++ this also warns for some cases of unnecessary parentheses in
7636 declarations, which can indicate an attempt at a function call instead
7637 of a declaration:
7638 @smallexample
7639 @{
7640 // Declares a local variable called mymutex.
7641 std::unique_lock<std::mutex> (mymutex);
7642 // User meant std::unique_lock<std::mutex> lock (mymutex);
7643 @}
7644 @end smallexample
7645
7646 This warning is enabled by @option{-Wall}.
7647
7648 @opindex Wself-move
7649 @opindex Wno-self-move
7650 @item -Wno-self-move @r{(C++ and Objective-C++ only)}
7651 This warning warns when a value is moved to itself with @code{std::move}.
7652 Such a @code{std::move} typically has no effect.
7653
7654 @smallexample
7655 struct T @{
7656 @dots{}
7657 @};
7658 void fn()
7659 @{
7660 T t;
7661 @dots{}
7662 t = std::move (t);
7663 @}
7664 @end smallexample
7665
7666 This warning is enabled by @option{-Wall}.
7667
7668 @opindex Wsequence-point
7669 @opindex Wno-sequence-point
7670 @item -Wsequence-point
7671 Warn about code that may have undefined semantics because of violations
7672 of sequence point rules in the C and C++ standards.
7673
7674 The C and C++ standards define the order in which expressions in a C/C++
7675 program are evaluated in terms of @dfn{sequence points}, which represent
7676 a partial ordering between the execution of parts of the program: those
7677 executed before the sequence point, and those executed after it. These
7678 occur after the evaluation of a full expression (one which is not part
7679 of a larger expression), after the evaluation of the first operand of a
7680 @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7681 function is called (but after the evaluation of its arguments and the
7682 expression denoting the called function), and in certain other places.
7683 Other than as expressed by the sequence point rules, the order of
7684 evaluation of subexpressions of an expression is not specified. All
7685 these rules describe only a partial order rather than a total order,
7686 since, for example, if two functions are called within one expression
7687 with no sequence point between them, the order in which the functions
7688 are called is not specified. However, the standards committee have
7689 ruled that function calls do not overlap.
7690
7691 It is not specified when between sequence points modifications to the
7692 values of objects take effect. Programs whose behavior depends on this
7693 have undefined behavior; the C and C++ standards specify that ``Between
7694 the previous and next sequence point an object shall have its stored
7695 value modified at most once by the evaluation of an expression.
7696 Furthermore, the prior value shall be read only to determine the value
7697 to be stored.''. If a program breaks these rules, the results on any
7698 particular implementation are entirely unpredictable.
7699
7700 Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7701 = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7702 diagnosed by this option, and it may give an occasional false positive
7703 result, but in general it has been found fairly effective at detecting
7704 this sort of problem in programs.
7705
7706 The C++17 standard will define the order of evaluation of operands in
7707 more cases: in particular it requires that the right-hand side of an
7708 assignment be evaluated before the left-hand side, so the above
7709 examples are no longer undefined. But this option will still warn
7710 about them, to help people avoid writing code that is undefined in C
7711 and earlier revisions of C++.
7712
7713 The standard is worded confusingly, therefore there is some debate
7714 over the precise meaning of the sequence point rules in subtle cases.
7715 Links to discussions of the problem, including proposed formal
7716 definitions, may be found on the GCC readings page, at
7717 @uref{https://gcc.gnu.org/@/readings.html}.
7718
7719 This warning is enabled by @option{-Wall} for C and C++.
7720
7721 @opindex Wno-return-local-addr
7722 @opindex Wreturn-local-addr
7723 @item -Wno-return-local-addr
7724 Do not warn about returning a pointer (or in C++, a reference) to a
7725 variable that goes out of scope after the function returns.
7726
7727 @opindex Wreturn-mismatch
7728 @opindex Wno-return-mismatch
7729 @item -Wreturn-mismatch
7730 Warn about return statements without an expressions in functions which
7731 do not return @code{void}. Also warn about a @code{return} statement
7732 with an expression in a function whose return type is @code{void},
7733 unless the expression type is also @code{void}. As a GNU extension, the
7734 latter case is accepted without a warning unless @option{-Wpedantic} is
7735 used.
7736
7737 Attempting to use the return value of a non-@code{void} function other
7738 than @code{main} that flows off the end by reaching the closing curly
7739 brace that terminates the function is undefined.
7740
7741 This warning is specific to C and enabled by default. In C99 and later
7742 language dialects, it is treated as an error. It can be downgraded
7743 to a warning using @option{-fpermissive} (along with other warnings),
7744 or for just this warning, with @option{-Wno-error=return-mismatch}.
7745
7746 @opindex Wreturn-type
7747 @opindex Wno-return-type
7748 @item -Wreturn-type
7749 Warn whenever a function is defined with a return type that defaults to
7750 @code{int} (unless @option{-Wimplicit-int} is active, which takes
7751 precedence). Also warn if execution may reach the end of the function
7752 body, or if the function does not contain any return statement at all.
7753
7754 Attempting to use the return value of a non-@code{void} function other
7755 than @code{main} that flows off the end by reaching the closing curly
7756 brace that terminates the function is undefined.
7757
7758 Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7759 than @code{main} results in undefined behavior even when the value of
7760 the function is not used.
7761
7762 This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7763
7764 @opindex Wshift-count-negative
7765 @opindex Wno-shift-count-negative
7766 @item -Wno-shift-count-negative
7767 Controls warnings if a shift count is negative.
7768 This warning is enabled by default.
7769
7770 @opindex Wshift-count-overflow
7771 @opindex Wno-shift-count-overflow
7772 @item -Wno-shift-count-overflow
7773 Controls warnings if a shift count is greater than or equal to the bit width
7774 of the type. This warning is enabled by default.
7775
7776 @opindex Wshift-negative-value
7777 @opindex Wno-shift-negative-value
7778 @item -Wshift-negative-value
7779 Warn if left shifting a negative value. This warning is enabled by
7780 @option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7781
7782 @opindex Wshift-overflow
7783 @opindex Wno-shift-overflow
7784 @item -Wno-shift-overflow
7785 @itemx -Wshift-overflow=@var{n}
7786 These options control warnings about left shift overflows.
7787
7788 @table @gcctabopt
7789 @item -Wshift-overflow=1
7790 This is the warning level of @option{-Wshift-overflow} and is enabled
7791 by default in C99 and C++11 modes (and newer). This warning level does
7792 not warn about left-shifting 1 into the sign bit. (However, in C, such
7793 an overflow is still rejected in contexts where an integer constant expression
7794 is required.) No warning is emitted in C++20 mode (and newer), as signed left
7795 shifts always wrap.
7796
7797 @item -Wshift-overflow=2
7798 This warning level also warns about left-shifting 1 into the sign bit,
7799 unless C++14 mode (or newer) is active.
7800 @end table
7801
7802 @opindex Wswitch
7803 @opindex Wno-switch
7804 @item -Wswitch
7805 Warn whenever a @code{switch} statement has an index of enumerated type
7806 and lacks a @code{case} for one or more of the named codes of that
7807 enumeration. (The presence of a @code{default} label prevents this
7808 warning.) @code{case} labels that do not correspond to enumerators also
7809 provoke warnings when this option is used, unless the enumeration is marked
7810 with the @code{flag_enum} attribute.
7811 This warning is enabled by @option{-Wall}.
7812
7813 @opindex Wswitch-default
7814 @opindex Wno-switch-default
7815 @item -Wswitch-default
7816 Warn whenever a @code{switch} statement does not have a @code{default}
7817 case.
7818
7819 @opindex Wswitch-enum
7820 @opindex Wno-switch-enum
7821 @item -Wswitch-enum
7822 Warn whenever a @code{switch} statement has an index of enumerated type
7823 and lacks a @code{case} for one or more of the named codes of that
7824 enumeration. @code{case} labels that do not correspond to enumerators also
7825 provoke warnings when this option is used, unless the enumeration is marked
7826 with the @code{flag_enum} attribute. The only difference
7827 between @option{-Wswitch} and this option is that this option gives a
7828 warning about an omitted enumeration code even if there is a
7829 @code{default} label.
7830
7831 @opindex Wswitch-bool
7832 @opindex Wno-switch-bool
7833 @item -Wno-switch-bool
7834 Do not warn when a @code{switch} statement has an index of boolean type
7835 and the case values are outside the range of a boolean type.
7836 It is possible to suppress this warning by casting the controlling
7837 expression to a type other than @code{bool}. For example:
7838 @smallexample
7839 @group
7840 switch ((int) (a == 4))
7841 @{
7842 @dots{}
7843 @}
7844 @end group
7845 @end smallexample
7846 This warning is enabled by default for C and C++ programs.
7847
7848 @opindex Wswitch-outside-range
7849 @opindex Wno-switch-outside-range
7850 @item -Wno-switch-outside-range
7851 This option controls warnings when a @code{switch} case has a value
7852 that is outside of its
7853 respective type range. This warning is enabled by default for
7854 C and C++ programs.
7855
7856 @opindex Wswitch-unreachable
7857 @opindex Wno-switch-unreachable
7858 @item -Wno-switch-unreachable
7859 Do not warn when a @code{switch} statement contains statements between the
7860 controlling expression and the first case label, which will never be
7861 executed. For example:
7862 @smallexample
7863 @group
7864 switch (cond)
7865 @{
7866 i = 15;
7867 @dots{}
7868 case 5:
7869 @dots{}
7870 @}
7871 @end group
7872 @end smallexample
7873 @option{-Wswitch-unreachable} does not warn if the statement between the
7874 controlling expression and the first case label is just a declaration:
7875 @smallexample
7876 @group
7877 switch (cond)
7878 @{
7879 int i;
7880 @dots{}
7881 case 5:
7882 i = 5;
7883 @dots{}
7884 @}
7885 @end group
7886 @end smallexample
7887 This warning is enabled by default for C and C++ programs.
7888
7889 @opindex Wsync-nand
7890 @opindex Wno-sync-nand
7891 @item -Wsync-nand @r{(C and C++ only)}
7892 Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7893 built-in functions are used. These functions changed semantics in GCC 4.4.
7894
7895 @opindex Wtrivial-auto-var-init
7896 @opindex Wno-trivial-auto-var-init
7897 @item -Wtrivial-auto-var-init
7898 Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7899 variable. A common situation is an automatic variable that is declared
7900 between the controlling expression and the first case label of a @code{switch}
7901 statement.
7902
7903 @opindex Wunused-but-set-parameter
7904 @opindex Wno-unused-but-set-parameter
7905 @item -Wunused-but-set-parameter
7906 Warn whenever a function parameter is assigned to, but otherwise unused
7907 (aside from its declaration).
7908
7909 To suppress this warning use the @code{unused} attribute
7910 (@pxref{Variable Attributes}).
7911
7912 This warning is also enabled by @option{-Wunused} together with
7913 @option{-Wextra}.
7914
7915 @opindex Wunused-but-set-variable
7916 @opindex Wno-unused-but-set-variable
7917 @item -Wunused-but-set-variable
7918 Warn whenever a local variable is assigned to, but otherwise unused
7919 (aside from its declaration).
7920 This warning is enabled by @option{-Wall}.
7921
7922 To suppress this warning use the @code{unused} attribute
7923 (@pxref{Variable Attributes}).
7924
7925 This warning is also enabled by @option{-Wunused}, which is enabled
7926 by @option{-Wall}.
7927
7928 @opindex Wunused-function
7929 @opindex Wno-unused-function
7930 @item -Wunused-function
7931 Warn whenever a static function is declared but not defined or a
7932 non-inline static function is unused.
7933 This warning is enabled by @option{-Wall}.
7934
7935 @opindex Wunused-label
7936 @opindex Wno-unused-label
7937 @item -Wunused-label
7938 Warn whenever a label is declared but not used.
7939 This warning is enabled by @option{-Wall}.
7940
7941 To suppress this warning use the @code{unused} attribute
7942 (@pxref{Variable Attributes}).
7943
7944 @opindex Wunused-local-typedefs
7945 @opindex Wno-unused-local-typedefs
7946 @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
7947 Warn when a typedef locally defined in a function is not used.
7948 This warning is enabled by @option{-Wall}.
7949
7950 @opindex Wunused-parameter
7951 @opindex Wno-unused-parameter
7952 @item -Wunused-parameter
7953 Warn whenever a function parameter is unused aside from its declaration.
7954 This option is not enabled by @code{-Wunused} unless @code{-Wextra} is also
7955 specified.
7956
7957 To suppress this warning use the @code{unused} attribute
7958 (@pxref{Variable Attributes}).
7959
7960 @opindex Wunused-result
7961 @opindex Wno-unused-result
7962 @item -Wno-unused-result
7963 Do not warn if a caller of a function marked with attribute
7964 @code{warn_unused_result} (@pxref{Function Attributes}) does not use
7965 its return value. The default is @option{-Wunused-result}.
7966
7967 @opindex Wunused-variable
7968 @opindex Wno-unused-variable
7969 @item -Wunused-variable
7970 Warn whenever a local or static variable is unused aside from its
7971 declaration. This option implies @option{-Wunused-const-variable=1} for C,
7972 but not for C++. This warning is enabled by @option{-Wall}.
7973
7974 To suppress this warning use the @code{unused} attribute
7975 (@pxref{Variable Attributes}).
7976
7977 @opindex Wunused-const-variable
7978 @opindex Wno-unused-const-variable
7979 @item -Wunused-const-variable
7980 @itemx -Wunused-const-variable=@var{n}
7981 Warn whenever a constant static variable is unused aside from its declaration.
7982
7983 To suppress this warning use the @code{unused} attribute
7984 (@pxref{Variable Attributes}).
7985
7986 @table @gcctabopt
7987 @item -Wunused-const-variable=1
7988 Warn about unused static const variables defined in the main
7989 compilation unit, but not about static const variables declared in any
7990 header included.
7991
7992 @option{-Wunused-const-variable=1} is enabled by either
7993 @option{-Wunused-variable} or @option{-Wunused} for C, but not for
7994 C++. In C this declares variable storage, but in C++ this is not an
7995 error since const variables take the place of @code{#define}s.
7996
7997 @item -Wunused-const-variable=2
7998 This warning level also warns for unused constant static variables in
7999 headers (excluding system headers). It is equivalent to the short form
8000 @option{-Wunused-const-variable}. This level must be explicitly
8001 requested in both C and C++ because it might be hard to clean up all
8002 headers included.
8003 @end table
8004
8005 @opindex Wunused-value
8006 @opindex Wno-unused-value
8007 @item -Wunused-value
8008 Warn whenever a statement computes a result that is explicitly not
8009 used. To suppress this warning cast the unused expression to
8010 @code{void}. This includes an expression-statement or the left-hand
8011 side of a comma expression that contains no side effects. For example,
8012 an expression such as @code{x[i,j]} causes a warning, while
8013 @code{x[(void)i,j]} does not.
8014
8015 This warning is enabled by @option{-Wall}.
8016
8017 @opindex Wunused
8018 @opindex Wno-unused
8019 @item -Wunused
8020 All the above @option{-Wunused} options combined, except those documented
8021 as needing to be specified explicitly.
8022
8023 In order to get a warning about an unused function parameter, you must
8024 either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
8025 @option{-Wunused}), or separately specify @option{-Wunused-parameter} and/or
8026 @option{-Wunused-but-set-parameter}.
8027
8028 @option{-Wunused} enables only @option{-Wunused-const-variable=1} rather than
8029 @option{-Wunused-const-variable}, and only for C, not C++.
8030
8031 @opindex Wuse-after-free
8032 @opindex Wno-use-after-free
8033 @item -Wuse-after-free @r{(C, Objective-C, C++ and Objective-C++ only)}
8034 @itemx -Wuse-after-free=@var{n}
8035 Warn about uses of pointers to dynamically allocated objects that have
8036 been rendered indeterminate by a call to a deallocation function.
8037 The warning is enabled at all optimization levels but may yield different
8038 results with optimization than without.
8039
8040 @table @gcctabopt
8041 @item -Wuse-after-free=1
8042 At level 1 the warning attempts to diagnose only unconditional uses
8043 of pointers made indeterminate by a deallocation call or a successful
8044 call to @code{realloc}, regardless of whether or not the call resulted
8045 in an actual reallocation of memory. This includes double-@code{free}
8046 calls as well as uses in arithmetic and relational expressions. Although
8047 undefined, uses of indeterminate pointers in equality (or inequality)
8048 expressions are not diagnosed at this level.
8049 @item -Wuse-after-free=2
8050 At level 2, in addition to unconditional uses, the warning also diagnoses
8051 conditional uses of pointers made indeterminate by a deallocation call.
8052 As at level 2, uses in equality (or inequality) expressions are not
8053 diagnosed. For example, the second call to @code{free} in the following
8054 function is diagnosed at this level:
8055 @smallexample
8056 struct A @{ int refcount; void *data; @};
8057
8058 void release (struct A *p)
8059 @{
8060 int refcount = --p->refcount;
8061 free (p);
8062 if (refcount == 0)
8063 free (p->data); // warning: p may be used after free
8064 @}
8065 @end smallexample
8066 @item -Wuse-after-free=3
8067 At level 3, the warning also diagnoses uses of indeterminate pointers in
8068 equality expressions. All uses of indeterminate pointers are undefined
8069 but equality tests sometimes appear after calls to @code{realloc} as
8070 an attempt to determine whether the call resulted in relocating the object
8071 to a different address. They are diagnosed at a separate level to aid
8072 gradually transitioning legacy code to safe alternatives. For example,
8073 the equality test in the function below is diagnosed at this level:
8074 @smallexample
8075 void adjust_pointers (int**, int);
8076
8077 void grow (int **p, int n)
8078 @{
8079 int **q = (int**)realloc (p, n *= 2);
8080 if (q == p)
8081 return;
8082 adjust_pointers ((int**)q, n);
8083 @}
8084 @end smallexample
8085 To avoid the warning at this level, store offsets into allocated memory
8086 instead of pointers. This approach obviates needing to adjust the stored
8087 pointers after reallocation.
8088 @end table
8089
8090 @option{-Wuse-after-free=2} is included in @option{-Wall}.
8091
8092 @opindex Wuseless-cast
8093 @opindex Wno-useless-cast
8094 @item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)}
8095 Warn when an expression is cast to its own type. This warning does not
8096 occur when a class object is converted to a non-reference type as that
8097 is a way to create a temporary:
8098
8099 @smallexample
8100 struct S @{ @};
8101 void g (S&&);
8102 void f (S&& arg)
8103 @{
8104 g (S(arg)); // make arg prvalue so that it can bind to S&&
8105 @}
8106 @end smallexample
8107
8108 @opindex Wuninitialized
8109 @opindex Wno-uninitialized
8110 @item -Wuninitialized
8111 Warn if an object with automatic or allocated storage duration is used
8112 without having been initialized. In C++, also warn if a non-static
8113 reference or non-static @code{const} member appears in a class without
8114 constructors.
8115
8116 In addition, passing a pointer (or in C++, a reference) to an uninitialized
8117 object to a @code{const}-qualified argument of a built-in function known to
8118 read the object is also diagnosed by this warning.
8119 (@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
8120
8121 If you want to warn about code that uses the uninitialized value of the
8122 variable in its own initializer, use the @option{-Winit-self} option.
8123
8124 These warnings occur for individual uninitialized elements of
8125 structure, union or array variables as well as for variables that are
8126 uninitialized as a whole. They do not occur for variables or elements
8127 declared @code{volatile}. Because these warnings depend on
8128 optimization, the exact variables or elements for which there are
8129 warnings depend on the precise optimization options and version of GCC
8130 used.
8131
8132 Note that there may be no warning about a variable that is used only
8133 to compute a value that itself is never used, because such
8134 computations may be deleted by data flow analysis before the warnings
8135 are printed.
8136
8137 In C++, this warning also warns about using uninitialized objects in
8138 member-initializer-lists. For example, GCC warns about @code{b} being
8139 uninitialized in the following snippet:
8140
8141 @smallexample
8142 struct A @{
8143 int a;
8144 int b;
8145 A() : a(b) @{ @}
8146 @};
8147 @end smallexample
8148
8149 @opindex Winvalid-memory-model
8150 @opindex Wno-invalid-memory-model
8151 @item -Wno-invalid-memory-model
8152 This option controls warnings
8153 for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
8154 and the C11 atomic generic functions with a memory consistency argument
8155 that is either invalid for the operation or outside the range of values
8156 of the @code{memory_order} enumeration. For example, since the
8157 @code{__atomic_store} and @code{__atomic_store_n} built-ins are only
8158 defined for the relaxed, release, and sequentially consistent memory
8159 orders the following code is diagnosed:
8160
8161 @smallexample
8162 void store (int *i)
8163 @{
8164 __atomic_store_n (i, 0, memory_order_consume);
8165 @}
8166 @end smallexample
8167
8168 @option{-Winvalid-memory-model} is enabled by default.
8169
8170 @opindex Wmaybe-uninitialized
8171 @opindex Wno-maybe-uninitialized
8172 @item -Wmaybe-uninitialized
8173 For an object with automatic or allocated storage duration, if there exists
8174 a path from the function entry to a use of the object that is initialized,
8175 but there exist some other paths for which the object is not initialized,
8176 the compiler emits a warning if it cannot prove the uninitialized paths
8177 are not executed at run time.
8178
8179 In addition, passing a pointer (or in C++, a reference) to an uninitialized
8180 object to a @code{const}-qualified function argument is also diagnosed by
8181 this warning. (@option{-Wuninitialized} is issued for built-in functions
8182 known to read the object.) Annotating the function with attribute
8183 @code{access (none)} indicates that the argument isn't used to access
8184 the object and avoids the warning (@pxref{Common Function Attributes}).
8185
8186 These warnings are only possible in optimizing compilation, because otherwise
8187 GCC does not keep track of the state of variables.
8188
8189 These warnings are made optional because GCC may not be able to determine when
8190 the code is correct in spite of appearing to have an error. Here is one
8191 example of how this can happen:
8192
8193 @smallexample
8194 @group
8195 @{
8196 int x;
8197 switch (y)
8198 @{
8199 case 1: x = 1;
8200 break;
8201 case 2: x = 4;
8202 break;
8203 case 3: x = 5;
8204 @}
8205 foo (x);
8206 @}
8207 @end group
8208 @end smallexample
8209
8210 @noindent
8211 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
8212 always initialized, but GCC doesn't know this. To suppress the
8213 warning, you need to provide a default case with assert(0) or
8214 similar code.
8215
8216 @cindex @code{longjmp} warnings
8217 This option also warns when a non-volatile automatic variable might be
8218 changed by a call to @code{longjmp}.
8219 The compiler sees only the calls to @code{setjmp}. It cannot know
8220 where @code{longjmp} will be called; in fact, a signal handler could
8221 call it at any point in the code. As a result, you may get a warning
8222 even when there is in fact no problem because @code{longjmp} cannot
8223 in fact be called at the place that would cause a problem.
8224
8225 Some spurious warnings can be avoided if you declare all the functions
8226 you use that never return as @code{noreturn}. @xref{Function
8227 Attributes}.
8228
8229 This warning is enabled by @option{-Wall} or @option{-Wextra}.
8230
8231 @opindex Wunknown-pragmas
8232 @opindex Wno-unknown-pragmas
8233 @cindex warning for unknown pragmas
8234 @cindex unknown pragmas, warning
8235 @cindex pragmas, warning of unknown
8236 @item -Wunknown-pragmas
8237 Warn when a @code{#pragma} directive is encountered that is not understood by
8238 GCC@. If this command-line option is used, warnings are even issued
8239 for unknown pragmas in system header files. This is not the case if
8240 the warnings are only enabled by the @option{-Wall} command-line option.
8241
8242 @opindex Wno-pragmas
8243 @opindex Wpragmas
8244 @item -Wno-pragmas
8245 Do not warn about misuses of pragmas, such as incorrect parameters,
8246 invalid syntax, or conflicts between pragmas. See also
8247 @option{-Wunknown-pragmas}.
8248
8249 @opindex Wno-pragma-once-outside-header
8250 @opindex Wpragma-once-outside-header
8251 @item -Wno-pragma-once-outside-header
8252 Do not warn when @code{#pragma once} is used in a file that is not a header
8253 file, such as a main file.
8254
8255 @opindex Wno-prio-ctor-dtor
8256 @opindex Wprio-ctor-dtor
8257 @item -Wno-prio-ctor-dtor
8258 Do not warn if a priority from 0 to 100 is used for constructor or destructor.
8259 The use of constructor and destructor attributes allow you to assign a
8260 priority to the constructor/destructor to control its order of execution
8261 before @code{main} is called or after it returns. The priority values must be
8262 greater than 100 as the compiler reserves priority values between 0--100 for
8263 the implementation.
8264
8265 @opindex Wstrict-aliasing
8266 @opindex Wno-strict-aliasing
8267 @item -Wstrict-aliasing
8268 This option is only active when @option{-fstrict-aliasing} is active.
8269 It warns about code that might break the strict aliasing rules that the
8270 compiler is using for optimization. The warning does not catch all
8271 cases, but does attempt to catch the more common pitfalls. It is
8272 included in @option{-Wall}.
8273 It is equivalent to @option{-Wstrict-aliasing=3}
8274
8275 @opindex Wstrict-aliasing=n
8276 @item -Wstrict-aliasing=n
8277 This option is only active when @option{-fstrict-aliasing} is active.
8278 It warns about code that might break the strict aliasing rules that the
8279 compiler is using for optimization.
8280 Higher levels correspond to higher accuracy (fewer false positives).
8281 Higher levels also correspond to more effort, similar to the way @option{-O}
8282 works.
8283 @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
8284
8285 Level 1: Most aggressive, quick, least accurate.
8286 Possibly useful when higher levels
8287 do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
8288 false negatives. However, it has many false positives.
8289 Warns for all pointer conversions between possibly incompatible types,
8290 even if never dereferenced. Runs in the front end only.
8291
8292 Level 2: Aggressive, quick, not too precise.
8293 May still have many false positives (not as many as level 1 though),
8294 and few false negatives (but possibly more than level 1).
8295 Unlike level 1, it only warns when an address is taken. Warns about
8296 incomplete types. Runs in the front end only.
8297
8298 Level 3 (default for @option{-Wstrict-aliasing}):
8299 Should have very few false positives and few false
8300 negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
8301 Takes care of the common pun+dereference pattern in the front end:
8302 @code{*(int*)&some_float}.
8303 If optimization is enabled, it also runs in the back end, where it deals
8304 with multiple statement cases using flow-sensitive points-to information.
8305 Only warns when the converted pointer is dereferenced.
8306 Does not warn about incomplete types.
8307
8308 @opindex Wstrict-overflow
8309 @opindex Wno-strict-overflow
8310 @item -Wstrict-overflow
8311 @itemx -Wstrict-overflow=@var{n}
8312 This option is only active when signed overflow is undefined.
8313 It warns about cases where the compiler optimizes based on the
8314 assumption that signed overflow does not occur. Note that it does not
8315 warn about all cases where the code might overflow: it only warns
8316 about cases where the compiler implements some optimization. Thus
8317 this warning depends on the optimization level.
8318
8319 An optimization that assumes that signed overflow does not occur is
8320 perfectly safe if the values of the variables involved are such that
8321 overflow never does, in fact, occur. Therefore this warning can
8322 easily give a false positive: a warning about code that is not
8323 actually a problem. To help focus on important issues, several
8324 warning levels are defined. No warnings are issued for the use of
8325 undefined signed overflow when estimating how many iterations a loop
8326 requires, in particular when determining whether a loop will be
8327 executed at all.
8328
8329 @table @gcctabopt
8330 @item -Wstrict-overflow=1
8331 Warn about cases that are both questionable and easy to avoid. For
8332 example the compiler simplifies
8333 @code{x + 1 > x} to @code{1}. This level of
8334 @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
8335 are not, and must be explicitly requested.
8336
8337 @item -Wstrict-overflow=2
8338 Also warn about other cases where a comparison is simplified to a
8339 constant. For example: @code{abs (x) >= 0}. This can only be
8340 simplified when signed integer overflow is undefined, because
8341 @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
8342 zero. @option{-Wstrict-overflow} (with no level) is the same as
8343 @option{-Wstrict-overflow=2}.
8344
8345 @item -Wstrict-overflow=3
8346 Also warn about other cases where a comparison is simplified. For
8347 example: @code{x + 1 > 1} is simplified to @code{x > 0}.
8348
8349 @item -Wstrict-overflow=4
8350 Also warn about other simplifications not covered by the above cases.
8351 For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
8352
8353 @item -Wstrict-overflow=5
8354 Also warn about cases where the compiler reduces the magnitude of a
8355 constant involved in a comparison. For example: @code{x + 2 > y} is
8356 simplified to @code{x + 1 >= y}. This is reported only at the
8357 highest warning level because this simplification applies to many
8358 comparisons, so this warning level gives a very large number of
8359 false positives.
8360 @end table
8361
8362 @opindex Wstring-compare
8363 @opindex Wno-string-compare
8364 @item -Wstring-compare
8365 Warn for calls to @code{strcmp} and @code{strncmp} whose result is
8366 determined to be either zero or non-zero in tests for such equality
8367 owing to the length of one argument being greater than the size of
8368 the array the other argument is stored in (or the bound in the case
8369 of @code{strncmp}). Such calls could be mistakes. For example,
8370 the call to @code{strcmp} below is diagnosed because its result is
8371 necessarily non-zero irrespective of the contents of the array @code{a}.
8372
8373 @smallexample
8374 extern char a[4];
8375 void f (char *d)
8376 @{
8377 strcpy (d, "string");
8378 @dots{}
8379 if (0 == strcmp (a, d)) // cannot be true
8380 puts ("a and d are the same");
8381 @}
8382 @end smallexample
8383
8384 @option{-Wstring-compare} is enabled by @option{-Wextra}.
8385
8386 @opindex Wstringop-overflow
8387 @opindex Wno-stringop-overflow
8388 @item -Wno-stringop-overflow
8389 @item -Wstringop-overflow
8390 @itemx -Wstringop-overflow=@var{type}
8391 Warn for code that can be statically determined to cause buffer overflows or
8392 memory overruns, such as calls to @code{memcpy} and
8393 @code{strcpy} that overflow the destination buffer. The
8394 optional argument is one greater than the type of Object Size Checking to
8395 perform to determine the size of the destination. @xref{Object Size Checking}.
8396 The argument is meaningful only for string functions
8397 that operate on character arrays; raw memory functions like @code{memcpy}
8398 always use type-zero Object Size Checking.
8399
8400 The option also warns for calls that specify a size
8401 in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
8402
8403 The option produces the best results with optimization enabled but can detect
8404 a small subset of simple buffer overflows even without optimization in
8405 calls to the GCC built-in functions like @code{__builtin_memcpy} that
8406 correspond to the standard functions. In any case, the option warns about
8407 just a subset of buffer overflows detected by the corresponding overflow
8408 checking built-ins, such as @code{__builtin___memcpy_chk}, which can perform
8409 run-time checking if the access cannot be identified as safe
8410 at compile time.
8411
8412 For example, the option issues a warning for
8413 the @code{strcpy} call below because it copies at least 5 characters
8414 (the string @code{"blue"} including the terminating NUL) into the buffer
8415 of size 4.
8416
8417 @smallexample
8418 enum Color @{ blue, purple, yellow @};
8419 const char* f (enum Color clr)
8420 @{
8421 static char buf [4];
8422 const char *str;
8423 switch (clr)
8424 @{
8425 case blue: str = "blue"; break;
8426 case purple: str = "purple"; break;
8427 case yellow: str = "yellow"; break;
8428 @}
8429
8430 return strcpy (buf, str); // warning here
8431 @}
8432 @end smallexample
8433
8434 The effect of this option is not limited to string or memory
8435 manipulation functions. In this example, a warning is diagnosed
8436 because a 1-element array is passed to a function requiring at least a
8437 4-element array argument:
8438
8439 @smallexample
8440 void f (int[static 4]);
8441
8442 void g (void)
8443 @{
8444 int *p = (int *) malloc (1 * sizeof(int));
8445 f (p); // warning here
8446 @}
8447 @end smallexample
8448
8449 Option @option{-Wstringop-overflow=2} is enabled by default.
8450
8451 @table @gcctabopt
8452 @opindex Wstringop-overflow
8453 @opindex Wno-stringop-overflow
8454 @item -Wstringop-overflow
8455 @itemx -Wstringop-overflow=1
8456 The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
8457 to determine the sizes of destination objects. At this setting the option
8458 does not warn for writes past the end of subobjects of larger objects accessed
8459 by pointers unless the size of the largest surrounding object is known. When
8460 the destination may be one of several objects it is assumed to be the largest
8461 one of them. On Linux systems, when optimization is enabled at this setting
8462 the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
8463 is defined to a non-zero value.
8464
8465 @item -Wstringop-overflow=2
8466 The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
8467 to determine the sizes of destination objects. At this setting the option
8468 warns about overflows when writing to members of the largest complete
8469 objects whose exact size is known. However, it does not warn for excessive
8470 writes to the same members of unknown objects referenced by pointers since
8471 they may point to arrays containing unknown numbers of elements. This is
8472 the default setting of the option.
8473
8474 @item -Wstringop-overflow=3
8475 The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
8476 to determine the sizes of destination objects. At this setting the option
8477 warns about overflowing the smallest object or data member. This is the
8478 most restrictive setting of the option that may result in warnings for safe
8479 code.
8480
8481 @item -Wstringop-overflow=4
8482 The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
8483 to determine the sizes of destination objects. At this setting the option
8484 warns about overflowing any data members, and when the destination is
8485 one of several objects it uses the size of the largest of them to decide
8486 whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
8487 setting of the option may result in warnings for benign code.
8488 @end table
8489
8490 @opindex Wstringop-overread
8491 @opindex Wno-stringop-overread
8492 @item -Wno-stringop-overread
8493 Warn for calls to string manipulation functions such as @code{memchr}, or
8494 @code{strcpy} that are determined to read past the end of the source
8495 sequence.
8496
8497 Option @option{-Wstringop-overread} is enabled by default.
8498
8499 @opindex Wstringop-truncation
8500 @opindex Wno-stringop-truncation
8501 @item -Wno-stringop-truncation
8502 Do not warn for calls to bounded string manipulation functions
8503 such as @code{strncat},
8504 @code{strncpy}, and @code{stpncpy} that may either truncate the copied string
8505 or leave the destination unchanged.
8506
8507 In the following example, the call to @code{strncat} specifies a bound that
8508 is less than the length of the source string. As a result, the copy of
8509 the source will be truncated and so the call is diagnosed. To avoid the
8510 warning use @code{bufsize - strlen (buf) - 1)} as the bound.
8511
8512 @smallexample
8513 void append (char *buf, size_t bufsize)
8514 @{
8515 strncat (buf, ".txt", 3);
8516 @}
8517 @end smallexample
8518
8519 As another example, the following call to @code{strncpy} results in copying
8520 to @code{d} just the characters preceding the terminating NUL, without
8521 appending the NUL to the end. Assuming the result of @code{strncpy} is
8522 necessarily a NUL-terminated string is a common mistake, and so the call
8523 is diagnosed. To avoid the warning when the result is not expected to be
8524 NUL-terminated, call @code{memcpy} instead.
8525
8526 @smallexample
8527 void copy (char *d, const char *s)
8528 @{
8529 strncpy (d, s, strlen (s));
8530 @}
8531 @end smallexample
8532
8533 In the following example, the call to @code{strncpy} specifies the size
8534 of the destination buffer as the bound. If the length of the source
8535 string is equal to or greater than this size the result of the copy will
8536 not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
8537 the warning, specify @code{sizeof buf - 1} as the bound and set the last
8538 element of the buffer to @code{NUL}.
8539
8540 @smallexample
8541 void copy (const char *s)
8542 @{
8543 char buf[80];
8544 strncpy (buf, s, sizeof buf);
8545 @dots{}
8546 @}
8547 @end smallexample
8548
8549 In situations where a character array is intended to store a sequence
8550 of bytes with no terminating @code{NUL} such an array may be annotated
8551 with attribute @code{nonstring} to avoid this warning. Such arrays,
8552 however, are not suitable arguments to functions that expect
8553 @code{NUL}-terminated strings. To help detect accidental misuses of
8554 such arrays GCC issues warnings unless it can prove that the use is
8555 safe. @xref{Common Variable Attributes}.
8556
8557 @opindex Wstrict-flex-arrays
8558 @opindex Wno-strict-flex-arrays
8559 @item -Wstrict-flex-arrays @r{(C and C++ only)}
8560 Warn about improper usages of flexible array members
8561 according to the @var{level} of the @code{strict_flex_array (@var{level})}
8562 attribute attached to the trailing array field of a structure if it's
8563 available, otherwise according to the @var{level} of the option
8564 @option{-fstrict-flex-arrays=@var{level}}. @xref{Common Variable Attributes},
8565 for more information about the attribute, and @ref{C Dialect Options} for
8566 more information about the option. @code{-Wstrict-flex-arrays}
8567 is effective only when @var{level} is greater than 0.
8568
8569 When @var{level}=1, warnings are issued for a trailing array reference
8570 of a structure that have 2 or more elements if the trailing array is referenced
8571 as a flexible array member.
8572
8573 When @var{level}=2, in addition to @var{level}=1, additional warnings are
8574 issued for a trailing one-element array reference of a structure
8575 if the array is referenced as a flexible array member.
8576
8577 When @var{level}=3, in addition to @var{level}=2, additional warnings are
8578 issued for a trailing zero-length array reference of a structure
8579 if the array is referenced as a flexible array member.
8580
8581 This option is more effective when @option{-ftree-vrp} is active (the
8582 default for @option{-O2} and above) but some warnings may be diagnosed
8583 even without optimization.
8584
8585 @opindex Wsuggest-attribute=
8586 @opindex Wno-suggest-attribute=
8587 @item -Wsuggest-attribute=@var{attribute-name}
8588 Warn for cases where adding an attribute may be beneficial. The
8589 @var{attribute-name}s currently supported are listed below.
8590
8591 @table @gcctabopt
8592 @opindex Wsuggest-attribute=pure
8593 @opindex Wno-suggest-attribute=pure
8594 @opindex Wsuggest-attribute=const
8595 @opindex Wno-suggest-attribute=const
8596 @opindex Wsuggest-attribute=noreturn
8597 @opindex Wno-suggest-attribute=noreturn
8598 @opindex Wmissing-noreturn
8599 @opindex Wno-missing-noreturn
8600 @opindex Wsuggest-attribute=malloc
8601 @opindex Wno-suggest-attribute=malloc
8602 @opindex Wsuggest-attribute=returns_nonnull
8603 @opindex Wno-suggest-attribute=returns_nonnull
8604 @item -Wsuggest-attribute=pure
8605 @itemx -Wsuggest-attribute=const
8606 @itemx -Wsuggest-attribute=noreturn
8607 @itemx -Wmissing-noreturn
8608 @itemx -Wsuggest-attribute=malloc
8609 @itemx -Wsuggest-attribute=returns_nonnull
8610
8611 Warn about functions that might be candidates for attributes
8612 @code{pure}, @code{const}, @code{noreturn}, @code{malloc} or
8613 @code{returns_nonnull}. The compiler
8614 only warns for functions visible in other compilation units or (in the case of
8615 @code{pure} and @code{const}) if it cannot prove that the function returns
8616 normally. A function returns normally if it doesn't contain an infinite loop or
8617 return abnormally by throwing, calling @code{abort} or trapping. This analysis
8618 requires option @option{-fipa-pure-const}, which is enabled by default at
8619 @option{-O} and higher. Higher optimization levels improve the accuracy
8620 of the analysis.
8621
8622 @opindex Wsuggest-attribute=format
8623 @opindex Wmissing-format-attribute
8624 @opindex Wno-suggest-attribute=format
8625 @opindex Wno-missing-format-attribute
8626 @opindex Wformat
8627 @opindex Wno-format
8628 @item -Wsuggest-attribute=format
8629 @itemx -Wmissing-format-attribute
8630
8631 Warn about function pointers that might be candidates for @code{format}
8632 attributes. Note these are only possible candidates, not absolute ones.
8633 GCC guesses that function pointers with @code{format} attributes that
8634 are used in assignment, initialization, parameter passing or return
8635 statements should have a corresponding @code{format} attribute in the
8636 resulting type. I.e.@: the left-hand side of the assignment or
8637 initialization, the type of the parameter variable, or the return type
8638 of the containing function respectively should also have a @code{format}
8639 attribute to avoid the warning.
8640
8641 GCC also warns about function definitions that might be
8642 candidates for @code{format} attributes. Again, these are only
8643 possible candidates. GCC guesses that @code{format} attributes
8644 might be appropriate for any function that calls a function like
8645 @code{vprintf} or @code{vscanf}, but this might not always be the
8646 case, and some functions for which @code{format} attributes are
8647 appropriate may not be detected.
8648
8649 @opindex Wsuggest-attribute=cold
8650 @opindex Wno-suggest-attribute=cold
8651 @item -Wsuggest-attribute=cold
8652
8653 Warn about functions that might be candidates for @code{cold} attribute. This
8654 is based on static detection and generally only warns about functions which
8655 always leads to a call to another @code{cold} function such as wrappers of
8656 C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
8657 @end table
8658
8659 @opindex Wno-alloc-size
8660 @opindex Walloc-size
8661 @item -Walloc-size
8662 Warn about calls to allocation functions decorated with attribute
8663 @code{alloc_size} that specify insufficient size for the target type of
8664 the pointer the result is assigned to, including those to the built-in
8665 forms of the functions @code{aligned_alloc}, @code{alloca},
8666 @code{calloc}, @code{malloc}, and @code{realloc}.
8667
8668 @opindex Wno-alloc-zero
8669 @opindex Walloc-zero
8670 @item -Walloc-zero
8671 Warn about calls to allocation functions decorated with attribute
8672 @code{alloc_size} that specify zero bytes, including those to the built-in
8673 forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
8674 @code{malloc}, and @code{realloc}. Because the behavior of these functions
8675 when called with a zero size differs among implementations (and in the case
8676 of @code{realloc} has been deprecated) relying on it may result in subtle
8677 portability bugs and should be avoided.
8678
8679 @opindex Wcalloc-transposed-args
8680 @opindex Wno-calloc-transposed-args
8681 @item -Wcalloc-transposed-args
8682 Warn about calls to allocation functions decorated with attribute
8683 @code{alloc_size} with two arguments, which use @code{sizeof} operator
8684 as the earlier size argument and don't use it as the later size argument.
8685 This is a coding style warning. The first argument to @code{calloc} is
8686 documented to be number of elements in array, while the second argument
8687 is size of each element, so @code{calloc (@var{n}, sizeof (int))} is preferred
8688 over @code{calloc (sizeof (int), @var{n})}. If @code{sizeof} in the earlier
8689 argument and not the latter is intentional, the warning can be suppressed
8690 by using @code{calloc (sizeof (struct @var{S}) + 0, n)} or
8691 @code{calloc (1 * sizeof (struct @var{S}), 4)} or using @code{sizeof} in the
8692 later argument as well.
8693
8694 @opindex Walloc-size-larger-than=
8695 @opindex Wno-alloc-size-larger-than
8696 @item -Walloc-size-larger-than=@var{byte-size}
8697 Warn about calls to functions decorated with attribute @code{alloc_size}
8698 that attempt to allocate objects larger than the specified number of bytes,
8699 or where the result of the size computation in an integer type with infinite
8700 precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
8701 @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8702 Warnings controlled by the option can be disabled either by specifying
8703 @var{byte-size} of @samp{SIZE_MAX} or more or by
8704 @option{-Wno-alloc-size-larger-than}.
8705 @xref{Function Attributes}.
8706
8707 @opindex Wno-alloc-size-larger-than
8708 @item -Wno-alloc-size-larger-than
8709 Disable @option{-Walloc-size-larger-than=} warnings. The option is
8710 equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
8711 larger.
8712
8713 @opindex Wno-alloca
8714 @opindex Walloca
8715 @item -Walloca
8716 This option warns on all uses of @code{alloca} in the source.
8717
8718 @opindex Wno-auto-profile
8719 @opindex Wauto-profile
8720 @item -Wauto-profile
8721 Output warnings about auto-profile inconsistencies.
8722
8723 @opindex Walloca-larger-than=
8724 @opindex Wno-alloca-larger-than
8725 @item -Walloca-larger-than=@var{byte-size}
8726 This option warns on calls to @code{alloca} with an integer argument whose
8727 value is either zero, or that is not bounded by a controlling predicate
8728 that limits its value to at most @var{byte-size}. It also warns for calls
8729 to @code{alloca} where the bound value is unknown. Arguments of non-integer
8730 types are considered unbounded even if they appear to be constrained to
8731 the expected range.
8732
8733 For example, a bounded case of @code{alloca} could be:
8734
8735 @smallexample
8736 void func (size_t n)
8737 @{
8738 void *p;
8739 if (n <= 1000)
8740 p = alloca (n);
8741 else
8742 p = malloc (n);
8743 f (p);
8744 @}
8745 @end smallexample
8746
8747 In the above example, passing @code{-Walloca-larger-than=1000} would not
8748 issue a warning because the call to @code{alloca} is known to be at most
8749 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8750 the compiler would emit a warning.
8751
8752 Unbounded uses, on the other hand, are uses of @code{alloca} with no
8753 controlling predicate constraining its integer argument. For example:
8754
8755 @smallexample
8756 void func ()
8757 @{
8758 void *p = alloca (n);
8759 f (p);
8760 @}
8761 @end smallexample
8762
8763 If @code{-Walloca-larger-than=500} were passed, the above would trigger
8764 a warning, but this time because of the lack of bounds checking.
8765
8766 Note, that even seemingly correct code involving signed integers could
8767 cause a warning:
8768
8769 @smallexample
8770 void func (signed int n)
8771 @{
8772 if (n < 500)
8773 @{
8774 p = alloca (n);
8775 f (p);
8776 @}
8777 @}
8778 @end smallexample
8779
8780 In the above example, @var{n} could be negative, causing a larger than
8781 expected argument to be implicitly cast into the @code{alloca} call.
8782
8783 This option also warns when @code{alloca} is used in a loop.
8784
8785 @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8786 but is usually only effective when @option{-ftree-vrp} is active (default
8787 for @option{-O2} and above).
8788
8789 See also @option{-Wvla-larger-than=}@samp{byte-size}.
8790
8791 @opindex Wno-alloca-larger-than
8792 @item -Wno-alloca-larger-than
8793 Disable @option{-Walloca-larger-than=} warnings. The option is
8794 equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8795
8796 @opindex Warith-conversion
8797 @opindex Wno-arith-conversion
8798 @item -Warith-conversion
8799 Do warn about implicit conversions from arithmetic operations even
8800 when conversion of the operands to the same type cannot change their
8801 values. This affects warnings from @option{-Wconversion},
8802 @option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8803
8804 @smallexample
8805 @group
8806 void f (char c, int i)
8807 @{
8808 c = c + i; // warns with @option{-Wconversion}
8809 c = c + 1; // only warns with @option{-Warith-conversion}
8810 @}
8811 @end group
8812 @end smallexample
8813
8814 @opindex Wno-array-bounds
8815 @opindex Warray-bounds
8816 @item -Warray-bounds
8817 @itemx -Warray-bounds=@var{n}
8818 Warn about out of bounds subscripts or offsets into arrays. This warning
8819 is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8820 is active (the default for @option{-O2} and above) but a subset of instances
8821 are issued even without optimization.
8822
8823 By default, the trailing array of a structure will be treated as a flexible
8824 array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8825 if it is declared as either a flexible array member per C99 standard onwards
8826 (@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8827 array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8828 zero-length arrays or one-element arrays are not warned by default.
8829
8830 You can add the option @option{-fstrict-flex-arrays} or
8831 @option{-fstrict-flex-arrays=@var{level}} to control how this
8832 option treat trailing array of a structure as a flexible array member:
8833
8834 when @var{level}<=1, no change to the default behavior.
8835
8836 when @var{level}=2, additional warnings will be issued for out of bounds
8837 subscripts or offsets into one-element arrays;
8838
8839 when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8840 issued for out of bounds subscripts or offsets into zero-length arrays.
8841
8842 @table @gcctabopt
8843 @item -Warray-bounds=1
8844 This is the default warning level of @option{-Warray-bounds} and is enabled
8845 by @option{-Wall}; higher levels are not, and must be explicitly requested.
8846
8847 @item -Warray-bounds=2
8848 This warning level also warns about the intermediate results of pointer
8849 arithmetic that may yield out of bounds values. This warning level may
8850 give a larger number of false positives and is deactivated by default.
8851 @end table
8852
8853 @opindex Wunterminated-string-initialization
8854 @opindex Wno-unterminated-string-initialization
8855 @item -Wunterminated-string-initialization @r{(C and Objective-C only)}
8856 Warn about character arrays initialized as unterminated character sequences
8857 with a string literal, unless the declaration being initialized has
8858 the @code{nonstring} attribute.
8859 For example:
8860
8861 @smallexample
8862 char arr[3] = "foo"; /* Warning. */
8863 char arr2[3] __attribute__((nonstring)) = "bar"; /* No warning. */
8864 @end smallexample
8865
8866 This warning is enabled by @option{-Wextra}. If @option{-Wc++-compat}
8867 is enabled, the warning has slightly different wording and warns even
8868 if the declaration being initialized has the @code{nonstring} warning,
8869 as in C++ such initializations are an error.
8870
8871 @opindex Warray-compare
8872 @opindex Wno-array-compare
8873 @item -Warray-compare
8874 Warn about equality and relational comparisons between two operands of array
8875 type. This comparison was deprecated in C++20. For example:
8876
8877 @smallexample
8878 int arr1[5];
8879 int arr2[5];
8880 bool same = arr1 == arr2;
8881 @end smallexample
8882
8883 @option{-Warray-compare} is enabled by @option{-Wall}.
8884
8885 @opindex Wno-array-parameter
8886 @opindex Warray-parameter
8887 @item -Warray-parameter
8888 @itemx -Warray-parameter=@var{n}
8889 Warn about redeclarations of functions involving parameters of array or
8890 pointer types of inconsistent kinds or forms, and enable the detection
8891 of out-of-bounds accesses to such parameters by warnings such as
8892 @option{-Warray-bounds}.
8893
8894 If the first function declaration uses the array form for a parameter
8895 declaration, the bound specified
8896 in the array is assumed to be the minimum number of elements expected to
8897 be provided in calls to the function and the maximum number of elements
8898 accessed by it. Failing to provide arguments of sufficient size or accessing
8899 more than the maximum number of elements may be diagnosed by warnings such
8900 as @option{-Warray-bounds} or @option{-Wstringop-overflow}.
8901 At level 1, the warning diagnoses inconsistencies
8902 involving array parameters declared using the @code{T[static N]} form.
8903
8904 For example, the warning triggers for the second declaration of @code{f}
8905 because the first one with the keyword @code{static} specifies that
8906 the array argument must have at least four elements, while the second
8907 allows an array of any size to be passed to @code{f}.
8908
8909 @smallexample
8910 void f (int[static 4]);
8911 void f (int[]); // warning (inconsistent array form)
8912
8913 void g (void)
8914 @{
8915 int *p = (int *)malloc (1 * sizeof (int));
8916 f (p); // warning (array too small)
8917 @dots{}
8918 @}
8919 @end smallexample
8920
8921 At level 2 the warning also triggers for redeclarations involving any other
8922 inconsistency in array or pointer argument forms denoting array sizes.
8923 Pointers and arrays of unspecified bound are considered equivalent and do
8924 not trigger a warning.
8925
8926 @smallexample
8927 void g (int*);
8928 void g (int[]); // no warning
8929 void g (int[8]); // warning (inconsistent array bound)
8930 @end smallexample
8931
8932 @option{-Warray-parameter=2} is included in @option{-Wall}. The
8933 @option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8934 involving Variable Length Array arguments.
8935
8936 The short form of the option @option{-Warray-parameter} is equivalent to
8937 @option{-Warray-parameter=2}. The negative form @option{-Wno-array-parameter}
8938 is equivalent to @option{-Warray-parameter=0}.
8939
8940 @opindex Wattribute-alias
8941 @opindex Wno-attribute-alias
8942 @item -Wattribute-alias=@var{n}
8943 @itemx -Wno-attribute-alias
8944 Warn about declarations using the @code{alias} and similar attributes whose
8945 target is incompatible with the type of the alias.
8946 @xref{Function Attributes,,Declaring Attributes of Functions}.
8947
8948 @table @gcctabopt
8949 @item -Wattribute-alias=1
8950 The default warning level of the @option{-Wattribute-alias} option diagnoses
8951 incompatibilities between the type of the alias declaration and that of its
8952 target. Such incompatibilities are typically indicative of bugs.
8953
8954 @item -Wattribute-alias=2
8955
8956 At this level @option{-Wattribute-alias} also diagnoses cases where
8957 the attributes of the alias declaration are more restrictive than the
8958 attributes applied to its target. These mismatches can potentially
8959 result in incorrect code generation. In other cases they may be
8960 benign and could be resolved simply by adding the missing attribute to
8961 the target. For comparison, see the @option{-Wmissing-attributes}
8962 option, which controls diagnostics when the alias declaration is less
8963 restrictive than the target, rather than more restrictive.
8964
8965 Attributes considered include @code{alloc_align}, @code{alloc_size},
8966 @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8967 @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8968 @code{returns_nonnull}, and @code{returns_twice}.
8969 @end table
8970
8971 @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8972 This is the default. You can disable these warnings with either
8973 @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8974
8975 @opindex Wbidi-chars=
8976 @opindex Wbidi-chars
8977 @opindex Wno-bidi-chars
8978 @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
8979 Warn about possibly misleading UTF-8 bidirectional control characters in
8980 comments, string literals, character constants, and identifiers. Such
8981 characters can change left-to-right writing direction into right-to-left
8982 (and vice versa), which can cause confusion between the logical order and
8983 visual order. This may be dangerous; for instance, it may seem that a piece
8984 of code is not commented out, whereas it in fact is.
8985
8986 There are three levels of warning supported by GCC@. The default is
8987 @option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8988 bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8989 @option{-Wbidi-chars=any} warns about any use of bidirectional control
8990 characters.
8991
8992 By default, this warning does not warn about UCNs. It is, however, possible
8993 to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8994 @option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8995 and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8996 @option{-Wbidi-chars=any} was specified.
8997
8998 @opindex Wno-bool-compare
8999 @opindex Wbool-compare
9000 @item -Wbool-compare
9001 Warn about boolean expression compared with an integer value different from
9002 @code{true}/@code{false}. For instance, the following comparison is
9003 always false:
9004 @smallexample
9005 int n = 5;
9006 @dots{}
9007 if ((n > 1) == 2) @{ @dots{} @}
9008 @end smallexample
9009 This warning is enabled by @option{-Wall}.
9010
9011 @opindex Wno-bool-operation
9012 @opindex Wbool-operation
9013 @item -Wbool-operation
9014 Warn about suspicious operations on expressions of a boolean type. For
9015 instance, bitwise negation of a boolean is very likely a bug in the program.
9016 For C, this warning also warns about incrementing or decrementing a boolean,
9017 which rarely makes sense. (In C++, decrementing a boolean is always invalid.
9018 Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
9019
9020 This warning is enabled by @option{-Wall}.
9021
9022 @opindex Wno-duplicated-branches
9023 @opindex Wduplicated-branches
9024 @item -Wduplicated-branches
9025 Warn when an if-else has identical branches. This warning detects cases like
9026 @smallexample
9027 if (p != NULL)
9028 return 0;
9029 else
9030 return 0;
9031 @end smallexample
9032 It doesn't warn when both branches contain just a null statement. This warning
9033 also warn for conditional operators:
9034 @smallexample
9035 int i = x ? *p : *p;
9036 @end smallexample
9037
9038 @opindex Wno-duplicated-cond
9039 @opindex Wduplicated-cond
9040 @item -Wduplicated-cond
9041 Warn about duplicated conditions in an if-else-if chain. For instance,
9042 warn for the following code:
9043 @smallexample
9044 if (p->q != NULL) @{ @dots{} @}
9045 else if (p->q != NULL) @{ @dots{} @}
9046 @end smallexample
9047
9048 @opindex Wno-frame-address
9049 @opindex Wframe-address
9050 @item -Wframe-address
9051 Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
9052 is called with an argument greater than 0. Such calls may return indeterminate
9053 values or crash the program. The warning is included in @option{-Wall}.
9054
9055 @opindex Wno-discarded-qualifiers
9056 @opindex Wdiscarded-qualifiers
9057 @item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
9058 Do not warn if type qualifiers on pointers are being discarded.
9059 Typically, the compiler warns if a @code{const char *} variable is
9060 passed to a function that takes a @code{char *} parameter. This option
9061 can be used to suppress such a warning.
9062
9063 @opindex Wno-discarded-array-qualifiers
9064 @opindex Wdiscarded-array-qualifiers
9065 @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
9066 Do not warn if type qualifiers on arrays which are pointer targets
9067 are being discarded. Typically, the compiler warns if a
9068 @code{const int (*)[]} variable is passed to a function that
9069 takes a @code{int (*)[]} parameter. This option can be used to
9070 suppress such a warning.
9071
9072 @opindex Wno-incompatible-pointer-types
9073 @opindex Wincompatible-pointer-types
9074 @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
9075 Do not warn when there is a conversion between pointers that have incompatible
9076 types. This warning is for cases not covered by @option{-Wno-pointer-sign},
9077 which warns for pointer argument passing or assignment with different
9078 signedness.
9079
9080 By default, in C99 and later dialects of C, GCC treats this issue as an
9081 error. The error can be downgraded to a warning using
9082 @option{-fpermissive} (along with certain other errors), or for this
9083 error alone, with @option{-Wno-error=incompatible-pointer-types}.
9084
9085 This warning is upgraded to an error by @option{-pedantic-errors}.
9086
9087 @opindex Wno-int-conversion
9088 @opindex Wint-conversion
9089 @item -Wno-int-conversion @r{(C and Objective-C only)}
9090 Do not warn about incompatible integer to pointer and pointer to integer
9091 conversions. This warning is about implicit conversions; for explicit
9092 conversions the warnings @option{-Wno-int-to-pointer-cast} and
9093 @option{-Wno-pointer-to-int-cast} may be used.
9094
9095 By default, in C99 and later dialects of C, GCC treats this issue as an
9096 error. The error can be downgraded to a warning using
9097 @option{-fpermissive} (along with certain other errors), or for this
9098 error alone, with @option{-Wno-error=int-conversion}.
9099
9100 This warning is upgraded to an error by @option{-pedantic-errors}.
9101
9102 @opindex Wzero-as-null-pointer-constant
9103 @opindex Wno-zero-as-null-pointer-constant
9104 @item -Wzero-as-null-pointer-constant
9105 Warn when a literal @samp{0} is used as null pointer constant.
9106
9107 @opindex Wzero-length-bounds
9108 @opindex Wzero-length-bounds
9109 @item -Wzero-length-bounds
9110 Warn about accesses to elements of zero-length array members that might
9111 overlap other members of the same object. Declaring interior zero-length
9112 arrays is discouraged because accesses to them are undefined.
9113 @xref{Zero Length}.
9114
9115 For example, the first two stores in function @code{bad} are diagnosed
9116 because the array elements overlap the subsequent members @code{b} and
9117 @code{c}. The third store is diagnosed by @option{-Warray-bounds}
9118 because it is beyond the bounds of the enclosing object.
9119
9120 @smallexample
9121 struct X @{ int a[0]; int b, c; @};
9122 struct X x;
9123
9124 void bad (void)
9125 @{
9126 x.a[0] = 0; // -Wzero-length-bounds
9127 x.a[1] = 1; // -Wzero-length-bounds
9128 x.a[2] = 2; // -Warray-bounds
9129 @}
9130 @end smallexample
9131
9132 Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
9133
9134 @opindex Wno-div-by-zero
9135 @opindex Wdiv-by-zero
9136 @item -Wno-div-by-zero
9137 Do not warn about compile-time integer division by zero. Floating-point
9138 division by zero is not warned about, as it can be a legitimate way of
9139 obtaining infinities and NaNs.
9140
9141 @opindex Wsystem-headers
9142 @opindex Wno-system-headers
9143 @cindex warnings from system headers
9144 @cindex system headers, warnings from
9145 @item -Wsystem-headers
9146 Print warning messages for constructs found in system header files.
9147 Warnings from system headers are normally suppressed, on the assumption
9148 that they usually do not indicate real problems and would only make the
9149 compiler output harder to read. Using this command-line option tells
9150 GCC to emit warnings from system headers as if they occurred in user
9151 code. However, note that using @option{-Wall} in conjunction with this
9152 option does @emph{not} warn about unknown pragmas in system
9153 headers---for that, @option{-Wunknown-pragmas} must also be used.
9154
9155 @opindex Wtautological-compare
9156 @opindex Wno-tautological-compare
9157 @item -Wtautological-compare
9158 Warn if a self-comparison always evaluates to true or false. This
9159 warning detects various mistakes such as:
9160 @smallexample
9161 int i = 1;
9162 @dots{}
9163 if (i > i) @{ @dots{} @}
9164 @end smallexample
9165
9166 This warning also warns about bitwise comparisons that always evaluate
9167 to true or false, for instance:
9168 @smallexample
9169 if ((a & 16) == 10) @{ @dots{} @}
9170 @end smallexample
9171 will always be false.
9172
9173 This warning is enabled by @option{-Wall}.
9174
9175 @opindex Wtrailing-whitespace
9176 @opindex Wno-trailing-whitespace
9177 @opindex Wtrailing-whitespace=
9178 @item -Wtrailing-whitespace
9179 @itemx -Wtrailing-whitespace=@var{kind}
9180 Warn about trailing whitespace at the end of lines, including inside of
9181 comments, but excluding trailing whitespace in raw string literals.
9182 @code{-Wtrailing-whitespace} is equivalent to
9183 @code{-Wtrailing-whitespace=blanks} and warns just about trailing space and
9184 horizontal tab characters. @code{-Wtrailing-whitespace=any} warns about
9185 those or trailing form feed or vertical tab characters.
9186 @code{-Wno-trailing-whitespace} or @code{-Wtrailing-whitespace=none}
9187 disables the warning, which is the default.
9188 This is a coding style warning.
9189
9190 @opindex Wleading-whitespace=
9191 @item -Wleading-whitespace=@var{kind}
9192 Warn about style issues in leading whitespace, but not about the amount of
9193 indentation. Some projects use coding styles where only spaces are used
9194 for indentation, others use only tabs, others use zero or more tabs (for
9195 multiples of @code{-ftabstop=@var{n}}) followed by zero or fewer than @var{n}
9196 spaces. No warning is emitted on lines which contain solely whitespace
9197 (although @code{-Wtrailing-whitespace=} warning might be emitted), no
9198 warnings are emitted inside of raw string literals. Warnings are also emitted
9199 for leading whitespace inside of multi-line comments.
9200 @code{-Wleading-whitespace=spaces} warns about leading whitespace other than
9201 spaces for projects which want to indent just by spaces.
9202 @code{-Wleading-whitespace=tabs} warns about leading whitespace other than
9203 horizontal tabs for projects which want to indent just by horizontal tabs.
9204 @code{-Wleading-whitespace=blanks} warns about leading whitespace other than
9205 spaces and horizontal tabs, or about horizontal tab after a space in the
9206 leading whitespace, or about @var{n} or more consecutive spaces in leading
9207 whitespace (where @var{n} is argument of @code{-ftabstop=@var{n}}, 8 by
9208 default).
9209 @code{-Wleading-whitespace=none} disables the warning, which is the default.
9210 This is a coding style warning.
9211
9212 @opindex Wtrampolines
9213 @opindex Wno-trampolines
9214 @item -Wtrampolines
9215 Warn about trampolines generated for pointers to nested functions.
9216 A trampoline is a small piece of data or code that is created at run
9217 time on the stack when the address of a nested function is taken, and is
9218 used to call the nested function indirectly. For some targets, it is
9219 made up of data only and thus requires no special treatment. But, for
9220 most targets, it is made up of code and thus requires the stack to be
9221 made executable in order for the program to work properly.
9222
9223 @opindex Wfloat-equal
9224 @opindex Wno-float-equal
9225 @item -Wfloat-equal
9226 Warn if floating-point values are used in equality comparisons.
9227
9228 The idea behind this is that sometimes it is convenient (for the
9229 programmer) to consider floating-point values as approximations to
9230 infinitely precise real numbers. If you are doing this, then you need
9231 to compute (by analyzing the code, or in some other way) the maximum or
9232 likely maximum error that the computation introduces, and allow for it
9233 when performing comparisons (and when producing output, but that's a
9234 different problem). In particular, instead of testing for equality, you
9235 should check to see whether the two values have ranges that overlap; and
9236 this is done with the relational operators, so equality comparisons are
9237 probably mistaken.
9238
9239 @opindex Wtraditional
9240 @opindex Wno-traditional
9241 @item -Wtraditional @r{(C and Objective-C only)}
9242 Warn about certain constructs that behave differently in traditional and
9243 ISO C@. Also warn about ISO C constructs that have no traditional C
9244 equivalent, and/or problematic constructs that should be avoided.
9245
9246 @itemize @bullet
9247 @item
9248 Macro parameters that appear within string literals in the macro body.
9249 In traditional C macro replacement takes place within string literals,
9250 but in ISO C it does not.
9251
9252 @item
9253 In traditional C, some preprocessor directives did not exist.
9254 Traditional preprocessors only considered a line to be a directive
9255 if the @samp{#} appeared in column 1 on the line. Therefore
9256 @option{-Wtraditional} warns about directives that traditional C
9257 understands but ignores because the @samp{#} does not appear as the
9258 first character on the line. It also suggests you hide directives like
9259 @code{#pragma} not understood by traditional C by indenting them. Some
9260 traditional implementations do not recognize @code{#elif}, so this option
9261 suggests avoiding it altogether.
9262
9263 @item
9264 A function-like macro that appears without arguments.
9265
9266 @item
9267 The unary plus operator.
9268
9269 @item
9270 The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
9271 constant suffixes. (Traditional C does support the @samp{L} suffix on integer
9272 constants.) Note, these suffixes appear in macros defined in the system
9273 headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
9274 Use of these macros in user code might normally lead to spurious
9275 warnings, however GCC's integrated preprocessor has enough context to
9276 avoid warning in these cases.
9277
9278 @item
9279 A function declared external in one block and then used after the end of
9280 the block.
9281
9282 @item
9283 A @code{switch} statement has an operand of type @code{long}.
9284
9285 @item
9286 A non-@code{static} function declaration follows a @code{static} one.
9287 This construct is not accepted by some traditional C compilers.
9288
9289 @item
9290 The ISO type of an integer constant has a different width or
9291 signedness from its traditional type. This warning is only issued if
9292 the base of the constant is ten. I.e.@: hexadecimal or octal values, which
9293 typically represent bit patterns, are not warned about.
9294
9295 @item
9296 Usage of ISO string concatenation is detected.
9297
9298 @item
9299 Initialization of automatic aggregates.
9300
9301 @item
9302 Identifier conflicts with labels. Traditional C lacks a separate
9303 namespace for labels.
9304
9305 @item
9306 Initialization of unions. If the initializer is zero, the warning is
9307 omitted. This is done under the assumption that the zero initializer in
9308 user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
9309 initializer warnings and relies on default initialization to zero in the
9310 traditional C case.
9311
9312 @item
9313 Conversions by prototypes between fixed/floating-point values and vice
9314 versa. The absence of these prototypes when compiling with traditional
9315 C causes serious problems. This is a subset of the possible
9316 conversion warnings; for the full set use @option{-Wtraditional-conversion}.
9317
9318 @item
9319 Use of ISO C style function definitions. This warning intentionally is
9320 @emph{not} issued for prototype declarations or variadic functions
9321 because these ISO C features appear in your code when using
9322 libiberty's traditional C compatibility macros, @code{PARAMS} and
9323 @code{VPARAMS}. This warning is also bypassed for nested functions
9324 because that feature is already a GCC extension and thus not relevant to
9325 traditional C compatibility.
9326 @end itemize
9327
9328 @opindex Wtraditional-conversion
9329 @opindex Wno-traditional-conversion
9330 @item -Wtraditional-conversion @r{(C and Objective-C only)}
9331 Warn if a prototype causes a type conversion that is different from what
9332 would happen to the same argument in the absence of a prototype. This
9333 includes conversions of fixed point to floating and vice versa, and
9334 conversions changing the width or signedness of a fixed-point argument
9335 except when the same as the default promotion.
9336
9337 @opindex Wdeclaration-after-statement
9338 @opindex Wno-declaration-after-statement
9339 @item -Wdeclaration-after-statement @r{(C and Objective-C only)}
9340 Warn when a declaration is found after a statement in a block. This
9341 construct, known from C++, was introduced with ISO C99 and is by default
9342 allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
9343
9344 This warning is upgraded to an error by @option{-pedantic-errors}.
9345
9346 @opindex Wshadow
9347 @opindex Wno-shadow
9348 @item -Wshadow
9349 Warn whenever a local variable or type declaration shadows another
9350 variable, parameter, type, class member (in C++), or instance variable
9351 (in Objective-C) or whenever a built-in function is shadowed. Note
9352 that in C++, the compiler warns if a local variable shadows an
9353 explicit typedef, but not if it shadows a struct/class/enum.
9354 If this warning is enabled, it includes also all instances of
9355 local shadowing. This means that @option{-Wno-shadow=local}
9356 and @option{-Wno-shadow=compatible-local} are ignored when
9357 @option{-Wshadow} is used.
9358 Same as @option{-Wshadow=global}.
9359
9360 @opindex Wno-shadow-ivar
9361 @opindex Wshadow-ivar
9362 @item -Wno-shadow-ivar @r{(Objective-C only)}
9363 Do not warn whenever a local variable shadows an instance variable in an
9364 Objective-C method.
9365
9366 @opindex Wshadow=global
9367 @item -Wshadow=global
9368 Warn for any shadowing.
9369 Same as @option{-Wshadow}.
9370
9371 @opindex Wshadow=local
9372 @item -Wshadow=local
9373 Warn when a local variable shadows another local variable or parameter.
9374
9375 @opindex Wshadow=compatible-local
9376 @item -Wshadow=compatible-local
9377 Warn when a local variable shadows another local variable or parameter
9378 whose type is compatible with that of the shadowing variable. In C++,
9379 type compatibility here means the type of the shadowing variable can be
9380 converted to that of the shadowed variable. The creation of this flag
9381 (in addition to @option{-Wshadow=local}) is based on the idea that when
9382 a local variable shadows another one of incompatible type, it is most
9383 likely intentional, not a bug or typo, as shown in the following example:
9384
9385 @smallexample
9386 @group
9387 for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
9388 @{
9389 for (int i = 0; i < N; ++i)
9390 @{
9391 ...
9392 @}
9393 ...
9394 @}
9395 @end group
9396 @end smallexample
9397
9398 Since the two variable @code{i} in the example above have incompatible types,
9399 enabling only @option{-Wshadow=compatible-local} does not emit a warning.
9400 Because their types are incompatible, if a programmer accidentally uses one
9401 in place of the other, type checking is expected to catch that and emit an
9402 error or warning. Use of this flag instead of @option{-Wshadow=local} can
9403 possibly reduce the number of warnings triggered by intentional shadowing.
9404 Note that this also means that shadowing @code{const char *i} by
9405 @code{char *i} does not emit a warning.
9406
9407 This warning is also enabled by @option{-Wshadow=local}.
9408
9409 @opindex Wlarger-than=
9410 @opindex Wlarger-than-@var{byte-size}
9411 @item -Wlarger-than=@var{byte-size}
9412 Warn whenever an object is defined whose size exceeds @var{byte-size}.
9413 @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
9414 Warnings controlled by the option can be disabled either by specifying
9415 @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
9416
9417 Also warn for calls to bounded functions such as @code{memchr} or
9418 @code{strnlen} that specify a bound greater than the largest possible
9419 object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
9420 can only be disabled by @option{-Wno-larger-than}.
9421
9422 @opindex Wno-larger-than
9423 @item -Wno-larger-than
9424 Disable @option{-Wlarger-than=} warnings. The option is equivalent
9425 to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
9426
9427 @opindex Wframe-larger-than=
9428 @opindex Wno-frame-larger-than
9429 @item -Wframe-larger-than=@var{byte-size}
9430 Warn if the size of a function frame exceeds @var{byte-size}.
9431 The computation done to determine the stack frame size is approximate
9432 and not conservative.
9433 The actual requirements may be somewhat greater than @var{byte-size}
9434 even if you do not get a warning. In addition, any space allocated
9435 via @code{alloca}, variable-length arrays, or related constructs
9436 is not included by the compiler when determining
9437 whether or not to issue a warning.
9438 @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
9439 Warnings controlled by the option can be disabled either by specifying
9440 @var{byte-size} of @samp{SIZE_MAX} or more or by
9441 @option{-Wno-frame-larger-than}.
9442
9443 @opindex Wno-frame-larger-than
9444 @item -Wno-frame-larger-than
9445 Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
9446 to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
9447
9448 @opindex Wfree-nonheap-object
9449 @opindex Wno-free-nonheap-object
9450 @item -Wfree-nonheap-object
9451 Warn when attempting to deallocate an object that was either not allocated
9452 on the heap, or by using a pointer that was not returned from a prior call
9453 to the corresponding allocation function. For example, because the call
9454 to @code{stpcpy} returns a pointer to the terminating nul character and
9455 not to the beginning of the object, the call to @code{free} below is
9456 diagnosed.
9457
9458 @smallexample
9459 void f (char *p)
9460 @{
9461 p = stpcpy (p, "abc");
9462 // ...
9463 free (p); // warning
9464 @}
9465 @end smallexample
9466
9467 @option{-Wfree-nonheap-object} is included in @option{-Wall}.
9468
9469 @opindex Wstack-usage
9470 @opindex Wno-stack-usage
9471 @item -Wstack-usage=@var{byte-size}
9472 Warn if the stack usage of a function might exceed @var{byte-size}.
9473 The computation done to determine the stack usage is conservative.
9474 Any space allocated via @code{alloca}, variable-length arrays, or related
9475 constructs is included by the compiler when determining whether or not to
9476 issue a warning.
9477
9478 The message is in keeping with the output of @option{-fstack-usage}.
9479
9480 @itemize
9481 @item
9482 If the stack usage is fully static but exceeds the specified amount, it's:
9483
9484 @smallexample
9485 warning: stack usage is 1120 bytes
9486 @end smallexample
9487 @item
9488 If the stack usage is (partly) dynamic but bounded, it's:
9489
9490 @smallexample
9491 warning: stack usage might be 1648 bytes
9492 @end smallexample
9493 @item
9494 If the stack usage is (partly) dynamic and not bounded, it's:
9495
9496 @smallexample
9497 warning: stack usage might be unbounded
9498 @end smallexample
9499 @end itemize
9500
9501 @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
9502 Warnings controlled by the option can be disabled either by specifying
9503 @var{byte-size} of @samp{SIZE_MAX} or more or by
9504 @option{-Wno-stack-usage}.
9505
9506 @opindex Wno-stack-usage
9507 @item -Wno-stack-usage
9508 Disable @option{-Wstack-usage=} warnings. The option is equivalent
9509 to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
9510
9511 @opindex Wunsafe-loop-optimizations
9512 @opindex Wno-unsafe-loop-optimizations
9513 @item -Wunsafe-loop-optimizations
9514 Warn if the loop cannot be optimized because the compiler cannot
9515 assume anything on the bounds of the loop indices. With
9516 @option{-funsafe-loop-optimizations} warn if the compiler makes
9517 such assumptions.
9518
9519 @opindex Wno-pedantic-ms-format
9520 @opindex Wpedantic-ms-format
9521 @item -Wno-pedantic-ms-format @r{(MinGW targets only)}
9522 When used in combination with @option{-Wformat}
9523 and @option{-pedantic} without GNU extensions, this option
9524 disables the warnings about non-ISO @code{printf} / @code{scanf} format
9525 width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
9526 which depend on the MS runtime.
9527
9528 @opindex Wpointer-arith
9529 @opindex Wno-pointer-arith
9530 @item -Wpointer-arith
9531 Warn about anything that depends on the ``size of'' a function type or
9532 of @code{void}. GNU C assigns these types a size of 1, for
9533 convenience in calculations with @code{void *} pointers and pointers
9534 to functions. In C++, warn also when an arithmetic operation involves
9535 @code{NULL}. This warning is also enabled by @option{-Wpedantic}.
9536
9537 This warning is upgraded to an error by @option{-pedantic-errors}.
9538
9539 @opindex Wpointer-compare
9540 @opindex Wno-pointer-compare
9541 @item -Wno-pointer-compare
9542 Do not warn if a pointer is compared with a zero character constant.
9543 This usually
9544 means that the pointer was meant to be dereferenced. For example:
9545
9546 @smallexample
9547 const char *p = foo ();
9548 if (p == '\0')
9549 return 42;
9550 @end smallexample
9551
9552 Note that the code above is invalid in C++11.
9553
9554 This warning is enabled by default.
9555
9556 @opindex Wtsan
9557 @opindex Wno-tsan
9558 @item -Wno-tsan
9559
9560 Disable warnings about unsupported features in ThreadSanitizer.
9561
9562 ThreadSanitizer does not support @code{std::atomic_thread_fence} and
9563 can report false positives.
9564
9565 @opindex Wtype-limits
9566 @opindex Wno-type-limits
9567 @item -Wtype-limits
9568 Warn if a comparison is always true or always false due to the limited
9569 range of the data type, but do not warn for constant expressions. For
9570 example, warn if an unsigned variable is compared against zero with
9571 @code{<} or @code{>=}. This warning is also enabled by
9572 @option{-Wextra}.
9573
9574 @opindex Wabsolute-value
9575 @opindex Wno-absolute-value
9576 @item -Wabsolute-value @r{(C and Objective-C only)}
9577 Warn for calls to standard functions that compute the absolute value
9578 of an argument when a more appropriate standard function is available.
9579 For example, calling @code{abs(3.14)} triggers the warning because the
9580 appropriate function to call to compute the absolute value of a double
9581 argument is @code{fabs}. The option also triggers warnings when the
9582 argument in a call to such a function has an unsigned type. This
9583 warning can be suppressed with an explicit type cast and it is also
9584 enabled by @option{-Wextra}.
9585
9586 @include cppwarnopts.texi
9587
9588 @opindex Wbad-function-cast
9589 @opindex Wno-bad-function-cast
9590 @item -Wbad-function-cast @r{(C and Objective-C only)}
9591 Warn when a function call is cast to a non-matching type.
9592 For example, warn if a call to a function returning an integer type
9593 is cast to a pointer type.
9594
9595 @opindex Wc90-c99-compat
9596 @opindex Wno-c90-c99-compat
9597 @item -Wc90-c99-compat @r{(C and Objective-C only)}
9598 Warn about features not present in ISO C90, but present in ISO C99.
9599 For instance, warn about use of variable length arrays, @code{long long}
9600 type, @code{bool} type, compound literals, designated initializers, and so
9601 on. This option is independent of the standards mode. Warnings are disabled
9602 in the expression that follows @code{__extension__}.
9603
9604 @opindex Wc99-c11-compat
9605 @opindex Wno-c99-c11-compat
9606 @item -Wc99-c11-compat @r{(C and Objective-C only)}
9607 Warn about features not present in ISO C99, but present in ISO C11.
9608 For instance, warn about use of anonymous structures and unions,
9609 @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
9610 @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
9611 and so on. This option is independent of the standards mode. Warnings are
9612 disabled in the expression that follows @code{__extension__}.
9613
9614 @opindex Wc11-c23-compat
9615 @opindex Wno-c11-c23-compat
9616 @item -Wc11-c23-compat @r{(C and Objective-C only)}
9617 @itemx -Wc11-c2x-compat @r{(C and Objective-C only)}
9618 Warn about features not present in ISO C11, but present in ISO C23.
9619 For instance, warn about omitting the string in @code{_Static_assert},
9620 use of @samp{[[]]} syntax for attributes, use of decimal
9621 floating-point types, and so on. This option is independent of the
9622 standards mode. Warnings are disabled in the expression that follows
9623 @code{__extension__}. The name @option{-Wc11-c2x-compat} is
9624 deprecated.
9625
9626 When not compiling in C23 mode, these warnings are upgraded to errors
9627 by @option{-pedantic-errors}.
9628
9629 @opindex Wc23-c2y-compat
9630 @opindex Wno-c23-c2y-compat
9631 @item -Wc23-c2y-compat @r{(C and Objective-C only)}
9632 @itemx -Wc23-c2y-compat @r{(C and Objective-C only)}
9633 Warn about features not present in ISO C23, but present in ISO C2Y.
9634 For instance, warn about @code{_Generic} selecting with a type name
9635 instead of an expression. This option is independent of the standards
9636 mode. Warnings are disabled in the expression that follows
9637 @code{__extension__}.
9638
9639 When not compiling in C2Y mode, these warnings are upgraded to errors
9640 by @option{-pedantic-errors}.
9641
9642 @opindex Wc++-compat
9643 @opindex Wno-c++-compat
9644 @item -Wc++-compat @r{(C and Objective-C only)}
9645 Warn about ISO C constructs that are outside of the common subset of
9646 ISO C and ISO C++, e.g.@: request for implicit conversion from
9647 @code{void *} to a pointer to non-@code{void} type.
9648
9649 @opindex Wc++11-compat
9650 @opindex Wno-c++11-compat
9651 @item -Wc++11-compat @r{(C++ and Objective-C++ only)}
9652 Warn about C++ constructs whose meaning differs between ISO C++ 1998
9653 and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
9654 in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
9655 enabled by @option{-Wall}.
9656
9657 @opindex Wc++14-compat
9658 @opindex Wno-c++14-compat
9659 @item -Wc++14-compat @r{(C++ and Objective-C++ only)}
9660 Warn about C++ constructs whose meaning differs between ISO C++ 2011
9661 and ISO C++ 2014. This warning is enabled by @option{-Wall}.
9662
9663 @opindex Wc++17-compat
9664 @opindex Wno-c++17-compat
9665 @item -Wc++17-compat @r{(C++ and Objective-C++ only)}
9666 Warn about C++ constructs whose meaning differs between ISO C++ 2014
9667 and ISO C++ 2017. This warning is enabled by @option{-Wall}.
9668
9669 @opindex Wc++20-compat
9670 @opindex Wno-c++20-compat
9671 @item -Wc++20-compat @r{(C++ and Objective-C++ only)}
9672 Warn about C++ constructs whose meaning differs between ISO C++ 2017
9673 and ISO C++ 2020. This warning is enabled by @option{-Wall}.
9674
9675 @opindex Wc++11-extensions
9676 @opindex Wno-c++11-extensions
9677 @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
9678 Do not warn about C++11 constructs in code being compiled using
9679 an older C++ standard. Even without this option, some C++11 constructs
9680 will only be diagnosed if @option{-Wpedantic} is used.
9681
9682 @opindex Wc++14-extensions
9683 @opindex Wno-c++14-extensions
9684 @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
9685 Do not warn about C++14 constructs in code being compiled using
9686 an older C++ standard. Even without this option, some C++14 constructs
9687 will only be diagnosed if @option{-Wpedantic} is used.
9688
9689 @opindex Wc++17-extensions
9690 @opindex Wno-c++17-extensions
9691 @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
9692 Do not warn about C++17 constructs in code being compiled using
9693 an older C++ standard. Even without this option, some C++17 constructs
9694 will only be diagnosed if @option{-Wpedantic} is used.
9695
9696 @opindex Wc++20-extensions
9697 @opindex Wno-c++20-extensions
9698 @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
9699 Do not warn about C++20 constructs in code being compiled using
9700 an older C++ standard. Even without this option, some C++20 constructs
9701 will only be diagnosed if @option{-Wpedantic} is used.
9702
9703 @opindex Wc++23-extensions
9704 @opindex Wno-c++23-extensions
9705 @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
9706 Do not warn about C++23 constructs in code being compiled using
9707 an older C++ standard. Even without this option, some C++23 constructs
9708 will only be diagnosed if @option{-Wpedantic} is used.
9709
9710 @opindex Wc++26-extensions
9711 @opindex Wno-c++26-extensions
9712 @item -Wno-c++26-extensions @r{(C++ and Objective-C++ only)}
9713 Do not warn about C++26 constructs in code being compiled using
9714 an older C++ standard. Even without this option, some C++26 constructs
9715 will only be diagnosed if @option{-Wpedantic} is used.
9716
9717 @opindex Wcast-qual
9718 @opindex Wno-cast-qual
9719 @item -Wcast-qual
9720 Warn whenever a pointer is cast so as to remove a type qualifier from
9721 the target type. For example, warn if a @code{const char *} is cast
9722 to an ordinary @code{char *}.
9723
9724 Also warn when making a cast that introduces a type qualifier in an
9725 unsafe way. For example, casting @code{char **} to @code{const char **}
9726 is unsafe, as in this example:
9727
9728 @smallexample
9729 /* p is char ** value. */
9730 const char **q = (const char **) p;
9731 /* Assignment of readonly string to const char * is OK. */
9732 *q = "string";
9733 /* Now char** pointer points to read-only memory. */
9734 **p = 'b';
9735 @end smallexample
9736
9737 @opindex Wcast-align
9738 @opindex Wno-cast-align
9739 @item -Wcast-align
9740 Warn whenever a pointer is cast such that the required alignment of the
9741 target is increased. For example, warn if a @code{char *} is cast to
9742 an @code{int *} on machines where integers can only be accessed at
9743 two- or four-byte boundaries.
9744
9745 @opindex Wcast-align=strict
9746 @item -Wcast-align=strict
9747 Warn whenever a pointer is cast such that the required alignment of the
9748 target is increased. For example, warn if a @code{char *} is cast to
9749 an @code{int *} regardless of the target machine.
9750
9751 @opindex Wcast-function-type
9752 @opindex Wno-cast-function-type
9753 @item -Wcast-function-type
9754 Warn when a function pointer is cast to an incompatible function pointer.
9755 In a cast involving function types with a variable argument list only
9756 the types of initial arguments that are provided are considered.
9757 Any parameter of pointer-type matches any other pointer-type. Any benign
9758 differences in integral types are ignored, like @code{int} vs.@: @code{long}
9759 on ILP32 targets. Likewise type qualifiers are ignored. The function
9760 type @code{void (*) (void)} is special and matches everything, which can
9761 be used to suppress this warning.
9762 In a cast involving pointer to member types this warning warns whenever
9763 the type cast is changing the pointer to member type.
9764 This warning is enabled by @option{-Wextra}.
9765
9766 @opindex Wcast-user-defined
9767 @opindex Wno-cast-user-defined
9768 @item -Wcast-user-defined
9769 Warn when a cast to reference type does not involve a user-defined
9770 conversion that the programmer might expect to be called.
9771
9772 @smallexample
9773 struct A @{ operator const int&(); @} a;
9774 auto r = (int&)a; // warning
9775 @end smallexample
9776
9777 This warning is enabled by default.
9778
9779 @opindex Wwrite-strings
9780 @opindex Wno-write-strings
9781 @item -Wwrite-strings
9782 When compiling C, give string constants the type @code{const
9783 char[@var{length}]} so that copying the address of one into a
9784 non-@code{const} @code{char *} pointer produces a warning. These
9785 warnings help you find at compile time code that can try to write
9786 into a string constant, but only if you have been very careful about
9787 using @code{const} in declarations and prototypes. Otherwise, it is
9788 just a nuisance. This is why we did not make @option{-Wall} request
9789 these warnings.
9790
9791 When compiling C++, warn about the deprecated conversion from string
9792 literals to @code{char *}. This warning is enabled by default for C++
9793 programs.
9794
9795 This warning is upgraded to an error by @option{-pedantic-errors} in
9796 C++11 mode or later.
9797
9798 @opindex Wclobbered
9799 @opindex Wno-clobbered
9800 @item -Wclobbered
9801 Warn for variables that might be changed by @code{longjmp} or
9802 @code{vfork}. This warning is also enabled by @option{-Wextra}.
9803
9804 @opindex Wcomplain-wrong-lang
9805 @opindex Wno-complain-wrong-lang
9806 @item -Wno-complain-wrong-lang
9807 By default, language front ends complain when a command-line option is
9808 valid, but not applicable to that front end.
9809 This may be disabled with @option{-Wno-complain-wrong-lang},
9810 which is mostly useful when invoking a single compiler driver for
9811 multiple source files written in different languages, for example:
9812
9813 @smallexample
9814 $ g++ -fno-rtti a.cc b.f90
9815 @end smallexample
9816
9817 The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
9818 and the Fortran front end to compile @file{b.f90}.
9819 The latter front end diagnoses
9820 @samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
9821 which may be disabled with @option{-Wno-complain-wrong-lang}.
9822
9823 @opindex Wcompare-distinct-pointer-types
9824 @item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)}
9825 Warn if pointers of distinct types are compared without a cast. This
9826 warning is enabled by default.
9827
9828 @opindex Wconversion
9829 @opindex Wno-conversion
9830 @item -Wconversion
9831 Warn for implicit conversions that may alter a value. This includes
9832 conversions between real and integer, like @code{abs (x)} when
9833 @code{x} is @code{double}; conversions between signed and unsigned,
9834 like @code{unsigned ui = -1}; and conversions to smaller types, like
9835 @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
9836 ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
9837 changed by the conversion like in @code{abs (2.0)}. Warnings about
9838 conversions between signed and unsigned integers can be disabled by
9839 using @option{-Wno-sign-conversion}.
9840
9841 For C++, also warn for confusing overload resolution for user-defined
9842 conversions; and conversions that never use a type conversion
9843 operator: conversions to @code{void}, the same type, a base class or a
9844 reference to them. Warnings about conversions between signed and
9845 unsigned integers are disabled by default in C++ unless
9846 @option{-Wsign-conversion} is explicitly enabled.
9847
9848 Warnings about conversion from arithmetic on a small type back to that
9849 type are only given with @option{-Warith-conversion}.
9850
9851 @opindex Wdangling-else
9852 @opindex Wno-dangling-else
9853 @item -Wdangling-else
9854 Warn about constructions where there may be confusion to which
9855 @code{if} statement an @code{else} branch belongs. Here is an example of
9856 such a case:
9857
9858 @smallexample
9859 @group
9860 @{
9861 if (a)
9862 if (b)
9863 foo ();
9864 else
9865 bar ();
9866 @}
9867 @end group
9868 @end smallexample
9869
9870 In C/C++, every @code{else} branch belongs to the innermost possible
9871 @code{if} statement, which in this example is @code{if (b)}. This is
9872 often not what the programmer expected, as illustrated in the above
9873 example by indentation the programmer chose. When there is the
9874 potential for this confusion, GCC issues a warning when this flag
9875 is specified. To eliminate the warning, add explicit braces around
9876 the innermost @code{if} statement so there is no way the @code{else}
9877 can belong to the enclosing @code{if}. The resulting code
9878 looks like this:
9879
9880 @smallexample
9881 @group
9882 @{
9883 if (a)
9884 @{
9885 if (b)
9886 foo ();
9887 else
9888 bar ();
9889 @}
9890 @}
9891 @end group
9892 @end smallexample
9893
9894 This warning is enabled by @option{-Wparentheses}.
9895
9896 @opindex Wdangling-pointer
9897 @opindex Wno-dangling-pointer
9898 @item -Wdangling-pointer
9899 @itemx -Wdangling-pointer=@var{n}
9900 Warn about uses of pointers (or C++ references) to objects with automatic
9901 storage duration after their lifetime has ended. This includes local
9902 variables declared in nested blocks, compound literals and other unnamed
9903 temporary objects. In addition, warn about storing the address of such
9904 objects in escaped pointers. The warning is enabled at all optimization
9905 levels but may yield different results with optimization than without.
9906
9907 @table @gcctabopt
9908 @item -Wdangling-pointer=1
9909 At level 1, the warning diagnoses only unconditional uses of dangling pointers.
9910
9911 @item -Wdangling-pointer=2
9912 At level 2, in addition to unconditional uses the warning also diagnoses
9913 conditional uses of dangling pointers.
9914 @end table
9915
9916 The short form @option{-Wdangling-pointer} is equivalent to
9917 @option{-Wdangling-pointer=2}, while @option{-Wno-dangling-pointer} and
9918 @option{-Wdangling-pointer=0} have the same effect of disabling the warnings.
9919 @option{-Wdangling-pointer=2} is included in @option{-Wall}.
9920
9921 This example triggers the warning at level 1; the address of the unnamed
9922 temporary is unconditionally referenced outside of its scope.
9923
9924 @smallexample
9925 char f (char c1, char c2, char c3)
9926 @{
9927 char *p;
9928 @{
9929 p = (char[]) @{ c1, c2, c3 @};
9930 @}
9931 // warning: using dangling pointer 'p' to an unnamed temporary
9932 return *p;
9933 @}
9934 @end smallexample
9935
9936 In the following function the store of the address of the local variable
9937 @code{x} in the escaped pointer @code{*p} triggers the warning at
9938 level 1.
9939
9940 @smallexample
9941 void g (int **p)
9942 @{
9943 int x = 7;
9944 // warning: storing the address of local variable 'x' in '*p'
9945 *p = &x;
9946 @}
9947 @end smallexample
9948
9949 In this example, the array @var{a} is out of
9950 scope when the pointer @var{s} is used. Since the code that sets @code{s}
9951 is conditional, the warning triggers at level 2.
9952
9953 @smallexample
9954 extern void frob (const char *);
9955 void h (char *s)
9956 @{
9957 if (!s)
9958 @{
9959 char a[12] = "tmpname";
9960 s = a;
9961 @}
9962 // warning: dangling pointer 's' to 'a' may be used
9963 frob (s);
9964 @}
9965 @end smallexample
9966
9967 @opindex Wdate-time
9968 @opindex Wno-date-time
9969 @item -Wdate-time
9970 Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9971 are encountered as they might prevent bit-wise-identical reproducible
9972 compilations.
9973
9974 @opindex Wempty-body
9975 @opindex Wno-empty-body
9976 @item -Wempty-body
9977 Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9978 while} statement. This warning is also enabled by @option{-Wextra}.
9979
9980 @opindex Wendif-labels
9981 @opindex Wno-endif-labels
9982 @item -Wno-endif-labels
9983 Do not warn about stray tokens after @code{#else} and @code{#endif}.
9984
9985 @opindex Wenum-compare
9986 @opindex Wno-enum-compare
9987 @item -Wenum-compare
9988 Warn about a comparison between values of different enumerated types.
9989 In C++ enumerated type mismatches in conditional expressions are also
9990 diagnosed and the warning is enabled by default. In C this warning is
9991 enabled by @option{-Wall}.
9992
9993 @opindex Wenum-conversion
9994 @opindex Wno-enum-conversion
9995 @item -Wenum-conversion
9996 Warn when a value of enumerated type is implicitly converted to a
9997 different enumerated type. This warning is enabled by @option{-Wextra}
9998 in C@.
9999
10000 @opindex Wenum-int-mismatch
10001 @opindex Wno-enum-int-mismatch
10002 @item -Wenum-int-mismatch @r{(C and Objective-C only)}
10003 Warn about mismatches between an enumerated type and an integer type in
10004 declarations. For example:
10005
10006 @smallexample
10007 enum E @{ l = -1, z = 0, g = 1 @};
10008 int foo(void);
10009 enum E foo(void);
10010 @end smallexample
10011
10012 In C, an enumerated type is compatible with @code{char}, a signed
10013 integer type, or an unsigned integer type. However, since the choice
10014 of the underlying type of an enumerated type is implementation-defined,
10015 such mismatches may cause portability issues. In C++, such mismatches
10016 are an error. In C, this warning is enabled by @option{-Wall} and
10017 @option{-Wc++-compat}.
10018
10019 @opindex Wjump-misses-init
10020 @opindex Wno-jump-misses-init
10021 @item -Wjump-misses-init @r{(C, Objective-C only)}
10022 Warn if a @code{goto} statement or a @code{switch} statement jumps
10023 forward across the initialization of a variable, or jumps backward to a
10024 label after the variable has been initialized. This only warns about
10025 variables that are initialized when they are declared. This warning is
10026 only supported for C and Objective-C; in C++ this sort of branch is an
10027 error in any case.
10028
10029 @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
10030 can be disabled with the @option{-Wno-jump-misses-init} option.
10031
10032 @opindex Wsign-compare
10033 @opindex Wno-sign-compare
10034 @cindex warning for comparison of signed and unsigned values
10035 @cindex comparison of signed and unsigned values, warning
10036 @cindex signed and unsigned values, comparison warning
10037 @item -Wsign-compare
10038 Warn when a comparison between signed and unsigned values could produce
10039 an incorrect result when the signed value is converted to unsigned.
10040 In C++, this warning is also enabled by @option{-Wall}. In C, it is
10041 also enabled by @option{-Wextra}.
10042
10043 @opindex Wsign-conversion
10044 @opindex Wno-sign-conversion
10045 @item -Wsign-conversion
10046 Warn for implicit conversions that may change the sign of an integer
10047 value, like assigning a signed integer expression to an unsigned
10048 integer variable. An explicit cast silences the warning. In C, this
10049 option is enabled also by @option{-Wconversion}.
10050
10051 @opindex Wflex-array-member-not-at-end
10052 @opindex Wno-flex-array-member-not-at-end
10053 @item -Wflex-array-member-not-at-end @r{(C and C++ only)}
10054 Warn when a structure containing a C99 flexible array member as the last
10055 field is not at the end of another structure.
10056 This warning warns e.g. about
10057
10058 @smallexample
10059 struct flex @{ int length; char data[]; @};
10060 struct mid_flex @{ int m; struct flex flex_data; int n; @};
10061 @end smallexample
10062
10063 @opindex Wfloat-conversion
10064 @opindex Wno-float-conversion
10065 @item -Wfloat-conversion
10066 Warn for implicit conversions that reduce the precision of a real value.
10067 This includes conversions from real to integer, and from higher precision
10068 real to lower precision real values. This option is also enabled by
10069 @option{-Wconversion}.
10070
10071 @opindex Wno-scalar-storage-order
10072 @opindex Wscalar-storage-order
10073 @item -Wno-scalar-storage-order
10074 Do not warn on suspicious constructs involving reverse scalar storage order.
10075
10076 @opindex Wsizeof-array-div
10077 @opindex Wno-sizeof-array-div
10078 @item -Wsizeof-array-div
10079 Warn about divisions of two sizeof operators when the first one is applied
10080 to an array and the divisor does not equal the size of the array element.
10081 In such a case, the computation will not yield the number of elements in the
10082 array, which is likely what the user intended. This warning warns e.g. about
10083 @smallexample
10084 int fn ()
10085 @{
10086 int arr[10];
10087 return sizeof (arr) / sizeof (short);
10088 @}
10089 @end smallexample
10090
10091 This warning is enabled by @option{-Wall}.
10092
10093 @opindex Wsizeof-pointer-div
10094 @opindex Wno-sizeof-pointer-div
10095 @item -Wsizeof-pointer-div
10096 Warn for suspicious divisions of two sizeof expressions that divide
10097 the pointer size by the element size, which is the usual way to compute
10098 the array size but won't work out correctly with pointers. This warning
10099 warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
10100 not an array, but a pointer. This warning is enabled by @option{-Wall}.
10101
10102 @opindex Wsizeof-pointer-memaccess
10103 @opindex Wno-sizeof-pointer-memaccess
10104 @item -Wsizeof-pointer-memaccess
10105 Warn for suspicious length parameters to certain string and memory built-in
10106 functions if the argument uses @code{sizeof}. This warning triggers for
10107 example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
10108 an array, but a pointer, and suggests a possible fix, or about
10109 @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
10110 also warns about calls to bounded string copy functions like @code{strncat}
10111 or @code{strncpy} that specify as the bound a @code{sizeof} expression of
10112 the source array. For example, in the following function the call to
10113 @code{strncat} specifies the size of the source string as the bound. That
10114 is almost certainly a mistake and so the call is diagnosed.
10115 @smallexample
10116 void make_file (const char *name)
10117 @{
10118 char path[PATH_MAX];
10119 strncpy (path, name, sizeof path - 1);
10120 strncat (path, ".text", sizeof ".text");
10121 @dots{}
10122 @}
10123 @end smallexample
10124
10125 The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
10126
10127 @opindex Wsizeof-array-argument
10128 @opindex Wno-sizeof-array-argument
10129 @item -Wno-sizeof-array-argument
10130 Do not warn when the @code{sizeof} operator is applied to a parameter that is
10131 declared as an array in a function definition. This warning is enabled by
10132 default for C and C++ programs.
10133
10134 @opindex Wmemset-elt-size
10135 @opindex Wno-memset-elt-size
10136 @item -Wmemset-elt-size
10137 Warn for suspicious calls to the @code{memset} built-in function, if the
10138 first argument references an array, and the third argument is a number
10139 equal to the number of elements, but not equal to the size of the array
10140 in memory. This indicates that the user has omitted a multiplication by
10141 the element size. This warning is enabled by @option{-Wall}.
10142
10143 @opindex Wmemset-transposed-args
10144 @opindex Wno-memset-transposed-args
10145 @item -Wmemset-transposed-args
10146 Warn for suspicious calls to the @code{memset} built-in function where
10147 the second argument is not zero and the third argument is zero. For
10148 example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
10149 @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
10150 is only emitted if the third argument is a literal zero. Otherwise, if
10151 it is an expression that is folded to zero, or a cast of zero to some
10152 type, it is far less likely that the arguments have been mistakenly
10153 transposed and no warning is emitted. This warning is enabled
10154 by @option{-Wall}.
10155
10156 @opindex Waddress
10157 @opindex Wno-address
10158 @item -Waddress
10159 Warn about suspicious uses of address expressions. These include comparing
10160 the address of a function or a declared object to the null pointer constant
10161 such as in
10162 @smallexample
10163 void f (void);
10164 void g (void)
10165 @{
10166 if (!f) // warning: expression evaluates to false
10167 abort ();
10168 @}
10169 @end smallexample
10170 comparisons of a pointer to a string literal, such as in
10171 @smallexample
10172 void f (const char *x)
10173 @{
10174 if (x == "abc") // warning: expression evaluates to false
10175 puts ("equal");
10176 @}
10177 @end smallexample
10178 and tests of the results of pointer addition or subtraction for equality
10179 to null, such as in
10180 @smallexample
10181 void f (const int *p, int i)
10182 @{
10183 return p + i == NULL;
10184 @}
10185 @end smallexample
10186 Such uses typically indicate a programmer error: the address of most
10187 functions and objects necessarily evaluates to true (the exception are
10188 weak symbols), so their use in a conditional might indicate missing
10189 parentheses in a function call or a missing dereference in an array
10190 expression. The subset of the warning for object pointers can be
10191 suppressed by casting the pointer operand to an integer type such
10192 as @code{intptr_t} or @code{uintptr_t}.
10193 Comparisons against string literals result in unspecified behavior
10194 and are not portable, and suggest the intent was to call @code{strcmp}.
10195 The warning is suppressed if the suspicious expression is the result
10196 of macro expansion.
10197 @option{-Waddress} warning is enabled by @option{-Wall}.
10198
10199 @opindex Waddress-of-packed-member
10200 @opindex Wno-address-of-packed-member
10201 @item -Wno-address-of-packed-member
10202 Do not warn when the address of packed member of struct or union is taken,
10203 which usually results in an unaligned pointer value. This is
10204 enabled by default.
10205
10206 @opindex Wlogical-op
10207 @opindex Wno-logical-op
10208 @item -Wlogical-op
10209 Warn about suspicious uses of logical operators in expressions.
10210 This includes using logical operators in contexts where a
10211 bit-wise operator is likely to be expected. Also warns when
10212 the operands of a logical operator are the same:
10213 @smallexample
10214 extern int a;
10215 if (a < 0 && a < 0) @{ @dots{} @}
10216 @end smallexample
10217
10218 @opindex Wlogical-not-parentheses
10219 @opindex Wno-logical-not-parentheses
10220 @item -Wlogical-not-parentheses
10221 Warn about logical not used on the left hand side operand of a comparison.
10222 This option does not warn if the right operand is considered to be a boolean
10223 expression. Its purpose is to detect suspicious code like the following:
10224 @smallexample
10225 int a;
10226 @dots{}
10227 if (!a > 1) @{ @dots{} @}
10228 @end smallexample
10229
10230 It is possible to suppress the warning by wrapping the LHS into
10231 parentheses:
10232 @smallexample
10233 if ((!a) > 1) @{ @dots{} @}
10234 @end smallexample
10235
10236 This warning is enabled by @option{-Wall}.
10237
10238 @opindex Waggregate-return
10239 @opindex Wno-aggregate-return
10240 @item -Waggregate-return
10241 Warn if any functions that return structures or unions are defined or
10242 called. (In languages where you can return an array, this also elicits
10243 a warning.)
10244
10245 @opindex Wno-aggressive-loop-optimizations
10246 @opindex Waggressive-loop-optimizations
10247 @item -Wno-aggressive-loop-optimizations
10248 Do not warn if the compiler detects undefined behavior in a loop with
10249 a constant number of iterations. @option{-Waggressive-loop-optimizations}
10250 is enabled by default.
10251
10252 @opindex Wno-attributes
10253 @opindex Wattributes
10254 @item -Wno-attributes
10255 Do not warn if an unexpected @code{__attribute__} is used, such as
10256 unrecognized attributes, function attributes applied to variables,
10257 etc. This does not stop errors for incorrect use of supported
10258 attributes.
10259
10260 Warnings about ill-formed uses of standard attributes are upgraded to
10261 errors by @option{-pedantic-errors}.
10262
10263 Additionally, using @option{-Wno-attributes=}, it is possible to suppress
10264 warnings about unknown scoped attributes (in C++11 and C23). For example,
10265 @option{-Wno-attributes=vendor::attr} disables warning about the following
10266 declaration:
10267
10268 @smallexample
10269 [[vendor::attr]] void f();
10270 @end smallexample
10271
10272 It is also possible to disable warning about all attributes in a namespace
10273 using @option{-Wno-attributes=vendor::} which prevents warning about both
10274 of these declarations:
10275
10276 @smallexample
10277 [[vendor::safe]] void f();
10278 [[vendor::unsafe]] void f2();
10279 @end smallexample
10280
10281 Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
10282
10283 @opindex Wno-builtin-declaration-mismatch
10284 @opindex Wbuiltin-declaration-mismatch
10285 @item -Wno-builtin-declaration-mismatch
10286 Warn if a built-in function is declared with an incompatible signature
10287 or as a non-function, or when a built-in function declared with a type
10288 that does not include a prototype is called with arguments whose promoted
10289 types do not match those expected by the function. When @option{-Wextra}
10290 is specified, also warn when a built-in function that takes arguments is
10291 declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
10292 warning is enabled by default. To avoid the warning include the appropriate
10293 header to bring the prototypes of built-in functions into scope.
10294
10295 For example, the call to @code{memset} below is diagnosed by the warning
10296 because the function expects a value of type @code{size_t} as its argument
10297 but the type of @code{32} is @code{int}. With @option{-Wextra},
10298 the declaration of the function is diagnosed as well.
10299 @smallexample
10300 extern void* memset ();
10301 void f (void *d)
10302 @{
10303 memset (d, '\0', 32);
10304 @}
10305 @end smallexample
10306
10307 @opindex Wno-builtin-macro-redefined
10308 @opindex Wbuiltin-macro-redefined
10309 @item -Wno-builtin-macro-redefined
10310 Do not warn if certain built-in macros are redefined. This suppresses
10311 warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
10312 @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
10313
10314 @opindex Wfree-labels
10315 @opindex Wno-free-labels
10316 @item -Wfree-labels @r{(C and Objective-C only)}
10317 Warn if a label is applied to a non-statement, or occurs at the end of a
10318 compound statement. Such labels are allowed by C23 and later dialects
10319 of C, and are available as a GCC extension in all other dialects.
10320
10321 This warning is also enabled by @option{-Wc11-c23-compat}. It is turned
10322 into an error if building for a C version before C23 by
10323 @option{-pedantic-errors}.
10324
10325 @opindex Wheader-guard
10326 @item -Wheader-guard
10327 Warn if a valid preprocessor header multiple inclusion guard has
10328 a @code{#define} directive right after @code{#ifndef} or @code{#if !defined}
10329 directive for the multiple inclusion guard, which defines a different macro
10330 from the guard macro with a similar name, the actual multiple inclusion guard
10331 macro isn't defined at the corresponding @code{#ifndef} directive at the end
10332 of the header, and the @code{#define} directive defines an object-like macro
10333 with empty definition. In such case, it often is just a misspelled guard
10334 name, either in the @code{#ifndef} or @code{#if !defined} directive or in the
10335 subsequent @code{#define} directive. This warning is enabled
10336 by @option{-Wall}.
10337
10338 @opindex Wstrict-prototypes
10339 @opindex Wno-strict-prototypes
10340 @item -Wstrict-prototypes @r{(C and Objective-C only)}
10341 Warn if a function is declared or defined without specifying the
10342 argument types. (An old-style function definition is permitted without
10343 a warning if preceded by a declaration that specifies the argument
10344 types.)
10345
10346 @opindex Wold-style-declaration
10347 @opindex Wno-old-style-declaration
10348 @item -Wold-style-declaration @r{(C and Objective-C only)}
10349 Warn for obsolescent usages, according to the C Standard, in a
10350 declaration. For example, warn if storage-class specifiers like
10351 @code{static} are not the first things in a declaration. This warning
10352 is also enabled by @option{-Wextra}.
10353
10354 @opindex Wold-style-definition
10355 @opindex Wno-old-style-definition
10356 @item -Wold-style-definition @r{(C and Objective-C only)}
10357 Warn if an old-style function definition is used. A warning is given
10358 even if there is a previous prototype. A definition using @samp{()}
10359 is not considered an old-style definition in C23 mode, because it is
10360 equivalent to @samp{(void)} in that case, but is considered an
10361 old-style definition for older standards.
10362
10363 @opindex Wdeprecated-non-prototype
10364 @opindex Wno-deprecated-non-prototype
10365 @item -Wdeprecated-non-prototype @r{(C and Objective-C only)}
10366 Warn if a function declared with an empty parameter list @samp{()} is
10367 called with one or more arguments, or if a function definition with one
10368 or more parameters is encountered after such a declaration. Both cases
10369 are errors in C23 and later dialects of C.
10370
10371 This warning is also enabled by @option{-Wc11-c23-compat}.
10372
10373 @opindex Wmissing-parameter-name
10374 @opindex Wno-missing-parameter-name
10375 @item -Wmissing-parameter-name @r{(C and Objective-C only)}
10376 Warn if a function definition omits a parameter name, specifying only
10377 its type. This can be used to document that a parameter is unused
10378 in the definition. It is part of C23 and later dialects of C,
10379 and available as a GCC extension in all other dialects.
10380
10381 This warning is also enabled by @option{-Wc11-c23-compat}. It is turned
10382 into an error if building for a C version before C23 by
10383 @option{-pedantic-errors}.
10384
10385 @opindex Wmissing-parameter-type
10386 @opindex Wno-missing-parameter-type
10387 @item -Wmissing-parameter-type @r{(C and Objective-C only)}
10388 A function parameter is declared without a type specifier in K&R-style
10389 functions:
10390
10391 @smallexample
10392 void foo(bar) @{ @}
10393 @end smallexample
10394
10395 This warning is also enabled by @option{-Wextra}.
10396
10397 @opindex Wno-declaration-missing-parameter-type
10398 @opindex Wdeclaration-missing-parameter-type
10399 @item -Wno-declaration-missing-parameter-type @r{(C and Objective-C only)}
10400 Do not warn if a function declaration contains a parameter name without
10401 a type. Such function declarations do not provide a function prototype
10402 and prevent most type checking in function calls.
10403
10404 This warning is enabled by default. In C99 and later dialects of C, it
10405 is treated as an error. The error can be downgraded to a warning using
10406 @option{-fpermissive} (along with certain other errors), or for this
10407 error alone, with @option{-Wno-error=declaration-missing-parameter-type}.
10408
10409 This warning is upgraded to an error by @option{-pedantic-errors}.
10410
10411 @opindex Wmissing-prototypes
10412 @opindex Wno-missing-prototypes
10413 @item -Wmissing-prototypes @r{(C and Objective-C only)}
10414 Warn if a global function is defined without a previous prototype
10415 declaration. This warning is issued even if the definition itself
10416 provides a prototype. Use this option to detect global functions
10417 that do not have a matching prototype declaration in a header file.
10418 This option is not valid for C++ because all function declarations
10419 provide prototypes and a non-matching declaration declares an
10420 overload rather than conflict with an earlier declaration.
10421 Use @option{-Wmissing-declarations} to detect missing declarations in C++.
10422
10423 @opindex Wmissing-variable-declarations
10424 @opindex Wno-missing-variable-declarations
10425 @item -Wmissing-variable-declarations @r{(C and Objective-C only)}
10426 Warn if a global variable is defined without a previous declaration.
10427 Use this option to detect global variables that do not have a matching
10428 extern declaration in a header file.
10429
10430 @opindex Wmissing-declarations
10431 @opindex Wno-missing-declarations
10432 @item -Wmissing-declarations
10433 Warn if a global function is defined without a previous declaration.
10434 Do so even if the definition itself provides a prototype.
10435 Use this option to detect global functions that are not declared in
10436 header files. In C, no warnings are issued for functions with previous
10437 non-prototype declarations; use @option{-Wmissing-prototypes} to detect
10438 missing prototypes. In C++, no warnings are issued for function templates,
10439 or for inline functions, or for functions in anonymous namespaces.
10440
10441 @opindex Wmissing-field-initializers
10442 @opindex Wno-missing-field-initializers
10443 @opindex W
10444 @opindex Wextra
10445 @opindex Wno-extra
10446 @item -Wmissing-field-initializers
10447 Warn if a structure's initializer has some fields missing. For
10448 example, the following code causes such a warning, because
10449 @code{x.h} is implicitly zero:
10450
10451 @smallexample
10452 struct s @{ int f, g, h; @};
10453 struct s x = @{ 3, 4 @};
10454 @end smallexample
10455
10456 @c It's unclear if this behavior is desirable. See PR39589 and PR96868.
10457 In C this option does not warn about designated initializers, so the
10458 following modification does not trigger a warning:
10459
10460 @smallexample
10461 struct s @{ int f, g, h; @};
10462 struct s x = @{ .f = 3, .g = 4 @};
10463 @end smallexample
10464
10465 In C this option does not warn about the universal zero initializer
10466 @samp{@{ 0 @}}:
10467
10468 @smallexample
10469 struct s @{ int f, g, h; @};
10470 struct s x = @{ 0 @};
10471 @end smallexample
10472
10473 Likewise, in C++ this option does not warn about the empty @{ @}
10474 initializer, for example:
10475
10476 @smallexample
10477 struct s @{ int f, g, h; @};
10478 s x = @{ @};
10479 @end smallexample
10480
10481 This warning is included in @option{-Wextra}. To get other @option{-Wextra}
10482 warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
10483
10484 @opindex Wmissing-requires
10485 @opindex Wno-missing-requires
10486 @item -Wno-missing-requires
10487
10488 By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
10489
10490 @smallexample
10491 bool satisfied = requires @{ C<T> @};
10492 @end smallexample
10493
10494 Here @samp{satisfied} will be true if @samp{C<T>} is a valid
10495 expression, which it is for all T. Presumably the user meant to write
10496
10497 @smallexample
10498 bool satisfied = requires @{ requires C<T> @};
10499 @end smallexample
10500
10501 so @samp{satisfied} is only true if concept @samp{C} is satisfied for
10502 type @samp{T}.
10503
10504 This warning can be disabled with @option{-Wno-missing-requires}.
10505
10506 @opindex Wmissing-template-keyword
10507 @opindex Wno-missing-template-keyword
10508 @item -Wno-missing-template-keyword
10509
10510 The member access tokens ., -> and :: must be followed by the @code{template}
10511 keyword if the parent object is dependent and the member being named is a
10512 template.
10513
10514 @smallexample
10515 template <class X>
10516 void DoStuff (X x)
10517 @{
10518 x.template DoSomeOtherStuff<X>(); // Good.
10519 x.DoMoreStuff<X>(); // Warning, x is dependent.
10520 @}
10521 @end smallexample
10522
10523 In rare cases it is possible to get false positives. To silence this, wrap
10524 the expression in parentheses. For example, the following is treated as a
10525 template, even where m and N are integers:
10526
10527 @smallexample
10528 void NotATemplate (my_class t)
10529 @{
10530 int N = 5;
10531
10532 bool test = t.m < N > (0); // Treated as a template.
10533 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
10534 @}
10535 @end smallexample
10536
10537 This warning can be disabled with @option{-Wno-missing-template-keyword}.
10538
10539 @opindex Wno-multichar
10540 @opindex Wmultichar
10541 @item -Wno-multichar
10542 Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
10543 Usually they indicate a typo in the user's code, as they have
10544 implementation-defined values, and should not be used in portable code.
10545
10546 @opindex Wnormalized=
10547 @opindex Wnormalized
10548 @opindex Wno-normalized
10549 @cindex NFC
10550 @cindex NFKC
10551 @cindex character set, input normalization
10552 @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
10553 In ISO C and ISO C++, two identifiers are different if they are
10554 different sequences of characters. However, sometimes when characters
10555 outside the basic ASCII character set are used, you can have two
10556 different character sequences that look the same. To avoid confusion,
10557 the ISO 10646 standard sets out some @dfn{normalization rules} which
10558 when applied ensure that two sequences that look the same are turned into
10559 the same sequence. GCC can warn you if you are using identifiers that
10560 have not been normalized; this option controls that warning.
10561
10562 There are four levels of warning supported by GCC@. The default is
10563 @option{-Wnormalized=nfc}, which warns about any identifier that is
10564 not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
10565 recommended form for most uses. It is equivalent to
10566 @option{-Wnormalized}.
10567
10568 Unfortunately, there are some characters allowed in identifiers by
10569 ISO C and ISO C++ that, when turned into NFC, are not allowed in
10570 identifiers. That is, there's no way to use these symbols in portable
10571 ISO C or C++ and have all your identifiers in NFC@.
10572 @option{-Wnormalized=id} suppresses the warning for these characters.
10573 It is hoped that future versions of the standards involved will correct
10574 this, which is why this option is not the default.
10575
10576 You can switch the warning off for all characters by writing
10577 @option{-Wnormalized=none} or @option{-Wno-normalized}. You should
10578 only do this if you are using some other normalization scheme (like
10579 ``D''), because otherwise you can easily create bugs that are
10580 literally impossible to see.
10581
10582 Some characters in ISO 10646 have distinct meanings but look identical
10583 in some fonts or display methodologies, especially once formatting has
10584 been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
10585 LETTER N'', displays just like a regular @code{n} that has been
10586 placed in a superscript. ISO 10646 defines the @dfn{NFKC}
10587 normalization scheme to convert all these into a standard form as
10588 well, and GCC warns if your code is not in NFKC if you use
10589 @option{-Wnormalized=nfkc}. This warning is comparable to warning
10590 about every identifier that contains the letter O because it might be
10591 confused with the digit 0, and so is not the default, but may be
10592 useful as a local coding convention if the programming environment
10593 cannot be fixed to display these characters distinctly.
10594
10595 @opindex Wno-attribute-warning
10596 @opindex Wattribute-warning
10597 @item -Wno-attribute-warning
10598 Do not warn about usage of functions (@pxref{Function Attributes})
10599 declared with @code{warning} attribute. By default, this warning is
10600 enabled. @option{-Wno-attribute-warning} can be used to disable the
10601 warning or @option{-Wno-error=attribute-warning} can be used to
10602 disable the error when compiled with @option{-Werror} flag.
10603
10604 @opindex Wno-deprecated
10605 @opindex Wdeprecated
10606 @item -Wno-deprecated
10607 Do not warn about usage of deprecated features. @xref{Deprecated Features}.
10608
10609 In C++, explicitly specifying @option{-Wdeprecated} also enables
10610 warnings about some features that are deprecated in later language
10611 standards, specifically @option{-Wcomma-subscript},
10612 @option{-Wvolatile}, @option{-Wdeprecated-enum-float-conversion},
10613 @option{-Wdeprecated-enum-enum-conversion},
10614 @option{-Wdeprecated-literal-operator}, and
10615 @option{-Wdeprecated-variadic-comma-omission}.
10616
10617 @opindex Wno-deprecated-declarations
10618 @opindex Wdeprecated-declarations
10619 @item -Wno-deprecated-declarations
10620 Do not warn about uses of functions (@pxref{Function Attributes}),
10621 variables (@pxref{Variable Attributes}), and types (@pxref{Type
10622 Attributes}) marked as deprecated by using the @code{deprecated}
10623 attribute.
10624
10625 @opindex Wno-overflow
10626 @opindex Woverflow
10627 @item -Wno-overflow
10628 Do not warn about compile-time overflow in constant expressions.
10629
10630 @opindex Wno-odr
10631 @opindex Wodr
10632 @item -Wno-odr
10633 Warn about One Definition Rule violations during link-time optimization.
10634 Enabled by default.
10635
10636 @opindex Wopenacc-parallelism
10637 @opindex Wno-openacc-parallelism
10638 @cindex OpenACC accelerator programming
10639 @item -Wopenacc-parallelism
10640 Warn about potentially suboptimal choices related to OpenACC parallelism.
10641
10642 @opindex Wopenmp
10643 @opindex Wno-openmp
10644 @item -Wno-openmp
10645 Warn about suspicious OpenMP code.
10646
10647 @opindex Wopenmp-simd
10648 @opindex Wno-openmp-simd
10649 @item -Wopenmp-simd
10650 Warn if the vectorizer cost model overrides the OpenMP
10651 simd directive set by user. The @option{-fsimd-cost-model=unlimited}
10652 option can be used to relax the cost model.
10653
10654 @opindex Woverride-init
10655 @opindex Wno-override-init
10656 @opindex W
10657 @opindex Wextra
10658 @opindex Wno-extra
10659 @item -Woverride-init @r{(C and Objective-C only)}
10660 Warn if an initialized field without side effects is overridden when
10661 using designated initializers (@pxref{Designated Inits, , Designated
10662 Initializers}).
10663
10664 This warning is included in @option{-Wextra}. To get other
10665 @option{-Wextra} warnings without this one, use @option{-Wextra
10666 -Wno-override-init}.
10667
10668 @opindex Woverride-init-side-effects
10669 @opindex Wno-override-init-side-effects
10670 @item -Wno-override-init-side-effects @r{(C and Objective-C only)}
10671 Do not warn if an initialized field with side effects is overridden when
10672 using designated initializers (@pxref{Designated Inits, , Designated
10673 Initializers}). This warning is enabled by default.
10674
10675 @opindex Wpacked
10676 @opindex Wno-packed
10677 @item -Wpacked
10678 Warn if a structure is given the packed attribute, but the packed
10679 attribute has no effect on the layout or size of the structure.
10680 Such structures may be mis-aligned for little benefit. For
10681 instance, in this code, the variable @code{f.x} in @code{struct bar}
10682 is misaligned even though @code{struct bar} does not itself
10683 have the packed attribute:
10684
10685 @smallexample
10686 @group
10687 struct foo @{
10688 int x;
10689 char a, b, c, d;
10690 @} __attribute__((packed));
10691 struct bar @{
10692 char z;
10693 struct foo f;
10694 @};
10695 @end group
10696 @end smallexample
10697
10698 @opindex Wpacked-bitfield-compat
10699 @opindex Wno-packed-bitfield-compat
10700 @item -Wnopacked-bitfield-compat
10701 The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
10702 on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
10703 the change can lead to differences in the structure layout. GCC
10704 informs you when the offset of such a field has changed in GCC 4.4.
10705 For example there is no longer a 4-bit padding between field @code{a}
10706 and @code{b} in this structure:
10707
10708 @smallexample
10709 struct foo
10710 @{
10711 char a:4;
10712 char b:8;
10713 @} __attribute__ ((packed));
10714 @end smallexample
10715
10716 This warning is enabled by default. Use
10717 @option{-Wno-packed-bitfield-compat} to disable this warning.
10718
10719 @opindex Wpacked-not-aligned
10720 @opindex Wno-packed-not-aligned
10721 @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
10722 Warn if a structure field with explicitly specified alignment in a
10723 packed struct or union is misaligned. For example, a warning will
10724 be issued on @code{struct S}, like, @code{warning: alignment 1 of
10725 'struct S' is less than 8}, in this code:
10726
10727 @smallexample
10728 @group
10729 struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
10730 struct __attribute__ ((packed)) S @{
10731 struct S8 s8;
10732 @};
10733 @end group
10734 @end smallexample
10735
10736 This warning is enabled by @option{-Wall}.
10737
10738 @opindex Wpadded
10739 @opindex Wno-padded
10740 @item -Wpadded
10741 Warn if padding is included in a structure, either to align an element
10742 of the structure or to align the whole structure. Sometimes when this
10743 happens it is possible to rearrange the fields of the structure to
10744 reduce the padding and so make the structure smaller.
10745
10746 @opindex Wredundant-decls
10747 @opindex Wno-redundant-decls
10748 @item -Wredundant-decls
10749 Warn if anything is declared more than once in the same scope, even in
10750 cases where multiple declaration is valid and changes nothing.
10751
10752 @opindex Wrestrict
10753 @opindex Wno-restrict
10754 @item -Wrestrict
10755 Warn when an object referenced by a @code{restrict}-qualified parameter
10756 (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
10757 argument, or when copies between such objects overlap. For example,
10758 the call to the @code{strcpy} function below attempts to truncate the string
10759 by replacing its initial characters with the last four. However, because
10760 the call writes the terminating NUL into @code{a[4]}, the copies overlap and
10761 the call is diagnosed.
10762
10763 @smallexample
10764 void foo (void)
10765 @{
10766 char a[] = "abcd1234";
10767 strcpy (a, a + 4);
10768 @dots{}
10769 @}
10770 @end smallexample
10771 The @option{-Wrestrict} option detects some instances of simple overlap
10772 even without optimization but works best at @option{-O2} and above. It
10773 is included in @option{-Wall}.
10774
10775 @opindex Wnested-externs
10776 @opindex Wno-nested-externs
10777 @item -Wnested-externs @r{(C and Objective-C only)}
10778 Warn if an @code{extern} declaration is encountered within a function.
10779
10780 @opindex Winline
10781 @opindex Wno-inline
10782 @item -Winline
10783 Warn if a function that is declared as inline cannot be inlined.
10784 Even with this option, the compiler does not warn about failures to
10785 inline functions declared in system headers.
10786
10787 The compiler uses a variety of heuristics to determine whether or not
10788 to inline a function. For example, the compiler takes into account
10789 the size of the function being inlined and the amount of inlining
10790 that has already been done in the current function. Therefore,
10791 seemingly insignificant changes in the source program can cause the
10792 warnings produced by @option{-Winline} to appear or disappear.
10793
10794 @opindex Winterference-size
10795 @item -Winterference-size
10796 Warn about use of C++17 @code{std::hardware_destructive_interference_size}
10797 without specifying its value with @option{--param destructive-interference-size}.
10798 Also warn about questionable values for that option.
10799
10800 This variable is intended to be used for controlling class layout, to
10801 avoid false sharing in concurrent code:
10802
10803 @smallexample
10804 struct independent_fields @{
10805 alignas(std::hardware_destructive_interference_size)
10806 std::atomic<int> one;
10807 alignas(std::hardware_destructive_interference_size)
10808 std::atomic<int> two;
10809 @};
10810 @end smallexample
10811
10812 Here @samp{one} and @samp{two} are intended to be far enough apart
10813 that stores to one won't require accesses to the other to reload the
10814 cache line.
10815
10816 By default, @option{--param destructive-interference-size} and
10817 @option{--param constructive-interference-size} are set based on the
10818 current @option{-mtune} option, typically to the L1 cache line size
10819 for the particular target CPU, sometimes to a range if tuning for a
10820 generic target. So all translation units that depend on ABI
10821 compatibility for the use of these variables must be compiled with
10822 the same @option{-mtune} (or @option{-mcpu}).
10823
10824 If ABI stability is important, such as if the use is in a header for a
10825 library, you should probably not use the hardware interference size
10826 variables at all. Alternatively, you can force a particular value
10827 with @option{--param}.
10828
10829 If you are confident that your use of the variable does not affect ABI
10830 outside a single build of your project, you can turn off the warning
10831 with @option{-Wno-interference-size}.
10832
10833 @opindex Wint-in-bool-context
10834 @opindex Wno-int-in-bool-context
10835 @item -Wint-in-bool-context
10836 Warn for suspicious use of integer values where boolean values are expected,
10837 such as conditional expressions (?:) using non-boolean integer constants in
10838 boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
10839 integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
10840 for all kinds of multiplications regardless of the data type.
10841 This warning is enabled by @option{-Wall}.
10842
10843 @opindex Wno-int-to-pointer-cast
10844 @opindex Wint-to-pointer-cast
10845 @item -Wno-int-to-pointer-cast
10846 Suppress warnings from casts to pointer type of an integer of a
10847 different size. In C++, casting to a pointer type of smaller size is
10848 an error. @option{Wint-to-pointer-cast} is enabled by default.
10849
10850
10851 @opindex Wno-pointer-to-int-cast
10852 @opindex Wpointer-to-int-cast
10853 @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
10854 Suppress warnings from casts from a pointer to an integer type of a
10855 different size.
10856
10857 @opindex Winvalid-pch
10858 @opindex Wno-invalid-pch
10859 @item -Winvalid-pch
10860 Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
10861 the search path but cannot be used.
10862
10863 @opindex Winvalid-utf8
10864 @opindex Wno-invalid-utf8
10865 @item -Winvalid-utf8
10866 Warn if an invalid UTF-8 character is found.
10867 This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
10868 is used and turned into error with @option{-pedantic-errors}.
10869
10870 @opindex Wunicode
10871 @opindex Wno-unicode
10872 @item -Wno-unicode
10873 Don't diagnose invalid forms of delimited or named escape sequences which are
10874 treated as separate tokens. @option{Wunicode} is enabled by default.
10875
10876 @opindex Wlong-long
10877 @opindex Wno-long-long
10878 @item -Wlong-long
10879 Warn if @code{long long} type is used. This is enabled by either
10880 @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
10881 modes. To inhibit the warning messages, use @option{-Wno-long-long}.
10882
10883 This warning is upgraded to an error by @option{-pedantic-errors}.
10884
10885 @opindex Wvariadic-macros
10886 @opindex Wno-variadic-macros
10887 @item -Wvariadic-macros
10888 Warn if variadic macros are used in ISO C90 mode, or if the GNU
10889 alternate syntax is used in ISO C99 mode. This is enabled by either
10890 @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
10891 messages, use @option{-Wno-variadic-macros}.
10892
10893 @opindex Wvarargs
10894 @opindex Wno-varargs
10895 @item -Wno-varargs
10896 Do not warn upon questionable usage of the macros used to handle variable
10897 arguments like @code{va_start}. These warnings are enabled by default.
10898
10899 @opindex Wvector-operation-performance
10900 @opindex Wno-vector-operation-performance
10901 @item -Wvector-operation-performance
10902 Warn if vector operation is not implemented via SIMD capabilities of the
10903 architecture. Mainly useful for the performance tuning.
10904 Vector operation can be implemented @code{piecewise}, which means that the
10905 scalar operation is performed on every vector element;
10906 @code{in parallel}, which means that the vector operation is implemented
10907 using scalars of wider type, which normally is more performance efficient;
10908 and @code{as a single scalar}, which means that vector fits into a
10909 scalar type.
10910
10911 @opindex Wvla
10912 @opindex Wno-vla
10913 @item -Wvla
10914 Warn if a variable-length array is used in the code.
10915 @option{-Wno-vla} prevents the @option{-Wpedantic} warning of
10916 the variable-length array.
10917
10918 This warning is upgraded to an error by @option{-pedantic-errors}.
10919
10920 @opindex Wvla-larger-than=
10921 @opindex Wno-vla-larger-than
10922 @item -Wvla-larger-than=@var{byte-size}
10923 If this option is used, the compiler warns for declarations of
10924 variable-length arrays whose size is either unbounded, or bounded
10925 by an argument that allows the array size to exceed @var{byte-size}
10926 bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
10927 works, but with variable-length arrays.
10928
10929 Note that GCC may optimize small variable-length arrays of a known
10930 value into plain arrays, so this warning may not get triggered for
10931 such arrays.
10932
10933 @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
10934 is typically only effective when @option{-ftree-vrp} is active (default
10935 for @option{-O2} and above).
10936
10937 See also @option{-Walloca-larger-than=@var{byte-size}}.
10938
10939 @opindex Wno-vla-larger-than
10940 @item -Wno-vla-larger-than
10941 Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
10942 to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
10943
10944 @opindex Wno-vla-parameter
10945 @item -Wvla-parameter
10946 Warn about redeclarations of functions involving arguments of Variable
10947 Length Array types of inconsistent kinds or forms, and enable the detection
10948 of out-of-bounds accesses to such parameters by warnings such as
10949 @option{-Warray-bounds}.
10950
10951 If the first function declaration uses the VLA form the bound specified
10952 in the array is assumed to be the minimum number of elements expected to
10953 be provided in calls to the function and the maximum number of elements
10954 accessed by it. Failing to provide arguments of sufficient size or
10955 accessing more than the maximum number of elements may be diagnosed.
10956
10957 For example, the warning triggers for the following redeclarations because
10958 the first one allows an array of any size to be passed to @code{f} while
10959 the second one specifies that the array argument must have at least @code{n}
10960 elements. In addition, calling @code{f} with the associated VLA bound
10961 parameter in excess of the actual VLA bound triggers a warning as well.
10962
10963 @smallexample
10964 void f (int n, int[n]);
10965 // warning: argument 2 previously declared as a VLA
10966 void f (int, int[]);
10967
10968 void g (int n)
10969 @{
10970 if (n > 4)
10971 return;
10972 int a[n];
10973 // warning: access to a by f may be out of bounds
10974 f (sizeof a, a);
10975 @dots{}
10976 @}
10977
10978 @end smallexample
10979
10980 @option{-Wvla-parameter} is included in @option{-Wall}. The
10981 @option{-Warray-parameter} option triggers warnings for similar problems
10982 involving ordinary array arguments.
10983
10984 @opindex Wvolatile-register-var
10985 @opindex Wno-volatile-register-var
10986 @item -Wvolatile-register-var
10987 Warn if a register variable is declared volatile. The volatile
10988 modifier does not inhibit all optimizations that may eliminate reads
10989 and/or writes to register variables. This warning is enabled by
10990 @option{-Wall}.
10991
10992 @opindex Wxor-used-as-pow
10993 @opindex Wno-xor-used-as-pow
10994 @item -Wno-xor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
10995 Disable warnings about uses of @code{^}, the exclusive or operator,
10996 where it appears the code meant exponentiation.
10997 Specifically, the warning occurs when the
10998 left-hand side is the decimal constant 2 or 10 and the right-hand side
10999 is also a decimal constant.
11000
11001 In C and C++, @code{^} means exclusive or, whereas in some other languages
11002 (e.g. TeX and some versions of BASIC) it means exponentiation.
11003
11004 This warning can be silenced by converting one of the operands to
11005 hexadecimal as well as by compiling with @option{-Wno-xor-used-as-pow}.
11006
11007 @opindex Wdisabled-optimization
11008 @opindex Wno-disabled-optimization
11009 @item -Wdisabled-optimization
11010 Warn if a requested optimization pass is disabled. This warning does
11011 not generally indicate that there is anything wrong with your code; it
11012 merely indicates that GCC's optimizers are unable to handle the code
11013 effectively. Often, the problem is that your code is too big or too
11014 complex; GCC refuses to optimize programs when the optimization
11015 itself is likely to take inordinate amounts of time.
11016
11017 @opindex Wpointer-sign
11018 @opindex Wno-pointer-sign
11019 @item -Wpointer-sign @r{(C and Objective-C only)}
11020 Warn for pointer argument passing or assignment with different signedness.
11021 This option is only supported for C and Objective-C@. It is implied by
11022 @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
11023 @option{-Wno-pointer-sign}.
11024
11025 This warning is upgraded to an error by @option{-pedantic-errors}.
11026
11027 @opindex Wstack-protector
11028 @opindex Wno-stack-protector
11029 @item -Wstack-protector
11030 This option is only active when @option{-fstack-protector} is active. It
11031 warns about functions that are not protected against stack smashing.
11032
11033 @opindex Woverlength-strings
11034 @opindex Wno-overlength-strings
11035 @item -Woverlength-strings
11036 Warn about string constants that are longer than the ``minimum
11037 maximum'' length specified in the C standard. Modern compilers
11038 generally allow string constants that are much longer than the
11039 standard's minimum limit, but very portable programs should avoid
11040 using longer strings.
11041
11042 The limit applies @emph{after} string constant concatenation, and does
11043 not count the trailing NUL@. In C90, the limit was 509 characters; in
11044 C99, it was raised to 4095. C++98 does not specify a normative
11045 minimum maximum, so we do not diagnose overlength strings in C++@.
11046
11047 This option is implied by @option{-Wpedantic}, and can be disabled with
11048 @option{-Wno-overlength-strings}.
11049
11050 @opindex Wunsuffixed-float-constants
11051 @opindex Wno-unsuffixed-float-constants
11052 @item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
11053
11054 Issue a warning for any floating constant that does not have
11055 a suffix. When used together with @option{-Wsystem-headers} it
11056 warns about such constants in system header files. This can be useful
11057 when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
11058 from the decimal floating-point extension to C99.
11059
11060 @opindex Wlto-type-mismatch
11061 @opindex Wno-lto-type-mismatch
11062 @item -Wno-lto-type-mismatch
11063
11064 During the link-time optimization, do not warn about type mismatches in
11065 global declarations from different compilation units.
11066 Requires @option{-flto} to be enabled. Enabled by default.
11067
11068 @opindex Wdesignated-init
11069 @opindex Wno-designated-init
11070 @item -Wno-designated-init @r{(C and Objective-C only)}
11071 Suppress warnings when a positional initializer is used to initialize
11072 a structure that has been marked with the @code{designated_init}
11073 attribute.
11074
11075 @end table
11076
11077 @node Static Analyzer Options
11078 @section Options That Control Static Analysis
11079
11080 @table @gcctabopt
11081 @opindex analyzer
11082 @opindex fanalyzer
11083 @opindex fno-analyzer
11084 @item -fanalyzer
11085 This option enables an static analysis of program flow which looks
11086 for ``interesting'' interprocedural paths through the
11087 code, and issues warnings for problems found on them.
11088
11089 This analysis is much more expensive than other GCC warnings.
11090
11091 In technical terms, it performs coverage-guided symbolic execution of
11092 the code being compiled. It is neither sound nor complete: it can
11093 have false positives and false negatives. It is a bug-finding tool,
11094 rather than a tool for proving program correctness.
11095
11096 The analyzer is only suitable for use on C code in this release.
11097
11098 Enabling this option effectively enables the following warnings:
11099
11100 @gccoptlist{
11101 -Wanalyzer-allocation-size
11102 -Wanalyzer-deref-before-check
11103 -Wanalyzer-double-fclose
11104 -Wanalyzer-double-free
11105 -Wanalyzer-exposure-through-output-file
11106 -Wanalyzer-exposure-through-uninit-copy
11107 -Wanalyzer-fd-access-mode-mismatch
11108 -Wanalyzer-fd-double-close
11109 -Wanalyzer-fd-leak
11110 -Wanalyzer-fd-phase-mismatch
11111 -Wanalyzer-fd-type-mismatch
11112 -Wanalyzer-fd-use-after-close
11113 -Wanalyzer-fd-use-without-check
11114 -Wanalyzer-file-leak
11115 -Wanalyzer-free-of-non-heap
11116 -Wanalyzer-imprecise-fp-arithmetic
11117 -Wanalyzer-infinite-loop
11118 -Wanalyzer-infinite-recursion
11119 -Wanalyzer-jump-through-null
11120 -Wanalyzer-malloc-leak
11121 -Wanalyzer-mismatching-deallocation
11122 -Wanalyzer-null-argument
11123 -Wanalyzer-null-dereference
11124 -Wanalyzer-out-of-bounds
11125 -Wanalyzer-overlapping-buffers
11126 -Wanalyzer-possible-null-argument
11127 -Wanalyzer-possible-null-dereference
11128 -Wanalyzer-putenv-of-auto-var
11129 -Wanalyzer-shift-count-negative
11130 -Wanalyzer-shift-count-overflow
11131 -Wanalyzer-stale-setjmp-buffer
11132 -Wanalyzer-tainted-allocation-size
11133 -Wanalyzer-tainted-array-index
11134 -Wanalyzer-tainted-assertion
11135 -Wanalyzer-tainted-divisor
11136 -Wanalyzer-tainted-offset
11137 -Wanalyzer-tainted-size
11138 -Wanalyzer-throw-of-unexpected-type
11139 -Wanalyzer-undefined-behavior-ptrdiff
11140 -Wanalyzer-undefined-behavior-strtok
11141 -Wanalyzer-unsafe-call-within-signal-handler
11142 -Wanalyzer-use-after-free
11143 -Wanalyzer-use-of-pointer-in-stale-stack-frame
11144 -Wanalyzer-use-of-uninitialized-value
11145 -Wanalyzer-va-arg-type-mismatch
11146 -Wanalyzer-va-list-exhausted
11147 -Wanalyzer-va-list-leak
11148 -Wanalyzer-va-list-use-after-va-end
11149 -Wanalyzer-write-to-const
11150 -Wanalyzer-write-to-string-literal
11151 }
11152
11153 This option is only available if GCC was configured with analyzer
11154 support enabled.
11155
11156 @opindex Wanalyzer-symbol-too-complex
11157 @opindex Wno-analyzer-symbol-too-complex
11158 @item -Wanalyzer-symbol-too-complex
11159 If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
11160 to attempt to track the state of memory, but these can be defeated by
11161 sufficiently complicated code.
11162
11163 By default, the analysis silently stops tracking values of expressions
11164 if they exceed the threshold defined by
11165 @option{--param analyzer-max-svalue-depth=@var{value}}, and falls back
11166 to an imprecise representation for such expressions.
11167 The @option{-Wanalyzer-symbol-too-complex} option warns if this occurs.
11168
11169 @opindex Wanalyzer-too-complex
11170 @opindex Wno-analyzer-too-complex
11171 @item -Wanalyzer-too-complex
11172 If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
11173 to attempt to explore the control flow and data flow in the program,
11174 but these can be defeated by sufficiently complicated code.
11175
11176 By default, the analysis silently stops if the code is too
11177 complicated for the analyzer to fully explore and it reaches an internal
11178 limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
11179
11180 @opindex Wanalyzer-allocation-size
11181 @opindex Wno-analyzer-allocation-size
11182 @item -Wno-analyzer-allocation-size
11183 This warning requires @option{-fanalyzer}, which enables it;
11184 to disable it, use @option{-Wno-analyzer-allocation-size}.
11185
11186 This diagnostic warns for paths through the code in which a pointer to
11187 a buffer is assigned to point at a buffer with a size that is not a
11188 multiple of @code{sizeof (*pointer)}.
11189
11190 See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
11191
11192 @opindex Wanalyzer-deref-before-check
11193 @opindex Wno-analyzer-deref-before-check
11194 @item -Wno-analyzer-deref-before-check
11195 This warning requires @option{-fanalyzer}, which enables it; use
11196 @option{-Wno-analyzer-deref-before-check}
11197 to disable it.
11198
11199 This diagnostic warns for paths through the code in which a pointer
11200 is checked for @code{NULL} *after* it has already been
11201 dereferenced, suggesting that the pointer could have been NULL.
11202 Such cases suggest that the check for NULL is either redundant,
11203 or that it needs to be moved to before the pointer is dereferenced.
11204
11205 This diagnostic also considers values passed to a function argument
11206 marked with @code{__attribute__((nonnull))} as requiring a non-NULL
11207 value, and thus will complain if such values are checked for @code{NULL}
11208 after returning from such a function call.
11209
11210 This diagnostic is unlikely to be reported when any level of optimization
11211 is enabled, as GCC's optimization logic will typically consider such
11212 checks for NULL as being redundant, and optimize them away before the
11213 analyzer "sees" them. Hence optimization should be disabled when
11214 attempting to trigger this diagnostic.
11215
11216 @opindex Wanalyzer-double-fclose
11217 @opindex Wno-analyzer-double-fclose
11218 @item -Wno-analyzer-double-fclose
11219 This warning requires @option{-fanalyzer}, which enables it; use
11220 @option{-Wno-analyzer-double-fclose} to disable it.
11221
11222 This diagnostic warns for paths through the code in which a @code{FILE *}
11223 can have @code{fclose} called on it more than once.
11224
11225 See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
11226
11227 @opindex Wanalyzer-double-free
11228 @opindex Wno-analyzer-double-free
11229 @item -Wno-analyzer-double-free
11230 This warning requires @option{-fanalyzer}, which enables it; use
11231 @option{-Wno-analyzer-double-free} to disable it.
11232
11233 This diagnostic warns for paths through the code in which a pointer
11234 can have a deallocator called on it more than once, either @code{free},
11235 or a deallocator referenced by attribute @code{malloc}.
11236
11237 See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
11238
11239 @opindex Wanalyzer-exposure-through-output-file
11240 @opindex Wno-analyzer-exposure-through-output-file
11241 @item -Wno-analyzer-exposure-through-output-file
11242 This warning requires @option{-fanalyzer}, which enables it; use
11243 @option{-Wno-analyzer-exposure-through-output-file}
11244 to disable it.
11245
11246 This diagnostic warns for paths through the code in which a
11247 security-sensitive value is written to an output file
11248 (such as writing a password to a log file).
11249
11250 See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
11251
11252 @opindex Wanalyzer-exposure-through-uninit-copy
11253 @opindex Wno-analyzer-exposure-through-uninit-copy
11254 @item -Wanalyzer-exposure-through-uninit-copy
11255 This warning requires both @option{-fanalyzer} and the use of a plugin
11256 to specify a function that copies across a ``trust boundary''. Use
11257 @option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
11258
11259 This diagnostic warns for ``infoleaks'' - paths through the code in which
11260 uninitialized values are copied across a security boundary
11261 (such as code within an OS kernel that copies a partially-initialized
11262 struct on the stack to user space).
11263
11264 See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
11265
11266 @opindex Wanalyzer-fd-access-mode-mismatch
11267 @opindex Wno-analyzer-fd-access-mode-mismatch
11268 @item -Wno-analyzer-fd-access-mode-mismatch
11269 This warning requires @option{-fanalyzer}, which enables it; use
11270 @option{-Wno-analyzer-fd-access-mode-mismatch}
11271 to disable it.
11272
11273 This diagnostic warns for paths through code in which a
11274 @code{read} on a write-only file descriptor is attempted, or vice versa.
11275
11276 This diagnostic also warns for code paths in a which a function with attribute
11277 @code{fd_arg_read (N)} is called with a file descriptor opened with
11278 @code{O_WRONLY} at referenced argument @code{N} or a function with attribute
11279 @code{fd_arg_write (N)} is called with a file descriptor opened with
11280 @code{O_RDONLY} at referenced argument @var{N}.
11281
11282 @opindex Wanalyzer-fd-double-close
11283 @opindex Wno-analyzer-fd-double-close
11284 @item -Wno-analyzer-fd-double-close
11285 This warning requires @option{-fanalyzer}, which enables it; use
11286 @option{-Wno-analyzer-fd-double-close}
11287 to disable it.
11288
11289 This diagnostic warns for paths through code in which a
11290 file descriptor can be closed more than once.
11291
11292 See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
11293
11294 @opindex Wanalyzer-fd-leak
11295 @opindex Wno-analyzer-fd-leak
11296 @item -Wno-analyzer-fd-leak
11297 This warning requires @option{-fanalyzer}, which enables it; use
11298 @option{-Wno-analyzer-fd-leak}
11299 to disable it.
11300
11301 This diagnostic warns for paths through code in which an
11302 open file descriptor is leaked.
11303
11304 See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
11305
11306 @opindex Wanalyzer-fd-phase-mismatch
11307 @opindex Wno-analyzer-fd-phase-mismatch
11308 @item -Wno-analyzer-fd-phase-mismatch
11309 This warning requires @option{-fanalyzer}, which enables it; use
11310 @option{-Wno-analyzer-fd-phase-mismatch}
11311 to disable it.
11312
11313 This diagnostic warns for paths through code in which an operation is
11314 attempted in the wrong phase of a file descriptor's lifetime.
11315 For example, it will warn on attempts to call @code{accept} on a stream
11316 socket that has not yet had @code{listen} successfully called on it.
11317
11318 See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
11319
11320 @opindex Wanalyzer-fd-type-mismatch
11321 @opindex Wno-analyzer-fd-type-mismatch
11322 @item -Wno-analyzer-fd-type-mismatch
11323 This warning requires @option{-fanalyzer}, which enables it; use
11324 @option{-Wno-analyzer-fd-type-mismatch}
11325 to disable it.
11326
11327 This diagnostic warns for paths through code in which an
11328 operation is attempted on the wrong type of file descriptor.
11329 For example, it will warn on attempts to use socket operations
11330 on a file descriptor obtained via @code{open}, or when attempting
11331 to use a stream socket operation on a datagram socket.
11332
11333 @opindex Wanalyzer-fd-use-after-close
11334 @opindex Wno-analyzer-fd-use-after-close
11335 @item -Wno-analyzer-fd-use-after-close
11336 This warning requires @option{-fanalyzer}, which enables it; use
11337 @option{-Wno-analyzer-fd-use-after-close}
11338 to disable it.
11339
11340 This diagnostic warns for paths through code in which a
11341 read or write is called on a closed file descriptor.
11342
11343 This diagnostic also warns for paths through code in which
11344 a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
11345 or @code{fd_arg_write (N)} is called with a closed file descriptor at
11346 referenced argument @code{N}.
11347
11348 @opindex Wanalyzer-fd-use-without-check
11349 @opindex Wno-analyzer-fd-use-without-check
11350 @item -Wno-analyzer-fd-use-without-check
11351 This warning requires @option{-fanalyzer}, which enables it; use
11352 @option{-Wno-analyzer-fd-use-without-check}
11353 to disable it.
11354
11355 This diagnostic warns for paths through code in which a
11356 file descriptor is used without being checked for validity.
11357
11358 This diagnostic also warns for paths through code in which
11359 a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
11360 or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
11361 argument @code{N}, without being checked for validity.
11362
11363 @opindex Wanalyzer-file-leak
11364 @opindex Wno-analyzer-file-leak
11365 @item -Wno-analyzer-file-leak
11366 This warning requires @option{-fanalyzer}, which enables it; use
11367 @option{-Wno-analyzer-file-leak}
11368 to disable it.
11369
11370 This diagnostic warns for paths through the code in which a
11371 @code{<stdio.h>} @code{FILE *} stream object is leaked.
11372
11373 See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
11374
11375 @opindex Wanalyzer-free-of-non-heap
11376 @opindex Wno-analyzer-free-of-non-heap
11377 @item -Wno-analyzer-free-of-non-heap
11378 This warning requires @option{-fanalyzer}, which enables it; use
11379 @option{-Wno-analyzer-free-of-non-heap}
11380 to disable it.
11381
11382 This diagnostic warns for paths through the code in which @code{free}
11383 is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
11384
11385 See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
11386
11387 @opindex Wanalyzer-imprecise-fp-arithmetic
11388 @opindex Wno-analyzer-imprecise-fp-arithmetic
11389 @item -Wno-analyzer-imprecise-fp-arithmetic
11390 This warning requires @option{-fanalyzer}, which enables it; use
11391 @option{-Wno-analyzer-imprecise-fp-arithmetic}
11392 to disable it.
11393
11394 This diagnostic warns for paths through the code in which floating-point
11395 arithmetic is used in locations where precise computation is needed. This
11396 diagnostic only warns on use of floating-point operands inside the
11397 calculation of an allocation size at the moment.
11398
11399 @opindex Wanalyzer-infinite-loop
11400 @opindex Wno-analyzer-infinite-loop
11401 @item -Wno-analyzer-infinite-loop
11402 This warning requires @option{-fanalyzer}, which enables it; use
11403 @option{-Wno-analyzer-infinite-loop} to disable it.
11404
11405 This diagnostics warns for paths through the code which appear to
11406 lead to an infinite loop.
11407
11408 Specifically, the analyzer will issue this warning when it "sees" a loop
11409 in which:
11410 @itemize @bullet
11411 @item
11412 no externally-visible work could be being done within the loop
11413 @item
11414 there is no way to escape from the loop
11415 @item
11416 the analyzer is sufficiently confident about the program state
11417 throughout the loop to know that the above are true
11418 @end itemize
11419
11420 One way for this warning to be emitted is when there is an execution
11421 path through a loop for which taking the path on one iteration implies
11422 that the same path will be taken on all subsequent iterations.
11423
11424 For example, consider:
11425
11426 @smallexample
11427 while (1)
11428 @{
11429 char opcode = *cpu_state.pc;
11430 switch (opcode)
11431 @{
11432 case OPCODE_FOO:
11433 handle_opcode_foo (&cpu_state);
11434 break;
11435 case OPCODE_BAR:
11436 handle_opcode_bar (&cpu_state);
11437 break;
11438 @}
11439 @}
11440 @end smallexample
11441
11442 The analyzer will complain for the above case because if @code{opcode}
11443 ever matches none of the cases, the @code{switch} will follow the
11444 implicit @code{default} case, making the body of the loop be a ``no-op''
11445 with @code{cpu_state.pc} unchanged, and thus using the same value of
11446 @code{opcode} on all subseqent iterations, leading to an infinite loop.
11447
11448 See @uref{https://cwe.mitre.org/data/definitions/835.html, CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')}.
11449
11450 @opindex Wanalyzer-infinite-recursion
11451 @opindex Wno-analyzer-infinite-recursion
11452 @item -Wno-analyzer-infinite-recursion
11453 This warning requires @option{-fanalyzer}, which enables it; use
11454 @option{-Wno-analyzer-infinite-recursion} to disable it.
11455
11456 This diagnostics warns for paths through the code which appear to
11457 lead to infinite recursion.
11458
11459 Specifically, when the analyzer "sees" a recursive call, it will compare
11460 the state of memory at the entry to the new frame with that at the entry
11461 to the previous frame of that function on the stack. The warning is
11462 issued if nothing in memory appears to be changing; any changes observed
11463 to parameters or globals are assumed to lead to termination of the
11464 recursion and thus suppress the warning.
11465
11466 This diagnostic is likely to miss cases of infinite recursion that
11467 are convered to iteration by the optimizer before the analyzer "sees"
11468 them. Hence optimization should be disabled when attempting to trigger
11469 this diagnostic.
11470
11471 Compare with @option{-Winfinite-recursion}, which provides a similar
11472 diagnostic, but is implemented in a different way.
11473
11474 See @uref{https://cwe.mitre.org/data/definitions/674.html, CWE-674: Uncontrolled Recursion}.
11475
11476 @opindex Wanalyzer-jump-through-null
11477 @opindex Wno-analyzer-jump-through-null
11478 @item -Wno-analyzer-jump-through-null
11479 This warning requires @option{-fanalyzer}, which enables it; use
11480 @option{-Wno-analyzer-jump-through-null}
11481 to disable it.
11482
11483 This diagnostic warns for paths through the code in which a @code{NULL}
11484 function pointer is called.
11485
11486 @opindex Wanalyzer-malloc-leak
11487 @opindex Wno-analyzer-malloc-leak
11488 @item -Wno-analyzer-malloc-leak
11489 This warning requires @option{-fanalyzer}, which enables it; use
11490 @option{-Wno-analyzer-malloc-leak}
11491 to disable it.
11492
11493 This diagnostic warns for paths through the code in which a
11494 pointer allocated via an allocator is leaked: either @code{malloc},
11495 or a function marked with attribute @code{malloc}.
11496
11497 See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
11498
11499 @opindex Wanalyzer-mismatching-deallocation
11500 @opindex Wno-analyzer-mismatching-deallocation
11501 @item -Wno-analyzer-mismatching-deallocation
11502 This warning requires @option{-fanalyzer}, which enables it; use
11503 @option{-Wno-analyzer-mismatching-deallocation}
11504 to disable it.
11505
11506 This diagnostic warns for paths through the code in which the
11507 wrong deallocation function is called on a pointer value, based on
11508 which function was used to allocate the pointer value. The diagnostic
11509 will warn about mismatches between @code{free}, scalar @code{delete}
11510 and vector @code{delete[]}, and those marked as allocator/deallocator
11511 pairs using attribute @code{malloc}.
11512
11513 See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
11514
11515 @opindex Wanalyzer-out-of-bounds
11516 @opindex Wno-analyzer-out-of-bounds
11517 @item -Wno-analyzer-out-of-bounds
11518 This warning requires @option{-fanalyzer}, which enables it; use
11519 @option{-Wno-analyzer-out-of-bounds} to disable it.
11520
11521 This diagnostic warns for paths through the code in which a buffer is
11522 definitely read or written out-of-bounds. The diagnostic applies for
11523 cases where the analyzer is able to determine a constant offset and for
11524 accesses past the end of a buffer, also a constant capacity. Further,
11525 the diagnostic does limited checking for accesses past the end when the
11526 offset as well as the capacity is symbolic.
11527
11528 See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
11529
11530 For cases where the analyzer is able, it will emit a text art diagram
11531 visualizing the spatial relationship between the memory region that the
11532 analyzer predicts would be accessed, versus the range of memory that is
11533 valid to access: whether they overlap, are touching, are close or far
11534 apart; which one is before or after in memory, the relative sizes
11535 involved, the direction of the access (read vs write), and, in some
11536 cases, the values of data involved. This diagram can be suppressed
11537 using @option{-fdiagnostics-text-art-charset=none}.
11538
11539 @opindex Wanalyzer-overlapping-buffers
11540 @opindex Wno-analyzer-overlapping-buffers
11541 @item -Wno-analyzer-overlapping-buffers
11542 This warning requires @option{-fanalyzer}, which enables it; use
11543 @option{-Wno-analyzer-overlapping-buffers} to disable it.
11544
11545 This diagnostic warns for paths through the code in which overlapping
11546 buffers are passed to an API for which the behavior on such buffers
11547 is undefined.
11548
11549 Specifically, the diagnostic occurs on calls to the following functions
11550 @itemize @bullet
11551 @item @code{memcpy}
11552 @item @code{strcat}
11553 @item @code{strcpy}
11554 @end itemize
11555 for cases where the buffers are known to overlap.
11556
11557 @opindex Wanalyzer-possible-null-argument
11558 @opindex Wno-analyzer-possible-null-argument
11559 @item -Wno-analyzer-possible-null-argument
11560 This warning requires @option{-fanalyzer}, which enables it; use
11561 @option{-Wno-analyzer-possible-null-argument} to disable it.
11562
11563 This diagnostic warns for paths through the code in which a
11564 possibly-NULL value is passed to a function argument marked
11565 with @code{__attribute__((nonnull))} as requiring a non-NULL
11566 value.
11567
11568 See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
11569
11570 @opindex Wanalyzer-possible-null-dereference
11571 @opindex Wno-analyzer-possible-null-dereference
11572 @item -Wno-analyzer-possible-null-dereference
11573 This warning requires @option{-fanalyzer}, which enables it; use
11574 @option{-Wno-analyzer-possible-null-dereference} to disable it.
11575
11576 This diagnostic warns for paths through the code in which a
11577 possibly-NULL value is dereferenced.
11578
11579 See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
11580
11581 @opindex Wanalyzer-null-argument
11582 @opindex Wno-analyzer-null-argument
11583 @item -Wno-analyzer-null-argument
11584 This warning requires @option{-fanalyzer}, which enables it; use
11585 @option{-Wno-analyzer-null-argument} to disable it.
11586
11587 This diagnostic warns for paths through the code in which a
11588 value known to be NULL is passed to a function argument marked
11589 with @code{__attribute__((nonnull))} as requiring a non-NULL
11590 value.
11591
11592 See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
11593
11594 @opindex Wanalyzer-null-dereference
11595 @opindex Wno-analyzer-null-dereference
11596 @item -Wno-analyzer-null-dereference
11597 This warning requires @option{-fanalyzer}, which enables it; use
11598 @option{-Wno-analyzer-null-dereference} to disable it.
11599
11600 This diagnostic warns for paths through the code in which a
11601 value known to be NULL is dereferenced.
11602
11603 See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
11604
11605 @opindex Wanalyzer-putenv-of-auto-var
11606 @opindex Wno-analyzer-putenv-of-auto-var
11607 @item -Wno-analyzer-putenv-of-auto-var
11608 This warning requires @option{-fanalyzer}, which enables it; use
11609 @option{-Wno-analyzer-putenv-of-auto-var} to disable it.
11610
11611 This diagnostic warns for paths through the code in which a
11612 call to @code{putenv} is passed a pointer to an automatic variable
11613 or an on-stack buffer.
11614
11615 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}.
11616
11617 @opindex Wanalyzer-shift-count-negative
11618 @opindex Wno-analyzer-shift-count-negative
11619 @item -Wno-analyzer-shift-count-negative
11620 This warning requires @option{-fanalyzer}, which enables it; use
11621 @option{-Wno-analyzer-shift-count-negative} to disable it.
11622
11623 This diagnostic warns for paths through the code in which a
11624 shift is attempted with a negative count. It is analogous to
11625 the @option{-Wshift-count-negative} diagnostic implemented in
11626 the C/C++ front ends, but is implemented based on analyzing
11627 interprocedural paths, rather than merely parsing the syntax tree.
11628 However, the analyzer does not prioritize detection of such paths, so
11629 false negatives are more likely relative to other warnings.
11630
11631 @opindex Wanalyzer-shift-count-overflow
11632 @opindex Wno-analyzer-shift-count-overflow
11633 @item -Wno-analyzer-shift-count-overflow
11634 This warning requires @option{-fanalyzer}, which enables it; use
11635 @option{-Wno-analyzer-shift-count-overflow} to disable it.
11636
11637 This diagnostic warns for paths through the code in which a
11638 shift is attempted with a count greater than or equal to the
11639 precision of the operand's type. It is analogous to
11640 the @option{-Wshift-count-overflow} diagnostic implemented in
11641 the C/C++ front ends, but is implemented based on analyzing
11642 interprocedural paths, rather than merely parsing the syntax tree.
11643 However, the analyzer does not prioritize detection of such paths, so
11644 false negatives are more likely relative to other warnings.
11645
11646 @opindex Wanalyzer-stale-setjmp-buffer
11647 @opindex Wno-analyzer-stale-setjmp-buffer
11648 @item -Wno-analyzer-stale-setjmp-buffer
11649 This warning requires @option{-fanalyzer}, which enables it; use
11650 @option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
11651
11652 This diagnostic warns for paths through the code in which
11653 @code{longjmp} is called to rewind to a @code{jmp_buf} relating
11654 to a @code{setjmp} call in a function that has returned.
11655
11656 When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
11657 location, it records the stack frame. The stack frame becomes invalid
11658 when the function containing the @code{setjmp} call returns. Attempting
11659 to rewind to it via @code{longjmp} would reference a stack frame that
11660 no longer exists, and likely lead to a crash (or worse).
11661
11662 @opindex Wanalyzer-tainted-allocation-size
11663 @opindex Wno-analyzer-tainted-allocation-size
11664 @item -Wno-analyzer-tainted-allocation-size
11665 This warning requires @option{-fanalyzer} which enables it;
11666 use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
11667
11668 This diagnostic warns for paths through the code in which a value
11669 that could be under an attacker's control is used as the size
11670 of an allocation without being sanitized, so that an attacker could
11671 inject an excessively large allocation and potentially cause a denial
11672 of service attack.
11673
11674 See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
11675
11676 @opindex Wanalyzer-tainted-assertion
11677 @opindex Wno-analyzer-tainted-assertion
11678 @item -Wno-analyzer-tainted-assertion
11679
11680 This warning requires @option{-fanalyzer} which enables it;
11681 use @option{-Wno-analyzer-tainted-assertion} to disable it.
11682
11683 This diagnostic warns for paths through the code in which a value
11684 that could be under an attacker's control is used as part of a
11685 condition without being first sanitized, and that condition guards a
11686 call to a function marked with attribute @code{noreturn}
11687 (such as the function @code{__builtin_unreachable}). Such functions
11688 typically indicate abnormal termination of the program, such as for
11689 assertion failure handlers. For example:
11690
11691 @smallexample
11692 assert (some_tainted_value < SOME_LIMIT);
11693 @end smallexample
11694
11695 In such cases:
11696
11697 @itemize
11698 @item
11699 when assertion-checking is enabled: an attacker could trigger
11700 a denial of service by injecting an assertion failure
11701
11702 @item
11703 when assertion-checking is disabled, such as by defining @code{NDEBUG},
11704 an attacker could inject data that subverts the process, since it
11705 presumably violates a precondition that is being assumed by the code.
11706
11707 @end itemize
11708
11709 Note that when assertion-checking is disabled, the assertions are
11710 typically removed by the preprocessor before the analyzer has a chance
11711 to "see" them, so this diagnostic can only generate warnings on builds
11712 in which assertion-checking is enabled.
11713
11714 For the purpose of this warning, any function marked with attribute
11715 @code{noreturn} is considered as a possible assertion failure
11716 handler, including @code{__builtin_unreachable}. Note that these functions
11717 are sometimes removed by the optimizer before the analyzer "sees" them.
11718 Hence optimization should be disabled when attempting to trigger this
11719 diagnostic.
11720
11721 See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
11722
11723 The warning can also report problematic constructions such as
11724
11725 @smallexample
11726 switch (some_tainted_value) @{
11727 case 0:
11728 /* [...etc; various valid cases omitted...] */
11729 break;
11730
11731 default:
11732 __builtin_unreachable (); /* BUG: attacker can trigger this */
11733 @}
11734 @end smallexample
11735
11736 despite the above not being an assertion failure, strictly speaking.
11737
11738 @opindex Wanalyzer-tainted-array-index
11739 @opindex Wno-analyzer-tainted-array-index
11740 @item -Wno-analyzer-tainted-array-index
11741 This warning requires @option{-fanalyzer} which enables it;
11742 use @option{-Wno-analyzer-tainted-array-index} to disable it.
11743
11744 This diagnostic warns for paths through the code in which a value
11745 that could be under an attacker's control is used as the index
11746 of an array access without being sanitized, so that an attacker
11747 could inject an out-of-bounds access.
11748
11749 See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11750
11751 @opindex Wanalyzer-tainted-divisor
11752 @opindex Wno-analyzer-tainted-divisor
11753 @item -Wno-analyzer-tainted-divisor
11754 This warning requires @option{-fanalyzer} which enables it;
11755 use @option{-Wno-analyzer-tainted-divisor} to disable it.
11756
11757 This diagnostic warns for paths through the code in which a value
11758 that could be under an attacker's control is used as the divisor
11759 in a division or modulus operation without being sanitized, so that
11760 an attacker could inject a division-by-zero.
11761
11762 See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
11763
11764 @opindex Wanalyzer-tainted-offset
11765 @opindex Wno-analyzer-tainted-offset
11766 @item -Wno-analyzer-tainted-offset
11767 This warning requires @option{-fanalyzer} which enables it;
11768 use @option{-Wno-analyzer-tainted-offset} to disable it.
11769
11770 This diagnostic warns for paths through the code in which a value
11771 that could be under an attacker's control is used as a pointer offset
11772 without being sanitized, so that an attacker could inject an out-of-bounds
11773 access.
11774
11775 See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
11776
11777 @opindex Wanalyzer-tainted-size
11778 @opindex Wno-analyzer-tainted-size
11779 @item -Wno-analyzer-tainted-size
11780 This warning requires @option{-fanalyzer} which enables it;
11781 use @option{-Wno-analyzer-tainted-size} to disable it.
11782
11783 This diagnostic warns for paths through the code in which a value
11784 that could be under an attacker's control is used as the size of
11785 an operation such as @code{memset} without being sanitized, so that an
11786 attacker could inject an out-of-bounds access.
11787
11788 See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11789
11790 @opindex Wanalyzer-throw-of-unexpected-type
11791 @opindex Wno-analyzer-throw-of-unexpected-type
11792 @item -Wno-analyzer-throw-of-unexpected-type
11793 This warning requires @option{-fanalyzer} which enables it;
11794 use @option{-Wno-analyzer-throw-of-unexpected-type} to disable it.
11795 Dynamic exception specifications are only available in C++14 and earlier.
11796
11797 This diagnostic warns for paths through the code in which a an exception
11798 is thrown from a function with a dynamic exception specification where
11799 the exception does not comply with the specification.
11800
11801 @opindex Wanalyzer-undefined-behavior-ptrdiff
11802 @opindex Wno-analyzer-undefined-behavior-ptrdiff
11803 @item -Wno-analyzer-undefined-behavior-ptrdiff
11804 This warning requires @option{-fanalyzer}, which enables it; use
11805 @option{-Wno-analyzer-undefined-behavior-ptrdiff} to disable it.
11806
11807 This diagnostic warns for paths through the code in which a pointer
11808 subtraction occurs where the pointers refer to different chunks of
11809 memory. Such code relies on undefined behavior, as pointer subtraction
11810 is only defined for cases where both pointers point to within (or just
11811 after) the same array.
11812
11813 See @uref{https://cwe.mitre.org/data/definitions/469.html, CWE-469: Use of Pointer Subtraction to Determine Size}.
11814
11815 @opindex Wanalyzer-undefined-behavior-strtok
11816 @opindex Wno-analyzer-undefined-behavior-strtok
11817 @item -Wno-analyzer-undefined-behavior-strtok
11818 This warning requires @option{-fanalyzer}, which enables it; use
11819 @option{-Wno-analyzer-undefined-behavior-strtok} to disable it.
11820
11821 This diagnostic warns for paths through the code in which a
11822 call is made to @code{strtok} with undefined behavior.
11823
11824 Specifically, passing NULL as the first parameter for the initial
11825 call to @code{strtok} within a process has undefined behavior.
11826
11827 @opindex Wanalyzer-unsafe-call-within-signal-handler
11828 @opindex Wno-analyzer-unsafe-call-within-signal-handler
11829 @item -Wno-analyzer-unsafe-call-within-signal-handler
11830 This warning requires @option{-fanalyzer}, which enables it; use
11831 @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
11832
11833 This diagnostic warns for paths through the code in which a
11834 function known to be async-signal-unsafe (such as @code{fprintf}) is
11835 called from a signal handler.
11836
11837 See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
11838
11839 @opindex Wanalyzer-use-after-free
11840 @opindex Wno-analyzer-use-after-free
11841 @item -Wno-analyzer-use-after-free
11842 This warning requires @option{-fanalyzer}, which enables it; use
11843 @option{-Wno-analyzer-use-after-free} to disable it.
11844
11845 This diagnostic warns for paths through the code in which a
11846 pointer is used after a deallocator is called on it: either @code{free},
11847 or a deallocator referenced by attribute @code{malloc}.
11848
11849 See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
11850
11851 @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
11852 @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
11853 @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
11854 This warning requires @option{-fanalyzer}, which enables it; use
11855 @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
11856 to disable it.
11857
11858 This diagnostic warns for paths through the code in which a pointer
11859 is dereferenced that points to a variable in a stale stack frame.
11860
11861 @opindex Wanalyzer-va-arg-type-mismatch
11862 @opindex Wno-analyzer-va-arg-type-mismatch
11863 @item -Wno-analyzer-va-arg-type-mismatch
11864 This warning requires @option{-fanalyzer}, which enables it; use
11865 @option{-Wno-analyzer-va-arg-type-mismatch}
11866 to disable it.
11867
11868 This diagnostic warns for interprocedural paths through the code for which
11869 the analyzer detects an attempt to use @code{va_arg} to extract a value
11870 passed to a variadic call, but uses a type that does not match that of
11871 the expression passed to the call.
11872
11873 See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
11874
11875 @opindex Wanalyzer-va-list-exhausted
11876 @opindex Wno-analyzer-va-list-exhausted
11877 @item -Wno-analyzer-va-list-exhausted
11878 This warning requires @option{-fanalyzer}, which enables it; use
11879 @option{-Wno-analyzer-va-list-exhausted}
11880 to disable it.
11881
11882 This diagnostic warns for interprocedural paths through the code for which
11883 the analyzer detects an attempt to use @code{va_arg} to access the next
11884 value passed to a variadic call, but all of the values in the
11885 @code{va_list} have already been consumed.
11886
11887 See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
11888
11889 @opindex Wanalyzer-va-list-leak
11890 @opindex Wno-analyzer-va-list-leak
11891 @item -Wno-analyzer-va-list-leak
11892 This warning requires @option{-fanalyzer}, which enables it; use
11893 @option{-Wno-analyzer-va-list-leak}
11894 to disable it.
11895
11896 This diagnostic warns for interprocedural paths through the code for which
11897 the analyzer detects that @code{va_start} or @code{va_copy} has been called
11898 on a @code{va_list} without a corresponding call to @code{va_end}.
11899
11900 @opindex Wanalyzer-va-list-use-after-va-end
11901 @opindex Wno-analyzer-va-list-use-after-va-end
11902 @item -Wno-analyzer-va-list-use-after-va-end
11903 This warning requires @option{-fanalyzer}, which enables it; use
11904 @option{-Wno-analyzer-va-list-use-after-va-end}
11905 to disable it.
11906
11907 This diagnostic warns for interprocedural paths through the code for which
11908 the analyzer detects an attempt to use a @code{va_list} after
11909 @code{va_end} has been called on it.
11910 @code{va_list}.
11911
11912 @opindex Wanalyzer-write-to-const
11913 @opindex Wno-analyzer-write-to-const
11914 @item -Wno-analyzer-write-to-const
11915 This warning requires @option{-fanalyzer}, which enables it; use
11916 @option{-Wno-analyzer-write-to-const}
11917 to disable it.
11918
11919 This diagnostic warns for paths through the code in which the analyzer
11920 detects an attempt to write through a pointer to a @code{const} object.
11921 However, the analyzer does not prioritize detection of such paths, so
11922 false negatives are more likely relative to other warnings.
11923
11924 @opindex Wanalyzer-write-to-string-literal
11925 @opindex Wno-analyzer-write-to-string-literal
11926 @item -Wno-analyzer-write-to-string-literal
11927 This warning requires @option{-fanalyzer}, which enables it; use
11928 @option{-Wno-analyzer-write-to-string-literal}
11929 to disable it.
11930
11931 This diagnostic warns for paths through the code in which the analyzer
11932 detects an attempt to write through a pointer to a string literal.
11933 However, the analyzer does not prioritize detection of such paths, so
11934 false negatives are more likely relative to other warnings.
11935
11936 @opindex Wanalyzer-use-of-uninitialized-value
11937 @opindex Wno-analyzer-use-of-uninitialized-value
11938 @item -Wno-analyzer-use-of-uninitialized-value
11939 This warning requires @option{-fanalyzer}, which enables it; use
11940 @option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
11941
11942 This diagnostic warns for paths through the code in which an uninitialized
11943 value is used.
11944
11945 See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
11946
11947 @end table
11948
11949 The analyzer has hardcoded knowledge about the behavior of the following
11950 memory-management functions:
11951
11952 @itemize @bullet
11953 @item @code{alloca}
11954 @item The built-in functions @code{__builtin_alloc},
11955 @code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
11956 @code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
11957 @code{__builtin_memcpy_chk}, @code{__builtin_memset},
11958 @code{__builtin_memset_chk}, @code{__builtin_realloc},
11959 @code{__builtin_stack_restore}, and @code{__builtin_stack_save}
11960 @item @code{calloc}
11961 @item @code{free}
11962 @item @code{malloc}
11963 @item @code{memset}
11964 @item @code{operator delete}
11965 @item @code{operator delete []}
11966 @item @code{operator new}
11967 @item @code{operator new []}
11968 @item @code{realloc}
11969 @item @code{strdup}
11970 @item @code{strndup}
11971 @end itemize
11972
11973 @noindent
11974 of the following functions for working with file descriptors:
11975
11976 @itemize @bullet
11977 @item @code{open}
11978 @item @code{close}
11979 @item @code{creat}
11980 @item @code{dup}, @code{dup2} and @code{dup3}
11981 @item @code{isatty}
11982 @item @code{pipe}, and @code{pipe2}
11983 @item @code{read}
11984 @item @code{write}
11985 @item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
11986 @end itemize
11987
11988 @noindent
11989 of the following functions for working with @code{<stdio.h>} streams:
11990 @itemize @bullet
11991 @item The built-in functions @code{__builtin_fprintf},
11992 @code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
11993 @code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
11994 @code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
11995 @code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
11996 @code{__builtin_printf_unlocked}, @code{__builtin_putc},
11997 @code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
11998 @code{__builtin_putc_unlocked}, @code{__builtin_puts},
11999 @code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
12000 @code{__builtin_vprintf}
12001 @item @code{fopen}
12002 @item @code{fclose}
12003 @item @code{ferror}
12004 @item @code{fgets}
12005 @item @code{fgets_unlocked}
12006 @item @code{fileno}
12007 @item @code{fread}
12008 @item @code{getc}
12009 @item @code{getchar}
12010 @item @code{fprintf}
12011 @item @code{printf}
12012 @item @code{fwrite}
12013 @end itemize
12014
12015 @noindent
12016 and of the following functions:
12017
12018 @itemize @bullet
12019 @item The built-in functions @code{__builtin_expect},
12020 @code{__builtin_expect_with_probability}, @code{__builtin_strchr},
12021 @code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
12022 @code{__builtin_strlen}, @code{__builtin_va_copy}, and
12023 @code{__builtin_va_start}
12024 @item The GNU extensions @code{error} and @code{error_at_line}
12025 @item @code{getpass}
12026 @item @code{longjmp}
12027 @item @code{putenv}
12028 @item @code{setjmp}
12029 @item @code{siglongjmp}
12030 @item @code{signal}
12031 @item @code{sigsetjmp}
12032 @item @code{strcat}
12033 @item @code{strchr}
12034 @item @code{strlen}
12035 @end itemize
12036
12037 In addition, various functions with an @code{__analyzer_} prefix have
12038 special meaning to the analyzer, described in the GCC Internals manual.
12039
12040 Pertinent parameters for controlling the exploration are:
12041 @itemize @bullet
12042 @item @option{--param analyzer-bb-explosion-factor=@var{value}}
12043 @item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
12044 @item @option{--param analyzer-max-recursion-depth=@var{value}}
12045 @item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
12046 @end itemize
12047
12048 The following options control the analyzer.
12049
12050 @table @gcctabopt
12051
12052 @opindex fanalyzer-call-summaries
12053 @opindex fno-analyzer-call-summaries
12054 @item -fanalyzer-call-summaries
12055 Simplify interprocedural analysis by computing the effect of certain calls,
12056 rather than exploring all paths through the function from callsite to each
12057 possible return.
12058
12059 If enabled, call summaries are only used for functions with more than one
12060 call site, and that are sufficiently complicated (as per
12061 @option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
12062
12063 @opindex fanalyzer-checker
12064 @item -fanalyzer-checker=@var{name}
12065 Restrict the analyzer to run just the named checker, and enable it.
12066
12067 @opindex fanalyzer-debug-text-art
12068 @opindex fno-analyzer-debug-text-art
12069 @item -fanalyzer-debug-text-art-headings
12070 This option is intended for analyzer developers. If enabled,
12071 the analyzer will add extra annotations to any diagrams it generates.
12072
12073 @opindex fanalyzer-feasibility
12074 @opindex fno-analyzer-feasibility
12075 @item -fno-analyzer-feasibility
12076 This option is intended for analyzer developers.
12077
12078 By default the analyzer verifies that there is a feasible control flow path
12079 for each diagnostic it emits: that the conditions that hold are not mutually
12080 exclusive. Diagnostics for which no feasible path can be found are rejected.
12081 This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
12082 debugging issues in this code.
12083
12084 @opindex fanalyzer-fine-grained
12085 @opindex fno-analyzer-fine-grained
12086 @item -fanalyzer-fine-grained
12087 This option is intended for analyzer developers.
12088
12089 Internally the analyzer builds an ``exploded graph'' that combines
12090 control flow graphs with data flow information.
12091
12092 By default, an edge in this graph can contain the effects of a run
12093 of multiple statements within a basic block. With
12094 @option{-fanalyzer-fine-grained}, each statement gets its own edge.
12095
12096 @opindex fanalyzer-show-duplicate-count
12097 @opindex fno-analyzer-show-duplicate-count
12098 @item -fanalyzer-show-duplicate-count
12099 This option is intended for analyzer developers: if multiple diagnostics
12100 have been detected as being duplicates of each other, it emits a note when
12101 reporting the best diagnostic, giving the number of additional diagnostics
12102 that were suppressed by the deduplication logic.
12103
12104 @opindex fanalyzer-show-events-in-system-headers
12105 @opindex fno-analyzer-show-events-in-system-headers
12106 @item -fanalyzer-show-events-in-system-headers
12107 By default the analyzer emits simplified diagnostics paths by hiding
12108 events fully located within a system header.
12109 With @option{-fanalyzer-show-events-in-system-headers} such
12110 events are no longer suppressed.
12111
12112 @opindex fanalyzer-state-merge
12113 @opindex fno-analyzer-state-merge
12114 @item -fno-analyzer-state-merge
12115 This option is intended for analyzer developers.
12116
12117 By default the analyzer attempts to simplify analysis by merging
12118 sufficiently similar states at each program point as it builds its
12119 ``exploded graph''. With @option{-fno-analyzer-state-merge} this
12120 merging can be suppressed, for debugging state-handling issues.
12121
12122 @opindex fanalyzer-state-purge
12123 @opindex fno-analyzer-state-purge
12124 @item -fno-analyzer-state-purge
12125 This option is intended for analyzer developers.
12126
12127 By default the analyzer attempts to simplify analysis by purging
12128 aspects of state at a program point that appear to no longer be relevant
12129 e.g. the values of locals that aren't accessed later in the function
12130 and which aren't relevant to leak analysis.
12131
12132 With @option{-fno-analyzer-state-purge} this purging of state can
12133 be suppressed, for debugging state-handling issues.
12134
12135 @opindex fanalyzer-suppress-followups
12136 @opindex fno-analyzer-suppress-followups
12137 @item -fno-analyzer-suppress-followups
12138 This option is intended for analyzer developers.
12139
12140 By default the analyzer will stop exploring an execution path after
12141 encountering certain diagnostics, in order to avoid potentially issuing a
12142 cascade of follow-up diagnostics.
12143
12144 The diagnostics that terminate analysis along a path are:
12145
12146 @itemize
12147 @item @option{-Wanalyzer-null-argument}
12148 @item @option{-Wanalyzer-null-dereference}
12149 @item @option{-Wanalyzer-use-after-free}
12150 @item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
12151 @item @option{-Wanalyzer-use-of-uninitialized-value}
12152 @end itemize
12153
12154 With @option{-fno-analyzer-suppress-followups} the analyzer will
12155 continue to explore such paths even after such diagnostics, which may
12156 be helpful for debugging issues in the analyzer, or for microbenchmarks
12157 for detecting undefined behavior.
12158
12159 @opindex fanalyzer-transitivity
12160 @opindex fno-analyzer-transitivity
12161 @item -fanalyzer-transitivity
12162 This option enables transitivity of constraints within the analyzer.
12163
12164 @opindex fanalyzer-undo-inlining
12165 @opindex fno-analyzer-undo-inlining
12166 @item -fno-analyzer-undo-inlining
12167 This option is intended for analyzer developers.
12168
12169 @option{-fanalyzer} runs relatively late compared to other code analysis
12170 tools, and some optimizations have already been applied to the code. In
12171 particular function inlining may have occurred, leading to the
12172 interprocedural execution paths emitted by the analyzer containing
12173 function frames that don't correspond to those in the original source
12174 code.
12175
12176 By default the analyzer attempts to reconstruct the original function
12177 frames, and to emit events showing the inlined calls.
12178
12179 With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
12180 the original frame information can be disabled, which may be of help
12181 when debugging issues in the analyzer.
12182
12183 @item -fanalyzer-verbose-edges
12184 This option is intended for analyzer developers. It enables more
12185 verbose, lower-level detail in the descriptions of control flow
12186 within diagnostic paths.
12187
12188 @item -fanalyzer-verbose-state-changes
12189 This option is intended for analyzer developers. It enables more
12190 verbose, lower-level detail in the descriptions of events relating
12191 to state machines within diagnostic paths.
12192
12193 @item -fanalyzer-verbosity=@var{level}
12194 This option controls the complexity of the control flow paths that are
12195 emitted for analyzer diagnostics.
12196
12197 The @var{level} can be one of:
12198
12199 @table @samp
12200 @item 0
12201 At this level, interprocedural call and return events are displayed,
12202 along with the most pertinent state-change events relating to
12203 a diagnostic. For example, for a double-@code{free} diagnostic,
12204 both calls to @code{free} will be shown.
12205
12206 @item 1
12207 As per the previous level, but also show events for the entry
12208 to each function.
12209
12210 @item 2
12211 As per the previous level, but also show events relating to
12212 control flow that are significant to triggering the issue
12213 (e.g. ``true path taken'' at a conditional).
12214
12215 This level is the default.
12216
12217 @item 3
12218 As per the previous level, but show all control flow events, not
12219 just significant ones.
12220
12221 @item 4
12222 This level is intended for analyzer developers; it adds various
12223 other events intended for debugging the analyzer.
12224
12225 @end table
12226
12227 @opindex fdump-analyzer
12228 @item -fdump-analyzer
12229 Dump internal details about what the analyzer is doing to
12230 @file{@var{file}.analyzer.txt}.
12231 @option{-fdump-analyzer-stderr} overrides this option.
12232
12233 @opindex fdump-analyzer-stderr
12234 @item -fdump-analyzer-stderr
12235 Dump internal details about what the analyzer is doing to stderr.
12236 This option overrides @option{-fdump-analyzer}.
12237
12238 @opindex fdump-analyzer-callgraph
12239 @item -fdump-analyzer-callgraph
12240 Dump a representation of the call graph suitable for viewing with
12241 GraphViz to @file{@var{file}.callgraph.dot}.
12242
12243 @opindex fdump-analyzer-exploded-graph
12244 @item -fdump-analyzer-exploded-graph
12245 Dump a representation of the ``exploded graph'' suitable for viewing with
12246 GraphViz to @file{@var{file}.eg.dot}.
12247 Nodes are color-coded based on state-machine states to emphasize
12248 state changes.
12249
12250 @opindex dump-analyzer-exploded-nodes
12251 @item -fdump-analyzer-exploded-nodes
12252 Emit diagnostics showing where nodes in the ``exploded graph'' are
12253 in relation to the program source.
12254
12255 @opindex dump-analyzer-exploded-nodes-2
12256 @item -fdump-analyzer-exploded-nodes-2
12257 Dump a textual representation of the ``exploded graph'' to
12258 @file{@var{file}.eg.txt}.
12259
12260 @opindex dump-analyzer-exploded-nodes-3
12261 @item -fdump-analyzer-exploded-nodes-3
12262 Dump a textual representation of the ``exploded graph'' to
12263 one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
12264 This is typically a large number of dump files.
12265
12266 @opindex fdump-analyzer-exploded-paths
12267 @item -fdump-analyzer-exploded-paths
12268 Dump a textual representation of the ``exploded path'' for each
12269 diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
12270
12271 @opindex dump-analyzer-feasibility
12272 @item -fdump-analyzer-feasibility
12273 Dump internal details about the analyzer's search for feasible paths.
12274 The details are written in a form suitable for viewing with GraphViz
12275 to filenames of the form @file{@var{file}.*.fg.dot},
12276 @file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
12277
12278 @opindex dump-analyzer-infinite-loop
12279 @item -fdump-analyzer-infinite-loop
12280 Dump internal details about the analyzer's search for infinite loops.
12281 The details are written in a form suitable for viewing with GraphViz
12282 to filenames of the form @file{@var{file}.*.infinite-loop.dot}.
12283
12284 @opindex fdump-analyzer-json
12285 @item -fdump-analyzer-json
12286 Dump a compressed JSON representation of analyzer internals to
12287 @file{@var{file}.analyzer.json.gz}. The precise format is subject
12288 to change.
12289
12290 @opindex fdump-analyzer-state-purge
12291 @item -fdump-analyzer-state-purge
12292 As per @option{-fdump-analyzer-supergraph}, dump a representation of the
12293 ``supergraph'' suitable for viewing with GraphViz, but annotate the
12294 graph with information on what state will be purged at each node.
12295 The graph is written to @file{@var{file}.state-purge.dot}.
12296
12297 @opindex fdump-analyzer-supergraph
12298 @item -fdump-analyzer-supergraph
12299 Dump representations of the ``supergraph'' suitable for viewing with
12300 GraphViz to @file{@var{file}.supergraph.dot} and to
12301 @file{@var{file}.supergraph-eg.dot}. These show all of the
12302 control flow graphs in the program, with interprocedural edges for
12303 calls and returns. The second dump contains annotations showing nodes
12304 in the ``exploded graph'' and diagnostics associated with them.
12305
12306 @opindex fdump-analyzer-untracked
12307 @item -fdump-analyzer-untracked
12308 Emit custom warnings with internal details intended for analyzer developers.
12309
12310 @end table
12311
12312 @node Debugging Options
12313 @section Options for Debugging Your Program
12314 @cindex options, debugging
12315 @cindex debugging information options
12316
12317 To tell GCC to emit extra information for use by a debugger, in almost
12318 all cases you need only to add @option{-g} to your other options. Some debug
12319 formats can co-exist (like DWARF with CTF) when each of them is enabled
12320 explicitly by adding the respective command line option to your other options.
12321
12322 GCC allows you to use @option{-g} with
12323 @option{-O}. The shortcuts taken by optimized code may occasionally
12324 be surprising: some variables you declared may not exist
12325 at all; flow of control may briefly move where you did not expect it;
12326 some statements may not be executed because they compute constant
12327 results or their values are already at hand; some statements may
12328 execute in different places because they have been moved out of loops.
12329 Nevertheless it is possible to debug optimized output. This makes
12330 it reasonable to use the optimizer for programs that might have bugs.
12331
12332 If you are not using some other optimization option, consider
12333 using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
12334 With no @option{-O} option at all, some compiler passes that collect
12335 information useful for debugging do not run at all, so that
12336 @option{-Og} may result in a better debugging experience.
12337
12338 @table @gcctabopt
12339 @opindex g
12340 @item -g
12341 Produce debugging information in the operating system's native format
12342 (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
12343 information.
12344
12345 On most systems that use stabs format, @option{-g} enables use of extra
12346 debugging information that only GDB can use; this extra information
12347 makes debugging work better in GDB but probably makes other debuggers
12348 crash or refuse to read the program. If you want to control for certain whether
12349 to generate the extra information, use @option{-gvms} (see below).
12350
12351 @opindex ggdb
12352 @item -ggdb
12353 Produce debugging information for use by GDB@. This means to use the
12354 most expressive format available (DWARF, stabs, or the native format
12355 if neither of those are supported), including GDB extensions if at all
12356 possible.
12357
12358 @opindex gdwarf
12359 @item -gdwarf
12360 @itemx -gdwarf-@var{version}
12361 Produce debugging information in DWARF format (if that is supported).
12362 The value of @var{version} may be either 2, 3, 4 or 5; the default
12363 version for most targets is 5 (with the exception of VxWorks, TPF and
12364 Darwin / macOS, which default to version 2, and AIX, which defaults
12365 to version 4).
12366
12367 Note that with DWARF Version 2, some ports require and always
12368 use some non-conflicting DWARF 3 extensions in the unwind tables.
12369
12370 Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
12371 for maximum benefit. Version 5 requires GDB 8.0 or higher.
12372
12373 GCC no longer supports DWARF Version 1, which is substantially
12374 different than Version 2 and later. For historical reasons, some
12375 other DWARF-related options such as
12376 @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
12377 in their names, but apply to all currently-supported versions of DWARF.
12378
12379 @opindex gbtf
12380 @item -gbtf
12381 Request BTF debug information. BTF is the default debugging format for the
12382 eBPF target. On other targets, like x86, BTF debug information can be
12383 generated along with DWARF debug information when both of the debug formats are
12384 enabled explicitly via their respective command line options.
12385
12386 @opindex gprune-btf
12387 @opindex gno-prune-btf
12388 @item -gprune-btf
12389 @itemx -gno-prune-btf
12390 Prune BTF information before emission. When pruning, only type
12391 information for types used by global variables and file-scope functions
12392 will be emitted. If compiling for the BPF target with BPF CO-RE
12393 enabled, type information will also be emitted for types used in BPF
12394 CO-RE relocations. In addition, struct and union types which are only
12395 referred to via pointers from members of other struct or union types
12396 shall be pruned and replaced with BTF_KIND_FWD, as though those types
12397 were only present in the input as forward declarations.
12398
12399 This option substantially reduces the size of produced BTF information,
12400 but at significant loss in the amount of detailed type information.
12401 It is primarily useful when compiling for the BPF target, to minimize
12402 the size of the resulting object, and to eliminate BTF information
12403 which is not immediately relevant to the BPF program loading process.
12404
12405 This option is enabled by default for the BPF target when generating
12406 BTF information.
12407
12408 @opindex gctf
12409 @item -gctf
12410 @itemx -gctf@var{level}
12411 Request CTF debug information and use level to specify how much CTF debug
12412 information should be produced. If @option{-gctf} is specified
12413 without a value for level, the default level of CTF debug information is 2.
12414
12415 CTF debug information can be generated along with DWARF debug information when
12416 both of the debug formats are enabled explicitly via their respective command
12417 line options.
12418
12419 Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
12420 negates @option{-gctf}.
12421
12422 Level 1 produces CTF information for tracebacks only. This includes callsite
12423 information, but does not include type information.
12424
12425 Level 2 produces type information for entities (functions, data objects etc.)
12426 at file-scope or global-scope only.
12427
12428 @opindex gvms
12429 @item -gvms
12430 Produce debugging information in Alpha/VMS debug format (if that is
12431 supported). This is the format used by DEBUG on Alpha/VMS systems.
12432
12433 @item -gcodeview
12434 @opindex gcodeview
12435 Produce debugging information in CodeView debug format (if that is
12436 supported). This is the format used by Microsoft Visual C++ on
12437 Windows.
12438
12439 @item -g@var{level}
12440 @itemx -ggdb@var{level}
12441 @itemx -gvms@var{level}
12442 Request debugging information and also use @var{level} to specify how
12443 much information. The default level is 2.
12444
12445 Level 0 produces no debug information at all. Thus, @option{-g0} negates
12446 @option{-g}.
12447
12448 Level 1 produces minimal information, enough for making backtraces in
12449 parts of the program that you don't plan to debug. This includes
12450 descriptions of functions and external variables, and line number
12451 tables, but no information about local variables.
12452
12453 Level 3 includes extra information, such as all the macro definitions
12454 present in the program. Some debuggers support macro expansion when
12455 you use @option{-g3}.
12456
12457 If you use multiple @option{-g} options, with or without level numbers,
12458 the last such option is the one that is effective.
12459
12460 @option{-gdwarf} does not accept a concatenated debug level, to avoid
12461 confusion with @option{-gdwarf-@var{level}}.
12462 Instead use an additional @option{-g@var{level}} option to change the
12463 debug level for DWARF.
12464
12465 @opindex feliminate-unused-debug-symbols
12466 @opindex fno-eliminate-unused-debug-symbols
12467 @item -fno-eliminate-unused-debug-symbols
12468 By default, no debug information is produced for symbols that are not actually
12469 used. Use this option if you want debug information for all symbols.
12470
12471 @opindex femit-class-debug-always
12472 @item -femit-class-debug-always
12473 Instead of emitting debugging information for a C++ class in only one
12474 object file, emit it in all object files using the class. This option
12475 should be used only with debuggers that are unable to handle the way GCC
12476 normally emits debugging information for classes because using this
12477 option increases the size of debugging information by as much as a
12478 factor of two.
12479
12480 @opindex fmerge-debug-strings
12481 @opindex fno-merge-debug-strings
12482 @item -fno-merge-debug-strings
12483 Direct the linker to not merge together strings in the debugging
12484 information that are identical in different object files. Merging is
12485 not supported by all assemblers or linkers. Merging decreases the size
12486 of the debug information in the output file at the cost of increasing
12487 link processing time. Merging is enabled by default.
12488
12489 @opindex fdebug-prefix-map
12490 @item -fdebug-prefix-map=@var{old}=@var{new}
12491 When compiling files residing in directory @file{@var{old}}, record
12492 debugging information describing them as if the files resided in
12493 directory @file{@var{new}} instead. This can be used to replace a
12494 build-time path with an install-time path in the debug info. It can
12495 also be used to change an absolute path to a relative path by using
12496 @file{.} for @var{new}. This can give more reproducible builds, which
12497 are location independent, but may require an extra command to tell GDB
12498 where to find the source files. See also @option{-ffile-prefix-map}
12499 and @option{-fcanon-prefix-map}.
12500
12501 @opindex fvar-tracking
12502 @item -fvar-tracking
12503 Run variable tracking pass. It computes where variables are stored at each
12504 position in code. Better debugging information is then generated
12505 (if the debugging information format supports this information).
12506
12507 It is enabled by default when compiling with optimization (@option{-Os},
12508 @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
12509 the debug info format supports it.
12510
12511 @opindex fvar-tracking-assignments
12512 @opindex fno-var-tracking-assignments
12513 @item -fvar-tracking-assignments
12514 Annotate assignments to user variables early in the compilation and
12515 attempt to carry the annotations over throughout the compilation all the
12516 way to the end, in an attempt to improve debug information while
12517 optimizing. Use of @option{-gdwarf-4} is recommended along with it.
12518
12519 It can be enabled even if var-tracking is disabled, in which case
12520 annotations are created and maintained, but discarded at the end.
12521 By default, this flag is enabled together with @option{-fvar-tracking},
12522 except when selective scheduling is enabled.
12523
12524 @opindex gsplit-dwarf
12525 @item -gsplit-dwarf
12526 If DWARF debugging information is enabled, separate as much debugging
12527 information as possible into a separate output file with the extension
12528 @file{.dwo}. This option allows the build system to avoid linking files with
12529 debug information. To be useful, this option requires a debugger capable of
12530 reading @file{.dwo} files.
12531
12532 @opindex gdwarf32
12533 @opindex gdwarf64
12534 @item -gdwarf32
12535 @itemx -gdwarf64
12536 If DWARF debugging information is enabled, the @option{-gdwarf32} selects
12537 the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
12538 DWARF format. The default is target specific, on most targets it is
12539 @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
12540 can't support more than 2GiB of debug information in any of the DWARF
12541 debug information sections. The 64-bit DWARF format allows larger debug
12542 information and might not be well supported by all consumers yet.
12543
12544 @opindex gdescribe-dies
12545 @item -gdescribe-dies
12546 Add description attributes to some DWARF DIEs that have no name attribute,
12547 such as artificial variables, external references and call site
12548 parameter DIEs.
12549
12550 @opindex gpubnames
12551 @item -gpubnames
12552 Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
12553
12554 @opindex ggnu-pubnames
12555 @item -ggnu-pubnames
12556 Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
12557 suitable for conversion into a GDB@ index. This option is only useful
12558 with a linker that can produce GDB@ index version 7.
12559
12560 @opindex fdebug-types-section
12561 @opindex fno-debug-types-section
12562 @item -fdebug-types-section
12563 When using DWARF Version 4 or higher, type DIEs can be put into
12564 their own @code{.debug_types} section instead of making them part of the
12565 @code{.debug_info} section. It is more efficient to put them in a separate
12566 comdat section since the linker can then remove duplicates.
12567 But not all DWARF consumers support @code{.debug_types} sections yet
12568 and on some objects @code{.debug_types} produces larger instead of smaller
12569 debugging information.
12570
12571 @opindex grecord-gcc-switches
12572 @opindex gno-record-gcc-switches
12573 @item -grecord-gcc-switches
12574 @itemx -gno-record-gcc-switches
12575 This switch causes the command-line options used to invoke the
12576 compiler that may affect code generation to be appended to the
12577 DW_AT_producer attribute in DWARF debugging information. The options
12578 are concatenated with spaces separating them from each other and from
12579 the compiler version.
12580 It is enabled by default.
12581 See also @option{-frecord-gcc-switches} for another
12582 way of storing compiler options into the object file.
12583
12584 @opindex gstrict-dwarf
12585 @item -gstrict-dwarf
12586 Disallow using extensions of later DWARF standard version than selected
12587 with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
12588 DWARF extensions from later standard versions is allowed.
12589
12590 @opindex gno-strict-dwarf
12591 @item -gno-strict-dwarf
12592 Allow using extensions of later DWARF standard version than selected with
12593 @option{-gdwarf-@var{version}}.
12594
12595 @opindex gas-loc-support
12596 @item -gas-loc-support
12597 Inform the compiler that the assembler supports @code{.loc} directives.
12598 It may then use them for the assembler to generate DWARF2+ line number
12599 tables.
12600
12601 This is generally desirable, because assembler-generated line-number
12602 tables are a lot more compact than those the compiler can generate
12603 itself.
12604
12605 This option will be enabled by default if, at GCC configure time, the
12606 assembler was found to support such directives.
12607
12608 @opindex gno-as-loc-support
12609 @item -gno-as-loc-support
12610 Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
12611 line number tables are to be generated.
12612
12613 @opindex gas-locview-support
12614 @item -gas-locview-support
12615 Inform the compiler that the assembler supports @code{view} assignment
12616 and reset assertion checking in @code{.loc} directives.
12617
12618 This option will be enabled by default if, at GCC configure time, the
12619 assembler was found to support them.
12620
12621 @item -gno-as-locview-support
12622 Force GCC to assign view numbers internally, if
12623 @option{-gvariable-location-views} are explicitly requested.
12624
12625 @opindex gcolumn-info
12626 @opindex gno-column-info
12627 @item -gcolumn-info
12628 @itemx -gno-column-info
12629 Emit location column information into DWARF debugging information, rather
12630 than just file and line.
12631 This option is enabled by default.
12632
12633 @opindex gstatement-frontiers
12634 @opindex gno-statement-frontiers
12635 @item -gstatement-frontiers
12636 @itemx -gno-statement-frontiers
12637 This option causes GCC to create markers in the internal representation
12638 at the beginning of statements, and to keep them roughly in place
12639 throughout compilation, using them to guide the output of @code{is_stmt}
12640 markers in the line number table. This is enabled by default when
12641 compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
12642 @dots{}), and outputting DWARF 2 debug information at the normal level.
12643
12644 @opindex gvariable-location-views
12645 @opindex gvariable-location-views=incompat5
12646 @opindex gno-variable-location-views
12647 @item -gvariable-location-views
12648 @itemx -gvariable-location-views=incompat5
12649 @itemx -gno-variable-location-views
12650 Augment variable location lists with progressive view numbers implied
12651 from the line number table. This enables debug information consumers to
12652 inspect state at certain points of the program, even if no instructions
12653 associated with the corresponding source locations are present at that
12654 point. If the assembler lacks support for view numbers in line number
12655 tables, this will cause the compiler to emit the line number table,
12656 which generally makes them somewhat less compact. The augmented line
12657 number tables and location lists are fully backward-compatible, so they
12658 can be consumed by debug information consumers that are not aware of
12659 these augmentations, but they won't derive any benefit from them either.
12660
12661 This is enabled by default when outputting DWARF 2 debug information at
12662 the normal level, as long as there is assembler support,
12663 @option{-fvar-tracking-assignments} is enabled and
12664 @option{-gstrict-dwarf} is not. When assembler support is not
12665 available, this may still be enabled, but it will force GCC to output
12666 internal line number tables, and if
12667 @option{-ginternal-reset-location-views} is not enabled, that will most
12668 certainly lead to silently mismatching location views.
12669
12670 There is a proposed representation for view numbers that is not backward
12671 compatible with the location list format introduced in DWARF 5, that can
12672 be enabled with @option{-gvariable-location-views=incompat5}. This
12673 option may be removed in the future, is only provided as a reference
12674 implementation of the proposed representation. Debug information
12675 consumers are not expected to support this extended format, and they
12676 would be rendered unable to decode location lists using it.
12677
12678 @opindex ginternal-reset-location-views
12679 @opindex gno-internal-reset-location-views
12680 @item -ginternal-reset-location-views
12681 @itemx -gno-internal-reset-location-views
12682 Attempt to determine location views that can be omitted from location
12683 view lists. This requires the compiler to have very accurate insn
12684 length estimates, which isn't always the case, and it may cause
12685 incorrect view lists to be generated silently when using an assembler
12686 that does not support location view lists. The GNU assembler will flag
12687 any such error as a @code{view number mismatch}. This is only enabled
12688 on ports that define a reliable estimation function.
12689
12690 @opindex ginline-points
12691 @opindex gno-inline-points
12692 @item -ginline-points
12693 @itemx -gno-inline-points
12694 Generate extended debug information for inlined functions. Location
12695 view tracking markers are inserted at inlined entry points, so that
12696 address and view numbers can be computed and output in debug
12697 information. This can be enabled independently of location views, in
12698 which case the view numbers won't be output, but it can only be enabled
12699 along with statement frontiers, and it is only enabled by default if
12700 location views are enabled.
12701
12702 @opindex gz
12703 @item -gz@r{[}=@var{type}@r{]}
12704 Produce compressed debug sections in DWARF format, if that is supported.
12705 If @var{type} is not given, the default type depends on the capabilities
12706 of the assembler and linker used. @var{type} may be one of
12707 @samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
12708 compression in ELF gABI format). If the linker doesn't support writing
12709 compressed debug sections, the option is rejected. Otherwise, if the
12710 assembler does not support them, @option{-gz} is silently ignored when
12711 producing object files.
12712
12713 @opindex femit-struct-debug-baseonly
12714 @item -femit-struct-debug-baseonly
12715 Emit debug information for struct-like types
12716 only when the base name of the compilation source file
12717 matches the base name of file in which the struct is defined.
12718
12719 This option substantially reduces the size of debugging information,
12720 but at significant potential loss in type information to the debugger.
12721 See @option{-femit-struct-debug-reduced} for a less aggressive option.
12722 See @option{-femit-struct-debug-detailed} for more detailed control.
12723
12724 This option works only with DWARF debug output.
12725
12726 @opindex femit-struct-debug-reduced
12727 @item -femit-struct-debug-reduced
12728 Emit debug information for struct-like types
12729 only when the base name of the compilation source file
12730 matches the base name of file in which the type is defined,
12731 unless the struct is a template or defined in a system header.
12732
12733 This option significantly reduces the size of debugging information,
12734 with some potential loss in type information to the debugger.
12735 See @option{-femit-struct-debug-baseonly} for a more aggressive option.
12736 See @option{-femit-struct-debug-detailed} for more detailed control.
12737
12738 This option works only with DWARF debug output.
12739
12740 @opindex femit-struct-debug-detailed
12741 @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
12742 Specify the struct-like types
12743 for which the compiler generates debug information.
12744 The intent is to reduce duplicate struct debug information
12745 between different object files within the same program.
12746
12747 This option is a detailed version of
12748 @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
12749 which serves for most needs.
12750
12751 A specification has the syntax@*
12752 [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
12753
12754 The optional first word limits the specification to
12755 structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
12756 A struct type is used directly when it is the type of a variable, member.
12757 Indirect uses arise through pointers to structs.
12758 That is, when use of an incomplete struct is valid, the use is indirect.
12759 An example is
12760 @samp{struct one direct; struct two * indirect;}.
12761
12762 The optional second word limits the specification to
12763 ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
12764 Generic structs are a bit complicated to explain.
12765 For C++, these are non-explicit specializations of template classes,
12766 or non-template classes within the above.
12767 Other programming languages have generics,
12768 but @option{-femit-struct-debug-detailed} does not yet implement them.
12769
12770 The third word specifies the source files for those
12771 structs for which the compiler should emit debug information.
12772 The values @samp{none} and @samp{any} have the normal meaning.
12773 The value @samp{base} means that
12774 the base of name of the file in which the type declaration appears
12775 must match the base of the name of the main compilation file.
12776 In practice, this means that when compiling @file{foo.c}, debug information
12777 is generated for types declared in that file and @file{foo.h},
12778 but not other header files.
12779 The value @samp{sys} means those types satisfying @samp{base}
12780 or declared in system or compiler headers.
12781
12782 You may need to experiment to determine the best settings for your application.
12783
12784 The default is @option{-femit-struct-debug-detailed=all}.
12785
12786 This option works only with DWARF debug output.
12787
12788 @opindex fdwarf2-cfi-asm
12789 @opindex fno-dwarf2-cfi-asm
12790 @item -fno-dwarf2-cfi-asm
12791 Emit DWARF unwind info as compiler generated @code{.eh_frame} section
12792 instead of using GAS @code{.cfi_*} directives.
12793
12794 @opindex feliminate-unused-debug-types
12795 @opindex fno-eliminate-unused-debug-types
12796 @item -fno-eliminate-unused-debug-types
12797 Normally, when producing DWARF output, GCC avoids producing debug symbol
12798 output for types that are nowhere used in the source file being compiled.
12799 Sometimes it is useful to have GCC emit debugging
12800 information for all types declared in a compilation
12801 unit, regardless of whether or not they are actually used
12802 in that compilation unit, for example
12803 if, in the debugger, you want to cast a value to a type that is
12804 not actually used in your program (but is declared). More often,
12805 however, this results in a significant amount of wasted space.
12806 @end table
12807
12808 @node Optimize Options
12809 @section Options That Control Optimization
12810 @cindex optimize options
12811 @cindex options, optimization
12812
12813 These options control various sorts of optimizations.
12814
12815 Without any optimization option, the compiler's goal is to reduce the
12816 cost of compilation and to make debugging produce the expected
12817 results. Statements are independent: if you stop the program with a
12818 breakpoint between statements, you can then assign a new value to any
12819 variable or change the program counter to any other statement in the
12820 function and get exactly the results you expect from the source
12821 code.
12822
12823 Turning on optimization flags makes the compiler attempt to improve
12824 the performance and/or code size at the expense of compilation time
12825 and possibly the ability to debug the program.
12826
12827 The compiler performs optimization based on the knowledge it has of the
12828 program. Compiling multiple files at once to a single output file mode allows
12829 the compiler to use information gained from all of the files when compiling
12830 each of them.
12831
12832 Not all optimizations are controlled directly by a flag. Only
12833 optimizations that have a flag are listed in this section.
12834
12835 Most optimizations are completely disabled at @option{-O0} or if an
12836 @option{-O} level is not set on the command line, even if individual
12837 optimization flags are specified. Similarly, @option{-Og} suppresses
12838 many optimization passes.
12839
12840 Depending on the target and how GCC was configured, a slightly different
12841 set of optimizations may be enabled at each @option{-O} level than
12842 those listed here. You can invoke GCC with @option{-Q --help=optimizers}
12843 to find out the exact set of optimizations that are enabled at each level.
12844 @xref{Overall Options}, for examples.
12845
12846 @table @gcctabopt
12847 @opindex O
12848 @opindex O1
12849 @item -O
12850 @itemx -O1
12851 Optimize. Optimizing compilation takes somewhat more time, and a lot
12852 more memory for a large function.
12853
12854 With @option{-O}, the compiler tries to reduce code size and execution
12855 time, without performing any optimizations that take a great deal of
12856 compilation time.
12857
12858 @option{-O} is the recommended optimization level for large machine-generated
12859 code as a sensible balance between time taken to compile and memory use:
12860 higher optimization levels perform optimizations with greater algorithmic
12861 complexity than at @option{-O}.
12862
12863 @c Note that in addition to the default_options_table list in opts.cc,
12864 @c several optimization flags default to true but control optimization
12865 @c passes that are explicitly disabled at -O0.
12866
12867 @option{-O} turns on the following optimization flags:
12868
12869 @c Please keep the following list alphabetized.
12870 @gccoptlist{-fauto-inc-dec
12871 -fbranch-count-reg
12872 -fcombine-stack-adjustments
12873 -fcompare-elim
12874 -fcprop-registers
12875 -fdce
12876 -fdefer-pop
12877 -fdelayed-branch
12878 -fdse
12879 -fforward-propagate
12880 -fguess-branch-probability
12881 -fif-conversion
12882 -fif-conversion2
12883 -finline-functions-called-once
12884 -fipa-modref
12885 -fipa-profile
12886 -fipa-pure-const
12887 -fipa-reference
12888 -fipa-reference-addressable
12889 -fivopts
12890 -fmerge-constants
12891 -fmove-loop-invariants
12892 -fmove-loop-stores
12893 -fomit-frame-pointer
12894 -freorder-blocks
12895 -fshrink-wrap
12896 -fshrink-wrap-separate
12897 -fsplit-wide-types
12898 -fssa-backprop
12899 -fssa-phiopt
12900 -ftree-bit-ccp
12901 -ftree-ccp
12902 -ftree-ch
12903 -ftree-coalesce-vars
12904 -ftree-copy-prop
12905 -ftree-dce
12906 -ftree-dominator-opts
12907 -ftree-dse
12908 -ftree-forwprop
12909 -ftree-fre
12910 -ftree-phiprop
12911 -ftree-pta
12912 -ftree-scev-cprop
12913 -ftree-sink
12914 -ftree-slsr
12915 -ftree-sra
12916 -ftree-ter
12917 -funit-at-a-time}
12918
12919 @opindex O2
12920 @item -O2
12921 Optimize even more. GCC performs nearly all supported optimizations
12922 that do not involve a space-speed tradeoff.
12923 As compared to @option{-O}, this option increases both compilation time
12924 and the performance of the generated code.
12925
12926 @option{-O2} turns on all optimization flags specified by @option{-O1}. It
12927 also turns on the following optimization flags:
12928
12929 @c Please keep the following list alphabetized!
12930 @gccoptlist{-falign-functions -falign-jumps
12931 -falign-labels -falign-loops
12932 -fcaller-saves
12933 -fcode-hoisting
12934 -fcrossjumping
12935 -fcse-follow-jumps -fcse-skip-blocks
12936 -fdelete-null-pointer-checks
12937 -fdevirtualize -fdevirtualize-speculatively
12938 -fexpensive-optimizations
12939 -ffinite-loops
12940 -fgcse -fgcse-lm
12941 -fhoist-adjacent-loads
12942 -finline-functions
12943 -finline-small-functions
12944 -findirect-inlining
12945 -fipa-bit-cp -fipa-cp -fipa-icf
12946 -fipa-ra -fipa-sra -fipa-vrp
12947 -fisolate-erroneous-paths-dereference
12948 -flra-remat
12949 -foptimize-crc
12950 -foptimize-sibling-calls
12951 -foptimize-strlen
12952 -fpartial-inlining
12953 -fpeephole2
12954 -freorder-blocks-algorithm=stc
12955 -freorder-blocks-and-partition -freorder-functions
12956 -frerun-cse-after-loop
12957 -fschedule-insns -fschedule-insns2
12958 -fsched-interblock -fsched-spec
12959 -fstore-merging
12960 -fstrict-aliasing
12961 -fthread-jumps
12962 -ftree-builtin-call-dce
12963 -ftree-loop-vectorize
12964 -ftree-pre
12965 -ftree-slp-vectorize
12966 -ftree-switch-conversion -ftree-tail-merge
12967 -ftree-vrp
12968 -fvect-cost-model=very-cheap}
12969
12970 Please note the warning under @option{-fgcse} about
12971 invoking @option{-O2} on programs that use computed gotos.
12972
12973 @opindex O3
12974 @item -O3
12975 Optimize yet more. @option{-O3} turns on all optimizations specified
12976 by @option{-O2} and also turns on the following optimization flags:
12977
12978 @c Please keep the following list alphabetized!
12979 @gccoptlist{-fgcse-after-reload
12980 -fipa-cp-clone
12981 -floop-interchange
12982 -floop-unroll-and-jam
12983 -fpeel-loops
12984 -fpredictive-commoning
12985 -fsplit-loops
12986 -fsplit-paths
12987 -ftree-loop-distribution
12988 -ftree-partial-pre
12989 -funswitch-loops
12990 -fvect-cost-model=dynamic
12991 -fversion-loops-for-strides}
12992
12993 @opindex O0
12994 @item -O0
12995 Reduce compilation time and make debugging produce the expected
12996 results. This is the default.
12997
12998 At @option{-O0}, GCC completely disables most optimization passes;
12999 they are not run even if you explicitly enable them on the command
13000 line, or are listed by @option{-Q --help=optimizers} as being enabled by
13001 default. Many optimizations performed by GCC depend on code analysis
13002 or canonicalization passes that are enabled by @option{-O}, and it would
13003 not be useful to run individual optimization passes in isolation.
13004
13005 @opindex Os
13006 @item -Os
13007 Optimize for size. @option{-Os} enables all @option{-O2} optimizations
13008 except those that often increase code size:
13009
13010 @gccoptlist{-falign-functions -falign-jumps
13011 -falign-labels -falign-loops
13012 -fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
13013
13014 It also enables @option{-finline-functions}, causes the compiler to tune for
13015 code size rather than execution speed, and performs further optimizations
13016 designed to reduce code size.
13017
13018 @opindex Ofast
13019 @item -Ofast
13020 Disregard strict standards compliance. @option{-Ofast} enables all
13021 @option{-O3} optimizations. It also enables optimizations that are not
13022 valid for all standard-compliant programs.
13023 It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
13024 and the Fortran-specific @option{-fstack-arrays}, unless
13025 @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
13026 It turns off @option{-fsemantic-interposition}.
13027
13028 @opindex Og
13029 @item -Og
13030 Optimize while keeping in mind debugging experience.
13031 @option{-Og} should be the optimization
13032 level of choice for the standard edit-compile-debug cycle, offering
13033 a reasonable blend of optimization, fast compilation and debugging experience
13034 especially for code with a high abstraction penalty. In contrast to
13035 @option{-O0}, this enables @option{-fvar-tracking-assignments} and
13036 @option{-fvar-tracking} which handle debug information in the prologue
13037 and epilogue of functions better than @option{-O0}.
13038
13039 Like @option{-O0}, @option{-Og} completely skips a number of
13040 optimization passes so that individual options controlling them have
13041 no effect. Otherwise @option{-Og} enables all @option{-O1}
13042 optimization flags except for those known to greatly interfere with debugging:
13043
13044 @gccoptlist{-fbranch-count-reg -fdelayed-branch
13045 -fdse -fif-conversion -fif-conversion2
13046 -finline-functions-called-once
13047 -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt
13048 -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
13049
13050 @opindex Oz
13051 @item -Oz
13052 Optimize aggressively for size rather than speed. This may increase
13053 the number of instructions executed if those instructions require
13054 fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
13055 including enabling most @option{-O2} optimizations.
13056
13057 @end table
13058
13059 If you use multiple @option{-O} options, with or without level numbers,
13060 the last such option is the one that is effective.
13061
13062 Options of the form @option{-f@var{flag}} specify machine-independent
13063 flags. Most flags have both positive and negative forms; the negative
13064 form of @option{-ffoo} is @option{-fno-foo}. In the table
13065 below, only one of the forms is listed---the one you typically
13066 use. You can figure out the other form by either removing @samp{no-}
13067 or adding it.
13068
13069 The following options control specific optimizations. They are either
13070 activated by @option{-O} options or are related to ones that are. You
13071 can use the following flags in the rare cases when ``fine-tuning'' of
13072 optimizations to be performed is desired.
13073
13074 @table @gcctabopt
13075 @opindex fno-defer-pop
13076 @opindex fdefer-pop
13077 @item -fno-defer-pop
13078 For machines that must pop arguments after a function call, always pop
13079 the arguments as soon as each function returns.
13080 At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
13081 this allows the compiler to let arguments accumulate on the stack for several
13082 function calls and pop them all at once.
13083
13084 @opindex fforward-propagate
13085 @item -fforward-propagate
13086 Perform a forward propagation pass on RTL@. The pass tries to combine two
13087 instructions and checks if the result can be simplified. If loop unrolling
13088 is active, two passes are performed and the second is scheduled after
13089 loop unrolling.
13090
13091 This option is enabled by default at optimization levels @option{-O1},
13092 @option{-O2}, @option{-O3}, @option{-Os}.
13093
13094 @opindex favoid-store-forwarding
13095 @item -favoid-store-forwarding
13096 @itemx -fno-avoid-store-forwarding
13097 Many CPUs will stall for many cycles when a load partially depends on previous
13098 smaller stores. This pass tries to detect such cases and avoid the penalty by
13099 changing the order of the load and store and then fixing up the loaded value.
13100
13101 Disabled by default.
13102
13103 @opindex ffp-contract
13104 @item -ffp-contract=@var{style}
13105 @option{-ffp-contract=off} disables floating-point expression contraction.
13106 @option{-ffp-contract=fast} enables floating-point expression contraction
13107 such as forming of fused multiply-add operations if the target has
13108 native support for them.
13109 @option{-ffp-contract=on} enables floating-point expression contraction
13110 if allowed by the language standard. This is implemented for C and C++,
13111 where it enables contraction within one expression, but not across
13112 different statements.
13113
13114 The default is @option{-ffp-contract=off} for C in a standards compliant mode
13115 (@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise.
13116
13117 @opindex fomit-frame-pointer
13118 @item -fomit-frame-pointer
13119 Omit the frame pointer in functions that don't need one. This avoids the
13120 instructions to save, set up and restore the frame pointer; on many targets
13121 it also makes an extra register available.
13122
13123 On some targets this flag has no effect because the standard calling sequence
13124 always uses a frame pointer, so it cannot be omitted.
13125
13126 Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
13127 is used in all functions. Several targets always omit the frame pointer in
13128 leaf functions.
13129
13130 Enabled by default at @option{-O1} and higher.
13131
13132 @opindex foptimize-crc
13133 @item -foptimize-crc
13134 Detect loops calculating CRC (performing polynomial long division) and
13135 replace them with a faster implementation. Detect 8, 16, 32, and 64 bit CRC,
13136 with a constant polynomial without the leading 1 bit,
13137 for both bit-forward and bit-reversed cases.
13138 If the target supports a CRC instruction and the polynomial used in the source
13139 code matches the polynomial used in the CRC instruction, generate that CRC
13140 instruction. Otherwise, if the target supports a carry-less-multiplication
13141 instruction, generate CRC using it; otherwise generate table-based CRC.
13142
13143 Enabled by default at @option{-O2} and higher.
13144
13145 @opindex foptimize-sibling-calls
13146 @item -foptimize-sibling-calls
13147 Optimize sibling and tail recursive calls.
13148
13149 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13150
13151 @opindex foptimize-strlen
13152 @item -foptimize-strlen
13153 Optimize various standard C string functions (e.g.@: @code{strlen},
13154 @code{strchr} or @code{strcpy}) and
13155 their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
13156
13157 Enabled at levels @option{-O2}, @option{-O3}.
13158
13159 @opindex finline-stringops
13160 @item -finline-stringops[=@var{fn}]
13161 Expand memory and string operations (for now, only @code{memset})
13162 inline, even when the length is variable or big enough as to require
13163 looping. This is most useful along with @option{-ffreestanding} and
13164 @option{-fno-builtin}.
13165
13166 In some circumstances, it enables the compiler to generate code that
13167 takes advantage of known alignment and length multipliers, but even then
13168 it may be less efficient than optimized runtime implementations, and
13169 grow code size so much that even a less performant but shared
13170 implementation runs faster due to better use of code caches. This
13171 option is disabled by default.
13172
13173 @opindex fno-inline
13174 @opindex finline
13175 @item -fno-inline
13176 Do not expand any functions inline apart from those marked with
13177 the @code{always_inline} attribute. This is the default when not
13178 optimizing.
13179
13180 Single functions can be exempted from inlining by marking them
13181 with the @code{noinline} attribute.
13182
13183 @opindex finline-small-functions
13184 @item -finline-small-functions
13185 Integrate functions into their callers when their body is smaller than expected
13186 function call code (so overall size of program gets smaller). The compiler
13187 heuristically decides which functions are simple enough to be worth integrating
13188 in this way. This inlining applies to all functions, even those not declared
13189 inline.
13190
13191 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13192
13193 @opindex findirect-inlining
13194 @item -findirect-inlining
13195 Inline also indirect calls that are discovered to be known at compile
13196 time thanks to previous inlining. This option has any effect only
13197 when inlining itself is turned on by the @option{-finline-functions}
13198 or @option{-finline-small-functions} options.
13199
13200 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13201
13202 @opindex finline-functions
13203 @item -finline-functions
13204 Consider all functions for inlining, even if they are not declared inline.
13205 The compiler heuristically decides which functions are worth integrating
13206 in this way.
13207
13208 If all calls to a given function are integrated, and the function is
13209 declared @code{static}, then the function is normally not output as
13210 assembler code in its own right.
13211
13212 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
13213 by @option{-fprofile-use} and @option{-fauto-profile}.
13214
13215 @opindex finline-functions-called-once
13216 @item -finline-functions-called-once
13217 Consider all @code{static} functions called once for inlining into their
13218 caller even if they are not marked @code{inline}. If a call to a given
13219 function is integrated, then the function is not output as assembler code
13220 in its own right.
13221
13222 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
13223 but not @option{-Og}.
13224
13225 @opindex fearly-inlining
13226 @item -fearly-inlining
13227 Inline functions marked by @code{always_inline} and functions whose body seems
13228 smaller than the function call overhead early before doing
13229 @option{-fprofile-generate} instrumentation and real inlining pass. Doing so
13230 makes profiling significantly cheaper and usually inlining faster on programs
13231 having large chains of nested wrapper functions.
13232
13233 Enabled by default.
13234
13235 @opindex fipa-sra
13236 @item -fipa-sra
13237 Perform interprocedural scalar replacement of aggregates, removal of
13238 unused parameters and replacement of parameters passed by reference
13239 by parameters passed by value.
13240
13241 Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
13242
13243 @opindex finline-limit
13244 @item -finline-limit=@var{n}
13245 By default, GCC limits the size of functions that can be inlined. This flag
13246 allows coarse control of this limit. @var{n} is the size of functions that
13247 can be inlined in number of pseudo instructions.
13248
13249 Inlining is actually controlled by a number of parameters, which may be
13250 specified individually by using @option{--param @var{name}=@var{value}}.
13251 The @option{-finline-limit=@var{n}} option sets some of these parameters
13252 as follows:
13253
13254 @table @gcctabopt
13255 @item max-inline-insns-single
13256 is set to @var{n}/2.
13257 @item max-inline-insns-auto
13258 is set to @var{n}/2.
13259 @end table
13260
13261 See below for a documentation of the individual
13262 parameters controlling inlining and for the defaults of these parameters.
13263
13264 @emph{Note:} there may be no value to @option{-finline-limit} that results
13265 in default behavior.
13266
13267 @emph{Note:} pseudo instruction represents, in this particular context, an
13268 abstract measurement of function's size. In no way does it represent a count
13269 of assembly instructions and as such its exact meaning might change from one
13270 release to an another.
13271
13272 @opindex fno-keep-inline-dllexport
13273 @opindex fkeep-inline-dllexport
13274 @item -fno-keep-inline-dllexport
13275 This is a more fine-grained version of @option{-fkeep-inline-functions},
13276 which applies only to functions that are declared using the @code{dllexport}
13277 attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
13278 Functions}.
13279
13280 @opindex fkeep-inline-functions
13281 @item -fkeep-inline-functions
13282 In C, emit @code{static} functions that are declared @code{inline}
13283 into the object file, even if the function has been inlined into all
13284 of its callers. This switch does not affect functions using the
13285 @code{extern inline} extension in GNU C90@. In C++, emit any and all
13286 inline functions into the object file.
13287
13288 @opindex fkeep-static-functions
13289 @item -fkeep-static-functions
13290 Emit @code{static} functions into the object file, even if the function
13291 is never used.
13292
13293 @opindex fkeep-static-consts
13294 @item -fkeep-static-consts
13295 Emit variables declared @code{static const} when optimization isn't turned
13296 on, even if the variables aren't referenced.
13297
13298 GCC enables this option by default. If you want to force the compiler to
13299 check if a variable is referenced, regardless of whether or not
13300 optimization is turned on, use the @option{-fno-keep-static-consts} option.
13301
13302 @opindex fmerge-constants
13303 @item -fmerge-constants
13304 Attempt to merge identical constants (string constants and floating-point
13305 constants) across compilation units.
13306
13307 This option is the default for optimized compilation if the assembler and
13308 linker support it. Use @option{-fno-merge-constants} to inhibit this
13309 behavior.
13310
13311 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13312
13313 @opindex fmerge-all-constants
13314 @item -fmerge-all-constants
13315 Attempt to merge identical constants and identical variables.
13316
13317 This option implies @option{-fmerge-constants}. In addition to
13318 @option{-fmerge-constants} this considers e.g.@: even constant initialized
13319 arrays or initialized constant variables with integral or floating-point
13320 types. Languages like C or C++ require each variable, including multiple
13321 instances of the same variable in recursive calls, to have distinct locations,
13322 so using this option results in non-conforming
13323 behavior.
13324
13325 @opindex fmodulo-sched
13326 @item -fmodulo-sched
13327 Perform swing modulo scheduling immediately before the first scheduling
13328 pass. This pass looks at innermost loops and reorders their
13329 instructions by overlapping different iterations.
13330
13331 @opindex fmodulo-sched-allow-regmoves
13332 @item -fmodulo-sched-allow-regmoves
13333 Perform more aggressive SMS-based modulo scheduling with register moves
13334 allowed. By setting this flag certain anti-dependences edges are
13335 deleted, which triggers the generation of reg-moves based on the
13336 life-range analysis. This option is effective only with
13337 @option{-fmodulo-sched} enabled.
13338
13339 @opindex fno-branch-count-reg
13340 @opindex fbranch-count-reg
13341 @item -fno-branch-count-reg
13342 Disable the optimization pass that scans for opportunities to use
13343 ``decrement and branch'' instructions on a count register instead of
13344 instruction sequences that decrement a register, compare it against zero, and
13345 then branch based upon the result. This option is only meaningful on
13346 architectures that support such instructions, which include x86, PowerPC,
13347 IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
13348 doesn't remove the decrement and branch instructions from the generated
13349 instruction stream introduced by other optimization passes.
13350
13351 The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
13352 except for @option{-Og}.
13353
13354 @opindex fno-function-cse
13355 @opindex ffunction-cse
13356 @item -fno-function-cse
13357 Do not put function addresses in registers; make each instruction that
13358 calls a constant function contain the function's address explicitly.
13359
13360 This option results in less efficient code, but some strange hacks
13361 that alter the assembler output may be confused by the optimizations
13362 performed when this option is not used.
13363
13364 The default is @option{-ffunction-cse}
13365
13366 @opindex fno-zero-initialized-in-bss
13367 @opindex fzero-initialized-in-bss
13368 @item -fno-zero-initialized-in-bss
13369 If the target supports a BSS section, GCC by default puts variables that
13370 are initialized to zero into BSS@. This can save space in the resulting
13371 code.
13372
13373 This option turns off this behavior because some programs explicitly
13374 rely on variables going to the data section---e.g., so that the
13375 resulting executable can find the beginning of that section and/or make
13376 assumptions based on that.
13377
13378 The default is @option{-fzero-initialized-in-bss} except in Ada.
13379
13380 @opindex fthread-jumps
13381 @item -fthread-jumps
13382 Perform optimizations that check to see if a jump branches to a
13383 location where another comparison subsumed by the first is found. If
13384 so, the first branch is redirected to either the destination of the
13385 second branch or a point immediately following it, depending on whether
13386 the condition is known to be true or false.
13387
13388 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13389
13390 @opindex fsplit-wide-types
13391 @item -fsplit-wide-types
13392 When using a type that occupies multiple registers, such as @code{long
13393 long} on a 32-bit system, split the registers apart and allocate them
13394 independently. This normally generates better code for those types,
13395 but may make debugging more difficult.
13396
13397 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
13398 @option{-Os}.
13399
13400 @opindex fsplit-wide-types-early
13401 @item -fsplit-wide-types-early
13402 Fully split wide types early, instead of very late.
13403 This option has no effect unless @option{-fsplit-wide-types} is turned on.
13404
13405 This is the default on some targets.
13406
13407 @opindex fcse-follow-jumps
13408 @item -fcse-follow-jumps
13409 In common subexpression elimination (CSE), scan through jump instructions
13410 when the target of the jump is not reached by any other path. For
13411 example, when CSE encounters an @code{if} statement with an
13412 @code{else} clause, CSE follows the jump when the condition
13413 tested is false.
13414
13415 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13416
13417 @opindex fcse-skip-blocks
13418 @item -fcse-skip-blocks
13419 This is similar to @option{-fcse-follow-jumps}, but causes CSE to
13420 follow jumps that conditionally skip over blocks. When CSE
13421 encounters a simple @code{if} statement with no else clause,
13422 @option{-fcse-skip-blocks} causes CSE to follow the jump around the
13423 body of the @code{if}.
13424
13425 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13426
13427 @opindex frerun-cse-after-loop
13428 @item -frerun-cse-after-loop
13429 Re-run common subexpression elimination after loop optimizations are
13430 performed.
13431
13432 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13433
13434 @opindex fgcse
13435 @item -fgcse
13436 Perform a global common subexpression elimination pass.
13437 This pass also performs global constant and copy propagation.
13438
13439 @emph{Note:} When compiling a program using computed gotos, a GCC
13440 extension, you may get better run-time performance if you disable
13441 the global common subexpression elimination pass by adding
13442 @option{-fno-gcse} to the command line.
13443
13444 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13445
13446 @opindex fgcse-lm
13447 @item -fgcse-lm
13448 When @option{-fgcse-lm} is enabled, global common subexpression elimination
13449 attempts to move loads that are only killed by stores into themselves. This
13450 allows a loop containing a load/store sequence to be changed to a load outside
13451 the loop, and a copy/store within the loop.
13452
13453 Enabled by default when @option{-fgcse} is enabled.
13454
13455 @opindex fgcse-sm
13456 @item -fgcse-sm
13457 When @option{-fgcse-sm} is enabled, a store motion pass is run after
13458 global common subexpression elimination. This pass attempts to move
13459 stores out of loops. When used in conjunction with @option{-fgcse-lm},
13460 loops containing a load/store sequence can be changed to a load before
13461 the loop and a store after the loop.
13462
13463 Not enabled at any optimization level.
13464
13465 @opindex fgcse-las
13466 @item -fgcse-las
13467 When @option{-fgcse-las} is enabled, the global common subexpression
13468 elimination pass eliminates redundant loads that come after stores to the
13469 same memory location (both partial and full redundancies).
13470
13471 Not enabled at any optimization level.
13472
13473 @opindex fgcse-after-reload
13474 @item -fgcse-after-reload
13475 When @option{-fgcse-after-reload} is enabled, a redundant load elimination
13476 pass is performed after reload. The purpose of this pass is to clean up
13477 redundant spilling.
13478
13479 Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
13480
13481 @opindex faggressive-loop-optimizations
13482 @item -faggressive-loop-optimizations
13483 This option tells the loop optimizer to use language constraints to
13484 derive bounds for the number of iterations of a loop. This assumes that
13485 loop code does not invoke undefined behavior by for example causing signed
13486 integer overflows or out-of-bound array accesses. The bounds for the
13487 number of iterations of a loop are used to guide loop unrolling and peeling
13488 and loop exit test optimizations.
13489 This option is enabled by default.
13490
13491 @opindex funconstrained-commons
13492 @item -funconstrained-commons
13493 This option tells the compiler that variables declared in common blocks
13494 (e.g.@: Fortran) may later be overridden with longer trailing arrays. This
13495 prevents certain optimizations that depend on knowing the array bounds.
13496
13497 @opindex fcrossjumping
13498 @item -fcrossjumping
13499 Perform cross-jumping transformation.
13500 This transformation unifies equivalent code and saves code size. The
13501 resulting code may or may not perform better than without cross-jumping.
13502
13503 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13504
13505 @opindex fauto-inc-dec
13506 @item -fauto-inc-dec
13507 Combine increments or decrements of addresses with memory accesses.
13508 This pass is always skipped on architectures that do not have
13509 instructions to support this. Enabled by default at @option{-O1} and
13510 higher on architectures that support this.
13511
13512 @opindex fdce
13513 @item -fdce
13514 Perform dead code elimination (DCE) on RTL@.
13515 Enabled by default at @option{-O1} and higher.
13516
13517 @opindex fdse
13518 @item -fdse
13519 Perform dead store elimination (DSE) on RTL@.
13520 Enabled by default at @option{-O1} and higher.
13521
13522 @opindex fif-conversion
13523 @item -fif-conversion
13524 Attempt to transform conditional jumps into branch-less equivalents. This
13525 includes use of conditional moves, min, max, set flags and abs instructions, and
13526 some tricks doable by standard arithmetics. The use of conditional execution
13527 on chips where it is available is controlled by @option{-fif-conversion2}.
13528
13529 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
13530 not with @option{-Og}.
13531
13532 @opindex fif-conversion2
13533 @item -fif-conversion2
13534 Use conditional execution (where available) to transform conditional jumps into
13535 branch-less equivalents.
13536
13537 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
13538 not with @option{-Og}.
13539
13540 @opindex fdeclone-ctor-dtor
13541 @item -fdeclone-ctor-dtor
13542 The C++ ABI requires multiple entry points for constructors and
13543 destructors: one for a base subobject, one for a complete object, and
13544 one for a virtual destructor that calls operator delete afterwards.
13545 For a hierarchy with virtual bases, the base and complete variants are
13546 clones, which means two copies of the function. With this option, the
13547 base and complete variants are changed to be thunks that call a common
13548 implementation.
13549
13550 Enabled by @option{-Os}.
13551
13552 @opindex fdelete-null-pointer-checks
13553 @item -fdelete-null-pointer-checks
13554 Assume that programs cannot safely dereference null pointers, and that
13555 no code or data element resides at address zero.
13556 This option enables simple constant
13557 folding optimizations at all optimization levels. In addition, other
13558 optimization passes in GCC use this flag to control global dataflow
13559 analyses that eliminate useless checks for null pointers; these assume
13560 that a memory access to address zero always results in a trap, so
13561 that if a pointer is checked after it has already been dereferenced,
13562 it cannot be null.
13563
13564 Note however that in some environments this assumption is not true.
13565 Use @option{-fno-delete-null-pointer-checks} to disable this optimization
13566 for programs that depend on that behavior.
13567
13568 This option is enabled by default on most targets.
13569 On AVR and MSP430, this option is completely disabled.
13570
13571 Passes that use the dataflow information
13572 are enabled independently at different optimization levels.
13573
13574 @opindex fdevirtualize
13575 @item -fdevirtualize
13576 Attempt to convert calls to virtual functions to direct calls. This
13577 is done both within a procedure and interprocedurally as part of
13578 indirect inlining (@option{-findirect-inlining}) and interprocedural constant
13579 propagation (@option{-fipa-cp}).
13580 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13581
13582 @opindex fdevirtualize-speculatively
13583 @item -fdevirtualize-speculatively
13584 Attempt to convert calls to virtual functions to speculative direct calls.
13585 Based on the analysis of the type inheritance graph, determine for a given call
13586 the set of likely targets. If the set is small, preferably of size 1, change
13587 the call into a conditional deciding between direct and indirect calls. The
13588 speculative calls enable more optimizations, such as inlining. When they seem
13589 useless after further optimization, they are converted back into original form.
13590
13591 @opindex fdevirtualize-at-ltrans
13592 @item -fdevirtualize-at-ltrans
13593 Stream extra information needed for aggressive devirtualization when running
13594 the link-time optimizer in local transformation mode.
13595 This option enables more devirtualization but
13596 significantly increases the size of streamed data. For this reason it is
13597 disabled by default.
13598
13599 @opindex fexpensive-optimizations
13600 @item -fexpensive-optimizations
13601 Perform a number of minor optimizations that are relatively expensive.
13602
13603 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13604
13605 @opindex free
13606 @item -free
13607 Attempt to remove redundant extension instructions. This is especially
13608 helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
13609 registers after writing to their lower 32-bit half.
13610
13611 Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at
13612 levels @option{-O2}, @option{-O3}, @option{-Os}.
13613
13614 @opindex fno-lifetime-dse
13615 @opindex flifetime-dse
13616 @item -fno-lifetime-dse
13617 In C++ the value of an object is only affected by changes within its
13618 lifetime: when the constructor begins, the object has an indeterminate
13619 value, and any changes during the lifetime of the object are dead when
13620 the object is destroyed. Normally dead store elimination will take
13621 advantage of this; if your code relies on the value of the object
13622 storage persisting beyond the lifetime of the object, you can use this
13623 flag to disable this optimization. To preserve stores before the
13624 constructor starts (e.g.@: because your operator new clears the object
13625 storage) but still treat the object as dead after the destructor, you
13626 can use @option{-flifetime-dse=1}. The default behavior can be
13627 explicitly selected with @option{-flifetime-dse=2}.
13628 @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
13629
13630 @opindex flive-range-shrinkage
13631 @item -flive-range-shrinkage
13632 Attempt to decrease register pressure through register live range
13633 shrinkage. This is helpful for fast processors with small or moderate
13634 size register sets.
13635
13636 @opindex fira-algorithm
13637 @item -fira-algorithm=@var{algorithm}
13638 Use the specified coloring algorithm for the integrated register
13639 allocator. The @var{algorithm} argument can be @samp{priority}, which
13640 specifies Chow's priority coloring, or @samp{CB}, which specifies
13641 Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
13642 for all architectures, but for those targets that do support it, it is
13643 the default because it generates better code.
13644
13645 @opindex fira-region
13646 @item -fira-region=@var{region}
13647 Use specified regions for the integrated register allocator. The
13648 @var{region} argument should be one of the following:
13649
13650 @table @samp
13651
13652 @item all
13653 Use all loops as register allocation regions.
13654 This can give the best results for machines with a small and/or
13655 irregular register set.
13656
13657 @item mixed
13658 Use all loops except for loops with small register pressure
13659 as the regions. This value usually gives
13660 the best results in most cases and for most architectures,
13661 and is enabled by default when compiling with optimization for speed
13662 (@option{-O}, @option{-O2}, @dots{}).
13663
13664 @item one
13665 Use all functions as a single region.
13666 This typically results in the smallest code size, and is enabled by default for
13667 @option{-Os} or @option{-O0}.
13668
13669 @end table
13670
13671 @opindex fira-hoist-pressure
13672 @item -fira-hoist-pressure
13673 Use IRA to evaluate register pressure in the code hoisting pass for
13674 decisions to hoist expressions. This option usually results in smaller
13675 code, but it can slow the compiler down.
13676
13677 This option is enabled at level @option{-Os} for all targets.
13678
13679 @opindex fira-loop-pressure
13680 @item -fira-loop-pressure
13681 Use IRA to evaluate register pressure in loops for decisions to move
13682 loop invariants. This option usually results in generation
13683 of faster and smaller code on machines with large register files (>= 32
13684 registers), but it can slow the compiler down.
13685
13686 This option is enabled at level @option{-O3} for some targets.
13687
13688 @opindex fno-ira-share-save-slots
13689 @opindex fira-share-save-slots
13690 @item -fno-ira-share-save-slots
13691 Disable sharing of stack slots used for saving call-used hard
13692 registers living through a call. Each hard register gets a
13693 separate stack slot, and as a result function stack frames are
13694 larger.
13695
13696 @opindex fno-ira-share-spill-slots
13697 @opindex fira-share-spill-slots
13698 @item -fno-ira-share-spill-slots
13699 Disable sharing of stack slots allocated for pseudo-registers. Each
13700 pseudo-register that does not get a hard register gets a separate
13701 stack slot, and as a result function stack frames are larger.
13702
13703 @opindex flra-remat
13704 @item -flra-remat
13705 Enable CFG-sensitive rematerialization in LRA. Instead of loading
13706 values of spilled pseudos, LRA tries to rematerialize (recalculate)
13707 values if it is profitable.
13708
13709 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13710
13711 @opindex fdelayed-branch
13712 @item -fdelayed-branch
13713 If supported for the target machine, attempt to reorder instructions
13714 to exploit instruction slots available after delayed branch
13715 instructions.
13716
13717 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
13718 but not at @option{-Og}.
13719
13720 @opindex fschedule-insns
13721 @item -fschedule-insns
13722 If supported for the target machine, attempt to reorder instructions to
13723 eliminate execution stalls due to required data being unavailable. This
13724 helps machines that have slow floating point or memory load instructions
13725 by allowing other instructions to be issued until the result of the load
13726 or floating-point instruction is required.
13727
13728 Conventionally enabled at optimization levels @option{-O2} and @option{-O3}.
13729 However, many targets override this behavior. For example, on x86, it is
13730 disabled at all levels, while on AArch64, it is enabled only at @option{-O3}.
13731
13732 @opindex fschedule-insns2
13733 @item -fschedule-insns2
13734 Similar to @option{-fschedule-insns}, but requests an additional pass of
13735 instruction scheduling after register allocation has been done. This is
13736 especially useful on machines with a relatively small number of
13737 registers and where memory load instructions take more than one cycle.
13738
13739 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13740
13741 @opindex fno-sched-interblock
13742 @opindex fsched-interblock
13743 @item -fno-sched-interblock
13744 Disable instruction scheduling across basic blocks, which
13745 is normally enabled when scheduling before register allocation, i.e.@:
13746 with @option{-fschedule-insns} or at @option{-O2} or higher.
13747
13748 @opindex fno-sched-spec
13749 @opindex fsched-spec
13750 @item -fno-sched-spec
13751 Disable speculative motion of non-load instructions, which
13752 is normally enabled when scheduling before register allocation, i.e.@:
13753 with @option{-fschedule-insns} or at @option{-O2} or higher.
13754
13755 @opindex fsched-pressure
13756 @item -fsched-pressure
13757 Enable register pressure sensitive insn scheduling before register
13758 allocation. This only makes sense when scheduling before register
13759 allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
13760 @option{-O2} or higher. Usage of this option can improve the
13761 generated code and decrease its size by preventing register pressure
13762 increase above the number of available hard registers and subsequent
13763 spills in register allocation.
13764
13765 @opindex fsched-spec-load
13766 @item -fsched-spec-load
13767 Allow speculative motion of some load instructions. This only makes
13768 sense when scheduling before register allocation, i.e.@: with
13769 @option{-fschedule-insns} or at @option{-O2} or higher.
13770
13771 @opindex fsched-spec-load-dangerous
13772 @item -fsched-spec-load-dangerous
13773 Allow speculative motion of more load instructions. This only makes
13774 sense when scheduling before register allocation, i.e.@: with
13775 @option{-fschedule-insns} or at @option{-O2} or higher.
13776
13777 @opindex fsched-stalled-insns
13778 @item -fsched-stalled-insns
13779 @itemx -fsched-stalled-insns=@var{n}
13780 Define how many insns (if any) can be moved prematurely from the queue
13781 of stalled insns into the ready list during the second scheduling pass.
13782 @option{-fno-sched-stalled-insns} means that no insns are moved
13783 prematurely, @option{-fsched-stalled-insns=0} means there is no limit
13784 on how many queued insns can be moved prematurely.
13785 @option{-fsched-stalled-insns} without a value is equivalent to
13786 @option{-fsched-stalled-insns=1}.
13787
13788 @opindex fsched-stalled-insns-dep
13789 @item -fsched-stalled-insns-dep
13790 @itemx -fsched-stalled-insns-dep=@var{n}
13791 Define how many insn groups (cycles) are examined for a dependency
13792 on a stalled insn that is a candidate for premature removal from the queue
13793 of stalled insns. This has an effect only during the second scheduling pass,
13794 and only if @option{-fsched-stalled-insns} is used.
13795 @option{-fno-sched-stalled-insns-dep} is equivalent to
13796 @option{-fsched-stalled-insns-dep=0}.
13797 @option{-fsched-stalled-insns-dep} without a value is equivalent to
13798 @option{-fsched-stalled-insns-dep=1}.
13799
13800 @opindex fsched2-use-superblocks
13801 @item -fsched2-use-superblocks
13802 When scheduling after register allocation, use superblock scheduling.
13803 This allows motion across basic block boundaries,
13804 resulting in faster schedules. This option is experimental, as not all machine
13805 descriptions used by GCC model the CPU closely enough to avoid unreliable
13806 results from the algorithm.
13807
13808 This only makes sense when scheduling after register allocation, i.e.@: with
13809 @option{-fschedule-insns2} or at @option{-O2} or higher.
13810
13811 @opindex fsched-group-heuristic
13812 @item -fsched-group-heuristic
13813 Enable the group heuristic in the scheduler. This heuristic favors
13814 the instruction that belongs to a schedule group. This is enabled
13815 by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
13816 or @option{-fschedule-insns2} or at @option{-O2} or higher.
13817
13818 @opindex fsched-critical-path-heuristic
13819 @item -fsched-critical-path-heuristic
13820 Enable the critical-path heuristic in the scheduler. This heuristic favors
13821 instructions on the critical path. This is enabled by default when
13822 scheduling is enabled, i.e.@: with @option{-fschedule-insns}
13823 or @option{-fschedule-insns2} or at @option{-O2} or higher.
13824
13825 @opindex fsched-spec-insn-heuristic
13826 @item -fsched-spec-insn-heuristic
13827 Enable the speculative instruction heuristic in the scheduler. This
13828 heuristic favors speculative instructions with greater dependency weakness.
13829 This is enabled by default when scheduling is enabled, i.e.@:
13830 with @option{-fschedule-insns} or @option{-fschedule-insns2}
13831 or at @option{-O2} or higher.
13832
13833 @opindex fsched-rank-heuristic
13834 @item -fsched-rank-heuristic
13835 Enable the rank heuristic in the scheduler. This heuristic favors
13836 the instruction belonging to a basic block with greater size or frequency.
13837 This is enabled by default when scheduling is enabled, i.e.@:
13838 with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13839 at @option{-O2} or higher.
13840
13841 @opindex fsched-last-insn-heuristic
13842 @item -fsched-last-insn-heuristic
13843 Enable the last-instruction heuristic in the scheduler. This heuristic
13844 favors the instruction that is less dependent on the last instruction
13845 scheduled. This is enabled by default when scheduling is enabled,
13846 i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13847 at @option{-O2} or higher.
13848
13849 @opindex fsched-dep-count-heuristic
13850 @item -fsched-dep-count-heuristic
13851 Enable the dependent-count heuristic in the scheduler. This heuristic
13852 favors the instruction that has more instructions depending on it.
13853 This is enabled by default when scheduling is enabled, i.e.@:
13854 with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13855 at @option{-O2} or higher.
13856
13857 @opindex freschedule-modulo-scheduled-loops
13858 @item -freschedule-modulo-scheduled-loops
13859 Modulo scheduling is performed before traditional scheduling. If a loop
13860 is modulo scheduled, later scheduling passes may change its schedule.
13861 Use this option to control that behavior.
13862
13863 @opindex fselective-scheduling
13864 @item -fselective-scheduling
13865 Schedule instructions using selective scheduling algorithm. Selective
13866 scheduling runs instead of the first scheduler pass.
13867
13868 @opindex fselective-scheduling2
13869 @item -fselective-scheduling2
13870 Schedule instructions using selective scheduling algorithm. Selective
13871 scheduling runs instead of the second scheduler pass.
13872
13873 @opindex fsel-sched-pipelining
13874 @item -fsel-sched-pipelining
13875 Enable software pipelining of innermost loops during selective scheduling.
13876 This option has no effect unless one of @option{-fselective-scheduling} or
13877 @option{-fselective-scheduling2} is turned on.
13878
13879 @opindex fsel-sched-pipelining-outer-loops
13880 @item -fsel-sched-pipelining-outer-loops
13881 When pipelining loops during selective scheduling, also pipeline outer loops.
13882 This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
13883
13884 @opindex fsemantic-interposition
13885 @item -fsemantic-interposition
13886 Some object formats, like ELF, allow interposing of symbols by the
13887 dynamic linker.
13888 This means that for symbols exported from the DSO, the compiler cannot perform
13889 interprocedural propagation, inlining and other optimizations in anticipation
13890 that the function or variable in question may change. While this feature is
13891 useful, for example, to rewrite memory allocation functions by a debugging
13892 implementation, it is expensive in the terms of code quality.
13893 With @option{-fno-semantic-interposition} the compiler assumes that
13894 if interposition happens for functions the overwriting function will have
13895 precisely the same semantics (and side effects).
13896 Similarly if interposition happens
13897 for variables, the constructor of the variable will be the same. The flag
13898 has no effect for functions explicitly declared inline
13899 (where it is never allowed for interposition to change semantics)
13900 and for symbols explicitly declared weak.
13901
13902 @opindex fshrink-wrap
13903 @item -fshrink-wrap
13904 Emit function prologues only before parts of the function that need it,
13905 rather than at the top of the function. This flag is enabled by default at
13906 @option{-O} and higher.
13907
13908 @opindex fshrink-wrap-separate
13909 @item -fshrink-wrap-separate
13910 Shrink-wrap separate parts of the prologue and epilogue separately, so that
13911 those parts are only executed when needed.
13912 This option is on by default, but has no effect unless @option{-fshrink-wrap}
13913 is also turned on and the target supports this.
13914
13915 @opindex fcaller-saves
13916 @item -fcaller-saves
13917 Enable allocation of values to registers that are clobbered by
13918 function calls, by emitting extra instructions to save and restore the
13919 registers around such calls. Such allocation is done only when it
13920 seems to result in better code.
13921
13922 This option is always enabled by default on certain machines, usually
13923 those which have no call-preserved registers to use instead.
13924
13925 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13926
13927 @opindex fcombine-stack-adjustments
13928 @item -fcombine-stack-adjustments
13929 Tracks stack adjustments (pushes and pops) and stack memory references
13930 and then tries to find ways to combine them.
13931
13932 Enabled by default at @option{-O1} and higher.
13933
13934 @opindex fipa-ra
13935 @item -fipa-ra
13936 Use caller save registers for allocation if those registers are not used by
13937 any called function. In that case it is not necessary to save and restore
13938 them around calls. This is only possible if called functions are part of
13939 same compilation unit as current function and they are compiled before it.
13940
13941 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
13942 is disabled if generated code will be instrumented for profiling
13943 (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
13944 exactly (this happens on targets that do not expose prologues
13945 and epilogues in RTL).
13946
13947 @opindex fconserve-stack
13948 @item -fconserve-stack
13949 Attempt to minimize stack usage. The compiler attempts to use less
13950 stack space, even if that makes the program slower. This option
13951 implies setting the @option{large-stack-frame} parameter to 100
13952 and the @option{large-stack-frame-growth} parameter to 400.
13953
13954 @opindex ftree-reassoc
13955 @item -ftree-reassoc
13956 Perform reassociation on trees. This flag is enabled by default
13957 at @option{-O1} and higher.
13958
13959 @opindex fcode-hoisting
13960 @item -fcode-hoisting
13961 Perform code hoisting. Code hoisting tries to move the
13962 evaluation of expressions executed on all paths to the function exit
13963 as early as possible. This is especially useful as a code size
13964 optimization, but it often helps for code speed as well.
13965 This flag is enabled by default at @option{-O2} and higher.
13966
13967 @opindex ftree-pre
13968 @item -ftree-pre
13969 Perform partial redundancy elimination (PRE) on trees. This flag is
13970 enabled by default at @option{-O2} and @option{-O3}.
13971
13972 @opindex ftree-partial-pre
13973 @item -ftree-partial-pre
13974 Make partial redundancy elimination (PRE) more aggressive. This flag is
13975 enabled by default at @option{-O3}.
13976
13977 @opindex ftree-forwprop
13978 @item -ftree-forwprop
13979 Perform forward propagation on trees. This flag is enabled by default
13980 at @option{-O1} and higher.
13981
13982 @opindex ftree-fre
13983 @item -ftree-fre
13984 Perform full redundancy elimination (FRE) on trees. The difference
13985 between FRE and PRE is that FRE only considers expressions
13986 that are computed on all paths leading to the redundant computation.
13987 This analysis is faster than PRE, though it exposes fewer redundancies.
13988 This flag is enabled by default at @option{-O1} and higher.
13989
13990 @opindex ftree-phiprop
13991 @item -ftree-phiprop
13992 Perform hoisting of loads from conditional pointers on trees. This
13993 pass is enabled by default at @option{-O1} and higher.
13994
13995 @opindex fhoist-adjacent-loads
13996 @item -fhoist-adjacent-loads
13997 Speculatively hoist loads from both branches of an if-then-else if the
13998 loads are from adjacent locations in the same structure and the target
13999 architecture has a conditional move instruction. This flag is enabled
14000 by default at @option{-O2} and higher.
14001
14002 @opindex ftree-copy-prop
14003 @item -ftree-copy-prop
14004 Perform copy propagation on trees. This pass eliminates unnecessary
14005 copy operations. This flag is enabled by default at @option{-O1} and
14006 higher.
14007
14008 @opindex fipa-pure-const
14009 @item -fipa-pure-const
14010 Discover which functions are pure or constant.
14011 Enabled by default at @option{-O1} and higher.
14012
14013 @opindex fipa-reference
14014 @item -fipa-reference
14015 Discover which static variables do not escape the
14016 compilation unit.
14017 Enabled by default at @option{-O1} and higher.
14018
14019 @opindex fipa-reference-addressable
14020 @item -fipa-reference-addressable
14021 Discover read-only, write-only and non-addressable static variables.
14022 Enabled by default at @option{-O1} and higher.
14023
14024 @opindex fipa-reorder-for-locality
14025 @item -fipa-reorder-for-locality
14026 Group call chains close together in the binary layout to improve code
14027 locality and minimize jump distances between frequently called functions.
14028 Unlike @option{-freorder-functions} this pass considers the call
14029 chains between functions and groups them together, rather than grouping all
14030 hot/normal/cold/never-executed functions into separate sections.
14031 Unlike @option{-fprofile-reorder-functions} it aims to improve code locality
14032 throughout the runtime of the program rather than focusing on program startup.
14033 This option is incompatible with an explicit
14034 @option{-flto-partition=} option since it enforces a custom partitioning
14035 scheme.
14036 If using this option it is recommended to also use profile feedback, but this
14037 option is not enabled by default otherwise.
14038
14039 @opindex fipa-stack-alignment
14040 @item -fipa-stack-alignment
14041 Reduce stack alignment on call sites if possible.
14042 Enabled by default.
14043
14044 @opindex fipa-pta
14045 @item -fipa-pta
14046 Perform interprocedural pointer analysis and interprocedural modification
14047 and reference analysis. This option can cause excessive memory and
14048 compile-time usage on large compilation units. It is not enabled by
14049 default at any optimization level.
14050
14051 @opindex fipa-profile
14052 @item -fipa-profile
14053 Perform interprocedural profile propagation. The functions called only from
14054 cold functions are marked as cold. Also functions executed once (such as
14055 @code{cold}, @code{noreturn}, static constructors or destructors) are
14056 identified. Cold functions and loop less parts of functions executed once are
14057 then optimized for size.
14058 Enabled by default at @option{-O1} and higher.
14059
14060 @opindex fipa-modref
14061 @item -fipa-modref
14062 Perform interprocedural mod/ref analysis. This optimization analyzes the side
14063 effects of functions (memory locations that are modified or referenced) and
14064 enables better optimization across the function call boundary. This flag is
14065 enabled by default at @option{-O1} and higher.
14066
14067 @opindex fipa-cp
14068 @item -fipa-cp
14069 Perform interprocedural constant propagation.
14070 This optimization analyzes the program to determine when values passed
14071 to functions are constants and then optimizes accordingly.
14072 This optimization can substantially increase performance
14073 if the application has constants passed to functions.
14074 This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
14075 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14076
14077 @opindex fipa-cp-clone
14078 @item -fipa-cp-clone
14079 Perform function cloning to make interprocedural constant propagation stronger.
14080 When enabled, interprocedural constant propagation performs function cloning
14081 when externally visible function can be called with constant arguments.
14082 Because this optimization can create multiple copies of functions,
14083 it may significantly increase code size
14084 (see @option{--param ipa-cp-unit-growth=@var{value}}).
14085 This flag is enabled by default at @option{-O3}.
14086 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14087
14088 @opindex fipa-bit-cp
14089 @item -fipa-bit-cp
14090 When enabled, perform interprocedural bitwise constant
14091 propagation. This flag is enabled by default at @option{-O2} and
14092 by @option{-fprofile-use} and @option{-fauto-profile}.
14093 It requires that @option{-fipa-cp} is enabled.
14094
14095 @opindex fipa-vrp
14096 @item -fipa-vrp
14097 When enabled, perform interprocedural propagation of value
14098 ranges. This flag is enabled by default at @option{-O2}. It requires
14099 that @option{-fipa-cp} is enabled.
14100
14101 @opindex fipa-icf
14102 @item -fipa-icf
14103 Perform Identical Code Folding for functions and read-only variables.
14104 The optimization reduces code size and may disturb unwind stacks by replacing
14105 a function by equivalent one with a different name. The optimization works
14106 more effectively with link-time optimization enabled.
14107
14108 Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
14109 works on different levels and thus the optimizations are not same - there are
14110 equivalences that are found only by GCC and equivalences found only by Gold.
14111
14112 This flag is enabled by default at @option{-O2} and @option{-Os}.
14113
14114 @opindex flate-combine-instructions
14115 @item -flate-combine-instructions
14116 Enable two instruction combination passes that run relatively late in the
14117 compilation process. One of the passes runs before register allocation and
14118 the other after register allocation. The main aim of the passes is to
14119 substitute definitions into all uses.
14120
14121 Most targets enable this flag by default at @option{-O2} and @option{-Os}.
14122
14123 @opindex flive-patching
14124 @item -flive-patching=@var{level}
14125 Control GCC's optimizations to produce output suitable for live-patching.
14126
14127 If the compiler's optimization uses a function's body or information extracted
14128 from its body to optimize/change another function, the latter is called an
14129 impacted function of the former. If a function is patched, its impacted
14130 functions should be patched too.
14131
14132 The impacted functions are determined by the compiler's interprocedural
14133 optimizations. For example, a caller is impacted when inlining a function
14134 into its caller,
14135 cloning a function and changing its caller to call this new clone,
14136 or extracting a function's pureness/constness information to optimize
14137 its direct or indirect callers, etc.
14138
14139 Usually, the more IPA optimizations enabled, the larger the number of
14140 impacted functions for each function. In order to control the number of
14141 impacted functions and more easily compute the list of impacted function,
14142 IPA optimizations can be partially enabled at two different levels.
14143
14144 The @var{level} argument should be one of the following:
14145
14146 @table @samp
14147
14148 @item inline-clone
14149
14150 Only enable inlining and cloning optimizations, which includes inlining,
14151 cloning, interprocedural scalar replacement of aggregates and partial inlining.
14152 As a result, when patching a function, all its callers and its clones'
14153 callers are impacted, therefore need to be patched as well.
14154
14155 @option{-flive-patching=inline-clone} disables the following optimization flags:
14156 @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra
14157 -fipa-icf -fipa-icf-functions -fipa-icf-variables
14158 -fipa-bit-cp -fipa-vrp -fipa-pure-const
14159 -fipa-reference-addressable
14160 -fipa-stack-alignment -fipa-modref}
14161
14162 @item inline-only-static
14163
14164 Only enable inlining of static functions.
14165 As a result, when patching a static function, all its callers are impacted
14166 and so need to be patched as well.
14167
14168 In addition to all the flags that @option{-flive-patching=inline-clone}
14169 disables,
14170 @option{-flive-patching=inline-only-static} disables the following additional
14171 optimization flags:
14172 @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
14173
14174 @end table
14175
14176 When @option{-flive-patching} is specified without any value, the default value
14177 is @var{inline-clone}.
14178
14179 This flag is disabled by default.
14180
14181 Note that @option{-flive-patching} is not supported with link-time optimization
14182 (@option{-flto}).
14183
14184 @opindex fisolate-erroneous-paths-dereference
14185 @item -fisolate-erroneous-paths-dereference
14186 Detect paths that trigger erroneous or undefined behavior due to
14187 dereferencing a null pointer. Isolate those paths from the main control
14188 flow and turn the statement with erroneous or undefined behavior into a trap.
14189 This flag is enabled by default at @option{-O2} and higher and depends on
14190 @option{-fdelete-null-pointer-checks} also being enabled.
14191
14192 @opindex fisolate-erroneous-paths-attribute
14193 @item -fisolate-erroneous-paths-attribute
14194 Detect paths that trigger erroneous or undefined behavior due to a null value
14195 being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
14196 attribute. Isolate those paths from the main control flow and turn the
14197 statement with erroneous or undefined behavior into a trap. This is not
14198 currently enabled, but may be enabled by @option{-O2} in the future.
14199
14200 @opindex ftree-sink
14201 @item -ftree-sink
14202 Perform forward store motion on trees. This flag is
14203 enabled by default at @option{-O1} and higher.
14204
14205 @opindex ftree-bit-ccp
14206 @item -ftree-bit-ccp
14207 Perform sparse conditional bit constant propagation on trees and propagate
14208 pointer alignment information.
14209 This pass only operates on local scalar variables and is enabled by default
14210 at @option{-O1} and higher, except for @option{-Og}.
14211 It requires that @option{-ftree-ccp} is enabled.
14212
14213 @opindex ftree-ccp
14214 @item -ftree-ccp
14215 Perform sparse conditional constant propagation (CCP) on trees. This
14216 pass only operates on local scalar variables and is enabled by default
14217 at @option{-O1} and higher.
14218
14219 @opindex fssa-backprop
14220 @item -fssa-backprop
14221 Propagate information about uses of a value up the definition chain
14222 in order to simplify the definitions. For example, this pass strips
14223 sign operations if the sign of a value never matters. The flag is
14224 enabled by default at @option{-O1} and higher.
14225
14226 @opindex fssa-phiopt
14227 @item -fssa-phiopt
14228 Perform pattern matching on SSA PHI nodes to optimize conditional
14229 code. This pass is enabled by default at @option{-O1} and higher,
14230 except for @option{-Og}.
14231
14232 @opindex ftree-switch-conversion
14233 @item -ftree-switch-conversion
14234 Perform conversion of simple initializations in a switch to
14235 initializations from a scalar array. This flag is enabled by default
14236 at @option{-O2} and higher.
14237
14238 @opindex ftree-tail-merge
14239 @item -ftree-tail-merge
14240 Look for identical code sequences. When found, replace one with a jump to the
14241 other. This optimization is known as tail merging or cross jumping. This flag
14242 is enabled by default at @option{-O2} and higher. The compilation time
14243 in this pass can
14244 be limited using @option{max-tail-merge-comparisons} parameter and
14245 @option{max-tail-merge-iterations} parameter.
14246
14247 @opindex ftree-cselim
14248 @item -ftree-cselim
14249 Perform conditional store elimination on trees. This flag is enabled by
14250 default at @option{-O1} and higher on targets that have conditional
14251 move instructions.
14252
14253 @opindex ftree-dce
14254 @item -ftree-dce
14255 Perform dead code elimination (DCE) on trees. This flag is enabled by
14256 default at @option{-O1} and higher.
14257
14258 @opindex ftree-builtin-call-dce
14259 @item -ftree-builtin-call-dce
14260 Perform conditional dead code elimination (DCE) for calls to built-in functions
14261 that may set @code{errno} but are otherwise free of side effects. This flag is
14262 enabled by default at @option{-O2} and higher if @option{-Os} is not also
14263 specified.
14264
14265 @opindex ffinite-loops
14266 @opindex fno-finite-loops
14267 @item -ffinite-loops
14268 Assume that a loop with an exit will eventually take the exit and not loop
14269 indefinitely. This allows the compiler to remove loops that otherwise have
14270 no side-effects, not considering eventual endless looping as such.
14271
14272 This option is enabled by default at @option{-O2} for C++ with -std=c++11
14273 or higher.
14274
14275 @opindex ftree-dominator-opts
14276 @item -ftree-dominator-opts
14277 Perform a variety of simple scalar cleanups (constant/copy
14278 propagation, redundancy elimination, range propagation and expression
14279 simplification) based on a dominator tree traversal. This also
14280 performs jump threading (to reduce jumps to jumps). This flag is
14281 enabled by default at @option{-O1} and higher.
14282
14283 @opindex ftree-dse
14284 @item -ftree-dse
14285 Perform dead store elimination (DSE) on trees. A dead store is a store into
14286 a memory location that is later overwritten by another store without
14287 any intervening loads. In this case the earlier store can be deleted. This
14288 flag is enabled by default at @option{-O1} and higher.
14289
14290 @opindex ftree-ch
14291 @item -ftree-ch
14292 Perform loop header copying on trees. This is beneficial since it increases
14293 effectiveness of code motion optimizations. It also saves one jump. This flag
14294 is enabled by default at @option{-O1} and higher. It is not enabled
14295 for @option{-Os}, since it usually increases code size.
14296
14297 @opindex ftree-loop-optimize
14298 @item -ftree-loop-optimize
14299 Perform loop optimizations on trees. This flag is enabled by default
14300 at @option{-O1} and higher.
14301
14302 @opindex ftree-loop-linear
14303 @opindex floop-strip-mine
14304 @opindex floop-block
14305 @item -ftree-loop-linear
14306 @itemx -floop-strip-mine
14307 @itemx -floop-block
14308 Perform loop nest optimizations. Same as
14309 @option{-floop-nest-optimize}. To use this code transformation, GCC has
14310 to be configured with @option{--with-isl} to enable the Graphite loop
14311 transformation infrastructure.
14312
14313 @opindex fgraphite-identity
14314 @item -fgraphite-identity
14315 Enable the identity transformation for graphite. For every SCoP we generate
14316 the polyhedral representation and transform it back to gimple. Using
14317 @option{-fgraphite-identity} we can check the costs or benefits of the
14318 GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
14319 are also performed by the code generator isl, like index splitting and
14320 dead code elimination in loops.
14321
14322 @opindex floop-nest-optimize
14323 @item -floop-nest-optimize
14324 Enable the isl based loop nest optimizer. This is a generic loop nest
14325 optimizer based on the Pluto optimization algorithms. It calculates a loop
14326 structure optimized for data-locality and parallelism. This option
14327 is experimental.
14328
14329 @opindex floop-parallelize-all
14330 @item -floop-parallelize-all
14331 Use the Graphite data dependence analysis to identify loops that can
14332 be parallelized. Parallelize all the loops that can be analyzed to
14333 not contain loop carried dependences without checking that it is
14334 profitable to parallelize the loops.
14335
14336 @opindex ftree-coalesce-vars
14337 @item -ftree-coalesce-vars
14338 While transforming the program out of the SSA representation, attempt to
14339 reduce copying by coalescing versions of different user-defined
14340 variables, instead of just compiler temporaries. This may severely
14341 limit the ability to debug an optimized program compiled with
14342 @option{-fno-var-tracking-assignments}. In the negated form, this flag
14343 prevents SSA coalescing of user variables. This option is enabled by
14344 default if optimization is enabled, and it does very little otherwise.
14345
14346 @opindex ftree-loop-if-convert
14347 @item -ftree-loop-if-convert
14348 Attempt to transform conditional jumps in the innermost loops to
14349 branch-less equivalents. The intent is to remove control-flow from
14350 the innermost loops in order to improve the ability of the
14351 vectorization pass to handle these loops. This is enabled by default
14352 if vectorization is enabled.
14353
14354 @opindex ftree-loop-distribution
14355 @item -ftree-loop-distribution
14356 Perform loop distribution. This flag can improve cache performance on
14357 big loop bodies and allow further loop optimizations, like
14358 parallelization or vectorization, to take place. For example, the loop
14359 @smallexample
14360 DO I = 1, N
14361 A(I) = B(I) + C
14362 D(I) = E(I) * F
14363 ENDDO
14364 @end smallexample
14365 is transformed to
14366 @smallexample
14367 DO I = 1, N
14368 A(I) = B(I) + C
14369 ENDDO
14370 DO I = 1, N
14371 D(I) = E(I) * F
14372 ENDDO
14373 @end smallexample
14374 This flag is enabled by default at @option{-O3}.
14375 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14376
14377 @opindex ftree-loop-distribute-patterns
14378 @item -ftree-loop-distribute-patterns
14379 Perform loop distribution of patterns that can be code generated with
14380 calls to a library. This flag is enabled by default at @option{-O2} and
14381 higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
14382
14383 This pass distributes the initialization loops and generates a call to
14384 memset zero. For example, the loop
14385 @smallexample
14386 DO I = 1, N
14387 A(I) = 0
14388 B(I) = A(I) + I
14389 ENDDO
14390 @end smallexample
14391 is transformed to
14392 @smallexample
14393 DO I = 1, N
14394 A(I) = 0
14395 ENDDO
14396 DO I = 1, N
14397 B(I) = A(I) + I
14398 ENDDO
14399 @end smallexample
14400 and the initialization loop is transformed into a call to memset zero.
14401
14402 @opindex floop-interchange
14403 @item -floop-interchange
14404 Perform loop interchange outside of graphite. This flag can improve cache
14405 performance on loop nest and allow further loop optimizations, like
14406 vectorization, to take place. For example, the loop
14407 @smallexample
14408 for (int i = 0; i < N; i++)
14409 for (int j = 0; j < N; j++)
14410 for (int k = 0; k < N; k++)
14411 c[i][j] = c[i][j] + a[i][k]*b[k][j];
14412 @end smallexample
14413 is transformed to
14414 @smallexample
14415 for (int i = 0; i < N; i++)
14416 for (int k = 0; k < N; k++)
14417 for (int j = 0; j < N; j++)
14418 c[i][j] = c[i][j] + a[i][k]*b[k][j];
14419 @end smallexample
14420 This flag is enabled by default at @option{-O3}.
14421 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14422
14423 @opindex floop-unroll-and-jam
14424 @item -floop-unroll-and-jam
14425 Apply unroll and jam transformations on feasible loops. In a loop
14426 nest this unrolls the outer loop by some factor and fuses the resulting
14427 multiple inner loops. This flag is enabled by default at @option{-O3}.
14428 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14429
14430 @opindex ftree-loop-im
14431 @item -ftree-loop-im
14432 Perform loop invariant motion on trees. This pass moves only invariants that
14433 are hard to handle at RTL level (function calls, operations that expand to
14434 nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
14435 operands of conditions that are invariant out of the loop, so that we can use
14436 just trivial invariantness analysis in loop unswitching. The pass also includes
14437 store motion.
14438
14439 @opindex ftree-loop-ivcanon
14440 @item -ftree-loop-ivcanon
14441 Create a canonical counter for number of iterations in loops for which
14442 determining number of iterations requires complicated analysis. Later
14443 optimizations then may determine the number easily. Useful especially
14444 in connection with unrolling.
14445
14446 @opindex ftree-scev-cprop
14447 @item -ftree-scev-cprop
14448 Perform final value replacement. If a variable is modified in a loop
14449 in such a way that its value when exiting the loop can be determined using
14450 only its initial value and the number of loop iterations, replace uses of
14451 the final value by such a computation, provided it is sufficiently cheap.
14452 This reduces data dependencies and may allow further simplifications.
14453 Enabled by default at @option{-O1} and higher.
14454
14455 @opindex fivopts
14456 @item -fivopts
14457 Perform induction variable optimizations (strength reduction, induction
14458 variable merging and induction variable elimination) on trees.
14459 Enabled by default at @option{-O1} and higher.
14460
14461 @opindex ftree-parallelize-loops
14462 @item -ftree-parallelize-loops=n
14463 Parallelize loops, i.e., split their iteration space to run in n threads.
14464 This is only possible for loops whose iterations are independent
14465 and can be arbitrarily reordered. The optimization is only
14466 profitable on multiprocessor machines, for loops that are CPU-intensive,
14467 rather than constrained e.g.@: by memory bandwidth. This option
14468 implies @option{-pthread}, and thus is only supported on targets
14469 that have support for @option{-pthread}.
14470
14471 @opindex ftree-pta
14472 @item -ftree-pta
14473 Perform function-local points-to analysis on trees. This flag is
14474 enabled by default at @option{-O1} and higher, except for @option{-Og}.
14475
14476 @opindex ftree-sra
14477 @item -ftree-sra
14478 Perform scalar replacement of aggregates. This pass replaces structure
14479 references with scalars to prevent committing structures to memory too
14480 early. This flag is enabled by default at @option{-O1} and higher,
14481 except for @option{-Og}.
14482
14483 @opindex fstore-merging
14484 @item -fstore-merging
14485 Perform merging of narrow stores to consecutive memory addresses. This pass
14486 merges contiguous stores of immediate values narrower than a word into fewer
14487 wider stores to reduce the number of instructions. This is enabled by default
14488 at @option{-O2} and higher as well as @option{-Os}.
14489
14490 @opindex ftree-ter
14491 @item -ftree-ter
14492 Perform temporary expression replacement during the SSA->normal phase. Single
14493 use/single def temporaries are replaced at their use location with their
14494 defining expression. This results in non-GIMPLE code, but gives the expanders
14495 much more complex trees to work on resulting in better RTL generation. This is
14496 enabled by default at @option{-O1} and higher.
14497
14498 @opindex ftree-slsr
14499 @item -ftree-slsr
14500 Perform straight-line strength reduction on trees. This recognizes related
14501 expressions involving multiplications and replaces them by less expensive
14502 calculations when possible. This is enabled by default at @option{-O1} and
14503 higher.
14504
14505 @opindex ftree-vectorize
14506 @item -ftree-vectorize
14507 Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
14508 and @option{-ftree-slp-vectorize} if not explicitly specified.
14509
14510 @opindex ftree-loop-vectorize
14511 @item -ftree-loop-vectorize
14512 Perform loop vectorization on trees. This flag is enabled by default at
14513 @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
14514 and @option{-fauto-profile}.
14515
14516 @opindex ftree-slp-vectorize
14517 @item -ftree-slp-vectorize
14518 Perform basic block vectorization on trees. This flag is enabled by default at
14519 @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
14520 and @option{-fauto-profile}.
14521
14522 @opindex ftrivial-auto-var-init
14523 @item -ftrivial-auto-var-init=@var{choice}
14524 Initialize automatic variables with either a pattern or with zeroes to increase
14525 the security and predictability of a program by preventing uninitialized memory
14526 disclosure and use.
14527 GCC still considers an automatic variable that doesn't have an explicit
14528 initializer as uninitialized, @option{-Wuninitialized} and
14529 @option{-Wanalyzer-use-of-uninitialized-value} will still report
14530 warning messages on such automatic variables and the compiler will
14531 perform optimization as if the variable were uninitialized.
14532 With this option, GCC will also initialize any padding of automatic variables
14533 that have structure or union types to zeroes.
14534 However, the current implementation cannot initialize automatic variables that
14535 are declared between the controlling expression and the first case of a
14536 @code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
14537 such cases.
14538
14539 The three values of @var{choice} are:
14540
14541 @itemize @bullet
14542 @item
14543 @samp{uninitialized} doesn't initialize any automatic variables.
14544 This is C and C++'s default.
14545
14546 @item
14547 @samp{pattern} Initialize automatic variables with values which will likely
14548 transform logic bugs into crashes down the line, are easily recognized in a
14549 crash dump and without being values that programmers can rely on for useful
14550 program semantics.
14551 The current value is byte-repeatable pattern with byte "0xFE".
14552 The values used for pattern initialization might be changed in the future.
14553
14554 @item
14555 @samp{zero} Initialize automatic variables with zeroes.
14556 @end itemize
14557
14558 The default is @samp{uninitialized}.
14559
14560 Note that the initializer values, whether @samp{zero} or @samp{pattern},
14561 refer to data representation (in memory or machine registers), rather
14562 than to their interpretation as numerical values. This distinction may
14563 be important in languages that support types with biases or implicit
14564 multipliers, and with such extensions as @samp{hardbool} (@pxref{Type
14565 Attributes}). For example, a variable that uses 8 bits to represent
14566 (biased) quantities in the @code{range 160..400} will be initialized
14567 with the bit patterns @code{0x00} or @code{0xFE}, depending on
14568 @var{choice}, whether or not these representations stand for values in
14569 that range, and even if they do, the interpretation of the value held by
14570 the variable will depend on the bias. A @samp{hardbool} variable that
14571 uses say @code{0X5A} and @code{0xA5} for @code{false} and @code{true},
14572 respectively, will trap with either @samp{choice} of trivial
14573 initializer, i.e., @samp{zero} initialization will not convert to the
14574 representation for @code{false}, even if it would for a @code{static}
14575 variable of the same type. This means the initializer pattern doesn't
14576 generally depend on the type of the initialized variable. One notable
14577 exception is that (non-hardened) boolean variables that fit in registers
14578 are initialized with @code{false} (zero), even when @samp{pattern} is
14579 requested.
14580
14581 You can control this behavior for a specific variable by using the variable
14582 attribute @code{uninitialized} (@pxref{Variable Attributes}).
14583
14584 @opindex fvect-cost-model
14585 @item -fvect-cost-model=@var{model}
14586 Alter the cost model used for vectorization. The @var{model} argument
14587 should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
14588 @samp{very-cheap}.
14589 With the @samp{unlimited} model the vectorized code-path is assumed
14590 to be profitable while with the @samp{dynamic} model a runtime check
14591 guards the vectorized code-path to enable it only for iteration
14592 counts that will likely execute faster than when executing the original
14593 scalar loop. The @samp{cheap} model disables vectorization of
14594 loops where doing so would be cost prohibitive for example due to
14595 required runtime checks for data dependence or alignment but otherwise
14596 is equal to the @samp{dynamic} model. The @samp{very-cheap} model disables
14597 vectorization of loops when any runtime check for data dependence or alignment
14598 is required, it also disables vectorization of epilogue loops but otherwise is
14599 equal to the @samp{cheap} model.
14600
14601 The default cost model depends on other optimization flags and is
14602 either @samp{dynamic} or @samp{cheap}.
14603
14604 @opindex fsimd-cost-model
14605 @item -fsimd-cost-model=@var{model}
14606 Alter the cost model used for vectorization of loops marked with the OpenMP
14607 simd directive. The @var{model} argument should be one of
14608 @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
14609 have the same meaning as described in @option{-fvect-cost-model} and by
14610 default a cost model defined with @option{-fvect-cost-model} is used.
14611
14612 @opindex ftree-vrp
14613 @item -ftree-vrp
14614 Perform Value Range Propagation on trees. This is similar to the
14615 constant propagation pass, but instead of values, ranges of values are
14616 propagated. This allows the optimizers to remove unnecessary range
14617 checks like array bound checks and null pointer checks. This is
14618 enabled by default at @option{-O2} and higher. Null pointer check
14619 elimination is only done if @option{-fdelete-null-pointer-checks} is
14620 enabled.
14621
14622 @opindex fsplit-paths
14623 @item -fsplit-paths
14624 Split paths leading to loop backedges. This can improve dead code
14625 elimination and common subexpression elimination. This is enabled by
14626 default at @option{-O3} and above.
14627
14628 @opindex fsplit-ivs-in-unroller
14629 @item -fsplit-ivs-in-unroller
14630 Enables expression of values of induction variables in later iterations
14631 of the unrolled loop using the value in the first iteration. This breaks
14632 long dependency chains, thus improving efficiency of the scheduling passes.
14633
14634 A combination of @option{-fweb} and CSE is often sufficient to obtain the
14635 same effect. However, that is not reliable in cases where the loop body
14636 is more complicated than a single basic block. It also does not work at all
14637 on some architectures due to restrictions in the CSE pass.
14638
14639 This optimization is enabled by default.
14640
14641 @opindex fvariable-expansion-in-unroller
14642 @item -fvariable-expansion-in-unroller
14643 With this option, the compiler creates multiple copies of some
14644 local variables when unrolling a loop, which can result in superior code.
14645
14646 This optimization is enabled by default for PowerPC targets, but disabled
14647 by default otherwise.
14648
14649 @opindex fpartial-inlining
14650 @item -fpartial-inlining
14651 Inline parts of functions. This option has any effect only
14652 when inlining itself is turned on by the @option{-finline-functions}
14653 or @option{-finline-small-functions} options.
14654
14655 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14656
14657 @opindex fpredictive-commoning
14658 @item -fpredictive-commoning
14659 Perform predictive commoning optimization, i.e., reusing computations
14660 (especially memory loads and stores) performed in previous
14661 iterations of loops.
14662
14663 This option is enabled at level @option{-O3}.
14664 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14665
14666 @opindex fprefetch-loop-arrays
14667 @item -fprefetch-loop-arrays
14668 If supported by the target machine, generate instructions to prefetch
14669 memory to improve the performance of loops that access large arrays.
14670
14671 This option may generate better or worse code; results are highly
14672 dependent on the structure of loops within the source code.
14673
14674 Disabled at level @option{-Os}.
14675
14676 @opindex fno-printf-return-value
14677 @opindex fprintf-return-value
14678 @item -fno-printf-return-value
14679 Do not substitute constants for known return value of formatted output
14680 functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
14681 @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
14682 transformation allows GCC to optimize or even eliminate branches based
14683 on the known return value of these functions called with arguments that
14684 are either constant, or whose values are known to be in a range that
14685 makes determining the exact return value possible. For example, when
14686 @option{-fprintf-return-value} is in effect, both the branch and the
14687 body of the @code{if} statement (but not the call to @code{snprint})
14688 can be optimized away when @code{i} is a 32-bit or smaller integer
14689 because the return value is guaranteed to be at most 8.
14690
14691 @smallexample
14692 char buf[9];
14693 if (snprintf (buf, "%08x", i) >= sizeof buf)
14694 @dots{}
14695 @end smallexample
14696
14697 The @option{-fprintf-return-value} option relies on other optimizations
14698 and yields best results with @option{-O2} and above. It works in tandem
14699 with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
14700 options. The @option{-fprintf-return-value} option is enabled by default.
14701
14702 @opindex fno-peephole
14703 @opindex fpeephole
14704 @opindex fno-peephole2
14705 @opindex fpeephole2
14706 @item -fno-peephole
14707 @itemx -fno-peephole2
14708 Disable any machine-specific peephole optimizations. The difference
14709 between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
14710 are implemented in the compiler; some targets use one, some use the
14711 other, a few use both.
14712
14713 @option{-fpeephole} is enabled by default.
14714 @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14715
14716 @opindex fno-guess-branch-probability
14717 @opindex fguess-branch-probability
14718 @item -fno-guess-branch-probability
14719 Do not guess branch probabilities using heuristics.
14720
14721 GCC uses heuristics to guess branch probabilities if they are
14722 not provided by profiling feedback (@option{-fprofile-arcs}). These
14723 heuristics are based on the control flow graph. If some branch probabilities
14724 are specified by @code{__builtin_expect}, then the heuristics are
14725 used to guess branch probabilities for the rest of the control flow graph,
14726 taking the @code{__builtin_expect} info into account. The interactions
14727 between the heuristics and @code{__builtin_expect} can be complex, and in
14728 some cases, it may be useful to disable the heuristics so that the effects
14729 of @code{__builtin_expect} are easier to understand.
14730
14731 It is also possible to specify expected probability of the expression
14732 with @code{__builtin_expect_with_probability} built-in function.
14733
14734 The default is @option{-fguess-branch-probability} at levels
14735 @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
14736
14737 @opindex freorder-blocks
14738 @item -freorder-blocks
14739 Reorder basic blocks in the compiled function in order to reduce number of
14740 taken branches and improve code locality.
14741
14742 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14743
14744 @opindex freorder-blocks-algorithm
14745 @item -freorder-blocks-algorithm=@var{algorithm}
14746 Use the specified algorithm for basic block reordering. The
14747 @var{algorithm} argument can be @samp{simple}, which does not increase
14748 code size (except sometimes due to secondary effects like alignment),
14749 or @samp{stc}, the ``software trace cache'' algorithm, which tries to
14750 put all often executed code together, minimizing the number of branches
14751 executed by making extra copies of code.
14752
14753 The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
14754 @samp{stc} at levels @option{-O2}, @option{-O3}.
14755
14756 @opindex freorder-blocks-and-partition
14757 @item -freorder-blocks-and-partition
14758 In addition to reordering basic blocks in the compiled function, in order
14759 to reduce number of taken branches, partitions hot and cold basic blocks
14760 into separate sections of the assembly and @file{.o} files, to improve
14761 paging and cache locality performance.
14762
14763 This optimization is automatically turned off in the presence of
14764 exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
14765 section attribute and on any architecture that does not support named
14766 sections. When @option{-fsplit-stack} is used this option is not
14767 enabled by default (to avoid linker errors), but may be enabled
14768 explicitly (if using a working linker).
14769
14770 Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
14771
14772 @opindex freorder-functions
14773 @item -freorder-functions
14774 Reorder functions in the object file in order to
14775 improve code locality. Unlike @option{-fipa-reorder-for-locality} this option
14776 prioritises grouping all functions within a category
14777 (hot/normal/cold/never-executed) together.
14778 This is implemented by using special subsections @code{.text.hot} for most
14779 frequently executed functions and @code{.text.unlikely} for unlikely executed
14780 functions. Reordering is done by the linker so object file format must support
14781 named sections and linker must place them in a reasonable way.
14782
14783 This option isn't effective unless you either provide profile feedback
14784 (see @option{-fprofile-arcs} for details) or manually annotate functions with
14785 @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
14786
14787 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14788
14789 @opindex fstrict-aliasing
14790 @item -fstrict-aliasing
14791 Allow the compiler to assume the strictest aliasing rules applicable to
14792 the language being compiled. For C (and C++), this activates
14793 optimizations based on the type of expressions. In particular, accessing
14794 an object of one type via an expression of a different type is not allowed,
14795 unless the types are @dfn{compatible types}, differ only in signedness or
14796 qualifiers, or the expression has a character type. Accessing scalar
14797 objects via a corresponding vector type is also allowed.
14798
14799 For example, an @code{unsigned int} can alias an @code{int}, but not a
14800 @code{void*} or a @code{double}. A character type may alias any other type.
14801
14802 @anchor{Type-punning}Pay special attention to code like this:
14803 @smallexample
14804 union a_union @{
14805 int i;
14806 double d;
14807 @};
14808
14809 int f() @{
14810 union a_union t;
14811 t.d = 3.0;
14812 return t.i;
14813 @}
14814 @end smallexample
14815 The practice of reading from a different union member than the one most
14816 recently written to (called ``type-punning'') is common. Even with
14817 @option{-fstrict-aliasing}, type-punning is allowed, provided the memory
14818 is accessed through the union type. So, the code above works as
14819 expected. @xref{Structures unions enumerations and bit-fields
14820 implementation}. However, this code might not:
14821 @smallexample
14822 int f() @{
14823 union a_union t;
14824 int* ip;
14825 t.d = 3.0;
14826 ip = &t.i;
14827 return *ip;
14828 @}
14829 @end smallexample
14830
14831 Similarly, access by taking the address, casting the resulting pointer
14832 and dereferencing the result has undefined behavior, even if the cast
14833 uses a union type, e.g.:
14834 @smallexample
14835 int f() @{
14836 double d = 3.0;
14837 return ((union a_union *) &d)->i;
14838 @}
14839 @end smallexample
14840
14841 The @option{-fstrict-aliasing} option is enabled at levels
14842 @option{-O2}, @option{-O3}, @option{-Os}.
14843
14844 @opindex fipa-strict-aliasing
14845 @item -fipa-strict-aliasing
14846 Controls whether rules of @option{-fstrict-aliasing} are applied across
14847 function boundaries. Note that if multiple functions gets inlined into a
14848 single function the memory accesses are no longer considered to be crossing a
14849 function boundary.
14850
14851 The @option{-fipa-strict-aliasing} option is enabled by default and is
14852 effective only in combination with @option{-fstrict-aliasing}.
14853
14854 @opindex falign-functions
14855 @item -falign-functions
14856 @itemx -falign-functions=@var{n}
14857 @itemx -falign-functions=@var{n}:@var{m}
14858 @itemx -falign-functions=@var{n}:@var{m}:@var{n2}
14859 @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
14860 Align the start of functions to the next power-of-two greater than or
14861 equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
14862 least the first @var{m} bytes of the function can be fetched by the CPU
14863 without crossing an @var{n}-byte alignment boundary.
14864 This is an optimization of code performance and alignment is ignored for
14865 functions considered cold. If alignment is required for all functions,
14866 use @option{-fmin-function-alignment}.
14867
14868 If @var{m} is not specified, it defaults to @var{n}.
14869
14870 Examples: @option{-falign-functions=32} aligns functions to the next
14871 32-byte boundary, @option{-falign-functions=24} aligns to the next
14872 32-byte boundary only if this can be done by skipping 23 bytes or less,
14873 @option{-falign-functions=32:7} aligns to the next
14874 32-byte boundary only if this can be done by skipping 6 bytes or less.
14875
14876 The second pair of @var{n2}:@var{m2} values allows you to specify
14877 a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
14878 the next 64-byte boundary if this can be done by skipping 6 bytes or less,
14879 otherwise aligns to the next 32-byte boundary if this can be done
14880 by skipping 2 bytes or less.
14881 If @var{m2} is not specified, it defaults to @var{n2}.
14882
14883 Some assemblers only support this flag when @var{n} is a power of two;
14884 in that case, it is rounded up.
14885
14886 @option{-fno-align-functions} and @option{-falign-functions=1} are
14887 equivalent and mean that functions are not aligned.
14888
14889 If @var{n} is not specified or is zero, use a machine-dependent default.
14890 The maximum allowed @var{n} option value is 65536.
14891
14892 Enabled at levels @option{-O2}, @option{-O3}.
14893
14894 @item -flimit-function-alignment
14895 If this option is enabled, the compiler tries to avoid unnecessarily
14896 overaligning functions. It attempts to instruct the assembler to align
14897 by the amount specified by @option{-falign-functions}, but not to
14898 skip more bytes than the size of the function.
14899
14900 @opindex falign-labels
14901 @item -falign-labels
14902 @itemx -falign-labels=@var{n}
14903 @itemx -falign-labels=@var{n}:@var{m}
14904 @itemx -falign-labels=@var{n}:@var{m}:@var{n2}
14905 @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
14906 Align all branch targets to a power-of-two boundary.
14907
14908 Parameters of this option are analogous to the @option{-falign-functions} option.
14909 @option{-fno-align-labels} and @option{-falign-labels=1} are
14910 equivalent and mean that labels are not aligned.
14911
14912 If @option{-falign-loops} or @option{-falign-jumps} are applicable and
14913 are greater than this value, then their values are used instead.
14914
14915 If @var{n} is not specified or is zero, use a machine-dependent default
14916 which is very likely to be @samp{1}, meaning no alignment.
14917 The maximum allowed @var{n} option value is 65536.
14918
14919 Enabled at levels @option{-O2}, @option{-O3}.
14920
14921 @opindex falign-loops
14922 @item -falign-loops
14923 @itemx -falign-loops=@var{n}
14924 @itemx -falign-loops=@var{n}:@var{m}
14925 @itemx -falign-loops=@var{n}:@var{m}:@var{n2}
14926 @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
14927 Align loops to a power-of-two boundary. If the loops are executed
14928 many times, this makes up for any execution of the dummy padding
14929 instructions.
14930 This is an optimization of code performance and alignment is ignored for
14931 loops considered cold.
14932
14933 If @option{-falign-labels} is greater than this value, then its value
14934 is used instead.
14935
14936 Parameters of this option are analogous to the @option{-falign-functions} option.
14937 @option{-fno-align-loops} and @option{-falign-loops=1} are
14938 equivalent and mean that loops are not aligned.
14939 The maximum allowed @var{n} option value is 65536.
14940
14941 If @var{n} is not specified or is zero, use a machine-dependent default.
14942
14943 Enabled at levels @option{-O2}, @option{-O3}.
14944
14945 @opindex falign-jumps
14946 @item -falign-jumps
14947 @itemx -falign-jumps=@var{n}
14948 @itemx -falign-jumps=@var{n}:@var{m}
14949 @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
14950 @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
14951 Align branch targets to a power-of-two boundary, for branch targets
14952 where the targets can only be reached by jumping. In this case,
14953 no dummy operations need be executed.
14954 This is an optimization of code performance and alignment is ignored for
14955 jumps considered cold.
14956
14957 If @option{-falign-labels} is greater than this value, then its value
14958 is used instead.
14959
14960 Parameters of this option are analogous to the @option{-falign-functions} option.
14961 @option{-fno-align-jumps} and @option{-falign-jumps=1} are
14962 equivalent and mean that loops are not aligned.
14963
14964 If @var{n} is not specified or is zero, use a machine-dependent default.
14965 The maximum allowed @var{n} option value is 65536.
14966
14967 Enabled at levels @option{-O2}, @option{-O3}.
14968
14969 @opindex fmin-function-alignment=@var{n}
14970 @item -fmin-function-alignment
14971 Specify minimal alignment of functions to the next power-of-two greater than or
14972 equal to @var{n}. Unlike @option{-falign-functions} this alignment is applied
14973 also to all functions (even those considered cold). The alignment is also not
14974 affected by @option{-flimit-function-alignment}
14975
14976
14977 @opindex fno-allocation-dce
14978 @opindex fallocation-dce
14979 @item -fno-allocation-dce
14980 Do not remove unused C++ allocations (using operator @code{new} and operator @code{delete})
14981 in dead code elimination.
14982
14983 See also @option{-fmalloc-dce}.
14984
14985 @opindex fallow-store-data-races
14986 @item -fallow-store-data-races
14987 Allow the compiler to perform optimizations that may introduce new data races
14988 on stores, without proving that the variable cannot be concurrently accessed
14989 by other threads. Does not affect optimization of local data. It is safe to
14990 use this option if it is known that global data will not be accessed by
14991 multiple threads.
14992
14993 Examples of optimizations enabled by @option{-fallow-store-data-races} include
14994 hoisting or if-conversions that may cause a value that was already in memory
14995 to be re-written with that same value. Such re-writing is safe in a single
14996 threaded context but may be unsafe in a multi-threaded context. Note that on
14997 some processors, if-conversions may be required in order to enable
14998 vectorization.
14999
15000 Enabled at level @option{-Ofast}.
15001
15002 @opindex funit-at-a-time
15003 @item -funit-at-a-time
15004 This option is left for compatibility reasons. @option{-funit-at-a-time}
15005 has no effect, while @option{-fno-unit-at-a-time} implies
15006 @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
15007
15008 Enabled by default.
15009
15010 @opindex fno-toplevel-reorder
15011 @opindex ftoplevel-reorder
15012 @item -fno-toplevel-reorder
15013 Do not reorder top-level functions, variables, and @code{asm}
15014 statements. Output them in the same order that they appear in the
15015 input file. When this option is used, unreferenced static variables
15016 are not removed. This option is intended to support existing code
15017 that relies on a particular ordering. For new code, it is better to
15018 use attributes when possible.
15019
15020 @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
15021 also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
15022 Additionally @option{-fno-toplevel-reorder} implies
15023 @option{-fno-section-anchors}.
15024
15025 @opindex funreachable-traps
15026 @item -funreachable-traps
15027 With this option, the compiler turns calls to
15028 @code{__builtin_unreachable} into traps, instead of using them for
15029 optimization. This also affects any such calls implicitly generated
15030 by the compiler.
15031
15032 This option has the same effect as @option{-fsanitize=unreachable
15033 -fsanitize-trap=unreachable}, but does not affect the values of those
15034 options. If @option{-fsanitize=unreachable} is enabled, that option
15035 takes priority over this one.
15036
15037 This option is enabled by default at @option{-O0} and @option{-Og}.
15038
15039 @opindex fweb
15040 @item -fweb
15041 Constructs webs as commonly used for register allocation purposes and assign
15042 each web individual pseudo register. This allows the register allocation pass
15043 to operate on pseudos directly, but also strengthens several other optimization
15044 passes, such as CSE, loop optimizer and trivial dead code remover. It can,
15045 however, make debugging impossible, since variables no longer stay in a
15046 ``home register''.
15047
15048 Enabled by default with @option{-funroll-loops}.
15049
15050 @opindex fwhole-program
15051 @item -fwhole-program
15052 Assume that the current compilation unit represents the whole program being
15053 compiled. All public functions and variables with the exception of @code{main}
15054 and those merged by attribute @code{externally_visible} become static functions
15055 and in effect are optimized more aggressively by interprocedural optimizers.
15056
15057 With @option{-flto} this option has a limited use. In most cases the
15058 precise list of symbols used or exported from the binary is known the
15059 resolution info passed to the link-time optimizer by the linker plugin. It is
15060 still useful if no linker plugin is used or during incremental link step when
15061 final code is produced (with @option{-flto}
15062 @option{-flinker-output=nolto-rel}).
15063
15064 @opindex flto
15065 @item -flto[=@var{n}]
15066 This option runs the standard link-time optimizer. When invoked
15067 with source code, it generates GIMPLE (one of GCC's internal
15068 representations) and writes it to special ELF sections in the object
15069 file. When the object files are linked together, all the function
15070 bodies are read from these ELF sections and instantiated as if they
15071 had been part of the same translation unit.
15072
15073 To use the link-time optimizer, @option{-flto} and optimization
15074 options should be specified at compile time and during the final link.
15075 It is recommended that you compile all the files participating in the
15076 same link with the same options and also specify those options at
15077 link time.
15078 For example:
15079
15080 @smallexample
15081 gcc -c -O2 -flto foo.c
15082 gcc -c -O2 -flto bar.c
15083 gcc -o myprog -flto -O2 foo.o bar.o
15084 @end smallexample
15085
15086 The first two invocations to GCC save a bytecode representation
15087 of GIMPLE into special ELF sections inside @file{foo.o} and
15088 @file{bar.o}. The final invocation reads the GIMPLE bytecode from
15089 @file{foo.o} and @file{bar.o}, merges the two files into a single
15090 internal image, and compiles the result as usual. Since both
15091 @file{foo.o} and @file{bar.o} are merged into a single image, this
15092 causes all the interprocedural analyses and optimizations in GCC to
15093 work across the two files as if they were a single one. This means,
15094 for example, that the inliner is able to inline functions in
15095 @file{bar.o} into functions in @file{foo.o} and vice-versa.
15096
15097 Another (simpler) way to enable link-time optimization is:
15098
15099 @smallexample
15100 gcc -o myprog -flto -O2 foo.c bar.c
15101 @end smallexample
15102
15103 The above generates bytecode for @file{foo.c} and @file{bar.c},
15104 merges them together into a single GIMPLE representation and optimizes
15105 them as usual to produce @file{myprog}.
15106
15107 The important thing to keep in mind is that to enable link-time
15108 optimizations you need to use the GCC driver to perform the link step.
15109 GCC automatically performs link-time optimization if any of the
15110 objects involved were compiled with the @option{-flto} command-line option.
15111 You can always override
15112 the automatic decision to do link-time optimization
15113 by passing @option{-fno-lto} to the link command.
15114
15115 To make whole program optimization effective, it is necessary to make
15116 certain whole program assumptions. The compiler needs to know
15117 what functions and variables can be accessed by libraries and runtime
15118 outside of the link-time optimized unit. When supported by the linker,
15119 the linker plugin (see @option{-fuse-linker-plugin}) passes information
15120 to the compiler about used and externally visible symbols. When
15121 the linker plugin is not available, @option{-fwhole-program} should be
15122 used to allow the compiler to make these assumptions, which leads
15123 to more aggressive optimization decisions.
15124
15125 When a file is compiled with @option{-flto} without
15126 @option{-fuse-linker-plugin}, the generated object file is larger than
15127 a regular object file because it contains GIMPLE bytecodes and the usual
15128 final code (see @option{-ffat-lto-objects}). This means that
15129 object files with LTO information can be linked as normal object
15130 files; if @option{-fno-lto} is passed to the linker, no
15131 interprocedural optimizations are applied. Note that when
15132 @option{-fno-fat-lto-objects} is enabled the compile stage is faster
15133 but you cannot perform a regular, non-LTO link on them.
15134
15135 When producing the final binary, GCC only
15136 applies link-time optimizations to those files that contain bytecode.
15137 Therefore, you can mix and match object files and libraries with
15138 GIMPLE bytecodes and final object code. GCC automatically selects
15139 which files to optimize in LTO mode and which files to link without
15140 further processing.
15141
15142 Generally, options specified at link time override those
15143 specified at compile time, although in some cases GCC attempts to infer
15144 link-time options from the settings used to compile the input files.
15145
15146 If you do not specify an optimization level option @option{-O} at
15147 link time, then GCC uses the highest optimization level
15148 used when compiling the object files. Note that it is generally
15149 ineffective to specify an optimization level option only at link time and
15150 not at compile time, for two reasons. First, compiling without
15151 optimization suppresses compiler passes that gather information
15152 needed for effective optimization at link time. Second, some early
15153 optimization passes can be performed only at compile time and
15154 not at link time.
15155
15156 There are some code generation flags preserved by GCC when
15157 generating bytecodes, as they need to be used during the final link.
15158 Currently, the following options and their settings are taken from
15159 the first object file that explicitly specifies them:
15160 @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
15161 @option{-fgnu-tm} and all the @option{-m} target flags.
15162
15163 The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
15164 @option{-fPIE} are combined based on the following scheme:
15165
15166 @smallexample
15167 @option{-fPIC} + @option{-fpic} = @option{-fpic}
15168 @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
15169 @option{-fpic/-fPIC} + (no option) = (no option)
15170 @option{-fPIC} + @option{-fPIE} = @option{-fPIE}
15171 @option{-fpic} + @option{-fPIE} = @option{-fpie}
15172 @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
15173 @end smallexample
15174
15175 Certain ABI-changing flags are required to match in all compilation units,
15176 and trying to override this at link time with a conflicting value
15177 is ignored. This includes options such as @option{-freg-struct-return}
15178 and @option{-fpcc-struct-return}.
15179
15180 Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
15181 @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
15182 are passed through to the link stage and merged conservatively for
15183 conflicting translation units. Specifically
15184 @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
15185 precedence; and for example @option{-ffp-contract=off} takes precedence
15186 over @option{-ffp-contract=fast}. You can override them at link time.
15187
15188 Diagnostic options such as @option{-Wstringop-overflow} are passed
15189 through to the link stage and their setting matches that of the
15190 compile-step at function granularity. Note that this matters only
15191 for diagnostics emitted during optimization. Note that code
15192 transforms such as inlining can lead to warnings being enabled
15193 or disabled for regions if code not consistent with the setting
15194 at compile time.
15195
15196 When you need to pass options to the assembler via @option{-Wa} or
15197 @option{-Xassembler} make sure to either compile such translation
15198 units with @option{-fno-lto} or consistently use the same assembler
15199 options on all translation units. You can alternatively also
15200 specify assembler options at LTO link time.
15201
15202 To enable debug info generation you need to supply @option{-g} at
15203 compile time. If any of the input files at link time were built
15204 with debug info generation enabled the link will enable debug info
15205 generation as well. Any elaborate debug info settings
15206 like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
15207 at the linker command line and mixing different settings in different
15208 translation units is discouraged.
15209
15210 If LTO encounters objects with C linkage declared with incompatible
15211 types in separate translation units to be linked together (undefined
15212 behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
15213 issued. The behavior is still undefined at run time. Similar
15214 diagnostics may be raised for other languages.
15215
15216 Another feature of LTO is that it is possible to apply interprocedural
15217 optimizations on files written in different languages:
15218
15219 @smallexample
15220 gcc -c -flto foo.c
15221 g++ -c -flto bar.cc
15222 gfortran -c -flto baz.f90
15223 g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
15224 @end smallexample
15225
15226 Notice that the final link is done with @command{g++} to get the C++
15227 runtime libraries and @option{-lgfortran} is added to get the Fortran
15228 runtime libraries. In general, when mixing languages in LTO mode, you
15229 should use the same link command options as when mixing languages in a
15230 regular (non-LTO) compilation.
15231
15232 If object files containing GIMPLE bytecode are stored in a library archive, say
15233 @file{libfoo.a}, it is possible to extract and use them in an LTO link if you
15234 are using a linker with plugin support. To create static libraries suitable
15235 for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
15236 and @command{ranlib};
15237 to show the symbols of object files with GIMPLE bytecode, use
15238 @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
15239 and @command{nm} have been compiled with plugin support. At link time, use the
15240 flag @option{-fuse-linker-plugin} to ensure that the library participates in
15241 the LTO optimization process:
15242
15243 @smallexample
15244 gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
15245 @end smallexample
15246
15247 With the linker plugin enabled, the linker extracts the needed
15248 GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
15249 to make them part of the aggregated GIMPLE image to be optimized.
15250
15251 If you are not using a linker with plugin support and/or do not
15252 enable the linker plugin, then the objects inside @file{libfoo.a}
15253 are extracted and linked as usual, but they do not participate
15254 in the LTO optimization process. In order to make a static library suitable
15255 for both LTO optimization and usual linkage, compile its object files with
15256 @option{-flto} @option{-ffat-lto-objects}.
15257
15258 Link-time optimizations do not require the presence of the whole program to
15259 operate. If the program does not require any symbols to be exported, it is
15260 possible to combine @option{-flto} and @option{-fwhole-program} to allow
15261 the interprocedural optimizers to use more aggressive assumptions which may
15262 lead to improved optimization opportunities.
15263 Use of @option{-fwhole-program} is not needed when linker plugin is
15264 active (see @option{-fuse-linker-plugin}).
15265
15266 The current implementation of LTO makes no
15267 attempt to generate bytecode that is portable between different
15268 types of hosts. The bytecode files are versioned and there is a
15269 strict version check, so bytecode files generated in one version of
15270 GCC do not work with an older or newer version of GCC.
15271
15272 Link-time optimization does not work well with generation of debugging
15273 information on systems other than those using a combination of ELF and
15274 DWARF.
15275
15276 If you specify the optional @var{n}, the optimization and code
15277 generation done at link time is executed in parallel using @var{n}
15278 parallel jobs by utilizing an installed @command{make} program. The
15279 environment variable @env{MAKE} may be used to override the program
15280 used.
15281
15282 You can also specify @option{-flto=jobserver} to use GNU make's
15283 job server mode to determine the number of parallel jobs. This
15284 is useful when the Makefile calling GCC is already executing in parallel.
15285 You must prepend a @samp{+} to the command recipe in the parent Makefile
15286 for this to work. This option likely only works if @env{MAKE} is
15287 GNU make. Even without the option value, GCC tries to automatically
15288 detect a running GNU make's job server.
15289
15290 Use @option{-flto=auto} to use GNU make's job server, if available,
15291 or otherwise fall back to autodetection of the number of CPU threads
15292 present in your system.
15293
15294 @opindex flto-partition
15295 @item -flto-partition=@var{alg}
15296 Specify the partitioning algorithm used by the link-time optimizer.
15297 The value is either @samp{1to1} to specify a partitioning mirroring
15298 the original source files or @samp{balanced} to specify partitioning
15299 into equally sized chunks (whenever possible) or @samp{max} to create
15300 new partition for every symbol where possible or @samp{cache} to
15301 balance chunk sizes while keeping related symbols together for better
15302 caching in incremental LTO. Specifying @samp{none} as an algorithm
15303 disables partitioning and streaming completely.
15304 The default value is @samp{balanced}. While @samp{1to1} can be used
15305 as an workaround for various code ordering issues, the @samp{max}
15306 partitioning is intended for internal testing only.
15307 The value @samp{one} specifies that exactly one partition should be
15308 used while the value @samp{none} bypasses partitioning and executes
15309 the link-time optimization step directly from the WPA phase.
15310
15311 @opindex flto-incremental
15312 @item -flto-incremental=@var{path}
15313 Enable incremental LTO, with its cache in given existing directory.
15314 Can significantly shorten edit-compile cycles with LTO.
15315
15316 When used with LTO (@option{-flto}), the output of translation units
15317 inside LTO is cached. Cached translation units are likely to be
15318 encountered again when recompiling with small code changes, leading to
15319 recompile time reduction.
15320
15321 Multiple GCC instances can use the same cache in parallel.
15322
15323 @opindex flto-incremental-cache-size
15324 @item -flto-incremental-cache-size=@var{n}
15325 Specifies number of cache entries in incremental LTO after which to prune
15326 old entries. This is a soft limit, temporarily there may be more entries.
15327
15328 @opindex flto-compression-level
15329 @item -flto-compression-level=@var{n}
15330 This option specifies the level of compression used for intermediate
15331 language written to LTO object files, and is only meaningful in
15332 conjunction with LTO mode (@option{-flto}). GCC currently supports two
15333 LTO compression algorithms. For zstd, valid values are 0 (no compression)
15334 to 19 (maximum compression), while zlib supports values from 0 to 9.
15335 Values outside this range are clamped to either minimum or maximum
15336 of the supported values. If the option is not given,
15337 a default balanced compression setting is used.
15338
15339 @opindex fuse-linker-plugin
15340 @item -fuse-linker-plugin
15341 Enables the use of a linker plugin during link-time optimization. This
15342 option relies on plugin support in the linker, which is available in gold
15343 or in GNU ld 2.21 or newer.
15344
15345 This option enables the extraction of object files with GIMPLE bytecode out
15346 of library archives. This improves the quality of optimization by exposing
15347 more code to the link-time optimizer. This information specifies what
15348 symbols can be accessed externally (by non-LTO object or during dynamic
15349 linking). Resulting code quality improvements on binaries (and shared
15350 libraries that use hidden visibility) are similar to @option{-fwhole-program}.
15351 See @option{-flto} for a description of the effect of this flag and how to
15352 use it.
15353
15354 This option is enabled by default when LTO support in GCC is enabled
15355 and GCC was configured for use with
15356 a linker supporting plugins (GNU ld 2.21 or newer or gold).
15357
15358 @opindex ffat-lto-objects
15359 @item -ffat-lto-objects
15360 Fat LTO objects are object files that contain both the intermediate language
15361 and the object code. This makes them usable for both LTO linking and normal
15362 linking. This option is effective only when compiling with @option{-flto}
15363 and is ignored at link time.
15364
15365 @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
15366 requires the complete toolchain to be aware of LTO. It requires a linker with
15367 linker plugin support for basic functionality. Additionally,
15368 @command{nm}, @command{ar} and @command{ranlib}
15369 need to support linker plugins to allow a full-featured build environment
15370 (capable of building static libraries etc). GCC provides the @command{gcc-ar},
15371 @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
15372 to these tools. With non fat LTO makefiles need to be modified to use them.
15373
15374 Note that modern binutils provide plugin auto-load mechanism.
15375 Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
15376 effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
15377 @command{gcc-ranlib}).
15378
15379 The default is @option{-fno-fat-lto-objects} on targets with linker plugin
15380 support.
15381
15382 @opindex fcompare-elim
15383 @item -fcompare-elim
15384 After register allocation and post-register allocation instruction splitting,
15385 identify arithmetic instructions that compute processor flags similar to a
15386 comparison operation based on that arithmetic. If possible, eliminate the
15387 explicit comparison operation.
15388
15389 This pass only applies to certain targets that cannot explicitly represent
15390 the comparison operation before register allocation is complete.
15391
15392 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
15393
15394 @opindex ffold-mem-offsets
15395 @item -ffold-mem-offsets
15396 @itemx -fno-fold-mem-offsets
15397 Try to eliminate add instructions by folding them in memory loads/stores.
15398
15399 Enabled at levels @option{-O2}, @option{-O3}.
15400
15401 @opindex fcprop-registers
15402 @item -fcprop-registers
15403 After register allocation and post-register allocation instruction splitting,
15404 perform a copy-propagation pass to try to reduce scheduling dependencies
15405 and occasionally eliminate the copy.
15406
15407 Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
15408
15409 @opindex fprofile-correction
15410 @item -fprofile-correction
15411 Profiles collected using an instrumented binary for multi-threaded programs may
15412 be inconsistent due to missed counter updates. When this option is specified,
15413 GCC uses heuristics to correct or smooth out such inconsistencies. By
15414 default, GCC emits an error message when an inconsistent profile is detected.
15415
15416 This option is enabled by @option{-fauto-profile}.
15417
15418 @opindex fprofile-partial-training
15419 @item -fprofile-partial-training
15420 With @code{-fprofile-use} all portions of programs not executed during train
15421 run are optimized aggressively for size rather than speed. In some cases it is
15422 not practical to train all possible hot paths in the program. (For
15423 example, program may contain functions specific for a given hardware and
15424 training may not cover all hardware configurations program is run on.) With
15425 @code{-fprofile-partial-training} profile feedback is ignored for all
15426 functions not executed during the train run, leading them to be optimized as if
15427 they were compiled without profile feedback. This leads to better performance
15428 when train run is not representative but also leads to significantly bigger
15429 code.
15430
15431 @opindex fprofile-use
15432 @item -fprofile-use
15433 @itemx -fprofile-use=@var{path}
15434 Enable profile feedback-directed optimizations,
15435 and the following optimizations, many of which
15436 are generally profitable only with profile feedback available:
15437
15438 @gccoptlist{-fbranch-probabilities -fprofile-values
15439 -funroll-loops -fpeel-loops -ftracer -fvpt
15440 -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
15441 -fpredictive-commoning -fsplit-loops -funswitch-loops
15442 -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
15443 -fvect-cost-model=dynamic -ftree-loop-distribute-patterns
15444 -fprofile-reorder-functions}
15445
15446 Before you can use this option, you must first generate profiling information.
15447 @xref{Instrumentation Options}, for information about the
15448 @option{-fprofile-generate} option.
15449
15450 By default, GCC emits an error message if the feedback profiles do not
15451 match the source code. This error can be turned into a warning by using
15452 @option{-Wno-error=coverage-mismatch}. Note this may result in poorly
15453 optimized code. Additionally, by default, GCC also emits a warning message if
15454 the feedback profiles do not exist (see @option{-Wmissing-profile}).
15455
15456 If @var{path} is specified, GCC looks at the @var{path} to find
15457 the profile feedback data files. See @option{-fprofile-dir}.
15458
15459 @opindex fauto-profile
15460 @item -fauto-profile
15461 @itemx -fauto-profile=@var{path}
15462 Enable sampling-based feedback-directed optimizations,
15463 and the following optimizations,
15464 many of which are generally profitable only with profile feedback available:
15465
15466 @gccoptlist{-fbranch-probabilities -fprofile-values
15467 -funroll-loops -fpeel-loops -ftracer -fvpt
15468 -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
15469 -fpredictive-commoning -fsplit-loops -funswitch-loops
15470 -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
15471 -fvect-cost-model=dynamic -ftree-loop-distribute-patterns
15472 -fprofile-correction}
15473
15474 @var{path} is the name of a file containing AutoFDO profile information.
15475 If omitted, it defaults to @file{fbdata.afdo} in the current directory.
15476
15477 Producing an AutoFDO profile data file requires running your program
15478 with the @command{perf} utility on a supported GNU/Linux target system.
15479 For more information, see @uref{https://perf.wiki.kernel.org/}.
15480
15481 E.g.
15482 @smallexample
15483 perf record -e br_inst_retired:near_taken -b -o perf.data \
15484 -- your_program
15485 @end smallexample
15486
15487 Then use the @command{create_gcov} tool to convert the raw profile data
15488 to a format that can be used by GCC.@ You must also supply the
15489 unstripped binary for your program to this tool.
15490 See @uref{https://github.com/google/autofdo}.
15491
15492 E.g.
15493 @smallexample
15494 create_gcov --binary=your_program.unstripped --profile=perf.data \
15495 --gcov=profile.afdo
15496 @end smallexample
15497
15498 @opindex fauto-profile-inlining
15499 @item -fauto-profile-inlining
15500 When auto-profile is available inline all relevant functions which was
15501 inlined in the tran run before reading the profile feedback. This improves
15502 context sensitivity of the profile. Enabled by default.
15503 @end table
15504
15505 The following options control compiler behavior regarding floating-point
15506 arithmetic. These options trade off between speed and
15507 correctness. All must be specifically enabled.
15508
15509 @table @gcctabopt
15510 @opindex fexcess-precision
15511 @item -fexcess-precision=@var{style}
15512 This option allows control over excess precision on machines
15513 where floating-point operations occur in a format with more precision or
15514 range than the IEEE standard and interchange floating-point types.
15515 An example of such a target is x87 floating point on x86 processors,
15516 which uses an 80-bit representation internally instead of the 64-bit
15517 IEEE format. For most programs, the excess precision is harmless,
15518 but some programs may rely on the
15519 requirements of the C or C++ language standards for handling IEEE values.
15520
15521 By default, @option{-fexcess-precision=fast} is in effect; this means that
15522 operations may be carried out in a wider precision than the types specified
15523 in the source if that would result in faster code, and it is unpredictable
15524 when rounding to the types specified in the source code takes place.
15525 When compiling C or C++, if @option{-fexcess-precision=standard} is specified
15526 then excess precision follows the rules specified in ISO C99 or C++;
15527 in particular,
15528 both casts and assignments cause values to be rounded to their
15529 semantic types (whereas @option{-ffloat-store} only affects
15530 assignments). This option is enabled by default for C or C++ if a strict
15531 conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
15532 @option{-ffast-math} enables @option{-fexcess-precision=fast} by default
15533 regardless of whether a strict conformance option is used.
15534 If @option{-fexcess-precision=16} is specified, constants and the
15535 results of expressions with types @code{_Float16} and @code{__bf16}
15536 are computed without excess precision.
15537
15538 @opindex mfpmath
15539 @option{-fexcess-precision=standard} is not implemented for languages
15540 other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
15541 or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
15542 semantics apply without excess precision, and in the latter, rounding
15543 is unpredictable.
15544
15545 @opindex ffloat-store
15546 @item -ffloat-store
15547 Do not store floating-point variables in registers, and inhibit other
15548 options that might change whether a floating-point value is taken from a
15549 register or memory. This option has generally been subsumed by
15550 @option{-fexcess-precision=standard}, which is more general. If you do use
15551 @option{-ffloat-store}, you may need to modify your program to explicitly
15552 store intermediate computations in temporary variables since
15553 @option{-ffloat-store} handles rounding to IEEE format
15554 only on assignments and not casts as @option{-fexcess-precision=standard}
15555 does.
15556
15557 @opindex ffast-math
15558 @item -ffast-math
15559 Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
15560 @option{-ffinite-math-only}, @option{-fno-rounding-math},
15561 @option{-fno-signaling-nans}, @option{-fcx-limited-range} and
15562 @option{-fexcess-precision=fast}.
15563
15564 This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
15565
15566 This option is not turned on by any @option{-O} option besides
15567 @option{-Ofast} since it can result in incorrect output for programs
15568 that depend on an exact implementation of IEEE or ISO rules/specifications
15569 for math functions. It may, however, yield faster code for programs
15570 that do not require the guarantees of these specifications.
15571
15572 @opindex fno-math-errno
15573 @opindex fmath-errno
15574 @item -fno-math-errno
15575 Do not set @code{errno} after calling math functions that are executed
15576 with a single instruction, e.g., @code{sqrt}. A program that relies on
15577 IEEE exceptions for math error handling may want to use this flag
15578 for speed while maintaining IEEE arithmetic compatibility.
15579
15580 This option is not turned on by any @option{-O} option besides
15581 @option{-Ofast} since it can result in incorrect output for
15582 programs that depend on an exact implementation of IEEE or
15583 ISO rules/specifications for math functions. It may, however,
15584 yield faster code for programs that do not require the guarantees
15585 of these specifications.
15586
15587 The default is @option{-fmath-errno}.
15588
15589 On Darwin systems, the math library never sets @code{errno}. There is
15590 therefore no reason for the compiler to consider the possibility that
15591 it might, and @option{-fno-math-errno} is the default.
15592
15593 @opindex funsafe-math-optimizations
15594 @item -funsafe-math-optimizations
15595
15596 Allow optimizations for floating-point arithmetic that (a) assume
15597 that arguments and results are valid and (b) may violate IEEE or
15598 ANSI standards. When used at link time, it may include libraries
15599 or startup files that change the default FPU control word or other
15600 similar optimizations.
15601
15602 This option is not turned on by any @option{-O} option besides
15603 @option{-Ofast} since it can result in incorrect output
15604 for programs that depend on an exact implementation of IEEE
15605 or ISO rules/specifications for math functions. It may, however,
15606 yield faster code for programs that do not require the guarantees
15607 of these specifications.
15608 Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
15609 @option{-fassociative-math} and @option{-freciprocal-math}.
15610
15611 The default is @option{-fno-unsafe-math-optimizations}.
15612
15613 @opindex fassociative-math
15614 @item -fassociative-math
15615
15616 Allow re-association of operands in series of floating-point operations.
15617 This violates the ISO C and C++ language standard by possibly changing
15618 computation result. NOTE: re-ordering may change the sign of zero as
15619 well as ignore NaNs and inhibit or create underflow or overflow (and
15620 thus cannot be used on code that relies on rounding behavior like
15621 @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
15622 and thus may not be used when ordered comparisons are required.
15623 This option requires that both @option{-fno-signed-zeros} and
15624 @option{-fno-trapping-math} be in effect. Moreover, it doesn't make
15625 much sense with @option{-frounding-math}. For Fortran the option
15626 is automatically enabled when both @option{-fno-signed-zeros} and
15627 @option{-fno-trapping-math} are in effect.
15628
15629 The default is @option{-fno-associative-math}.
15630
15631 @opindex freciprocal-math
15632 @item -freciprocal-math
15633
15634 Allow the reciprocal of a value to be used instead of dividing by
15635 the value if this enables optimizations. For example @code{x / y}
15636 can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
15637 is subject to common subexpression elimination. Note that this loses
15638 precision and increases the number of flops operating on the value.
15639
15640 The default is @option{-fno-reciprocal-math}.
15641
15642 @opindex ffinite-math-only
15643 @item -ffinite-math-only
15644 Allow optimizations for floating-point arithmetic that assume
15645 that arguments and results are not NaNs or +-Infs.
15646
15647 This option is not turned on by any @option{-O} option besides
15648 @option{-Ofast} since it can result in incorrect output
15649 for programs that depend on an exact implementation of IEEE or
15650 ISO rules/specifications for math functions. It may, however,
15651 yield faster code for programs that do not require the guarantees
15652 of these specifications.
15653
15654 The default is @option{-fno-finite-math-only}.
15655
15656 @opindex fno-signed-zeros
15657 @opindex fsigned-zeros
15658 @item -fno-signed-zeros
15659 Allow optimizations for floating-point arithmetic that ignore the
15660 signedness of zero. IEEE arithmetic specifies the behavior of
15661 distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
15662 of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
15663 This option implies that the sign of a zero result isn't significant.
15664
15665 The default is @option{-fsigned-zeros}.
15666
15667 @opindex fno-trapping-math
15668 @opindex ftrapping-math
15669 @item -fno-trapping-math
15670 Compile code assuming that floating-point operations cannot generate
15671 user-visible traps. These traps include division by zero, overflow,
15672 underflow, inexact result and invalid operation. This option requires
15673 that @option{-fno-signaling-nans} be in effect. Setting this option may
15674 allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
15675
15676 This option is not turned on by any @option{-O} option besides
15677 @option{-Ofast} since it can result in incorrect output for programs
15678 that depend on an exact implementation of IEEE or ISO rules/specifications
15679 for math functions.
15680
15681 The default is @option{-ftrapping-math}.
15682
15683 Future versions of GCC may provide finer control of this setting
15684 using C99's @code{FENV_ACCESS} pragma. This command-line option
15685 will be used along with @option{-frounding-math} to specify the
15686 default state for @code{FENV_ACCESS}.
15687
15688 @opindex frounding-math
15689 @item -frounding-math
15690 Disable transformations and optimizations that assume default floating-point
15691 rounding behavior (round-to-nearest).
15692 This option should be specified for programs that change
15693 the FP rounding mode dynamically, or that may be executed with a
15694 non-default rounding mode. This option disables constant folding of
15695 floating-point expressions at compile time (which may be affected by
15696 rounding mode) and arithmetic transformations that are unsafe in the
15697 presence of sign-dependent rounding modes.
15698
15699 The default is @option{-fno-rounding-math}.
15700
15701 This option is experimental and does not currently guarantee to
15702 disable all GCC optimizations that are affected by rounding mode.
15703 Future versions of GCC may provide finer control of this setting
15704 using C99's @code{FENV_ACCESS} pragma. This command-line option
15705 will be used along with @option{-ftrapping-math} to specify the
15706 default state for @code{FENV_ACCESS}.
15707
15708 @opindex fsignaling-nans
15709 @item -fsignaling-nans
15710 Compile code assuming that IEEE signaling NaNs may generate user-visible
15711 traps during floating-point operations. Setting this option disables
15712 optimizations that may change the number of exceptions visible with
15713 signaling NaNs. This option implies @option{-ftrapping-math}.
15714
15715 This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
15716 be defined.
15717
15718 The default is @option{-fno-signaling-nans}.
15719
15720 This option is experimental and does not currently guarantee to
15721 disable all GCC optimizations that affect signaling NaN behavior.
15722
15723 @opindex fno-fp-int-builtin-inexact
15724 @opindex ffp-int-builtin-inexact
15725 @item -fno-fp-int-builtin-inexact
15726 Do not allow the built-in functions @code{ceil}, @code{floor},
15727 @code{round} and @code{trunc}, and their @code{float} and @code{long
15728 double} variants, to generate code that raises the ``inexact''
15729 floating-point exception for noninteger arguments. ISO C99 and C11
15730 allow these functions to raise the ``inexact'' exception, but ISO/IEC
15731 TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
15732 ISO C23, does not allow these functions to do so.
15733
15734 The default is @option{-ffp-int-builtin-inexact}, allowing the
15735 exception to be raised, unless C23 or a later C standard is selected.
15736 This option does nothing unless @option{-ftrapping-math} is in effect.
15737
15738 Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
15739 generate a call to a library function then the ``inexact'' exception
15740 may be raised if the library implementation does not follow TS 18661.
15741
15742 @opindex fsingle-precision-constant
15743 @item -fsingle-precision-constant
15744 Treat floating-point constants as single precision instead of
15745 implicitly converting them to double-precision constants.
15746
15747 @opindex fcx-limited-range
15748 @item -fcx-limited-range
15749 When enabled, this option states that a range reduction step is not
15750 needed when performing complex division. Also, there is no checking
15751 whether the result of a complex multiplication or division is @code{NaN
15752 + I*NaN}, with an attempt to rescue the situation in that case. The
15753 option is enabled by @option{-ffast-math}.
15754
15755 This option controls the default setting of the ISO C99
15756 @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
15757 all languages.
15758
15759 @opindex fcx-fortran-rules
15760 @item -fcx-fortran-rules
15761 Complex multiplication and division follow Fortran rules. Range
15762 reduction is done as part of complex division, but there is no checking
15763 whether the result of a complex multiplication or division is @code{NaN
15764 + I*NaN}, with an attempt to rescue the situation in that case.
15765
15766 @opindex fcx-method
15767 @item -fcx-method=@var{method}
15768 Complex multiplication and division follow the stated @var{method}. The
15769 @var{method} argument should be one of @samp{limited-range}, @samp{fortran}
15770 or @samp{stdc}.
15771
15772 The default is to honor language specific constraints which means
15773 @samp{fortran} for Fortran and @samp{stdc} otherwise.
15774
15775 @end table
15776
15777 The following options control optimizations that may improve
15778 performance, but are not enabled by any @option{-O} options. This
15779 section includes experimental options that may produce broken code.
15780
15781 @table @gcctabopt
15782 @opindex fbranch-probabilities
15783 @item -fbranch-probabilities
15784 After running a program compiled with @option{-fprofile-arcs}
15785 (@pxref{Instrumentation Options}),
15786 you can compile it a second time using
15787 @option{-fbranch-probabilities}, to improve optimizations based on
15788 the number of times each branch was taken. When a program
15789 compiled with @option{-fprofile-arcs} exits, it saves arc execution
15790 counts to a file called @file{@var{sourcename}.gcda} for each source
15791 file. The information in this data file is very dependent on the
15792 structure of the generated code, so you must use the same source code
15793 and the same optimization options for both compilations.
15794 See details about the file naming in @option{-fprofile-arcs}.
15795
15796 With @option{-fbranch-probabilities}, GCC puts a
15797 @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
15798 These can be used to improve optimization. Currently, they are only
15799 used in one place: in @file{reorg.cc}, instead of guessing which path a
15800 branch is most likely to take, the @samp{REG_BR_PROB} values are used to
15801 exactly determine which path is taken more often.
15802
15803 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15804
15805 @opindex fprofile-values
15806 @item -fprofile-values
15807 If combined with @option{-fprofile-arcs}, it adds code so that some
15808 data about values of expressions in the program is gathered.
15809
15810 With @option{-fbranch-probabilities}, it reads back the data gathered
15811 from profiling values of expressions for usage in optimizations.
15812
15813 Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
15814 @option{-fauto-profile}.
15815
15816 @opindex fprofile-reorder-functions
15817 @item -fprofile-reorder-functions
15818 Function reordering based on profile instrumentation collects
15819 first time of execution of a function and orders these functions
15820 in ascending order, aiming to optimize program startup through more
15821 efficient loading of text segments.
15822
15823 Enabled with @option{-fprofile-use}.
15824
15825 @opindex fvpt
15826 @item -fvpt
15827 If combined with @option{-fprofile-arcs}, this option instructs the compiler
15828 to add code to gather information about values of expressions.
15829
15830 With @option{-fbranch-probabilities}, it reads back the data gathered
15831 and actually performs the optimizations based on them.
15832 Currently the optimizations include specialization of division operations
15833 using the knowledge about the value of the denominator.
15834
15835 Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
15836
15837 @opindex frename-registers
15838 @item -frename-registers
15839 Attempt to avoid false dependencies in scheduled code by making use
15840 of registers left over after register allocation. This optimization
15841 most benefits processors with lots of registers. Depending on the
15842 debug information format adopted by the target, however, it can
15843 make debugging impossible, since variables no longer stay in
15844 a ``home register''.
15845
15846 Enabled by default with @option{-funroll-loops}.
15847
15848 @opindex fschedule-fusion
15849 @item -fschedule-fusion
15850 Performs a target dependent pass over the instruction stream to schedule
15851 instructions of same type together because target machine can execute them
15852 more efficiently if they are adjacent to each other in the instruction flow.
15853
15854 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
15855
15856 @opindex ftracer
15857 @item -ftracer
15858 Perform tail duplication to enlarge superblock size. This transformation
15859 simplifies the control flow of the function allowing other optimizations to do
15860 a better job.
15861
15862 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15863
15864 @opindex funroll-loops
15865 @item -funroll-loops
15866 Unroll loops whose number of iterations can be determined at compile time or
15867 upon entry to the loop. @option{-funroll-loops} implies
15868 @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
15869 It also turns on complete loop peeling (i.e.@: complete removal of loops with
15870 a small constant number of iterations). This option makes code larger, and may
15871 or may not make it run faster.
15872
15873 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15874
15875 @opindex funroll-all-loops
15876 @item -funroll-all-loops
15877 Unroll all loops, even if their number of iterations is uncertain when
15878 the loop is entered. This usually makes programs run more slowly.
15879 @option{-funroll-all-loops} implies the same options as
15880 @option{-funroll-loops}.
15881
15882 @opindex fpeel-loops
15883 @item -fpeel-loops
15884 Peels loops for which there is enough information that they do not
15885 roll much (from profile feedback or static analysis). It also turns on
15886 complete loop peeling (i.e.@: complete removal of loops with small constant
15887 number of iterations).
15888
15889 Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
15890
15891 @opindex fno-malloc-dce
15892 @opindex fmalloc-dce
15893 @item -fmalloc-dce
15894 Control whether @code{malloc} (and its variants such as @code{calloc} or
15895 @code{strdup}), can be optimized away provided its return value is only used
15896 as a parameter of @code{free} call or compared with @code{NULL}. If
15897 @option{-fmalloc-dce=1} is used, only calls to @code{free} are allowed while
15898 with @option{-fmalloc-dce=2} also comparisons with @code{NULL} pointer are
15899 considered safe to remove.
15900
15901 The default is @option{-fmalloc-dce=2}. See also @option{-fallocation-dce}.
15902
15903 @opindex fmove-loop-invariants
15904 @item -fmove-loop-invariants
15905 Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
15906 at level @option{-O1} and higher, except for @option{-Og}.
15907
15908 @opindex fmove-loop-stores
15909 @item -fmove-loop-stores
15910 Enables the loop store motion pass in the GIMPLE loop optimizer. This
15911 moves invariant stores to after the end of the loop in exchange for
15912 carrying the stored value in a register across the iteration.
15913 Note for this option to have an effect @option{-ftree-loop-im} has to
15914 be enabled as well. Enabled at level @option{-O1} and higher, except
15915 for @option{-Og}.
15916
15917 @opindex fsplit-loops
15918 @item -fsplit-loops
15919 Split a loop into two if it contains a condition that's always true
15920 for one side of the iteration space and false for the other.
15921
15922 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15923
15924 @opindex funswitch-loops
15925 @item -funswitch-loops
15926 Move branches with loop invariant conditions out of the loop, with duplicates
15927 of the loop on both branches (modified according to result of the condition).
15928
15929 Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15930
15931 @opindex fversion-loops-for-strides
15932 @item -fversion-loops-for-strides
15933 If a loop iterates over an array with a variable stride, create another
15934 version of the loop that assumes the stride is always one. For example:
15935
15936 @smallexample
15937 for (int i = 0; i < n; ++i)
15938 x[i * stride] = @dots{};
15939 @end smallexample
15940
15941 becomes:
15942
15943 @smallexample
15944 if (stride == 1)
15945 for (int i = 0; i < n; ++i)
15946 x[i] = @dots{};
15947 else
15948 for (int i = 0; i < n; ++i)
15949 x[i * stride] = @dots{};
15950 @end smallexample
15951
15952 This is particularly useful for assumed-shape arrays in Fortran where
15953 (for example) it allows better vectorization assuming contiguous accesses.
15954 This flag is enabled by default at @option{-O3}.
15955 It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15956
15957 @opindex ffunction-sections
15958 @opindex fdata-sections
15959 @item -ffunction-sections
15960 @itemx -fdata-sections
15961 Place each function or data item into its own section in the output
15962 file if the target supports arbitrary sections. The name of the
15963 function or the name of the data item determines the section's name
15964 in the output file.
15965
15966 Use these options on systems where the linker can perform optimizations to
15967 improve locality of reference in the instruction space. Most systems using the
15968 ELF object format have linkers with such optimizations. On AIX, the linker
15969 rearranges sections (CSECTs) based on the call graph. The performance impact
15970 varies.
15971
15972 Together with a linker garbage collection (linker @option{--gc-sections}
15973 option) these options may lead to smaller statically-linked executables (after
15974 stripping).
15975
15976 On ELF/DWARF systems these options do not degenerate the quality of the debug
15977 information. There could be issues with other object files/debug info formats.
15978
15979 Only use these options when there are significant benefits from doing so. When
15980 you specify these options, the assembler and linker create larger object and
15981 executable files and are also slower. These options affect code generation.
15982 They prevent optimizations by the compiler and assembler using relative
15983 locations inside a translation unit since the locations are unknown until
15984 link time. An example of such an optimization is relaxing calls to short call
15985 instructions.
15986
15987 @opindex fstdarg-opt
15988 @item -fstdarg-opt
15989 Optimize the prologue of variadic argument functions with respect to usage of
15990 those arguments.
15991
15992 @opindex fsection-anchors
15993 @item -fsection-anchors
15994 Try to reduce the number of symbolic address calculations by using
15995 shared ``anchor'' symbols to address nearby objects. This transformation
15996 can help to reduce the number of GOT entries and GOT accesses on some
15997 targets.
15998
15999 For example, the implementation of the following function @code{foo}:
16000
16001 @smallexample
16002 static int a, b, c;
16003 int foo (void) @{ return a + b + c; @}
16004 @end smallexample
16005
16006 @noindent
16007 usually calculates the addresses of all three variables, but if you
16008 compile it with @option{-fsection-anchors}, it accesses the variables
16009 from a common anchor point instead. The effect is similar to the
16010 following pseudocode (which isn't valid C):
16011
16012 @smallexample
16013 int foo (void)
16014 @{
16015 register int *xr = &x;
16016 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
16017 @}
16018 @end smallexample
16019
16020 Not all targets support this option.
16021
16022 @opindex fzero-call-used-regs
16023 @item -fzero-call-used-regs=@var{choice}
16024 Zero call-used registers at function return to increase program
16025 security by either mitigating Return-Oriented Programming (ROP)
16026 attacks or preventing information leakage through registers.
16027
16028 The possible values of @var{choice} are the same as for the
16029 @code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
16030 The default is @samp{skip}.
16031
16032 You can control this behavior for a specific function by using the function
16033 attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
16034
16035 @opindex param
16036 @item --param @var{name}=@var{value}
16037 In some places, GCC uses various constants to control the amount of
16038 optimization that is done. For example, GCC does not inline functions
16039 that contain more than a certain number of instructions. You can
16040 control some of these constants on the command line using the
16041 @option{--param} option.
16042
16043 The names of specific parameters, and the meaning of the values, are
16044 tied to the internals of the compiler, and are subject to change
16045 without notice in future releases.
16046
16047 In order to get the minimal, maximal and default values of a parameter,
16048 use the @option{--help=param -Q} options.
16049
16050 In each case, the @var{value} is an integer. The following choices
16051 of @var{name} are recognized for all targets:
16052
16053 @table @gcctabopt
16054 @item phiopt-factor-max-stmts-live
16055 When factoring statements out of if/then/else, this is the max # of statements
16056 after the defining statement to be allow to extend the lifetime of a name
16057
16058 @item predictable-branch-outcome
16059 When branch is predicted to be taken with probability lower than this threshold
16060 (in percent), then it is considered well predictable.
16061
16062 @item max-rtl-if-conversion-insns
16063 RTL if-conversion tries to remove conditional branches around a block and
16064 replace them with conditionally executed instructions. This parameter
16065 gives the maximum number of instructions in a block which should be
16066 considered for if-conversion. The compiler will
16067 also use other heuristics to decide whether if-conversion is likely to be
16068 profitable.
16069
16070 @item file-cache-files
16071 Max number of files in the file cache.
16072 The file cache is used to print source lines in diagnostics and do some
16073 source checks like @option{-Wmisleading-indentation}.
16074
16075 @item file-cache-lines
16076 Max number of lines to index into file cache. When 0 this is automatically sized.
16077 The file cache is used to print source lines in diagnostics and do some
16078 source checks like @option{-Wmisleading-indentation}.
16079
16080 @item max-rtl-if-conversion-predictable-cost
16081 RTL if-conversion will try to remove conditional branches around a block
16082 and replace them with conditionally executed instructions. These parameters
16083 give the maximum permissible cost for the sequence that would be generated
16084 by if-conversion depending on whether the branch is statically determined
16085 to be predictable or not. The units for this parameter are the same as
16086 those for the GCC internal seq_cost metric. The compiler will try to
16087 provide a reasonable default for this parameter using the BRANCH_COST
16088 target macro.
16089
16090 @item max-crossjump-edges
16091 The maximum number of incoming edges to consider for cross-jumping.
16092 The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
16093 the number of edges incoming to each block. Increasing values mean
16094 more aggressive optimization, making the compilation time increase with
16095 probably small improvement in executable size.
16096
16097 @item min-crossjump-insns
16098 The minimum number of instructions that must be matched at the end
16099 of two blocks before cross-jumping is performed on them. This
16100 value is ignored in the case where all instructions in the block being
16101 cross-jumped from are matched.
16102
16103 @item max-grow-copy-bb-insns
16104 The maximum code size expansion factor when copying basic blocks
16105 instead of jumping. The expansion is relative to a jump instruction.
16106
16107 @item max-goto-duplication-insns
16108 The maximum number of instructions to duplicate to a block that jumps
16109 to a computed goto. To avoid @math{O(N^2)} behavior in a number of
16110 passes, GCC factors computed gotos early in the compilation process,
16111 and unfactors them as late as possible. Only computed jumps at the
16112 end of a basic blocks with no more than max-goto-duplication-insns are
16113 unfactored.
16114
16115 @item max-delay-slot-insn-search
16116 The maximum number of instructions to consider when looking for an
16117 instruction to fill a delay slot. If more than this arbitrary number of
16118 instructions are searched, the time savings from filling the delay slot
16119 are minimal, so stop searching. Increasing values mean more
16120 aggressive optimization, making the compilation time increase with probably
16121 small improvement in execution time.
16122
16123 @item max-delay-slot-live-search
16124 When trying to fill delay slots, the maximum number of instructions to
16125 consider when searching for a block with valid live register
16126 information. Increasing this arbitrarily chosen value means more
16127 aggressive optimization, increasing the compilation time. This parameter
16128 should be removed when the delay slot code is rewritten to maintain the
16129 control-flow graph.
16130
16131 @item max-gcse-memory
16132 The approximate maximum amount of memory in @code{kB} that can be allocated in
16133 order to perform the global common subexpression elimination
16134 optimization. If more memory than specified is required, the
16135 optimization is not done.
16136
16137 @item max-gcse-insertion-ratio
16138 If the ratio of expression insertions to deletions is larger than this value
16139 for any expression, then RTL PRE inserts or removes the expression and thus
16140 leaves partially redundant computations in the instruction stream.
16141
16142 @item max-pending-list-length
16143 The maximum number of pending dependencies scheduling allows
16144 before flushing the current state and starting over. Large functions
16145 with few branches or calls can create excessively large lists which
16146 needlessly consume memory and resources.
16147
16148 @item max-modulo-backtrack-attempts
16149 The maximum number of backtrack attempts the scheduler should make
16150 when modulo scheduling a loop. Larger values can exponentially increase
16151 compilation time.
16152
16153 @item max-inline-functions-called-once-loop-depth
16154 Maximal loop depth of a call considered by inline heuristics that tries to
16155 inline all functions called once.
16156
16157 @item max-inline-functions-called-once-insns
16158 Maximal estimated size of functions produced while inlining functions called
16159 once.
16160
16161 @item max-inline-insns-single
16162 Several parameters control the tree inliner used in GCC@. This number sets the
16163 maximum number of instructions (counted in GCC's internal representation) in a
16164 single function that the tree inliner considers for inlining. This only
16165 affects functions declared inline and methods implemented in a class
16166 declaration (C++).
16167
16168
16169 @item max-inline-insns-auto
16170 When you use @option{-finline-functions} (included in @option{-O3}),
16171 a lot of functions that would otherwise not be considered for inlining
16172 by the compiler are investigated. To those functions, a different
16173 (more restrictive) limit compared to functions declared inline can
16174 be applied (@option{--param max-inline-insns-auto}).
16175
16176 @item max-inline-insns-small
16177 This is the bound applied to calls that are considered relevant with
16178 @option{-finline-small-functions}.
16179
16180 @item max-inline-insns-size
16181 This is the bound applied to calls that are optimized for size. Small growth
16182 may be desirable to anticipate optimization opportunities exposed by inlining.
16183
16184 @item uninlined-function-insns
16185 Number of instructions accounted by inliner for function overhead such as
16186 function prologue and epilogue.
16187
16188 @item uninlined-function-time
16189 Extra time accounted by inliner for function overhead such as time needed to
16190 execute function prologue and epilogue.
16191
16192 @item inline-heuristics-hint-percent
16193 The scale (in percents) applied to @option{inline-insns-single},
16194 @option{inline-insns-single-O2}, @option{inline-insns-auto}
16195 when inline heuristics hints that inlining is
16196 very profitable (will enable later optimizations).
16197
16198 @item uninlined-thunk-insns
16199 @item uninlined-thunk-time
16200 Same as @option{--param uninlined-function-insns} and
16201 @option{--param uninlined-function-time} but applied to function thunks.
16202
16203 @item inline-min-speedup
16204 When estimated performance improvement of caller + callee runtime exceeds this
16205 threshold (in percent), the function can be inlined regardless of the limit on
16206 @option{--param max-inline-insns-single} and @option{--param
16207 max-inline-insns-auto}.
16208
16209 @item large-function-insns
16210 The limit specifying really large functions. For functions larger than this
16211 limit after inlining, inlining is constrained by
16212 @option{--param large-function-growth}. This parameter is useful primarily
16213 to avoid extreme compilation time caused by non-linear algorithms used by the
16214 back end.
16215
16216 @item large-function-growth
16217 Specifies maximal growth of large functions caused by inlining in percents.
16218 For example, parameter value 100 limits large function growth to 2.0 times
16219 the original size.
16220
16221 @item large-unit-insns
16222 The limit specifying large translation unit. Growth caused by inlining of
16223 units larger than this limit is limited by @option{--param inline-unit-growth}.
16224 For small units this might be too tight.
16225 For example, consider a unit consisting of function A
16226 that is inline and B that just calls A three times. If B is small relative to
16227 A, the growth of unit is 300\% and yet such inlining is very sane. For very
16228 large units consisting of small inlineable functions, however, the overall unit
16229 growth limit is needed to avoid exponential explosion of code size. Thus for
16230 smaller units, the size is increased to @option{--param large-unit-insns}
16231 before applying @option{--param inline-unit-growth}.
16232
16233 @item lazy-modules
16234 Maximum number of concurrently open C++ module files when lazy loading.
16235
16236 @item inline-unit-growth
16237 Specifies maximal overall growth of the compilation unit caused by inlining.
16238 For example, parameter value 20 limits unit growth to 1.2 times the original
16239 size. Cold functions (either marked cold via an attribute or by profile
16240 feedback) are not accounted into the unit size.
16241
16242 @item ipa-cp-unit-growth
16243 Specifies maximal overall growth of the compilation unit caused by
16244 interprocedural constant propagation. For example, parameter value 10 limits
16245 unit growth to 1.1 times the original size.
16246
16247 @item ipa-cp-large-unit-insns
16248 The size of translation unit that IPA-CP pass considers large.
16249
16250 @item large-stack-frame
16251 The limit specifying large stack frames. While inlining the algorithm is trying
16252 to not grow past this limit too much.
16253
16254 @item large-stack-frame-growth
16255 Specifies maximal growth of large stack frames caused by inlining in percents.
16256 For example, parameter value 1000 limits large stack frame growth to 11 times
16257 the original size.
16258
16259 @item max-inline-insns-recursive
16260 @itemx max-inline-insns-recursive-auto
16261 Specifies the maximum number of instructions an out-of-line copy of a
16262 self-recursive inline
16263 function can grow into by performing recursive inlining.
16264
16265 @option{--param max-inline-insns-recursive} applies to functions
16266 declared inline.
16267 For functions not declared inline, recursive inlining
16268 happens only when @option{-finline-functions} (included in @option{-O3}) is
16269 enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
16270
16271 @item max-inline-recursive-depth
16272 @itemx max-inline-recursive-depth-auto
16273 Specifies the maximum recursion depth used for recursive inlining.
16274
16275 @option{--param max-inline-recursive-depth} applies to functions
16276 declared inline. For functions not declared inline, recursive inlining
16277 happens only when @option{-finline-functions} (included in @option{-O3}) is
16278 enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
16279
16280 @item min-inline-recursive-probability
16281 Recursive inlining is profitable only for function having deep recursion
16282 in average and can hurt for function having little recursion depth by
16283 increasing the prologue size or complexity of function body to other
16284 optimizers.
16285
16286 When profile feedback is available (see @option{-fprofile-generate}) the actual
16287 recursion depth can be guessed from the probability that function recurses
16288 via a given call expression. This parameter limits inlining only to call
16289 expressions whose probability exceeds the given threshold (in percents).
16290
16291 @item early-inlining-insns
16292 Specify growth that the early inliner can make. In effect it increases
16293 the amount of inlining for code having a large abstraction penalty.
16294
16295 @item max-early-inliner-iterations
16296 Limit of iterations of the early inliner. This basically bounds
16297 the number of nested indirect calls the early inliner can resolve.
16298 Deeper chains are still handled by late inlining.
16299
16300 @item comdat-sharing-probability
16301 Probability (in percent) that C++ inline function with comdat visibility
16302 are shared across multiple compilation units.
16303
16304 @item modref-max-bases
16305 @item modref-max-refs
16306 @item modref-max-accesses
16307 Specifies the maximal number of base pointers, references and accesses stored
16308 for a single function by mod/ref analysis.
16309
16310 @item modref-max-tests
16311 Specifies the maxmal number of tests alias oracle can perform to disambiguate
16312 memory locations using the mod/ref information. This parameter ought to be
16313 bigger than @option{--param modref-max-bases} and @option{--param
16314 modref-max-refs}.
16315
16316 @item modref-max-depth
16317 Specifies the maximum depth of DFS walk used by modref escape analysis.
16318 Setting to 0 disables the analysis completely.
16319
16320 @item modref-max-escape-points
16321 Specifies the maximum number of escape points tracked by modref per SSA-name.
16322
16323 @item modref-max-adjustments
16324 Specifies the maximum number the access range is enlarged during modref dataflow
16325 analysis.
16326
16327 @item profile-func-internal-id
16328 A parameter to control whether to use function internal id in profile
16329 database lookup. If the value is 0, the compiler uses an id that
16330 is based on function assembler name and filename, which makes old profile
16331 data more tolerant to source changes such as function reordering etc.
16332
16333 @item min-vect-loop-bound
16334 The minimum number of iterations under which loops are not vectorized
16335 when @option{-ftree-vectorize} is used. The number of iterations after
16336 vectorization needs to be greater than the value specified by this option
16337 to allow vectorization.
16338
16339 @item gcse-cost-distance-ratio
16340 Scaling factor in calculation of maximum distance an expression
16341 can be moved by GCSE optimizations. This is currently supported only in the
16342 code hoisting pass. The bigger the ratio, the more aggressive code hoisting
16343 is with simple expressions, i.e., the expressions that have cost
16344 less than @option{gcse-unrestricted-cost}. Specifying 0 disables
16345 hoisting of simple expressions.
16346
16347 @item gcse-unrestricted-cost
16348 Cost, roughly measured as the cost of a single typical machine
16349 instruction, at which GCSE optimizations do not constrain
16350 the distance an expression can travel. This is currently
16351 supported only in the code hoisting pass. The lesser the cost,
16352 the more aggressive code hoisting is. Specifying 0
16353 allows all expressions to travel unrestricted distances.
16354
16355 @item max-hoist-depth
16356 The depth of search in the dominator tree for expressions to hoist.
16357 This is used to avoid quadratic behavior in hoisting algorithm.
16358 The value of 0 does not limit on the search, but may slow down compilation
16359 of huge functions.
16360
16361 @item max-tail-merge-comparisons
16362 The maximum amount of similar bbs to compare a bb with. This is used to
16363 avoid quadratic behavior in tree tail merging.
16364
16365 @item max-tail-merge-iterations
16366 The maximum amount of iterations of the pass over the function. This is used to
16367 limit compilation time in tree tail merging.
16368
16369 @item store-merging-allow-unaligned
16370 Allow the store merging pass to introduce unaligned stores if it is legal to
16371 do so.
16372
16373 @item max-stores-to-merge
16374 The maximum number of stores to attempt to merge into wider stores in the store
16375 merging pass.
16376
16377 @item max-store-chains-to-track
16378 The maximum number of store chains to track at the same time in the attempt
16379 to merge them into wider stores in the store merging pass.
16380
16381 @item max-stores-to-track
16382 The maximum number of stores to track at the same time in the attemt to
16383 to merge them into wider stores in the store merging pass.
16384
16385 @item max-unrolled-insns
16386 The maximum number of instructions that a loop may have to be unrolled.
16387 If a loop is unrolled, this parameter also determines how many times
16388 the loop code is unrolled.
16389
16390 @item max-average-unrolled-insns
16391 The maximum number of instructions biased by probabilities of their execution
16392 that a loop may have to be unrolled. If a loop is unrolled,
16393 this parameter also determines how many times the loop code is unrolled.
16394
16395 @item max-unroll-times
16396 The maximum number of unrollings of a single loop.
16397
16398 @item max-peeled-insns
16399 The maximum number of instructions that a loop may have to be peeled.
16400 If a loop is peeled, this parameter also determines how many times
16401 the loop code is peeled.
16402
16403 @item max-peel-times
16404 The maximum number of peelings of a single loop.
16405
16406 @item max-peel-branches
16407 The maximum number of branches on the hot path through the peeled sequence.
16408
16409 @item max-completely-peeled-insns
16410 The maximum number of insns of a completely peeled loop.
16411
16412 @item max-completely-peel-times
16413 The maximum number of iterations of a loop to be suitable for complete peeling.
16414
16415 @item max-completely-peel-loop-nest-depth
16416 The maximum depth of a loop nest suitable for complete peeling.
16417
16418 @item max-unswitch-insns
16419 The maximum number of insns of an unswitched loop.
16420
16421 @item max-unswitch-depth
16422 The maximum depth of a loop nest to be unswitched.
16423
16424 @item lim-expensive
16425 The minimum cost of an expensive expression in the loop invariant motion.
16426
16427 @item min-loop-cond-split-prob
16428 When FDO profile information is available, @option{min-loop-cond-split-prob}
16429 specifies minimum threshold for probability of semi-invariant condition
16430 statement to trigger loop split.
16431
16432 @item iv-consider-all-candidates-bound
16433 Bound on number of candidates for induction variables, below which
16434 all candidates are considered for each use in induction variable
16435 optimizations. If there are more candidates than this,
16436 only the most relevant ones are considered to avoid quadratic time complexity.
16437
16438 @item iv-max-considered-uses
16439 The induction variable optimizations give up on loops that contain more
16440 induction variable uses.
16441
16442 @item iv-always-prune-cand-set-bound
16443 If the number of candidates in the set is smaller than this value,
16444 always try to remove unnecessary ivs from the set
16445 when adding a new one.
16446
16447 @item avg-loop-niter
16448 Average number of iterations of a loop.
16449
16450 @item dse-max-object-size
16451 Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
16452 Larger values may result in larger compilation times.
16453
16454 @item dse-max-alias-queries-per-store
16455 Maximum number of queries into the alias oracle per store.
16456 Larger values result in larger compilation times and may result in more
16457 removed dead stores.
16458
16459 @item scev-max-expr-size
16460 Bound on size of expressions used in the scalar evolutions analyzer.
16461 Large expressions slow the analyzer.
16462
16463 @item scev-max-expr-complexity
16464 Bound on the complexity of the expressions in the scalar evolutions analyzer.
16465 Complex expressions slow the analyzer.
16466
16467 @item max-tree-if-conversion-phi-args
16468 Maximum number of arguments in a PHI supported by TREE if conversion
16469 unless the loop is marked with simd pragma.
16470
16471 @item vect-max-layout-candidates
16472 The maximum number of possible vector layouts (such as permutations)
16473 to consider when optimizing to-be-vectorized code.
16474
16475 @item vect-max-version-for-alignment-checks
16476 The maximum number of run-time checks that can be performed when
16477 doing loop versioning for alignment in the vectorizer.
16478
16479 @item vect-max-version-for-alias-checks
16480 The maximum number of run-time checks that can be performed when
16481 doing loop versioning for alias in the vectorizer.
16482
16483 @item vect-max-peeling-for-alignment
16484 The maximum number of loop peels to enhance access alignment
16485 for vectorizer. Value -1 means no limit.
16486
16487 @item max-iterations-to-track
16488 The maximum number of iterations of a loop the brute-force algorithm
16489 for analysis of the number of iterations of the loop tries to evaluate.
16490
16491 @item hot-bb-count-fraction
16492 The denominator n of fraction 1/n of the maximal execution count of a
16493 basic block in the entire program that a basic block needs to at least
16494 have in order to be considered hot. The default is 10000, which means
16495 that a basic block is considered hot if its execution count is greater
16496 than 1/10000 of the maximal execution count. 0 means that it is never
16497 considered hot. Used in non-LTO mode.
16498
16499 @item hot-bb-count-ws-permille
16500 The number of most executed permilles, ranging from 0 to 1000, of the
16501 profiled execution of the entire program to which the execution count
16502 of a basic block must be part of in order to be considered hot. The
16503 default is 990, which means that a basic block is considered hot if
16504 its execution count contributes to the upper 990 permilles, or 99.0%,
16505 of the profiled execution of the entire program. 0 means that it is
16506 never considered hot. Used in LTO mode.
16507
16508 @item hot-bb-frequency-fraction
16509 The denominator n of fraction 1/n of the execution frequency of the
16510 entry block of a function that a basic block of this function needs
16511 to at least have in order to be considered hot. The default is 1000,
16512 which means that a basic block is considered hot in a function if it
16513 is executed more frequently than 1/1000 of the frequency of the entry
16514 block of the function. 0 means that it is never considered hot.
16515
16516 @item unlikely-bb-count-fraction
16517 The denominator n of fraction 1/n of the number of profiled runs of
16518 the entire program below which the execution count of a basic block
16519 must be in order for the basic block to be considered unlikely executed.
16520 The default is 20, which means that a basic block is considered unlikely
16521 executed if it is executed in fewer than 1/20, or 5%, of the runs of
16522 the program. 0 means that it is always considered unlikely executed.
16523
16524 @item max-predicted-iterations
16525 The maximum number of loop iterations we predict statically. This is useful
16526 in cases where a function contains a single loop with known bound and
16527 another loop with unknown bound.
16528 The known number of iterations is predicted correctly, while
16529 the unknown number of iterations average to roughly 10. This means that the
16530 loop without bounds appears artificially cold relative to the other one.
16531
16532 @item builtin-expect-probability
16533 Control the probability of the expression having the specified value. This
16534 parameter takes a percentage (i.e.@: 0 ... 100) as input.
16535
16536 @item builtin-string-cmp-inline-length
16537 The maximum length of a constant string for a builtin string cmp call
16538 eligible for inlining.
16539
16540 @item align-threshold
16541
16542 Select fraction of the maximal frequency of executions of a basic block in
16543 a function to align the basic block.
16544
16545 @item align-loop-iterations
16546
16547 A loop expected to iterate at least the selected number of iterations is
16548 aligned.
16549
16550 @item tracer-dynamic-coverage
16551 @itemx tracer-dynamic-coverage-feedback
16552
16553 This value is used to limit superblock formation once the given percentage of
16554 executed instructions is covered. This limits unnecessary code size
16555 expansion.
16556
16557 The @option{tracer-dynamic-coverage-feedback} parameter
16558 is used only when profile
16559 feedback is available. The real profiles (as opposed to statically estimated
16560 ones) are much less balanced allowing the threshold to be larger value.
16561
16562 @item tracer-max-code-growth
16563 Stop tail duplication once code growth has reached given percentage. This is
16564 a rather artificial limit, as most of the duplicates are eliminated later in
16565 cross jumping, so it may be set to much higher values than is the desired code
16566 growth.
16567
16568 @item tracer-min-branch-ratio
16569
16570 Stop reverse growth when the reverse probability of best edge is less than this
16571 threshold (in percent).
16572
16573 @item tracer-min-branch-probability
16574 @itemx tracer-min-branch-probability-feedback
16575
16576 Stop forward growth if the best edge has probability lower than this
16577 threshold.
16578
16579 Similarly to @option{tracer-dynamic-coverage} two parameters are
16580 provided. @option{tracer-min-branch-probability-feedback} is used for
16581 compilation with profile feedback and @option{tracer-min-branch-probability}
16582 compilation without. The value for compilation with profile feedback
16583 needs to be more conservative (higher) in order to make tracer
16584 effective.
16585
16586 @item stack-clash-protection-guard-size
16587 Specify the size of the operating system provided stack guard as
16588 2 raised to @var{num} bytes. Higher values may reduce the
16589 number of explicit probes, but a value larger than the operating system
16590 provided guard will leave code vulnerable to stack clash style attacks.
16591
16592 @item stack-clash-protection-probe-interval
16593 Stack clash protection involves probing stack space as it is allocated. This
16594 param controls the maximum distance between probes into the stack as 2 raised
16595 to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
16596 larger than the operating system provided guard will leave code vulnerable to
16597 stack clash style attacks.
16598
16599 @item max-cse-path-length
16600
16601 The maximum number of basic blocks on path that CSE considers.
16602
16603 @item max-cse-insns
16604 The maximum number of instructions CSE processes before flushing.
16605
16606 @item ggc-min-expand
16607
16608 GCC uses a garbage collector to manage its own memory allocation. This
16609 parameter specifies the minimum percentage by which the garbage
16610 collector's heap should be allowed to expand between collections.
16611 Tuning this may improve compilation speed; it has no effect on code
16612 generation.
16613
16614 The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
16615 RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
16616 the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
16617 GCC is not able to calculate RAM on a particular platform, the lower
16618 bound of 30% is used. Setting this parameter and
16619 @option{ggc-min-heapsize} to zero causes a full collection to occur at
16620 every opportunity. This is extremely slow, but can be useful for
16621 debugging.
16622
16623 @item ggc-min-heapsize
16624
16625 Minimum size of the garbage collector's heap before it begins bothering
16626 to collect garbage. The first collection occurs after the heap expands
16627 by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
16628 tuning this may improve compilation speed, and has no effect on code
16629 generation.
16630
16631 The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
16632 tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
16633 with a lower bound of 4096 (four megabytes) and an upper bound of
16634 131072 (128 megabytes). If GCC is not able to calculate RAM on a
16635 particular platform, the lower bound is used. Setting this parameter
16636 very large effectively disables garbage collection. Setting this
16637 parameter and @option{ggc-min-expand} to zero causes a full collection
16638 to occur at every opportunity.
16639
16640 @item max-reload-search-insns
16641 The maximum number of instruction reload should look backward for equivalent
16642 register. Increasing values mean more aggressive optimization, making the
16643 compilation time increase with probably slightly better performance.
16644
16645 @item max-cselib-memory-locations
16646 The maximum number of memory locations cselib should take into account.
16647 Increasing values mean more aggressive optimization, making the compilation time
16648 increase with probably slightly better performance.
16649
16650 @item max-sched-ready-insns
16651 The maximum number of instructions ready to be issued the scheduler should
16652 consider at any given time during the first scheduling pass. Increasing
16653 values mean more thorough searches, making the compilation time increase
16654 with probably little benefit.
16655
16656 @item max-sched-region-blocks
16657 The maximum number of blocks in a region to be considered for
16658 interblock scheduling.
16659
16660 @item max-pipeline-region-blocks
16661 The maximum number of blocks in a region to be considered for
16662 pipelining in the selective scheduler.
16663
16664 @item max-sched-region-insns
16665 The maximum number of insns in a region to be considered for
16666 interblock scheduling.
16667
16668 @item max-pipeline-region-insns
16669 The maximum number of insns in a region to be considered for
16670 pipelining in the selective scheduler.
16671
16672 @item min-spec-prob
16673 The minimum probability (in percents) of reaching a source block
16674 for interblock speculative scheduling.
16675
16676 @item max-sched-extend-regions-iters
16677 The maximum number of iterations through CFG to extend regions.
16678 A value of 0 disables region extensions.
16679
16680 @item max-sched-insn-conflict-delay
16681 The maximum conflict delay for an insn to be considered for speculative motion.
16682
16683 @item sched-spec-prob-cutoff
16684 The minimal probability of speculation success (in percents), so that
16685 speculative insns are scheduled.
16686
16687 @item sched-state-edge-prob-cutoff
16688 The minimum probability an edge must have for the scheduler to save its
16689 state across it.
16690
16691 @item sched-mem-true-dep-cost
16692 Minimal distance (in CPU cycles) between store and load targeting same
16693 memory locations.
16694
16695 @item selsched-max-lookahead
16696 The maximum size of the lookahead window of selective scheduling. It is a
16697 depth of search for available instructions.
16698
16699 @item selsched-max-sched-times
16700 The maximum number of times that an instruction is scheduled during
16701 selective scheduling. This is the limit on the number of iterations
16702 through which the instruction may be pipelined.
16703
16704 @item selsched-insns-to-rename
16705 The maximum number of best instructions in the ready list that are considered
16706 for renaming in the selective scheduler.
16707
16708 @item sms-min-sc
16709 The minimum value of stage count that swing modulo scheduler
16710 generates.
16711
16712 @item max-last-value-rtl
16713 The maximum size measured as number of RTLs that can be recorded in an expression
16714 in combiner for a pseudo register as last known value of that register.
16715
16716 @item max-combine-insns
16717 The maximum number of instructions the RTL combiner tries to combine.
16718
16719 @item max-combine-search-insns
16720 The maximum number of instructions that the RTL combiner searches in order
16721 to find the next use of a given register definition. If this limit is reached
16722 without finding such a use, the combiner will stop trying to optimize the
16723 definition.
16724
16725 Currently this limit only applies after certain successful combination
16726 attempts, but it could be extended to other cases in future.
16727
16728 @item integer-share-limit
16729 Small integer constants can use a shared data structure, reducing the
16730 compiler's memory usage and increasing its speed. This sets the maximum
16731 value of a shared integer constant.
16732
16733 @item ssp-buffer-size
16734 The minimum size of buffers (i.e.@: arrays) that receive stack smashing
16735 protection when @option{-fstack-protector} is used.
16736
16737 @item min-size-for-stack-sharing
16738 The minimum size of variables taking part in stack slot sharing when not
16739 optimizing.
16740
16741 @item max-jump-thread-duplication-stmts
16742 Maximum number of statements allowed in a block that needs to be
16743 duplicated when threading jumps.
16744
16745 @item max-jump-thread-paths
16746 The maximum number of paths to consider when searching for jump threading
16747 opportunities. When arriving at a block, incoming edges are only considered
16748 if the number of paths to be searched so far multiplied by the number of
16749 incoming edges does not exhaust the specified maximum number of paths to
16750 consider.
16751
16752 @item max-fields-for-field-sensitive
16753 Maximum number of fields in a structure treated in
16754 a field sensitive manner during pointer analysis.
16755
16756 @item prefetch-latency
16757 Estimate on average number of instructions that are executed before
16758 prefetch finishes. The distance prefetched ahead is proportional
16759 to this constant. Increasing this number may also lead to less
16760 streams being prefetched (see @option{simultaneous-prefetches}).
16761
16762 @item simultaneous-prefetches
16763 Maximum number of prefetches that can run at the same time.
16764
16765 @item l1-cache-line-size
16766 The size of cache line in L1 data cache, in bytes.
16767
16768 @item l1-cache-size
16769 The size of L1 data cache, in kilobytes.
16770
16771 @item l2-cache-size
16772 The size of L2 data cache, in kilobytes.
16773
16774 @item prefetch-dynamic-strides
16775 Whether the loop array prefetch pass should issue software prefetch hints
16776 for strides that are non-constant. In some cases this may be
16777 beneficial, though the fact the stride is non-constant may make it
16778 hard to predict when there is clear benefit to issuing these hints.
16779
16780 Set to 1 if the prefetch hints should be issued for non-constant
16781 strides. Set to 0 if prefetch hints should be issued only for strides that
16782 are known to be constant and below @option{prefetch-minimum-stride}.
16783
16784 @item prefetch-minimum-stride
16785 Minimum constant stride, in bytes, to start using prefetch hints for. If
16786 the stride is less than this threshold, prefetch hints will not be issued.
16787
16788 This setting is useful for processors that have hardware prefetchers, in
16789 which case there may be conflicts between the hardware prefetchers and
16790 the software prefetchers. If the hardware prefetchers have a maximum
16791 stride they can handle, it should be used here to improve the use of
16792 software prefetchers.
16793
16794 A value of -1 means we don't have a threshold and therefore
16795 prefetch hints can be issued for any constant stride.
16796
16797 This setting is only useful for strides that are known and constant.
16798
16799 @item destructive-interference-size
16800 @item constructive-interference-size
16801 The values for the C++17 variables
16802 @code{std::hardware_destructive_interference_size} and
16803 @code{std::hardware_constructive_interference_size}. The destructive
16804 interference size is the minimum recommended offset between two
16805 independent concurrently-accessed objects; the constructive
16806 interference size is the maximum recommended size of contiguous memory
16807 accessed together. Typically both will be the size of an L1 cache
16808 line for the target, in bytes. For a generic target covering a range of L1
16809 cache line sizes, typically the constructive interference size will be
16810 the small end of the range and the destructive size will be the large
16811 end.
16812
16813 The destructive interference size is intended to be used for layout,
16814 and thus has ABI impact. The default value is not expected to be
16815 stable, and on some targets varies with @option{-mtune}, so use of
16816 this variable in a context where ABI stability is important, such as
16817 the public interface of a library, is strongly discouraged; if it is
16818 used in that context, users can stabilize the value using this
16819 option.
16820
16821 The constructive interference size is less sensitive, as it is
16822 typically only used in a @samp{static_assert} to make sure that a type
16823 fits within a cache line.
16824
16825 See also @option{-Winterference-size}.
16826
16827 @item loop-interchange-max-num-stmts
16828 The maximum number of stmts in a loop to be interchanged.
16829
16830 @item loop-interchange-stride-ratio
16831 The minimum ratio between stride of two loops for interchange to be profitable.
16832
16833 @item min-insn-to-prefetch-ratio
16834 The minimum ratio between the number of instructions and the
16835 number of prefetches to enable prefetching in a loop.
16836
16837 @item prefetch-min-insn-to-mem-ratio
16838 The minimum ratio between the number of instructions and the
16839 number of memory references to enable prefetching in a loop.
16840
16841 @item use-canonical-types
16842 Whether the compiler should use the ``canonical'' type system.
16843 Should always be 1, which uses a more efficient internal
16844 mechanism for comparing types in C++ and Objective-C++. However, if
16845 bugs in the canonical type system are causing compilation failures,
16846 set this value to 0 to disable canonical types.
16847
16848 @item switch-conversion-max-branch-ratio
16849 Switch initialization conversion refuses to create arrays that are
16850 bigger than @option{switch-conversion-max-branch-ratio} times the number of
16851 branches in the switch.
16852
16853 @item switch-lower-slow-alg-max-cases
16854 Maximum number of cases for slow switch lowering algorithms to be used.
16855
16856 @item max-partial-antic-length
16857 Maximum length of the partial antic set computed during the tree
16858 partial redundancy elimination optimization (@option{-ftree-pre}) when
16859 optimizing at @option{-O3} and above. For some sorts of source code
16860 the enhanced partial redundancy elimination optimization can run away,
16861 consuming all of the memory available on the host machine. This
16862 parameter sets a limit on the length of the sets that are computed,
16863 which prevents the runaway behavior. Setting a value of 0 for
16864 this parameter allows an unlimited set length.
16865
16866 @item rpo-vn-max-loop-depth
16867 Maximum loop depth that is value-numbered optimistically.
16868 When the limit hits the innermost
16869 @var{rpo-vn-max-loop-depth} loops and the outermost loop in the
16870 loop nest are value-numbered optimistically and the remaining ones not.
16871
16872 @item sccvn-max-alias-queries-per-access
16873 Maximum number of alias-oracle queries we perform when looking for
16874 redundancies for loads and stores. If this limit is hit the search
16875 is aborted and the load or store is not considered redundant. The
16876 number of queries is algorithmically limited to the number of
16877 stores on all paths from the load to the function entry.
16878
16879 @item ira-max-loops-num
16880 IRA uses regional register allocation by default. If a function
16881 contains more loops than the number given by this parameter, only at most
16882 the given number of the most frequently-executed loops form regions
16883 for regional register allocation.
16884
16885 @item ira-max-conflict-table-size
16886 Although IRA uses a sophisticated algorithm to compress the conflict
16887 table, the table can still require excessive amounts of memory for
16888 huge functions. If the conflict table for a function could be more
16889 than the size in MB given by this parameter, the register allocator
16890 instead uses a faster, simpler, and lower-quality
16891 algorithm that does not require building a pseudo-register conflict table.
16892
16893 @item ira-loop-reserved-regs
16894 IRA can be used to evaluate more accurate register pressure in loops
16895 for decisions to move loop invariants (see @option{-O3}). The number
16896 of available registers reserved for some other purposes is given
16897 by this parameter. Default of the parameter
16898 is the best found from numerous experiments.
16899
16900 @item ira-consider-dup-in-all-alts
16901 Make IRA to consider matching constraint (duplicated operand number)
16902 heavily in all available alternatives for preferred register class.
16903 If it is set as zero, it means IRA only respects the matching
16904 constraint when it's in the only available alternative with an
16905 appropriate register class. Otherwise, it means IRA will check all
16906 available alternatives for preferred register class even if it has
16907 found some choice with an appropriate register class and respect the
16908 found qualified matching constraint.
16909
16910 @item ira-simple-lra-insn-threshold
16911 Approximate function insn number in 1K units triggering simple local RA.
16912
16913 @item lra-inheritance-ebb-probability-cutoff
16914 LRA tries to reuse values reloaded in registers in subsequent insns.
16915 This optimization is called inheritance. EBB is used as a region to
16916 do this optimization. The parameter defines a minimal fall-through
16917 edge probability in percentage used to add BB to inheritance EBB in
16918 LRA. The default value was chosen
16919 from numerous runs of SPEC2000 on x86-64.
16920
16921 @item loop-invariant-max-bbs-in-loop
16922 Loop invariant motion can be very expensive, both in compilation time and
16923 in amount of needed compile-time memory, with very large loops. Loops
16924 with more basic blocks than this parameter won't have loop invariant
16925 motion optimization performed on them.
16926
16927 @item loop-max-datarefs-for-datadeps
16928 Building data dependencies is expensive for very large loops. This
16929 parameter limits the number of data references in loops that are
16930 considered for data dependence analysis. These large loops are no
16931 handled by the optimizations using loop data dependencies.
16932
16933 @item max-vartrack-size
16934 Sets a maximum number of hash table slots to use during variable
16935 tracking dataflow analysis of any function. If this limit is exceeded
16936 with variable tracking at assignments enabled, analysis for that
16937 function is retried without it, after removing all debug insns from
16938 the function. If the limit is exceeded even without debug insns, var
16939 tracking analysis is completely disabled for the function. Setting
16940 the parameter to zero makes it unlimited.
16941
16942 @item max-vartrack-expr-depth
16943 Sets a maximum number of recursion levels when attempting to map
16944 variable names or debug temporaries to value expressions. This trades
16945 compilation time for more complete debug information. If this is set too
16946 low, value expressions that are available and could be represented in
16947 debug information may end up not being used; setting this higher may
16948 enable the compiler to find more complex debug expressions, but compile
16949 time and memory use may grow.
16950
16951 @item max-debug-marker-count
16952 Sets a threshold on the number of debug markers (e.g.@: begin stmt
16953 markers) to avoid complexity explosion at inlining or expanding to RTL.
16954 If a function has more such gimple stmts than the set limit, such stmts
16955 will be dropped from the inlined copy of a function, and from its RTL
16956 expansion.
16957
16958 @item min-nondebug-insn-uid
16959 Use uids starting at this parameter for nondebug insns. The range below
16960 the parameter is reserved exclusively for debug insns created by
16961 @option{-fvar-tracking-assignments}, but debug insns may get
16962 (non-overlapping) uids above it if the reserved range is exhausted.
16963
16964 @item ipa-sra-deref-prob-threshold
16965 IPA-SRA replaces a pointer which is known not be NULL with one or more
16966 new parameters only when the probability (in percent, relative to
16967 function entry) of it being dereferenced is higher than this parameter.
16968
16969 @item ipa-sra-ptr-growth-factor
16970 IPA-SRA replaces a pointer to an aggregate with one or more new
16971 parameters only when their cumulative size is less or equal to
16972 @option{ipa-sra-ptr-growth-factor} times the size of the original
16973 pointer parameter.
16974
16975 @item ipa-sra-ptrwrap-growth-factor
16976 Additional maximum allowed growth of total size of new parameters
16977 that ipa-sra replaces a pointer to an aggregate with,
16978 if it points to a local variable that the caller only writes to and
16979 passes it as an argument to other functions.
16980
16981 @item ipa-sra-max-replacements
16982 Maximum pieces of an aggregate that IPA-SRA tracks. As a
16983 consequence, it is also the maximum number of replacements of a formal
16984 parameter.
16985
16986 @item sra-max-scalarization-size-Ospeed
16987 @itemx sra-max-scalarization-size-Osize
16988 The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
16989 replace scalar parts of aggregates with uses of independent scalar
16990 variables. These parameters control the maximum size, in storage units,
16991 of aggregate which is considered for replacement when compiling for
16992 speed
16993 (@option{sra-max-scalarization-size-Ospeed}) or size
16994 (@option{sra-max-scalarization-size-Osize}) respectively.
16995
16996 @item sra-max-propagations
16997 The maximum number of artificial accesses that Scalar Replacement of
16998 Aggregates (SRA) will track, per one local variable, in order to
16999 facilitate copy propagation.
17000
17001 @item tm-max-aggregate-size
17002 When making copies of thread-local variables in a transaction, this
17003 parameter specifies the size in bytes after which variables are
17004 saved with the logging functions as opposed to save/restore code
17005 sequence pairs. This option only applies when using
17006 @option{-fgnu-tm}.
17007
17008 @item graphite-max-nb-scop-params
17009 To avoid exponential effects in the Graphite loop transforms, the
17010 number of parameters in a Static Control Part (SCoP) is bounded.
17011 A value of zero can be used to lift
17012 the bound. A variable whose value is unknown at compilation time and
17013 defined outside a SCoP is a parameter of the SCoP.
17014
17015 @item hardcfr-max-blocks
17016 Disable @option{-fharden-control-flow-redundancy} for functions with a
17017 larger number of blocks than the specified value. Zero removes any
17018 limit.
17019
17020 @item hardcfr-max-inline-blocks
17021 Force @option{-fharden-control-flow-redundancy} to use out-of-line
17022 checking for functions with a larger number of basic blocks than the
17023 specified value.
17024
17025 @item loop-block-tile-size
17026 Loop blocking or strip mining transforms, enabled with
17027 @option{-floop-block} or @option{-floop-strip-mine}, strip mine each
17028 loop in the loop nest by a given number of iterations. The strip
17029 length can be changed using the @option{loop-block-tile-size}
17030 parameter.
17031
17032 @item ipa-jump-function-lookups
17033 Specifies number of statements visited during jump function offset discovery.
17034
17035 @item ipa-cp-value-list-size
17036 IPA-CP attempts to track all possible values and types passed to a function's
17037 parameter in order to propagate them and perform devirtualization.
17038 @option{ipa-cp-value-list-size} is the maximum number of values and types it
17039 stores per one formal parameter of a function.
17040
17041 @item ipa-cp-eval-threshold
17042 IPA-CP calculates its own score of cloning profitability heuristics
17043 and performs those cloning opportunities with scores that exceed
17044 @option{ipa-cp-eval-threshold}.
17045
17046 @item ipa-cp-max-recursive-depth
17047 Maximum depth of recursive cloning for self-recursive function.
17048
17049 @item ipa-cp-min-recursive-probability
17050 Recursive cloning only when the probability of call being executed exceeds
17051 the parameter.
17052
17053 @item ipa-cp-recursive-freq-factor
17054 The number of times interprocedural copy propagation expects recursive
17055 functions to call themselves.
17056
17057 @item ipa-cp-recursion-penalty
17058 Percentage penalty the recursive functions will receive when they
17059 are evaluated for cloning.
17060
17061 @item ipa-cp-single-call-penalty
17062 Percentage penalty functions containing a single call to another
17063 function will receive when they are evaluated for cloning.
17064
17065 @item ipa-max-agg-items
17066 IPA-CP is also capable to propagate a number of scalar values passed
17067 in an aggregate. @option{ipa-max-agg-items} controls the maximum
17068 number of such values per one parameter.
17069
17070 @item ipa-cp-loop-hint-bonus
17071 When IPA-CP determines that a cloning candidate would make the number
17072 of iterations of a loop known, it adds a bonus of
17073 @option{ipa-cp-loop-hint-bonus} to the profitability score of
17074 the candidate.
17075
17076 @item ipa-max-loop-predicates
17077 The maximum number of different predicates IPA will use to describe when
17078 loops in a function have known properties.
17079
17080 @item ipa-max-aa-steps
17081 During its analysis of function bodies, IPA-CP employs alias analysis
17082 in order to track values pointed to by function parameters. In order
17083 not spend too much time analyzing huge functions, it gives up and
17084 consider all memory clobbered after examining
17085 @option{ipa-max-aa-steps} statements modifying memory.
17086
17087 @item ipa-max-switch-predicate-bounds
17088 Maximal number of boundary endpoints of case ranges of switch statement.
17089 For switch exceeding this limit, IPA-CP will not construct cloning cost
17090 predicate, which is used to estimate cloning benefit, for default case
17091 of the switch statement.
17092
17093 @item ipa-max-param-expr-ops
17094 IPA-CP will analyze conditional statement that references some function
17095 parameter to estimate benefit for cloning upon certain constant value.
17096 But if number of operations in a parameter expression exceeds
17097 @option{ipa-max-param-expr-ops}, the expression is treated as complicated
17098 one, and is not handled by IPA analysis.
17099
17100 @item lto-partitions
17101 Specify desired number of partitions produced during WHOPR compilation.
17102 The number of partitions should exceed the number of CPUs used for compilation.
17103
17104 @item lto-min-partition
17105 Size of minimal partition for WHOPR (in estimated instructions).
17106 This prevents expenses of splitting very small programs into too many
17107 partitions.
17108
17109 @item lto-max-partition
17110 Size of max partition for WHOPR (in estimated instructions).
17111 to provide an upper bound for individual size of partition.
17112 Meant to be used only with balanced partitioning.
17113
17114 @item lto-partition-locality-frequency-cutoff
17115 The denominator n of fraction 1/n of the execution frequency of callee to be
17116 cloned for a particular caller. Special value of 0 dictates to always clone
17117 without a cut-off.
17118
17119 @item lto-partition-locality-size-cutoff
17120 Size cut-off for callee including inlined calls to be cloned for a particular
17121 caller.
17122
17123 @item lto-max-locality-partition
17124 Maximal size of a locality partition for LTO (in estimated instructions).
17125 Value of 0 results in default value being used.
17126
17127 @item lto-max-streaming-parallelism
17128 Maximal number of parallel processes used for LTO streaming.
17129
17130 @item cxx-max-namespaces-for-diagnostic-help
17131 The maximum number of namespaces to consult for suggestions when C++
17132 name lookup fails for an identifier.
17133
17134 @item sink-frequency-threshold
17135 The maximum relative execution frequency (in percents) of the target block
17136 relative to a statement's original block to allow statement sinking of a
17137 statement. Larger numbers result in more aggressive statement sinking.
17138 A small positive adjustment is applied for
17139 statements with memory operands as those are even more profitable so sink.
17140
17141 @item max-stores-to-sink
17142 The maximum number of conditional store pairs that can be sunk. Set to 0
17143 if either vectorization (@option{-ftree-vectorize}) or if-conversion
17144 (@option{-ftree-loop-if-convert}) is disabled.
17145
17146 @item case-values-threshold
17147 The smallest number of different values for which it is best to use a
17148 jump-table instead of a tree of conditional branches. If the value is
17149 0, use the default for the machine.
17150
17151 @item jump-table-max-growth-ratio-for-size
17152 The maximum code size growth ratio when expanding
17153 into a jump table (in percent). The parameter is used when
17154 optimizing for size.
17155
17156 @item jump-table-max-growth-ratio-for-speed
17157 The maximum code size growth ratio when expanding
17158 into a jump table (in percent). The parameter is used when
17159 optimizing for speed.
17160
17161 @item tree-reassoc-width
17162 Set the maximum number of instructions executed in parallel in
17163 reassociated tree. This parameter overrides target dependent
17164 heuristics used by default if has non zero value.
17165
17166 @item sched-pressure-algorithm
17167 Choose between the two available implementations of
17168 @option{-fsched-pressure}. Algorithm 1 is the original implementation
17169 and is the more likely to prevent instructions from being reordered.
17170 Algorithm 2 was designed to be a compromise between the relatively
17171 conservative approach taken by algorithm 1 and the rather aggressive
17172 approach taken by the default scheduler. It relies more heavily on
17173 having a regular register file and accurate register pressure classes.
17174 See @file{haifa-sched.cc} in the GCC sources for more details.
17175
17176 The default choice depends on the target.
17177
17178 @item max-slsr-cand-scan
17179 Set the maximum number of existing candidates that are considered when
17180 seeking a basis for a new straight-line strength reduction candidate.
17181
17182 @item asan-globals
17183 Enable buffer overflow detection for global objects. This kind
17184 of protection is enabled by default if you are using
17185 @option{-fsanitize=address} option.
17186 To disable global objects protection use @option{--param asan-globals=0}.
17187
17188 @item asan-stack
17189 Enable buffer overflow detection for stack objects. This kind of
17190 protection is enabled by default when using @option{-fsanitize=address}.
17191 To disable stack protection use @option{--param asan-stack=0} option.
17192
17193 @item asan-instrument-reads
17194 Enable buffer overflow detection for memory reads. This kind of
17195 protection is enabled by default when using @option{-fsanitize=address}.
17196 To disable memory reads protection use
17197 @option{--param asan-instrument-reads=0}.
17198
17199 @item asan-instrument-writes
17200 Enable buffer overflow detection for memory writes. This kind of
17201 protection is enabled by default when using @option{-fsanitize=address}.
17202 To disable memory writes protection use
17203 @option{--param asan-instrument-writes=0} option.
17204
17205 @item asan-memintrin
17206 Enable detection for built-in functions. This kind of protection
17207 is enabled by default when using @option{-fsanitize=address}.
17208 To disable built-in functions protection use
17209 @option{--param asan-memintrin=0}.
17210
17211 @item asan-use-after-return
17212 Enable detection of use-after-return. This kind of protection
17213 is enabled by default when using the @option{-fsanitize=address} option.
17214 To disable it use @option{--param asan-use-after-return=0}.
17215
17216 Note: By default the check is disabled at run time. To enable it,
17217 add @code{detect_stack_use_after_return=1} to the environment variable
17218 @env{ASAN_OPTIONS}.
17219
17220 @item asan-instrumentation-with-call-threshold
17221 If number of memory accesses in function being instrumented
17222 is greater or equal to this number, use callbacks instead of inline checks.
17223 E.g. to disable inline code use
17224 @option{--param asan-instrumentation-with-call-threshold=0}.
17225
17226 @item asan-kernel-mem-intrinsic-prefix
17227 If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
17228 with @samp{__asan_} or @samp{__hwasan_}
17229 for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
17230 respectively.
17231
17232 @item hwasan-instrument-stack
17233 Enable hwasan instrumentation of statically sized stack-allocated variables.
17234 This kind of instrumentation is enabled by default when using
17235 @option{-fsanitize=hwaddress} and disabled by default when using
17236 @option{-fsanitize=kernel-hwaddress}.
17237 To disable stack instrumentation use
17238 @option{--param hwasan-instrument-stack=0}, and to enable it use
17239 @option{--param hwasan-instrument-stack=1}.
17240
17241 @item hwasan-random-frame-tag
17242 When using stack instrumentation, decide tags for stack variables using a
17243 deterministic sequence beginning at a random tag for each frame. With this
17244 parameter unset tags are chosen using the same sequence but beginning from 1.
17245 This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
17246 for @option{-fsanitize=kernel-hwaddress}.
17247 To disable it use @option{--param hwasan-random-frame-tag=0}.
17248
17249 @item hwasan-instrument-allocas
17250 Enable hwasan instrumentation of dynamically sized stack-allocated variables.
17251 This kind of instrumentation is enabled by default when using
17252 @option{-fsanitize=hwaddress} and disabled by default when using
17253 @option{-fsanitize=kernel-hwaddress}.
17254 To disable instrumentation of such variables use
17255 @option{--param hwasan-instrument-allocas=0}, and to enable it use
17256 @option{--param hwasan-instrument-allocas=1}.
17257
17258 @item hwasan-instrument-reads
17259 Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
17260 default for both @option{-fsanitize=hwaddress} and
17261 @option{-fsanitize=kernel-hwaddress}.
17262 To disable checking memory reads use
17263 @option{--param hwasan-instrument-reads=0}.
17264
17265 @item hwasan-instrument-writes
17266 Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
17267 default for both @option{-fsanitize=hwaddress} and
17268 @option{-fsanitize=kernel-hwaddress}.
17269 To disable checking memory writes use
17270 @option{--param hwasan-instrument-writes=0}.
17271
17272 @item hwasan-instrument-mem-intrinsics
17273 Enable hwasan instrumentation of builtin functions. Instrumentation of these
17274 builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
17275 and @option{-fsanitize=kernel-hwaddress}.
17276 To disable instrumentation of builtin functions use
17277 @option{--param hwasan-instrument-mem-intrinsics=0}.
17278
17279 @item use-after-scope-direct-emission-threshold
17280 If the size of a local variable in bytes is smaller or equal to this
17281 number, directly poison (or unpoison) shadow memory instead of using
17282 run-time callbacks.
17283
17284 @item tsan-distinguish-volatile
17285 Emit special instrumentation for accesses to volatiles.
17286
17287 @item tsan-instrument-func-entry-exit
17288 Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
17289
17290 @item max-fsm-thread-path-insns
17291 Maximum number of instructions to copy when duplicating blocks on a
17292 finite state automaton jump thread path.
17293
17294 @item threader-debug
17295 threader-debug=[none|all] Enables verbose dumping of the threader solver.
17296
17297 @item parloops-chunk-size
17298 Chunk size of omp schedule for loops parallelized by parloops.
17299
17300 @item parloops-schedule
17301 Schedule type of omp schedule for loops parallelized by parloops (static,
17302 dynamic, guided, auto, runtime).
17303
17304 @item parloops-min-per-thread
17305 The minimum number of iterations per thread of an innermost parallelized
17306 loop for which the parallelized variant is preferred over the single threaded
17307 one. Note that for a parallelized loop nest the
17308 minimum number of iterations of the outermost loop per thread is two.
17309
17310 @item max-ssa-name-query-depth
17311 Maximum depth of recursion when querying properties of SSA names in things
17312 like fold routines. One level of recursion corresponds to following a
17313 use-def chain.
17314
17315 @item max-speculative-devirt-maydefs
17316 The maximum number of may-defs we analyze when looking for a must-def
17317 specifying the dynamic type of an object that invokes a virtual call
17318 we may be able to devirtualize speculatively.
17319
17320 @item ranger-debug
17321 Specifies the type of debug output to be issued for ranges.
17322
17323 @item unroll-jam-min-percent
17324 The minimum percentage of memory references that must be optimized
17325 away for the unroll-and-jam transformation to be considered profitable.
17326
17327 @item unroll-jam-max-unroll
17328 The maximum number of times the outer loop should be unrolled by
17329 the unroll-and-jam transformation.
17330
17331 @item max-rtl-if-conversion-unpredictable-cost
17332 Maximum permissible cost for the sequence that would be generated
17333 by the RTL if-conversion pass for a branch that is considered unpredictable.
17334
17335 @item max-variable-expansions-in-unroller
17336 If @option{-fvariable-expansion-in-unroller} is used, the maximum number
17337 of times that an individual variable will be expanded during loop unrolling.
17338
17339 @item partial-inlining-entry-probability
17340 Maximum probability of the entry BB of split region
17341 (in percent relative to entry BB of the function)
17342 to make partial inlining happen.
17343
17344 @item max-tracked-strlens
17345 Maximum number of strings for which strlen optimization pass will
17346 track string lengths.
17347
17348 @item gcse-after-reload-partial-fraction
17349 The threshold ratio for performing partial redundancy
17350 elimination after reload.
17351
17352 @item gcse-after-reload-critical-fraction
17353 The threshold ratio of critical edges execution count that
17354 permit performing redundancy elimination after reload.
17355
17356 @item max-loop-header-insns
17357 The maximum number of insns in loop header duplicated
17358 by the copy loop headers pass.
17359
17360 @item vect-epilogues-nomask
17361 Enable loop epilogue vectorization using smaller vector size.
17362
17363 @item vect-partial-vector-usage
17364 Controls when the loop vectorizer considers using partial vector loads
17365 and stores as an alternative to falling back to scalar code. 0 stops
17366 the vectorizer from ever using partial vector loads and stores. 1 allows
17367 partial vector loads and stores if vectorization removes the need for the
17368 code to iterate. 2 allows partial vector loads and stores in all loops.
17369 The parameter only has an effect on targets that support partial
17370 vector loads and stores.
17371
17372 @item vect-inner-loop-cost-factor
17373 The maximum factor which the loop vectorizer applies to the cost of statements
17374 in an inner loop relative to the loop being vectorized. The factor applied
17375 is the maximum of the estimated number of iterations of the inner loop and
17376 this parameter. The default value of this parameter is 50.
17377
17378 @item vect-induction-float
17379 Enable loop vectorization of floating point inductions.
17380
17381 @item vect-scalar-cost-multiplier
17382 Apply the given multiplier % to scalar loop costing during vectorization.
17383 Increasing the cost multiplier will make vector loops more profitable.
17384
17385 @item vrp-block-limit
17386 Maximum number of basic blocks before VRP switches to a lower memory algorithm.
17387
17388 @item vrp-sparse-threshold
17389 Maximum number of basic blocks before VRP uses a sparse bitmap cache.
17390
17391 @item vrp-switch-limit
17392 Maximum number of outgoing edges in a switch before VRP will not process it.
17393
17394 @item vrp-vector-threshold
17395 Maximum number of basic blocks for VRP to use a basic cache vector.
17396
17397 @item avoid-fma-max-bits
17398 Maximum number of bits for which we avoid creating FMAs.
17399
17400 @item fully-pipelined-fma
17401 Whether the target fully pipelines FMA instructions. If non-zero,
17402 reassociation considers the benefit of parallelizing FMA's multiplication
17403 part and addition part, assuming FMUL and FMA use the same units that can
17404 also do FADD.
17405
17406 @item sms-loop-average-count-threshold
17407 A threshold on the average loop count considered by the swing modulo scheduler.
17408
17409 @item sms-dfa-history
17410 The number of cycles the swing modulo scheduler considers when checking
17411 conflicts using DFA.
17412
17413 @item graphite-allow-codegen-errors
17414 Whether codegen errors should be ICEs when @option{-fchecking}.
17415
17416 @item sms-max-ii-factor
17417 A factor for tuning the upper bound that swing modulo scheduler
17418 uses for scheduling a loop.
17419
17420 @item lra-max-considered-reload-pseudos
17421 The max number of reload pseudos which are considered during
17422 spilling a non-reload pseudo.
17423
17424 @item max-pow-sqrt-depth
17425 Maximum depth of sqrt chains to use when synthesizing exponentiation
17426 by a real constant.
17427
17428 @item max-dse-active-local-stores
17429 Maximum number of active local stores in RTL dead store elimination.
17430
17431 @item asan-instrument-allocas
17432 Enable asan allocas/VLAs protection.
17433
17434 @item max-iterations-computation-cost
17435 Bound on the cost of an expression to compute the number of iterations.
17436
17437 @item max-isl-operations
17438 Maximum number of isl operations, 0 means unlimited.
17439
17440 @item graphite-max-arrays-per-scop
17441 Maximum number of arrays per scop.
17442
17443 @item max-vartrack-reverse-op-size
17444 Max. size of loc list for which reverse ops should be added.
17445
17446 @item fsm-scale-path-stmts
17447 Scale factor to apply to the number of statements in a threading path
17448 crossing a loop backedge when comparing to
17449 @option{--param=max-jump-thread-duplication-stmts}.
17450
17451 @item uninit-control-dep-attempts
17452 Maximum number of nested calls to search for control dependencies
17453 during uninitialized variable analysis.
17454
17455 @item uninit-max-chain-len
17456 Maximum number of predicates anded for each predicate ored in the normalized
17457 predicate chain.
17458
17459 @item uninit-max-num-chains
17460 Maximum number of predicates ored in the normalized predicate chain.
17461
17462 @item uninit-max-prune-work
17463 Maximum amount of work done to prune paths where the variable is always initialized.
17464
17465 @item sched-autopref-queue-depth
17466 Hardware autoprefetcher scheduler model control flag.
17467 Number of lookahead cycles the model looks into; at '
17468 ' only enable instruction sorting heuristic.
17469
17470 @item loop-versioning-max-inner-insns
17471 The maximum number of instructions that an inner loop can have
17472 before the loop versioning pass considers it too big to copy.
17473
17474 @item loop-versioning-max-outer-insns
17475 The maximum number of instructions that an outer loop can have
17476 before the loop versioning pass considers it too big to copy,
17477 discounting any instructions in inner loops that directly benefit
17478 from versioning.
17479
17480 @item ssa-name-def-chain-limit
17481 The maximum number of SSA_NAME assignments to follow in determining
17482 a property of a variable such as its value. This limits the number
17483 of iterations or recursive calls GCC performs when optimizing certain
17484 statements or when determining their validity prior to issuing
17485 diagnostics.
17486
17487 @item store-merging-max-size
17488 Maximum size of a single store merging region in bytes.
17489
17490 @item store-forwarding-max-distance
17491 Maximum number of instruction distance that a small store forwarded to a larger
17492 load may stall. Value '0' disables the cost checks for the
17493 avoid-store-forwarding pass.
17494
17495 @item hash-table-verification-limit
17496 The number of elements for which hash table verification is done
17497 for each searched element.
17498
17499 @item max-find-base-term-values
17500 Maximum number of VALUEs handled during a single find_base_term call.
17501
17502 @item analyzer-max-enodes-per-program-point
17503 The maximum number of exploded nodes per program point within
17504 the analyzer, before terminating analysis of that point.
17505
17506 @item analyzer-max-constraints
17507 The maximum number of constraints per state.
17508
17509 @item analyzer-min-snodes-for-call-summary
17510 The minimum number of supernodes within a function for the
17511 analyzer to consider summarizing its effects at call sites.
17512
17513 @item analyzer-max-enodes-for-full-dump
17514 The maximum depth of exploded nodes that should appear in a dot dump
17515 before switching to a less verbose format.
17516
17517 @item analyzer-max-recursion-depth
17518 The maximum number of times a callsite can appear in a call stack
17519 within the analyzer, before terminating analysis of a call that would
17520 recurse deeper.
17521
17522 @item analyzer-max-svalue-depth
17523 The maximum depth of a symbolic value, before approximating
17524 the value as unknown.
17525
17526 @item analyzer-max-infeasible-edges
17527 The maximum number of infeasible edges to reject before declaring
17528 a diagnostic as infeasible.
17529
17530 @item gimple-fe-computed-hot-bb-threshold
17531 The number of executions of a basic block which is considered hot.
17532 The parameter is used only in GIMPLE FE.
17533
17534 @item analyzer-bb-explosion-factor
17535 The maximum number of 'after supernode' exploded nodes within the analyzer
17536 per supernode, before terminating analysis.
17537
17538 @item analyzer-text-art-string-ellipsis-threshold
17539 The number of bytes at which to ellipsize string literals in analyzer text art diagrams.
17540
17541 @item analyzer-text-art-ideal-canvas-width
17542 The ideal width in characters of text art diagrams generated by the analyzer.
17543
17544 @item analyzer-text-art-string-ellipsis-head-len
17545 The number of literal bytes to show at the head of a string literal in text art when ellipsizing it.
17546
17547 @item analyzer-text-art-string-ellipsis-tail-len
17548 The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it.
17549
17550 @item ranger-logical-depth
17551 Maximum depth of logical expression evaluation ranger will look through
17552 when evaluating outgoing edge ranges.
17553
17554 @item ranger-recompute-depth
17555 Maximum depth of instruction chains to consider for recomputation
17556 in the outgoing range calculator.
17557
17558 @item relation-block-limit
17559 Maximum number of relations the oracle will register in a basic block.
17560
17561 @item transitive-relations-work-bound
17562 Work bound when discovering transitive relations from existing relations.
17563
17564 @item min-pagesize
17565 Minimum page size for warning and early break vectorization purposes.
17566
17567 @item openacc-kernels
17568 Specify mode of OpenACC `kernels' constructs handling.
17569 With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
17570 constructs are decomposed into parts, a sequence of compute
17571 constructs, each then handled individually.
17572 This is work in progress.
17573 With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
17574 constructs are handled by the @samp{parloops} pass, en bloc.
17575 This is the current default.
17576
17577 @item openacc-privatization
17578 Control whether the @option{-fopt-info-omp-note} and applicable
17579 @option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
17580 With @option{--param=openacc-privatization=quiet}, don't diagnose.
17581 This is the current default.
17582 With @option{--param=openacc-privatization=noisy}, do diagnose.
17583
17584 @item cycle-accurate-model
17585 Specifies whether GCC should assume that the scheduling description is mostly
17586 a cycle-accurate model of the target processor the code is intended to
17587 run on, in the absence of cache misses. Nonzero means that the selected
17588 scheduling model is accurate and likely describes an in-order processor,
17589 and that scheduling should aggressively spill to try and fill any pipeline
17590 bubbles. This is the current default. Zero means the scheduling description
17591 might not be available/accurate or perhaps not applicable at all, such as for
17592 modern out-of-order processors.
17593
17594 @end table
17595
17596 The following choices of @var{name} are available on AArch64 targets:
17597
17598 @table @gcctabopt
17599 @item aarch64-vect-compare-costs
17600 When vectorizing, consider using multiple different approaches and use
17601 the cost model to choose the cheapest one. This includes:
17602
17603 @itemize
17604 @item
17605 Trying both SVE and Advanced SIMD, when SVE is available.
17606
17607 @item
17608 Trying to use 64-bit Advanced SIMD vectors for the smallest data elements,
17609 rather than using 128-bit vectors for everything.
17610
17611 @item
17612 Trying to use ``unpacked'' SVE vectors for smaller elements. This includes
17613 storing smaller elements in larger containers and accessing elements with
17614 extending loads and truncating stores.
17615 @end itemize
17616
17617 @item aarch64-float-recp-precision
17618 The number of Newton iterations for calculating the reciprocal for float type.
17619 The precision of division is proportional to this param when division
17620 approximation is enabled. The default value is 1.
17621
17622 @item aarch64-double-recp-precision
17623 The number of Newton iterations for calculating the reciprocal for double type.
17624 The precision of division is proportional to this param when division
17625 approximation is enabled. The default value is 2.
17626
17627 @item aarch64-autovec-preference
17628 An old alias for @option{-mautovec-preference}. If both
17629 @option{-mautovec-preference} and @option{--param=aarch64-autovec-preference}
17630 are passed, the @option{--param} value will be used.
17631
17632 @item aarch64-ldp-policy
17633 Fine-grained policy for load pairs.
17634 With @option{--param=aarch64-ldp-policy=default}, use the policy of the
17635 tuning structure. This is the current default.
17636 With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless
17637 of alignment.
17638 With @option{--param=aarch64-ldp-policy=never}, do not emit ldp.
17639 With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the
17640 source pointer is aligned to at least double the alignment of the type.
17641
17642 @item aarch64-stp-policy
17643 Fine-grained policy for store pairs.
17644 With @option{--param=aarch64-stp-policy=default}, use the policy of the
17645 tuning structure. This is the current default.
17646 With @option{--param=aarch64-stp-policy=always}, emit stp regardless
17647 of alignment.
17648 With @option{--param=aarch64-stp-policy=never}, do not emit stp.
17649 With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the
17650 source pointer is aligned to at least double the alignment of the type.
17651
17652 @item aarch64-ldp-alias-check-limit
17653 Limit on the number of alias checks performed by the AArch64 load/store pair
17654 fusion pass when attempting to form an ldp/stp. Higher values make the pass
17655 more aggressive at re-ordering loads over stores, at the expense of increased
17656 compile time.
17657
17658 @item aarch64-ldp-writeback
17659 Param to control which writeback opportunities we try to handle in the AArch64
17660 load/store pair fusion pass. A value of zero disables writeback handling. One
17661 means we try to form pairs involving one or more existing individual writeback
17662 accesses where possible. A value of two means we also try to opportunistically
17663 form writeback opportunities by folding in trailing destructive updates of the
17664 base register used by a pair.
17665
17666 @item aarch64-loop-vect-issue-rate-niters
17667 The tuning for some AArch64 CPUs tries to take both latencies and issue
17668 rates into account when deciding whether a loop should be vectorized
17669 using SVE, vectorized using Advanced SIMD, or not vectorized at all.
17670 If this parameter is set to @var{n}, GCC will not use this heuristic
17671 for loops that are known to execute in fewer than @var{n} Advanced
17672 SIMD iterations.
17673
17674 @item aarch64-vect-unroll-limit
17675 The vectorizer will use available tuning information to determine whether it
17676 would be beneficial to unroll the main vectorized loop and by how much. This
17677 parameter set's the upper bound of how much the vectorizer will unroll the main
17678 loop. The default value is four.
17679
17680 @end table
17681
17682 The following choices of @var{name} are available on GCN targets:
17683
17684 @table @gcctabopt
17685 @item gcn-preferred-vectorization-factor
17686 Preferred vectorization factor: @samp{default}, @samp{32}, @samp{64}.
17687
17688 @end table
17689
17690 The following choices of @var{name} are available on i386 and x86_64 targets:
17691
17692 @table @gcctabopt
17693 @item x86-stlf-window-ninsns
17694 Instructions number above which STFL stall penalty can be compensated.
17695
17696 @item x86-stv-max-visits
17697 The maximum number of use and def visits when discovering a STV chain before
17698 the discovery is aborted.
17699
17700 @end table
17701
17702 @end table
17703
17704 @node Instrumentation Options
17705 @section Program Instrumentation Options
17706 @cindex instrumentation options
17707 @cindex program instrumentation options
17708 @cindex run-time error checking options
17709 @cindex profiling options
17710 @cindex options, program instrumentation
17711 @cindex options, run-time error checking
17712 @cindex options, profiling
17713
17714 GCC supports a number of command-line options that control adding
17715 run-time instrumentation to the code it normally generates.
17716 For example, one purpose of instrumentation is collect profiling
17717 statistics for use in finding program hot spots, code coverage
17718 analysis, or profile-guided optimizations.
17719 Another class of program instrumentation is adding run-time checking
17720 to detect programming errors like invalid pointer
17721 dereferences or out-of-bounds array accesses, as well as deliberately
17722 hostile attacks such as stack smashing or C++ vtable hijacking.
17723 There is also a general hook which can be used to implement other
17724 forms of tracing or function-level instrumentation for debug or
17725 program analysis purposes.
17726
17727 @table @gcctabopt
17728 @cindex @command{prof}
17729 @cindex @command{gprof}
17730 @opindex p
17731 @opindex pg
17732 @item -p
17733 @itemx -pg
17734 Generate extra code to write profile information suitable for the
17735 analysis program @command{prof} (for @option{-p}) or @command{gprof}
17736 (for @option{-pg}). You must use this option when compiling
17737 the source files you want data about, and you must also use it when
17738 linking.
17739
17740 You can use the function attribute @code{no_instrument_function} to
17741 suppress profiling of individual functions when compiling with these options.
17742 @xref{Common Function Attributes}.
17743
17744 @opindex fprofile-arcs
17745 @item -fprofile-arcs
17746 Add code so that program flow @dfn{arcs} are instrumented. During
17747 execution the program records how many times each branch and call is
17748 executed and how many times it is taken or returns. On targets that support
17749 constructors with priority support, profiling properly handles constructors,
17750 destructors and C++ constructors (and destructors) of classes which are used
17751 as a type of a global variable.
17752
17753 When the compiled
17754 program exits it saves this data to a file called
17755 @file{@var{auxname}.gcda} for each source file. The data may be used for
17756 profile-directed optimizations (@option{-fbranch-probabilities}), or for
17757 test coverage analysis (@option{-ftest-coverage}). Each object file's
17758 @var{auxname} is generated from the name of the output file, if
17759 explicitly specified and it is not the final executable, otherwise it is
17760 the basename of the source file. In both cases any suffix is removed
17761 (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
17762 @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
17763
17764 Note that if a command line directly links source files, the corresponding
17765 @var{.gcda} files will be prefixed with the unsuffixed name of the output file.
17766 E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
17767 @file{binary-b.gcda} files.
17768
17769 @item -fcondition-coverage
17770 @opindex fcondition-coverage
17771 Add code so that program conditions are instrumented. During execution the
17772 program records what terms in a conditional contributes to a decision, which
17773 can be used to verify that all terms in a Boolean function are tested and have
17774 an independent effect on the outcome of a decision. The result can be read
17775 with @code{gcov --conditions}.
17776
17777 @item -fpath-coverage
17778 @opindex fpath-coverage
17779 Add code so that the paths taken are tracked. During execution the
17780 program records the prime paths taken. The number of paths grows very
17781 fast with complexity, and to avoid exploding compile times GCC will give
17782 up instrumentation if the approximate number of paths exceeds the limit
17783 controlled by @option{-fpath-coverage-limit}. The result can be read
17784 with @code{gcov --prime-paths --prime-paths-lines --prime-paths-source},
17785 @xref{gcov prime paths example}.
17786
17787 @item -fpath-coverage-limit=@var{limit}
17788 @opindex fpath-coverage-limit
17789 The threshold at which point @option{-fpath-coverage} gives up on
17790 instrumenting a function. This limit is approximate and conservative,
17791 as GCC uses a pessimistic heuristic which slightly overcounts the
17792 running number of paths, and gives up if the threshold is reached before
17793 finding all the paths. This option is not for fine grained control over
17794 which functions to instrument - rather it is intended to limit the
17795 effect of path explosion and keep compile times reasonable. The default
17796 is @var{250000}.
17797
17798 @xref{Cross-profiling}.
17799
17800 @cindex @command{gcov}
17801 @opindex coverage
17802 @item --coverage
17803
17804 This option is used to compile and link code instrumented for coverage
17805 analysis. The option is a synonym for @option{-fprofile-arcs}
17806 @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
17807 linking). See the documentation for those options for more details.
17808
17809 @itemize
17810
17811 @item
17812 Compile the source files with @option{-fprofile-arcs} plus optimization
17813 and code generation options. For test coverage analysis, use the
17814 additional @option{-ftest-coverage} option. You do not need to profile
17815 every source file in a program.
17816
17817 @item
17818 Compile the source files additionally with @option{-fprofile-abs-path}
17819 to create absolute path names in the @file{.gcno} files. This allows
17820 @command{gcov} to find the correct sources in projects where compilations
17821 occur with different working directories.
17822
17823 @item
17824 Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
17825 (the latter implies the former).
17826
17827 @item
17828 Run the program on a representative workload to generate the arc profile
17829 information. This may be repeated any number of times. You can run
17830 concurrent instances of your program, and provided that the file system
17831 supports locking, the data files will be correctly updated. Unless
17832 a strict ISO C dialect option is in effect, @code{fork} calls are
17833 detected and correctly handled without double counting.
17834
17835 Moreover, an object file can be recompiled multiple times
17836 and the corresponding @file{.gcda} file merges as long as
17837 the source file and the compiler options are unchanged.
17838
17839 @item
17840 For profile-directed optimizations, compile the source files again with
17841 the same optimization and code generation options plus
17842 @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
17843 Control Optimization}).
17844
17845 @item
17846 For test coverage analysis, use @command{gcov} to produce human readable
17847 information from the @file{.gcno} and @file{.gcda} files. Refer to the
17848 @command{gcov} documentation for further information.
17849
17850 @end itemize
17851
17852 With @option{-fprofile-arcs}, for each function of your program GCC
17853 creates a program flow graph, then finds a spanning tree for the graph.
17854 Only arcs that are not on the spanning tree have to be instrumented: the
17855 compiler adds code to count the number of times that these arcs are
17856 executed. When an arc is the only exit or only entrance to a block, the
17857 instrumentation code can be added to the block; otherwise, a new basic
17858 block must be created to hold the instrumentation code.
17859
17860 With @option{-fcondition-coverage}, for each conditional in your program GCC
17861 creates a bitset and records the exercised boolean values that have an
17862 independent effect on the outcome of that expression.
17863
17864 With @option{-fpath-coverage}, GCC finds and enumerates and records the
17865 taken prime paths of each function, unless the number of paths would
17866 exceed the limit controlled by @option{-fpath-coverage-limit}. If the
17867 limit is exceeded the function is not instrumented as if
17868 @option{-fpath-coverage} was not used. A prime path is the longest
17869 sequence of unique blocks, except possibly the first and last, which is
17870 not a subpath of any other path.
17871
17872 @need 2000
17873 @opindex ftest-coverage
17874 @item -ftest-coverage
17875 Produce a notes file that the @command{gcov} code-coverage utility
17876 (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
17877 show program coverage. Each source file's note file is called
17878 @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
17879 above for a description of @var{auxname} and instructions on how to
17880 generate test coverage data. Coverage data matches the source files
17881 more closely if you do not optimize.
17882
17883 @opindex fprofile-abs-path
17884 @item -fprofile-abs-path
17885 Automatically convert relative source file names to absolute path names
17886 in the @file{.gcno} files. This allows @command{gcov} to find the correct
17887 sources in projects where compilations occur with different working
17888 directories.
17889
17890 @opindex fprofile-dir
17891 @item -fprofile-dir=@var{path}
17892
17893 Set the directory to search for the profile data files in to @var{path}.
17894 This option affects only the profile data generated by
17895 @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
17896 and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
17897 and its related options. Both absolute and relative paths can be used.
17898 By default, GCC uses the current directory as @var{path}, thus the
17899 profile data file appears in the same directory as the object file.
17900 In order to prevent the file name clashing, if the object file name is
17901 not an absolute path, we mangle the absolute path of the
17902 @file{@var{sourcename}.gcda} file and use it as the file name of a
17903 @file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
17904 See similar option @option{-fprofile-note}.
17905
17906 When an executable is run in a massive parallel environment, it is recommended
17907 to save profile to different folders. That can be done with variables
17908 in @var{path} that are exported during run-time:
17909
17910 @table @gcctabopt
17911
17912 @item %p
17913 process ID.
17914
17915 @item %q@{VAR@}
17916 value of environment variable @var{VAR}
17917
17918 @end table
17919
17920 @opindex fprofile-generate
17921 @item -fprofile-generate
17922 @itemx -fprofile-generate=@var{path}
17923
17924 Enable options usually used for instrumenting application to produce
17925 profile useful for later recompilation with profile feedback based
17926 optimization. You must use @option{-fprofile-generate} both when
17927 compiling and when linking your program.
17928
17929 The following options are enabled:
17930 @option{-fprofile-arcs}, @option{-fprofile-values},
17931 @option{-finline-functions}, and @option{-fipa-bit-cp}.
17932
17933 If @var{path} is specified, GCC looks at the @var{path} to find
17934 the profile feedback data files. See @option{-fprofile-dir}.
17935
17936 To optimize the program based on the collected profile information, use
17937 @option{-fprofile-use}. @xref{Optimize Options}, for more information.
17938
17939 @opindex fprofile-info-section
17940 @item -fprofile-info-section
17941 @itemx -fprofile-info-section=@var{name}
17942
17943 Register the profile information in the specified section instead of using a
17944 constructor/destructor. The section name is @var{name} if it is specified,
17945 otherwise the section name defaults to @code{.gcov_info}. A pointer to the
17946 profile information generated by @option{-fprofile-arcs} is placed in the
17947 specified section for each translation unit. This option disables the profile
17948 information registration through a constructor and it disables the profile
17949 information processing through a destructor. This option is not intended to be
17950 used in hosted environments such as GNU/Linux. It targets freestanding
17951 environments (for example embedded systems) with limited resources which do not
17952 support constructors/destructors or the C library file I/O.
17953
17954 The linker could collect the input sections in a continuous memory block and
17955 define start and end symbols. A GNU linker script example which defines a
17956 linker output section follows:
17957
17958 @smallexample
17959 .gcov_info :
17960 @{
17961 PROVIDE (__gcov_info_start = .);
17962 KEEP (*(.gcov_info))
17963 PROVIDE (__gcov_info_end = .);
17964 @}
17965 @end smallexample
17966
17967 The program could dump the profiling information registered in this linker set
17968 for example like this:
17969
17970 @smallexample
17971 #include <gcov.h>
17972 #include <stdio.h>
17973 #include <stdlib.h>
17974
17975 extern const struct gcov_info *const __gcov_info_start[];
17976 extern const struct gcov_info *const __gcov_info_end[];
17977
17978 static void
17979 dump (const void *d, unsigned n, void *arg)
17980 @{
17981 const unsigned char *c = d;
17982
17983 for (unsigned i = 0; i < n; ++i)
17984 printf ("%02x", c[i]);
17985 @}
17986
17987 static void
17988 filename (const char *f, void *arg)
17989 @{
17990 __gcov_filename_to_gcfn (f, dump, arg );
17991 @}
17992
17993 static void *
17994 allocate (unsigned length, void *arg)
17995 @{
17996 return malloc (length);
17997 @}
17998
17999 static void
18000 dump_gcov_info (void)
18001 @{
18002 const struct gcov_info *const *info = __gcov_info_start;
18003 const struct gcov_info *const *end = __gcov_info_end;
18004
18005 /* Obfuscate variable to prevent compiler optimizations. */
18006 __asm__ ("" : "+r" (info));
18007
18008 while (info != end)
18009 @{
18010 void *arg = NULL;
18011 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
18012 putchar ('\n');
18013 ++info;
18014 @}
18015 @}
18016
18017 int
18018 main (void)
18019 @{
18020 dump_gcov_info ();
18021 return 0;
18022 @}
18023 @end smallexample
18024
18025 The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
18026 deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
18027 @code{__gcov_info_to_gcda} functions and merge the profile information into
18028 @file{.gcda} files on the host filesystem.
18029
18030 @opindex fprofile-note
18031 @item -fprofile-note=@var{path}
18032
18033 If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
18034 location. If you combine the option with multiple source files,
18035 the @file{.gcno} file will be overwritten.
18036
18037 @opindex fprofile-prefix-path
18038 @item -fprofile-prefix-path=@var{path}
18039
18040 This option can be used in combination with
18041 @option{profile-generate=}@var{profile_dir} and
18042 @option{profile-use=}@var{profile_dir} to inform GCC where is the base
18043 directory of built source tree. By default @var{profile_dir} will contain
18044 files with mangled absolute paths of all object files in the built project.
18045 This is not desirable when directory used to build the instrumented binary
18046 differs from the directory used to build the binary optimized with profile
18047 feedback because the profile data will not be found during the optimized build.
18048 In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
18049 pointing to the base directory of the build can be used to strip the irrelevant
18050 part of the path and keep all file names relative to the main build directory.
18051
18052 @opindex fprofile-prefix-map
18053 @item -fprofile-prefix-map=@var{old}=@var{new}
18054 When compiling files residing in directory @file{@var{old}}, record
18055 profiling information (with @option{--coverage})
18056 describing them as if the files resided in
18057 directory @file{@var{new}} instead.
18058 See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
18059
18060 @opindex fprofile-update
18061 @item -fprofile-update=@var{method}
18062
18063 Alter the update method for an application instrumented for profile
18064 feedback based optimization. The @var{method} argument should be one of
18065 @samp{single}, @samp{atomic} or @samp{prefer-atomic}.
18066 The first one is useful for single-threaded applications,
18067 while the second one prevents profile corruption by emitting thread-safe code.
18068
18069 @strong{Warning:} When an application does not properly join all threads
18070 (or creates an detached thread), a profile file can be still corrupted.
18071
18072 Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
18073 when supported by a target, or to @samp{single} otherwise. The GCC driver
18074 automatically selects @samp{prefer-atomic} when @option{-pthread}
18075 is present in the command line, otherwise the default method is @samp{single}.
18076
18077 If @samp{atomic} is selected, then the profile information is updated using
18078 atomic operations on a best-effort basis. Ideally, the profile information is
18079 updated through atomic operations in hardware. If the target platform does not
18080 support the required atomic operations in hardware, however, @file{libatomic}
18081 is available, then the profile information is updated through calls to
18082 @file{libatomic}. If the target platform neither supports the required atomic
18083 operations in hardware nor @file{libatomic}, then the profile information is
18084 not atomically updated and a warning is issued. In this case, the obtained
18085 profiling information may be corrupt for multi-threaded applications.
18086
18087 For performance reasons, if 64-bit counters are used for the profiling
18088 information and the target platform only supports 32-bit atomic operations in
18089 hardware, then the performance critical profiling updates are done using two
18090 32-bit atomic operations for each counter update. If a signal interrupts these
18091 two operations updating a counter, then the profiling information may be in an
18092 inconsistent state.
18093
18094 @opindex fprofile-filter-files
18095 @item -fprofile-filter-files=@var{regex}
18096
18097 Instrument only functions from files whose name matches
18098 any of the regular expressions (separated by semi-colons).
18099
18100 For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
18101 only @file{main.c} and all C files starting with 'module'.
18102
18103 @opindex fprofile-exclude-files
18104 @item -fprofile-exclude-files=@var{regex}
18105
18106 Instrument only functions from files whose name does not match
18107 any of the regular expressions (separated by semi-colons).
18108
18109 For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
18110 of all files that are located in the @file{/usr/} folder.
18111
18112 @opindex fprofile-reproducible
18113 @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
18114 Control level of reproducibility of profile gathered by
18115 @code{-fprofile-generate}. This makes it possible to rebuild program
18116 with same outcome which is useful, for example, for distribution
18117 packages.
18118
18119 With @option{-fprofile-reproducible=serial} the profile gathered by
18120 @option{-fprofile-generate} is reproducible provided the trained program
18121 behaves the same at each invocation of the train run, it is not
18122 multi-threaded and profile data streaming is always done in the same
18123 order. Note that profile streaming happens at the end of program run but
18124 also before @code{fork} function is invoked.
18125
18126 Note that it is quite common that execution counts of some part of
18127 programs depends, for example, on length of temporary file names or
18128 memory space randomization (that may affect hash-table collision rate).
18129 Such non-reproducible part of programs may be annotated by
18130 @code{no_instrument_function} function attribute. @command{gcov-dump} with
18131 @option{-l} can be used to dump gathered data and verify that they are
18132 indeed reproducible.
18133
18134 With @option{-fprofile-reproducible=parallel-runs} collected profile
18135 stays reproducible regardless the order of streaming of the data into
18136 gcda files. This setting makes it possible to run multiple instances of
18137 instrumented program in parallel (such as with @code{make -j}). This
18138 reduces quality of gathered data, in particular of indirect call
18139 profiling.
18140
18141 @opindex fsanitize=address
18142 @item -fsanitize=address
18143 Enable AddressSanitizer, a fast memory error detector.
18144 Memory access instructions are instrumented to detect
18145 out-of-bounds and use-after-free bugs.
18146 The option enables @option{-fsanitize-address-use-after-scope}.
18147 See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
18148 more details. The run-time behavior can be influenced using the
18149 @env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
18150 the available options are shown at startup of the instrumented program. See
18151 @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
18152 for a list of supported options.
18153 The option cannot be combined with @option{-fsanitize=thread} or
18154 @option{-fsanitize=hwaddress}. Note that the only targets
18155 @option{-fsanitize=hwaddress} is currently supported on are x86-64
18156 (only with @code{-mlam=u48} or @code{-mlam=u57} options) and AArch64,
18157 in both cases only in ABIs with 64-bit pointers.
18158
18159 When compiling with @option{-fsanitize=address}, you should also
18160 use @option{-g} to produce more meaningful output.
18161 To get more accurate stack traces, it is possible to use options such as
18162 @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
18163 most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
18164 optimizing sibling and tail recursive calls; this option is implicit for
18165 @option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
18166 disables Identical Code Folding for functions).
18167 Using @option{-fno-omit-frame-pointer} also improves stack traces.
18168 Since multiple runs of the
18169 program may yield backtraces with different addresses due to ASLR (Address
18170 Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
18171 this can be achieved with @samp{setarch `uname -m` -R ./prog}.
18172
18173 @opindex fsanitize=kernel-address
18174 @item -fsanitize=kernel-address
18175 Enable AddressSanitizer for Linux kernel.
18176 See @uref{https://github.com/google/kernel-sanitizers} for more details.
18177
18178 @opindex fsanitize=hwaddress
18179 @item -fsanitize=hwaddress
18180 Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
18181 ignore the top byte of a pointer to allow the detection of memory errors with
18182 a low memory overhead.
18183 Memory access instructions are instrumented to detect out-of-bounds and
18184 use-after-free bugs.
18185 The option enables @option{-fsanitize-address-use-after-scope}.
18186 See
18187 @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
18188 for more details. The run-time behavior can be influenced using the
18189 @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
18190 the available options are shown at startup of the instrumented program.
18191 The option cannot be combined with @option{-fsanitize=thread} or
18192 @option{-fsanitize=address}, and is currently only available on AArch64.
18193
18194 @opindex fsanitize=kernel-hwaddress
18195 @item -fsanitize=kernel-hwaddress
18196 Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
18197 Similar to @option{-fsanitize=kernel-address} but using an alternate
18198 instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
18199 instrumentation differences necessary for compiling the Linux kernel.
18200 These differences are to avoid hwasan library initialization calls and to
18201 account for the stack pointer having a different value in its top byte.
18202
18203 @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
18204 Instrumenting the stack and alloca calls are not on by default but are still
18205 possible by specifying the command-line options
18206 @option{--param hwasan-instrument-stack=1} and
18207 @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
18208 tag is not implemented for kernel instrumentation.
18209
18210 @opindex fsanitize=pointer-compare
18211 @item -fsanitize=pointer-compare
18212 Instrument comparison operation (<, <=, >, >=) with pointer operands.
18213 The option must be combined with either @option{-fsanitize=kernel-address} or
18214 @option{-fsanitize=address}
18215 The option cannot be combined with @option{-fsanitize=thread}.
18216 Note: By default the check is disabled at run time. To enable it,
18217 add @code{detect_invalid_pointer_pairs=2} to the environment variable
18218 @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
18219 invalid operation only when both pointers are non-null.
18220
18221 @opindex fsanitize=pointer-subtract
18222 @item -fsanitize=pointer-subtract
18223 Instrument subtraction with pointer operands.
18224 The option must be combined with either @option{-fsanitize=kernel-address} or
18225 @option{-fsanitize=address}
18226 The option cannot be combined with @option{-fsanitize=thread}.
18227 Note: By default the check is disabled at run time. To enable it,
18228 add @code{detect_invalid_pointer_pairs=2} to the environment variable
18229 @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
18230 invalid operation only when both pointers are non-null.
18231
18232 @opindex fsanitize=shadow-call-stack
18233 @item -fsanitize=shadow-call-stack
18234 Enable ShadowCallStack, a security enhancement mechanism used to protect
18235 programs against return address overwrites (e.g. stack buffer overflows.)
18236 It works by saving a function's return address to a separately allocated
18237 shadow call stack in the function prologue and restoring the return address
18238 from the shadow call stack in the function epilogue. Instrumentation only
18239 occurs in functions that need to save the return address to the stack.
18240
18241 Currently it only supports the aarch64 platform. It is specifically
18242 designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
18243 For the user space programs, runtime support is not currently provided
18244 in libc and libgcc. Users who want to use this feature in user space need
18245 to provide their own support for the runtime. It should be noted that
18246 this may cause the ABI rules to be broken.
18247
18248 On aarch64, the instrumentation makes use of the platform register @code{x18}.
18249 This generally means that any code that may run on the same thread as code
18250 compiled with ShadowCallStack must be compiled with the flag
18251 @option{-ffixed-x18}, otherwise functions compiled without
18252 @option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
18253 stack pointer.
18254
18255 Also, because there is no userspace runtime support, code compiled with
18256 ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
18257 to turn off exceptions.
18258
18259 See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
18260 details.
18261
18262 @opindex fsanitize=thread
18263 @item -fsanitize=thread
18264 Enable ThreadSanitizer, a fast data race detector.
18265 Memory access instructions are instrumented to detect
18266 data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
18267 details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
18268 environment variable; see
18269 @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
18270 supported options.
18271 The option cannot be combined with @option{-fsanitize=address},
18272 @option{-fsanitize=leak}.
18273
18274 When compiling with @option{-fsanitize=thread}, you should also use
18275 @option{-g} to produce more meaningful output.
18276
18277 Note that sanitized atomic builtins cannot throw exceptions when
18278 operating on invalid memory addresses with non-call exceptions
18279 (@option{-fnon-call-exceptions}).
18280
18281 @opindex fsanitize=leak
18282 @item -fsanitize=leak
18283 Enable LeakSanitizer, a memory leak detector.
18284 This option only matters for linking of executables.
18285 The executable is linked against a library that overrides @code{malloc}
18286 and other allocator functions. See
18287 @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
18288 details. The run-time behavior can be influenced using the
18289 @env{LSAN_OPTIONS} environment variable.
18290 The option cannot be combined with @option{-fsanitize=thread}.
18291
18292 @opindex fsanitize=undefined
18293 @item -fsanitize=undefined
18294 Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
18295 Various computations are instrumented to detect undefined behavior
18296 at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
18297 @env{UBSAN_OPTIONS} environment variable. Current suboptions are:
18298
18299 @table @gcctabopt
18300
18301 @opindex fsanitize=shift
18302 @item -fsanitize=shift
18303 This option enables checking that the result of a shift operation is
18304 not undefined. Note that what exactly is considered undefined differs
18305 slightly between C and C++, as well as between ISO C90 and C99, etc.
18306 This option has two suboptions, @option{-fsanitize=shift-base} and
18307 @option{-fsanitize=shift-exponent}.
18308
18309 @opindex fsanitize=shift-exponent
18310 @item -fsanitize=shift-exponent
18311 This option enables checking that the second argument of a shift operation
18312 is not negative and is smaller than the precision of the promoted first
18313 argument.
18314
18315 @opindex fsanitize=shift-base
18316 @item -fsanitize=shift-base
18317 If the second argument of a shift operation is within range, check that the
18318 result of a shift operation is not undefined. Note that what exactly is
18319 considered undefined differs slightly between C and C++, as well as between
18320 ISO C90 and C99, etc.
18321
18322 @opindex fsanitize=integer-divide-by-zero
18323 @item -fsanitize=integer-divide-by-zero
18324 Detect integer division by zero.
18325
18326 @opindex fsanitize=unreachable
18327 @item -fsanitize=unreachable
18328 With this option, the compiler turns the @code{__builtin_unreachable}
18329 call into a diagnostics message call instead. When reaching the
18330 @code{__builtin_unreachable} call, the behavior is undefined.
18331
18332 @opindex fsanitize=vla-bound
18333 @item -fsanitize=vla-bound
18334 This option instructs the compiler to check that the size of a variable
18335 length array is positive.
18336
18337 @opindex fsanitize=null
18338 @item -fsanitize=null
18339 This option enables pointer checking. Particularly, the application
18340 built with this option turned on will issue an error message when it
18341 tries to dereference a NULL pointer, or if a reference (possibly an
18342 rvalue reference) is bound to a NULL pointer, or if a method is invoked
18343 on an object pointed by a NULL pointer.
18344
18345 @opindex fsanitize=return
18346 @item -fsanitize=return
18347 This option enables return statement checking. Programs
18348 built with this option turned on will issue an error message
18349 when the end of a non-void function is reached without actually
18350 returning a value. This option works in C++ only.
18351
18352 @opindex fsanitize=signed-integer-overflow
18353 @item -fsanitize=signed-integer-overflow
18354 This option enables signed integer overflow checking. We check that
18355 the result of @code{+}, @code{*}, and both unary and binary @code{-}
18356 does not overflow in the signed arithmetics. This also detects
18357 @code{INT_MIN / -1} signed division. Note, integer promotion
18358 rules must be taken into account. That is, the following is not an
18359 overflow:
18360 @smallexample
18361 signed char a = SCHAR_MAX;
18362 a++;
18363 @end smallexample
18364
18365 @opindex fsanitize=bounds
18366 @item -fsanitize=bounds
18367 This option enables instrumentation of array bounds. Various out of bounds
18368 accesses are detected. Flexible array members, flexible array member-like
18369 arrays, and initializers of variables with static storage are not
18370 instrumented, with the exception of flexible array member-like arrays
18371 for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
18372 options or @code{strict_flex_array} attributes say they shouldn't be treated
18373 like flexible array member-like arrays.
18374
18375 @opindex fsanitize=bounds-strict
18376 @item -fsanitize=bounds-strict
18377 This option enables strict instrumentation of array bounds. Most out of bounds
18378 accesses are detected, including flexible array member-like arrays.
18379 Initializers of variables with static storage are not instrumented.
18380
18381 @opindex fsanitize=alignment
18382 @item -fsanitize=alignment
18383
18384 This option enables checking of alignment of pointers when they are
18385 dereferenced, or when a reference is bound to insufficiently aligned target,
18386 or when a method or constructor is invoked on insufficiently aligned object.
18387
18388 @opindex fsanitize=object-size
18389 @item -fsanitize=object-size
18390 This option enables instrumentation of memory references using the
18391 @code{__builtin_dynamic_object_size} function. Various out of bounds
18392 pointer accesses are detected.
18393
18394 @opindex fsanitize=float-divide-by-zero
18395 @item -fsanitize=float-divide-by-zero
18396 Detect floating-point division by zero. Unlike other similar options,
18397 @option{-fsanitize=float-divide-by-zero} is not enabled by
18398 @option{-fsanitize=undefined}, since floating-point division by zero can
18399 be a legitimate way of obtaining infinities and NaNs.
18400
18401 @opindex fsanitize=float-cast-overflow
18402 @item -fsanitize=float-cast-overflow
18403 This option enables floating-point type to integer conversion checking.
18404 We check that the result of the conversion does not overflow.
18405 Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
18406 not enabled by @option{-fsanitize=undefined}.
18407 This option does not work well with @code{FE_INVALID} exceptions enabled.
18408
18409 @opindex fsanitize=nonnull-attribute
18410 @item -fsanitize=nonnull-attribute
18411
18412 This option enables instrumentation of calls, checking whether null values
18413 are not passed to arguments marked as requiring a non-null value by the
18414 @code{nonnull} function attribute.
18415
18416 @opindex fsanitize=returns-nonnull-attribute
18417 @item -fsanitize=returns-nonnull-attribute
18418
18419 This option enables instrumentation of return statements in functions
18420 marked with @code{returns_nonnull} function attribute, to detect returning
18421 of null values from such functions.
18422
18423 @opindex fsanitize=bool
18424 @item -fsanitize=bool
18425
18426 This option enables instrumentation of loads from bool. If a value other
18427 than 0/1 is loaded, a run-time error is issued.
18428
18429 @opindex fsanitize=enum
18430 @item -fsanitize=enum
18431
18432 This option enables instrumentation of loads from an enum type. If
18433 a value outside the range of values for the enum type is loaded,
18434 a run-time error is issued.
18435
18436 @opindex fsanitize=vptr
18437 @item -fsanitize=vptr
18438
18439 This option enables instrumentation of C++ member function calls, member
18440 accesses and some conversions between pointers to base and derived classes,
18441 to verify the referenced object has the correct dynamic type.
18442
18443 @opindex fsanitize=pointer-overflow
18444 @item -fsanitize=pointer-overflow
18445
18446 This option enables instrumentation of pointer arithmetics. If the pointer
18447 arithmetics overflows, a run-time error is issued.
18448
18449 @opindex fsanitize=builtin
18450 @item -fsanitize=builtin
18451
18452 This option enables instrumentation of arguments to selected builtin
18453 functions. If an invalid value is passed to such arguments, a run-time
18454 error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
18455 or @code{__builtin_clz} invokes undefined behavior and is diagnosed
18456 by this option.
18457
18458 @end table
18459
18460 Note that sanitizers tend to increase the rate of false positive
18461 warnings, most notably those around @option{-Wmaybe-uninitialized}.
18462 We recommend against combining @option{-Werror} and [the use of]
18463 sanitizers.
18464
18465 While @option{-ftrapv} causes traps for signed overflows to be emitted,
18466 @option{-fsanitize=undefined} gives a diagnostic message.
18467 This currently works only for the C family of languages.
18468
18469 @opindex fno-sanitize=all
18470 @item -fno-sanitize=all
18471
18472 This option disables all previously enabled sanitizers.
18473 @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
18474 together.
18475
18476 @opindex fasan-shadow-offset
18477 @item -fasan-shadow-offset=@var{number}
18478 This option forces GCC to use custom shadow offset in AddressSanitizer checks.
18479 It is useful for experimenting with different shadow memory layouts in
18480 Kernel AddressSanitizer.
18481
18482 @opindex fsanitize-sections
18483 @item -fsanitize-sections=@var{s1},@var{s2},...
18484 Sanitize global variables in selected user-defined sections. @var{si} may
18485 contain wildcards.
18486
18487 @opindex fsanitize-recover
18488 @opindex fno-sanitize-recover
18489 @item -fsanitize-recover@r{[}=@var{opts}@r{]}
18490 @option{-fsanitize-recover=} controls error recovery mode for sanitizers
18491 mentioned in comma-separated list of @var{opts}. Enabling this option
18492 for a sanitizer component causes it to attempt to continue
18493 running the program as if no error happened. This means multiple
18494 runtime errors can be reported in a single program run, and the exit
18495 code of the program may indicate success even when errors
18496 have been reported. The @option{-fno-sanitize-recover=} option
18497 can be used to alter
18498 this behavior: only the first detected error is reported
18499 and program then exits with a non-zero exit code.
18500
18501 Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
18502 except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
18503 @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
18504 @option{-fsanitize=bounds-strict},
18505 @option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
18506 For these sanitizers error recovery is turned on by default,
18507 except @option{-fsanitize=address}, for which this feature is experimental.
18508 @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
18509 accepted, the former enables recovery for all sanitizers that support it,
18510 the latter disables recovery for all sanitizers that support it.
18511
18512 Even if a recovery mode is turned on the compiler side, it needs to be also
18513 enabled on the runtime library side, otherwise the failures are still fatal.
18514 The runtime library defaults to @code{halt_on_error=0} for
18515 ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
18516 AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
18517 setting the @code{halt_on_error} flag in the corresponding environment variable.
18518
18519 Syntax without an explicit @var{opts} parameter is deprecated. It is
18520 equivalent to specifying an @var{opts} list of:
18521
18522 @smallexample
18523 undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
18524 @end smallexample
18525
18526 @opindex fsanitize-address-use-after-scope
18527 @item -fsanitize-address-use-after-scope
18528 Enable sanitization of local variables to detect use-after-scope bugs.
18529 The option sets @option{-fstack-reuse} to @samp{none}.
18530
18531 @opindex fsanitize-trap
18532 @opindex fno-sanitize-trap
18533 @item -fsanitize-trap@r{[}=@var{opts}@r{]}
18534 The @option{-fsanitize-trap=} option instructs the compiler to
18535 report for sanitizers mentioned in comma-separated list of @var{opts}
18536 undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
18537 library routine. If this option is enabled for certain sanitizer,
18538 it takes precedence over the @option{-fsanitizer-recover=} for that
18539 sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
18540 of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
18541
18542 The advantage of this is that the @code{libubsan} library is not needed
18543 and is not linked in, so this is usable even in freestanding environments.
18544
18545 Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
18546 except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
18547 @option{-fsanitize=float-divide-by-zero} and
18548 @option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
18549 specified, which enables it for @code{undefined} suboptions,
18550 @option{-fsanitize=float-cast-overflow},
18551 @option{-fsanitize=float-divide-by-zero} and
18552 @option{-fsanitize=bounds-strict}.
18553 If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
18554 and @code{-fsanitize=vptr} is enabled on the command line, the
18555 instrumentation is silently ignored as the instrumentation always needs
18556 @code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
18557
18558 @opindex fsanitize-undefined-trap-on-error
18559 @item -fsanitize-undefined-trap-on-error
18560 The @option{-fsanitize-undefined-trap-on-error} option is deprecated
18561 equivalent of @option{-fsanitize-trap=all}.
18562
18563 @opindex fsanitize-coverage=trace-pc
18564 @item -fsanitize-coverage=trace-pc
18565 Enable coverage-guided fuzzing code instrumentation.
18566 Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
18567
18568 @opindex fsanitize-coverage=trace-cmp
18569 @item -fsanitize-coverage=trace-cmp
18570 Enable dataflow guided fuzzing code instrumentation.
18571 Inserts a call to @code{__sanitizer_cov_trace_cmp1},
18572 @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
18573 @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
18574 variable or @code{__sanitizer_cov_trace_const_cmp1},
18575 @code{__sanitizer_cov_trace_const_cmp2},
18576 @code{__sanitizer_cov_trace_const_cmp4} or
18577 @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
18578 operand constant, @code{__sanitizer_cov_trace_cmpf} or
18579 @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
18580 @code{__sanitizer_cov_trace_switch} for switch statements.
18581
18582 @opindex fcf-protection
18583 @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
18584 @itemx -fcf-protection
18585 Enable code instrumentation to increase
18586 program security by checking that target addresses of control-flow
18587 transfer instructions (such as indirect function call, function return,
18588 indirect jump) are valid. This prevents diverting the flow of control
18589 to an unexpected target. This is intended to protect against such
18590 threats as Return-oriented Programming (ROP), and similarly
18591 call/jmp-oriented programming (COP/JOP).
18592
18593 The @option{-fcf-protection=} keywords are interpreted as follows.
18594
18595 The value @code{branch} tells the compiler to implement checking of
18596 validity of control-flow transfer at the point of indirect branch
18597 instructions, i.e.@: call/jmp instructions.
18598
18599 The value @code{return} implements checking of validity at the point of
18600 returning from a function.
18601
18602 The value @code{full} is an alias for specifying both
18603 @code{branch} and @code{return}.
18604
18605 The value @code{check} is used for the final link with link-time
18606 optimization (LTO). An error is issued if LTO object files are
18607 compiled with different @option{-fcf-protection} values. The
18608 value @code{check} is ignored at the compile time.
18609
18610 The value @code{none} turns off instrumentation.
18611
18612 @option{-fcf-protection} is an alias for @option{-fcf-protection=full}.
18613 To override a previous @option{-fcf-protection} option on the command
18614 line, add @option{-fcf-protection=none} and then
18615 @option{-fcf-protection=@var{kind}}.
18616
18617 The macro @code{__CET__} is defined when @option{-fcf-protection} is
18618 used. The first bit of @code{__CET__} is set to 1 for the value
18619 @code{branch} and the second bit of @code{__CET__} is set to 1 for
18620 the @code{return}.
18621
18622 You can also use the @code{nocf_check} attribute to identify
18623 which functions and calls should be skipped from instrumentation
18624 (@pxref{Function Attributes}).
18625
18626 Currently the x86 GNU/Linux target provides an implementation based
18627 on Intel Control-flow Enforcement Technology (CET) which works for
18628 i686 processor or newer.
18629
18630 @opindex fharden-compares
18631 @item -fharden-compares
18632 For every logical test that survives gimple optimizations and is
18633 @emph{not} the condition in a conditional branch (for example,
18634 conditions tested for conditional moves, or to store in boolean
18635 variables), emit extra code to compute and verify the reversed
18636 condition, and to call @code{__builtin_trap} if the results do not
18637 match. Use with @samp{-fharden-conditional-branches} to cover all
18638 conditionals.
18639
18640 @opindex fharden-conditional-branches
18641 @item -fharden-conditional-branches
18642 For every non-vectorized conditional branch that survives gimple
18643 optimizations, emit extra code to compute and verify the reversed
18644 condition, and to call @code{__builtin_trap} if the result is
18645 unexpected. Use with @samp{-fharden-compares} to cover all
18646 conditionals.
18647
18648 @opindex fharden-control-flow-redundancy
18649 @item -fharden-control-flow-redundancy
18650 Emit extra code to set booleans when entering basic blocks, and to
18651 verify and trap, at function exits, when the booleans do not form an
18652 execution path that is compatible with the control flow graph.
18653
18654 Verification takes place before returns, before mandatory tail calls
18655 (see below) and, optionally, before escaping exceptions with
18656 @option{-fhardcfr-check-exceptions}, before returning calls with
18657 @option{-fhardcfr-check-returning-calls}, and before noreturn calls with
18658 @option{-fhardcfr-check-noreturn-calls}). Tuning options
18659 @option{--param hardcfr-max-blocks} and @option{--param
18660 hardcfr-max-inline-blocks} are available.
18661
18662 Tail call optimization takes place too late to affect control flow
18663 redundancy, but calls annotated as mandatory tail calls by language
18664 front-ends, and any calls marked early enough as potential tail calls
18665 would also have verification issued before the call, but these
18666 possibilities are merely theoretical, as these conditions can only be
18667 met when using custom compiler plugins.
18668
18669 @opindex fhardcfr-skip-leaf
18670 @item -fhardcfr-skip-leaf
18671 Disable @option{-fharden-control-flow-redundancy} in leaf functions.
18672
18673 @opindex fhardcfr-check-exceptions
18674 @opindex fno-hardcfr-check-exceptions
18675 @item -fhardcfr-check-exceptions
18676 When @option{-fharden-control-flow-redundancy} is active, check the
18677 recorded execution path against the control flow graph at exception
18678 escape points, as if the function body was wrapped with a cleanup
18679 handler that performed the check and reraised. This option is enabled
18680 by default; use @option{-fno-hardcfr-check-exceptions} to disable it.
18681
18682 @opindex fhardcfr-check-returning-calls
18683 @opindex fno-hardcfr-check-returning-calls
18684 @item -fhardcfr-check-returning-calls
18685 When @option{-fharden-control-flow-redundancy} is active, check the
18686 recorded execution path against the control flow graph before any
18687 function call immediately followed by a return of its result, if any, so
18688 as to not prevent tail-call optimization, whether or not it is
18689 ultimately optimized to a tail call.
18690
18691 This option is enabled by default whenever sibling call optimizations
18692 are enabled (see @option{-foptimize-sibling-calls}), but it can be
18693 enabled (or disabled, using its negated form) explicitly, regardless of
18694 the optimizations.
18695
18696 @opindex fhardcfr-check-noreturn-calls
18697 @item -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
18698 When @option{-fharden-control-flow-redundancy} is active, check the
18699 recorded execution path against the control flow graph before
18700 @code{noreturn} calls, either all of them (@option{always}), those that
18701 aren't expected to return control to the caller through an exception
18702 (@option{no-xthrow}, the default), those that may not return control to
18703 the caller through an exception either (@option{nothrow}), or none of
18704 them (@option{never}).
18705
18706 Checking before a @code{noreturn} function that may return control to
18707 the caller through an exception may cause checking to be performed more
18708 than once, if the exception is caught in the caller, whether by a
18709 handler or a cleanup. When @option{-fhardcfr-check-exceptions} is also
18710 enabled, the compiler will avoid associating a @code{noreturn} call with
18711 the implicitly-added cleanup handler, since it would be redundant with
18712 the check performed before the call, but other handlers or cleanups in
18713 the function, if activated, will modify the recorded execution path and
18714 check it again when another checkpoint is hit. The checkpoint may even
18715 be another @code{noreturn} call, so checking may end up performed
18716 multiple times.
18717
18718 Various optimizers may cause calls to be marked as @code{noreturn}
18719 and/or @code{nothrow}, even in the absence of the corresponding
18720 attributes, which may affect the placement of checks before calls, as
18721 well as the addition of implicit cleanup handlers for them. This
18722 unpredictability, and the fact that raising and reraising exceptions
18723 frequently amounts to implicitly calling @code{noreturn} functions, have
18724 made @option{no-xthrow} the default setting for this option: it excludes
18725 from the @code{noreturn} treatment only internal functions used to
18726 (re)raise exceptions, that are not affected by these optimizations.
18727
18728 @opindex fhardened
18729 @item -fhardened
18730 Enable a set of flags for C and C++ that improve the security of the
18731 generated code without affecting its ABI. The precise flags enabled
18732 may change between major releases of GCC, but are currently:
18733
18734 @c Keep this in sync with print_help_hardened!
18735 @gccoptlist{
18736 -D_FORTIFY_SOURCE=3
18737 -D_GLIBCXX_ASSERTIONS
18738 -ftrivial-auto-var-init=zero
18739 -fPIE -pie -Wl,-z,relro,-z,now
18740 -fstack-protector-strong
18741 -fstack-clash-protection
18742 -fcf-protection=full @r{(x86 GNU/Linux only)}
18743 }
18744
18745 The list of options enabled by @option{-fhardened} can be generated using
18746 the @option{--help=hardened} option.
18747
18748 When the system glibc is older than 2.35, @option{-D_FORTIFY_SOURCE=2}
18749 is used instead.
18750
18751 This option is intended to be used in production builds, not merely
18752 in debug builds.
18753
18754 Currently, @option{-fhardened} is only supported on GNU/Linux targets.
18755
18756 @option{-fhardened} only enables a particular option if it wasn't
18757 already specified anywhere on the command line. For instance,
18758 @option{-fhardened} @option{-fstack-protector} will only enable
18759 @option{-fstack-protector}, but not @option{-fstack-protector-strong}.
18760
18761 @opindex fstack-protector
18762 @item -fstack-protector
18763 Emit extra code to check for buffer overflows, such as stack smashing
18764 attacks. This is done by adding a guard variable to functions with
18765 vulnerable objects. This includes functions that call @code{alloca}, and
18766 functions with buffers larger than or equal to 8 bytes. The guards are
18767 initialized when a function is entered and then checked when the function
18768 exits. If a guard check fails, an error message is printed and the program
18769 exits. Only variables that are actually allocated on the stack are
18770 considered, optimized away variables or variables allocated in registers
18771 don't count.
18772
18773 @opindex fstack-protector-all
18774 @item -fstack-protector-all
18775 Like @option{-fstack-protector} except that all functions are protected.
18776
18777 @opindex fstack-protector-strong
18778 @item -fstack-protector-strong
18779 Like @option{-fstack-protector} but includes additional functions to
18780 be protected --- those that have local array definitions, or have
18781 references to local frame addresses. Only variables that are actually
18782 allocated on the stack are considered, optimized away variables or variables
18783 allocated in registers don't count.
18784
18785 @opindex fstack-protector-explicit
18786 @item -fstack-protector-explicit
18787 Like @option{-fstack-protector} but only protects those functions which
18788 have the @code{stack_protect} attribute.
18789
18790 @opindex fstack-check
18791 @item -fstack-check
18792 Generate code to verify that you do not go beyond the boundary of the
18793 stack. You should specify this flag if you are running in an
18794 environment with multiple threads, but you only rarely need to specify it in
18795 a single-threaded environment since stack overflow is automatically
18796 detected on nearly all systems if there is only one stack.
18797
18798 Note that this switch does not actually cause checking to be done; the
18799 operating system or the language runtime must do that. The switch causes
18800 generation of code to ensure that they see the stack being extended.
18801
18802 You can additionally specify a string parameter: @samp{no} means no
18803 checking, @samp{generic} means force the use of old-style checking,
18804 @samp{specific} means use the best checking method and is equivalent
18805 to bare @option{-fstack-check}.
18806
18807 Old-style checking is a generic mechanism that requires no specific
18808 target support in the compiler but comes with the following drawbacks:
18809
18810 @enumerate
18811 @item
18812 Modified allocation strategy for large objects: they are always
18813 allocated dynamically if their size exceeds a fixed threshold. Note this
18814 may change the semantics of some code.
18815
18816 @item
18817 Fixed limit on the size of the static frame of functions: when it is
18818 topped by a particular function, stack checking is not reliable and
18819 a warning is issued by the compiler.
18820
18821 @item
18822 Inefficiency: because of both the modified allocation strategy and the
18823 generic implementation, code performance is hampered.
18824 @end enumerate
18825
18826 Note that old-style stack checking is also the fallback method for
18827 @samp{specific} if no target support has been added in the compiler.
18828
18829 @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
18830 and stack overflows. @samp{specific} is an excellent choice when compiling
18831 Ada code. It is not generally sufficient to protect against stack-clash
18832 attacks. To protect against those you want @samp{-fstack-clash-protection}.
18833
18834 @opindex fstack-clash-protection
18835 @item -fstack-clash-protection
18836 Generate code to prevent stack clash style attacks. When this option is
18837 enabled, the compiler will only allocate one page of stack space at a time
18838 and each page is accessed immediately after allocation. Thus, it prevents
18839 allocations from jumping over any stack guard page provided by the
18840 operating system.
18841
18842 Most targets do not fully support stack clash protection. However, on
18843 those targets @option{-fstack-clash-protection} will protect dynamic stack
18844 allocations. @option{-fstack-clash-protection} may also provide limited
18845 protection for static stack allocations if the target supports
18846 @option{-fstack-check=specific}.
18847
18848 @opindex fstack-limit-register
18849 @opindex fstack-limit-symbol
18850 @opindex fno-stack-limit
18851 @item -fstack-limit-register=@var{reg}
18852 @itemx -fstack-limit-symbol=@var{sym}
18853 @itemx -fno-stack-limit
18854 Generate code to ensure that the stack does not grow beyond a certain value,
18855 either the value of a register or the address of a symbol. If a larger
18856 stack is required, a signal is raised at run time. For most targets,
18857 the signal is raised before the stack overruns the boundary, so
18858 it is possible to catch the signal without taking special precautions.
18859
18860 For instance, if the stack starts at absolute address @samp{0x80000000}
18861 and grows downwards, you can use the flags
18862 @option{-fstack-limit-symbol=__stack_limit} and
18863 @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
18864 of 128KB@. Note that this may only work with the GNU linker.
18865
18866 You can locally override stack limit checking by using the
18867 @code{no_stack_limit} function attribute (@pxref{Function Attributes}).
18868
18869 @opindex fsplit-stack
18870 @item -fsplit-stack
18871 Generate code to automatically split the stack before it overflows.
18872 The resulting program has a discontiguous stack which can only
18873 overflow if the program is unable to allocate any more memory. This
18874 is most useful when running threaded programs, as it is no longer
18875 necessary to calculate a good stack size to use for each thread. This
18876 is currently only implemented for the x86 targets running
18877 GNU/Linux.
18878
18879 When code compiled with @option{-fsplit-stack} calls code compiled
18880 without @option{-fsplit-stack}, there may not be much stack space
18881 available for the latter code to run. If compiling all code,
18882 including library code, with @option{-fsplit-stack} is not an option,
18883 then the linker can fix up these calls so that the code compiled
18884 without @option{-fsplit-stack} always has a large stack. Support for
18885 this is implemented in the gold linker in GNU binutils release 2.21
18886 and later.
18887
18888 @opindex fstrub=disable
18889 @item -fstrub=disable
18890 Disable stack scrubbing entirely, ignoring any @code{strub} attributes.
18891 See @xref{Common Type Attributes}.
18892
18893 @opindex fstrub=strict
18894 @item -fstrub=strict
18895 Functions default to @code{strub} mode @code{disabled}, and apply
18896 @option{strict}ly the restriction that only functions associated with
18897 @code{strub}-@code{callable} modes (@code{at-calls}, @code{callable} and
18898 @code{always_inline} @code{internal}) are @code{callable} by functions
18899 with @code{strub}-enabled modes (@code{at-calls} and @code{internal}).
18900
18901 @opindex fstrub=relaxed
18902 @item -fstrub=relaxed
18903 Restore the default stack scrub (@code{strub}) setting, namely,
18904 @code{strub} is only enabled as required by @code{strub} attributes
18905 associated with function and data types. @code{Relaxed} means that
18906 strub contexts are only prevented from calling functions explicitly
18907 associated with @code{strub} mode @code{disabled}. This option is only
18908 useful to override other @option{-fstrub=*} options that precede it in
18909 the command line.
18910
18911 @opindex fstrub=at-calls
18912 @item -fstrub=at-calls
18913 Enable @code{at-calls} @code{strub} mode where viable. The primary use
18914 of this option is for testing. It exercises the @code{strub} machinery
18915 in scenarios strictly local to a translation unit. This @code{strub}
18916 mode modifies function interfaces, so any function that is visible to
18917 other translation units, or that has its address taken, will @emph{not}
18918 be affected by this option. Optimization options may also affect
18919 viability. See the @code{strub} attribute documentation for details on
18920 viability and eligibility requirements.
18921
18922 @opindex fstrub=internal
18923 @item -fstrub=internal
18924 Enable @code{internal} @code{strub} mode where viable. The primary use
18925 of this option is for testing. This option is intended to exercise
18926 thoroughly parts of the @code{strub} machinery that implement the less
18927 efficient, but interface-preserving @code{strub} mode. Functions that
18928 would not be affected by this option are quite uncommon.
18929
18930 @opindex fstrub=all
18931 @item -fstrub=all
18932 Enable some @code{strub} mode where viable. When both strub modes are
18933 viable, @code{at-calls} is preferred. @option{-fdump-ipa-strubm} adds
18934 function attributes that tell which mode was selected for each function.
18935 The primary use of this option is for testing, to exercise thoroughly
18936 the @code{strub} machinery.
18937
18938 @opindex fvtable-verify
18939 @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
18940 This option is only available when compiling C++ code.
18941 It turns on (or off, if using @option{-fvtable-verify=none}) the security
18942 feature that verifies at run time, for every virtual call, that
18943 the vtable pointer through which the call is made is valid for the type of
18944 the object, and has not been corrupted or overwritten. If an invalid vtable
18945 pointer is detected at run time, an error is reported and execution of the
18946 program is immediately halted.
18947
18948 This option causes run-time data structures to be built at program startup,
18949 which are used for verifying the vtable pointers.
18950 The options @samp{std} and @samp{preinit}
18951 control the timing of when these data structures are built. In both cases the
18952 data structures are built before execution reaches @code{main}. Using
18953 @option{-fvtable-verify=std} causes the data structures to be built after
18954 shared libraries have been loaded and initialized.
18955 @option{-fvtable-verify=preinit} causes them to be built before shared
18956 libraries have been loaded and initialized.
18957
18958 If this option appears multiple times in the command line with different
18959 values specified, @samp{none} takes highest priority over both @samp{std} and
18960 @samp{preinit}; @samp{preinit} takes priority over @samp{std}.
18961
18962 @opindex fvtv-debug
18963 @item -fvtv-debug
18964 When used in conjunction with @option{-fvtable-verify=std} or
18965 @option{-fvtable-verify=preinit}, causes debug versions of the
18966 runtime functions for the vtable verification feature to be called.
18967 This flag also causes the compiler to log information about which
18968 vtable pointers it finds for each class.
18969 This information is written to a file named @file{vtv_set_ptr_data.log}
18970 in the directory named by the environment variable @env{VTV_LOGS_DIR}
18971 if that is defined or the current working directory otherwise.
18972
18973 Note: This feature @emph{appends} data to the log file. If you want a fresh log
18974 file, be sure to delete any existing one.
18975
18976 @opindex fvtv-counts
18977 @item -fvtv-counts
18978 This is a debugging flag. When used in conjunction with
18979 @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
18980 causes the compiler to keep track of the total number of virtual calls
18981 it encounters and the number of verifications it inserts. It also
18982 counts the number of calls to certain run-time library functions
18983 that it inserts and logs this information for each compilation unit.
18984 The compiler writes this information to a file named
18985 @file{vtv_count_data.log} in the directory named by the environment
18986 variable @env{VTV_LOGS_DIR} if that is defined or the current working
18987 directory otherwise. It also counts the size of the vtable pointer sets
18988 for each class, and writes this information to @file{vtv_class_set_sizes.log}
18989 in the same directory.
18990
18991 Note: This feature @emph{appends} data to the log files. To get fresh log
18992 files, be sure to delete any existing ones.
18993
18994 @opindex finstrument-functions
18995 @item -finstrument-functions
18996 Generate instrumentation calls for entry and exit to functions. Just
18997 after function entry and just before function exit, the following
18998 profiling functions are called with the address of the current
18999 function and its call site. (On some platforms,
19000 @code{__builtin_return_address} does not work beyond the current
19001 function, so the call site information may not be available to the
19002 profiling functions otherwise.)
19003
19004 @smallexample
19005 void __cyg_profile_func_enter (void *this_fn,
19006 void *call_site);
19007 void __cyg_profile_func_exit (void *this_fn,
19008 void *call_site);
19009 @end smallexample
19010
19011 The first argument is the address of the start of the current function,
19012 which may be looked up exactly in the symbol table.
19013
19014 This instrumentation is also done for functions expanded inline in other
19015 functions. The profiling calls indicate where, conceptually, the
19016 inline function is entered and exited. This means that addressable
19017 versions of such functions must be available. If all your uses of a
19018 function are expanded inline, this may mean an additional expansion of
19019 code size. If you use @code{extern inline} in your C code, an
19020 addressable version of such functions must be provided. (This is
19021 normally the case anyway, but if you get lucky and the optimizer always
19022 expands the functions inline, you might have gotten away without
19023 providing static copies.)
19024
19025 A function may be given the attribute @code{no_instrument_function}, in
19026 which case this instrumentation is not done. This can be used, for
19027 example, for the profiling functions listed above, high-priority
19028 interrupt routines, and any functions from which the profiling functions
19029 cannot safely be called (perhaps signal handlers, if the profiling
19030 routines generate output or allocate memory).
19031 @xref{Common Function Attributes}.
19032
19033 @opindex finstrument-functions-once
19034 @item -finstrument-functions-once
19035 This is similar to @option{-finstrument-functions}, but the profiling
19036 functions are called only once per instrumented function, i.e. the first
19037 profiling function is called after the first entry into the instrumented
19038 function and the second profiling function is called before the exit
19039 corresponding to this first entry.
19040
19041 The definition of @code{once} for the purpose of this option is a little
19042 vague because the implementation is not protected against data races.
19043 As a result, the implementation only guarantees that the profiling
19044 functions are called at @emph{least} once per process and at @emph{most}
19045 once per thread, but the calls are always paired, that is to say, if a
19046 thread calls the first function, then it will call the second function,
19047 unless it never reaches the exit of the instrumented function.
19048
19049 @opindex finstrument-functions-exclude-file-list
19050 @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
19051
19052 Set the list of functions that are excluded from instrumentation (see
19053 the description of @option{-finstrument-functions}). If the file that
19054 contains a function definition matches with one of @var{file}, then
19055 that function is not instrumented. The match is done on substrings:
19056 if the @var{file} parameter is a substring of the file name, it is
19057 considered to be a match.
19058
19059 For example:
19060
19061 @smallexample
19062 -finstrument-functions-exclude-file-list=/bits/stl,include/sys
19063 @end smallexample
19064
19065 @noindent
19066 excludes any inline function defined in files whose pathnames
19067 contain @file{/bits/stl} or @file{include/sys}.
19068
19069 If, for some reason, you want to include letter @samp{,} in one of
19070 @var{sym}, write @samp{\,}. For example,
19071 @option{-finstrument-functions-exclude-file-list='\,\,tmp'}
19072 (note the single quote surrounding the option).
19073
19074 @opindex finstrument-functions-exclude-function-list
19075 @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
19076
19077 This is similar to @option{-finstrument-functions-exclude-file-list},
19078 but this option sets the list of function names to be excluded from
19079 instrumentation. The function name to be matched is its user-visible
19080 name, such as @code{vector<int> blah(const vector<int> &)}, not the
19081 internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
19082 match is done on substrings: if the @var{sym} parameter is a substring
19083 of the function name, it is considered to be a match. For C99 and C++
19084 extended identifiers, the function name must be given in UTF-8, not
19085 using universal character names.
19086
19087 @opindex fpatchable-function-entry
19088 @item -fpatchable-function-entry=@var{N}[,@var{M}]
19089 Generate @var{N} NOPs right at the beginning
19090 of each function, with the function entry point before the @var{M}th NOP.
19091 If @var{M} is omitted, it defaults to @code{0} so the
19092 function entry points to the address just at the first NOP.
19093 The NOP instructions reserve extra space which can be used to patch in
19094 any desired instrumentation at run time, provided that the code segment
19095 is writable. The amount of space is controllable indirectly via
19096 the number of NOPs; the NOP instruction used corresponds to the instruction
19097 emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
19098 is target-specific and may also depend on the architecture variant and/or
19099 other compilation options.
19100
19101 For run-time identification, the starting addresses of these areas,
19102 which correspond to their respective function entries minus @var{M},
19103 are additionally collected in the @code{__patchable_function_entries}
19104 section of the resulting binary.
19105
19106 Note that the value of @code{__attribute__ ((patchable_function_entry
19107 (N,M)))} takes precedence over command-line option
19108 @option{-fpatchable-function-entry=N,M}. This can be used to increase
19109 the area size or to remove it completely on a single function.
19110 If @code{N=0}, no pad location is recorded.
19111
19112 The NOP instructions are inserted at---and maybe before, depending on
19113 @var{M}---the function entry address, even before the prologue. On
19114 PowerPC with the ELFv2 ABI, for a function with dual entry points,
19115 the local entry point is this function entry address by default. See
19116 the @option{-msplit-patch-nops} option to change this.
19117
19118 The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
19119 ELFv2 ABI, for a function with dual entry points, the supported values
19120 for @var{M} are 0, 2, 6 and 14 when not using @option{-msplit-patch-nops}.
19121 @end table
19122
19123
19124 @node Preprocessor Options
19125 @section Options Controlling the Preprocessor
19126 @cindex preprocessor options
19127 @cindex options, preprocessor
19128
19129 These options control the C preprocessor, which is run on each C source
19130 file before actual compilation.
19131
19132 If you use the @option{-E} option, nothing is done except preprocessing.
19133 Some of these options make sense only together with @option{-E} because
19134 they cause the preprocessor output to be unsuitable for actual
19135 compilation.
19136
19137 In addition to the options listed here, there are a number of options
19138 to control search paths for include files documented in
19139 @ref{Directory Options}.
19140 Options to control preprocessor diagnostics are listed in
19141 @ref{Warning Options}.
19142
19143 @table @gcctabopt
19144 @include cppopts.texi
19145
19146 @opindex Wp
19147 @item -Wp,@var{option}
19148 You can use @option{-Wp,@var{option}} to bypass the compiler driver
19149 and pass @var{option} directly through to the preprocessor. If
19150 @var{option} contains commas, it is split into multiple options at the
19151 commas. However, many options are modified, translated or interpreted
19152 by the compiler driver before being passed to the preprocessor, and
19153 @option{-Wp} forcibly bypasses this phase. The preprocessor's direct
19154 interface is undocumented and subject to change, so whenever possible
19155 you should avoid using @option{-Wp} and let the driver handle the
19156 options instead.
19157
19158 @opindex Xpreprocessor
19159 @item -Xpreprocessor @var{option}
19160 Pass @var{option} as an option to the preprocessor. You can use this to
19161 supply system-specific preprocessor options that GCC does not
19162 recognize.
19163
19164 If you want to pass an option that takes an argument, you must use
19165 @option{-Xpreprocessor} twice, once for the option and once for the argument.
19166
19167 @opindex no-integrated-cpp
19168 @item -no-integrated-cpp
19169 Perform preprocessing as a separate pass before compilation.
19170 By default, GCC performs preprocessing as an integrated part of
19171 input tokenization and parsing.
19172 If this option is provided, the appropriate language front end
19173 (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
19174 and Objective-C, respectively) is instead invoked twice,
19175 once for preprocessing only and once for actual compilation
19176 of the preprocessed input.
19177 This option may be useful in conjunction with the @option{-B} or
19178 @option{-wrapper} options to specify an alternate preprocessor or
19179 perform additional processing of the program source between
19180 normal preprocessing and compilation.
19181
19182 @end table
19183
19184 @node Assembler Options
19185 @section Passing Options to the Assembler
19186
19187 @c prevent bad page break with this line
19188 You can pass options to the assembler.
19189
19190 @table @gcctabopt
19191 @opindex Wa
19192 @item -Wa,@var{option}
19193 Pass @var{option} as an option to the assembler. If @var{option}
19194 contains commas, it is split into multiple options at the commas.
19195
19196 @opindex Xassembler
19197 @item -Xassembler @var{option}
19198 Pass @var{option} as an option to the assembler. You can use this to
19199 supply system-specific assembler options that GCC does not
19200 recognize.
19201
19202 If you want to pass an option that takes an argument, you must use
19203 @option{-Xassembler} twice, once for the option and once for the argument.
19204
19205 @end table
19206
19207 @node Link Options
19208 @section Options for Linking
19209 @cindex link options
19210 @cindex options, linking
19211
19212 These options come into play when the compiler links object files into
19213 an executable output file. They are meaningless if the compiler is
19214 not doing a link step.
19215
19216 @table @gcctabopt
19217 @cindex file names
19218 @item @var{object-file-name}
19219 A file name that does not end in a special recognized suffix is
19220 considered to name an object file or library. (Object files are
19221 distinguished from libraries by the linker according to the file
19222 contents.) If linking is done, these object files are used as input
19223 to the linker.
19224
19225 @opindex c
19226 @opindex S
19227 @opindex E
19228 @item -c
19229 @itemx -S
19230 @itemx -E
19231 If any of these options is used, then the linker is not run, and
19232 object file names should not be used as arguments. @xref{Overall
19233 Options}.
19234
19235 @opindex flinker-output
19236 @item -flinker-output=@var{type}
19237 This option controls code generation of the link-time optimizer. By
19238 default the linker output is automatically determined by the linker
19239 plugin. For debugging the compiler and if incremental linking with a
19240 non-LTO object file is desired, it may be useful to control the type
19241 manually.
19242
19243 If @var{type} is @samp{exec}, code generation produces a static
19244 binary. In this case @option{-fpic} and @option{-fpie} are both
19245 disabled.
19246
19247 If @var{type} is @samp{dyn}, code generation produces a shared
19248 library. In this case @option{-fpic} or @option{-fPIC} is preserved,
19249 but not enabled automatically. This allows to build shared libraries
19250 without position-independent code on architectures where this is
19251 possible, i.e.@: on x86.
19252
19253 If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
19254 executable. This results in similar optimizations as @samp{exec}
19255 except that @option{-fpie} is not disabled if specified at compilation
19256 time.
19257
19258 If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
19259 done. The sections containing intermediate code for link-time optimization are
19260 merged, pre-optimized, and output to the resulting object file. In addition, if
19261 @option{-ffat-lto-objects} is specified, binary code is produced for future
19262 non-LTO linking. The object file produced by incremental linking is smaller
19263 than a static library produced from the same object files. At link time the
19264 result of incremental linking also loads faster than a static
19265 library assuming that the majority of objects in the library are used.
19266
19267 Finally @samp{nolto-rel} configures the compiler for incremental linking where
19268 code generation is forced, a final binary is produced, and the intermediate
19269 code for later link-time optimization is stripped. When multiple object files
19270 are linked together the resulting code is better optimized than with
19271 link-time optimizations disabled (for example, cross-module inlining
19272 happens), but most of benefits of whole program optimizations are lost.
19273
19274 During the incremental link (by @option{-r}) the linker plugin defaults to
19275 @option{rel}. With current interfaces to GNU Binutils it is however not
19276 possible to incrementally link LTO objects and non-LTO objects into a single
19277 mixed object file. If any of object files in incremental link cannot
19278 be used for link-time optimization, the linker plugin issues a warning and
19279 uses @samp{nolto-rel}. To maintain whole program optimization, it is
19280 recommended to link such objects into static library instead. Alternatively it
19281 is possible to use H.J. Lu's binutils with support for mixed objects.
19282
19283 @opindex fuse-ld=bfd
19284 @item -fuse-ld=bfd
19285 Use the @command{bfd} linker instead of the default linker.
19286
19287 @opindex fuse-ld=gold
19288 @item -fuse-ld=gold
19289 Use the @command{gold} linker instead of the default linker.
19290
19291 @opindex fuse-ld=lld
19292 @item -fuse-ld=lld
19293 Use the LLVM @command{lld} linker instead of the default linker.
19294
19295 @opindex fuse-ld=mold
19296 @item -fuse-ld=mold
19297 Use the Modern Linker (@command{mold}) instead of the default linker.
19298
19299 @cindex Libraries
19300 @opindex l
19301 @item -l@var{library}
19302 @itemx -l @var{library}
19303 Search the library named @var{library} when linking. (The second
19304 alternative with the library as a separate argument is only for
19305 POSIX compliance and is not recommended.)
19306
19307 The @option{-l} option is passed directly to the linker by GCC. Refer
19308 to your linker documentation for exact details. The general
19309 description below applies to the GNU linker.
19310
19311 The linker searches a standard list of directories for the library.
19312 The directories searched include several standard system directories
19313 plus any that you specify with @option{-L}.
19314
19315 Static libraries are archives of object files, and have file names
19316 like @file{lib@var{library}.a}. Some targets also support shared
19317 libraries, which typically have names like @file{lib@var{library}.so}.
19318 If both static and shared libraries are found, the linker gives
19319 preference to linking with the shared library unless the
19320 @option{-static} option is used.
19321
19322 It makes a difference where in the command you write this option; the
19323 linker searches and processes libraries and object files in the order they
19324 are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
19325 after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
19326 to functions in @samp{z}, those functions may not be loaded.
19327
19328 @opindex lobjc
19329 @item -lobjc
19330 You need this special case of the @option{-l} option in order to
19331 link an Objective-C or Objective-C++ program.
19332
19333 @opindex nostartfiles
19334 @item -nostartfiles
19335 Do not use the standard system startup files when linking.
19336 The standard system libraries are used normally, unless @option{-nostdlib},
19337 @option{-nolibc}, or @option{-nodefaultlibs} is used.
19338
19339 @opindex nodefaultlibs
19340 @item -nodefaultlibs
19341 Do not use the standard system libraries when linking.
19342 Only the libraries you specify are passed to the linker, and options
19343 specifying linkage of the system libraries, such as @option{-static-libgcc}
19344 or @option{-shared-libgcc}, are ignored.
19345 The standard startup files are used normally, unless @option{-nostartfiles}
19346 is used.
19347
19348 The compiler may generate calls to @code{memcmp},
19349 @code{memset}, @code{memcpy} and @code{memmove}.
19350 These entries are usually resolved by entries in
19351 libc. These entry points should be supplied through some other
19352 mechanism when this option is specified.
19353
19354 @opindex nolibc
19355 @item -nolibc
19356 Do not use the C library or system libraries tightly coupled with it when
19357 linking. Still link with the startup files, @file{libgcc} or toolchain
19358 provided language support libraries such as @file{libgnat}, @file{libgfortran}
19359 or @file{libstdc++} unless options preventing their inclusion are used as
19360 well. This typically removes @option{-lc} from the link command line, as well
19361 as system libraries that normally go with it and become meaningless when
19362 absence of a C library is assumed, for example @option{-lpthread} or
19363 @option{-lm} in some configurations. This is intended for bare-board
19364 targets when there is indeed no C library available.
19365
19366 @opindex nostdlib
19367 @item -nostdlib
19368 Do not use the standard system startup files or libraries when linking.
19369 No startup files and only the libraries you specify are passed to
19370 the linker, and options specifying linkage of the system libraries, such as
19371 @option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
19372
19373 The compiler may generate calls to @code{memcmp}, @code{memset},
19374 @code{memcpy} and @code{memmove}.
19375 These entries are usually resolved by entries in
19376 libc. These entry points should be supplied through some other
19377 mechanism when this option is specified.
19378
19379 @cindex @option{-lgcc}, use with @option{-nostdlib}
19380 @cindex @option{-nostdlib} and unresolved references
19381 @cindex unresolved references and @option{-nostdlib}
19382 @cindex @option{-lgcc}, use with @option{-nodefaultlibs}
19383 @cindex @option{-nodefaultlibs} and unresolved references
19384 @cindex unresolved references and @option{-nodefaultlibs}
19385 One of the standard libraries bypassed by @option{-nostdlib} and
19386 @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
19387 which GCC uses to overcome shortcomings of particular machines, or special
19388 needs for some languages.
19389 (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
19390 Collection (GCC) Internals},
19391 for more discussion of @file{libgcc.a}.)
19392 In most cases, you need @file{libgcc.a} even when you want to avoid
19393 other standard libraries. In other words, when you specify @option{-nostdlib}
19394 or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
19395 This ensures that you have no unresolved references to internal GCC
19396 library subroutines.
19397 (An example of such an internal subroutine is @code{__main}, used to ensure C++
19398 constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
19399 GNU Compiler Collection (GCC) Internals}.)
19400
19401 @opindex nostdlib++
19402 @item -nostdlib++
19403 Do not implicitly link with standard C++ libraries.
19404
19405 @opindex e
19406 @opindex entry
19407 @item -e @var{entry}
19408 @itemx --entry=@var{entry}
19409
19410 Specify that the program entry point is @var{entry}. The argument is
19411 interpreted by the linker; the GNU linker accepts either a symbol name
19412 or an address.
19413
19414 @opindex pie
19415 @item -pie
19416 Produce a dynamically linked position independent executable on targets
19417 that support it. For predictable results, you must also specify the same
19418 set of options used for compilation (@option{-fpie}, @option{-fPIE},
19419 or model suboptions) when you specify this linker option.
19420
19421 @opindex no-pie
19422 @item -no-pie
19423 Don't produce a dynamically linked position independent executable.
19424
19425 @opindex static-pie
19426 @item -static-pie
19427 Produce a static position independent executable on targets that support
19428 it. A static position independent executable is similar to a static
19429 executable, but can be loaded at any address without a dynamic linker.
19430 For predictable results, you must also specify the same set of options
19431 used for compilation (@option{-fpie}, @option{-fPIE}, or model
19432 suboptions) when you specify this linker option.
19433
19434 @opindex pthread
19435 @item -pthread
19436 Link with the POSIX threads library. This option is supported on
19437 GNU/Linux targets, most other Unix derivatives, and also on
19438 x86 Cygwin and MinGW targets. On some targets this option also sets
19439 flags for the preprocessor, so it should be used consistently for both
19440 compilation and linking.
19441
19442 @opindex r
19443 @item -r
19444 Produce a relocatable object as output. This is also known as partial
19445 linking.
19446
19447 @opindex rdynamic
19448 @item -rdynamic
19449 Pass the flag @option{-export-dynamic} to the ELF linker, on targets
19450 that support it. This instructs the linker to add all symbols, not
19451 only used ones, to the dynamic symbol table. This option is needed
19452 for some uses of @code{dlopen} or to allow obtaining backtraces
19453 from within a program.
19454
19455 @opindex s
19456 @item -s
19457 Remove all symbol table and relocation information from the executable.
19458
19459 @opindex static
19460 @item -static
19461 On systems that support dynamic linking, this overrides @option{-pie}
19462 and prevents linking with the shared libraries. On other systems, this
19463 option has no effect.
19464
19465 @opindex shared
19466 @item -shared
19467 Produce a shared object which can then be linked with other objects to
19468 form an executable. Not all systems support this option. For predictable
19469 results, you must also specify the same set of options used for compilation
19470 (@option{-fpic}, @option{-fPIC}, or model suboptions) when
19471 you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
19472 needs to build supplementary stub code for constructors to work. On
19473 multi-libbed systems, @samp{gcc -shared} must select the correct support
19474 libraries to link against. Failing to supply the correct flags may lead
19475 to subtle defects. Supplying them in cases where they are not necessary
19476 is innocuous. @option{-shared} suppresses the addition of startup code
19477 to alter the floating-point environment as done with @option{-ffast-math},
19478 @option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
19479
19480 @opindex shared-libgcc
19481 @opindex static-libgcc
19482 @item -shared-libgcc
19483 @itemx -static-libgcc
19484 On systems that provide @file{libgcc} as a shared library, these options
19485 force the use of either the shared or static version, respectively.
19486 If no shared version of @file{libgcc} was built when the compiler was
19487 configured, these options have no effect.
19488
19489 There are several situations in which an application should use the
19490 shared @file{libgcc} instead of the static version. The most common
19491 of these is when the application wishes to throw and catch exceptions
19492 across different shared libraries. In that case, each of the libraries
19493 as well as the application itself should use the shared @file{libgcc}.
19494
19495 Therefore, the G++ driver automatically adds @option{-shared-libgcc}
19496 whenever you build a shared library or a main executable, because C++
19497 programs typically use exceptions, so this is the right thing to do.
19498
19499 If, instead, you use the GCC driver to create shared libraries, you may
19500 find that they are not always linked with the shared @file{libgcc}.
19501 If GCC finds, at its configuration time, that you have a non-GNU linker
19502 or a GNU linker that does not support option @option{--eh-frame-hdr},
19503 it links the shared version of @file{libgcc} into shared libraries
19504 by default. Otherwise, it takes advantage of the linker and optimizes
19505 away the linking with the shared version of @file{libgcc}, linking with
19506 the static version of libgcc by default. This allows exceptions to
19507 propagate through such shared libraries, without incurring relocation
19508 costs at library load time.
19509
19510 However, if a library or main executable is supposed to throw or catch
19511 exceptions, you must link it using the G++ driver, or using the option
19512 @option{-shared-libgcc}, such that it is linked with the shared
19513 @file{libgcc}.
19514
19515 @opindex static-libasan
19516 @item -static-libasan
19517 When the @option{-fsanitize=address} option is used to link a program,
19518 the GCC driver automatically links against @option{libasan}. If
19519 @file{libasan} is available as a shared library, and the @option{-static}
19520 option is not used, then this links against the shared version of
19521 @file{libasan}. The @option{-static-libasan} option directs the GCC
19522 driver to link @file{libasan} statically, without necessarily linking
19523 other libraries statically.
19524
19525 @opindex static-libtsan
19526 @item -static-libtsan
19527 When the @option{-fsanitize=thread} option is used to link a program,
19528 the GCC driver automatically links against @option{libtsan}. If
19529 @file{libtsan} is available as a shared library, and the @option{-static}
19530 option is not used, then this links against the shared version of
19531 @file{libtsan}. The @option{-static-libtsan} option directs the GCC
19532 driver to link @file{libtsan} statically, without necessarily linking
19533 other libraries statically.
19534
19535 @opindex static-liblsan
19536 @item -static-liblsan
19537 When the @option{-fsanitize=leak} option is used to link a program,
19538 the GCC driver automatically links against @option{liblsan}. If
19539 @file{liblsan} is available as a shared library, and the @option{-static}
19540 option is not used, then this links against the shared version of
19541 @file{liblsan}. The @option{-static-liblsan} option directs the GCC
19542 driver to link @file{liblsan} statically, without necessarily linking
19543 other libraries statically.
19544
19545 @opindex static-libubsan
19546 @item -static-libubsan
19547 When the @option{-fsanitize=undefined} option is used to link a program,
19548 the GCC driver automatically links against @option{libubsan}. If
19549 @file{libubsan} is available as a shared library, and the @option{-static}
19550 option is not used, then this links against the shared version of
19551 @file{libubsan}. The @option{-static-libubsan} option directs the GCC
19552 driver to link @file{libubsan} statically, without necessarily linking
19553 other libraries statically.
19554
19555 @opindex static-libstdc++
19556 @item -static-libstdc++
19557 When the @command{g++} program is used to link a C++ program, it
19558 normally automatically links against @option{libstdc++}. If
19559 @file{libstdc++} is available as a shared library, and the
19560 @option{-static} option is not used, then this links against the
19561 shared version of @file{libstdc++}. That is normally fine. However, it
19562 is sometimes useful to freeze the version of @file{libstdc++} used by
19563 the program without going all the way to a fully static link. The
19564 @option{-static-libstdc++} option directs the @command{g++} driver to
19565 link @file{libstdc++} statically, without necessarily linking other
19566 libraries statically.
19567
19568 @opindex symbolic
19569 @item -symbolic
19570 Bind references to global symbols when building a shared object. Warn
19571 about any unresolved references (unless overridden by the link editor
19572 option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
19573 this option.
19574
19575 @opindex T
19576 @cindex linker script
19577 @item -T @var{script}
19578 Use @var{script} as the linker script. This option is supported by most
19579 systems using the GNU linker. On some targets, such as bare-board
19580 targets without an operating system, the @option{-T} option may be required
19581 when linking to avoid references to undefined symbols.
19582
19583 @opindex Xlinker
19584 @item -Xlinker @var{option}
19585 Pass @var{option} as an option to the linker. You can use this to
19586 supply system-specific linker options that GCC does not recognize.
19587
19588 If you want to pass an option that takes a separate argument, you must use
19589 @option{-Xlinker} twice, once for the option and once for the argument.
19590 For example, to pass @option{-assert definitions}, you must write
19591 @option{-Xlinker -assert -Xlinker definitions}. It does not work to write
19592 @option{-Xlinker "-assert definitions"}, because this passes the entire
19593 string as a single argument, which is not what the linker expects.
19594
19595 When using the GNU linker, it is usually more convenient to pass
19596 arguments to linker options using the @option{@var{option}=@var{value}}
19597 syntax than as separate arguments. For example, you can specify
19598 @option{-Xlinker -Map=output.map} rather than
19599 @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
19600 this syntax for command-line options.
19601
19602 @opindex Wl
19603 @item -Wl,@var{option}
19604 Pass @var{option} as an option to the linker. If @var{option} contains
19605 commas, it is split into multiple options at the commas. You can use this
19606 syntax to pass an argument to the option.
19607 For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
19608 linker. When using the GNU linker, you can also get the same effect with
19609 @option{-Wl,-Map=output.map}.
19610
19611 @opindex u
19612 @item -u @var{symbol}
19613 Pretend the symbol @var{symbol} is undefined, to force linking of
19614 library modules to define it. You can use @option{-u} multiple times with
19615 different symbols to force loading of additional library modules.
19616
19617 @opindex z
19618 @item -z @var{keyword}
19619 @option{-z} is passed directly on to the linker along with the keyword
19620 @var{keyword}. See the section in the documentation of your linker for
19621 permitted values and their meanings.
19622 @end table
19623
19624 @node Directory Options
19625 @section Options for Directory Search
19626 @cindex directory options
19627 @cindex options, directory search
19628 @cindex search path
19629
19630 These options specify directories to search for header files, for
19631 libraries and for parts of the compiler:
19632
19633 @table @gcctabopt
19634 @include cppdiropts.texi
19635
19636 @opindex iplugindir=
19637 @item -iplugindir=@var{dir}
19638 Set the directory to search for plugins that are passed
19639 by @option{-fplugin=@var{name}} instead of
19640 @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
19641 to be used by the user, but only passed by the driver.
19642
19643 @opindex L
19644 @item -L@var{dir}
19645 Add directory @var{dir} to the list of directories to be searched
19646 for @option{-l}.
19647
19648 @opindex B
19649 @item -B@var{prefix}
19650 This option specifies where to find the executables, libraries,
19651 include files, and data files of the compiler itself.
19652
19653 The compiler driver program runs one or more of the subprograms
19654 @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
19655 @var{prefix} as a prefix for each program it tries to run, both with and
19656 without @samp{@var{machine}/@var{version}/} for the corresponding target
19657 machine and compiler version.
19658
19659 For each subprogram to be run, the compiler driver first tries the
19660 @option{-B} prefix, if any. If that name is not found, or if @option{-B}
19661 is not specified, the driver tries two standard prefixes,
19662 @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
19663 those results in a file name that is found, the unmodified program
19664 name is searched for using the directories specified in your
19665 @env{PATH} environment variable.
19666
19667 The compiler checks to see if the path provided by @option{-B}
19668 refers to a directory, and if necessary it adds a directory
19669 separator character at the end of the path.
19670
19671 @option{-B} prefixes that effectively specify directory names also apply
19672 to libraries in the linker, because the compiler translates these
19673 options into @option{-L} options for the linker. They also apply to
19674 include files in the preprocessor, because the compiler translates these
19675 options into @option{-isystem} options for the preprocessor. In this case,
19676 the compiler appends @samp{include} to the prefix.
19677
19678 The runtime support file @file{libgcc.a} can also be searched for using
19679 the @option{-B} prefix, if needed. If it is not found there, the two
19680 standard prefixes above are tried, and that is all. The file is left
19681 out of the link if it is not found by those means.
19682
19683 Another way to specify a prefix much like the @option{-B} prefix is to use
19684 the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
19685 Variables}.
19686
19687 As a special kludge, if the path provided by @option{-B} is
19688 @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
19689 9, then it is replaced by @file{[dir/]include}. This is to help
19690 with boot-strapping the compiler.
19691
19692 @opindex no-canonical-prefixes
19693 @item -no-canonical-prefixes
19694 Do not expand any symbolic links, resolve references to @samp{/../}
19695 or @samp{/./}, or make the path absolute when generating a relative
19696 prefix.
19697
19698 @opindex sysroot
19699 @item --sysroot=@var{dir}
19700 Use @var{dir} as the logical root directory for headers and libraries.
19701 For example, if the compiler normally searches for headers in
19702 @file{/usr/include} and libraries in @file{/usr/lib}, it instead
19703 searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
19704
19705 If you use both this option and the @option{-isysroot} option, then
19706 the @option{--sysroot} option applies to libraries, but the
19707 @option{-isysroot} option applies to header files.
19708
19709 The GNU linker (beginning with version 2.16) has the necessary support
19710 for this option. If your linker does not support this option, the
19711 header file aspect of @option{--sysroot} still works, but the
19712 library aspect does not.
19713
19714 @opindex no-sysroot-suffix
19715 @item --no-sysroot-suffix
19716 For some targets, a suffix is added to the root directory specified
19717 with @option{--sysroot}, depending on the other options used, so that
19718 headers may for example be found in
19719 @file{@var{dir}/@var{suffix}/usr/include} instead of
19720 @file{@var{dir}/usr/include}. This option disables the addition of
19721 such a suffix.
19722
19723 @end table
19724
19725 @node Code Gen Options
19726 @section Options for Code Generation Conventions
19727 @cindex code generation conventions
19728 @cindex options, code generation
19729 @cindex run-time options
19730
19731 These machine-independent options control the interface conventions
19732 used in code generation.
19733
19734 Most of them have both positive and negative forms; the negative form
19735 of @option{-ffoo} is @option{-fno-foo}. In the table below, only
19736 one of the forms is listed---the one that is not the default. You
19737 can figure out the other form by either removing @samp{no-} or adding
19738 it.
19739
19740 @table @gcctabopt
19741 @opindex fstack_reuse
19742 @item -fstack-reuse=@var{reuse-level}
19743 This option controls stack space reuse for user declared local/auto variables
19744 and compiler generated temporaries. @var{reuse_level} can be @samp{all},
19745 @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
19746 local variables and temporaries, @samp{named_vars} enables the reuse only for
19747 user defined local variables with names, and @samp{none} disables stack reuse
19748 completely. The default value is @samp{all}. The option is needed when the
19749 program extends the lifetime of a scoped local variable or a compiler generated
19750 temporary beyond the end point defined by the language. When a lifetime of
19751 a variable ends, and if the variable lives in memory, the optimizing compiler
19752 has the freedom to reuse its stack space with other temporaries or scoped
19753 local variables whose live range does not overlap with it. Legacy code extending
19754 local lifetime is likely to break with the stack reuse optimization.
19755
19756 For example,
19757
19758 @smallexample
19759 int *p;
19760 @{
19761 int local1;
19762
19763 p = &local1;
19764 local1 = 10;
19765 ....
19766 @}
19767 @{
19768 int local2;
19769 local2 = 20;
19770 ...
19771 @}
19772
19773 if (*p == 10) // out of scope use of local1
19774 @{
19775
19776 @}
19777 @end smallexample
19778
19779 Another example:
19780 @smallexample
19781
19782 struct A
19783 @{
19784 A(int k) : i(k), j(k) @{ @}
19785 int i;
19786 int j;
19787 @};
19788
19789 A *ap;
19790
19791 void foo(const A& ar)
19792 @{
19793 ap = &ar;
19794 @}
19795
19796 void bar()
19797 @{
19798 foo(A(10)); // temp object's lifetime ends when foo returns
19799
19800 @{
19801 A a(20);
19802 ....
19803 @}
19804 ap->i+= 10; // ap references out of scope temp whose space
19805 // is reused with a. What is the value of ap->i?
19806 @}
19807
19808 @end smallexample
19809
19810 The lifetime of a compiler generated temporary is well defined by the C++
19811 standard. When a lifetime of a temporary ends, and if the temporary lives
19812 in memory, the optimizing compiler has the freedom to reuse its stack
19813 space with other temporaries or scoped local variables whose live range
19814 does not overlap with it. However some of the legacy code relies on
19815 the behavior of older compilers in which temporaries' stack space is
19816 not reused, the aggressive stack reuse can lead to runtime errors. This
19817 option is used to control the temporary stack reuse optimization.
19818
19819 @opindex ftrapv
19820 @item -ftrapv
19821 This option generates traps for signed overflow on addition, subtraction,
19822 multiplication operations.
19823 The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
19824 @option{-ftrapv} @option{-fwrapv} on the command-line results in
19825 @option{-fwrapv} being effective. Note that only active options override, so
19826 using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
19827 results in @option{-ftrapv} being effective.
19828
19829 @opindex fwrapv
19830 @item -fwrapv
19831 This option instructs the compiler to assume that signed arithmetic
19832 overflow of addition, subtraction and multiplication wraps around
19833 using twos-complement representation. This flag enables some optimizations
19834 and disables others.
19835 The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
19836 @option{-ftrapv} @option{-fwrapv} on the command-line results in
19837 @option{-fwrapv} being effective. Note that only active options override, so
19838 using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
19839 results in @option{-ftrapv} being effective.
19840
19841 @opindex fwrapv-pointer
19842 @item -fwrapv-pointer
19843 This option instructs the compiler to assume that pointer arithmetic
19844 overflow on addition and subtraction wraps around using twos-complement
19845 representation. This flag disables some optimizations which assume
19846 pointer overflow is invalid.
19847
19848 @opindex fstrict-overflow
19849 @item -fstrict-overflow
19850 This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
19851 negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
19852
19853 @opindex fexceptions
19854 @item -fexceptions
19855 Enable exception handling. Generates extra code needed to propagate
19856 exceptions. For some targets, this implies GCC generates frame
19857 unwind information for all functions, which can produce significant data
19858 size overhead, although it does not affect execution. If you do not
19859 specify this option, GCC enables it by default for languages like
19860 C++ that normally require exception handling, and disables it for
19861 languages like C that do not normally require it. However, you may need
19862 to enable this option when compiling C code that needs to interoperate
19863 properly with exception handlers written in C++. You may also wish to
19864 disable this option if you are compiling older C++ programs that don't
19865 use exception handling.
19866
19867 @opindex fnon-call-exceptions
19868 @item -fnon-call-exceptions
19869 Generate code that allows trapping instructions to throw exceptions.
19870 Note that this requires platform-specific runtime support that does
19871 not exist everywhere. Moreover, it only allows @emph{trapping}
19872 instructions to throw exceptions, i.e.@: memory references or floating-point
19873 instructions. It does not allow exceptions to be thrown from
19874 arbitrary signal handlers such as @code{SIGALRM}. This enables
19875 @option{-fexceptions}.
19876
19877 @opindex fdelete-dead-exceptions
19878 @item -fdelete-dead-exceptions
19879 Consider that instructions that may throw exceptions but don't otherwise
19880 contribute to the execution of the program can be optimized away.
19881 This does not affect calls to functions except those with the
19882 @code{pure} or @code{const} attributes.
19883 This option is enabled by default for the Ada and C++ compilers, as permitted by
19884 the language specifications.
19885 Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
19886
19887 @opindex funwind-tables
19888 @item -funwind-tables
19889 Similar to @option{-fexceptions}, except that it just generates any needed
19890 static data, but does not affect the generated code in any other way.
19891 You normally do not need to enable this option; instead, a language processor
19892 that needs this handling enables it on your behalf.
19893
19894 @opindex fasynchronous-unwind-tables
19895 @item -fasynchronous-unwind-tables
19896 Generate unwind table in DWARF format, if supported by target machine. The
19897 table is exact at each instruction boundary, so it can be used for stack
19898 unwinding from asynchronous events (such as debugger or garbage collector).
19899
19900 @opindex fno-gnu-unique
19901 @opindex fgnu-unique
19902 @item -fno-gnu-unique
19903 On systems with recent GNU assembler and C library, the C++ compiler
19904 uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
19905 of template static data members and static local variables in inline
19906 functions are unique even in the presence of @code{RTLD_LOCAL}; this
19907 is necessary to avoid problems with a library used by two different
19908 @code{RTLD_LOCAL} plugins depending on a definition in one of them and
19909 therefore disagreeing with the other one about the binding of the
19910 symbol. But this causes @code{dlclose} to be ignored for affected
19911 DSOs; if your program relies on reinitialization of a DSO via
19912 @code{dlclose} and @code{dlopen}, you can use
19913 @option{-fno-gnu-unique}.
19914
19915 @opindex fpcc-struct-return
19916 @item -fpcc-struct-return
19917 Return ``short'' @code{struct} and @code{union} values in memory like
19918 longer ones, rather than in registers. This convention is less
19919 efficient, but it has the advantage of allowing intercallability between
19920 GCC-compiled files and files compiled with other compilers, particularly
19921 the Portable C Compiler (pcc).
19922
19923 The precise convention for returning structures in memory depends
19924 on the target configuration macros.
19925
19926 Short structures and unions are those whose size and alignment match
19927 that of some integer type.
19928
19929 @strong{Warning:} code compiled with the @option{-fpcc-struct-return}
19930 switch is not binary compatible with code compiled with the
19931 @option{-freg-struct-return} switch.
19932 Use it to conform to a non-default application binary interface.
19933
19934 @opindex freg-struct-return
19935 @item -freg-struct-return
19936 Return @code{struct} and @code{union} values in registers when possible.
19937 This is more efficient for small structures than
19938 @option{-fpcc-struct-return}.
19939
19940 If you specify neither @option{-fpcc-struct-return} nor
19941 @option{-freg-struct-return}, GCC defaults to whichever convention is
19942 standard for the target. If there is no standard convention, GCC
19943 defaults to @option{-fpcc-struct-return}, except on targets where GCC is
19944 the principal compiler. In those cases, we can choose the standard, and
19945 we chose the more efficient register return alternative.
19946
19947 @strong{Warning:} code compiled with the @option{-freg-struct-return}
19948 switch is not binary compatible with code compiled with the
19949 @option{-fpcc-struct-return} switch.
19950 Use it to conform to a non-default application binary interface.
19951
19952 @opindex fshort-enums
19953 @item -fshort-enums
19954 Allocate to an @code{enum} type only as many bytes as it needs for the
19955 declared range of possible values. Specifically, the @code{enum} type
19956 is equivalent to the smallest integer type that has enough room.
19957 This option has no effect for an enumeration type with a fixed underlying
19958 type.
19959
19960 @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
19961 code that is not binary compatible with code generated without that switch.
19962 Use it to conform to a non-default application binary interface.
19963
19964 @opindex fshort-wchar
19965 @item -fshort-wchar
19966 Override the underlying type for @code{wchar_t} to be @code{short
19967 unsigned int} instead of the default for the target. This option is
19968 useful for building programs to run under WINE@.
19969
19970 @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
19971 code that is not binary compatible with code generated without that switch.
19972 Use it to conform to a non-default application binary interface.
19973
19974 @opindex fcommon
19975 @opindex fno-common
19976 @cindex tentative definitions
19977 @item -fcommon
19978 In C code, this option controls the placement of global variables
19979 defined without an initializer, known as @dfn{tentative definitions}
19980 in the C standard. Tentative definitions are distinct from declarations
19981 of a variable with the @code{extern} keyword, which do not allocate storage.
19982
19983 The default is @option{-fno-common}, which specifies that the compiler places
19984 uninitialized global variables in the BSS section of the object file.
19985 This inhibits the merging of tentative definitions by the linker so you get a
19986 multiple-definition error if the same variable is accidentally defined in more
19987 than one compilation unit.
19988
19989 The @option{-fcommon} places uninitialized global variables in a common block.
19990 This allows the linker to resolve all tentative definitions of the same variable
19991 in different compilation units to the same object, or to a non-tentative
19992 definition. This behavior is inconsistent with C++, and on many targets implies
19993 a speed and code size penalty on global variable references. It is mainly
19994 useful to enable legacy code to link without errors.
19995
19996 @opindex fno-ident
19997 @opindex fident
19998 @item -fno-ident
19999 Ignore the @code{#ident} directive.
20000
20001 @opindex finhibit-size-directive
20002 @item -finhibit-size-directive
20003 Don't output a @code{.size} assembler directive, or anything else that
20004 would cause trouble if the function is split in the middle, and the
20005 two halves are placed at locations far apart in memory. This option is
20006 used when compiling @file{crtstuff.c}; you should not need to use it
20007 for anything else.
20008
20009 @opindex fverbose-asm
20010 @item -fverbose-asm
20011 Put extra commentary information in the generated assembly code to
20012 make it more readable. This option is generally only of use to those
20013 who actually need to read the generated assembly code (perhaps while
20014 debugging the compiler itself).
20015
20016 @option{-fno-verbose-asm}, the default, causes the
20017 extra information to be omitted and is useful when comparing two assembler
20018 files.
20019
20020 The added comments include:
20021
20022 @itemize @bullet
20023
20024 @item
20025 information on the compiler version and command-line options,
20026
20027 @item
20028 the source code lines associated with the assembly instructions,
20029 in the form FILENAME:LINENUMBER:CONTENT OF LINE,
20030
20031 @item
20032 hints on which high-level expressions correspond to
20033 the various assembly instruction operands.
20034
20035 @end itemize
20036
20037 For example, given this C source file:
20038
20039 @smallexample
20040 int test (int n)
20041 @{
20042 int i;
20043 int total = 0;
20044
20045 for (i = 0; i < n; i++)
20046 total += i * i;
20047
20048 return total;
20049 @}
20050 @end smallexample
20051
20052 compiling to (x86_64) assembly via @option{-S} and emitting the result
20053 direct to stdout via @option{-o} @option{-}
20054
20055 @smallexample
20056 gcc -S test.c -fverbose-asm -Os -o -
20057 @end smallexample
20058
20059 gives output similar to this:
20060
20061 @smallexample
20062 .file "test.c"
20063 # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
20064 [...snip...]
20065 # options passed:
20066 [...snip...]
20067
20068 .text
20069 .globl test
20070 .type test, @@function
20071 test:
20072 .LFB0:
20073 .cfi_startproc
20074 # test.c:4: int total = 0;
20075 xorl %eax, %eax # <retval>
20076 # test.c:6: for (i = 0; i < n; i++)
20077 xorl %edx, %edx # i
20078 .L2:
20079 # test.c:6: for (i = 0; i < n; i++)
20080 cmpl %edi, %edx # n, i
20081 jge .L5 #,
20082 # test.c:7: total += i * i;
20083 movl %edx, %ecx # i, tmp92
20084 imull %edx, %ecx # i, tmp92
20085 # test.c:6: for (i = 0; i < n; i++)
20086 incl %edx # i
20087 # test.c:7: total += i * i;
20088 addl %ecx, %eax # tmp92, <retval>
20089 jmp .L2 #
20090 .L5:
20091 # test.c:10: @}
20092 ret
20093 .cfi_endproc
20094 .LFE0:
20095 .size test, .-test
20096 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
20097 .section .note.GNU-stack,"",@@progbits
20098 @end smallexample
20099
20100 The comments are intended for humans rather than machines and hence the
20101 precise format of the comments is subject to change.
20102
20103 @opindex frecord-gcc-switches
20104 @item -frecord-gcc-switches
20105 This switch causes the command line used to invoke the
20106 compiler to be recorded into the object file that is being created.
20107 This switch is only implemented on some targets and the exact format
20108 of the recording is target and binary file format dependent, but it
20109 usually takes the form of a section containing ASCII text. This
20110 switch is related to the @option{-fverbose-asm} switch, but that
20111 switch only records information in the assembler output file as
20112 comments, so it never reaches the object file.
20113 See also @option{-grecord-gcc-switches} for another
20114 way of storing compiler options into the object file.
20115
20116 @opindex fpic
20117 @cindex global offset table
20118 @cindex PIC
20119 @item -fpic
20120 Generate position-independent code (PIC) suitable for use in a shared
20121 library, if supported for the target machine. Such code accesses all
20122 constant addresses through a global offset table (GOT)@. The dynamic
20123 loader resolves the GOT entries when the program starts (the dynamic
20124 loader is not part of GCC; it is part of the operating system). If
20125 the GOT size for the linked executable exceeds a machine-specific
20126 maximum size, you get an error message from the linker indicating that
20127 @option{-fpic} does not work; in that case, recompile with @option{-fPIC}
20128 instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
20129 on the m68k and RS/6000. The x86 has no such limit.)
20130
20131 Position-independent code requires special support, and therefore works
20132 only on certain machines. For the x86, GCC supports PIC for System V
20133 but not for the Sun 386i. Code generated for the IBM RS/6000 is always
20134 position-independent.
20135
20136 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
20137 are defined to 1.
20138
20139 @opindex fPIC
20140 @item -fPIC
20141 If supported for the target machine, emit position-independent code,
20142 suitable for dynamic linking and avoiding any limit on the size of the
20143 global offset table. This option makes a difference on AArch64, m68k,
20144 PowerPC and SPARC@.
20145
20146 Position-independent code requires special support, and therefore works
20147 only on certain machines.
20148
20149 When this flag is set, the macros @code{__pic__} and @code{__PIC__}
20150 are defined to 2.
20151
20152 @opindex fpie
20153 @opindex fPIE
20154 @item -fpie
20155 @itemx -fPIE
20156 These options are similar to @option{-fpic} and @option{-fPIC}, but the
20157 generated position-independent code can be only linked into executables.
20158 Usually these options are used to compile code that will be linked using
20159 the @option{-pie} GCC option.
20160
20161 @option{-fpie} and @option{-fPIE} both define the macros
20162 @code{__pie__} and @code{__PIE__}. The macros have the value 1
20163 for @option{-fpie} and 2 for @option{-fPIE}.
20164
20165 @opindex fno-plt
20166 @opindex fplt
20167 @item -fno-plt
20168 Do not use the PLT for external function calls in position-independent code.
20169 Instead, load the callee address at call sites from the GOT and branch to it.
20170 This leads to more efficient code by eliminating PLT stubs and exposing
20171 GOT loads to optimizations. On architectures such as 32-bit x86 where
20172 PLT stubs expect the GOT pointer in a specific register, this gives more
20173 register allocation freedom to the compiler.
20174 Lazy binding requires use of the PLT;
20175 with @option{-fno-plt} all external symbols are resolved at load time.
20176
20177 Alternatively, the function attribute @code{noplt} can be used to avoid calls
20178 through the PLT for specific external functions.
20179
20180 In position-dependent code, a few targets also convert calls to
20181 functions that are marked to not use the PLT to use the GOT instead.
20182
20183 @opindex fno-jump-tables
20184 @opindex fjump-tables
20185 @item -fno-jump-tables
20186 Do not use jump tables for switch statements even where it would be
20187 more efficient than other code generation strategies. This option is
20188 of use in conjunction with @option{-fpic} or @option{-fPIC} for
20189 building code that forms part of a dynamic linker and cannot
20190 reference the address of a jump table. On some targets, jump tables
20191 do not require a GOT and this option is not needed.
20192
20193 @opindex fno-bit-tests
20194 @opindex fbit-tests
20195 @item -fno-bit-tests
20196 Do not use bit tests for switch statements even where it would be
20197 more efficient than other code generation strategies.
20198
20199 @opindex ffixed
20200 @item -ffixed-@var{reg}
20201 Treat the register named @var{reg} as a fixed register; generated code
20202 should never refer to it (except perhaps as a stack pointer, frame
20203 pointer or in some other fixed role).
20204
20205 @var{reg} must be the name of a register. The register names accepted
20206 are machine-specific and are defined in the @code{REGISTER_NAMES}
20207 macro in the machine description macro file.
20208
20209 This flag does not have a negative form, because it specifies a
20210 three-way choice.
20211
20212 @opindex fcall-used
20213 @item -fcall-used-@var{reg}
20214 Treat the register named @var{reg} as an allocable register that is
20215 clobbered by function calls. It may be allocated for temporaries or
20216 variables that do not live across a call. Functions compiled this way
20217 do not save and restore the register @var{reg}.
20218
20219 It is an error to use this flag with the frame pointer or stack pointer.
20220 Use of this flag for other registers that have fixed pervasive roles in
20221 the machine's execution model produces disastrous results.
20222
20223 This flag does not have a negative form, because it specifies a
20224 three-way choice.
20225
20226 @opindex fcall-saved
20227 @item -fcall-saved-@var{reg}
20228 Treat the register named @var{reg} as an allocable register saved by
20229 functions. It may be allocated even for temporaries or variables that
20230 live across a call. Functions compiled this way save and restore
20231 the register @var{reg} if they use it.
20232
20233 It is an error to use this flag with the frame pointer or stack pointer.
20234 Use of this flag for other registers that have fixed pervasive roles in
20235 the machine's execution model produces disastrous results.
20236
20237 A different sort of disaster results from the use of this flag for
20238 a register in which function values may be returned.
20239
20240 This flag does not have a negative form, because it specifies a
20241 three-way choice.
20242
20243 @opindex fpack-struct
20244 @item -fpack-struct[=@var{n}]
20245 Without a value specified, pack all structure members together without
20246 holes. When a value is specified (which must be a small power of two), pack
20247 structure members according to this value, representing the maximum
20248 alignment (that is, objects with default alignment requirements larger than
20249 this are output potentially unaligned at the next fitting location.
20250
20251 @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
20252 code that is not binary compatible with code generated without that switch.
20253 Additionally, it makes the code suboptimal.
20254 Use it to conform to a non-default application binary interface.
20255
20256 @opindex fleading-underscore
20257 @item -fleading-underscore
20258 This option and its counterpart, @option{-fno-leading-underscore}, forcibly
20259 change the way C symbols are represented in the object file. One use
20260 is to help link with legacy assembly code.
20261
20262 @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
20263 generate code that is not binary compatible with code generated without that
20264 switch. Use it to conform to a non-default application binary interface.
20265 Not all targets provide complete support for this switch.
20266
20267 @opindex ftls-model
20268 @item -ftls-model=@var{model}
20269 Alter the thread-local storage model to be used (@pxref{Thread-Local}).
20270 The @var{model} argument should be one of @samp{global-dynamic},
20271 @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
20272 Note that the choice is subject to optimization: the compiler may use
20273 a more efficient model for symbols not visible outside of the translation
20274 unit, or if @option{-fpic} is not given on the command line.
20275
20276 The default without @option{-fpic} is @samp{initial-exec}; with
20277 @option{-fpic} the default is @samp{global-dynamic}.
20278
20279 @opindex ftrampolines
20280 @item -ftrampolines
20281 For targets that normally need trampolines for nested functions, always
20282 generate them instead of using descriptors. Otherwise, for targets that
20283 do not need them, like for example HP-PA or IA-64, do nothing.
20284
20285 A trampoline is a small piece of code that is created at run time on the
20286 stack when the address of a nested function is taken, and is used to call
20287 the nested function indirectly. Therefore, it requires the stack to be
20288 made executable in order for the program to work properly.
20289
20290 @option{-fno-trampolines} is enabled by default on a language by language
20291 basis to let the compiler avoid generating them, if it computes that this
20292 is safe, and replace them with descriptors. Descriptors are made up of data
20293 only, but the generated code must be prepared to deal with them. As of this
20294 writing, @option{-fno-trampolines} is enabled by default only for Ada.
20295
20296 Moreover, code compiled with @option{-ftrampolines} and code compiled with
20297 @option{-fno-trampolines} are not binary compatible if nested functions are
20298 present. This option must therefore be used on a program-wide basis and be
20299 manipulated with extreme care.
20300
20301 For languages other than Ada, the @code{-ftrampolines} and
20302 @code{-fno-trampolines} options currently have no effect, and
20303 trampolines are always generated on platforms that need them
20304 for nested functions.
20305
20306 @opindex ftrampoline-impl
20307 @item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
20308 By default, trampolines are generated on stack. However, certain platforms
20309 (such as the Apple M1) do not permit an executable stack. Compiling with
20310 @option{-ftrampoline-impl=heap} generate calls to
20311 @code{__gcc_nested_func_ptr_created} and
20312 @code{__gcc_nested_func_ptr_deleted} in order to allocate and
20313 deallocate trampoline space on the executable heap. These functions are
20314 implemented in libgcc, and will only be provided on specific targets:
20315 x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap
20316 trampolines are @emph{not} guaranteed to be correctly deallocated if you
20317 @code{setjmp}, instantiate nested functions, and then @code{longjmp} back
20318 to a state prior to having allocated those nested functions.
20319
20320 @opindex fvisibility
20321 @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
20322 Set the default ELF image symbol visibility to the specified option---all
20323 symbols are marked with this unless overridden within the code.
20324 Using this feature can very substantially improve linking and
20325 load times of shared object libraries, produce more optimized
20326 code, provide near-perfect API export and prevent symbol clashes.
20327 It is @strong{strongly} recommended that you use this in any shared objects
20328 you distribute.
20329
20330 Despite the nomenclature, @samp{default} always means public; i.e.,
20331 available to be linked against from outside the shared object.
20332 @samp{protected} and @samp{internal} are pretty useless in real-world
20333 usage so the only other commonly used option is @samp{hidden}.
20334 The default if @option{-fvisibility} isn't specified is
20335 @samp{default}, i.e., make every symbol public.
20336
20337 A good explanation of the benefits offered by ensuring ELF
20338 symbols have the correct visibility is given by ``How To Write
20339 Shared Libraries'' by Ulrich Drepper (which can be found at
20340 @w{@uref{https://www.akkadia.org/drepper/}})---however a superior
20341 solution made possible by this option to marking things hidden when
20342 the default is public is to make the default hidden and mark things
20343 public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
20344 and @code{__attribute__ ((visibility("default")))} instead of
20345 @code{__declspec(dllexport)} you get almost identical semantics with
20346 identical syntax. This is a great boon to those working with
20347 cross-platform projects.
20348
20349 For those adding visibility support to existing code, you may find
20350 @code{#pragma GCC visibility} of use. This works by you enclosing
20351 the declarations you wish to set visibility for with (for example)
20352 @code{#pragma GCC visibility push(hidden)} and
20353 @code{#pragma GCC visibility pop}.
20354 Bear in mind that symbol visibility should be viewed @strong{as
20355 part of the API interface contract} and thus all new code should
20356 always specify visibility when it is not the default; i.e., declarations
20357 only for use within the local DSO should @strong{always} be marked explicitly
20358 as hidden as so to avoid PLT indirection overheads---making this
20359 abundantly clear also aids readability and self-documentation of the code.
20360 Note that due to ISO C++ specification requirements, @code{operator new} and
20361 @code{operator delete} must always be of default visibility.
20362
20363 Be aware that headers from outside your project, in particular system
20364 headers and headers from any other library you use, may not be
20365 expecting to be compiled with visibility other than the default. You
20366 may need to explicitly say @code{#pragma GCC visibility push(default)}
20367 before including any such headers.
20368
20369 @code{extern} declarations are not affected by @option{-fvisibility}, so
20370 a lot of code can be recompiled with @option{-fvisibility=hidden} with
20371 no modifications. However, this means that calls to @code{extern}
20372 functions with no explicit visibility use the PLT, so it is more
20373 effective to use @code{__attribute ((visibility))} and/or
20374 @code{#pragma GCC visibility} to tell the compiler which @code{extern}
20375 declarations should be treated as hidden.
20376
20377 Note that @option{-fvisibility} does affect C++ vague linkage
20378 entities. This means that, for instance, an exception class that is
20379 be thrown between DSOs must be explicitly marked with default
20380 visibility so that the @samp{type_info} nodes are unified between
20381 the DSOs.
20382
20383 An overview of these techniques, their benefits and how to use them
20384 is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
20385
20386 @opindex fstrict-volatile-bitfields
20387 @item -fstrict-volatile-bitfields
20388 This option should be used if accesses to volatile bit-fields (or other
20389 structure fields, although the compiler usually honors those types
20390 anyway) should use a single access of the width of the
20391 field's type, aligned to a natural alignment if possible. For
20392 example, targets with memory-mapped peripheral registers might require
20393 all such accesses to be 16 bits wide; with this flag you can
20394 declare all peripheral bit-fields as @code{unsigned short} (assuming short
20395 is 16 bits on these targets) to force GCC to use 16-bit accesses
20396 instead of, perhaps, a more efficient 32-bit access.
20397
20398 If this option is disabled, the compiler uses the most efficient
20399 instruction. In the previous example, that might be a 32-bit load
20400 instruction, even though that accesses bytes that do not contain
20401 any portion of the bit-field, or memory-mapped registers unrelated to
20402 the one being updated.
20403
20404 In some cases, such as when the @code{packed} attribute is applied to a
20405 structure field, it may not be possible to access the field with a single
20406 read or write that is correctly aligned for the target machine. In this
20407 case GCC falls back to generating multiple accesses rather than code that
20408 will fault or truncate the result at run time.
20409
20410 Note: Due to restrictions of the C/C++11 memory model, write accesses are
20411 not allowed to touch non bit-field members. It is therefore recommended
20412 to define all bits of the field's type as bit-field members.
20413
20414 The default value of this option is determined by the application binary
20415 interface for the target processor.
20416
20417 @opindex fsync-libcalls
20418 @item -fsync-libcalls
20419 This option controls whether any out-of-line instance of the @code{__sync}
20420 family of functions may be used to implement the C++11 @code{__atomic}
20421 family of functions.
20422
20423 The default value of this option is enabled, thus the only useful form
20424 of the option is @option{-fno-sync-libcalls}. This option is used in
20425 the implementation of the @file{libatomic} runtime library.
20426
20427 @opindex fzero-init-padding-bits=@var{value}
20428 @item -fzero-init-padding-bits=@var{value}
20429 Guarantee zero initialization of padding bits in automatic variable
20430 initializers.
20431 Certain languages guarantee zero initialization of padding bits in
20432 certain cases, e.g. C23 when using empty initializers (@code{@{@}}),
20433 or C++ when using zero-initialization or C guarantees that fields
20434 not specified in an initializer have their padding bits zero initialized.
20435 This option allows to change when padding bits in initializers are
20436 guaranteed to be zero initialized.
20437 The default is @code{-fzero-init-padding-bits=standard}, which makes
20438 no further guarantees than the corresponding standard. E.g.@:
20439
20440 @smallexample
20441 struct A @{ char a; unsigned long long b; char c; @};
20442 union B @{ char a; unsigned long long b; @};
20443 struct A a = @{@}; // C23 guarantees padding bits are zero.
20444 struct A b = @{ 1, 2, 3 @}; // No guarantees.
20445 union B c = @{@}; // C23 guarantees padding bits are zero.
20446 union B d = @{ 1 @}; // No guarantees.
20447 @end smallexample
20448
20449 @code{-fzero-init-padding-bits=unions} guarantees zero initialization
20450 of padding bits in unions on top of what the standards guarantee,
20451 if the initializer of an union is empty (then all bits of the union
20452 are zero initialized) or if the initialized member of the union is
20453 smaller than the size of the union (in that case guarantees padding
20454 bits outside of the initialized member to be zero initialized).
20455 This was the GCC behavior before GCC 15 and in the above example guarantees
20456 zero initialization of last @code{sizeof (unsigned long long) - 1}
20457 bytes in the union.
20458
20459 @code{-fzero-init-padding-bits=all} guarantees additionally
20460 zero initialization of padding bits of other aggregates, so
20461 the padding in between @code{b.a} and @code{b.b} (if any) and
20462 tail padding in the structure (if any).
20463
20464 @end table
20465
20466 @node Developer Options
20467 @section GCC Developer Options
20468 @cindex developer options
20469 @cindex debugging GCC
20470 @cindex debug dump options
20471 @cindex dump options
20472 @cindex compilation statistics
20473
20474 This section describes command-line options that are primarily of
20475 interest to GCC developers, including options to support compiler
20476 testing and investigation of compiler bugs and compile-time
20477 performance problems. This includes options that produce debug dumps
20478 at various points in the compilation; that print statistics such as
20479 memory use and execution time; and that print information about GCC's
20480 configuration, such as where it searches for libraries. You should
20481 rarely need to use any of these options for ordinary compilation and
20482 linking tasks.
20483
20484 Many developer options that cause GCC to dump output to a file take an
20485 optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
20486 or @samp{-} to dump to standard output, and @samp{stderr} for standard
20487 error.
20488
20489 If @samp{=@var{filename}} is omitted, a default dump file name is
20490 constructed by concatenating the base dump file name, a pass number,
20491 phase letter, and pass name. The base dump file name is the name of
20492 output file produced by the compiler if explicitly specified and not
20493 an executable; otherwise it is the source file name.
20494 The pass number is determined by the order passes are registered with
20495 the compiler's pass manager.
20496 This is generally the same as the order of execution, but passes
20497 registered by plugins, target-specific passes, or passes that are
20498 otherwise registered late are numbered higher than the pass named
20499 @samp{final}, even if they are executed earlier. The phase letter is
20500 one of @samp{i} (inter-procedural analysis), @samp{l}
20501 (language-specific), @samp{r} (RTL), or @samp{t} (tree).
20502 The files are created in the directory of the output file.
20503
20504 @table @gcctabopt
20505
20506 @opindex fcallgraph-info
20507 @item -fcallgraph-info
20508 @itemx -fcallgraph-info=@var{MARKERS}
20509 Makes the compiler output callgraph information for the program, on a
20510 per-object-file basis. The information is generated in the common VCG
20511 format. It can be decorated with additional, per-node and/or per-edge
20512 information, if a list of comma-separated markers is additionally
20513 specified. When the @code{su} marker is specified, the callgraph is
20514 decorated with stack usage information; it is equivalent to
20515 @option{-fstack-usage}. When the @code{da} marker is specified, the
20516 callgraph is decorated with information about dynamically allocated
20517 objects.
20518
20519 When compiling with @option{-flto}, no callgraph information is output
20520 along with the object file. At LTO link time, @option{-fcallgraph-info}
20521 may generate multiple callgraph information files next to intermediate
20522 LTO output files.
20523
20524 @opindex d
20525 @opindex fdump-rtl-@var{pass}
20526 @item -d@var{letters}
20527 @itemx -fdump-rtl-@var{pass}
20528 @itemx -fdump-rtl-@var{pass}=@var{filename}
20529 Says to make debugging dumps during compilation at times specified by
20530 @var{letters}. This is used for debugging the RTL-based passes of the
20531 compiler.
20532
20533 Some @option{-d@var{letters}} switches have different meaning when
20534 @option{-E} is used for preprocessing. @xref{Preprocessor Options},
20535 for information about preprocessor-specific dump options.
20536
20537 Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
20538 @option{-d} option @var{letters}. Here are the possible
20539 letters for use in @var{pass} and @var{letters}, and their meanings:
20540
20541 @table @gcctabopt
20542
20543 @opindex fdump-rtl-alignments
20544 @item -fdump-rtl-alignments
20545 Dump after branch alignments have been computed.
20546
20547 @opindex fdump-rtl-asmcons
20548 @item -fdump-rtl-asmcons
20549 Dump after fixing rtl statements that have unsatisfied in/out constraints.
20550
20551 @opindex fdump-rtl-auto_inc_dec
20552 @item -fdump-rtl-auto_inc_dec
20553 Dump after auto-inc-dec discovery. This pass is only run on
20554 architectures that have auto inc or auto dec instructions.
20555
20556 @opindex fdump-rtl-barriers
20557 @item -fdump-rtl-barriers
20558 Dump after cleaning up the barrier instructions.
20559
20560 @opindex fdump-rtl-bbpart
20561 @item -fdump-rtl-bbpart
20562 Dump after partitioning hot and cold basic blocks.
20563
20564 @opindex fdump-rtl-bbro
20565 @item -fdump-rtl-bbro
20566 Dump after block reordering.
20567
20568 @opindex fdump-rtl-btl2
20569 @opindex fdump-rtl-btl2
20570 @item -fdump-rtl-btl1
20571 @itemx -fdump-rtl-btl2
20572 @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
20573 after the two branch
20574 target load optimization passes.
20575
20576 @opindex fdump-rtl-bypass
20577 @item -fdump-rtl-bypass
20578 Dump after jump bypassing and control flow optimizations.
20579
20580 @opindex fdump-rtl-combine
20581 @item -fdump-rtl-combine
20582 Dump after the RTL instruction combination pass.
20583
20584 @opindex fdump-rtl-compgotos
20585 @item -fdump-rtl-compgotos
20586 Dump after duplicating the computed gotos.
20587
20588 @opindex fdump-rtl-ce1
20589 @opindex fdump-rtl-ce2
20590 @opindex fdump-rtl-ce3
20591 @item -fdump-rtl-ce1
20592 @itemx -fdump-rtl-ce2
20593 @itemx -fdump-rtl-ce3
20594 @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
20595 @option{-fdump-rtl-ce3} enable dumping after the three
20596 if conversion passes.
20597
20598 @opindex fdump-rtl-cprop_hardreg
20599 @item -fdump-rtl-cprop_hardreg
20600 Dump after hard register copy propagation.
20601
20602 @opindex fdump-rtl-csa
20603 @item -fdump-rtl-csa
20604 Dump after combining stack adjustments.
20605
20606 @opindex fdump-rtl-cse1
20607 @opindex fdump-rtl-cse2
20608 @item -fdump-rtl-cse1
20609 @itemx -fdump-rtl-cse2
20610 @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
20611 the two common subexpression elimination passes.
20612
20613 @opindex fdump-rtl-dce
20614 @item -fdump-rtl-dce
20615 Dump after the standalone dead code elimination passes.
20616
20617 @opindex fdump-rtl-dbr
20618 @item -fdump-rtl-dbr
20619 Dump after delayed branch scheduling.
20620
20621 @opindex fdump-rtl-dce1
20622 @opindex fdump-rtl-dce2
20623 @item -fdump-rtl-dce1
20624 @itemx -fdump-rtl-dce2
20625 @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
20626 the two dead store elimination passes.
20627
20628 @opindex fdump-rtl-eh
20629 @item -fdump-rtl-eh
20630 Dump after finalization of EH handling code.
20631
20632 @opindex fdump-rtl-eh_ranges
20633 @item -fdump-rtl-eh_ranges
20634 Dump after conversion of EH handling range regions.
20635
20636 @opindex fdump-rtl-expand
20637 @item -fdump-rtl-expand
20638 Dump after RTL generation.
20639
20640 @opindex fdump-rtl-fwprop1
20641 @opindex fdump-rtl-fwprop2
20642 @item -fdump-rtl-fwprop1
20643 @itemx -fdump-rtl-fwprop2
20644 @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
20645 dumping after the two forward propagation passes.
20646
20647 @opindex fdump-rtl-gcse1
20648 @opindex fdump-rtl-gcse2
20649 @item -fdump-rtl-gcse1
20650 @itemx -fdump-rtl-gcse2
20651 @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
20652 after global common subexpression elimination.
20653
20654 @opindex fdump-rtl-init-regs
20655 @item -fdump-rtl-init-regs
20656 Dump after the initialization of the registers.
20657
20658 @opindex fdump-rtl-initvals
20659 @item -fdump-rtl-initvals
20660 Dump after the computation of the initial value sets.
20661
20662 @opindex fdump-rtl-into_cfglayout
20663 @item -fdump-rtl-into_cfglayout
20664 Dump after converting to cfglayout mode.
20665
20666 @opindex fdump-rtl-ira
20667 @item -fdump-rtl-ira
20668 Dump after iterated register allocation.
20669
20670 @opindex fdump-rtl-jump
20671 @item -fdump-rtl-jump
20672 Dump after the second jump optimization.
20673
20674 @opindex fdump-rtl-loop2
20675 @item -fdump-rtl-loop2
20676 @option{-fdump-rtl-loop2} enables dumping after the rtl
20677 loop optimization passes.
20678
20679 @opindex fdump-rtl-mach
20680 @item -fdump-rtl-mach
20681 Dump after performing the machine dependent reorganization pass, if that
20682 pass exists.
20683
20684 @opindex fdump-rtl-mode_sw
20685 @item -fdump-rtl-mode_sw
20686 Dump after removing redundant mode switches.
20687
20688 @opindex fdump-rtl-rnreg
20689 @item -fdump-rtl-rnreg
20690 Dump after register renumbering.
20691
20692 @opindex fdump-rtl-outof_cfglayout
20693 @item -fdump-rtl-outof_cfglayout
20694 Dump after converting from cfglayout mode.
20695
20696 @opindex fdump-rtl-peephole2
20697 @item -fdump-rtl-peephole2
20698 Dump after the peephole pass.
20699
20700 @opindex fdump-rtl-postreload
20701 @item -fdump-rtl-postreload
20702 Dump after post-reload optimizations.
20703
20704 @opindex fdump-rtl-pro_and_epilogue
20705 @item -fdump-rtl-pro_and_epilogue
20706 Dump after generating the function prologues and epilogues.
20707
20708 @opindex fdump-rtl-sched1
20709 @opindex fdump-rtl-sched2
20710 @item -fdump-rtl-sched1
20711 @itemx -fdump-rtl-sched2
20712 @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
20713 after the basic block scheduling passes.
20714
20715 @opindex fdump-rtl-ree
20716 @item -fdump-rtl-ree
20717 Dump after sign/zero extension elimination.
20718
20719 @opindex fdump-rtl-seqabstr
20720 @item -fdump-rtl-seqabstr
20721 Dump after common sequence discovery.
20722
20723 @opindex fdump-rtl-shorten
20724 @item -fdump-rtl-shorten
20725 Dump after shortening branches.
20726
20727 @opindex fdump-rtl-split1
20728 @opindex fdump-rtl-split2
20729 @opindex fdump-rtl-split3
20730 @opindex fdump-rtl-split4
20731 @opindex fdump-rtl-split5
20732 @item -fdump-rtl-split1
20733 @itemx -fdump-rtl-split2
20734 @itemx -fdump-rtl-split3
20735 @itemx -fdump-rtl-split4
20736 @itemx -fdump-rtl-split5
20737 These options enable dumping after five rounds of
20738 instruction splitting.
20739
20740 @opindex fdump-rtl-sms
20741 @item -fdump-rtl-sms
20742 Dump after modulo scheduling. This pass is only run on some
20743 architectures.
20744
20745 @opindex fdump-rtl-stack
20746 @item -fdump-rtl-stack
20747 Dump after conversion from GCC's ``flat register file'' registers to the
20748 x87's stack-like registers. This pass is only run on x86 variants.
20749
20750 @opindex fdump-rtl-subreg1
20751 @opindex fdump-rtl-subreg2
20752 @item -fdump-rtl-subreg1
20753 @itemx -fdump-rtl-subreg2
20754 @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
20755 the two subreg expansion passes.
20756
20757 @opindex fdump-rtl-vartrack
20758 @item -fdump-rtl-vartrack
20759 Dump after variable tracking.
20760
20761 @opindex fdump-rtl-vregs
20762 @item -fdump-rtl-vregs
20763 Dump after converting virtual registers to hard registers.
20764
20765 @opindex fdump-rtl-web
20766 @item -fdump-rtl-web
20767 Dump after live range splitting.
20768
20769 @opindex fdump-rtl-regclass
20770 @opindex fdump-rtl-subregs_of_mode_init
20771 @opindex fdump-rtl-subregs_of_mode_finish
20772 @opindex fdump-rtl-dfinit
20773 @opindex fdump-rtl-dfinish
20774 @item -fdump-rtl-regclass
20775 @itemx -fdump-rtl-subregs_of_mode_init
20776 @itemx -fdump-rtl-subregs_of_mode_finish
20777 @itemx -fdump-rtl-dfinit
20778 @itemx -fdump-rtl-dfinish
20779 These dumps are defined but always produce empty files.
20780
20781 @opindex da
20782 @opindex fdump-rtl-all
20783 @item -da
20784 @itemx -fdump-rtl-all
20785 Produce all the dumps listed above.
20786
20787 @opindex dA
20788 @item -dA
20789 Annotate the assembler output with miscellaneous debugging information.
20790
20791 @opindex dD
20792 @item -dD
20793 Dump all macro definitions, at the end of preprocessing, in addition to
20794 normal output.
20795
20796 @opindex dH
20797 @item -dH
20798 Produce a core dump whenever an error occurs.
20799
20800 @opindex dp
20801 @item -dp
20802 Annotate the assembler output with a comment indicating which
20803 pattern and alternative is used. The length and cost of each instruction are
20804 also printed.
20805
20806 @opindex dP
20807 @item -dP
20808 Dump the RTL in the assembler output as a comment before each instruction.
20809 Also turns on @option{-dp} annotation.
20810
20811 @opindex dx
20812 @item -dx
20813 Just generate RTL for a function instead of compiling it. Usually used
20814 with @option{-fdump-rtl-expand}.
20815 @end table
20816
20817 @opindex fdump-debug
20818 @item -fdump-debug
20819 Dump debugging information generated during the debug
20820 generation phase.
20821
20822 @opindex fdump-earlydebug
20823 @item -fdump-earlydebug
20824 Dump debugging information generated during the early debug
20825 generation phase.
20826
20827 @opindex fdump-noaddr
20828 @item -fdump-noaddr
20829 When doing debugging dumps, suppress address output. This makes it more
20830 feasible to use diff on debugging dumps for compiler invocations with
20831 different compiler binaries and/or different
20832 text / bss / data / heap / stack / dso start locations.
20833
20834 @opindex freport-bug
20835 @item -freport-bug
20836 Collect and dump debug information into a temporary file if an
20837 internal compiler error (ICE) occurs.
20838
20839 @opindex fdump-unnumbered
20840 @item -fdump-unnumbered
20841 When doing debugging dumps, suppress instruction numbers and address output.
20842 This makes it more feasible to use diff on debugging dumps for compiler
20843 invocations with different options, in particular with and without
20844 @option{-g}.
20845
20846 @opindex fdump-unnumbered-links
20847 @item -fdump-unnumbered-links
20848 When doing debugging dumps (see @option{-d} option above), suppress
20849 instruction numbers for the links to the previous and next instructions
20850 in a sequence.
20851
20852 @opindex fdump-ipa
20853 @item -fdump-ipa-@var{switch}
20854 @itemx -fdump-ipa-@var{switch}-@var{options}
20855 Control the dumping at various stages of inter-procedural analysis
20856 language tree to a file. The file name is generated by appending a
20857 switch specific suffix to the source file name, and the file is created
20858 in the same directory as the output file. The following dumps are
20859 possible:
20860
20861 @table @samp
20862 @item all
20863 Enables all inter-procedural analysis dumps.
20864
20865 @item cgraph
20866 Dumps information about call-graph optimization, unused function removal,
20867 and inlining decisions.
20868
20869 @item inline
20870 Dump after function inlining.
20871
20872 @item strubm
20873 Dump after selecting @code{strub} modes, and recording the selections as
20874 function attributes.
20875
20876 @item strub
20877 Dump @code{strub} transformations: interface changes, function wrapping,
20878 and insertion of builtin calls for stack scrubbing and watermarking.
20879
20880 @end table
20881
20882 Additionally, the options @option{-optimized}, @option{-missed},
20883 @option{-note}, and @option{-all} can be provided, with the same meaning
20884 as for @option{-fopt-info}, defaulting to @option{-optimized}.
20885
20886 For example, @option{-fdump-ipa-inline-optimized-missed} will emit
20887 information on callsites that were inlined, along with callsites
20888 that were not inlined.
20889
20890 By default, the dump will contain messages about successful
20891 optimizations (equivalent to @option{-optimized}) together with
20892 low-level details about the analysis.
20893
20894 @opindex fdump-ipa-clones
20895 @item -fdump-ipa-clones
20896
20897 Create a dump file containing information about creation of call graph
20898 node clones and removals of call graph nodes during inter-procedural
20899 optimizations and transformations. Its main intended use is that tools
20900 that create live-patches can determine the set of functions that need to
20901 be live-patched to completely replace a particular function (see
20902 @option{-flive-patching}). The file name is generated by appending
20903 suffix @code{ipa-clones} to the source file name, and the file is
20904 created in the same directory as the output file. Each entry in the
20905 file is on a separate line containing semicolon separated fields.
20906
20907 In the case of call graph clone creation, the individual fields are:
20908
20909 @enumerate
20910 @item
20911 String @code{Callgraph clone}.
20912
20913 @item
20914 Name of the function being cloned as it is presented to the assembler.
20915
20916 @item
20917 A number that uniquely represents the function being cloned in the call
20918 graph. Note that the number is unique only within a compilation unit or
20919 within whole-program analysis but is likely to be different in the two
20920 phases.
20921
20922 @item
20923 The file name of the source file where the function is defined.
20924
20925 @item
20926 The line on which the function definition is located.
20927
20928 @item
20929 The column where the function definition is located.
20930
20931 @item
20932 Name of the new function clone as it is presented to the assembler.
20933
20934 @item
20935 A number that uniquely represents the new function clone in the call
20936 graph. Note that the number is unique only within a compilation unit or
20937 within whole-program analysis but is likely to be different in the two
20938 phases.
20939
20940 @item
20941 The file name of the source file where the source code location of the
20942 new clone points to.
20943
20944 @item
20945 The line to which the source code location of the new clone points to.
20946
20947 @item
20948 The column to which the source code location of the new clone points to.
20949
20950 @item
20951 A string that determines the reason for cloning.
20952
20953 @end enumerate
20954
20955 In the case of call graph clone removal, the individual fields are:
20956
20957 @enumerate
20958 @item
20959 String @code{Callgraph removal}.
20960
20961 @item
20962 Name of the function being removed as it would be presented to the assembler.
20963
20964 @item
20965 A number that uniquely represents the function being cloned in the call
20966 graph. Note that the number is unique only within a compilation unit or
20967 within whole-program analysis but is likely to be different in the two
20968 phases.
20969
20970 @item
20971 The file name of the source file where the function is defined.
20972
20973 @item
20974 The line on which the function definition is located.
20975
20976 @item
20977 The column where the function definition is located.
20978
20979 @end enumerate
20980
20981 @opindex fdump-lang
20982 @item -fdump-lang
20983 Dump language-specific information. The file name is made by appending
20984 @file{.lang} to the source file name.
20985
20986 @opindex fdump-lang-all
20987 @opindex fdump-lang
20988 @item -fdump-lang-all
20989 @itemx -fdump-lang-@var{switch}
20990 @itemx -fdump-lang-@var{switch}-@var{options}
20991 @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
20992 Control the dumping of language-specific information. The @var{options}
20993 and @var{filename} portions behave as described in the
20994 @option{-fdump-tree} option. @option{-fdump-tree-all} enables all
20995 language-specific dumps; other options vary with the language. For
20996 instance, see @xref{C++ Dialect Options} for the @option{-fdump-lang}
20997 flags supported by the C++ front-end.
20998
20999 @opindex fdump-passes
21000 @item -fdump-passes
21001 Print on @file{stderr} the list of optimization passes that are turned
21002 on and off by the current command-line options.
21003
21004 @opindex fdump-statistics
21005 @item -fdump-statistics-@var{option}
21006 Enable and control dumping of pass statistics in a separate file. The
21007 file name is generated by appending a suffix ending in
21008 @samp{.statistics} to the source file name, and the file is created in
21009 the same directory as the output file. If the @samp{-@var{option}}
21010 form is used, @samp{-stats} causes counters to be summed over the
21011 whole compilation unit while @samp{-details} dumps every event as
21012 the passes generate them. The default with no option is to sum
21013 counters for each function compiled.
21014
21015 @opindex fdump-tree-all
21016 @opindex fdump-tree
21017 @item -fdump-tree-all
21018 @itemx -fdump-tree-@var{switch}
21019 @itemx -fdump-tree-@var{switch}-@var{options}
21020 @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
21021 Control the dumping at various stages of processing the intermediate
21022 language tree to a file. If the @samp{-@var{options}}
21023 form is used, @var{options} is a list of @samp{-} separated options
21024 which control the details of the dump. Not all options are applicable
21025 to all dumps; those that are not meaningful are ignored. The
21026 following options are available
21027
21028 @table @samp
21029 @item address
21030 Print the address of each node. Usually this is not meaningful as it
21031 changes according to the environment and source file. Its primary use
21032 is for tying up a dump file with a debug environment.
21033 @item asmname
21034 If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
21035 in the dump instead of @code{DECL_NAME}. Its primary use is ease of
21036 use working backward from mangled names in the assembly file.
21037 @item slim
21038 When dumping front-end intermediate representations, inhibit dumping
21039 of members of a scope or body of a function merely because that scope
21040 has been reached. Only dump such items when they are directly reachable
21041 by some other path.
21042
21043 When dumping pretty-printed trees, this option inhibits dumping the
21044 bodies of control structures.
21045
21046 When dumping RTL, print the RTL in slim (condensed) form instead of
21047 the default LISP-like representation.
21048 @item raw
21049 Print a raw representation of the tree. By default, trees are
21050 pretty-printed into a C-like representation.
21051 @item details
21052 Enable more detailed dumps (not honored by every dump option). Also
21053 include information from the optimization passes.
21054 @item stats
21055 Enable dumping various statistics about the pass (not honored by every dump
21056 option).
21057 @item blocks
21058 Enable showing basic block boundaries (disabled in raw dumps).
21059 @item graph
21060 For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
21061 dump a representation of the control flow graph suitable for viewing with
21062 GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
21063 the file is pretty-printed as a subgraph, so that GraphViz can render them
21064 all in a single plot.
21065
21066 This option currently only works for RTL dumps, and the RTL is always
21067 dumped in slim form.
21068 @item vops
21069 Enable showing virtual operands for every statement.
21070 @item lineno
21071 Enable showing line numbers for statements.
21072 @item uid
21073 Enable showing the unique ID (@code{DECL_UID}) for each variable.
21074 @item verbose
21075 Enable showing the tree dump for each statement.
21076 @item eh
21077 Enable showing the EH region number holding each statement.
21078 @item scev
21079 Enable showing scalar evolution analysis details.
21080 @item optimized
21081 Enable showing optimization information (only available in certain
21082 passes).
21083 @item missed
21084 Enable showing missed optimization information (only available in certain
21085 passes).
21086 @item note
21087 Enable other detailed optimization information (only available in
21088 certain passes).
21089 @item all
21090 Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
21091 and @option{lineno}.
21092 @item optall
21093 Turn on all optimization options, i.e., @option{optimized},
21094 @option{missed}, and @option{note}.
21095 @end table
21096
21097 To determine what tree dumps are available or find the dump for a pass
21098 of interest follow the steps below.
21099
21100 @enumerate
21101 @item
21102 Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
21103 look for a code that corresponds to the pass you are interested in.
21104 For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
21105 @code{tree-vrp2} correspond to the three Value Range Propagation passes.
21106 The number at the end distinguishes distinct invocations of the same pass.
21107 @item
21108 To enable the creation of the dump file, append the pass code to
21109 the @option{-fdump-} option prefix and invoke GCC with it. For example,
21110 to enable the dump from the Early Value Range Propagation pass, invoke
21111 GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
21112 specify the name of the dump file. If you don't specify one, GCC
21113 creates as described below.
21114 @item
21115 Find the pass dump in a file whose name is composed of three components
21116 separated by a period: the name of the source file GCC was invoked to
21117 compile, a numeric suffix indicating the pass number followed by the
21118 letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
21119 and finally the pass code. For example, the Early VRP pass dump might
21120 be in a file named @file{myfile.c.038t.evrp} in the current working
21121 directory. Note that the numeric codes are not stable and may change
21122 from one version of GCC to another.
21123 @end enumerate
21124
21125 @opindex fopt-info
21126 @item -fopt-info
21127 @itemx -fopt-info-@var{options}
21128 @itemx -fopt-info-@var{options}=@var{filename}
21129 Controls optimization dumps from various optimization passes. If the
21130 @samp{-@var{options}} form is used, @var{options} is a list of
21131 @samp{-} separated option keywords to select the dump details and
21132 optimizations.
21133
21134 The @var{options} can be divided into three groups:
21135 @enumerate
21136 @item
21137 options describing what kinds of messages should be emitted,
21138 @item
21139 options describing the verbosity of the dump, and
21140 @item
21141 options describing which optimizations should be included.
21142 @end enumerate
21143 The options from each group can be freely mixed as they are
21144 non-overlapping. However, in case of any conflicts,
21145 the later options override the earlier options on the command
21146 line.
21147
21148 The following options control which kinds of messages should be emitted:
21149
21150 @table @samp
21151 @item optimized
21152 Print information when an optimization is successfully applied. It is
21153 up to a pass to decide which information is relevant. For example, the
21154 vectorizer passes print the source location of loops which are
21155 successfully vectorized.
21156 @item missed
21157 Print information about missed optimizations. Individual passes
21158 control which information to include in the output.
21159 @item note
21160 Print verbose information about optimizations, such as certain
21161 transformations, more detailed messages about decisions etc.
21162 @item all
21163 Print detailed optimization information. This includes
21164 @samp{optimized}, @samp{missed}, and @samp{note}.
21165 @end table
21166
21167 The following option controls the dump verbosity:
21168
21169 @table @samp
21170 @item internals
21171 By default, only ``high-level'' messages are emitted. This option enables
21172 additional, more detailed, messages, which are likely to only be of interest
21173 to GCC developers.
21174 @end table
21175
21176 One or more of the following option keywords can be used to describe a
21177 group of optimizations:
21178
21179 @table @samp
21180 @item ipa
21181 Enable dumps from all interprocedural optimizations.
21182 @item loop
21183 Enable dumps from all loop optimizations.
21184 @item inline
21185 Enable dumps from all inlining optimizations.
21186 @item omp
21187 Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
21188 @item vec
21189 Enable dumps from all vectorization optimizations.
21190 @item optall
21191 Enable dumps from all optimizations. This is a superset of
21192 the optimization groups listed above.
21193 @end table
21194
21195 If @var{options} is
21196 omitted, it defaults to @samp{optimized-optall}, which means to dump messages
21197 about successful optimizations from all the passes, omitting messages
21198 that are treated as ``internals''.
21199
21200 If the @var{filename} is provided, then the dumps from all the
21201 applicable optimizations are concatenated into the @var{filename}.
21202 Otherwise the dump is output onto @file{stderr}. Though multiple
21203 @option{-fopt-info} options are accepted, only one of them can include
21204 a @var{filename}. If other filenames are provided then all but the
21205 first such option are ignored.
21206
21207 Note that the output @var{filename} is overwritten
21208 in case of multiple translation units. If a combined output from
21209 multiple translation units is desired, @file{stderr} should be used
21210 instead.
21211
21212 In the following example, the optimization info is output to
21213 @file{stderr}:
21214
21215 @smallexample
21216 gcc -O3 -fopt-info
21217 @end smallexample
21218
21219 This example:
21220 @smallexample
21221 gcc -O3 -fopt-info-missed=missed.all
21222 @end smallexample
21223
21224 @noindent
21225 outputs missed optimization report from all the passes into
21226 @file{missed.all}, and this one:
21227
21228 @smallexample
21229 gcc -O2 -ftree-vectorize -fopt-info-vec-missed
21230 @end smallexample
21231
21232 @noindent
21233 prints information about missed optimization opportunities from
21234 vectorization passes on @file{stderr}.
21235 Note that @option{-fopt-info-vec-missed} is equivalent to
21236 @option{-fopt-info-missed-vec}. The order of the optimization group
21237 names and message types listed after @option{-fopt-info} does not matter.
21238
21239 As another example,
21240 @smallexample
21241 gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
21242 @end smallexample
21243
21244 @noindent
21245 outputs information about missed optimizations as well as
21246 optimized locations from all the inlining passes into
21247 @file{inline.txt}.
21248
21249 Finally, consider:
21250
21251 @smallexample
21252 gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
21253 @end smallexample
21254
21255 @noindent
21256 Here the two output filenames @file{vec.miss} and @file{loop.opt} are
21257 in conflict since only one output file is allowed. In this case, only
21258 the first option takes effect and the subsequent options are
21259 ignored. Thus only @file{vec.miss} is produced which contains
21260 dumps from the vectorizer about missed opportunities.
21261
21262 @opindex fsave-optimization-record
21263 @item -fsave-optimization-record
21264 Write a SRCFILE.opt-record.json.gz file detailing what optimizations
21265 were performed, for those optimizations that support @option{-fopt-info}.
21266
21267 This option is experimental and the format of the data within the
21268 compressed JSON file is subject to change.
21269
21270 It is roughly equivalent to a machine-readable version of
21271 @option{-fopt-info-all}, as a collection of messages with source file,
21272 line number and column number, with the following additional data for
21273 each message:
21274
21275 @itemize @bullet
21276
21277 @item
21278 the execution count of the code being optimized, along with metadata about
21279 whether this was from actual profile data, or just an estimate, allowing
21280 consumers to prioritize messages by code hotness,
21281
21282 @item
21283 the function name of the code being optimized, where applicable,
21284
21285 @item
21286 the ``inlining chain'' for the code being optimized, so that when
21287 a function is inlined into several different places (which might
21288 themselves be inlined), the reader can distinguish between the copies,
21289
21290 @item
21291 objects identifying those parts of the message that refer to expressions,
21292 statements or symbol-table nodes, which of these categories they are, and,
21293 when available, their source code location,
21294
21295 @item
21296 the GCC pass that emitted the message, and
21297
21298 @item
21299 the location in GCC's own code from which the message was emitted
21300
21301 @end itemize
21302
21303 Additionally, some messages are logically nested within other
21304 messages, reflecting implementation details of the optimization
21305 passes.
21306
21307 @opindex fsched-verbose
21308 @item -fsched-verbose=@var{n}
21309 On targets that use instruction scheduling, this option controls the
21310 amount of debugging output the scheduler prints to the dump files.
21311
21312 For @var{n} greater than zero, @option{-fsched-verbose} outputs the
21313 same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
21314 For @var{n} greater than one, it also output basic block probabilities,
21315 detailed ready list information and unit/insn info. For @var{n} greater
21316 than two, it includes RTL at abort point, control-flow and regions info.
21317 And for @var{n} over four, @option{-fsched-verbose} also includes
21318 dependence info.
21319
21320
21321
21322 @opindex fdisable-
21323 @opindex fenable-
21324 @item -fenable-@var{kind}-@var{pass}
21325 @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
21326
21327 This is a set of options that are used to explicitly disable/enable
21328 optimization passes. These options are intended for use for debugging GCC.
21329 Compiler users should use regular options for enabling/disabling
21330 passes instead.
21331
21332 @table @gcctabopt
21333
21334 @item -fdisable-ipa-@var{pass}
21335 Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
21336 statically invoked in the compiler multiple times, the pass name should be
21337 appended with a sequential number starting from 1.
21338
21339 @item -fdisable-rtl-@var{pass}
21340 @itemx -fdisable-rtl-@var{pass}=@var{range-list}
21341 Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
21342 statically invoked in the compiler multiple times, the pass name should be
21343 appended with a sequential number starting from 1. @var{range-list} is a
21344 comma-separated list of function ranges or assembler names. Each range is a number
21345 pair separated by a colon. The range is inclusive in both ends. If the range
21346 is trivial, the number pair can be simplified as a single number. If the
21347 function's call graph node's @var{uid} falls within one of the specified ranges,
21348 the @var{pass} is disabled for that function. The @var{uid} is shown in the
21349 function header of a dump file, and the pass names can be dumped by using
21350 option @option{-fdump-passes}.
21351
21352 @item -fdisable-tree-@var{pass}
21353 @itemx -fdisable-tree-@var{pass}=@var{range-list}
21354 Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
21355 option arguments.
21356
21357 @item -fenable-ipa-@var{pass}
21358 Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
21359 statically invoked in the compiler multiple times, the pass name should be
21360 appended with a sequential number starting from 1.
21361
21362 @item -fenable-rtl-@var{pass}
21363 @itemx -fenable-rtl-@var{pass}=@var{range-list}
21364 Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
21365 description and examples.
21366
21367 @item -fenable-tree-@var{pass}
21368 @itemx -fenable-tree-@var{pass}=@var{range-list}
21369 Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
21370 of option arguments.
21371
21372 @end table
21373
21374 Here are some examples showing uses of these options.
21375
21376 @smallexample
21377
21378 # disable ccp1 for all functions
21379 -fdisable-tree-ccp1
21380 # disable complete unroll for function whose cgraph node uid is 1
21381 -fenable-tree-cunroll=1
21382 # disable gcse2 for functions at the following ranges [1,1],
21383 # [300,400], and [400,1000]
21384 # disable gcse2 for functions foo and foo2
21385 -fdisable-rtl-gcse2=foo,foo2
21386 # disable early inlining
21387 -fdisable-tree-einline
21388 # disable ipa inlining
21389 -fdisable-ipa-inline
21390 # enable tree full unroll
21391 -fenable-tree-unroll
21392
21393 @end smallexample
21394
21395 @opindex fchecking
21396 @opindex fno-checking
21397 @item -fchecking
21398 @itemx -fchecking=@var{n}
21399 Enable internal consistency checking. The default depends on
21400 the compiler configuration. @option{-fchecking=2} enables further
21401 internal consistency checking that might affect code generation.
21402
21403 @opindex frandom-seed
21404 @item -frandom-seed=@var{string}
21405 This option provides a seed that GCC uses in place of
21406 random numbers in generating certain symbol names
21407 that have to be different in every compiled file. It is also used to
21408 place unique stamps in coverage data files and the object files that
21409 produce them. You can use the @option{-frandom-seed} option to produce
21410 reproducibly identical object files.
21411
21412 The @var{string} can either be a number (decimal, octal or hex) or an
21413 arbitrary string (in which case it's converted to a number by
21414 computing CRC32).
21415
21416 The @var{string} should be different for every file you compile.
21417
21418 @opindex save-temps
21419 @item -save-temps
21420 Store the usual ``temporary'' intermediate files permanently; name them
21421 as auxiliary output files, as specified described under
21422 @option{-dumpbase} and @option{-dumpdir}.
21423
21424 When used in combination with the @option{-x} command-line option,
21425 @option{-save-temps} is sensible enough to avoid overwriting an
21426 input source file with the same extension as an intermediate file.
21427 The corresponding intermediate file may be obtained by renaming the
21428 source file before using @option{-save-temps}.
21429
21430 @opindex save-temps=cwd
21431 @item -save-temps=cwd
21432 Equivalent to @option{-save-temps -dumpdir ./}.
21433
21434 @opindex save-temps=obj
21435 @item -save-temps=obj
21436 Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
21437 @file{outdir/} is the directory of the output file specified after the
21438 @option{-o} option, including any directory separators. If the
21439 @option{-o} option is not used, the @option{-save-temps=obj} switch
21440 behaves like @option{-save-temps=cwd}.
21441
21442 @opindex time
21443 @item -time@r{[}=@var{file}@r{]}
21444 Report the CPU time taken by each subprocess in the compilation
21445 sequence. For C source files, this is the compiler proper and assembler
21446 (plus the linker if linking is done).
21447
21448 Without the specification of an output file, the output looks like this:
21449
21450 @smallexample
21451 # cc1 0.12 0.01
21452 # as 0.00 0.01
21453 @end smallexample
21454
21455 The first number on each line is the ``user time'', that is time spent
21456 executing the program itself. The second number is ``system time'',
21457 time spent executing operating system routines on behalf of the program.
21458 Both numbers are in seconds.
21459
21460 With the specification of an output file, the output is appended to the
21461 named file, and it looks like this:
21462
21463 @smallexample
21464 0.12 0.01 cc1 @var{options}
21465 0.00 0.01 as @var{options}
21466 @end smallexample
21467
21468 The ``user time'' and the ``system time'' are moved before the program
21469 name, and the options passed to the program are displayed, so that one
21470 can later tell what file was being compiled, and with which options.
21471
21472 @opindex fdump-final-insns
21473 @item -fdump-final-insns@r{[}=@var{file}@r{]}
21474 Dump the final internal representation (RTL) to @var{file}. If the
21475 optional argument is omitted (or if @var{file} is @code{.}), the name
21476 of the dump file is determined by appending @code{.gkd} to the
21477 dump base name, see @option{-dumpbase}.
21478
21479 @opindex fcompare-debug
21480 @opindex fno-compare-debug
21481 @item -fcompare-debug@r{[}=@var{opts}@r{]}
21482 If no error occurs during compilation, run the compiler a second time,
21483 adding @var{opts} and @option{-fcompare-debug-second} to the arguments
21484 passed to the second compilation. Dump the final internal
21485 representation in both compilations, and print an error if they differ.
21486
21487 If the equal sign is omitted, the default @option{-gtoggle} is used.
21488
21489 The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
21490 and nonzero, implicitly enables @option{-fcompare-debug}. If
21491 @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
21492 then it is used for @var{opts}, otherwise the default @option{-gtoggle}
21493 is used.
21494
21495 @option{-fcompare-debug=}, with the equal sign but without @var{opts},
21496 is equivalent to @option{-fno-compare-debug}, which disables the dumping
21497 of the final representation and the second compilation, preventing even
21498 @env{GCC_COMPARE_DEBUG} from taking effect.
21499
21500 To verify full coverage during @option{-fcompare-debug} testing, set
21501 @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
21502 which GCC rejects as an invalid option in any actual compilation
21503 (rather than preprocessing, assembly or linking). To get just a
21504 warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
21505 not overridden} will do.
21506
21507 @opindex fcompare-debug-second
21508 @item -fcompare-debug-second
21509 This option is implicitly passed to the compiler for the second
21510 compilation requested by @option{-fcompare-debug}, along with options to
21511 silence warnings, and omitting other options that would cause the compiler
21512 to produce output to files or to standard output as a side effect. Dump
21513 files and preserved temporary files are renamed so as to contain the
21514 @code{.gk} additional extension during the second compilation, to avoid
21515 overwriting those generated by the first.
21516
21517 When this option is passed to the compiler driver, it causes the
21518 @emph{first} compilation to be skipped, which makes it useful for little
21519 other than debugging the compiler proper.
21520
21521 @opindex gtoggle
21522 @item -gtoggle
21523 Turn off generation of debug info, if leaving out this option
21524 generates it, or turn it on at level 2 otherwise. The position of this
21525 argument in the command line does not matter; it takes effect after all
21526 other options are processed, and it does so only once, no matter how
21527 many times it is given. This is mainly intended to be used with
21528 @option{-fcompare-debug}.
21529
21530 @opindex fvar-tracking-assignments-toggle
21531 @opindex fno-var-tracking-assignments-toggle
21532 @item -fvar-tracking-assignments-toggle
21533 Toggle @option{-fvar-tracking-assignments}, in the same way that
21534 @option{-gtoggle} toggles @option{-g}.
21535
21536 @opindex Q
21537 @item -Q
21538 When used on the command line prior to @option{--help=}, @option{-Q}
21539 acts as a modifier to the help output. @xref{Overall Options},
21540 for details about @option{--help=}.
21541
21542 Otherwise, this option makes the compiler print out each function name
21543 as it is compiled, and print some statistics about each pass when it
21544 finishes.
21545
21546 @opindex ftime-report
21547 @item -ftime-report
21548 Makes the compiler print some statistics to stderr about the time consumed
21549 by each pass when it finishes.
21550
21551 If SARIF output of diagnostics was requested via
21552 @option{-fdiagnostics-format=sarif-file} or
21553 @option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report}
21554 information is instead emitted in JSON form as part of SARIF output. The
21555 precise format of this JSON data is subject to change, and the values may
21556 not exactly match those emitted to stderr due to being written out at a
21557 slightly different place within the compiler.
21558
21559 @opindex ftime-report-details
21560 @item -ftime-report-details
21561 Record the time consumed by infrastructure parts separately for each pass.
21562
21563 @opindex fira-verbose
21564 @item -fira-verbose=@var{n}
21565 Control the verbosity of the dump file for the integrated register allocator.
21566 The default value is 5. If the value @var{n} is greater or equal to 10,
21567 the dump output is sent to stderr using the same format as @var{n} minus 10.
21568
21569 @opindex flto-report
21570 @item -flto-report
21571 Prints a report with internal details on the workings of the link-time
21572 optimizer. The contents of this report vary from version to version.
21573 It is meant to be useful to GCC developers when processing object
21574 files in LTO mode (via @option{-flto}).
21575
21576 Disabled by default.
21577
21578 @opindex flto-report-wpa
21579 @item -flto-report-wpa
21580 Like @option{-flto-report}, but only print for the WPA phase of link-time
21581 optimization.
21582
21583 @opindex fmem-report
21584 @item -fmem-report
21585 Makes the compiler print some statistics about permanent memory
21586 allocation when it finishes.
21587
21588 @opindex fmem-report-wpa
21589 @item -fmem-report-wpa
21590 Makes the compiler print some statistics about permanent memory
21591 allocation for the WPA phase only.
21592
21593 @opindex fpre-ipa-mem-report
21594 @opindex fpost-ipa-mem-report
21595 @item -fpre-ipa-mem-report
21596 @item -fpost-ipa-mem-report
21597 Makes the compiler print some statistics about permanent memory
21598 allocation before or after interprocedural optimization.
21599
21600 @opindex fmultiflags
21601 @item -fmultiflags
21602 This option enables multilib-aware @code{TFLAGS} to be used to build
21603 target libraries with options different from those the compiler is
21604 configured to use by default, through the use of specs (@pxref{Spec
21605 Files}) set up by compiler internals, by the target, or by builders at
21606 configure time.
21607
21608 Like @code{TFLAGS}, this allows the target libraries to be built for
21609 portable baseline environments, while the compiler defaults to more
21610 demanding ones. That's useful because users can easily override the
21611 defaults the compiler is configured to use to build their own programs,
21612 if the defaults are not ideal for their target environment, whereas
21613 rebuilding the runtime libraries is usually not as easy or desirable.
21614
21615 Unlike @code{TFLAGS}, the use of specs enables different flags to be
21616 selected for different multilibs. The way to accomplish that is to
21617 build with @samp{make TFLAGS=-fmultiflags}, after configuring
21618 @samp{--with-specs=%@{fmultiflags:...@}}.
21619
21620 This option is discarded by the driver once it's done processing driver
21621 self spec.
21622
21623 It is also useful to check that @code{TFLAGS} are being used to build
21624 all target libraries, by configuring a non-bootstrap compiler
21625 @samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
21626 the compiler and target libraries.
21627
21628 @opindex fprofile-report
21629 @item -fprofile-report
21630 Makes the compiler print some statistics about consistency of the
21631 (estimated) profile and effect of individual passes.
21632
21633 @opindex fstack-usage
21634 @item -fstack-usage
21635 Makes the compiler output stack usage information for the program, on a
21636 per-function basis. The filename for the dump is made by appending
21637 @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
21638 the output file, if explicitly specified and it is not an executable,
21639 otherwise it is the basename of the source file. An entry is made up
21640 of three fields:
21641
21642 @itemize
21643 @item
21644 The name of the function.
21645 @item
21646 A number of bytes.
21647 @item
21648 One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
21649 @end itemize
21650
21651 The qualifier @code{static} means that the function manipulates the stack
21652 statically: a fixed number of bytes are allocated for the frame on function
21653 entry and released on function exit; no stack adjustments are otherwise made
21654 in the function. The second field is this fixed number of bytes.
21655
21656 The qualifier @code{dynamic} means that the function manipulates the stack
21657 dynamically: in addition to the static allocation described above, stack
21658 adjustments are made in the body of the function, for example to push/pop
21659 arguments around function calls. If the qualifier @code{bounded} is also
21660 present, the amount of these adjustments is bounded at compile time and
21661 the second field is an upper bound of the total amount of stack used by
21662 the function. If it is not present, the amount of these adjustments is
21663 not bounded at compile time and the second field only represents the
21664 bounded part.
21665
21666 @opindex fstats
21667 @item -fstats
21668 Emit statistics about front-end processing at the end of the compilation.
21669 This option is supported only by the C++ front end, and
21670 the information is generally only useful to the G++ development team.
21671
21672 @opindex fdbg-cnt-list
21673 @item -fdbg-cnt-list
21674 Print the name and the counter upper bound for all debug counters.
21675
21676
21677 @opindex fdbg-cnt
21678 @item -fdbg-cnt=@var{counter-value-list}
21679 Set the internal debug counter lower and upper bound. @var{counter-value-list}
21680 is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
21681 [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
21682 the name of the counter and list of closed intervals.
21683 The @var{lower_bound} is optional and is zero
21684 initialized if not set.
21685 For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
21686 @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
21687 eleventh invocation.
21688 For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
21689
21690 @opindex print-file-name
21691 @item -print-file-name=@var{library}
21692 Print the full absolute name of the library file @var{library} that
21693 would be used when linking---and don't do anything else. With this
21694 option, GCC does not compile or link anything; it just prints the
21695 file name.
21696
21697 @opindex print-multi-directory
21698 @item -print-multi-directory
21699 Print the directory name corresponding to the multilib selected by any
21700 other switches present in the command line. This directory is supposed
21701 to exist in @env{GCC_EXEC_PREFIX}.
21702
21703 @opindex print-multi-lib
21704 @item -print-multi-lib
21705 Print the mapping from multilib directory names to compiler switches
21706 that enable them. The directory name is separated from the switches by
21707 @samp{;}, and each switch starts with an @samp{@@} instead of the
21708 @samp{-}, without spaces between multiple switches. This is supposed to
21709 ease shell processing.
21710
21711 @opindex print-multi-os-directory
21712 @item -print-multi-os-directory
21713 Print the path to OS libraries for the selected
21714 multilib, relative to some @file{lib} subdirectory. If OS libraries are
21715 present in the @file{lib} subdirectory and no multilibs are used, this is
21716 usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
21717 sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
21718 @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
21719 subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
21720
21721 @opindex print-multiarch
21722 @item -print-multiarch
21723 Print the path to OS libraries for the selected multiarch,
21724 relative to some @file{lib} subdirectory.
21725
21726 @opindex print-prog-name
21727 @item -print-prog-name=@var{program}
21728 Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
21729
21730 @opindex print-libgcc-file-name
21731 @item -print-libgcc-file-name
21732 Same as @option{-print-file-name=libgcc.a}.
21733
21734 This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
21735 but you do want to link with @file{libgcc.a}. You can do:
21736
21737 @smallexample
21738 gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
21739 @end smallexample
21740
21741 @opindex print-search-dirs
21742 @item -print-search-dirs
21743 Print the name of the configured installation directory and a list of
21744 program and library directories @command{gcc} searches---and don't do anything else.
21745
21746 This is useful when @command{gcc} prints the error message
21747 @samp{installation problem, cannot exec cpp0: No such file or directory}.
21748 To resolve this you either need to put @file{cpp0} and the other compiler
21749 components where @command{gcc} expects to find them, or you can set the environment
21750 variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
21751 Don't forget the trailing @samp{/}.
21752 @xref{Environment Variables}.
21753
21754 @opindex print-sysroot
21755 @item -print-sysroot
21756 Print the target sysroot directory that is used during
21757 compilation. This is the target sysroot specified either at configure
21758 time or using the @option{--sysroot} option, possibly with an extra
21759 suffix that depends on compilation options. If no target sysroot is
21760 specified, the option prints nothing.
21761
21762 @opindex print-sysroot-headers-suffix
21763 @item -print-sysroot-headers-suffix
21764 Print the suffix added to the target sysroot when searching for
21765 headers, or give an error if the compiler is not configured with such
21766 a suffix---and don't do anything else.
21767
21768 @opindex dumpmachine
21769 @item -dumpmachine
21770 Print the compiler's target machine (for example,
21771 @samp{i686-pc-linux-gnu})---and don't do anything else.
21772
21773 @opindex dumpversion
21774 @item -dumpversion
21775 Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
21776 anything else. This is the compiler version used in filesystem paths and
21777 specs. Depending on how the compiler has been configured it can be just
21778 a single number (major version), two numbers separated by a dot (major and
21779 minor version) or three numbers separated by dots (major, minor and patchlevel
21780 version).
21781
21782 @opindex dumpfullversion
21783 @item -dumpfullversion
21784 Print the full compiler version---and don't do anything else. The output is
21785 always three numbers separated by dots, major, minor and patchlevel version.
21786
21787 @opindex dumpspecs
21788 @item -dumpspecs
21789 Print the compiler's built-in specs---and don't do anything else. (This
21790 is used when GCC itself is being built.) @xref{Spec Files}.
21791 @end table
21792
21793 @node Submodel Options
21794 @section Machine-Dependent Options
21795 @cindex submodel options
21796 @cindex specifying hardware config
21797 @cindex hardware models and configurations, specifying
21798 @cindex target-dependent options
21799 @cindex machine-dependent options
21800
21801 Each target machine supported by GCC can have its own options---for
21802 example, to allow you to compile for a particular processor variant or
21803 ABI, or to control optimizations specific to that machine. By
21804 convention, the names of machine-specific options start with
21805 @samp{-m}.
21806
21807 Some configurations of the compiler also support additional target-specific
21808 options, usually for compatibility with other compilers on the same
21809 platform.
21810
21811 @c This list is ordered alphanumerically by subsection name.
21812 @c It should be the same order and spelling as these options are listed
21813 @c in Machine Dependent Options
21814
21815 @menu
21816 * AArch64 Options::
21817 * Adapteva Epiphany Options::
21818 * AMD GCN Options::
21819 * ARC Options::
21820 * ARM Options::
21821 * AVR Options::
21822 * Blackfin Options::
21823 * C6X Options::
21824 * CRIS Options::
21825 * C-SKY Options::
21826 * Cygwin and MinGW Options::
21827 * Darwin Options::
21828 * DEC Alpha Options::
21829 * eBPF Options::
21830 * FR30 Options::
21831 * FT32 Options::
21832 * FRV Options::
21833 * GNU/Linux Options::
21834 * H8/300 Options::
21835 * HPPA Options::
21836 * IA-64 Options::
21837 * LM32 Options::
21838 * LoongArch Options::
21839 * M32C Options::
21840 * M32R/D Options::
21841 * M680x0 Options::
21842 * MCore Options::
21843 * MicroBlaze Options::
21844 * MIPS Options::
21845 * MMIX Options::
21846 * MN10300 Options::
21847 * Moxie Options::
21848 * MSP430 Options::
21849 * NDS32 Options::
21850 * Nvidia PTX Options::
21851 * OpenRISC Options::
21852 * PDP-11 Options::
21853 * PowerPC Options::
21854 * PRU Options::
21855 * RISC-V Options::
21856 * RL78 Options::
21857 * RS/6000 and PowerPC Options::
21858 * RX Options::
21859 * S/390 and zSeries Options::
21860 * SH Options::
21861 * Solaris 2 Options::
21862 * SPARC Options::
21863 * System V Options::
21864 * V850 Options::
21865 * VAX Options::
21866 * Visium Options::
21867 * VMS Options::
21868 * VxWorks Options::
21869 * x86 Options::
21870 * x86 Windows Options::
21871 * Xstormy16 Options::
21872 * Xtensa Options::
21873 * zSeries Options::
21874 @end menu
21875
21876 @node AArch64 Options
21877 @subsection AArch64 Options
21878 @cindex AArch64 Options
21879
21880 These options are defined for AArch64 implementations:
21881
21882 @table @gcctabopt
21883
21884 @opindex mabi
21885 @item -mabi=@var{name}
21886 Generate code for the specified data model. Permissible values
21887 are @samp{ilp32} for SysV-like data model where int, long int and pointers
21888 are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
21889 but long int and pointers are 64 bits.
21890
21891 The default depends on the specific target configuration. Note that
21892 the LP64 and ILP32 ABIs are not link-compatible; you must compile your
21893 entire program with the same ABI, and link with a compatible set of libraries.
21894
21895 The @samp{ilp32} model is deprecated.
21896
21897 @opindex mbig-endian
21898 @item -mbig-endian
21899 Generate big-endian code. This is the default when GCC is configured for an
21900 @samp{aarch64_be-*-*} target.
21901
21902 @opindex mgeneral-regs-only
21903 @item -mgeneral-regs-only
21904 Generate code which uses only the general-purpose registers. This will prevent
21905 the compiler from using floating-point and Advanced SIMD registers but will not
21906 impose any restrictions on the assembler.
21907
21908 @opindex mlittle-endian
21909 @item -mlittle-endian
21910 Generate little-endian code. This is the default when GCC is configured for an
21911 @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
21912
21913 @opindex mcmodel=
21914 @opindex mcmodel=tiny
21915 @item -mcmodel=tiny
21916 Generate code for the tiny code model. The program and its statically defined
21917 symbols must be within 1MB of each other. Programs can be statically or
21918 dynamically linked.
21919
21920 @opindex mcmodel=small
21921 @item -mcmodel=small
21922 Generate code for the small code model. The program and its statically defined
21923 symbols must be within 4GB of each other. Programs can be statically or
21924 dynamically linked. This is the default code model.
21925
21926 @opindex mcmodel=large
21927 @item -mcmodel=large
21928 Generate code for the large code model. This makes no assumptions about
21929 addresses and sizes of sections. Programs can be statically linked only. The
21930 @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
21931 @option{-fpic} and @option{-fPIC}.
21932
21933 @item -mtp=@var{name}
21934 @opindex mtp
21935 Specify the system register to use as a thread pointer. The valid values
21936 are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2},
21937 @samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0},
21938 @samp{el1}, @samp{el2}, @samp{el3} are also accepted.
21939 The default setting is @samp{tpidr_el0}. It is recommended to compile all
21940 code intended to interoperate with the same value of this option to avoid
21941 accessing a different thread pointer from the wrong exception level.
21942
21943 @opindex mstrict-align
21944 @opindex mno-strict-align
21945 @item -mstrict-align
21946 @itemx -mno-strict-align
21947 Avoid or allow generating memory accesses that may not be aligned on a natural
21948 object boundary as described in the architecture specification.
21949
21950 @opindex momit-leaf-frame-pointer
21951 @opindex mno-omit-leaf-frame-pointer
21952 @item -momit-leaf-frame-pointer
21953 @itemx -mno-omit-leaf-frame-pointer
21954 Omit or keep the frame pointer in leaf functions. The former behavior is the
21955 default.
21956
21957 @opindex mstack-protector-guard
21958 @opindex mstack-protector-guard-reg
21959 @opindex mstack-protector-guard-offset
21960 @item -mstack-protector-guard=@var{guard}
21961 @itemx -mstack-protector-guard-reg=@var{reg}
21962 @itemx -mstack-protector-guard-offset=@var{offset}
21963 Generate stack protection code using canary at @var{guard}. Supported
21964 locations are @samp{global} for a global canary or @samp{sysreg} for a
21965 canary in an appropriate system register.
21966
21967 With the latter choice the options
21968 @option{-mstack-protector-guard-reg=@var{reg}} and
21969 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
21970 which system register to use as base register for reading the canary,
21971 and from what offset from that base register. There is no default
21972 register or offset as this is entirely for use within the Linux
21973 kernel.
21974
21975 @opindex mtls-dialect=desc
21976 @item -mtls-dialect=desc
21977 Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
21978 of TLS variables. This is the default.
21979
21980 @opindex mtls-dialect=traditional
21981 @item -mtls-dialect=traditional
21982 Use traditional TLS as the thread-local storage mechanism for dynamic accesses
21983 of TLS variables.
21984
21985 @opindex mtls-size
21986 @item -mtls-size=@var{size}
21987 Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
21988 This option requires binutils 2.26 or newer.
21989
21990 @opindex mfix-cortex-a53-835769
21991 @opindex mno-fix-cortex-a53-835769
21992 @item -mfix-cortex-a53-835769
21993 @itemx -mno-fix-cortex-a53-835769
21994 Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
21995 This involves inserting a NOP instruction between memory instructions and
21996 64-bit integer multiply-accumulate instructions. This flag will be ignored if
21997 an architecture or cpu is specified on the command line which does not need the
21998 workaround.
21999
22000 @opindex mfix-cortex-a53-843419
22001 @opindex mno-fix-cortex-a53-843419
22002 @item -mfix-cortex-a53-843419
22003 @itemx -mno-fix-cortex-a53-843419
22004 Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
22005 This erratum workaround is made at link time and this will only pass the
22006 corresponding flag to the linker. This flag will be ignored if
22007 an architecture or cpu is specified on the command line which does not need the
22008 workaround.
22009
22010
22011 @opindex mlow-precision-recip-sqrt
22012 @opindex mno-low-precision-recip-sqrt
22013 @item -mlow-precision-recip-sqrt
22014 @itemx -mno-low-precision-recip-sqrt
22015 Enable or disable the reciprocal square root approximation.
22016 This option only has an effect if @option{-ffast-math} or
22017 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
22018 precision of reciprocal square root results to about 16 bits for
22019 single precision and to 32 bits for double precision.
22020
22021 @opindex mlow-precision-sqrt
22022 @opindex mno-low-precision-sqrt
22023 @item -mlow-precision-sqrt
22024 @itemx -mno-low-precision-sqrt
22025 Enable or disable the square root approximation.
22026 This option only has an effect if @option{-ffast-math} or
22027 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
22028 precision of square root results to about 16 bits for
22029 single precision and to 32 bits for double precision.
22030 If enabled, it implies @option{-mlow-precision-recip-sqrt}.
22031
22032 @opindex mlow-precision-div
22033 @opindex mno-low-precision-div
22034 @item -mlow-precision-div
22035 @itemx -mno-low-precision-div
22036 Enable or disable the division approximation.
22037 This option only has an effect if @option{-ffast-math} or
22038 @option{-funsafe-math-optimizations} is used as well. Enabling this reduces
22039 precision of division results to about 16 bits for
22040 single precision and to 32 bits for double precision.
22041
22042 @item -mtrack-speculation
22043 @itemx -mno-track-speculation
22044 Enable or disable generation of additional code to track speculative
22045 execution through conditional branches. The tracking state can then
22046 be used by the compiler when expanding calls to
22047 @code{__builtin_speculation_safe_copy} to permit a more efficient code
22048 sequence to be generated.
22049
22050 @item -moutline-atomics
22051 @itemx -mno-outline-atomics
22052 Enable or disable calls to out-of-line helpers to implement atomic operations.
22053 These helpers will, at runtime, determine if the LSE instructions from
22054 ARMv8.1-A can be used; if not, they will use the load/store-exclusive
22055 instructions that are present in the base ARMv8.0 ISA.
22056
22057 This option is only applicable when compiling for the base ARMv8.0
22058 instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
22059 or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
22060 used directly. The same applies when using @option{-mcpu=} when the
22061 selected cpu supports the @samp{lse} feature.
22062 This option is on by default.
22063
22064 @item -mmax-vectorization
22065 @itemx -mno-max-vectorization
22066 Enable or disable an override to vectorizer cost model making vectorization
22067 always appear profitable. This option can be combined with
22068 @option{-mautovec-preference} allowing precise control over which ISA will be
22069 used for auto-vectorization. Unlike @option{-fno-vect-cost-model} or
22070 @option{-fvect-cost-model=unlimited} this option does not turn off cost
22071 comparison between different vector modes.
22072
22073 @item -mautovec-preference=@var{name}
22074 Force an ISA selection strategy for auto-vectorization. The possible
22075 values of @var{name} are:
22076 @table @samp
22077 @item default
22078 Use the default heuristics.
22079 @item asimd-only
22080 Use only Advanced SIMD for auto-vectorization.
22081 @item sve-only
22082 Use only SVE for auto-vectorization.
22083 @item prefer-asimd
22084 Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
22085 deemed equal.
22086 @item prefer-sve
22087 Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
22088 @end table
22089
22090 For best performance it is highly recommended to use @option{-mcpu} or
22091 @option{-mtune} instead. This parameter should only be used for code
22092 exploration.
22093
22094 @opindex march
22095 @item -march=@var{name}
22096 Specify the name of the target architecture and, optionally, one or
22097 more feature modifiers. This option has the form
22098 @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
22099
22100 The table below summarizes the permissible values for @var{arch}
22101 and the features that they enable by default:
22102
22103 @multitable @columnfractions 0.20 0.20 0.60
22104 @headitem @var{arch} value @tab Architecture @tab Includes by default
22105 @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
22106 @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
22107 @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
22108 @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}, @samp{+fcma}, @samp{+jscvt}
22109 @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}, @samp{+rcpc2}
22110 @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}, @samp{+frintts}, @samp{+flagm2}
22111 @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
22112 @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+wfxt}, @samp{+xs}
22113 @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
22114 @item @samp{armv8.9-a} @tab Armv8.9-a @tab @samp{armv8.8-a}
22115 @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
22116 @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
22117 @item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+wfxt}, @samp{+xs}
22118 @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
22119 @item @samp{armv9.4-a} @tab Armv9.4-A @tab @samp{armv9.3-a}, @samp{+sve2p1}
22120 @item @samp{armv9.5-a} @tab Armv9.4-A @tab @samp{armv9.4-a}, @samp{cpa}, @samp{+faminmax}, @samp{+lut}
22121 @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
22122 @end multitable
22123
22124 The value @samp{native} is available on native AArch64 GNU/Linux and
22125 causes the compiler to pick the architecture of the host system. This
22126 option has no effect if the compiler is unable to recognize the
22127 architecture of the host system. When @option{-march=native} is given and
22128 no other @option{-mcpu} or @option{-mtune} is given then GCC will pick
22129 the host CPU as the CPU to tune for as well as select the architecture features
22130 from. That is, @option{-march=native} is treated as @option{-mcpu=native}.
22131
22132 The permissible values for @var{feature} are listed in the sub-section
22133 on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
22134 Feature Modifiers}. Where conflicting feature modifiers are
22135 specified, the right-most feature is used.
22136
22137 GCC uses @var{name} to determine what kind of instructions it can emit
22138 when generating assembly code. If @option{-march} is specified
22139 without either of @option{-mtune} or @option{-mcpu} also being
22140 specified, the code is tuned to perform well across a range of target
22141 processors implementing the target architecture.
22142
22143 @opindex mtune
22144 @item -mtune=@var{name}
22145 Specify the name of the target processor for which GCC should tune the
22146 performance of the code. Permissible values for this option are:
22147 @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22148 @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22149 @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22150 @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
22151 @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
22152 @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
22153 @samp{oryon-1},
22154 @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
22155 @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{grace},
22156 @samp{neoverse-v3}, @samp{neoverse-v3ae}, @samp{neoverse-n3}, @samp{olympus},
22157 @samp{cortex-a725}, @samp{cortex-x925},
22158 @samp{qdf24xx}, @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
22159 @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
22160 @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
22161 @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
22162 @samp{octeontx2f95mm},
22163 @samp{a64fx}, @samp{fujitsu-monaka},
22164 @samp{thunderx}, @samp{thunderxt88},
22165 @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
22166 @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
22167 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22168 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
22169 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
22170 @samp{cortex-r82}, @samp{cortex-r82ae}, @samp{cortex-x1}, @samp{cortex-x1c},
22171 @samp{cortex-x2}, @samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510},
22172 @samp{cortex-a520}, @samp{cortex-a520ae}, @samp{cortex-a710}, @samp{cortex-a715},
22173 @samp{cortex-a720}, @samp{cortex-a720ae}, @samp{ampere1}, @samp{ampere1a},
22174 @samp{ampere1b}, @samp{cobalt-100}, @samp{apple-m1}, @samp{apple-m2},
22175 @samp{apple-m3} and @samp{native}.
22176
22177 The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22178 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
22179 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
22180 @samp{apple-m1}, @samp{apple-m2}, @samp{apple-m3}, @samp{gb10} specify that GCC
22181 should tune for a big.LITTLE system.
22182
22183 The value @samp{neoverse-512tvb} specifies that GCC should tune
22184 for Neoverse cores that (a) implement SVE and (b) have a total vector
22185 bandwidth of 512 bits per cycle. In other words, the option tells GCC to
22186 tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
22187 instructions a cycle and that can execute an equivalent number of SVE
22188 arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
22189 This is more general than tuning for a specific core like Neoverse V1
22190 but is more specific than the default tuning described below.
22191
22192 Additionally on native AArch64 GNU/Linux systems the value
22193 @samp{native} tunes performance to the host system. This option has no effect
22194 if the compiler is unable to recognize the processor of the host system.
22195
22196 Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
22197 are specified, the code is tuned to perform well across a range
22198 of target processors.
22199
22200 This option cannot be suffixed by feature modifiers.
22201
22202 @opindex mcpu
22203 @item -mcpu=@var{name}
22204 Specify the name of the target processor, optionally suffixed by one
22205 or more feature modifiers. This option has the form
22206 @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
22207 the permissible values for @var{cpu} are the same as those available
22208 for @option{-mtune}. The permissible values for @var{feature} are
22209 documented in the sub-section on
22210 @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
22211 Feature Modifiers}. Where conflicting feature modifiers are
22212 specified, the right-most feature is used.
22213
22214 GCC uses @var{name} to determine what kind of instructions it can emit when
22215 generating assembly code (as if by @option{-march}) and to determine
22216 the target processor for which to tune for performance (as if
22217 by @option{-mtune}). Where this option is used in conjunction
22218 with @option{-march} or @option{-mtune}, those options take precedence
22219 over the appropriate part of this option.
22220
22221 @option{-mcpu=neoverse-512tvb} is special in that it does not refer
22222 to a specific core, but instead refers to all Neoverse cores that
22223 (a) implement SVE and (b) have a total vector bandwidth of 512 bits
22224 a cycle. Unless overridden by @option{-march},
22225 @option{-mcpu=neoverse-512tvb} generates code that can run on a
22226 Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
22227 these properties. Unless overridden by @option{-mtune},
22228 @option{-mcpu=neoverse-512tvb} tunes code in the same way as for
22229 @option{-mtune=neoverse-512tvb}.
22230
22231 @opindex moverride
22232 @item -moverride=@var{string}
22233 Override tuning decisions made by the back-end in response to a
22234 @option{-mtune=} switch. The syntax, semantics, and accepted values
22235 for @var{string} in this option are not guaranteed to be consistent
22236 across releases.
22237
22238 This option is only intended to be useful when developing GCC.
22239
22240 @opindex mverbose-cost-dump
22241 @item -mverbose-cost-dump
22242 Enable verbose cost model dumping in the debug dump files. This option is
22243 provided for use in debugging the compiler.
22244
22245 @opindex mpc-relative-literal-loads
22246 @opindex mno-pc-relative-literal-loads
22247 @item -mpc-relative-literal-loads
22248 @itemx -mno-pc-relative-literal-loads
22249 Enable or disable PC-relative literal loads. With this option literal pools are
22250 accessed using a single instruction and emitted after each function. This
22251 limits the maximum size of functions to 1MB. This is enabled by default for
22252 @option{-mcmodel=tiny}.
22253
22254 @opindex msign-return-address
22255 @item -msign-return-address=@var{scope}
22256 Select the function scope on which return address signing will be applied.
22257 Permissible values are @samp{none}, which disables return address signing,
22258 @samp{non-leaf}, which enables pointer signing for functions which are not leaf
22259 functions, and @samp{all}, which enables pointer signing for all functions. The
22260 default value is @samp{none}. This option has been deprecated by
22261 -mbranch-protection.
22262
22263 @opindex mbranch-protection
22264 @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}|@var{gcs}
22265 Select the branch protection features to use.
22266 @samp{none} is the default and turns off all types of branch protection.
22267 @samp{standard} turns on all types of branch protection features. If a feature
22268 has additional tuning options, then @samp{standard} sets it to its standard
22269 level.
22270 @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
22271 level: signing functions that save the return address to memory (non-leaf
22272 functions will practically always do this) using the a-key. The optional
22273 argument @samp{leaf} can be used to extend the signing to include leaf
22274 functions. The optional argument @samp{b-key} can be used to sign the functions
22275 with the B-key instead of the A-key.
22276 @samp{bti} turns on branch target identification mechanism.
22277 @samp{gcs} turns on guarded control stack compatible code generation.
22278
22279 @opindex mharden-sls
22280 @item -mharden-sls=@var{opts}
22281 Enable compiler hardening against straight line speculation (SLS).
22282 @var{opts} is a comma-separated list of the following options:
22283 @table @samp
22284 @item retbr
22285 @item blr
22286 @end table
22287 In addition, @samp{-mharden-sls=all} enables all SLS hardening while
22288 @samp{-mharden-sls=none} disables all SLS hardening.
22289
22290 @opindex mearly-ra
22291 @item -mearly-ra=@var{scope}
22292 Determine when to enable an early register allocation pass. This pass runs
22293 before instruction scheduling and tries to find a spill-free allocation of
22294 floating-point and vector code. It also tries to make use of strided
22295 multi-register instructions, such as SME2's strided LD1 and ST1.
22296
22297 The possible values of @var{scope} are: @var{all}, which runs the pass on
22298 all functions; @var{strided}, which runs the pass on functions that have
22299 access to strided multi-register instructions; and @var{none}, which
22300 disables the pass.
22301
22302 @option{-mearly-ra=all} is the default for @option{-O2} and above, and for
22303 @option{-Os}. @option{-mearly-ra=none} is the default otherwise.
22304
22305 @opindex mearly-ldp-fusion
22306 @item -mearly-ldp-fusion
22307 Enable the copy of the AArch64 load/store pair fusion pass that runs before
22308 register allocation. Enabled by default at @samp{-O} and above.
22309
22310 @opindex mlate-ldp-fusion
22311 @item -mlate-ldp-fusion
22312 Enable the copy of the AArch64 load/store pair fusion pass that runs after
22313 register allocation. Enabled by default at @samp{-O} and above.
22314
22315 @opindex msve-vector-bits
22316 @item -msve-vector-bits=@var{bits}
22317 Specify the number of bits in an SVE vector register. This option only has
22318 an effect when SVE is enabled.
22319
22320 GCC supports two forms of SVE code generation: ``vector-length
22321 agnostic'' output that works with any size of vector register and
22322 ``vector-length specific'' output that allows GCC to make assumptions
22323 about the vector length when it is useful for optimization reasons.
22324 The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
22325 @samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
22326 Specifying @samp{scalable} selects vector-length agnostic
22327 output. At present @samp{-msve-vector-bits=128} also generates vector-length
22328 agnostic output for big-endian targets. All other values generate
22329 vector-length specific code. The behavior of these values may change
22330 in future releases and no value except @samp{scalable} should be
22331 relied on for producing code that is portable across different
22332 hardware SVE vector lengths.
22333
22334 The default is @samp{-msve-vector-bits=scalable}, which produces
22335 vector-length agnostic code.
22336
22337 @opindex Wexperimental-fmv-target
22338 @opindex Wno-experimental-fmv-target
22339 @item -Wexperimental-fmv-target
22340 Warn about use of experimental Function Multi Versioning.
22341 The Arm C Language Extension specification for Function Multi Versioning
22342 is beta and subject to change. Any usage of FMV is caveated that future
22343 behavior change and incompatibility is likely.
22344 @end table
22345
22346 @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
22347 @anchor{aarch64-feature-modifiers}
22348 @cindex @option{-march} feature modifiers
22349 @cindex @option{-mcpu} feature modifiers
22350 Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
22351 the following and their inverses @option{no@var{feature}}:
22352
22353 @table @samp
22354 @item crc
22355 Enable CRC extension. This is on by default for
22356 @option{-march=armv8.1-a}.
22357 @item crypto
22358 Enable Crypto extension. This also enables Advanced SIMD and floating-point
22359 instructions.
22360 @item fp
22361 Enable floating-point instructions. This is on by default for all possible
22362 values for options @option{-march} and @option{-mcpu}.
22363 @item simd
22364 Enable Advanced SIMD instructions. This also enables floating-point
22365 instructions. This is on by default for all possible values for options
22366 @option{-march} and @option{-mcpu}.
22367 @item sve
22368 Enable Scalable Vector Extension instructions. This also enables Advanced
22369 SIMD and floating-point instructions.
22370 @item lse
22371 Enable Large System Extension instructions. This is on by default for
22372 @option{-march=armv8.1-a}.
22373 @item rdma
22374 Enable Round Double Multiply Accumulate instructions. This is on by default
22375 for @option{-march=armv8.1-a}.
22376 @item fp16
22377 Enable FP16 extension. This also enables floating-point instructions.
22378 @item fp16fml
22379 Enable FP16 fmla extension. This also enables FP16 extensions and
22380 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.
22381
22382 @item rcpc
22383 Enable the RCpc extension. This enables the use of the LDAPR instructions for
22384 load-acquire atomic semantics, and passes it on to the assembler, enabling
22385 inline asm statements to use instructions from the RCpc extension.
22386 @item dotprod
22387 Enable the Dot Product extension. This also enables Advanced SIMD instructions.
22388 @item aes
22389 Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
22390 SIMD instructions.
22391 @item sha2
22392 Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
22393 @item sha3
22394 Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
22395 instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
22396 @item sm4
22397 Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
22398 Use of this option with architectures prior to Armv8.2-A is not supported.
22399 @item profile
22400 Enable the Statistical Profiling extension. This option is only to enable the
22401 extension at the assembler level and does not affect code generation.
22402 @item rng
22403 Enable the Armv8.5-a Random Number instructions. This option is only to
22404 enable the extension at the assembler level and does not affect code
22405 generation.
22406 @item memtag
22407 Enable the Armv8.5-a Memory Tagging Extensions.
22408 Use of this option with architectures prior to Armv8.5-A is not supported.
22409 @item sb
22410 Enable the Armv8-a Speculation Barrier instruction. This option is only to
22411 enable the extension at the assembler level and does not affect code
22412 generation. This option is enabled by default for @option{-march=armv8.5-a}.
22413 @item ssbs
22414 Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
22415 is only to enable the extension at the assembler level and does not affect code
22416 generation. This option is enabled by default for @option{-march=armv8.5-a}.
22417 @item predres
22418 Enable the Armv8-a Execution and Data Prediction Restriction instructions.
22419 This option is only to enable the extension at the assembler level and does
22420 not affect code generation. This option is enabled by default for
22421 @option{-march=armv8.5-a}.
22422 @item sve2
22423 Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
22424 instructions.
22425 @item sve2-bitperm
22426 Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
22427 @item sve2-sm4
22428 Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
22429 @item sve2-aes
22430 Enable SVE2 aes instructions. This also enables SVE2 instructions.
22431 @item sve2-sha3
22432 Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
22433 @item sve2p1
22434 Enable SVE2.1 instructions. This also enables SVE2 instructions.
22435 @item tme
22436 Enable the Transactional Memory Extension.
22437 @item i8mm
22438 Enable 8-bit Integer Matrix Multiply instructions. This also enables
22439 Advanced SIMD and floating-point instructions. This option is enabled by
22440 default for @option{-march=armv8.6-a}. Use of this option with architectures
22441 prior to Armv8.2-A is not supported.
22442 @item f32mm
22443 Enable 32-bit Floating point Matrix Multiply instructions. This also enables
22444 SVE instructions. Use of this option with architectures prior to Armv8.2-A is
22445 not supported.
22446 @item f64mm
22447 Enable 64-bit Floating point Matrix Multiply instructions. This also enables
22448 SVE instructions. Use of this option with architectures prior to Armv8.2-A is
22449 not supported.
22450 @item bf16
22451 Enable brain half-precision floating-point instructions. This also enables
22452 Advanced SIMD and floating-point instructions. This option is enabled by
22453 default for @option{-march=armv8.6-a}. Use of this option with architectures
22454 prior to Armv8.2-A is not supported.
22455 @item ls64
22456 Enable the 64-byte atomic load and store instructions for accelerators.
22457 @item mops
22458 Enable the instructions to accelerate memory operations like @code{memcpy},
22459 @code{memmove}, @code{memset}. This option is enabled by default for
22460 @option{-march=armv8.8-a}
22461 @item flagm
22462 Enable the Flag Manipulation instructions Extension.
22463 @item flagm2
22464 Enable the FlagM2 flag conversion instructions.
22465 @item pauth
22466 Enable the Pointer Authentication Extension.
22467 @item cssc
22468 Enable the Common Short Sequence Compression instructions.
22469 @item cmpbr
22470 Enable the shorter compare and branch instructions, @code{cbb}, @code{cbh} and
22471 @code{cb}.
22472 @item sme
22473 Enable the Scalable Matrix Extension. This is only supported when SVE2 is also
22474 enabled.
22475 @item sme-i16i64
22476 Enable the FEAT_SME_I16I64 extension to SME. This also enables SME
22477 instructions.
22478 @item sme-f64f64
22479 Enable the FEAT_SME_F64F64 extension to SME. This also enables SME
22480 instructions.
22481 @item sme2
22482 Enable the Scalable Matrix Extension 2. This also enables SME instructions.
22483 @item sme-b16b16
22484 Enable the FEAT_SME_B16B16 extension to SME. This also enables SME2
22485 and SVE_B16B16 instructions.
22486 @item sme-f16f16
22487 Enable the FEAT_SME_F16F16 extension to SME. This also enables SME2
22488 instructions.
22489 @item sme2p1
22490 Enable the Scalable Matrix Extension version 2.1. This also enables SME2
22491 instructions.
22492 @item fcma
22493 Enable the complex number SIMD extensions.
22494 @item jscvt
22495 Enable the @code{fjcvtzs} JavaScript conversion instruction.
22496 @item frintts
22497 Enable floating-point round to integral value instructions.
22498 @item wfxt
22499 Enable @code{wfet} and @code{wfit} instructions.
22500 @item xs
22501 Enable the XS memory attribute extension.
22502 @item lse128
22503 Enable the LSE128 128-bit atomic instructions extension. This also
22504 enables LSE instructions.
22505 @item d128
22506 Enable support for 128-bit system register read/write instructions.
22507 This also enables the LSE128 extension.
22508 @item gcs
22509 Enable support for Armv9.4-a Guarded Control Stack extension.
22510 @item the
22511 Enable support for Armv8.9-a/9.4-a translation hardening extension.
22512 @item rcpc2
22513 Enable the RCpc2 extension.
22514 @item rcpc3
22515 Enable the RCpc3 (Release Consistency) extension.
22516 @item fp8
22517 Enable the fp8 (8-bit floating point) extension.
22518 @item fp8fma
22519 Enable the fp8 (8-bit floating point) multiply accumulate extension.
22520 @item ssve-fp8fma
22521 Enable the fp8 (8-bit floating point) multiply accumulate extension in streaming
22522 mode.
22523 @item fp8dot4
22524 Enable the fp8 (8-bit floating point) to single-precision 4-way dot product
22525 extension.
22526 @item ssve-fp8dot4
22527 Enable the fp8 (8-bit floating point) to single-precision 4-way dot product
22528 extension in streaming mode.
22529 @item fp8dot2
22530 Enable the fp8 (8-bit floating point) to half-precision 2-way dot product
22531 extension.
22532 @item ssve-fp8dot2
22533 Enable the fp8 (8-bit floating point) to half-precision 2-way dot product
22534 extension in streaming mode.
22535 @item faminmax
22536 Enable the Floating Point Absolute Maximum/Minimum extension.
22537 @item lut
22538 Enable the Lookup Table extension.
22539 @item cpa
22540 Enable the Checked Pointer Arithmetic instructions.
22541 @item sve-b16b16
22542 Enable the SVE non-widening brain floating-point (@code{bf16}) extension.
22543 This only has an effect when @code{sve2} or @code{sme2} are also enabled.
22544
22545 @end table
22546
22547 Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
22548 which implies @option{fp}.
22549 Conversely, @option{nofp} implies @option{nosimd}, which implies
22550 @option{nocrypto}, @option{noaes} and @option{nosha2}.
22551
22552 @node Adapteva Epiphany Options
22553 @subsection Adapteva Epiphany Options
22554
22555 These @samp{-m} options are defined for Adapteva Epiphany:
22556
22557 @table @gcctabopt
22558 @opindex mhalf-reg-file
22559 @item -mhalf-reg-file
22560 Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
22561 That allows code to run on hardware variants that lack these registers.
22562
22563 @opindex mprefer-short-insn-regs
22564 @item -mprefer-short-insn-regs
22565 Preferentially allocate registers that allow short instruction generation.
22566 This can result in increased instruction count, so this may either reduce or
22567 increase overall code size.
22568
22569 @opindex mbranch-cost
22570 @item -mbranch-cost=@var{num}
22571 Set the cost of branches to roughly @var{num} ``simple'' instructions.
22572 This cost is only a heuristic and is not guaranteed to produce
22573 consistent results across releases.
22574
22575 @opindex mcmove
22576 @item -mcmove
22577 Enable the generation of conditional moves.
22578
22579 @opindex mnops
22580 @item -mnops=@var{num}
22581 Emit @var{num} NOPs before every other generated instruction.
22582
22583 @opindex mno-soft-cmpsf
22584 @opindex msoft-cmpsf
22585 @item -mno-soft-cmpsf
22586 For single-precision floating-point comparisons, emit an @code{fsub} instruction
22587 and test the flags. This is faster than a software comparison, but can
22588 get incorrect results in the presence of NaNs, or when two different small
22589 numbers are compared such that their difference is calculated as zero.
22590 The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
22591 software comparisons.
22592
22593 @opindex mstack-offset
22594 @item -mstack-offset=@var{num}
22595 Set the offset between the top of the stack and the stack pointer.
22596 E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
22597 can be used by leaf functions without stack allocation.
22598 Values other than @samp{8} or @samp{16} are untested and unlikely to work.
22599 Note also that this option changes the ABI; compiling a program with a
22600 different stack offset than the libraries have been compiled with
22601 generally does not work.
22602 This option can be useful if you want to evaluate if a different stack
22603 offset would give you better code, but to actually use a different stack
22604 offset to build working programs, it is recommended to configure the
22605 toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
22606
22607 @opindex mno-round-nearest
22608 @opindex mround-nearest
22609 @item -mno-round-nearest
22610 Make the scheduler assume that the rounding mode has been set to
22611 truncating. The default is @option{-mround-nearest}.
22612
22613 @opindex mlong-calls
22614 @item -mlong-calls
22615 If not otherwise specified by an attribute, assume all calls might be beyond
22616 the offset range of the @code{b} / @code{bl} instructions, and therefore load the
22617 function address into a register before performing a (otherwise direct) call.
22618 This is the default.
22619
22620 @opindex short-calls
22621 @item -mshort-calls
22622 If not otherwise specified by an attribute, assume all direct calls are
22623 in the range of the @code{b} / @code{bl} instructions, so use these instructions
22624 for direct calls. The default is @option{-mlong-calls}.
22625
22626 @opindex msmall16
22627 @item -msmall16
22628 Assume addresses can be loaded as 16-bit unsigned values. This does not
22629 apply to function addresses for which @option{-mlong-calls} semantics
22630 are in effect.
22631
22632 @opindex mfp-mode
22633 @item -mfp-mode=@var{mode}
22634 Set the prevailing mode of the floating-point unit.
22635 This determines the floating-point mode that is provided and expected
22636 at function call and return time. Making this mode match the mode you
22637 predominantly need at function start can make your programs smaller and
22638 faster by avoiding unnecessary mode switches.
22639
22640 @var{mode} can be set to one the following values:
22641
22642 @table @samp
22643 @item caller
22644 Any mode at function entry is valid, and retained or restored when
22645 the function returns, and when it calls other functions.
22646 This mode is useful for compiling libraries or other compilation units
22647 you might want to incorporate into different programs with different
22648 prevailing FPU modes, and the convenience of being able to use a single
22649 object file outweighs the size and speed overhead for any extra
22650 mode switching that might be needed, compared with what would be needed
22651 with a more specific choice of prevailing FPU mode.
22652
22653 @item truncate
22654 This is the mode used for floating-point calculations with
22655 truncating (i.e.@: round towards zero) rounding mode. That includes
22656 conversion from floating point to integer.
22657
22658 @item round-nearest
22659 This is the mode used for floating-point calculations with
22660 round-to-nearest-or-even rounding mode.
22661
22662 @item int
22663 This is the mode used to perform integer calculations in the FPU, e.g.@:
22664 integer multiply, or integer multiply-and-accumulate.
22665 @end table
22666
22667 The default is @option{-mfp-mode=caller}
22668
22669 @opindex mno-split-lohi
22670 @opindex msplit-lohi
22671 @opindex mno-postinc
22672 @opindex mpostinc
22673 @opindex mno-postmodify
22674 @opindex mpostmodify
22675 @item -mno-split-lohi
22676 @itemx -mno-postinc
22677 @itemx -mno-postmodify
22678 Code generation tweaks that disable, respectively, splitting of 32-bit
22679 loads, generation of post-increment addresses, and generation of
22680 post-modify addresses. The defaults are @option{msplit-lohi},
22681 @option{-mpost-inc}, and @option{-mpost-modify}.
22682
22683 @opindex mno-vect-double
22684 @opindex mvect-double
22685 @item -mnovect-double
22686 Change the preferred SIMD mode to SImode. The default is
22687 @option{-mvect-double}, which uses DImode as preferred SIMD mode.
22688
22689 @opindex max-vect-align
22690 @item -max-vect-align=@var{num}
22691 The maximum alignment for SIMD vector mode types.
22692 @var{num} may be 4 or 8. The default is 8.
22693 Note that this is an ABI change, even though many library function
22694 interfaces are unaffected if they don't use SIMD vector modes
22695 in places that affect size and/or alignment of relevant types.
22696
22697 @opindex msplit-vecmove-early
22698 @item -msplit-vecmove-early
22699 Split vector moves into single word moves before reload. In theory this
22700 can give better register allocation, but so far the reverse seems to be
22701 generally the case.
22702
22703 @opindex m1reg-
22704 @item -m1reg-@var{reg}
22705 Specify a register to hold the constant @minus{}1, which makes loading small negative
22706 constants and certain bitmasks faster.
22707 Allowable values for @var{reg} are @samp{r43} and @samp{r63},
22708 which specify use of that register as a fixed register,
22709 and @samp{none}, which means that no register is used for this
22710 purpose. The default is @option{-m1reg-none}.
22711
22712 @end table
22713
22714 @node AMD GCN Options
22715 @subsection AMD GCN Options
22716 @cindex AMD GCN Options
22717
22718 These options are defined specifically for the AMD GCN port.
22719
22720 @table @gcctabopt
22721
22722 @opindex march
22723 @opindex mtune
22724 @item -march=@var{gpu}
22725 @itemx -mtune=@var{gpu}
22726 Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
22727 are
22728
22729 @table @samp
22730 @item gfx900
22731 Compile for GCN5 Vega 10 devices (gfx900).
22732
22733 @item gfx902
22734 Compile for GCN5 Vega gfx902 devices. (Experimental)
22735
22736 @item gfx904
22737 Compile for GCN5 Vega gfx904 devices. (Experimental)
22738
22739 @item gfx906
22740 Compile for GCN5 Vega 20 devices (gfx906).
22741
22742 @item gfx908
22743 Compile for CDNA1 Instinct MI100 series devices (gfx908).
22744
22745 @item gfx909
22746 Compile for GCN5 Vega gfx909 devices. (Experimental)
22747
22748 @item gfx90a
22749 Compile for CDNA2 Instinct MI200 series devices (gfx90a).
22750
22751 @item gfx90c
22752 Compile for GCN5 Vega 7 devices (gfx90c).
22753
22754 @item gfx942
22755 Compile for CDNA3 Instinct MI300 series devices (gfx942). (Experimental)
22756
22757 @item gfx950
22758 Compile for the CDNA3 gfx950 devices. (Experimental)
22759
22760 @item gfx9-generic
22761 Compile generic code for Vega devices, executable on the following subset of
22762 GFX9 devices: gfx900, gfx902, gfx904, gfx906, gfx909 and gfx90c. (Experimental)
22763
22764 @item gfx9-4-generic
22765 Compile generic code for CDNA3 devices, executable on the following subset of
22766 GFX9 devices: gfx942 and gfx950. (Experimental)
22767
22768 @item gfx1030
22769 Compile for RDNA2 gfx1030 devices (GFX10 series).
22770
22771 @item gfx1031
22772 Compile for RDNA2 gfx1031 devices (GFX10 series). (Experimental)
22773
22774 @item gfx1032
22775 Compile for RDNA2 gfx1032 devices (GFX10 series). (Experimental)
22776
22777 @item gfx1033
22778 Compile for RDNA2 gfx1033 devices (GFX10 series). (Experimental)
22779
22780 @item gfx1034
22781 Compile for RDNA2 gfx1034 devices (GFX10 series). (Experimental)
22782
22783 @item gfx1035
22784 Compile for RDNA2 gfx1035 devices (GFX10 series). (Experimental)
22785
22786 @item gfx1036
22787 Compile for RDNA2 gfx1036 devices (GFX10 series).
22788
22789 @item gfx10-3-generic
22790 Compile generic code for GFX10-3 devices, executable on gfx1030,
22791 gfx1031, gfx1032, gfx1033, gfx1034, gfx1035, and gfx1036. (Experimental)
22792
22793 @item gfx1100
22794 Compile for RDNA3 gfx1100 devices (GFX11 series).
22795
22796 @item gfx1101
22797 Compile for RDNA3 gfx1101 devices (GFX11 series). (Experimental)
22798
22799 @item gfx1102
22800 Compile for RDNA3 gfx1102 devices (GFX11 series). (Experimental)
22801
22802 @item gfx1103
22803 Compile for RDNA3 gfx1103 devices (GFX11 series).
22804
22805 @item gfx1150
22806 Compile for RDNA3 gfx1150 devices (GFX11 series). (Experimental)
22807
22808 @item gfx1151
22809 Compile for RDNA3 gfx1151 devices (GFX11 series). (Experimental)
22810
22811 @item gfx1152
22812 Compile for RDNA3 gfx1152 devices (GFX11 series). (Experimental)
22813
22814 @item gfx1153
22815 Compile for RDNA3 gfx1153 devices (GFX11 series). (Experimental)
22816
22817 @item gfx11-generic
22818 Compile generic code for GFX11 devices, executable on gfx1100, gfx1101,
22819 gfx1102, gfx1103, gfx1150, gfx1151, gfx1152, and gfx1153. (Experimental)
22820 @end table
22821
22822 @opindex msram-ecc
22823 @item -msram-ecc=on
22824 @itemx -msram-ecc=off
22825 @itemx -msram-ecc=any
22826 Compile binaries suitable for devices with the SRAM-ECC feature enabled,
22827 disabled, or either mode. This feature can be enabled per-process on some
22828 devices. The compiled code must match the device mode. The default is
22829 @samp{any}, for devices that support it.
22830
22831 @opindex mstack-size
22832 @item -mstack-size=@var{bytes}
22833 Specify how many @var{bytes} of stack space will be requested for each GPU
22834 thread (wave-front). Beware that there may be many threads and limited memory
22835 available. The size of the stack allocation may also have an impact on
22836 run-time performance. The default is 32KB when using OpenACC or OpenMP, and
22837 1MB otherwise.
22838
22839 @opindex mxnack
22840 @item -mxnack=on
22841 @itemx -mxnack=off
22842 @itemx -mxnack=any
22843 Compile binaries suitable for devices with the XNACK feature enabled, disabled,
22844 or either mode. Some devices always require XNACK and some allow the user to
22845 configure XNACK. The compiled code must match the device mode.
22846 The default is @samp{-mxnack=any} on devices that support Unified Shared
22847 Memory, and @samp{-mxnack=no} otherwise.
22848
22849 @end table
22850
22851 @node ARC Options
22852 @subsection ARC Options
22853 @cindex ARC options
22854
22855 The following options control the architecture variant for which code
22856 is being compiled:
22857
22858 @c architecture variants
22859 @table @gcctabopt
22860
22861 @opindex mbarrel-shifter
22862 @item -mbarrel-shifter
22863 Generate instructions supported by barrel shifter. This is the default
22864 unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
22865
22866 @opindex mjli-always
22867 @item -mjli-always
22868 Force to call a function using jli_s instruction. This option is
22869 valid only for ARCv2 architecture.
22870
22871 @opindex mcpu
22872 @item -mcpu=@var{cpu}
22873 Set architecture type, register usage, and instruction scheduling
22874 parameters for @var{cpu}. There are also shortcut alias options
22875 available for backward compatibility and convenience. Supported
22876 values for @var{cpu} are
22877
22878 @table @samp
22879 @opindex mA6
22880 @opindex mARC600
22881 @item arc600
22882 Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
22883
22884 @opindex mARC601
22885 @item arc601
22886 Compile for ARC601. Alias: @option{-mARC601}.
22887
22888 @opindex mA7
22889 @opindex mARC700
22890 @item arc700
22891 Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
22892 This is the default when configured with @option{--with-cpu=arc700}@.
22893
22894 @item arcem
22895 Compile for ARC EM.
22896
22897 @item archs
22898 Compile for ARC HS.
22899
22900 @item em
22901 Compile for ARC EM CPU with no hardware extensions.
22902
22903 @item em4
22904 Compile for ARC EM4 CPU.
22905
22906 @item em4_dmips
22907 Compile for ARC EM4 DMIPS CPU.
22908
22909 @item em4_fpus
22910 Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
22911 extension.
22912
22913 @item em4_fpuda
22914 Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
22915 double assist instructions.
22916
22917 @item hs
22918 Compile for ARC HS CPU with no hardware extensions except the atomic
22919 instructions.
22920
22921 @item hs34
22922 Compile for ARC HS34 CPU.
22923
22924 @item hs38
22925 Compile for ARC HS38 CPU.
22926
22927 @item hs38_linux
22928 Compile for ARC HS38 CPU with all hardware extensions on.
22929
22930 @item hs4x
22931 Compile for ARC HS4x CPU.
22932
22933 @item hs4xd
22934 Compile for ARC HS4xD CPU.
22935
22936 @item hs4x_rel31
22937 Compile for ARC HS4x CPU release 3.10a.
22938
22939 @item arc600_norm
22940 Compile for ARC 600 CPU with @code{norm} instructions enabled.
22941
22942 @item arc600_mul32x16
22943 Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
22944 instructions enabled.
22945
22946 @item arc600_mul64
22947 Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
22948 instructions enabled.
22949
22950 @item arc601_norm
22951 Compile for ARC 601 CPU with @code{norm} instructions enabled.
22952
22953 @item arc601_mul32x16
22954 Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
22955 instructions enabled.
22956
22957 @item arc601_mul64
22958 Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
22959 instructions enabled.
22960
22961 @item nps400
22962 Compile for ARC 700 on NPS400 chip.
22963
22964 @item em_mini
22965 Compile for ARC EM minimalist configuration featuring reduced register
22966 set.
22967
22968 @end table
22969
22970 @opindex mdpfp
22971 @opindex mdpfp-compact
22972 @item -mdpfp
22973 @itemx -mdpfp-compact
22974 Generate double-precision FPX instructions, tuned for the compact
22975 implementation.
22976
22977 @opindex mdpfp-fast
22978 @item -mdpfp-fast
22979 Generate double-precision FPX instructions, tuned for the fast
22980 implementation.
22981
22982 @opindex mno-dpfp-lrsr
22983 @item -mno-dpfp-lrsr
22984 Disable @code{lr} and @code{sr} instructions from using FPX extension
22985 aux registers.
22986
22987 @opindex mea
22988 @item -mea
22989 Generate extended arithmetic instructions. Currently only
22990 @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
22991 supported. Only valid for @option{-mcpu=ARC700}.
22992
22993 @opindex mno-mpy
22994 @opindex mmpy
22995 @item -mno-mpy
22996 Do not generate @code{mpy}-family instructions for ARC700. This option is
22997 deprecated.
22998
22999 @opindex mmul32x16
23000 @item -mmul32x16
23001 Generate 32x16-bit multiply and multiply-accumulate instructions.
23002
23003 @opindex mmul64
23004 @item -mmul64
23005 Generate @code{mul64} and @code{mulu64} instructions.
23006 Only valid for @option{-mcpu=ARC600}.
23007
23008 @opindex mnorm
23009 @item -mnorm
23010 Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
23011 is in effect.
23012
23013 @opindex mspfp
23014 @opindex mspfp-compact
23015 @item -mspfp
23016 @itemx -mspfp-compact
23017 Generate single-precision FPX instructions, tuned for the compact
23018 implementation.
23019
23020 @opindex mspfp-fast
23021 @item -mspfp-fast
23022 Generate single-precision FPX instructions, tuned for the fast
23023 implementation.
23024
23025 @opindex msimd
23026 @item -msimd
23027 Enable generation of ARC SIMD instructions via target-specific
23028 builtins. Only valid for @option{-mcpu=ARC700}.
23029
23030 @opindex msoft-float
23031 @item -msoft-float
23032 This option ignored; it is provided for compatibility purposes only.
23033 Software floating-point code is emitted by default, and this default
23034 can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
23035 @option{-mspfp-fast} for single precision, and @option{-mdpfp},
23036 @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
23037
23038 @opindex mswap
23039 @item -mswap
23040 Generate @code{swap} instructions.
23041
23042 @opindex matomic
23043 @item -matomic
23044 This enables use of the locked load/store conditional extension to implement
23045 atomic memory built-in functions. Not available for ARC 6xx or ARC
23046 EM cores.
23047
23048 @opindex mdiv-rem
23049 @item -mdiv-rem
23050 Enable @code{div} and @code{rem} instructions for ARCv2 cores.
23051
23052 @opindex mcode-density
23053 @item -mcode-density
23054 Enable code density instructions for ARC EM.
23055 This option is on by default for ARC HS.
23056
23057 @opindex mll64
23058 @item -mll64
23059 Enable double load/store operations for ARC HS cores.
23060
23061 @opindex mtp-regno
23062 @item -mtp-regno=@var{regno}
23063 Specify thread pointer register number.
23064
23065 @opindex mmpy-option
23066 @item -mmpy-option=@var{multo}
23067 Compile ARCv2 code with a multiplier design option. You can specify
23068 the option using either a string or numeric value for @var{multo}.
23069 @samp{wlh1} is the default value. The recognized values are:
23070
23071 @table @samp
23072 @item 0
23073 @itemx none
23074 No multiplier available.
23075
23076 @item 1
23077 @itemx w
23078 16x16 multiplier, fully pipelined.
23079 The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
23080
23081 @item 2
23082 @itemx wlh1
23083 32x32 multiplier, fully
23084 pipelined (1 stage). The following instructions are additionally
23085 enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23086
23087 @item 3
23088 @itemx wlh2
23089 32x32 multiplier, fully pipelined
23090 (2 stages). The following instructions are additionally enabled: @code{mpy},
23091 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23092
23093 @item 4
23094 @itemx wlh3
23095 Two 16x16 multipliers, blocking,
23096 sequential. The following instructions are additionally enabled: @code{mpy},
23097 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23098
23099 @item 5
23100 @itemx wlh4
23101 One 16x16 multiplier, blocking,
23102 sequential. The following instructions are additionally enabled: @code{mpy},
23103 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23104
23105 @item 6
23106 @itemx wlh5
23107 One 32x4 multiplier, blocking,
23108 sequential. The following instructions are additionally enabled: @code{mpy},
23109 @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
23110
23111 @item 7
23112 @itemx plus_dmpy
23113 ARC HS SIMD support.
23114
23115 @item 8
23116 @itemx plus_macd
23117 ARC HS SIMD support.
23118
23119 @item 9
23120 @itemx plus_qmacw
23121 ARC HS SIMD support.
23122
23123 @end table
23124
23125 This option is only available for ARCv2 cores@.
23126
23127 @opindex mfpu
23128 @item -mfpu=@var{fpu}
23129 Enables support for specific floating-point hardware extensions for ARCv2
23130 cores. Supported values for @var{fpu} are:
23131
23132 @table @samp
23133
23134 @item fpus
23135 Enables support for single-precision floating-point hardware
23136 extensions@.
23137
23138 @item fpud
23139 Enables support for double-precision floating-point hardware
23140 extensions. The single-precision floating-point extension is also
23141 enabled. Not available for ARC EM@.
23142
23143 @item fpuda
23144 Enables support for double-precision floating-point hardware
23145 extensions using double-precision assist instructions. The single-precision
23146 floating-point extension is also enabled. This option is
23147 only available for ARC EM@.
23148
23149 @item fpuda_div
23150 Enables support for double-precision floating-point hardware
23151 extensions using double-precision assist instructions.
23152 The single-precision floating-point, square-root, and divide
23153 extensions are also enabled. This option is
23154 only available for ARC EM@.
23155
23156 @item fpuda_fma
23157 Enables support for double-precision floating-point hardware
23158 extensions using double-precision assist instructions.
23159 The single-precision floating-point and fused multiply and add
23160 hardware extensions are also enabled. This option is
23161 only available for ARC EM@.
23162
23163 @item fpuda_all
23164 Enables support for double-precision floating-point hardware
23165 extensions using double-precision assist instructions.
23166 All single-precision floating-point hardware extensions are also
23167 enabled. This option is only available for ARC EM@.
23168
23169 @item fpus_div
23170 Enables support for single-precision floating-point, square-root and divide
23171 hardware extensions@.
23172
23173 @item fpud_div
23174 Enables support for double-precision floating-point, square-root and divide
23175 hardware extensions. This option
23176 includes option @samp{fpus_div}. Not available for ARC EM@.
23177
23178 @item fpus_fma
23179 Enables support for single-precision floating-point and
23180 fused multiply and add hardware extensions@.
23181
23182 @item fpud_fma
23183 Enables support for double-precision floating-point and
23184 fused multiply and add hardware extensions. This option
23185 includes option @samp{fpus_fma}. Not available for ARC EM@.
23186
23187 @item fpus_all
23188 Enables support for all single-precision floating-point hardware
23189 extensions@.
23190
23191 @item fpud_all
23192 Enables support for all single- and double-precision floating-point
23193 hardware extensions. Not available for ARC EM@.
23194
23195 @end table
23196
23197 @opindex mirq-ctrl-saved
23198 @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
23199 Specifies general-purposes registers that the processor automatically
23200 saves/restores on interrupt entry and exit. @var{register-range} is
23201 specified as two registers separated by a dash. The register range
23202 always starts with @code{r0}, the upper limit is @code{fp} register.
23203 @var{blink} and @var{lp_count} are optional. This option is only
23204 valid for ARC EM and ARC HS cores.
23205
23206 @opindex mrgf-banked-regs
23207 @item -mrgf-banked-regs=@var{number}
23208 Specifies the number of registers replicated in second register bank
23209 on entry to fast interrupt. Fast interrupts are interrupts with the
23210 highest priority level P0. These interrupts save only PC and STATUS32
23211 registers to avoid memory transactions during interrupt entry and exit
23212 sequences. Use this option when you are using fast interrupts in an
23213 ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
23214
23215 @opindex mlpc-width
23216 @item -mlpc-width=@var{width}
23217 Specify the width of the @code{lp_count} register. Valid values for
23218 @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
23219 fixed to 32 bits. If the width is less than 32, the compiler does not
23220 attempt to transform loops in your program to use the zero-delay loop
23221 mechanism unless it is known that the @code{lp_count} register can
23222 hold the required loop-counter value. Depending on the width
23223 specified, the compiler and run-time library might continue to use the
23224 loop mechanism for various needs. This option defines macro
23225 @code{__ARC_LPC_WIDTH__} with the value of @var{width}.
23226
23227 @opindex mrf16
23228 @item -mrf16
23229 This option instructs the compiler to generate code for a 16-entry
23230 register file. This option defines the @code{__ARC_RF16__}
23231 preprocessor macro.
23232
23233 @opindex mbranch-index
23234 @item -mbranch-index
23235 Enable use of @code{bi} or @code{bih} instructions to implement jump
23236 tables.
23237
23238 @end table
23239
23240 The following options are passed through to the assembler, and also
23241 define preprocessor macro symbols.
23242
23243 @c Flags used by the assembler, but for which we define preprocessor
23244 @c macro symbols as well.
23245 @table @gcctabopt
23246 @opindex mdsp-packa
23247 @item -mdsp-packa
23248 Passed down to the assembler to enable the DSP Pack A extensions.
23249 Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
23250 deprecated.
23251
23252 @opindex mdvbf
23253 @item -mdvbf
23254 Passed down to the assembler to enable the dual Viterbi butterfly
23255 extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
23256 option is deprecated.
23257
23258 @c ARC700 4.10 extension instruction
23259 @opindex mlock
23260 @item -mlock
23261 Passed down to the assembler to enable the locked load/store
23262 conditional extension. Also sets the preprocessor symbol
23263 @code{__Xlock}.
23264
23265 @opindex mmac-d16
23266 @item -mmac-d16
23267 Passed down to the assembler. Also sets the preprocessor symbol
23268 @code{__Xxmac_d16}. This option is deprecated.
23269
23270 @opindex mmac-24
23271 @item -mmac-24
23272 Passed down to the assembler. Also sets the preprocessor symbol
23273 @code{__Xxmac_24}. This option is deprecated.
23274
23275 @c ARC700 4.10 extension instruction
23276 @opindex mrtsc
23277 @item -mrtsc
23278 Passed down to the assembler to enable the 64-bit time-stamp counter
23279 extension instruction. Also sets the preprocessor symbol
23280 @code{__Xrtsc}. This option is deprecated.
23281
23282 @c ARC700 4.10 extension instruction
23283 @opindex mswape
23284 @item -mswape
23285 Passed down to the assembler to enable the swap byte ordering
23286 extension instruction. Also sets the preprocessor symbol
23287 @code{__Xswape}.
23288
23289 @opindex mtelephony
23290 @item -mtelephony
23291 Passed down to the assembler to enable dual- and single-operand
23292 instructions for telephony. Also sets the preprocessor symbol
23293 @code{__Xtelephony}. This option is deprecated.
23294
23295 @opindex mxy
23296 @item -mxy
23297 Passed down to the assembler to enable the XY memory extension. Also
23298 sets the preprocessor symbol @code{__Xxy}.
23299
23300 @end table
23301
23302 The following options control how the assembly code is annotated:
23303
23304 @c Assembly annotation options
23305 @table @gcctabopt
23306 @opindex misize
23307 @item -misize
23308 Annotate assembler instructions with estimated addresses.
23309
23310 @opindex mannotate-align
23311 @item -mannotate-align
23312 Does nothing. Preserved for backward compatibility.
23313
23314 @end table
23315
23316 The following options are passed through to the linker:
23317
23318 @c options passed through to the linker
23319 @table @gcctabopt
23320 @opindex marclinux
23321 @item -marclinux
23322 Passed through to the linker, to specify use of the @code{arclinux} emulation.
23323 This option is enabled by default in tool chains built for
23324 @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
23325 when profiling is not requested.
23326
23327 @opindex marclinux_prof
23328 @item -marclinux_prof
23329 Passed through to the linker, to specify use of the
23330 @code{arclinux_prof} emulation. This option is enabled by default in
23331 tool chains built for @w{@code{arc-linux-uclibc}} and
23332 @w{@code{arceb-linux-uclibc}} targets when profiling is requested.
23333
23334 @end table
23335
23336 The following options control the semantics of generated code:
23337
23338 @c semantically relevant code generation options
23339 @table @gcctabopt
23340 @opindex mlong-calls
23341 @item -mlong-calls
23342 Generate calls as register indirect calls, thus providing access
23343 to the full 32-bit address range.
23344
23345 @opindex mmedium-calls
23346 @item -mmedium-calls
23347 Don't use less than 25-bit addressing range for calls, which is the
23348 offset available for an unconditional branch-and-link
23349 instruction. Conditional execution of function calls is suppressed, to
23350 allow use of the 25-bit range, rather than the 21-bit range with
23351 conditional branch-and-link. This is the default for tool chains built
23352 for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
23353
23354 @opindex G
23355 @item -G @var{num}
23356 Put definitions of externally-visible data in a small data section if
23357 that data is no bigger than @var{num} bytes. The default value of
23358 @var{num} is 4 for any ARC configuration, or 8 when we have double
23359 load/store operations.
23360
23361 @opindex mno-sdata
23362 @opindex msdata
23363 @item -mno-sdata
23364 Do not generate sdata references. This is the default for tool chains
23365 built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
23366 targets.
23367
23368 @opindex mvolatile-cache
23369 @item -mvolatile-cache
23370 Use ordinarily cached memory accesses for volatile references. This is the
23371 default.
23372
23373 @opindex mno-volatile-cache
23374 @opindex mvolatile-cache
23375 @item -mno-volatile-cache
23376 Enable cache bypass for volatile references.
23377
23378 @end table
23379
23380 The following options fine tune code generation:
23381 @c code generation tuning options
23382 @table @gcctabopt
23383 @opindex malign-call
23384 @item -malign-call
23385 Does nothing. Preserved for backward compatibility.
23386
23387 @opindex mauto-modify-reg
23388 @item -mauto-modify-reg
23389 Enable the use of pre/post modify with register displacement.
23390
23391 @opindex mbbit-peephole
23392 @item -mbbit-peephole
23393 Does nothing. Preserved for backward compatibility.
23394
23395 @opindex mno-brcc
23396 @item -mno-brcc
23397 This option disables a target-specific pass in @file{arc_reorg} to
23398 generate compare-and-branch (@code{br@var{cc}}) instructions.
23399 It has no effect on
23400 generation of these instructions driven by the combiner pass.
23401
23402 @opindex mcase-vector-pcrel
23403 @item -mcase-vector-pcrel
23404 Use PC-relative switch case tables to enable case table shortening.
23405 This is the default for @option{-Os}.
23406
23407 @opindex mcompact-casesi
23408 @item -mcompact-casesi
23409 Enable compact @code{casesi} pattern. This is the default for @option{-Os},
23410 and only available for ARCv1 cores. This option is deprecated.
23411
23412 @opindex mno-cond-exec
23413 @item -mno-cond-exec
23414 Disable the ARCompact-specific pass to generate conditional
23415 execution instructions.
23416
23417 Due to delay slot scheduling and interactions between operand numbers,
23418 literal sizes, instruction lengths, and the support for conditional execution,
23419 the target-independent pass to generate conditional execution is often lacking,
23420 so the ARC port has kept a special pass around that tries to find more
23421 conditional execution generation opportunities after register allocation,
23422 branch shortening, and delay slot scheduling have been done. This pass
23423 generally, but not always, improves performance and code size, at the cost of
23424 extra compilation time, which is why there is an option to switch it off.
23425 If you have a problem with call instructions exceeding their allowable
23426 offset range because they are conditionalized, you should consider using
23427 @option{-mmedium-calls} instead.
23428
23429 @opindex mearly-cbranchsi
23430 @item -mearly-cbranchsi
23431 Enable pre-reload use of the @code{cbranchsi} pattern.
23432
23433 @opindex mexpand-adddi
23434 @item -mexpand-adddi
23435 Expand @code{adddi3} and @code{subdi3} at RTL generation time into
23436 @code{add.f}, @code{adc} etc. This option is deprecated.
23437
23438 @opindex mindexed-loads
23439 @item -mindexed-loads
23440 Enable the use of indexed loads. This can be problematic because some
23441 optimizers then assume that indexed stores exist, which is not
23442 the case.
23443
23444 @opindex mlra
23445 @item -mlra
23446 Does nothing. Preserved for backward compatibility.
23447
23448 @opindex mlra-priority-none
23449 @item -mlra-priority-none
23450 Don't indicate any priority for target registers.
23451
23452 @opindex mlra-priority-compact
23453 @item -mlra-priority-compact
23454 Indicate target register priority for r0..r3 / r12..r15.
23455
23456 @opindex mlra-priority-noncompact
23457 @item -mlra-priority-noncompact
23458 Reduce target register priority for r0..r3 / r12..r15.
23459
23460 @opindex mmillicode
23461 @item -mmillicode
23462 When optimizing for size (using @option{-Os}), prologues and epilogues
23463 that have to save or restore a large number of registers are often
23464 shortened by using call to a special function in libgcc; this is
23465 referred to as a @emph{millicode} call. As these calls can pose
23466 performance issues, and/or cause linking issues when linking in a
23467 nonstandard way, this option is provided to turn on or off millicode
23468 call generation.
23469
23470 @opindex mcode-density-frame
23471 @item -mcode-density-frame
23472 This option enable the compiler to emit @code{enter} and @code{leave}
23473 instructions. These instructions are only valid for CPUs with
23474 code-density feature.
23475
23476 @opindex mmixed-code
23477 @item -mmixed-code
23478 Does nothing. Preserved for backward compatibility.
23479
23480 @opindex mq-class
23481 @item -mq-class
23482 Ths option is deprecated. Enable @samp{q} instruction alternatives.
23483 This is the default for @option{-Os}.
23484
23485 @opindex mRcq
23486 @item -mRcq
23487 Does nothing. Preserved for backward compatibility.
23488
23489 @opindex mRcw
23490 @item -mRcw
23491 Does nothing. Preserved for backward compatibility.
23492
23493 @opindex msize-level
23494 @item -msize-level=@var{level}
23495 Fine-tune size optimization with regards to instruction lengths and alignment.
23496 The recognized values for @var{level} are:
23497 @table @samp
23498 @item 0
23499 No size optimization. This level is deprecated and treated like @samp{1}.
23500
23501 @item 1
23502 Short instructions are used opportunistically.
23503
23504 @item 2
23505 In addition, alignment of loops and of code after barriers are dropped.
23506
23507 @item 3
23508 In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
23509
23510 @end table
23511
23512 This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
23513 the behavior when this is not set is equivalent to level @samp{1}.
23514
23515 @opindex mtune
23516 @item -mtune=@var{cpu}
23517 Set instruction scheduling parameters for @var{cpu}, overriding any implied
23518 by @option{-mcpu=}.
23519
23520 Supported values for @var{cpu} are
23521
23522 @table @samp
23523 @item ARC600
23524 Tune for ARC600 CPU.
23525
23526 @item ARC601
23527 Tune for ARC601 CPU.
23528
23529 @item ARC700
23530 Tune for ARC700 CPU with standard multiplier block.
23531
23532 @item ARC700-xmac
23533 Tune for ARC700 CPU with XMAC block.
23534
23535 @item ARC725D
23536 Tune for ARC725D CPU.
23537
23538 @item ARC750D
23539 Tune for ARC750D CPU.
23540
23541 @item core3
23542 Tune for ARCv2 core3 type CPU. This option enable usage of
23543 @code{dbnz} instruction.
23544
23545 @item release31a
23546 Tune for ARC4x release 3.10a.
23547
23548 @end table
23549
23550 @opindex mmultcost
23551 @item -mmultcost=@var{num}
23552 Cost to assume for a multiply instruction, with @samp{4} being equal to a
23553 normal instruction.
23554
23555 @opindex munalign-prob-threshold
23556 @item -munalign-prob-threshold=@var{probability}
23557 Does nothing. Preserved for backward compatibility.
23558
23559 @end table
23560
23561 The following options are maintained for backward compatibility, but
23562 are now deprecated and will be removed in a future release:
23563
23564 @c Deprecated options
23565 @table @gcctabopt
23566
23567 @opindex margonaut
23568 @item -margonaut
23569 Obsolete FPX.
23570
23571 @opindex mbig-endian
23572 @opindex EB
23573 @item -mbig-endian
23574 @itemx -EB
23575 Compile code for big-endian targets. Use of these options is now
23576 deprecated. Big-endian code is supported by configuring GCC to build
23577 @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
23578 for which big endian is the default.
23579
23580 @opindex mlittle-endian
23581 @opindex EL
23582 @item -mlittle-endian
23583 @itemx -EL
23584 Compile code for little-endian targets. Use of these options is now
23585 deprecated. Little-endian code is supported by configuring GCC to build
23586 @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
23587 for which little endian is the default.
23588
23589 @opindex mbarrel_shifter
23590 @item -mbarrel_shifter
23591 Replaced by @option{-mbarrel-shifter}.
23592
23593 @opindex mdpfp_compact
23594 @item -mdpfp_compact
23595 Replaced by @option{-mdpfp-compact}.
23596
23597 @opindex mdpfp_fast
23598 @item -mdpfp_fast
23599 Replaced by @option{-mdpfp-fast}.
23600
23601 @opindex mdsp_packa
23602 @item -mdsp_packa
23603 Replaced by @option{-mdsp-packa}.
23604
23605 @opindex mEA
23606 @item -mEA
23607 Replaced by @option{-mea}.
23608
23609 @opindex mmac_24
23610 @item -mmac_24
23611 Replaced by @option{-mmac-24}.
23612
23613 @opindex mmac_d16
23614 @item -mmac_d16
23615 Replaced by @option{-mmac-d16}.
23616
23617 @opindex mspfp_compact
23618 @item -mspfp_compact
23619 Replaced by @option{-mspfp-compact}.
23620
23621 @opindex mspfp_fast
23622 @item -mspfp_fast
23623 Replaced by @option{-mspfp-fast}.
23624
23625 @opindex mtune
23626 @item -mtune=@var{cpu}
23627 Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
23628 @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
23629 @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
23630
23631 @opindex multcost
23632 @item -multcost=@var{num}
23633 Replaced by @option{-mmultcost}.
23634
23635 @end table
23636
23637 @node ARM Options
23638 @subsection ARM Options
23639 @cindex ARM options
23640
23641 These @samp{-m} options are defined for the ARM port:
23642
23643 @table @gcctabopt
23644 @opindex mabi
23645 @item -mabi=@var{name}
23646 Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
23647 @samp{atpcs}, @samp{aapcs} and @samp{aapcs-linux}.
23648
23649 @opindex mapcs-frame
23650 @item -mapcs-frame
23651 Generate a stack frame that is compliant with the ARM Procedure Call
23652 Standard for all functions, even if this is not strictly necessary for
23653 correct execution of the code. Specifying @option{-fomit-frame-pointer}
23654 with this option causes the stack frames not to be generated for
23655 leaf functions. The default is @option{-mno-apcs-frame}.
23656 This option is deprecated.
23657
23658 @opindex mapcs
23659 @item -mapcs
23660 This is a synonym for @option{-mapcs-frame} and is deprecated.
23661
23662 @ignore
23663 @c not currently implemented
23664 @opindex mapcs-stack-check
23665 @item -mapcs-stack-check
23666 Generate code to check the amount of stack space available upon entry to
23667 every function (that actually uses some stack space). If there is
23668 insufficient space available then either the function
23669 @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
23670 called, depending upon the amount of stack space required. The runtime
23671 system is required to provide these functions. The default is
23672 @option{-mno-apcs-stack-check}, since this produces smaller code.
23673
23674 @c not currently implemented
23675 @opindex mapcs-reentrant
23676 @item -mapcs-reentrant
23677 Generate reentrant, position-independent code. The default is
23678 @option{-mno-apcs-reentrant}.
23679 @end ignore
23680
23681 @opindex mthumb-interwork
23682 @item -mthumb-interwork
23683 Generate code that supports calling between the ARM and Thumb
23684 instruction sets. Without this option, on pre-v5 architectures, the
23685 two instruction sets cannot be reliably used inside one program. The
23686 default is @option{-mno-thumb-interwork}, since slightly larger code
23687 is generated when @option{-mthumb-interwork} is specified. In AAPCS
23688 configurations this option is meaningless.
23689
23690 @opindex mno-sched-prolog
23691 @opindex msched-prolog
23692 @item -mno-sched-prolog
23693 Prevent the reordering of instructions in the function prologue, or the
23694 merging of those instruction with the instructions in the function's
23695 body. This means that all functions start with a recognizable set
23696 of instructions (or in fact one of a choice from a small set of
23697 different function prologues), and this information can be used to
23698 locate the start of functions inside an executable piece of code. The
23699 default is @option{-msched-prolog}.
23700
23701 @opindex mfloat-abi
23702 @item -mfloat-abi=@var{name}
23703 Specifies which floating-point ABI to use. Permissible values
23704 are: @samp{soft}, @samp{softfp} and @samp{hard}.
23705
23706 Specifying @samp{soft} causes GCC to generate output containing
23707 library calls for floating-point operations.
23708 @samp{softfp} allows the generation of code using hardware floating-point
23709 instructions, but still uses the soft-float calling conventions.
23710 @samp{hard} allows generation of floating-point instructions
23711 and uses FPU-specific calling conventions.
23712
23713 The default depends on the specific target configuration. Note that
23714 the hard-float and soft-float ABIs are not link-compatible; you must
23715 compile your entire program with the same ABI, and link with a
23716 compatible set of libraries.
23717
23718 @opindex mgeneral-regs-only
23719 @item -mgeneral-regs-only
23720 Generate code which uses only the general-purpose registers. This will prevent
23721 the compiler from using floating-point and Advanced SIMD registers but will not
23722 impose any restrictions on the assembler.
23723
23724 @opindex mlittle-endian
23725 @item -mlittle-endian
23726 Generate code for a processor running in little-endian mode. This is
23727 the default for all standard configurations.
23728
23729 @opindex mbig-endian
23730 @item -mbig-endian
23731 Generate code for a processor running in big-endian mode; the default is
23732 to compile code for a little-endian processor.
23733
23734 @opindex mbe8
23735 @item -mbe8
23736 @itemx -mbe32
23737 When linking a big-endian image select between BE8 and BE32 formats.
23738 The option has no effect for little-endian images and is ignored. The
23739 default is dependent on the selected target architecture. For ARMv6
23740 and later architectures the default is BE8, for older architectures
23741 the default is BE32. BE32 format has been deprecated by ARM.
23742
23743 @opindex march
23744 @item -march=@var{name}@r{[}+extension@dots{}@r{]}
23745 This specifies the name of the target ARM architecture. GCC uses this
23746 name to determine what kind of instructions it can emit when generating
23747 assembly code. This option can be used in conjunction with or instead
23748 of the @option{-mcpu=} option.
23749
23750 Permissible names are:
23751 @samp{armv4t},
23752 @samp{armv5t}, @samp{armv5te},
23753 @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
23754 @samp{armv6z}, @samp{armv6zk},
23755 @samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
23756 @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
23757 @samp{armv8.4-a},
23758 @samp{armv8.5-a},
23759 @samp{armv8.6-a},
23760 @samp{armv9-a},
23761 @samp{armv7-r},
23762 @samp{armv8-r},
23763 @samp{armv6-m}, @samp{armv6s-m},
23764 @samp{armv7-m}, @samp{armv7e-m},
23765 @samp{armv8-m.base}, @samp{armv8-m.main},
23766 @samp{armv8.1-m.main},
23767 @samp{iwmmxt} and @samp{iwmmxt2}.
23768
23769 Additionally, the following architectures, which lack support for the
23770 Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
23771
23772 Many of the architectures support extensions. These can be added by
23773 appending @samp{+@var{extension}} to the architecture name. Extension
23774 options are processed in order and capabilities accumulate. An extension
23775 will also enable any necessary base extensions
23776 upon which it depends. For example, the @samp{+crypto} extension
23777 will always enable the @samp{+simd} extension. The exception to the
23778 additive construction is for extensions that are prefixed with
23779 @samp{+no@dots{}}: these extensions disable the specified option and
23780 any other extensions that may depend on the presence of that
23781 extension.
23782
23783 For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
23784 writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
23785 entirely disabled by the @samp{+nofp} option that follows it.
23786
23787 Most extension names are generically named, but have an effect that is
23788 dependent upon the architecture to which it is applied. For example,
23789 the @samp{+simd} option can be applied to both @samp{armv7-a} and
23790 @samp{armv8-a} architectures, but will enable the original ARMv7-A
23791 Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
23792 variant for @samp{armv8-a}.
23793
23794 The table below lists the supported extensions for each architecture.
23795 Architectures not mentioned do not support any extensions.
23796
23797 @table @samp
23798 @item armv5te
23799 @itemx armv6
23800 @itemx armv6j
23801 @itemx armv6k
23802 @itemx armv6kz
23803 @itemx armv6t2
23804 @itemx armv6z
23805 @itemx armv6zk
23806 @table @samp
23807 @item +fp
23808 The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
23809 used as an alias for this extension.
23810
23811 @item +nofp
23812 Disable the floating-point instructions.
23813 @end table
23814
23815 @item armv7
23816 The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
23817 @table @samp
23818 @item +fp
23819 The VFPv3 floating-point instructions, with 16 double-precision
23820 registers. The extension @samp{+vfpv3-d16} can be used as an alias
23821 for this extension. Note that floating-point is not supported by the
23822 base ARMv7-M architecture, but is compatible with both the ARMv7-A and
23823 ARMv7-R architectures.
23824
23825 @item +nofp
23826 Disable the floating-point instructions.
23827 @end table
23828
23829 @item armv7-a
23830 @table @samp
23831 @item +mp
23832 The multiprocessing extension.
23833
23834 @item +sec
23835 The security extension.
23836
23837 @item +fp
23838 The VFPv3 floating-point instructions, with 16 double-precision
23839 registers. The extension @samp{+vfpv3-d16} can be used as an alias
23840 for this extension.
23841
23842 @item +simd
23843 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
23844 The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
23845 for this extension.
23846
23847 @item +vfpv3
23848 The VFPv3 floating-point instructions, with 32 double-precision
23849 registers.
23850
23851 @item +vfpv3-d16-fp16
23852 The VFPv3 floating-point instructions, with 16 double-precision
23853 registers and the half-precision floating-point conversion operations.
23854
23855 @item +vfpv3-fp16
23856 The VFPv3 floating-point instructions, with 32 double-precision
23857 registers and the half-precision floating-point conversion operations.
23858
23859 @item +vfpv4-d16
23860 The VFPv4 floating-point instructions, with 16 double-precision
23861 registers.
23862
23863 @item +vfpv4
23864 The VFPv4 floating-point instructions, with 32 double-precision
23865 registers.
23866
23867 @item +neon-fp16
23868 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
23869 the half-precision floating-point conversion operations.
23870
23871 @item +neon-vfpv4
23872 The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
23873
23874 @item +nosimd
23875 Disable the Advanced SIMD instructions (does not disable floating point).
23876
23877 @item +nofp
23878 Disable the floating-point and Advanced SIMD instructions.
23879 @end table
23880
23881 @item armv7ve
23882 The extended version of the ARMv7-A architecture with support for
23883 virtualization.
23884 @table @samp
23885 @item +fp
23886 The VFPv4 floating-point instructions, with 16 double-precision registers.
23887 The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
23888
23889 @item +simd
23890 The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
23891 extension @samp{+neon-vfpv4} can be used as an alias for this extension.
23892
23893 @item +vfpv3-d16
23894 The VFPv3 floating-point instructions, with 16 double-precision
23895 registers.
23896
23897 @item +vfpv3
23898 The VFPv3 floating-point instructions, with 32 double-precision
23899 registers.
23900
23901 @item +vfpv3-d16-fp16
23902 The VFPv3 floating-point instructions, with 16 double-precision
23903 registers and the half-precision floating-point conversion operations.
23904
23905 @item +vfpv3-fp16
23906 The VFPv3 floating-point instructions, with 32 double-precision
23907 registers and the half-precision floating-point conversion operations.
23908
23909 @item +vfpv4-d16
23910 The VFPv4 floating-point instructions, with 16 double-precision
23911 registers.
23912
23913 @item +vfpv4
23914 The VFPv4 floating-point instructions, with 32 double-precision
23915 registers.
23916
23917 @item +neon
23918 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
23919 The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
23920
23921 @item +neon-fp16
23922 The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
23923 the half-precision floating-point conversion operations.
23924
23925 @item +nosimd
23926 Disable the Advanced SIMD instructions (does not disable floating point).
23927
23928 @item +nofp
23929 Disable the floating-point and Advanced SIMD instructions.
23930 @end table
23931
23932 @item armv8-a
23933 @table @samp
23934 @item +crc
23935 The Cyclic Redundancy Check (CRC) instructions.
23936 @item +simd
23937 The ARMv8-A Advanced SIMD and floating-point instructions.
23938 @item +crypto
23939 The cryptographic instructions.
23940 @item +nocrypto
23941 Disable the cryptographic instructions.
23942 @item +nofp
23943 Disable the floating-point, Advanced SIMD and cryptographic instructions.
23944 @item +sb
23945 Speculation Barrier Instruction.
23946 @item +predres
23947 Execution and Data Prediction Restriction Instructions.
23948 @end table
23949
23950 @item armv8.1-a
23951 @table @samp
23952 @item +simd
23953 The ARMv8.1-A Advanced SIMD and floating-point instructions.
23954
23955 @item +crypto
23956 The cryptographic instructions. This also enables the Advanced SIMD and
23957 floating-point instructions.
23958
23959 @item +nocrypto
23960 Disable the cryptographic instructions.
23961
23962 @item +nofp
23963 Disable the floating-point, Advanced SIMD and cryptographic instructions.
23964
23965 @item +sb
23966 Speculation Barrier Instruction.
23967
23968 @item +predres
23969 Execution and Data Prediction Restriction Instructions.
23970 @end table
23971
23972 @item armv8.2-a
23973 @itemx armv8.3-a
23974 @table @samp
23975 @item +fp16
23976 The half-precision floating-point data processing instructions.
23977 This also enables the Advanced SIMD and floating-point instructions.
23978
23979 @item +fp16fml
23980 The half-precision floating-point fmla extension. This also enables
23981 the half-precision floating-point extension and Advanced SIMD and
23982 floating-point instructions.
23983
23984 @item +simd
23985 The ARMv8.1-A Advanced SIMD and floating-point instructions.
23986
23987 @item +crypto
23988 The cryptographic instructions. This also enables the Advanced SIMD and
23989 floating-point instructions.
23990
23991 @item +dotprod
23992 Enable the Dot Product extension. This also enables Advanced SIMD instructions.
23993
23994 @item +nocrypto
23995 Disable the cryptographic extension.
23996
23997 @item +nofp
23998 Disable the floating-point, Advanced SIMD and cryptographic instructions.
23999
24000 @item +sb
24001 Speculation Barrier Instruction.
24002
24003 @item +predres
24004 Execution and Data Prediction Restriction Instructions.
24005
24006 @item +i8mm
24007 8-bit Integer Matrix Multiply instructions.
24008 This also enables Advanced SIMD and floating-point instructions.
24009
24010 @item +bf16
24011 Brain half-precision floating-point instructions.
24012 This also enables Advanced SIMD and floating-point instructions.
24013 @end table
24014
24015 @item armv8.4-a
24016 @table @samp
24017 @item +fp16
24018 The half-precision floating-point data processing instructions.
24019 This also enables the Advanced SIMD and floating-point instructions as well
24020 as the Dot Product extension and the half-precision floating-point fmla
24021 extension.
24022
24023 @item +simd
24024 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
24025 Dot Product extension.
24026
24027 @item +crypto
24028 The cryptographic instructions. This also enables the Advanced SIMD and
24029 floating-point instructions as well as the Dot Product extension.
24030
24031 @item +nocrypto
24032 Disable the cryptographic extension.
24033
24034 @item +nofp
24035 Disable the floating-point, Advanced SIMD and cryptographic instructions.
24036
24037 @item +sb
24038 Speculation Barrier Instruction.
24039
24040 @item +predres
24041 Execution and Data Prediction Restriction Instructions.
24042
24043 @item +i8mm
24044 8-bit Integer Matrix Multiply instructions.
24045 This also enables Advanced SIMD and floating-point instructions.
24046
24047 @item +bf16
24048 Brain half-precision floating-point instructions.
24049 This also enables Advanced SIMD and floating-point instructions.
24050 @end table
24051
24052 @item armv8.5-a
24053 @table @samp
24054 @item +fp16
24055 The half-precision floating-point data processing instructions.
24056 This also enables the Advanced SIMD and floating-point instructions as well
24057 as the Dot Product extension and the half-precision floating-point fmla
24058 extension.
24059
24060 @item +simd
24061 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
24062 Dot Product extension.
24063
24064 @item +crypto
24065 The cryptographic instructions. This also enables the Advanced SIMD and
24066 floating-point instructions as well as the Dot Product extension.
24067
24068 @item +nocrypto
24069 Disable the cryptographic extension.
24070
24071 @item +nofp
24072 Disable the floating-point, Advanced SIMD and cryptographic instructions.
24073
24074 @item +i8mm
24075 8-bit Integer Matrix Multiply instructions.
24076 This also enables Advanced SIMD and floating-point instructions.
24077
24078 @item +bf16
24079 Brain half-precision floating-point instructions.
24080 This also enables Advanced SIMD and floating-point instructions.
24081 @end table
24082
24083 @item armv8.6-a
24084 @table @samp
24085 @item +fp16
24086 The half-precision floating-point data processing instructions.
24087 This also enables the Advanced SIMD and floating-point instructions as well
24088 as the Dot Product extension and the half-precision floating-point fmla
24089 extension.
24090
24091 @item +simd
24092 The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
24093 Dot Product extension.
24094
24095 @item +crypto
24096 The cryptographic instructions. This also enables the Advanced SIMD and
24097 floating-point instructions as well as the Dot Product extension.
24098
24099 @item +nocrypto
24100 Disable the cryptographic extension.
24101
24102 @item +nofp
24103 Disable the floating-point, Advanced SIMD and cryptographic instructions.
24104
24105 @item +i8mm
24106 8-bit Integer Matrix Multiply instructions.
24107 This also enables Advanced SIMD and floating-point instructions.
24108
24109 @item +bf16
24110 Brain half-precision floating-point instructions.
24111 This also enables Advanced SIMD and floating-point instructions.
24112 @end table
24113
24114 @item armv7-r
24115 @table @samp
24116 @item +fp.sp
24117 The single-precision VFPv3 floating-point instructions. The extension
24118 @samp{+vfpv3xd} can be used as an alias for this extension.
24119
24120 @item +fp
24121 The VFPv3 floating-point instructions with 16 double-precision registers.
24122 The extension +vfpv3-d16 can be used as an alias for this extension.
24123
24124 @item +vfpv3xd-d16-fp16
24125 The single-precision VFPv3 floating-point instructions with 16 double-precision
24126 registers and the half-precision floating-point conversion operations.
24127
24128 @item +vfpv3-d16-fp16
24129 The VFPv3 floating-point instructions with 16 double-precision
24130 registers and the half-precision floating-point conversion operations.
24131
24132 @item +nofp
24133 Disable the floating-point extension.
24134
24135 @item +idiv
24136 The ARM-state integer division instructions.
24137
24138 @item +noidiv
24139 Disable the ARM-state integer division extension.
24140 @end table
24141
24142 @item armv7e-m
24143 @table @samp
24144 @item +fp
24145 The single-precision VFPv4 floating-point instructions.
24146
24147 @item +fpv5
24148 The single-precision FPv5 floating-point instructions.
24149
24150 @item +fp.dp
24151 The single- and double-precision FPv5 floating-point instructions.
24152
24153 @item +nofp
24154 Disable the floating-point extensions.
24155 @end table
24156
24157 @item armv8.1-m.main
24158 @table @samp
24159
24160 @item +dsp
24161 The DSP instructions.
24162
24163 @item +mve
24164 The M-Profile Vector Extension (MVE) integer instructions.
24165
24166 @item +mve.fp
24167 The M-Profile Vector Extension (MVE) integer and single precision
24168 floating-point instructions.
24169
24170 @item +fp
24171 The single-precision floating-point instructions.
24172
24173 @item +fp.dp
24174 The single- and double-precision floating-point instructions.
24175
24176 @item +nofp
24177 Disable the floating-point extension.
24178
24179 @item +cdecp0, +cdecp1, ... , +cdecp7
24180 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
24181 to the numbers given in the options in the range 0 to 7.
24182
24183 @item +pacbti
24184 Enable the Pointer Authentication and Branch Target Identification Extension.
24185 @end table
24186
24187 @item armv8-m.main
24188 @table @samp
24189 @item +dsp
24190 The DSP instructions.
24191
24192 @item +nodsp
24193 Disable the DSP extension.
24194
24195 @item +fp
24196 The single-precision floating-point instructions.
24197
24198 @item +fp.dp
24199 The single- and double-precision floating-point instructions.
24200
24201 @item +nofp
24202 Disable the floating-point extension.
24203
24204 @item +cdecp0, +cdecp1, ... , +cdecp7
24205 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
24206 to the numbers given in the options in the range 0 to 7.
24207 @end table
24208
24209 @item armv8-r
24210 @table @samp
24211 @item +crc
24212 The Cyclic Redundancy Check (CRC) instructions.
24213 @item +fp.sp
24214 The single-precision FPv5 floating-point instructions.
24215 @item +simd
24216 The ARMv8-A Advanced SIMD and floating-point instructions.
24217 @item +crypto
24218 The cryptographic instructions.
24219 @item +nocrypto
24220 Disable the cryptographic instructions.
24221 @item +nofp
24222 Disable the floating-point, Advanced SIMD and cryptographic instructions.
24223 @end table
24224
24225 @end table
24226
24227 @option{-march=native} causes the compiler to auto-detect the architecture
24228 of the build computer. At present, this feature is only supported on
24229 GNU/Linux, and not all architectures are recognized. If the auto-detect
24230 is unsuccessful the option has no effect.
24231
24232 @option{-march=unset} causes the compiler to ignore any
24233 @option{-march=@dots{}} options that appear earlier on the command line
24234 and behave as if the option was never passed. This is useful to avoid
24235 warnings about conflicting CPU and architecture options when the two
24236 produce different architecture specifications.
24237
24238 @opindex mtune
24239 @item -mtune=@var{name}
24240 This option specifies the name of the target ARM processor for
24241 which GCC should tune the performance of the code.
24242 For some ARM implementations better performance can be obtained by using
24243 this option.
24244 Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
24245 @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
24246 @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
24247 @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
24248 @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
24249 @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
24250 @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
24251 @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
24252 @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
24253 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
24254 @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
24255 @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
24256 @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
24257 @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
24258 @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
24259 @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
24260 @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
24261 @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
24262 @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
24263 @samp{cortex-m35p}, @samp{cortex-m52}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
24264 @samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
24265 @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
24266 @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
24267 @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
24268 @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
24269 @samp{xgene1}.
24270
24271 Additionally, this option can specify that GCC should tune the performance
24272 of the code for a big.LITTLE system. Permissible names are:
24273 @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
24274 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
24275 @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
24276 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
24277
24278 @option{-mtune=generic-@var{arch}} specifies that GCC should tune the
24279 performance for a blend of processors within architecture @var{arch}.
24280 The aim is to generate code that run well on the current most popular
24281 processors, balancing between optimizations that benefit some CPUs in the
24282 range, and avoiding performance pitfalls of other CPUs. The effects of
24283 this option may change in future GCC versions as CPU models come and go.
24284
24285 @option{-mtune} permits the same extension options as @option{-mcpu}, but
24286 the extension options do not affect the tuning of the generated code.
24287
24288 @option{-mtune=native} causes the compiler to auto-detect the CPU
24289 of the build computer. At present, this feature is only supported on
24290 GNU/Linux, and not all architectures are recognized. If the auto-detect is
24291 unsuccessful the option has no effect.
24292
24293 @opindex mcpu
24294 @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
24295 This specifies the name of the target ARM processor. GCC uses this name
24296 to derive the name of the target ARM architecture (as if specified
24297 by @option{-march}) and the ARM processor type for which to tune for
24298 performance (as if specified by @option{-mtune}). Where this option
24299 is used in conjunction with @option{-march} or @option{-mtune},
24300 those options take precedence over the appropriate part of this option.
24301
24302 Many of the supported CPUs implement optional architectural
24303 extensions. Where this is so the architectural extensions are
24304 normally enabled by default. If implementations that lack the
24305 extension exist, then the extension syntax can be used to disable
24306 those extensions that have been omitted. For floating-point and
24307 Advanced SIMD (Neon) instructions, the settings of the options
24308 @option{-mfloat-abi} and @option{-mfpu} must also be considered:
24309 floating-point and Advanced SIMD instructions will only be used if
24310 @option{-mfloat-abi} is not set to @samp{soft}; and any setting of
24311 @option{-mfpu} other than @samp{auto} will override the available
24312 floating-point and SIMD extension instructions.
24313
24314 For example, @samp{cortex-a9} can be found in three major
24315 configurations: integer only, with just a floating-point unit or with
24316 floating-point and Advanced SIMD. The default is to enable all the
24317 instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
24318 be used to disable just the SIMD or both the SIMD and floating-point
24319 instructions respectively.
24320
24321 Permissible names for this option are the same as those for
24322 @option{-mtune}.
24323
24324 The following extension options are common to the listed CPUs:
24325
24326 @table @samp
24327 @item +nodsp
24328 Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
24329 @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
24330 Also disable the M-Profile Vector Extension (MVE) integer and
24331 single precision floating-point instructions on
24332 @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
24333
24334 @item +nopacbti
24335 Disable the Pointer Authentication and Branch Target Identification Extension
24336 on @samp{cortex-m52} and @samp{cortex-m85}.
24337
24338 @item +nomve
24339 Disable the M-Profile Vector Extension (MVE) integer and single precision
24340 floating-point instructions on @samp{cortex-m52}, @samp{cortex-m55} and
24341 @samp{cortex-m85}.
24342
24343 @item +nomve.fp
24344 Disable the M-Profile Vector Extension (MVE) single precision floating-point
24345 instructions on @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
24346
24347 @item +cdecp0, +cdecp1, ... , +cdecp7
24348 Enable the Custom Datapath Extension (CDE) on selected coprocessors according
24349 to the numbers given in the options in the range 0 to 7 on @samp{cortex-m52},
24350 @samp{cortex-m55} and @samp{star-mc1}.
24351
24352 @item +nofp
24353 Disables the floating-point instructions on @samp{arm9e},
24354 @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
24355 @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
24356 @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
24357 @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
24358 @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
24359 Disables the floating-point and SIMD instructions on
24360 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
24361 @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
24362 @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
24363 @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
24364 @samp{cortex-a53} and @samp{cortex-a55}.
24365
24366 @item +nofp.dp
24367 Disables the double-precision component of the floating-point instructions
24368 on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
24369 @samp{cortex-r52plus} and @samp{cortex-m7}.
24370
24371 @item +nosimd
24372 Disables the SIMD (but not floating-point) instructions on
24373 @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
24374 and @samp{cortex-a9}.
24375
24376 @item +crypto
24377 Enables the cryptographic instructions on @samp{cortex-a32},
24378 @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
24379 @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
24380 @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
24381 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
24382 @samp{cortex-a75.cortex-a55}.
24383 @end table
24384
24385 Additionally the @samp{generic-armv7-a} pseudo target defaults to
24386 VFPv3 with 16 double-precision registers. It supports the following
24387 extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
24388 @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
24389 @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
24390 @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
24391 the extensions to @option{-march=armv7-a}.
24392
24393 @option{-mcpu=generic-@var{arch}} is also permissible, and is
24394 equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
24395 See @option{-mtune} for more information.
24396
24397 @option{-mcpu=native} causes the compiler to auto-detect the CPU
24398 of the build computer. At present, this feature is only supported on
24399 GNU/Linux, and not all architectures are recognized. If the auto-detect
24400 is unsuccessful the option has no effect.
24401
24402 @option{-mcpu=unset} causes the compiler to ignore any
24403 @option{-mcpu=@dots{}} options that appear earlier on the command line
24404 and behave as if the option was never passed. This is useful to avoid
24405 warnings about conflicting CPU and architecture options when the two
24406 produce different architecture specifications.
24407
24408 @opindex mfpu
24409 @item -mfpu=@var{name}
24410 This specifies what floating-point hardware (or hardware emulation) is
24411 available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
24412 @samp{vfpv3},
24413 @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
24414 @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
24415 @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
24416 @samp{fpv5-d16}, @samp{fpv5-sp-d16},
24417 @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
24418 Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
24419 is an alias for @samp{vfpv2}.
24420
24421 The setting @samp{auto} is the default and is special. It causes the
24422 compiler to select the floating-point and Advanced SIMD instructions
24423 based on the settings of @option{-mcpu} and @option{-march}.
24424
24425 If the selected floating-point hardware includes the NEON extension
24426 (e.g.@: @option{-mfpu=neon}), note that floating-point
24427 operations are not generated by GCC's auto-vectorization pass unless
24428 @option{-funsafe-math-optimizations} is also specified. This is
24429 because NEON hardware does not fully implement the IEEE 754 standard for
24430 floating-point arithmetic (in particular denormal values are treated as
24431 zero), so the use of NEON instructions may lead to a loss of precision.
24432
24433 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}).
24434
24435 @opindex mfp16-format
24436 @item -mfp16-format=@var{name}
24437 Specify the format of the @code{__fp16} half-precision floating-point type.
24438 Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
24439 the default is @samp{none}, in which case the @code{__fp16} type is not
24440 defined. @xref{Half-Precision}, for more information.
24441
24442 @opindex mstructure-size-boundary
24443 @item -mstructure-size-boundary=@var{n}
24444 The sizes of all structures and unions are rounded up to a multiple
24445 of the number of bits set by this option. Permissible values are 8, 32
24446 and 64. The default value varies for different toolchains. For the COFF
24447 targeted toolchain the default value is 8. A value of 64 is only allowed
24448 if the underlying ABI supports it.
24449
24450 Specifying a larger number can produce faster, more efficient code, but
24451 can also increase the size of the program. Different values are potentially
24452 incompatible. Code compiled with one value cannot necessarily expect to
24453 work with code or libraries compiled with another value, if they exchange
24454 information using structures or unions.
24455
24456 This option is deprecated.
24457
24458 @opindex mabort-on-noreturn
24459 @item -mabort-on-noreturn
24460 Generate a call to the function @code{abort} at the end of a
24461 @code{noreturn} function. It is executed if the function tries to
24462 return.
24463
24464 @opindex mlong-calls
24465 @opindex mno-long-calls
24466 @item -mlong-calls
24467 @itemx -mno-long-calls
24468 Tells the compiler to perform function calls by first loading the
24469 address of the function into a register and then performing a subroutine
24470 call on this register. This switch is needed if the target function
24471 lies outside of the 64-megabyte addressing range of the offset-based
24472 version of subroutine call instruction.
24473
24474 Even if this switch is enabled, not all function calls are turned
24475 into long calls. The heuristic is that static functions, functions
24476 that have the @code{short_call} attribute, functions that are inside
24477 the scope of a @code{#pragma no_long_calls} directive, and functions whose
24478 definitions have already been compiled within the current compilation
24479 unit are not turned into long calls. The exceptions to this rule are
24480 that weak function definitions, functions with the @code{long_call}
24481 attribute or the @code{section} attribute, and functions that are within
24482 the scope of a @code{#pragma long_calls} directive are always
24483 turned into long calls.
24484
24485 This feature is not enabled by default. Specifying
24486 @option{-mno-long-calls} restores the default behavior, as does
24487 placing the function calls within the scope of a @code{#pragma
24488 long_calls_off} directive. Note these switches have no effect on how
24489 the compiler generates code to handle function calls via function
24490 pointers.
24491
24492 @opindex msingle-pic-base
24493 @item -msingle-pic-base
24494 Treat the register used for PIC addressing as read-only, rather than
24495 loading it in the prologue for each function. The runtime system is
24496 responsible for initializing this register with an appropriate value
24497 before execution begins.
24498
24499 @opindex mpic-register
24500 @item -mpic-register=@var{reg}
24501 Specify the register to be used for PIC addressing.
24502 For standard PIC base case, the default is any suitable register
24503 determined by compiler. For single PIC base case, the default is
24504 @samp{R9} if target is EABI based or stack-checking is enabled,
24505 otherwise the default is @samp{R10}.
24506
24507 @opindex mpic-data-is-text-relative
24508 @item -mpic-data-is-text-relative
24509 Assume that the displacement between the text and data segments is fixed
24510 at static link time. This permits using PC-relative addressing
24511 operations to access data known to be in the data segment. For
24512 non-VxWorks RTP targets, this option is enabled by default. When
24513 disabled on such targets, it will enable @option{-msingle-pic-base} by
24514 default.
24515
24516 @opindex mpoke-function-name
24517 @item -mpoke-function-name
24518 Write the name of each function into the text section, directly
24519 preceding the function prologue. The generated code is similar to this:
24520
24521 @smallexample
24522 t0
24523 .ascii "arm_poke_function_name", 0
24524 .align
24525 t1
24526 .word 0xff000000 + (t1 - t0)
24527 arm_poke_function_name
24528 mov ip, sp
24529 stmfd sp!, @{fp, ip, lr, pc@}
24530 sub fp, ip, #4
24531 @end smallexample
24532
24533 When performing a stack backtrace, code can inspect the value of
24534 @code{pc} stored at @code{fp + 0}. If the trace function then looks at
24535 location @code{pc - 12} and the top 8 bits are set, then we know that
24536 there is a function name embedded immediately preceding this location
24537 and has length @code{((pc[-3]) & 0xff000000)}.
24538
24539 @opindex marm
24540 @opindex mthumb
24541 @item -mthumb
24542 @itemx -marm
24543
24544 Select between generating code that executes in ARM and Thumb
24545 states. The default for most configurations is to generate code
24546 that executes in ARM state, but the default can be changed by
24547 configuring GCC with the @option{--with-mode=}@var{state}
24548 configure option.
24549
24550 You can also override the ARM and Thumb mode for each function
24551 by using the @code{target("thumb")} and @code{target("arm")} function attributes
24552 (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
24553
24554 @opindex mflip-thumb
24555 @item -mflip-thumb
24556 Switch ARM/Thumb modes on alternating functions.
24557 This option is provided for regression testing of mixed Thumb/ARM code
24558 generation, and is not intended for ordinary use in compiling code.
24559
24560 @opindex mtpcs-frame
24561 @item -mtpcs-frame
24562 Generate a stack frame that is compliant with the Thumb Procedure Call
24563 Standard for all non-leaf functions. (A leaf function is one that does
24564 not call any other functions.) The default is @option{-mno-tpcs-frame}.
24565
24566 @opindex mtpcs-leaf-frame
24567 @item -mtpcs-leaf-frame
24568 Generate a stack frame that is compliant with the Thumb Procedure Call
24569 Standard for all leaf functions. (A leaf function is one that does
24570 not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
24571
24572 @opindex mcallee-super-interworking
24573 @item -mcallee-super-interworking
24574 Gives all externally visible functions in the file being compiled an ARM
24575 instruction set header which switches to Thumb mode before executing the
24576 rest of the function. This allows these functions to be called from
24577 non-interworking code. This option is not valid in AAPCS configurations
24578 because interworking is enabled by default.
24579
24580 @opindex mcaller-super-interworking
24581 @item -mcaller-super-interworking
24582 Allows calls via function pointers (including virtual functions) to
24583 execute correctly regardless of whether the target code has been
24584 compiled for interworking or not. There is a small overhead in the cost
24585 of executing a function pointer if this option is enabled. This option
24586 is not valid in AAPCS configurations because interworking is enabled
24587 by default.
24588
24589 @opindex mtp
24590 @item -mtp=@var{name}
24591 Specify the access model for the thread local storage pointer. The model
24592 @samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted
24593 models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch
24594 the thread pointer from the corresponding system register directly
24595 (supported from the arm6k architecture and later). These system registers
24596 are accessed through the CP15 co-processor interface and the argument
24597 @samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}.
24598 The argument @samp{auto} uses the best available method for the selected
24599 processor. The default setting is @samp{auto}.
24600
24601 @opindex mtls-dialect
24602 @item -mtls-dialect=@var{dialect}
24603 Specify the dialect to use for accessing thread local storage. Two
24604 @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
24605 @samp{gnu} dialect selects the original GNU scheme for supporting
24606 local and global dynamic TLS models. The @samp{gnu2} dialect
24607 selects the GNU descriptor scheme, which provides better performance
24608 for shared libraries. The GNU descriptor scheme is compatible with
24609 the original scheme, but does require new assembler, linker and
24610 library support. Initial and local exec TLS models are unaffected by
24611 this option and always use the original scheme.
24612
24613 @opindex mword-relocations
24614 @item -mword-relocations
24615 Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
24616 This is enabled by default on targets (uClinux, SymbianOS) where the runtime
24617 loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
24618 is specified. This option conflicts with @option{-mslow-flash-data}.
24619
24620 @opindex mfix-cortex-m3-ldrd
24621 @item -mfix-cortex-m3-ldrd
24622 Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
24623 with overlapping destination and base registers are used. This option avoids
24624 generating these instructions. This option is enabled by default when
24625 @option{-mcpu=cortex-m3} is specified.
24626
24627 @item -mfix-cortex-a57-aes-1742098
24628 @itemx -mno-fix-cortex-a57-aes-1742098
24629 @itemx -mfix-cortex-a72-aes-1655431
24630 @itemx -mno-fix-cortex-a72-aes-1655431
24631 Enable (disable) mitigation for an erratum on Cortex-A57 and
24632 Cortex-A72 that affects the AES cryptographic instructions. This
24633 option is enabled by default when either @option{-mcpu=cortex-a57} or
24634 @option{-mcpu=cortex-a72} is specified.
24635
24636 @opindex munaligned-access
24637 @opindex mno-unaligned-access
24638 @item -munaligned-access
24639 @itemx -mno-unaligned-access
24640 Enables (or disables) reading and writing of 16- and 32- bit values
24641 from addresses that are not 16- or 32- bit aligned. By default
24642 unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
24643 ARMv8-M Baseline architectures, and enabled for all other
24644 architectures. If unaligned access is not enabled then words in packed
24645 data structures are accessed a byte at a time.
24646
24647 The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
24648 generated object file to either true or false, depending upon the
24649 setting of this option. If unaligned access is enabled then the
24650 preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
24651 defined.
24652
24653 @opindex mneon-for-64bits
24654 @item -mneon-for-64bits
24655 This option is deprecated and has no effect.
24656
24657 @opindex mslow-flash-data
24658 @item -mslow-flash-data
24659 Assume loading data from flash is slower than fetching instruction.
24660 Therefore literal load is minimized for better performance.
24661 This option is only supported when compiling for ARMv7 M-profile and
24662 off by default. It conflicts with @option{-mword-relocations}.
24663
24664 @opindex masm-syntax-unified
24665 @item -masm-syntax-unified
24666 Assume inline assembler is using unified asm syntax. The default is
24667 currently off which implies divided syntax. This option has no impact
24668 on Thumb2. However, this may change in future releases of GCC.
24669 Divided syntax should be considered deprecated.
24670
24671 @opindex mrestrict-it
24672 @item -mrestrict-it
24673 Restricts generation of IT blocks to conform to the rules of ARMv8-A.
24674 IT blocks can only contain a single 16-bit instruction from a select
24675 set of instructions. This option is on by default for ARMv8-A Thumb mode.
24676
24677 @opindex mprint-tune-info
24678 @item -mprint-tune-info
24679 Print CPU tuning information as comment in assembler file. This is
24680 an option used only for regression testing of the compiler and not
24681 intended for ordinary use in compiling code. This option is disabled
24682 by default.
24683
24684 @opindex mverbose-cost-dump
24685 @item -mverbose-cost-dump
24686 Enable verbose cost model dumping in the debug dump files. This option is
24687 provided for use in debugging the compiler.
24688
24689 @opindex mpure-code
24690 @item -mpure-code
24691 Do not allow constant data to be placed in code sections.
24692 Additionally, when compiling for ELF object format give all text sections the
24693 ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
24694 is only available when generating non-pic code for M-profile targets.
24695
24696 @opindex mcmse
24697 @item -mcmse
24698 Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
24699 Development Tools Engineering Specification", which can be found on
24700 @url{https://developer.arm.com/documentation/ecm0359818/latest/}.
24701
24702 @opindex mfix-cmse-cve-2021-35465
24703 @item -mfix-cmse-cve-2021-35465
24704 Mitigate against a potential security issue with the @code{VLLDM} instruction
24705 in some M-profile devices when using CMSE (CVE-2021-365465). This option is
24706 enabled by default when the option @option{-mcpu=} is used with
24707 @code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m52}, @code{cortex-m55},
24708 @code{cortex-m85} or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465}
24709 can be used to disable the mitigation.
24710
24711 @opindex mstack-protector-guard
24712 @opindex mstack-protector-guard-offset
24713 @item -mstack-protector-guard=@var{guard}
24714 @itemx -mstack-protector-guard-offset=@var{offset}
24715 Generate stack protection code using canary at @var{guard}. Supported
24716 locations are @samp{global} for a global canary or @samp{tls} for a
24717 canary accessible via the TLS register. The option
24718 @option{-mstack-protector-guard-offset=} is for use with
24719 @option{-fstack-protector-guard=tls} and not for use in user-land code.
24720
24721 @opindex mfdpic
24722 @opindex mno-fdpic
24723 @item -mfdpic
24724 @itemx -mno-fdpic
24725 Select the FDPIC ABI, which uses 64-bit function descriptors to
24726 represent pointers to functions. When the compiler is configured for
24727 @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
24728 and implies @option{-fPIE} if none of the PIC/PIE-related options is
24729 provided. On other targets, it only enables the FDPIC-specific code
24730 generation features, and the user should explicitly provide the
24731 PIC/PIE-related options as needed.
24732
24733 Note that static linking is not supported because it would still
24734 involve the dynamic linker when the program self-relocates. If such
24735 behavior is acceptable, use -static and -Wl,-dynamic-linker options.
24736
24737 The opposite @option{-mno-fdpic} option is useful (and required) to
24738 build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
24739 toolchain as the one used to build the userland programs.
24740
24741 @opindex mbranch-protection
24742 @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
24743 Enable branch protection features (armv8.1-m.main only).
24744 @samp{none} generate code without branch protection or return address
24745 signing.
24746 @samp{standard[+@var{leaf}]} generate code with all branch protection
24747 features enabled at their standard level.
24748 @samp{pac-ret[+@var{leaf}]} generate code with return address signing
24749 set to its standard level, which is to sign all functions that save
24750 the return address to memory.
24751 @samp{leaf} When return address signing is enabled, also sign leaf
24752 functions even if they do not write the return address to memory.
24753 +@samp{bti} Add landing-pad instructions at the permitted targets of
24754 indirect branch instructions.
24755
24756 If the @samp{+pacbti} architecture extension is not enabled, then all
24757 branch protection and return address signing operations are
24758 constrained to use only the instructions defined in the
24759 architectural-NOP space. The generated code will remain
24760 backwards-compatible with earlier versions of the architecture, but
24761 the additional security can be enabled at run time on processors that
24762 support the @samp{PACBTI} extension.
24763
24764 Branch target enforcement using BTI can only be enabled at runtime if
24765 all code in the application has been compiled with at least
24766 @samp{-mbranch-protection=bti}.
24767
24768 Any setting other than @samp{none} is supported only on armv8-m.main
24769 or later.
24770
24771 The default is to generate code without branch protection or return
24772 address signing.
24773
24774 @end table
24775
24776 @node AVR Options
24777 @subsection AVR Options
24778 @cindex AVR Options
24779
24780 These options are defined for AVR implementations:
24781
24782 @table @gcctabopt
24783 @opindex mmcu
24784 @item -mmcu=@var{mcu}
24785 Specify the AVR instruction set architecture (ISA) or device type.
24786 The default for this option is@tie{}@code{avr2}.
24787
24788 The following AVR devices and ISAs are supported.
24789 @emph{Note:} A complete device support consists of
24790 startup code @code{crt@var{mcu}.o}, a device header @code{avr/io*.h},
24791 a device library @code{lib@var{mcu}.a} and a
24792 @uref{https://gcc.gnu.org/wiki/avr-gcc#spec-files,device-specs} file
24793 @code{specs-@var{mcu}}. Only the latter is provided by the compiler
24794 according the supported @code{@var{mcu}}s below. The rest is supported
24795 by @w{@uref{https://github.com/avrdudes/avr-libc/,AVR-LibC}}, or by means of
24796 @uref{https://gcc.gnu.org/wiki/avr-gcc#atpack,@code{atpack}} files
24797 from the hardware manufacturer.
24798
24799 @c Auto-generated. Re-build when new devices are added to avr-mcus.def
24800 @c by running "make avr-mcus" in $builddir/gcc.
24801 @include avr-mmcu.texi
24802
24803 @opindex mabsdata
24804 @item -mabsdata
24805
24806 Assume that all data in static storage can be accessed by LDS / STS
24807 instructions. This option has only an effect on reduced Tiny devices like
24808 ATtiny40. See also the @code{absdata}
24809 @ref{AVR Variable Attributes,variable attribute}.
24810
24811 @opindex mcvt
24812 @item -mcvt
24813 Use a @emph{compact vector table}. Some devices support a CVT
24814 with only four entries: 0=Reset, 1=NMI, 2=Prio1 IRQ, 3=Prio0 IRQs.
24815 This option will link startup code from @code{crt@var{mcu}-cvt.o}
24816 instead of the usual @code{crt@var{mcu}.o}.
24817 Apart from providing a compact vector table, the startup code will set bit
24818 @code{CPUINT_CTRLA.CPUINT_CVT} which enables the CVT on the device.
24819
24820 When you do not want the startup code to set @code{CPUINT_CTRLA.CPUINT_CVT},
24821 then you can satisfy symbol @code{__init_cvt} so that the respective
24822 code is no more pulled in from @code{lib@var{mcu}.a}.
24823 For example, you can link with @code{-Wl,--defsym,__init_cvt=0}.
24824
24825 The CVT startup code is available since
24826 @w{@uref{https://github.com/avrdudes/avr-libc/issues/1010,AVR-LibC v2.3}}.
24827
24828 @opindex mdouble
24829 @opindex mlong-double
24830 @item -mdouble=@var{bits}
24831 @itemx -mlong-double=@var{bits}
24832 Set the size (in bits) of the @code{double} or @code{long double} type,
24833 respectively. Possible values for @var{bits} are 32 and 64.
24834 Whether or not a specific value for @var{bits} is allowed depends on
24835 the @code{--with-double=} and @code{--with-long-double=}
24836 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
24837 and the same applies for the default values of the options.
24838
24839 @opindex mgas-isr-prologues
24840 @item -mgas-isr-prologues
24841 Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
24842 instruction supported by GNU Binutils.
24843 If this option is on, the feature can still be disabled for individual
24844 ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
24845 function attribute. This feature is activated per default
24846 if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
24847 and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
24848
24849 @opindex mint8
24850 @item -mint8
24851 Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
24852 @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
24853 and @code{long long} is 4 bytes. Please note that this option does not
24854 conform to the C standards, but it results in smaller code
24855 size.
24856
24857 @opindex mmain-is-OS_task
24858 @item -mmain-is-OS_task
24859 Do not save registers in @code{main}. The effect is the same like
24860 attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
24861 to @code{main}. It is activated per default if optimization is on.
24862
24863 @opindex mno-call-main
24864 @opindex mcall-main
24865 @item -mno-call-main
24866 Don't run @code{main} by means of
24867 @example
24868 XCALL main
24869 XJMP exit
24870 @end example
24871 Instead, put @code{main} in section
24872 @w{@uref{https://avrdudes.github.io/avr-libc/avr-libc-user-manual/mem_sections.html#sec_dot_init,@code{.init9}}}
24873 so that no call is required.
24874 By setting this option the user asserts that @code{main} will not return.
24875
24876 This option can be used for devices with very limited resources in order
24877 to save a few bytes of code and stack space. It will work as expected since
24878 @w{@uref{https://github.com/avrdudes/avr-libc/issues/1012,AVR-LibC v2.3}}.
24879 With older versions, there will be no performance gain.
24880
24881 @opindex mno-interrupts
24882 @item -mno-interrupts
24883 Generated code is not compatible with hardware interrupts.
24884 Code size is smaller.
24885
24886 @opindex mrelax
24887 @item -mrelax
24888 Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
24889 @code{RCALL} resp.@: @code{RJMP} instruction if applicable.
24890 Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
24891 the assembler's command line and the @option{--relax} option to the
24892 linker's command line.
24893
24894 Jump relaxing is performed by the linker because jump offsets are not
24895 known before code is located. Therefore, the assembler code generated by the
24896 compiler is the same, but the instructions in the executable may
24897 differ from instructions in the assembler code.
24898
24899 Relaxing must be turned on if linker stubs are needed, see the
24900 section on @code{EIND} and linker stubs below.
24901
24902 @opindex mrodata-in-ram
24903 @item -mrodata-in-ram
24904 @itemx -mno-rodata-in-ram
24905 Locate the @code{.rodata} sections for read-only data in RAM resp.@:
24906 in program memory.
24907 For most devices, there is no choice and this option acts rather
24908 like an assertion.
24909
24910 Since v14 and for the AVR64* and AVR128* devices, @code{.rodata}
24911 is located in flash memory per default, provided the required GNU Binutils
24912 support (@w{@uref{https://sourceware.org/PR31124,PR31124}}) is available.
24913 In that case, @option{-mrodata-in-ram} can be used to return to the old
24914 layout with @code{.rodata} in RAM.
24915
24916 @opindex mtiny-stack
24917 @item -mtiny-stack
24918 Only change the lower 8@tie{}bits of the stack pointer.
24919
24920 @opindex mfract-convert-truncate
24921 @item -mfract-convert-truncate
24922 Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
24923
24924 @opindex nodevicelib
24925 @item -nodevicelib
24926 Don't link against AVR-LibC's device specific library @code{lib@var{mcu}.a}.
24927
24928 Notice that since AVR-LibC v2.3, that library contains code that is
24929 essential for the correct functioning of a program. In particular,
24930 it contains parts of the startup code like:
24931 @w{@uref{https://github.com/avrdudes/avr-libc/issues/1011,@code{__init_sp}}}
24932 to initialize the stack pointer with symbol @code{__stack},
24933 @w{@uref{https://github.com/avrdudes/avr-libc/issues/1010,@code{__init_cvt}}}
24934 to set up the hardware to use a compact vector table with @option{-mcvt},
24935 @w{@uref{https://github.com/avrdudes/avr-libc/issues/1012,@code{__call_main}}}
24936 to call @code{main} and @code{exit}, and
24937 @w{@uref{https://github.com/avrdudes/avr-libc/issues/931,@code{__do_flmap_init}}}
24938 to set up FLMAP according to symbol @code{__flmap}.
24939
24940 @opindex nodevicespecs
24941 @item -nodevicespecs
24942 Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
24943 command line. The user takes responsibility for supplying the sub-processes
24944 like compiler proper, assembler and linker with appropriate command line
24945 options. This means that the user has to supply her private device specs
24946 file by means of @option{-specs=@var{path-to-specs-file}}. There is no
24947 more need for option @option{-mmcu=@var{mcu}}.
24948
24949 This option can also serve as a replacement for the older way of
24950 specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
24951 which contains a folder named @code{device-specs} which contains a specs file named
24952 @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
24953
24954 @opindex Waddr-space-convert
24955 @opindex Wno-addr-space-convert
24956 @item -Waddr-space-convert
24957 Warn about conversions between address spaces in the case where the
24958 resulting address space is not contained in the incoming address space.
24959
24960 @opindex Wmisspelled-isr
24961 @opindex Wno-misspelled-isr
24962 @item -Wmisspelled-isr
24963 Warn if the ISR is misspelled, i.e.@: without __vector prefix.
24964 Enabled by default.
24965 @end table
24966
24967
24968 @subsubsection AVR Optimization Options
24969 The following options are pure optimization options.
24970 Options @option{-mgas-isr-prologues}, @option{-mmain-is-OS_task},
24971 @option{-mno-call-main} and @option{-mrelax} from above are only
24972 @emph{almost} optimization options, since there are rare occasions
24973 where their different code generation matters.
24974
24975 @table @gcctabopt
24976 @opindex maccumulate-args
24977 @item -maccumulate-args
24978 Accumulate outgoing function arguments and acquire/release the needed
24979 stack space for outgoing function arguments once in function
24980 prologue/epilogue. Without this option, outgoing arguments are pushed
24981 before calling a function and popped afterwards.
24982 See also the @option{-fdefer-pop}
24983 @ref{Optimize Options,,optimization option}.
24984
24985 Popping the arguments after the function call can be expensive on
24986 AVR so that accumulating the stack space might lead to smaller
24987 executables because arguments need not be removed from the
24988 stack after such a function call.
24989
24990 This option can lead to reduced code size for functions that perform
24991 several calls to functions that get their arguments on the stack like
24992 calls to printf-like functions.
24993
24994 @opindex mbranch-cost
24995 @item -mbranch-cost=@var{cost}
24996 Set the branch costs for conditional branch instructions to
24997 @var{cost}. Reasonable values for @var{cost} are small, non-negative
24998 integers. The default branch cost is 0.
24999
25000 @opindex mcall-prologues
25001 @item -mcall-prologues
25002 Functions prologues/epilogues are expanded as calls to appropriate
25003 subroutines. Code size is smaller.
25004
25005 @opindex mfuse-add
25006 @item -mfuse-add
25007 @itemx -mno-fuse-add
25008 @itemx -mfuse-add=@var{level}
25009 Optimize indirect memory accesses on reduced Tiny devices.
25010 The default uses @code{@var{level}=1} for optimizations @option{-Og}
25011 and @option{-O1}, and @code{@var{level}=2} for higher optimizations.
25012 Valid values for @var{level} are @code{0}, @code{1} and @code{2}.
25013
25014 @opindex mfuse-move
25015 @item -mfuse-move
25016 @itemx -mno-fuse-move
25017 @itemx -mfuse-move=@var{level}
25018 Run a post reload optimization pass that tries to fuse move instructions
25019 and to split multi-byte instructions into 8-bit operations.
25020 The default uses @code{@var{level}=3} for optimization @option{-O1},
25021 and @code{@var{level}=23} for higher optimizations.
25022 Valid values for @var{level} are in the range @code{0} @dots{} @code{23}
25023 which is a 3:2:2:2 mixed radix value. Each digit controls some
25024 aspect of the optimization.
25025
25026 @opindex mstrict-X
25027 @item -mstrict-X
25028 Use address register @code{X} in a way proposed by the hardware. This means
25029 that @code{X} is only used in indirect, post-increment or
25030 pre-decrement addressing.
25031
25032 Without this option, the @code{X} register may be used in the same way
25033 as @code{Y} or @code{Z} which then is emulated by additional
25034 instructions.
25035 For example, loading a value with @code{X+const} addressing with a
25036 small non-negative @code{const < 64} to a register @var{Rn} is
25037 performed as
25038
25039 @example
25040 adiw r26, const ; X += const
25041 ld @var{Rn}, X ; @var{Rn} = *X
25042 sbiw r26, const ; X -= const
25043 @end example
25044
25045 @opindex msplit-bit-shift
25046 @item -msplit-bit-shift
25047 Split multi-byte shifts with a constant offset into a shift with
25048 a byte offset and a residual shift with a non-byte offset.
25049 This optimization is turned on per default for @option{-O2} and higher,
25050 including @option{-Os} but excluding @option{-Oz}.
25051 Splitting of shifts with a constant offset that is
25052 a multiple of 8 is controlled by @option{-mfuse-move}.
25053
25054 @opindex msplit-ldst
25055 @item -msplit-ldst
25056 Split multi-byte loads and stores into several byte loads and stores.
25057 This optimization is turned on per default for @option{-O2} and higher.
25058
25059 @opindex muse-nonzero-bits
25060 @item -muse-nonzero-bits
25061 Enable optimizations that are only possible when some bits in a
25062 register are always zero.
25063 This optimization is turned on per default for @option{-O2} and higher.
25064
25065 @end table
25066
25067 @anchor{eind}
25068 @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
25069 @cindex @code{EIND}
25070 Pointers in the implementation are 16@tie{}bits wide.
25071 The address of a function or label is represented as word address so
25072 that indirect jumps and calls can target any code address in the
25073 range of 64@tie{}Ki words.
25074
25075 In order to facilitate indirect jump on devices with more than 128@tie{}Ki
25076 bytes of program memory space, there is a special function register called
25077 @code{EIND} that serves as most significant part of the target address
25078 when @code{EICALL} or @code{EIJMP} instructions are used.
25079
25080 Indirect jumps and calls on these devices are handled as follows by
25081 the compiler and are subject to some limitations:
25082
25083 @itemize @bullet
25084
25085 @item
25086 The compiler never sets @code{EIND}.
25087
25088 @item
25089 The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
25090 instructions or might read @code{EIND} directly in order to emulate an
25091 indirect call/jump by means of a @code{RET} instruction.
25092
25093 @item
25094 The compiler assumes that @code{EIND} never changes during the startup
25095 code or during the application. In particular, @code{EIND} is not
25096 saved/restored in function or interrupt service routine
25097 prologue/epilogue.
25098
25099 @item
25100 For indirect calls to functions and computed goto, the linker
25101 generates @emph{stubs}. Stubs are jump pads sometimes also called
25102 @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
25103 The stub contains a direct jump to the desired address.
25104
25105 @item
25106 Linker relaxation must be turned on so that the linker generates
25107 the stubs correctly in all situations. See the compiler option
25108 @option{-mrelax} and the linker option @option{--relax}.
25109 There are corner cases where the linker is supposed to generate stubs
25110 but aborts without relaxation and without a helpful error message.
25111
25112 @item
25113 The default linker script is arranged for code with @code{EIND = 0}.
25114 If code is supposed to work for a setup with @code{EIND != 0}, a custom
25115 linker script has to be used in order to place the sections whose
25116 name start with @code{.trampolines} into the segment where @code{EIND}
25117 points to.
25118
25119 @item
25120 The startup code from libgcc never sets @code{EIND}.
25121 Notice that startup code is a blend of code from libgcc and AVR-LibC.
25122 For the impact of AVR-LibC on @code{EIND}, see the
25123 @w{@uref{https://avrdudes.github.io/avr-libc/avr-libc-user-manual/,AVR-LibC user manual}}.
25124
25125 @item
25126 It is legitimate for user-specific startup code to set up @code{EIND}
25127 early, for example by means of initialization code located in
25128 section @code{.init3}. Such code runs prior to general startup code
25129 that initializes RAM and calls constructors, but after the bit
25130 of startup code from AVR-LibC that sets @code{EIND} to the segment
25131 where the vector table is located.
25132 @example
25133 #include <avr/io.h>
25134
25135 static void
25136 __attribute__((section(".init3"),naked,used,no_instrument_function))
25137 init3_set_eind (void)
25138 @{
25139 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
25140 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
25141 @}
25142 @end example
25143
25144 @noindent
25145 The @code{__trampolines_start} symbol is defined in the linker script.
25146
25147 @item
25148 Stubs are generated automatically by the linker if
25149 the following two conditions are met:
25150 @itemize @minus
25151
25152 @item The address of a label is taken by means of the @code{gs} modifier
25153 (short for @emph{generate stubs}) like so:
25154 @example
25155 LDI r24, lo8(gs(@var{func}))
25156 LDI r25, hi8(gs(@var{func}))
25157 @end example
25158 @item The final location of that label is in a code segment
25159 @emph{outside} the segment where the stubs are located.
25160 @end itemize
25161
25162 @item
25163 The compiler emits such @code{gs} modifiers for code labels in the
25164 following situations:
25165 @itemize @minus
25166 @item Taking address of a function or code label.
25167 @item Computed goto.
25168 @item If prologue-save function is used, see @option{-mcall-prologues}
25169 command-line option.
25170 @item Switch/case dispatch tables. If you do not want such dispatch
25171 tables you can specify the @option{-fno-jump-tables} command-line option.
25172 @item C and C++ constructors/destructors called during startup/shutdown.
25173 @item If the tools hit a @code{gs()} modifier explained above.
25174 @end itemize
25175
25176 @item
25177 Jumping to non-symbolic addresses like so is @emph{not} supported:
25178
25179 @example
25180 int main (void)
25181 @{
25182 /* Call function at word address 0x2 */
25183 return ((int(*)(void)) 0x2)();
25184 @}
25185 @end example
25186
25187 Instead, a stub has to be set up, i.e.@: the function has to be called
25188 through a symbol (@code{func_4} in the example):
25189
25190 @example
25191 int main (void)
25192 @{
25193 extern int func_4 (void);
25194
25195 /* Call function at byte address 0x4 */
25196 return func_4();
25197 @}
25198 @end example
25199
25200 and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
25201 Alternatively, @code{func_4} can be defined in the linker script.
25202 @end itemize
25203
25204 @anchor{ramp}
25205 @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
25206 @cindex @code{RAMPD}
25207 @cindex @code{RAMPX}
25208 @cindex @code{RAMPY}
25209 @cindex @code{RAMPZ}
25210 Some AVR devices support memories larger than the 64@tie{}KiB range
25211 that can be accessed with 16-bit pointers. To access memory locations
25212 outside this 64@tie{}KiB range, the content of a @code{RAMP}
25213 register is used as high part of the address:
25214 The @code{X}, @code{Y}, @code{Z} address register is concatenated
25215 with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
25216 register, respectively, to get a wide address. Similarly,
25217 @code{RAMPD} is used together with direct addressing.
25218
25219 @itemize
25220 @item
25221 The startup code initializes the @code{RAMP} special function
25222 registers with zero.
25223
25224 @item
25225 If a @ref{AVR Named Address Spaces,named address space} other than
25226 generic or @code{__flash} is used, then @code{RAMPZ} is set
25227 as needed before the operation.
25228
25229 @item
25230 If the device supports RAM larger than 64@tie{}KiB and the compiler
25231 needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
25232 is reset to zero after the operation.
25233
25234 @item
25235 If the device comes with a specific @code{RAMP} register, the ISR
25236 prologue/epilogue saves/restores that SFR and initializes it with
25237 zero in case the ISR code might (implicitly) use it.
25238
25239 @item
25240 RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
25241 If you use inline assembler to read from locations outside the
25242 16-bit address range and change one of the @code{RAMP} registers,
25243 you must reset it to zero after the access.
25244
25245 @end itemize
25246
25247 @anchor{avr-macros}
25248 @subsubsection AVR Built-in Macros
25249
25250 GCC defines several built-in macros so that the user code can test
25251 for the presence or absence of features. Almost any of the following
25252 built-in macros are deduced from device capabilities and thus
25253 triggered by the @option{-mmcu=} command-line option.
25254
25255 For even more AVR-specific built-in macros see
25256 @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
25257
25258 @table @code
25259
25260 @item __AVR_ARCH__
25261 Build-in macro that resolves to a decimal number that identifies the
25262 architecture and depends on the @option{-mmcu=@var{mcu}} option.
25263 Possible values are:
25264
25265 @code{2}, @code{25}, @code{3}, @code{31}, @code{35},
25266 @code{4}, @code{5}, @code{51}, @code{6}
25267
25268 for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
25269 @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
25270
25271 respectively and
25272
25273 @code{100},
25274 @code{102}, @code{103}, @code{104},
25275 @code{105}, @code{106}, @code{107}
25276
25277 for @var{mcu}=@code{avrtiny},
25278 @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
25279 @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
25280 If @var{mcu} specifies a device, this built-in macro is set
25281 accordingly. For example, with @option{-mmcu=atmega8} the macro is
25282 defined to @code{4}.
25283
25284 @item __AVR_@var{Device}__
25285 Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
25286 the device's name. For example, @option{-mmcu=atmega8} defines the
25287 built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
25288 @code{__AVR_ATtiny261A__}, etc.
25289
25290 The built-in macros' names follow
25291 the scheme @code{__AVR_@var{Device}__} where @var{Device} is
25292 the device name as from the AVR user manual. The difference between
25293 @var{Device} in the built-in macro and @var{device} in
25294 @option{-mmcu=@var{device}} is that the latter is always lowercase.
25295
25296 If @var{device} is not a device but only a core architecture like
25297 @samp{avr51}, this macro is not defined.
25298
25299 @item __AVR_DEVICE_NAME__
25300 Setting @option{-mmcu=@var{device}} defines this built-in macro to
25301 the device's name. For example, with @option{-mmcu=atmega8} the macro
25302 is defined to @code{atmega8}.
25303
25304 If @var{device} is not a device but only a core architecture like
25305 @samp{avr51}, this macro is not defined.
25306
25307 @item __AVR_CVT__
25308 The code is being compiled with option @code{-mcvt} to use a
25309 @emph{compact vector table}.
25310
25311 @item __AVR_XMEGA__
25312 The device / architecture belongs to the XMEGA family of devices.
25313
25314 @item __AVR_HAVE_ADIW__
25315 The device has the @code{ADIW} and @code{SBIW} instructions.
25316
25317 @item __AVR_HAVE_ELPM__
25318 The device has the @code{ELPM} instruction.
25319
25320 @item __AVR_HAVE_ELPMX__
25321 The device has the @code{ELPM R@var{n},Z} and @code{ELPM
25322 R@var{n},Z+} instructions.
25323
25324 @item __AVR_HAVE_LPMX__
25325 The device has the @code{LPM R@var{n},Z} and
25326 @code{LPM R@var{n},Z+} instructions.
25327
25328 @item __AVR_HAVE_MOVW__
25329 The device has the @code{MOVW} instruction to perform 16-bit
25330 register-register moves.
25331
25332 @item __AVR_HAVE_MUL__
25333 The device has a hardware multiplier.
25334
25335 @item __AVR_HAVE_JMP_CALL__
25336 The device has the @code{JMP} and @code{CALL} instructions.
25337 This is the case for devices with more than 8@tie{}KiB of program
25338 memory.
25339
25340 @item __AVR_HAVE_EIJMP_EICALL__
25341 @itemx __AVR_3_BYTE_PC__
25342 The device has the @code{EIJMP} and @code{EICALL} instructions.
25343 This is the case for devices with more than 128@tie{}KiB of program memory.
25344 This also means that the program counter
25345 (PC) is 3@tie{}bytes wide.
25346
25347 @item __AVR_2_BYTE_PC__
25348 The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
25349 with up to 128@tie{}KiB of program memory.
25350
25351 @item __AVR_HAVE_8BIT_SP__
25352 @itemx __AVR_HAVE_16BIT_SP__
25353 The stack pointer (SP) register is treated as 8-bit respectively
25354 16-bit register by the compiler.
25355 The definition of these macros is affected by @option{-mtiny-stack}.
25356
25357 @item __AVR_HAVE_SPH__
25358 @itemx __AVR_SP8__
25359 The device has the SPH (high part of stack pointer) special function
25360 register or has an 8-bit stack pointer, respectively.
25361 The definition of these macros is affected by @option{-mmcu=} and
25362 in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
25363 by @option{-msp8}.
25364
25365 @item __AVR_HAVE_RAMPD__
25366 @itemx __AVR_HAVE_RAMPX__
25367 @itemx __AVR_HAVE_RAMPY__
25368 @itemx __AVR_HAVE_RAMPZ__
25369 The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
25370 @code{RAMPZ} special function register, respectively.
25371
25372 @item __NO_INTERRUPTS__
25373 This macro reflects the @option{-mno-interrupts} command-line option.
25374
25375 @item __AVR_ERRATA_SKIP__
25376 @itemx __AVR_ERRATA_SKIP_JMP_CALL__
25377 Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
25378 instructions because of a hardware erratum. Skip instructions are
25379 @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
25380 The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
25381 set.
25382
25383 @item __AVR_ISA_RMW__
25384 The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
25385
25386 @item __AVR_SFR_OFFSET__=@var{offset}
25387 Instructions that can address I/O special function registers directly
25388 like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
25389 address as if addressed by an instruction to access RAM like @code{LD}
25390 or @code{STS}. This offset depends on the device architecture and has
25391 to be subtracted from the RAM address in order to get the
25392 respective I/O@tie{}address.
25393
25394 @item __AVR_SHORT_CALLS__
25395 The @option{-mshort-calls} command line option is set.
25396
25397 @item __AVR_PM_BASE_ADDRESS__=@var{addr}
25398 Some devices support reading from flash memory by means of @code{LD*}
25399 instructions. The flash memory is seen in the data address space
25400 at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
25401 is not defined, this feature is not available. If defined,
25402 the address space is linear and there is no need to put
25403 @code{.rodata} into RAM. This is handled by the default linker
25404 description file, and is currently available for
25405 @code{avrtiny} and @code{avrxmega3}. Even more convenient,
25406 there is no need to use address spaces like @code{__flash} or
25407 features like attribute @code{progmem} and @code{pgm_read_*}.
25408
25409 @item __AVR_HAVE_FLMAP__
25410 This macro is defined provided the following conditions are met:
25411 @itemize @bullet
25412 @item The device has the @code{NVMCTRL_CTRLB.FLMAP} bitfield.
25413 This applies to the AVR64* and AVR128* devices.
25414 @item It's not known at assembler-time which emulation will be used.
25415 @end itemize
25416 This implies the compiler was configured with GNU Binutils that implement
25417 @w{@uref{https://sourceware.org/PR31124,PR31124}}.
25418
25419 @item __AVR_RODATA_IN_RAM__
25420 This macro is undefined when the code is compiled for a core architecture.
25421
25422 When the code is compiled for a device, the macro is defined to@tie{}1
25423 when the @code{.rodata} sections for read-only data is located in RAM;
25424 and defined to@tie{}0, otherwise.
25425
25426 @item __WITH_AVRLIBC__
25427 The compiler is configured to be used together with AVR-LibC.
25428 See the @option{--with-avrlibc} configure option.
25429
25430 @item __HAVE_SIGNAL_N__
25431 The compiler supports the @code{signal(@var{num})} and
25432 @code{interrupt(@var{num})}
25433 @ref{AVR Function Attributes,,function attributes}
25434 with an argument @var{num} that specifies the number of the
25435 interrupt service routine.
25436
25437 @item __HAVE_DOUBLE_MULTILIB__
25438 Defined if @option{-mdouble=} acts as a multilib option.
25439
25440 @item __HAVE_DOUBLE32__
25441 @itemx __HAVE_DOUBLE64__
25442 Defined if the compiler supports 32-bit double resp. 64-bit double.
25443 The actual layout is specified by option @option{-mdouble=}.
25444
25445 @item __DEFAULT_DOUBLE__
25446 The size in bits of @code{double} if @option{-mdouble=} is not set.
25447 To test the layout of @code{double} in a program, use the built-in
25448 macro @code{__SIZEOF_DOUBLE__}.
25449
25450 @item __HAVE_LONG_DOUBLE32__
25451 @itemx __HAVE_LONG_DOUBLE64__
25452 @itemx __HAVE_LONG_DOUBLE_MULTILIB__
25453 @itemx __DEFAULT_LONG_DOUBLE__
25454 Same as above, but for @code{long double} instead of @code{double}.
25455
25456 @item __WITH_DOUBLE_COMPARISON__
25457 Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
25458 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
25459 and is defined to @code{2} or @code{3}.
25460
25461 @item __WITH_LIBF7_LIBGCC__
25462 @itemx __WITH_LIBF7_MATH__
25463 @itemx __WITH_LIBF7_MATH_SYMBOLS__
25464 Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
25465 @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
25466
25467 @end table
25468
25469 @subsubsection AVR Internal Options
25470 The following options are used internally by the compiler and to communicate
25471 between device specs files and the compiler proper. You don't need to set these
25472 options by hand, in particular they are not optimization options.
25473 Using these options in the wrong way may lead to sub-optimal or wrong code.
25474 They are documented for completeness, and in order to get a better
25475 understanding of
25476 @w{@uref{https://gcc.gnu.org/wiki/avr-gcc#spec-files,device specs}}
25477 files.
25478
25479 @table @gcctabopt
25480
25481 @opindex mn-flash
25482 @item -mn-flash=@var{num}
25483 Assume that the flash memory has a size of @var{num} times 64@tie{}KiB.
25484 This determines which @code{__flash@var{N}} address spaces are available.
25485
25486 @opindex mflmap
25487 @item -mflmap
25488 The device has the @code{FLMAP} bit field located in special function
25489 register @code{NVMCTRL_CTRLB}.
25490
25491 @opindex mrmw
25492 @item -mrmw
25493 Assume that the device supports the Read-Modify-Write
25494 instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
25495
25496 @opindex mshort-calls
25497 @item -mshort-calls
25498
25499 Assume that @code{RJMP} and @code{RCALL} can target the whole
25500 program memory. This option is used for multilib generation and selection
25501 for the devices from architecture @code{avrxmega3}.
25502
25503 @opindex mskip-bug
25504 @item -mskip-bug
25505
25506 Generate code without skips (@code{CPSE}, @code{SBRS},
25507 @code{SBRC}, @code{SBIS}, @code{SBIC}) over 32-bit instructions.
25508
25509 @opindex msp8
25510 @item -msp8
25511 Treat the stack pointer register as an 8-bit register,
25512 i.e.@: assume the high byte of the stack pointer is zero.
25513 This option is used by the compiler to select and
25514 build multilibs for architectures @code{avr2} and @code{avr25}.
25515 These architectures mix devices with and without @code{SPH}.
25516
25517 @end table
25518
25519 @node Blackfin Options
25520 @subsection Blackfin Options
25521 @cindex Blackfin Options
25522
25523 @table @gcctabopt
25524 @opindex mcpu=
25525 @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
25526 Specifies the name of the target Blackfin processor. Currently, @var{cpu}
25527 can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
25528 @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
25529 @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
25530 @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
25531 @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
25532 @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
25533 @samp{bf561}, @samp{bf592}.
25534
25535 The optional @var{sirevision} specifies the silicon revision of the target
25536 Blackfin processor. Any workarounds available for the targeted silicon revision
25537 are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
25538 If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
25539 are enabled. The @code{__SILICON_REVISION__} macro is defined to two
25540 hexadecimal digits representing the major and minor numbers in the silicon
25541 revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
25542 is not defined. If @var{sirevision} is @samp{any}, the
25543 @code{__SILICON_REVISION__} is defined to be @code{0xffff}.
25544 If this optional @var{sirevision} is not used, GCC assumes the latest known
25545 silicon revision of the targeted Blackfin processor.
25546
25547 GCC defines a preprocessor macro for the specified @var{cpu}.
25548 For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
25549 provided by libgloss to be linked in if @option{-msim} is not given.
25550
25551 Without this option, @samp{bf532} is used as the processor by default.
25552
25553 Note that support for @samp{bf561} is incomplete. For @samp{bf561},
25554 only the preprocessor macro is defined.
25555
25556 @opindex msim
25557 @item -msim
25558 Specifies that the program will be run on the simulator. This causes
25559 the simulator BSP provided by libgloss to be linked in. This option
25560 has effect only for @samp{bfin-elf} toolchain.
25561 Certain other options, such as @option{-mid-shared-library} and
25562 @option{-mfdpic}, imply @option{-msim}.
25563
25564 @opindex momit-leaf-frame-pointer
25565 @item -momit-leaf-frame-pointer
25566 Don't keep the frame pointer in a register for leaf functions. This
25567 avoids the instructions to save, set up and restore frame pointers and
25568 makes an extra register available in leaf functions.
25569
25570 @opindex mspecld-anomaly
25571 @item -mspecld-anomaly
25572 When enabled, the compiler ensures that the generated code does not
25573 contain speculative loads after jump instructions. If this option is used,
25574 @code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
25575
25576 @opindex mno-specld-anomaly
25577 @opindex mspecld-anomaly
25578 @item -mno-specld-anomaly
25579 Don't generate extra code to prevent speculative loads from occurring.
25580
25581 @opindex mcsync-anomaly
25582 @item -mcsync-anomaly
25583 When enabled, the compiler ensures that the generated code does not
25584 contain CSYNC or SSYNC instructions too soon after conditional branches.
25585 If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
25586
25587 @opindex mno-csync-anomaly
25588 @opindex mcsync-anomaly
25589 @item -mno-csync-anomaly
25590 Don't generate extra code to prevent CSYNC or SSYNC instructions from
25591 occurring too soon after a conditional branch.
25592
25593 @opindex mlow64k
25594 @item -mlow64k
25595 When enabled, the compiler is free to take advantage of the knowledge that
25596 the entire program fits into the low 64k of memory.
25597
25598 @opindex mno-low64k
25599 @item -mno-low64k
25600 Assume that the program is arbitrarily large. This is the default.
25601
25602 @opindex mstack-check-l1
25603 @item -mstack-check-l1
25604 Do stack checking using information placed into L1 scratchpad memory by the
25605 uClinux kernel.
25606
25607 @opindex mid-shared-library
25608 @item -mid-shared-library
25609 Generate code that supports shared libraries via the library ID method.
25610 This allows for execute in place and shared libraries in an environment
25611 without virtual memory management. This option implies @option{-fPIC}.
25612 With a @samp{bfin-elf} target, this option implies @option{-msim}.
25613
25614 @opindex mno-id-shared-library
25615 @opindex mid-shared-library
25616 @item -mno-id-shared-library
25617 Generate code that doesn't assume ID-based shared libraries are being used.
25618 This is the default.
25619
25620 @opindex mleaf-id-shared-library
25621 @item -mleaf-id-shared-library
25622 Generate code that supports shared libraries via the library ID method,
25623 but assumes that this library or executable won't link against any other
25624 ID shared libraries. That allows the compiler to use faster code for jumps
25625 and calls.
25626
25627 @opindex mno-leaf-id-shared-library
25628 @opindex mleaf-id-shared-library
25629 @item -mno-leaf-id-shared-library
25630 Do not assume that the code being compiled won't link against any ID shared
25631 libraries. Slower code is generated for jump and call insns.
25632
25633 @opindex mshared-library-id
25634 @item -mshared-library-id=n
25635 Specifies the identification number of the ID-based shared library being
25636 compiled. Specifying a value of 0 generates more compact code; specifying
25637 other values forces the allocation of that number to the current
25638 library but is no more space- or time-efficient than omitting this option.
25639
25640 @opindex msep-data
25641 @item -msep-data
25642 Generate code that allows the data segment to be located in a different
25643 area of memory from the text segment. This allows for execute in place in
25644 an environment without virtual memory management by eliminating relocations
25645 against the text section.
25646
25647 @opindex mno-sep-data
25648 @opindex msep-data
25649 @item -mno-sep-data
25650 Generate code that assumes that the data segment follows the text segment.
25651 This is the default.
25652
25653 @opindex mlong-calls
25654 @opindex mno-long-calls
25655 @item -mlong-calls
25656 @itemx -mno-long-calls
25657 Tells the compiler to perform function calls by first loading the
25658 address of the function into a register and then performing a subroutine
25659 call on this register. This switch is needed if the target function
25660 lies outside of the 24-bit addressing range of the offset-based
25661 version of subroutine call instruction.
25662
25663 This feature is not enabled by default. Specifying
25664 @option{-mno-long-calls} restores the default behavior. Note these
25665 switches have no effect on how the compiler generates code to handle
25666 function calls via function pointers.
25667
25668 @opindex mfast-fp
25669 @item -mfast-fp
25670 Link with the fast floating-point library. This library relaxes some of
25671 the IEEE floating-point standard's rules for checking inputs against
25672 Not-a-Number (NAN), in the interest of performance.
25673
25674 @opindex minline-plt
25675 @item -minline-plt
25676 Enable inlining of PLT entries in function calls to functions that are
25677 not known to bind locally. It has no effect without @option{-mfdpic}.
25678
25679 @opindex mmulticore
25680 @item -mmulticore
25681 Build a standalone application for multicore Blackfin processors.
25682 This option causes proper start files and link scripts supporting
25683 multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
25684 It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
25685
25686 This option can be used with @option{-mcorea} or @option{-mcoreb}, which
25687 selects the one-application-per-core programming model. Without
25688 @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
25689 programming model is used. In this model, the main function of Core B
25690 should be named as @code{coreb_main}.
25691
25692 If this option is not used, the single-core application programming
25693 model is used.
25694
25695 @opindex mcorea
25696 @item -mcorea
25697 Build a standalone application for Core A of BF561 when using
25698 the one-application-per-core programming model. Proper start files
25699 and link scripts are used to support Core A, and the macro
25700 @code{__BFIN_COREA} is defined.
25701 This option can only be used in conjunction with @option{-mmulticore}.
25702
25703 @opindex mcoreb
25704 @item -mcoreb
25705 Build a standalone application for Core B of BF561 when using
25706 the one-application-per-core programming model. Proper start files
25707 and link scripts are used to support Core B, and the macro
25708 @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
25709 should be used instead of @code{main}.
25710 This option can only be used in conjunction with @option{-mmulticore}.
25711
25712 @opindex msdram
25713 @item -msdram
25714 Build a standalone application for SDRAM. Proper start files and
25715 link scripts are used to put the application into SDRAM, and the macro
25716 @code{__BFIN_SDRAM} is defined.
25717 The loader should initialize SDRAM before loading the application.
25718
25719 @opindex micplb
25720 @item -micplb
25721 Assume that ICPLBs are enabled at run time. This has an effect on certain
25722 anomaly workarounds. For Linux targets, the default is to assume ICPLBs
25723 are enabled; for standalone applications the default is off.
25724 @end table
25725
25726 @node C6X Options
25727 @subsection C6X Options
25728 @cindex C6X Options
25729
25730 @table @gcctabopt
25731 @opindex march
25732 @item -march=@var{name}
25733 This specifies the name of the target architecture. GCC uses this
25734 name to determine what kind of instructions it can emit when generating
25735 assembly code. Permissible names are: @samp{c62x},
25736 @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
25737
25738 @opindex mbig-endian
25739 @item -mbig-endian
25740 Generate code for a big-endian target.
25741
25742 @opindex mlittle-endian
25743 @item -mlittle-endian
25744 Generate code for a little-endian target. This is the default.
25745
25746 @opindex msim
25747 @item -msim
25748 Choose startup files and linker script suitable for the simulator.
25749
25750 @opindex msdata=default
25751 @item -msdata=default
25752 Put small global and static data in the @code{.neardata} section,
25753 which is pointed to by register @code{B14}. Put small uninitialized
25754 global and static data in the @code{.bss} section, which is adjacent
25755 to the @code{.neardata} section. Put small read-only data into the
25756 @code{.rodata} section. The corresponding sections used for large
25757 pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
25758
25759 @opindex msdata=all
25760 @item -msdata=all
25761 Put all data, not just small objects, into the sections reserved for
25762 small data, and use addressing relative to the @code{B14} register to
25763 access them.
25764
25765 @opindex msdata=none
25766 @item -msdata=none
25767 Make no use of the sections reserved for small data, and use absolute
25768 addresses to access all data. Put all initialized global and static
25769 data in the @code{.fardata} section, and all uninitialized data in the
25770 @code{.far} section. Put all constant data into the @code{.const}
25771 section.
25772 @end table
25773
25774 @node CRIS Options
25775 @subsection CRIS Options
25776 @cindex CRIS Options
25777
25778 These options are defined specifically for the CRIS ports.
25779
25780 @table @gcctabopt
25781 @opindex march
25782 @opindex mcpu
25783 @item -march=@var{architecture-type}
25784 @itemx -mcpu=@var{architecture-type}
25785 Generate code for the specified architecture. The choices for
25786 @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
25787 respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
25788 Default is @samp{v0}.
25789
25790 @opindex mtune
25791 @item -mtune=@var{architecture-type}
25792 Tune to @var{architecture-type} everything applicable about the generated
25793 code, except for the ABI and the set of available instructions. The
25794 choices for @var{architecture-type} are the same as for
25795 @option{-march=@var{architecture-type}}.
25796
25797 @opindex mmax-stack-frame
25798 @item -mmax-stack-frame=@var{n}
25799 Warn when the stack frame of a function exceeds @var{n} bytes.
25800
25801 @opindex metrax4
25802 @opindex metrax100
25803 @item -metrax4
25804 @itemx -metrax100
25805 The options @option{-metrax4} and @option{-metrax100} are synonyms for
25806 @option{-march=v3} and @option{-march=v8} respectively.
25807
25808 @opindex mmul-bug-workaround
25809 @opindex mno-mul-bug-workaround
25810 @item -mmul-bug-workaround
25811 @itemx -mno-mul-bug-workaround
25812 Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
25813 models where it applies. This option is disabled by default.
25814
25815 @opindex mpdebug
25816 @item -mpdebug
25817 Enable CRIS-specific verbose debug-related information in the assembly
25818 code. This option also has the effect of turning off the @samp{#NO_APP}
25819 formatted-code indicator to the assembler at the beginning of the
25820 assembly file.
25821
25822 @opindex mcc-init
25823 @item -mcc-init
25824 Do not use condition-code results from previous instruction; always emit
25825 compare and test instructions before use of condition codes.
25826
25827 @opindex mno-side-effects
25828 @opindex mside-effects
25829 @item -mno-side-effects
25830 Do not emit instructions with side effects in addressing modes other than
25831 post-increment.
25832
25833 @opindex mstack-align
25834 @opindex mno-stack-align
25835 @opindex mdata-align
25836 @opindex mno-data-align
25837 @opindex mconst-align
25838 @opindex mno-const-align
25839 @item -mstack-align
25840 @itemx -mno-stack-align
25841 @itemx -mdata-align
25842 @itemx -mno-data-align
25843 @itemx -mconst-align
25844 @itemx -mno-const-align
25845 These options (@samp{no-} options) arrange (eliminate arrangements) for the
25846 stack frame, individual data and constants to be aligned for the maximum
25847 single data access size for the chosen CPU model. The default is to
25848 arrange for 32-bit alignment. ABI details such as structure layout are
25849 not affected by these options.
25850
25851 @opindex m32-bit
25852 @opindex m16-bit
25853 @opindex m8-bit
25854 @item -m32-bit
25855 @itemx -m16-bit
25856 @itemx -m8-bit
25857 Similar to the stack- data- and const-align options above, these options
25858 arrange for stack frame, writable data and constants to all be 32-bit,
25859 16-bit or 8-bit aligned. The default is 32-bit alignment.
25860
25861 @opindex mno-prologue-epilogue
25862 @opindex mprologue-epilogue
25863 @item -mno-prologue-epilogue
25864 @itemx -mprologue-epilogue
25865 With @option{-mno-prologue-epilogue}, the normal function prologue and
25866 epilogue which set up the stack frame are omitted and no return
25867 instructions or return sequences are generated in the code. Use this
25868 option only together with visual inspection of the compiled code: no
25869 warnings or errors are generated when call-saved registers must be saved,
25870 or storage for local variables needs to be allocated.
25871
25872 @opindex melf
25873 @item -melf
25874 Legacy no-op option.
25875
25876 @opindex sim
25877 @item -sim
25878 This option arranges
25879 to link with input-output functions from a simulator library. Code,
25880 initialized data and zero-initialized data are allocated consecutively.
25881
25882 @opindex sim2
25883 @item -sim2
25884 Like @option{-sim}, but pass linker options to locate initialized data at
25885 0x40000000 and zero-initialized data at 0x80000000.
25886 @end table
25887
25888 @node C-SKY Options
25889 @subsection C-SKY Options
25890 @cindex C-SKY Options
25891
25892 GCC supports these options when compiling for C-SKY V2 processors.
25893
25894 @table @gcctabopt
25895
25896 @opindex march=
25897 @item -march=@var{arch}
25898 Specify the C-SKY target architecture. Valid values for @var{arch} are:
25899 @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
25900 The default is @samp{ck810}.
25901
25902 @opindex mcpu=
25903 @item -mcpu=@var{cpu}
25904 Specify the C-SKY target processor. Valid values for @var{cpu} are:
25905 @samp{ck801}, @samp{ck801t},
25906 @samp{ck802}, @samp{ck802t}, @samp{ck802j},
25907 @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
25908 @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
25909 @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
25910 @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
25911 @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
25912 @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
25913 @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
25914 @samp{ck803eftr1}, @samp{ck803efhtr1},
25915 @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
25916 @samp{ck803sef}, @samp{ck803seft},
25917 @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
25918 @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
25919 @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
25920 @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
25921
25922 @opindex mbig-endian
25923 @opindex EB
25924 @opindex mlittle-endian
25925 @opindex EL
25926 @item -mbig-endian
25927 @itemx -EB
25928 @itemx -mlittle-endian
25929 @itemx -EL
25930
25931 Select big- or little-endian code. The default is little-endian.
25932
25933 @opindex mfloat-abi
25934 @item -mfloat-abi=@var{name}
25935 Specifies which floating-point ABI to use. Permissible values
25936 are: @samp{soft}, @samp{softfp} and @samp{hard}.
25937
25938 Specifying @samp{soft} causes GCC to generate output containing
25939 library calls for floating-point operations.
25940 @samp{softfp} allows the generation of code using hardware floating-point
25941 instructions, but still uses the soft-float calling conventions.
25942 @samp{hard} allows generation of floating-point instructions
25943 and uses FPU-specific calling conventions.
25944
25945 The default depends on the specific target configuration. Note that
25946 the hard-float and soft-float ABIs are not link-compatible; you must
25947 compile your entire program with the same ABI, and link with a
25948 compatible set of libraries.
25949
25950 @opindex mhard-float
25951 @opindex msoft-float
25952 @item -mhard-float
25953 @itemx -msoft-float
25954
25955 Select hardware or software floating-point implementations.
25956 The default is soft float.
25957
25958 @opindex mdouble-float
25959 @item -mdouble-float
25960 @itemx -mno-double-float
25961 When @option{-mhard-float} is in effect, enable generation of
25962 double-precision float instructions. This is the default except
25963 when compiling for CK803.
25964
25965 @opindex mfdivdu
25966 @item -mfdivdu
25967 @itemx -mno-fdivdu
25968 When @option{-mhard-float} is in effect, enable generation of
25969 @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
25970 This is the default except when compiling for CK803.
25971
25972 @opindex mfpu=
25973 @item -mfpu=@var{fpu}
25974 Select the floating-point processor. This option can only be used with
25975 @option{-mhard-float}.
25976 Values for @var{fpu} are
25977 @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
25978 @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
25979 @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
25980
25981 @opindex melrw
25982 @item -melrw
25983 @itemx -mno-elrw
25984 Enable the extended @code{lrw} instruction. This option defaults to on
25985 for CK801 and off otherwise.
25986
25987 @opindex mistack
25988 @item -mistack
25989 @itemx -mno-istack
25990 Enable interrupt stack instructions; the default is off.
25991
25992 The @option{-mistack} option is required to handle the
25993 @code{interrupt} and @code{isr} function attributes
25994 (@pxref{C-SKY Function Attributes}).
25995
25996 @opindex mmp
25997 @item -mmp
25998 Enable multiprocessor instructions; the default is off.
25999
26000 @opindex mcp
26001 @item -mcp
26002 Enable coprocessor instructions; the default is off.
26003
26004 @opindex mcache
26005 @item -mcache
26006 Enable coprocessor instructions; the default is off.
26007
26008 @opindex msecurity
26009 @item -msecurity
26010 Enable C-SKY security instructions; the default is off.
26011
26012 @opindex mtrust
26013 @item -mtrust
26014 Enable C-SKY trust instructions; the default is off.
26015
26016 @opindex mdsp
26017 @opindex medsp
26018 @opindex mvdsp
26019 @item -mdsp
26020 @itemx -medsp
26021 @itemx -mvdsp
26022 Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
26023 All of these options default to off.
26024
26025 @opindex mdiv
26026 @item -mdiv
26027 @itemx -mno-div
26028 Generate divide instructions. Default is off.
26029
26030 @opindex msmart
26031 @item -msmart
26032 @itemx -mno-smart
26033 Generate code for Smart Mode, using only registers numbered 0-7 to allow
26034 use of 16-bit instructions. This option is ignored for CK801 where this
26035 is the required behavior, and it defaults to on for CK802.
26036 For other targets, the default is off.
26037
26038 @opindex mhigh-registers
26039 @item -mhigh-registers
26040 @itemx -mno-high-registers
26041 Generate code using the high registers numbered 16-31. This option
26042 is not supported on CK801, CK802, or CK803, and is enabled by default
26043 for other processors.
26044
26045 @opindex manchor
26046 @item -manchor
26047 @itemx -mno-anchor
26048 Generate code using global anchor symbol addresses.
26049
26050 @opindex mpushpop
26051 @item -mpushpop
26052 @itemx -mno-pushpop
26053 Generate code using @code{push} and @code{pop} instructions. This option
26054 defaults to on.
26055
26056 @opindex mmultiple-stld
26057 @item -mmultiple-stld
26058 @itemx -mstm
26059 @itemx -mno-multiple-stld
26060 @itemx -mno-stm
26061 Generate code using @code{stm} and @code{ldm} instructions. This option
26062 isn't supported on CK801 but is enabled by default on other processors.
26063
26064 @opindex mconstpool
26065 @item -mconstpool
26066 @itemx -mno-constpool
26067 Create constant pools in the compiler instead of deferring it to the
26068 assembler. This option is the default and required for correct code
26069 generation on CK801 and CK802, and is optional on other processors.
26070
26071 @opindex mstack-size
26072 @item -mstack-size
26073 @item -mno-stack-size
26074 Emit @code{.stack_size} directives for each function in the assembly
26075 output. This option defaults to off.
26076
26077 @opindex mccrt
26078 @item -mccrt
26079 @itemx -mno-ccrt
26080 Generate code for the C-SKY compiler runtime instead of libgcc. This
26081 option defaults to off.
26082
26083 @opindex mbranch-cost=
26084 @item -mbranch-cost=@var{n}
26085 Set the branch costs to roughly @code{n} instructions. The default is 1.
26086
26087 @opindex msched-prolog
26088 @item -msched-prolog
26089 @itemx -mno-sched-prolog
26090 Permit scheduling of function prologue and epilogue sequences. Using
26091 this option can result in code that is not compliant with the C-SKY V2 ABI
26092 prologue requirements and that cannot be debugged or backtraced.
26093 It is disabled by default.
26094
26095 @opindex msim
26096 @item -msim
26097 Links the library libsemi.a which is in compatible with simulator. Applicable
26098 to ELF compiler only.
26099
26100 @end table
26101
26102 @node Cygwin and MinGW Options
26103 @subsection Cygwin and MinGW Options
26104 @cindex Cygwin and MinGW Options
26105 @cindex Options for Cygwin and MinGW
26106
26107 These additional options are available for Microsoft Windows targets:
26108
26109 @table @gcctabopt
26110 @opindex mconsole
26111 @item -mconsole
26112 This option
26113 specifies that a console application is to be generated, by
26114 instructing the linker to set the PE header subsystem type
26115 required for console applications.
26116 This option is available for Cygwin and MinGW targets and is
26117 enabled by default on those targets.
26118
26119 @opindex mcrtdll
26120 @item -mcrtdll=@var{library}
26121 Preprocess, compile or link with specified C RunTime DLL @var{library}.
26122 This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__},
26123 @code{_UCRT} and @code{__MSVCRT_VERSION__} for specified CRT @var{library},
26124 choose start file for CRT @var{library} and link with CRT @var{library}.
26125 Recognized CRT library names for proprocessor are:
26126 @code{crtdll*}, @code{msvcrt10*}, @code{msvcrt20*}, @code{msvcrt40*},
26127 @code{msvcr40*}, @code{msvcrtd*}, @code{msvcrt-os*},
26128 @code{msvcr70*}, @code{msvcr71*}, @code{msvcr80*}, @code{msvcr90*},
26129 @code{msvcr100*}, @code{msvcr110*}, @code{msvcr120*} and @code{ucrt*}.
26130 If this options is not specified then the default MinGW import library
26131 @code{msvcrt} is used for linking and no other adjustment for
26132 preprocessor is done. MinGW import library @code{msvcrt} is just a
26133 symlink to (or a copy of) another MinGW CRT import library
26134 chosen during MinGW compilation. MinGW import library @code{msvcrt-os}
26135 is for Windows system CRT DLL library @code{msvcrt.dll} and
26136 in most cases is the default MinGW import library.
26137 Generally speaking, changing the CRT DLL requires recompiling
26138 the entire MinGW CRT. This option is for experimental and testing
26139 purposes only.
26140 This option is available for MinGW targets.
26141
26142 @opindex mdll
26143 @item -mdll
26144 This option is available for Cygwin and MinGW targets. It
26145 specifies that a DLL---a dynamic link library---is to be
26146 generated, enabling the selection of the required runtime
26147 startup object and entry point.
26148
26149 @opindex mnop-fun-dllimport
26150 @item -mnop-fun-dllimport
26151 This option is available for Cygwin and MinGW targets. It
26152 specifies that the @code{dllimport} attribute should be ignored.
26153
26154 @opindex mthreads
26155 @item -mthreads
26156 This option is available for MinGW targets. It specifies
26157 that MinGW-specific thread support is to be used.
26158
26159 @opindex municode
26160 @item -municode
26161 This option is available for MinGW-w64 targets. It causes
26162 the @code{UNICODE} preprocessor macro to be predefined, and
26163 chooses Unicode-capable runtime startup code.
26164
26165 @opindex mwin32
26166 @item -mwin32
26167 This option is available for Cygwin and MinGW targets. It
26168 specifies that the typical Microsoft Windows predefined macros are to
26169 be set in the pre-processor, but does not influence the choice
26170 of runtime library/startup code.
26171
26172 @opindex mwindows
26173 @item -mwindows
26174 This option is available for Cygwin and MinGW targets. It
26175 specifies that a GUI application is to be generated by
26176 instructing the linker to set the PE header subsystem type
26177 appropriately.
26178
26179 @opindex fno-set-stack-executable
26180 @opindex fset-stack-executable
26181 @item -fno-set-stack-executable
26182 This option is available for MinGW targets. It specifies that
26183 the executable flag for the stack used by nested functions isn't
26184 set. This is necessary for binaries running in kernel mode of
26185 Microsoft Windows, as there the User32 API, which is used to set executable
26186 privileges, isn't available.
26187
26188 @opindex fno-writable-relocated-rdata
26189 @opindex fwritable-relocated-rdata
26190 @item -fwritable-relocated-rdata
26191 This option is available for MinGW and Cygwin targets. It specifies
26192 that relocated-data in read-only section is put into the @code{.data}
26193 section. This is a necessary for older runtimes not supporting
26194 modification of @code{.rdata} sections for pseudo-relocation.
26195
26196 @opindex mpe-aligned-commons
26197 @item -mpe-aligned-commons
26198 This option is available for Cygwin and MinGW targets. It
26199 specifies that the GNU extension to the PE file format that
26200 permits the correct alignment of COMMON variables should be
26201 used when generating code. It is enabled by default if
26202 GCC detects that the target assembler found during configuration
26203 supports the feature.
26204 @end table
26205
26206 See also under @ref{x86 Options} for standard options.
26207
26208 @node Darwin Options
26209 @subsection Darwin Options
26210 @cindex Darwin options
26211
26212 These options are defined for all architectures running the Darwin operating
26213 system.
26214
26215 FSF GCC on Darwin does not create ``fat'' object files; it creates
26216 an object file for the single architecture that GCC was built to
26217 target. Apple's GCC on Darwin does create ``fat'' files if multiple
26218 @option{-arch} options are used; it does so by running the compiler or
26219 linker multiple times and joining the results together with
26220 @file{lipo}.
26221
26222 The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
26223 @samp{i686}) is determined by the flags that specify the ISA
26224 that GCC is targeting, like @option{-mcpu} or @option{-march}. The
26225 @option{-force_cpusubtype_ALL} option can be used to override this.
26226
26227 The Darwin tools vary in their behavior when presented with an ISA
26228 mismatch. The assembler, @file{as}, only permits instructions to
26229 be used that are valid for the subtype of the file it is generating,
26230 so you cannot put 64-bit instructions in a @samp{ppc750} object file.
26231 The linker for shared libraries, @file{/usr/bin/libtool}, fails
26232 and prints an error if asked to create a shared library with a less
26233 restrictive subtype than its input files (for instance, trying to put
26234 a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
26235 for executables, @command{ld}, quietly gives the executable the most
26236 restrictive subtype of any of its input files.
26237
26238 @table @gcctabopt
26239 @opindex F
26240 @item -F@var{dir}
26241 Add the framework directory @var{dir} to the head of the list of
26242 directories to be searched for header files. These directories are
26243 interleaved with those specified by @option{-I} options and are
26244 scanned in a left-to-right order.
26245
26246 A framework directory is a directory with frameworks in it. A
26247 framework is a directory with a @file{Headers} and/or
26248 @file{PrivateHeaders} directory contained directly in it that ends
26249 in @file{.framework}. The name of a framework is the name of this
26250 directory excluding the @file{.framework}. Headers associated with
26251 the framework are found in one of those two directories, with
26252 @file{Headers} being searched first. A subframework is a framework
26253 directory that is in a framework's @file{Frameworks} directory.
26254 Includes of subframework headers can only appear in a header of a
26255 framework that contains the subframework, or in a sibling subframework
26256 header. Two subframeworks are siblings if they occur in the same
26257 framework. A subframework should not have the same name as a
26258 framework; a warning is issued if this is violated. Currently a
26259 subframework cannot have subframeworks; in the future, the mechanism
26260 may be extended to support this. The standard frameworks can be found
26261 in @file{/System/Library/Frameworks} and
26262 @file{/Library/Frameworks}. An example include looks like
26263 @code{#include <Framework/header.h>}, where @file{Framework} denotes
26264 the name of the framework and @file{header.h} is found in the
26265 @file{PrivateHeaders} or @file{Headers} directory.
26266
26267 @opindex iframework
26268 @item -iframework@var{dir}
26269 Like @option{-F} except the directory is a treated as a system
26270 directory. The main difference between this @option{-iframework} and
26271 @option{-F} is that with @option{-iframework} the compiler does not
26272 warn about constructs contained within header files found via
26273 @var{dir}. This option is valid only for the C family of languages.
26274
26275 @opindex gused
26276 @item -gused
26277 Emit debugging information for symbols that are used. For stabs
26278 debugging format, this enables @option{-feliminate-unused-debug-symbols}.
26279 This is by default ON@.
26280
26281 @opindex gfull
26282 @item -gfull
26283 Emit debugging information for all symbols and types.
26284
26285 @opindex fconstant-cfstrings
26286 @item -fconstant-cfstrings
26287 The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}.
26288
26289 @opindex mconstant-cfstrings
26290 @item -mconstant-cfstrings
26291 When the NeXT runtime is being used (the default on these systems), override
26292 any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"}
26293 literals to be laid out as constant CoreFoundation strings.
26294
26295 @opindex mmacosx-version-min
26296 @item -mmacosx-version-min=@var{version}
26297 The earliest version of MacOS X that this executable will run on is
26298 @var{version}. Typical values supported for @var{version} include @code{12},
26299 @code{10.12}, and @code{10.5.8}.
26300
26301 If the compiler was built to use the system's headers by default,
26302 then the default for this option is the system version on which the
26303 compiler is running, otherwise the default is to make choices that
26304 are compatible with as many systems and code bases as possible.
26305
26306 @opindex mkernel
26307 @item -mkernel
26308 Enable kernel development mode. The @option{-mkernel} option sets
26309 @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
26310 @option{-fno-exceptions}, @option{-fno-non-call-exceptions},
26311 @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
26312 applicable. This mode also sets @option{-mno-altivec},
26313 @option{-msoft-float}, @option{-fno-builtin} and
26314 @option{-mlong-branch} for PowerPC targets.
26315
26316 @opindex mone-byte-bool
26317 @item -mone-byte-bool
26318 Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
26319 By default @code{sizeof(bool)} is @code{4} when compiling for
26320 Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
26321 option has no effect on x86.
26322
26323 @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
26324 to generate code that is not binary compatible with code generated
26325 without that switch. Using this switch may require recompiling all
26326 other modules in a program, including system libraries. Use this
26327 switch to conform to a non-default data model.
26328
26329 @opindex mfix-and-continue
26330 @opindex ffix-and-continue
26331 @opindex findirect-data
26332 @item -mfix-and-continue
26333 @itemx -ffix-and-continue
26334 @itemx -findirect-data
26335 Generate code suitable for fast turnaround development, such as to
26336 allow GDB to dynamically load @file{.o} files into already-running
26337 programs. @option{-findirect-data} and @option{-ffix-and-continue}
26338 are provided for backwards compatibility.
26339
26340 @opindex all_load
26341 @item -all_load
26342 Loads all members of static archive libraries.
26343 See man ld(1) for more information.
26344
26345 @opindex arch_errors_fatal
26346 @item -arch_errors_fatal
26347 Cause the errors having to do with files that have the wrong architecture
26348 to be fatal.
26349
26350 @opindex bind_at_load
26351 @item -bind_at_load
26352 Causes the output file to be marked such that the dynamic linker will
26353 bind all undefined references when the file is loaded or launched.
26354
26355 @opindex bundle
26356 @item -bundle
26357 Produce a Mach-o bundle format file.
26358 See man ld(1) for more information.
26359
26360 @opindex bundle_loader
26361 @item -bundle_loader @var{executable}
26362 This option specifies the @var{executable} that will load the build
26363 output file being linked. See man ld(1) for more information.
26364
26365 @opindex dynamiclib
26366 @item -dynamiclib
26367 When passed this option, GCC produces a dynamic library instead of
26368 an executable when linking, using the Darwin @file{libtool} command.
26369
26370 @opindex force_cpusubtype_ALL
26371 @item -force_cpusubtype_ALL
26372 This causes GCC's output file to have the @samp{ALL} subtype, instead of
26373 one controlled by the @option{-mcpu} or @option{-march} option.
26374
26375 @opindex nodefaultrpaths
26376 @item -nodefaultrpaths
26377 Do not add default run paths for the compiler library directories to
26378 executables, modules or dynamic libraries. On macOS 10.5 and later,
26379 the embedded runpath is added by default unless the user adds
26380 @option{-nodefaultrpaths} to the link line. Run paths are needed
26381 (and therefore enforced) to build on macOS version 10.11 or later.
26382
26383 @item -allowable_client @var{client_name}
26384 @itemx -client_name
26385 @itemx -compatibility_version
26386 @itemx -current_version
26387 @itemx -dead_strip
26388 @itemx -dependency-file
26389 @itemx -dylib_file
26390 @itemx -dylinker_install_name
26391 @itemx -dynamic
26392 @itemx -exported_symbols_list
26393 @itemx -filelist
26394 @need 800
26395 @itemx -flat_namespace
26396 @itemx -force_flat_namespace
26397 @itemx -headerpad_max_install_names
26398 @itemx -image_base
26399 @itemx -init
26400 @itemx -install_name
26401 @itemx -keep_private_externs
26402 @itemx -multi_module
26403 @itemx -multiply_defined
26404 @itemx -multiply_defined_unused
26405 @need 800
26406 @itemx -noall_load
26407 @itemx -no_dead_strip_inits_and_terms
26408 @itemx -nofixprebinding
26409 @itemx -nomultidefs
26410 @itemx -noprebind
26411 @itemx -noseglinkedit
26412 @itemx -pagezero_size
26413 @itemx -prebind
26414 @itemx -prebind_all_twolevel_modules
26415 @itemx -private_bundle
26416 @need 800
26417 @itemx -read_only_relocs
26418 @itemx -sectalign
26419 @itemx -sectobjectsymbols
26420 @itemx -whyload
26421 @itemx -seg1addr
26422 @itemx -sectcreate
26423 @itemx -sectobjectsymbols
26424 @itemx -sectorder
26425 @itemx -segaddr
26426 @itemx -segs_read_only_addr
26427 @need 800
26428 @itemx -segs_read_write_addr
26429 @itemx -seg_addr_table
26430 @itemx -seg_addr_table_filename
26431 @itemx -seglinkedit
26432 @itemx -segprot
26433 @itemx -segs_read_only_addr
26434 @itemx -segs_read_write_addr
26435 @itemx -single_module
26436 @itemx -static
26437 @itemx -sub_library
26438 @need 800
26439 @opindex allowable_client
26440 @opindex client_name
26441 @opindex compatibility_version
26442 @opindex current_version
26443 @opindex dead_strip
26444 @opindex dependency-file
26445 @opindex dylib_file
26446 @opindex dylinker_install_name
26447 @opindex dynamic
26448 @opindex exported_symbols_list
26449 @opindex filelist
26450 @opindex flat_namespace
26451 @opindex force_flat_namespace
26452 @opindex headerpad_max_install_names
26453 @opindex image_base
26454 @opindex init
26455 @opindex install_name
26456 @opindex keep_private_externs
26457 @opindex multi_module
26458 @opindex multiply_defined
26459 @opindex multiply_defined_unused
26460 @opindex noall_load
26461 @opindex no_dead_strip_inits_and_terms
26462 @opindex nofixprebinding
26463 @opindex nomultidefs
26464 @opindex noprebind
26465 @opindex noseglinkedit
26466 @opindex pagezero_size
26467 @opindex prebind
26468 @opindex prebind_all_twolevel_modules
26469 @opindex private_bundle
26470 @opindex read_only_relocs
26471 @opindex sectalign
26472 @opindex sectobjectsymbols
26473 @opindex whyload
26474 @opindex seg1addr
26475 @opindex sectcreate
26476 @opindex sectobjectsymbols
26477 @opindex sectorder
26478 @opindex segaddr
26479 @opindex segs_read_only_addr
26480 @opindex segs_read_write_addr
26481 @opindex seg_addr_table
26482 @opindex seg_addr_table_filename
26483 @opindex seglinkedit
26484 @opindex segprot
26485 @opindex segs_read_only_addr
26486 @opindex segs_read_write_addr
26487 @opindex single_module
26488 @opindex static
26489 @opindex sub_library
26490 @opindex sub_umbrella
26491 @opindex twolevel_namespace
26492 @opindex umbrella
26493 @opindex undefined
26494 @opindex unexported_symbols_list
26495 @opindex weak_reference_mismatches
26496 @opindex whatsloaded
26497 @itemx -sub_umbrella
26498 @itemx -twolevel_namespace
26499 @itemx -umbrella
26500 @itemx -undefined
26501 @itemx -unexported_symbols_list
26502 @itemx -weak_reference_mismatches
26503 @itemx -whatsloaded
26504 These options are passed to the Darwin linker. The Darwin linker man page
26505 describes them in detail.
26506 @end table
26507
26508 @node DEC Alpha Options
26509 @subsection DEC Alpha Options
26510
26511 These @samp{-m} options are defined for the DEC Alpha implementations:
26512
26513 @table @gcctabopt
26514 @opindex mno-soft-float
26515 @opindex msoft-float
26516 @item -mno-soft-float
26517 @itemx -msoft-float
26518 Use (do not use) the hardware floating-point instructions for
26519 floating-point operations. When @option{-msoft-float} is specified,
26520 functions in @file{libgcc.a} are used to perform floating-point
26521 operations. Unless they are replaced by routines that emulate the
26522 floating-point operations, or compiled in such a way as to call such
26523 emulations routines, these routines issue floating-point
26524 operations. If you are compiling for an Alpha without floating-point
26525 operations, you must ensure that the library is built so as not to call
26526 them.
26527
26528 Note that Alpha implementations without floating-point operations are
26529 required to have floating-point registers.
26530
26531 @opindex mfp-reg
26532 @opindex mno-fp-regs
26533 @item -mfp-reg
26534 @itemx -mno-fp-regs
26535 Generate code that uses (does not use) the floating-point register set.
26536 @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
26537 register set is not used, floating-point operands are passed in integer
26538 registers as if they were integers and floating-point results are passed
26539 in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
26540 so any function with a floating-point argument or return value called by code
26541 compiled with @option{-mno-fp-regs} must also be compiled with that
26542 option.
26543
26544 A typical use of this option is building a kernel that does not use,
26545 and hence need not save and restore, any floating-point registers.
26546
26547 @opindex mieee
26548 @item -mieee
26549 The Alpha architecture implements floating-point hardware optimized for
26550 maximum performance. It is mostly compliant with the IEEE floating-point
26551 standard. However, for full compliance, software assistance is
26552 required. This option generates code fully IEEE-compliant code
26553 @emph{except} that the @var{inexact-flag} is not maintained (see below).
26554 If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
26555 defined during compilation. The resulting code is less efficient but is
26556 able to correctly support denormalized numbers and exceptional IEEE
26557 values such as not-a-number and plus/minus infinity. Other Alpha
26558 compilers call this option @option{-ieee_with_no_inexact}.
26559
26560 @opindex mieee-with-inexact
26561 @item -mieee-with-inexact
26562 This is like @option{-mieee} except the generated code also maintains
26563 the IEEE @var{inexact-flag}. Turning on this option causes the
26564 generated code to implement fully-compliant IEEE math. In addition to
26565 @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
26566 macro. On some Alpha implementations the resulting code may execute
26567 significantly slower than the code generated by default. Since there is
26568 very little code that depends on the @var{inexact-flag}, you should
26569 normally not specify this option. Other Alpha compilers call this
26570 option @option{-ieee_with_inexact}.
26571
26572 @opindex mfp-trap-mode
26573 @item -mfp-trap-mode=@var{trap-mode}
26574 This option controls what floating-point related traps are enabled.
26575 Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
26576 The trap mode can be set to one of four values:
26577
26578 @table @samp
26579 @item n
26580 This is the default (normal) setting. The only traps that are enabled
26581 are the ones that cannot be disabled in software (e.g., division by zero
26582 trap).
26583
26584 @item u
26585 In addition to the traps enabled by @samp{n}, underflow traps are enabled
26586 as well.
26587
26588 @item su
26589 Like @samp{u}, but the instructions are marked to be safe for software
26590 completion (see Alpha architecture manual for details).
26591
26592 @item sui
26593 Like @samp{su}, but inexact traps are enabled as well.
26594 @end table
26595
26596 @opindex mfp-rounding-mode
26597 @item -mfp-rounding-mode=@var{rounding-mode}
26598 Selects the IEEE rounding mode. Other Alpha compilers call this option
26599 @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
26600 of:
26601
26602 @table @samp
26603 @item n
26604 Normal IEEE rounding mode. Floating-point numbers are rounded towards
26605 the nearest machine number or towards the even machine number in case
26606 of a tie.
26607
26608 @item m
26609 Round towards minus infinity.
26610
26611 @item c
26612 Chopped rounding mode. Floating-point numbers are rounded towards zero.
26613
26614 @item d
26615 Dynamic rounding mode. A field in the floating-point control register
26616 (@var{fpcr}, see Alpha architecture reference manual) controls the
26617 rounding mode in effect. The C library initializes this register for
26618 rounding towards plus infinity. Thus, unless your program modifies the
26619 @var{fpcr}, @samp{d} corresponds to round towards plus infinity.
26620 @end table
26621
26622 @opindex mtrap-precision
26623 @item -mtrap-precision=@var{trap-precision}
26624 In the Alpha architecture, floating-point traps are imprecise. This
26625 means without software assistance it is impossible to recover from a
26626 floating trap and program execution normally needs to be terminated.
26627 GCC can generate code that can assist operating system trap handlers
26628 in determining the exact location that caused a floating-point trap.
26629 Depending on the requirements of an application, different levels of
26630 precisions can be selected:
26631
26632 @table @samp
26633 @item p
26634 Program precision. This option is the default and means a trap handler
26635 can only identify which program caused a floating-point exception.
26636
26637 @item f
26638 Function precision. The trap handler can determine the function that
26639 caused a floating-point exception.
26640
26641 @item i
26642 Instruction precision. The trap handler can determine the exact
26643 instruction that caused a floating-point exception.
26644 @end table
26645
26646 Other Alpha compilers provide the equivalent options called
26647 @option{-scope_safe} and @option{-resumption_safe}.
26648
26649 @opindex mieee-conformant
26650 @item -mieee-conformant
26651 This option marks the generated code as IEEE conformant. You must not
26652 use this option unless you also specify @option{-mtrap-precision=i} and either
26653 @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
26654 is to emit the line @samp{.eflag 48} in the function prologue of the
26655 generated assembly file.
26656
26657 @opindex mbuild-constants
26658 @item -mbuild-constants
26659 Normally GCC examines a 32- or 64-bit integer constant to
26660 see if it can construct it from smaller constants in two or three
26661 instructions. If it cannot, it outputs the constant as a literal and
26662 generates code to load it from the data segment at run time.
26663
26664 Use this option to require GCC to construct @emph{all} integer constants
26665 using code, even if it takes more instructions (the maximum is six).
26666
26667 You typically use this option to build a shared library dynamic
26668 loader. Itself a shared library, it must relocate itself in memory
26669 before it can find the variables and constants in its own data segment.
26670
26671 @opindex mbwx
26672 @opindex mno-bwx
26673 @opindex mcix
26674 @opindex mno-cix
26675 @opindex mfix
26676 @opindex mno-fix
26677 @opindex mmax
26678 @opindex mno-max
26679 @item -mbwx
26680 @itemx -mno-bwx
26681 @itemx -mcix
26682 @itemx -mno-cix
26683 @itemx -mfix
26684 @itemx -mno-fix
26685 @itemx -mmax
26686 @itemx -mno-max
26687 Indicate whether GCC should generate code to use the optional BWX,
26688 CIX, FIX and MAX instruction sets. The default is to use the instruction
26689 sets supported by the CPU type specified via @option{-mcpu=} option or that
26690 of the CPU on which GCC was built if none is specified.
26691
26692 @opindex msafe-bwa
26693 @opindex mno-safe-bwa
26694 @item -msafe-bwa
26695 @itemx -mno-safe-bwa
26696 Indicate whether in the absence of the optional BWX instruction set
26697 GCC should generate multi-thread and async-signal safe code for byte
26698 and aligned word memory accesses.
26699
26700 @opindex msafe-partial
26701 @opindex mno-safe-partial
26702 @item -msafe-partial
26703 @itemx -mno-safe-partial
26704 Indicate whether GCC should generate multi-thread and async-signal
26705 safe code for partial memory accesses, including piecemeal accesses
26706 to unaligned data as well as block accesses to leading and trailing
26707 parts of aggregate types or other objects in memory that do not
26708 respectively start and end on an aligned 64-bit data boundary.
26709
26710 @opindex mfloat-vax
26711 @opindex mfloat-ieee
26712 @item -mfloat-vax
26713 @itemx -mfloat-ieee
26714 Generate code that uses (does not use) VAX F and G floating-point
26715 arithmetic instead of IEEE single and double precision.
26716
26717 @opindex mexplicit-relocs
26718 @opindex mno-explicit-relocs
26719 @item -mexplicit-relocs
26720 @itemx -mno-explicit-relocs
26721 Older Alpha assemblers provided no way to generate symbol relocations
26722 except via assembler macros. Use of these macros does not allow
26723 optimal instruction scheduling. GNU binutils as of version 2.12
26724 supports a new syntax that allows the compiler to explicitly mark
26725 which relocations should apply to which instructions. This option
26726 is mostly useful for debugging, as GCC detects the capabilities of
26727 the assembler when it is built and sets the default accordingly.
26728
26729 @opindex msmall-data
26730 @opindex mlarge-data
26731 @item -msmall-data
26732 @itemx -mlarge-data
26733 When @option{-mexplicit-relocs} is in effect, static data is
26734 accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
26735 is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
26736 (the @code{.sdata} and @code{.sbss} sections) and are accessed via
26737 16-bit relocations off of the @code{$gp} register. This limits the
26738 size of the small data area to 64KB, but allows the variables to be
26739 directly accessed via a single instruction.
26740
26741 The default is @option{-mlarge-data}. With this option the data area
26742 is limited to just below 2GB@. Programs that require more than 2GB of
26743 data must use @code{malloc} or @code{mmap} to allocate the data in the
26744 heap instead of in the program's data segment.
26745
26746 When generating code for shared libraries, @option{-fpic} implies
26747 @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
26748
26749 @opindex msmall-text
26750 @opindex mlarge-text
26751 @item -msmall-text
26752 @itemx -mlarge-text
26753 When @option{-msmall-text} is used, the compiler assumes that the
26754 code of the entire program (or shared library) fits in 4MB, and is
26755 thus reachable with a branch instruction. When @option{-msmall-data}
26756 is used, the compiler can assume that all local symbols share the
26757 same @code{$gp} value, and thus reduce the number of instructions
26758 required for a function call from 4 to 1.
26759
26760 The default is @option{-mlarge-text}.
26761
26762 @opindex mcpu
26763 @item -mcpu=@var{cpu_type}
26764 Set the instruction set and instruction scheduling parameters for
26765 machine type @var{cpu_type}. You can specify either the @samp{EV}
26766 style name or the corresponding chip number. GCC supports scheduling
26767 parameters for the EV4, EV5 and EV6 family of processors and
26768 chooses the default values for the instruction set from the processor
26769 you specify. If you do not specify a processor type, GCC defaults
26770 to the processor on which the compiler was built.
26771
26772 Supported values for @var{cpu_type} are
26773
26774 @table @samp
26775 @item ev4
26776 @itemx ev45
26777 @itemx 21064
26778 Schedules as an EV4 and has no instruction set extensions.
26779
26780 @item ev5
26781 @itemx 21164
26782 Schedules as an EV5 and has no instruction set extensions.
26783
26784 @item ev56
26785 @itemx 21164a
26786 Schedules as an EV5 and supports the BWX extension.
26787
26788 @item pca56
26789 @itemx 21164pc
26790 @itemx 21164PC
26791 Schedules as an EV5 and supports the BWX and MAX extensions.
26792
26793 @item ev6
26794 @itemx 21264
26795 Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
26796
26797 @item ev67
26798 @itemx 21264a
26799 Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
26800 @end table
26801
26802 Native toolchains also support the value @samp{native},
26803 which selects the best architecture option for the host processor.
26804 @option{-mcpu=native} has no effect if GCC does not recognize
26805 the processor.
26806
26807 @opindex mtune
26808 @item -mtune=@var{cpu_type}
26809 Set only the instruction scheduling parameters for machine type
26810 @var{cpu_type}. The instruction set is not changed.
26811
26812 Native toolchains also support the value @samp{native},
26813 which selects the best architecture option for the host processor.
26814 @option{-mtune=native} has no effect if GCC does not recognize
26815 the processor.
26816
26817 @opindex mmemory-latency
26818 @item -mmemory-latency=@var{time}
26819 Sets the latency the scheduler should assume for typical memory
26820 references as seen by the application. This number is highly
26821 dependent on the memory access patterns used by the application
26822 and the size of the external cache on the machine.
26823
26824 Valid options for @var{time} are
26825
26826 @table @samp
26827 @item @var{number}
26828 A decimal number representing clock cycles.
26829
26830 @item L1
26831 @itemx L2
26832 @itemx L3
26833 @itemx main
26834 The compiler contains estimates of the number of clock cycles for
26835 ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
26836 (also called Dcache, Scache, and Bcache), as well as to main memory.
26837 Note that L3 is only valid for EV5.
26838
26839 @end table
26840 @end table
26841
26842 @node eBPF Options
26843 @subsection eBPF Options
26844 @cindex eBPF Options
26845
26846 @table @gcctabopt
26847 @item -mframe-limit=@var{bytes}
26848 This specifies the hard limit for frame sizes, in bytes. Currently,
26849 the value that can be specified should be less than or equal to
26850 @samp{32767}. Defaults to whatever limit is imposed by the version of
26851 the Linux kernel targeted.
26852
26853 @opindex mbig-endian
26854 @item -mbig-endian
26855 Generate code for a big-endian target.
26856
26857 @opindex mlittle-endian
26858 @item -mlittle-endian
26859 Generate code for a little-endian target. This is the default.
26860
26861 @opindex mjmpext
26862 @item -mjmpext
26863 @itemx -mno-jmpext
26864 Enable or disable generation of extra conditional-branch instructions.
26865 Enabled for CPU v2 and above.
26866
26867 @opindex mjmp32
26868 @item -mjmp32
26869 @itemx -mno-jmp32
26870 Enable or disable generation of 32-bit jump instructions.
26871 Enabled for CPU v3 and above.
26872
26873 @opindex malu32
26874 @item -malu32
26875 @itemx -mno-alu32
26876 Enable or disable generation of 32-bit ALU instructions.
26877 Enabled for CPU v3 and above.
26878
26879 @opindex mv3-atomics
26880 @item -mv3-atomics
26881 @itemx -mno-v3-atomics
26882 Enable or disable instructions for general atomic operations introduced
26883 in CPU v3. Enabled for CPU v3 and above.
26884
26885 @opindex mbswap
26886 @item -mbswap
26887 @itemx -mno-bswap
26888 Enable or disable byte swap instructions. Enabled for CPU v4 and above.
26889
26890 @opindex msdiv
26891 @item -msdiv
26892 @itemx -mno-sdiv
26893 Enable or disable signed division and modulus instructions. Enabled for
26894 CPU v4 and above.
26895
26896 @opindex msmov
26897 @item -msmov
26898 @itemx -mno-smov
26899 Enable or disable sign-extending move and memory load instructions.
26900 Enabled for CPU v4 and above.
26901
26902 @opindex mcpu
26903 @item -mcpu=@var{version}
26904 This specifies which version of the eBPF ISA to target. Newer versions
26905 may not be supported by all kernels. The default is @samp{v4}.
26906
26907 Supported values for @var{version} are:
26908
26909 @table @samp
26910 @item v1
26911 The first stable eBPF ISA with no special features or extensions.
26912
26913 @item v2
26914 Supports the jump extensions, as in @option{-mjmpext}.
26915
26916 @item v3
26917 All features of v2, plus:
26918 @itemize @minus
26919 @item 32-bit jump operations, as in @option{-mjmp32}
26920 @item 32-bit ALU operations, as in @option{-malu32}
26921 @item general atomic operations, as in @option{-mv3-atomics}
26922 @end itemize
26923
26924 @item v4
26925 All features of v3, plus:
26926 @itemize @minus
26927 @item Byte swap instructions, as in @option{-mbswap}
26928 @item Signed division and modulus instructions, as in @option{-msdiv}
26929 @item Sign-extending move and memory load instructions, as in @option{-msmov}
26930 @end itemize
26931 @end table
26932
26933 @opindex mco-re
26934 @item -mco-re
26935 Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
26936 is implied by @option{-gbtf}.
26937
26938 @opindex mno-co-re
26939 @item -mno-co-re
26940 Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
26941 support is enabled by default when generating BTF debug information for
26942 the BPF target.
26943
26944 @item -mxbpf
26945 Generate code for an expanded version of BPF, which relaxes some of
26946 the restrictions imposed by the BPF architecture:
26947 @itemize @minus
26948 @item Save and restore callee-saved registers at function entry and
26949 exit, respectively.
26950 @end itemize
26951
26952 @opindex masm=@var{dialect}
26953 @item -masm=@var{dialect}
26954 Outputs assembly instructions using eBPF selected @var{dialect}. The default
26955 is @samp{pseudoc}.
26956
26957 Supported values for @var{dialect} are:
26958
26959 @table @samp
26960 @item normal
26961 Outputs normal assembly dialect.
26962
26963 @item pseudoc
26964 Outputs pseudo-c assembly dialect.
26965
26966 @end table
26967
26968 @opindex minline-memops-threshold
26969 @item -minline-memops-threshold=@var{bytes}
26970 Specifies a size threshold in bytes at or below which memmove, memcpy
26971 and memset shall always be expanded inline. Operations dealing with
26972 sizes larger than this threshold would have to be implemented using
26973 a library call instead of being expanded inline, but since BPF doesn't
26974 allow libcalls, exceeding this threshold results in a compile-time
26975 error. The default is @samp{1024} bytes.
26976
26977 @end table
26978
26979 @node FR30 Options
26980 @subsection FR30 Options
26981 @cindex FR30 Options
26982
26983 These options are defined specifically for the FR30 port.
26984
26985 @table @gcctabopt
26986
26987 @opindex msmall-model
26988 @item -msmall-model
26989 Use the small address space model. This can produce smaller code, but
26990 it does assume that all symbolic values and addresses fit into a
26991 20-bit range.
26992
26993 @opindex mno-lsim
26994 @item -mno-lsim
26995 Assume that runtime support has been provided and so there is no need
26996 to include the simulator library (@file{libsim.a}) on the linker
26997 command line.
26998
26999 @end table
27000
27001 @node FT32 Options
27002 @subsection FT32 Options
27003 @cindex FT32 Options
27004
27005 These options are defined specifically for the FT32 port.
27006
27007 @table @gcctabopt
27008
27009 @opindex msim
27010 @item -msim
27011 Specifies that the program will be run on the simulator. This causes
27012 an alternate runtime startup and library to be linked.
27013 You must not use this option when generating programs that will run on
27014 real hardware; you must provide your own runtime library for whatever
27015 I/O functions are needed.
27016
27017 @opindex mlra
27018 @item -mlra
27019 Does nothing. Preserved for backward compatibility.
27020
27021 @opindex mnodiv
27022 @item -mnodiv
27023 Do not use div and mod instructions.
27024
27025 @opindex mft32b
27026 @item -mft32b
27027 Enable use of the extended instructions of the FT32B processor.
27028
27029 @opindex mcompress
27030 @item -mcompress
27031 Compress all code using the Ft32B code compression scheme.
27032
27033 @opindex mnopm
27034 @item -mnopm
27035 Do not generate code that reads program memory.
27036
27037 @end table
27038
27039 @node FRV Options
27040 @subsection FRV Options
27041 @cindex FRV Options
27042
27043 @table @gcctabopt
27044 @opindex mgpr-32
27045 @item -mgpr-32
27046
27047 Only use the first 32 general-purpose registers.
27048
27049 @opindex mgpr-64
27050 @item -mgpr-64
27051
27052 Use all 64 general-purpose registers.
27053
27054 @opindex mfpr-32
27055 @item -mfpr-32
27056
27057 Use only the first 32 floating-point registers.
27058
27059 @opindex mfpr-64
27060 @item -mfpr-64
27061
27062 Use all 64 floating-point registers.
27063
27064 @opindex mhard-float
27065 @item -mhard-float
27066
27067 Use hardware instructions for floating-point operations.
27068
27069 @opindex msoft-float
27070 @item -msoft-float
27071
27072 Use library routines for floating-point operations.
27073
27074 @opindex malloc-cc
27075 @item -malloc-cc
27076
27077 Dynamically allocate condition code registers.
27078
27079 @opindex mfixed-cc
27080 @item -mfixed-cc
27081
27082 Do not try to dynamically allocate condition code registers, only
27083 use @code{icc0} and @code{fcc0}.
27084
27085 @opindex mdword
27086 @item -mdword
27087
27088 Change ABI to use double word insns.
27089
27090 @opindex mno-dword
27091 @opindex mdword
27092 @item -mno-dword
27093
27094 Do not use double word instructions.
27095
27096 @opindex mdouble
27097 @item -mdouble
27098
27099 Use floating-point double instructions.
27100
27101 @opindex mno-double
27102 @item -mno-double
27103
27104 Do not use floating-point double instructions.
27105
27106 @opindex mmedia
27107 @item -mmedia
27108
27109 Use media instructions.
27110
27111 @opindex mno-media
27112 @item -mno-media
27113
27114 Do not use media instructions.
27115
27116 @opindex mmuladd
27117 @item -mmuladd
27118
27119 Use multiply and add/subtract instructions.
27120
27121 @opindex mno-muladd
27122 @item -mno-muladd
27123
27124 Do not use multiply and add/subtract instructions.
27125
27126 @opindex mfdpic
27127 @item -mfdpic
27128
27129 Select the FDPIC ABI, which uses function descriptors to represent
27130 pointers to functions. Without any PIC/PIE-related options, it
27131 implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
27132 assumes GOT entries and small data are within a 12-bit range from the
27133 GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
27134 are computed with 32 bits.
27135 With a @samp{bfin-elf} target, this option implies @option{-msim}.
27136
27137 @opindex minline-plt
27138 @item -minline-plt
27139
27140 Enable inlining of PLT entries in function calls to functions that are
27141 not known to bind locally. It has no effect without @option{-mfdpic}.
27142 It's enabled by default if optimizing for speed and compiling for
27143 shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
27144 optimization option such as @option{-O3} or above is present in the
27145 command line.
27146
27147 @opindex mTLS
27148 @item -mTLS
27149
27150 Assume a large TLS segment when generating thread-local code.
27151
27152 @opindex mtls
27153 @item -mtls
27154
27155 Do not assume a large TLS segment when generating thread-local code.
27156
27157 @opindex mgprel-ro
27158 @item -mgprel-ro
27159
27160 Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
27161 that is known to be in read-only sections. It's enabled by default,
27162 except for @option{-fpic} or @option{-fpie}: even though it may help
27163 make the global offset table smaller, it trades 1 instruction for 4.
27164 With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
27165 one of which may be shared by multiple symbols, and it avoids the need
27166 for a GOT entry for the referenced symbol, so it's more likely to be a
27167 win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
27168
27169 @opindex multilib-library-pic
27170 @item -multilib-library-pic
27171
27172 Link with the (library, not FD) pic libraries. It's implied by
27173 @option{-mlibrary-pic}, as well as by @option{-fPIC} and
27174 @option{-fpic} without @option{-mfdpic}. You should never have to use
27175 it explicitly.
27176
27177 @opindex mlinked-fp
27178 @item -mlinked-fp
27179
27180 Follow the EABI requirement of always creating a frame pointer whenever
27181 a stack frame is allocated. This option is enabled by default and can
27182 be disabled with @option{-mno-linked-fp}.
27183
27184 @opindex mlong-calls
27185 @item -mlong-calls
27186
27187 Use indirect addressing to call functions outside the current
27188 compilation unit. This allows the functions to be placed anywhere
27189 within the 32-bit address space.
27190
27191 @opindex malign-labels
27192 @item -malign-labels
27193
27194 Try to align labels to an 8-byte boundary by inserting NOPs into the
27195 previous packet. This option only has an effect when VLIW packing
27196 is enabled. It doesn't create new packets; it merely adds NOPs to
27197 existing ones.
27198
27199 @opindex mlibrary-pic
27200 @item -mlibrary-pic
27201
27202 Generate position-independent EABI code.
27203
27204 @opindex macc-4
27205 @item -macc-4
27206
27207 Use only the first four media accumulator registers.
27208
27209 @opindex macc-8
27210 @item -macc-8
27211
27212 Use all eight media accumulator registers.
27213
27214 @opindex mpack
27215 @item -mpack
27216
27217 Pack VLIW instructions.
27218
27219 @opindex mno-pack
27220 @item -mno-pack
27221
27222 Do not pack VLIW instructions.
27223
27224 @opindex mno-eflags
27225 @item -mno-eflags
27226
27227 Do not mark ABI switches in e_flags.
27228
27229 @opindex mcond-move
27230 @item -mcond-move
27231
27232 Enable the use of conditional-move instructions (default).
27233
27234 This switch is mainly for debugging the compiler and will likely be removed
27235 in a future version.
27236
27237 @opindex mno-cond-move
27238 @item -mno-cond-move
27239
27240 Disable the use of conditional-move instructions.
27241
27242 This switch is mainly for debugging the compiler and will likely be removed
27243 in a future version.
27244
27245 @opindex mscc
27246 @item -mscc
27247
27248 Enable the use of conditional set instructions (default).
27249
27250 This switch is mainly for debugging the compiler and will likely be removed
27251 in a future version.
27252
27253 @opindex mno-scc
27254 @item -mno-scc
27255
27256 Disable the use of conditional set instructions.
27257
27258 This switch is mainly for debugging the compiler and will likely be removed
27259 in a future version.
27260
27261 @opindex mcond-exec
27262 @item -mcond-exec
27263
27264 Enable the use of conditional execution (default).
27265
27266 This switch is mainly for debugging the compiler and will likely be removed
27267 in a future version.
27268
27269 @opindex mno-cond-exec
27270 @item -mno-cond-exec
27271
27272 Disable the use of conditional execution.
27273
27274 This switch is mainly for debugging the compiler and will likely be removed
27275 in a future version.
27276
27277 @opindex mvliw-branch
27278 @item -mvliw-branch
27279
27280 Run a pass to pack branches into VLIW instructions (default).
27281
27282 This switch is mainly for debugging the compiler and will likely be removed
27283 in a future version.
27284
27285 @opindex mno-vliw-branch
27286 @item -mno-vliw-branch
27287
27288 Do not run a pass to pack branches into VLIW instructions.
27289
27290 This switch is mainly for debugging the compiler and will likely be removed
27291 in a future version.
27292
27293 @opindex mmulti-cond-exec
27294 @item -mmulti-cond-exec
27295
27296 Enable optimization of @code{&&} and @code{||} in conditional execution
27297 (default).
27298
27299 This switch is mainly for debugging the compiler and will likely be removed
27300 in a future version.
27301
27302 @opindex mno-multi-cond-exec
27303 @item -mno-multi-cond-exec
27304
27305 Disable optimization of @code{&&} and @code{||} in conditional execution.
27306
27307 This switch is mainly for debugging the compiler and will likely be removed
27308 in a future version.
27309
27310 @opindex mnested-cond-exec
27311 @item -mnested-cond-exec
27312
27313 Enable nested conditional execution optimizations (default).
27314
27315 This switch is mainly for debugging the compiler and will likely be removed
27316 in a future version.
27317
27318 @opindex mno-nested-cond-exec
27319 @item -mno-nested-cond-exec
27320
27321 Disable nested conditional execution optimizations.
27322
27323 This switch is mainly for debugging the compiler and will likely be removed
27324 in a future version.
27325
27326 @opindex moptimize-membar
27327 @item -moptimize-membar
27328
27329 This switch removes redundant @code{membar} instructions from the
27330 compiler-generated code. It is enabled by default.
27331
27332 @opindex mno-optimize-membar
27333 @opindex moptimize-membar
27334 @item -mno-optimize-membar
27335
27336 This switch disables the automatic removal of redundant @code{membar}
27337 instructions from the generated code.
27338
27339 @opindex mtomcat-stats
27340 @item -mtomcat-stats
27341
27342 Cause gas to print out tomcat statistics.
27343
27344 @opindex mcpu
27345 @item -mcpu=@var{cpu}
27346
27347 Select the processor type for which to generate code. Possible values are
27348 @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
27349 @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
27350
27351 @end table
27352
27353 @node GNU/Linux Options
27354 @subsection GNU/Linux Options
27355
27356 These @samp{-m} options are defined for GNU/Linux targets:
27357
27358 @table @gcctabopt
27359 @opindex mglibc
27360 @item -mglibc
27361 Use the GNU C library. This is the default except
27362 on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
27363 @samp{*-*-linux-*android*} targets.
27364
27365 @opindex muclibc
27366 @item -muclibc
27367 Use uClibc C library. This is the default on
27368 @samp{*-*-linux-*uclibc*} targets.
27369
27370 @opindex mmusl
27371 @item -mmusl
27372 Use the musl C library. This is the default on
27373 @samp{*-*-linux-*musl*} targets.
27374
27375 @opindex mbionic
27376 @item -mbionic
27377 Use Bionic C library. This is the default on
27378 @samp{*-*-linux-*android*} targets.
27379
27380 @opindex mandroid
27381 @item -mandroid
27382 Compile code compatible with Android platform. This is the default on
27383 @samp{*-*-linux-*android*} targets.
27384
27385 When compiling, this option enables @option{-mbionic}, @option{-fPIC},
27386 @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
27387 this option makes the GCC driver pass Android-specific options to the linker.
27388 Finally, this option causes the preprocessor macro @code{__ANDROID__}
27389 to be defined.
27390
27391 @opindex tno-android-cc
27392 @item -tno-android-cc
27393 Disable compilation effects of @option{-mandroid}, i.e., do not enable
27394 @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
27395 @option{-fno-rtti} by default.
27396
27397 @opindex tno-android-ld
27398 @item -tno-android-ld
27399 Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
27400 linking options to the linker.
27401
27402 @end table
27403
27404 @node H8/300 Options
27405 @subsection H8/300 Options
27406
27407 These @samp{-m} options are defined for the H8/300 implementations:
27408
27409 @table @gcctabopt
27410 @opindex mrelax
27411 @item -mrelax
27412 Shorten some address references at link time, when possible; uses the
27413 linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
27414 ld, Using ld}, for a fuller description.
27415
27416 @opindex mh
27417 @item -mh
27418 Generate code for the H8/300H@.
27419
27420 @opindex ms
27421 @item -ms
27422 Generate code for the H8S@.
27423
27424 @opindex mn
27425 @item -mn
27426 Generate code for the H8S and H8/300H in the normal mode. This switch
27427 must be used either with @option{-mh} or @option{-ms}.
27428
27429 @opindex ms2600
27430 @item -ms2600
27431 Generate code for the H8S/2600. This switch must be used with @option{-ms}.
27432
27433 @opindex mexr
27434 @item -mexr
27435 Extended registers are stored on stack before execution of function
27436 with monitor attribute. Default option is @option{-mexr}.
27437 This option is valid only for H8S targets.
27438
27439 @opindex mno-exr
27440 @opindex mexr
27441 @item -mno-exr
27442 Extended registers are not stored on stack before execution of function
27443 with monitor attribute. Default option is @option{-mno-exr}.
27444 This option is valid only for H8S targets.
27445
27446 @opindex mint32
27447 @item -mint32
27448 Make @code{int} data 32 bits by default.
27449
27450 @opindex malign-300
27451 @item -malign-300
27452 On the H8/300H and H8S, use the same alignment rules as for the H8/300.
27453 The default for the H8/300H and H8S is to align longs and floats on
27454 4-byte boundaries.
27455 @option{-malign-300} causes them to be aligned on 2-byte boundaries.
27456 This option has no effect on the H8/300.
27457 @end table
27458
27459 @node HPPA Options
27460 @subsection HPPA Options
27461 @cindex HPPA Options
27462
27463 These @samp{-m} options are defined for the HPPA family of computers:
27464
27465 @table @gcctabopt
27466 @opindex march
27467 @item -march=@var{architecture-type}
27468 Generate code for the specified architecture. The choices for
27469 @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
27470 1.1, and @samp{2.0} for PA 2.0 processors. Refer to
27471 @file{/usr/lib/sched.models} on an HP-UX system to determine the proper
27472 architecture option for your machine. Code compiled for lower numbered
27473 architectures runs on higher numbered architectures, but not the
27474 other way around.
27475
27476 @opindex mpa-risc-1-0
27477 @opindex mpa-risc-1-1
27478 @opindex mpa-risc-2-0
27479 @item -mpa-risc-1-0
27480 @itemx -mpa-risc-1-1
27481 @itemx -mpa-risc-2-0
27482 Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
27483
27484 @opindex matomic-libcalls
27485 @opindex mno-atomic-libcalls
27486 @item -matomic-libcalls
27487 Generate libcalls for atomic loads and stores when sync libcalls are disabled.
27488 This option is enabled by default. It only affects the generation of
27489 atomic libcalls by the HPPA backend.
27490
27491 Both the sync and @file{libatomic} libcall implementations use locking.
27492 As a result, processor stores are not atomic with respect to other
27493 atomic operations. Processor loads up to DImode are atomic with
27494 respect to other atomic operations provided they are implemented as
27495 a single access.
27496
27497 The PA-RISC architecture does not support any atomic operations in
27498 hardware except for the @code{ldcw} instruction. Thus, all atomic
27499 support is implemented using sync and atomic libcalls. Sync libcall
27500 support is in @file{libgcc.a}. Atomic libcall support is in
27501 @file{libatomic}.
27502
27503 This option generates @code{__atomic_exchange} calls for atomic stores.
27504 It also provides special handling for atomic DImode accesses on 32-bit
27505 targets.
27506
27507 @opindex mbig-switch
27508 @item -mbig-switch
27509 Does nothing. Preserved for backward compatibility.
27510
27511 @opindex mcaller-copies
27512 @item -mcaller-copies
27513 The caller copies function arguments passed by hidden reference. This
27514 option should be used with care as it is not compatible with the default
27515 32-bit runtime. However, only aggregates larger than eight bytes are
27516 passed by hidden reference and the option provides better compatibility
27517 with OpenMP.
27518
27519 @opindex mcoherent-ldcw
27520 @item -mcoherent-ldcw
27521 Use ldcw/ldcd coherent cache-control hint.
27522
27523 @opindex mdisable-fpregs
27524 @item -mdisable-fpregs
27525 Disable floating-point registers. Equivalent to @code{-msoft-float}.
27526
27527 @opindex mdisable-indexing
27528 @item -mdisable-indexing
27529 Prevent the compiler from using indexing address modes. This avoids some
27530 rather obscure problems when compiling MIG generated code under MACH@.
27531
27532 @opindex mfast-indirect-calls
27533 @item -mfast-indirect-calls
27534 Generate code that assumes calls never cross space boundaries. This
27535 allows GCC to emit code that performs faster indirect calls.
27536
27537 This option does not work in the presence of shared libraries or nested
27538 functions.
27539
27540 @opindex mfixed-range
27541 @item -mfixed-range=@var{register-range}
27542 Generate code treating the given register range as fixed registers.
27543 A fixed register is one that the register allocator cannot use. This is
27544 useful when compiling kernel code. A register range is specified as
27545 two registers separated by a dash. Multiple register ranges can be
27546 specified separated by a comma.
27547
27548 @opindex mgas
27549 @item -mgas
27550 Enable the use of assembler directives only GAS understands.
27551
27552 @opindex mgnu-ld
27553 @item -mgnu-ld
27554 Use options specific to GNU @command{ld}.
27555 This passes @option{-shared} to @command{ld} when
27556 building a shared library. It is the default when GCC is configured,
27557 explicitly or implicitly, with the GNU linker. This option does not
27558 affect which @command{ld} is called; it only changes what parameters
27559 are passed to that @command{ld}.
27560 The @command{ld} that is called is determined by the
27561 @option{--with-ld} configure option, GCC's program search path, and
27562 finally by the user's @env{PATH}. The linker used by GCC can be printed
27563 using @samp{which `gcc -print-prog-name=ld`}. This option is only available
27564 on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
27565
27566 @opindex mhp-ld
27567 @item -mhp-ld
27568 Use options specific to HP @command{ld}.
27569 This passes @option{-b} to @command{ld} when building
27570 a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
27571 links. It is the default when GCC is configured, explicitly or
27572 implicitly, with the HP linker. This option does not affect
27573 which @command{ld} is called; it only changes what parameters are passed to that
27574 @command{ld}.
27575 The @command{ld} that is called is determined by the @option{--with-ld}
27576 configure option, GCC's program search path, and finally by the user's
27577 @env{PATH}. The linker used by GCC can be printed using @samp{which
27578 `gcc -print-prog-name=ld`}. This option is only available on the 64-bit
27579 HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
27580
27581 @opindex mlinker-opt
27582 @item -mlinker-opt
27583 Enable the optimization pass in the HP-UX linker. Note this makes symbolic
27584 debugging impossible.
27585
27586 @opindex mno-long-calls
27587 @opindex mlong-calls
27588 @item -mlong-calls
27589 Generate code that uses long call sequences. This ensures that a call
27590 is always able to reach linker generated stubs. The default is to generate
27591 long calls only when the distance from the call site to the beginning
27592 of the function or translation unit, as the case may be, exceeds a
27593 predefined limit set by the branch type being used. The limits for
27594 normal calls are 7,600,000 and 240,000 bytes, respectively for the
27595 PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
27596 240,000 bytes.
27597
27598 Distances are measured from the beginning of functions when using the
27599 @option{-ffunction-sections} option, or when using the @option{-mgas}
27600 and @option{-mno-portable-runtime} options together under HP-UX with
27601 the SOM linker.
27602
27603 It is normally not desirable to use this option as it degrades
27604 performance. However, it may be useful in large applications,
27605 particularly when partial linking is used to build the application.
27606
27607 The types of long calls used depends on the capabilities of the
27608 assembler and linker, and the type of code being generated. The
27609 impact on systems that support long absolute calls, and long pic
27610 symbol-difference or pc-relative calls should be relatively small.
27611 However, an indirect call is used on 32-bit ELF systems in pic code
27612 and it is quite long.
27613
27614 @opindex mlong-load-store
27615 @item -mlong-load-store
27616 Generate 3-instruction load and store sequences as sometimes required by
27617 the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
27618 the HP compilers.
27619
27620 @opindex mjump-in-delay
27621 @item -mjump-in-delay
27622 This option is ignored and provided for compatibility purposes only.
27623
27624 @opindex mno-space-regs
27625 @opindex mspace-regs
27626 @item -mno-space-regs
27627 Generate code that assumes the target has no space registers. This allows
27628 GCC to generate faster indirect calls and use unscaled index address modes.
27629
27630 Such code is suitable for level 0 PA systems and kernels.
27631
27632 @opindex mordered
27633 @item -mordered
27634 Assume memory references are ordered and barriers are not needed.
27635
27636 @opindex mportable-runtime
27637 @item -mportable-runtime
27638 Use the portable calling conventions proposed by HP for ELF systems.
27639
27640 @opindex mschedule
27641 @item -mschedule=@var{cpu-type}
27642 Schedule code according to the constraints for the machine type
27643 @var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
27644 @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
27645 to @file{/usr/lib/sched.models} on an HP-UX system to determine the
27646 proper scheduling option for your machine. The default scheduling is
27647 @samp{8000}.
27648
27649 @opindex msio
27650 @item -msio
27651 Generate the predefine, @code{_SIO}, for server IO@. The default is
27652 @option{-mwsio}. This generates the predefines, @code{__hp9000s700},
27653 @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
27654 options are available under HP-UX and HI-UX@.
27655
27656 @opindex msoft-float
27657 @item -msoft-float
27658 Generate output containing library calls for floating point.
27659 @strong{Warning:} the requisite libraries are not available for all HPPA
27660 targets. Normally the facilities of the machine's usual C compiler are
27661 used, but this cannot be done directly in cross-compilation. You must make
27662 your own arrangements to provide suitable library functions for
27663 cross-compilation.
27664
27665 @option{-msoft-float} changes the calling convention in the output file;
27666 therefore, it is only useful if you compile @emph{all} of a program with
27667 this option. In particular, you need to compile @file{libgcc.a}, the
27668 library that comes with GCC, with @option{-msoft-float} in order for
27669 this to work.
27670
27671 @opindex msoft-mult
27672 @item -msoft-mult
27673 Use software integer multiplication.
27674
27675 This disables the use of the @code{xmpyu} instruction.
27676
27677 @opindex march
27678 @item -munix=@var{unix-std}
27679 Generate compiler predefines and select a startfile for the specified
27680 UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
27681 and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
27682 is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
27683 11.11 and later. The default values are @samp{93} for HP-UX 10.00,
27684 @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
27685 and later.
27686
27687 @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
27688 @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
27689 and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
27690 @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
27691 @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
27692 @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
27693
27694 It is @emph{important} to note that this option changes the interfaces
27695 for various library routines. It also affects the operational behavior
27696 of the C library. Thus, @emph{extreme} care is needed in using this
27697 option.
27698
27699 Library code that is intended to operate with more than one UNIX
27700 standard must test, set and restore the variable @code{__xpg4_extended_mask}
27701 as appropriate. Most GNU software doesn't provide this capability.
27702
27703 @opindex nolibdld
27704 @item -nolibdld
27705 Suppress the generation of link options to search libdld.sl when the
27706 @option{-static} option is specified on HP-UX 10 and later.
27707
27708 @opindex static
27709 @item -static
27710 The HP-UX implementation of setlocale in libc has a dependency on
27711 libdld.sl. There isn't an archive version of libdld.sl. Thus,
27712 when the @option{-static} option is specified, special link options
27713 are needed to resolve this dependency.
27714
27715 On HP-UX 10 and later, the GCC driver adds the necessary options to
27716 link with libdld.sl when the @option{-static} option is specified.
27717 This causes the resulting binary to be dynamic. On the 64-bit port,
27718 the linkers generate dynamic binaries by default in any case. The
27719 @option{-nolibdld} option can be used to prevent the GCC driver from
27720 adding these link options.
27721
27722 @opindex threads
27723 @item -threads
27724 Add support for multithreading with the @dfn{dce thread} library
27725 under HP-UX@. This option sets flags for both the preprocessor and
27726 linker.
27727 @end table
27728
27729 @node IA-64 Options
27730 @subsection IA-64 Options
27731 @cindex IA-64 Options
27732
27733 These are the @samp{-m} options defined for the Intel IA-64 architecture.
27734
27735 @table @gcctabopt
27736 @opindex mbig-endian
27737 @item -mbig-endian
27738 Generate code for a big-endian target. This is the default for HP-UX@.
27739
27740 @opindex mlittle-endian
27741 @item -mlittle-endian
27742 Generate code for a little-endian target. This is the default for AIX5
27743 and GNU/Linux.
27744
27745 @opindex mgnu-as
27746 @opindex mno-gnu-as
27747 @item -mgnu-as
27748 @itemx -mno-gnu-as
27749 Generate (or don't) code for the GNU assembler. This is the default.
27750 @c Also, this is the default if the configure option @option{--with-gnu-as}
27751 @c is used.
27752
27753 @opindex mgnu-ld
27754 @opindex mno-gnu-ld
27755 @item -mgnu-ld
27756 @itemx -mno-gnu-ld
27757 Generate (or don't) code for the GNU linker. This is the default.
27758 @c Also, this is the default if the configure option @option{--with-gnu-ld}
27759 @c is used.
27760
27761 @opindex mno-pic
27762 @item -mno-pic
27763 Generate code that does not use a global pointer register. The result
27764 is not position independent code, and violates the IA-64 ABI@.
27765
27766 @opindex mvolatile-asm-stop
27767 @opindex mno-volatile-asm-stop
27768 @item -mvolatile-asm-stop
27769 @itemx -mno-volatile-asm-stop
27770 Generate (or don't) a stop bit immediately before and after volatile asm
27771 statements.
27772
27773 @opindex mregister-names
27774 @opindex mno-register-names
27775 @item -mregister-names
27776 @itemx -mno-register-names
27777 Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
27778 the stacked registers. This may make assembler output more readable.
27779
27780 @opindex mno-sdata
27781 @opindex msdata
27782 @item -mno-sdata
27783 @itemx -msdata
27784 Disable (or enable) optimizations that use the small data section. This may
27785 be useful for working around optimizer bugs.
27786
27787 @opindex mconstant-gp
27788 @item -mconstant-gp
27789 Generate code that uses a single constant global pointer value. This is
27790 useful when compiling kernel code.
27791
27792 @opindex mauto-pic
27793 @item -mauto-pic
27794 Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
27795 This is useful when compiling firmware code.
27796
27797 @opindex minline-float-divide-min-latency
27798 @item -minline-float-divide-min-latency
27799 Generate code for inline divides of floating-point values
27800 using the minimum latency algorithm.
27801
27802 @opindex minline-float-divide-max-throughput
27803 @item -minline-float-divide-max-throughput
27804 Generate code for inline divides of floating-point values
27805 using the maximum throughput algorithm.
27806
27807 @opindex mno-inline-float-divide
27808 @item -mno-inline-float-divide
27809 Do not generate inline code for divides of floating-point values.
27810
27811 @opindex minline-int-divide-min-latency
27812 @item -minline-int-divide-min-latency
27813 Generate code for inline divides of integer values
27814 using the minimum latency algorithm.
27815
27816 @opindex minline-int-divide-max-throughput
27817 @item -minline-int-divide-max-throughput
27818 Generate code for inline divides of integer values
27819 using the maximum throughput algorithm.
27820
27821 @opindex mno-inline-int-divide
27822 @opindex minline-int-divide
27823 @item -mno-inline-int-divide
27824 Do not generate inline code for divides of integer values.
27825
27826 @opindex minline-sqrt-min-latency
27827 @item -minline-sqrt-min-latency
27828 Generate code for inline square roots
27829 using the minimum latency algorithm.
27830
27831 @opindex minline-sqrt-max-throughput
27832 @item -minline-sqrt-max-throughput
27833 Generate code for inline square roots
27834 using the maximum throughput algorithm.
27835
27836 @opindex mno-inline-sqrt
27837 @item -mno-inline-sqrt
27838 Do not generate inline code for @code{sqrt}.
27839
27840 @opindex mfused-madd
27841 @opindex mno-fused-madd
27842 @item -mfused-madd
27843 @itemx -mno-fused-madd
27844 Do (don't) generate code that uses the fused multiply/add or multiply/subtract
27845 instructions. The default is to use these instructions.
27846
27847 @opindex mno-dwarf2-asm
27848 @opindex mdwarf2-asm
27849 @item -mno-dwarf2-asm
27850 @itemx -mdwarf2-asm
27851 Don't (or do) generate assembler code for the DWARF line number debugging
27852 info. This may be useful when not using the GNU assembler.
27853
27854 @opindex mearly-stop-bits
27855 @opindex mno-early-stop-bits
27856 @item -mearly-stop-bits
27857 @itemx -mno-early-stop-bits
27858 Allow stop bits to be placed earlier than immediately preceding the
27859 instruction that triggered the stop bit. This can improve instruction
27860 scheduling, but does not always do so.
27861
27862 @opindex mfixed-range
27863 @item -mfixed-range=@var{register-range}
27864 Generate code treating the given register range as fixed registers.
27865 A fixed register is one that the register allocator cannot use. This is
27866 useful when compiling kernel code. A register range is specified as
27867 two registers separated by a dash. Multiple register ranges can be
27868 specified separated by a comma.
27869
27870 @opindex mtls-size
27871 @item -mtls-size=@var{tls-size}
27872 Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
27873 64.
27874
27875 @opindex mtune
27876 @item -mtune=@var{cpu-type}
27877 Tune the instruction scheduling for a particular CPU, Valid values are
27878 @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
27879 and @samp{mckinley}.
27880
27881 @opindex milp32
27882 @opindex mlp64
27883 @item -milp32
27884 @itemx -mlp64
27885 Generate code for a 32-bit or 64-bit environment.
27886 The 32-bit environment sets int, long and pointer to 32 bits.
27887 The 64-bit environment sets int to 32 bits and long and pointer
27888 to 64 bits. These are HP-UX specific flags.
27889
27890 @opindex mno-sched-br-data-spec
27891 @opindex msched-br-data-spec
27892 @item -mno-sched-br-data-spec
27893 @itemx -msched-br-data-spec
27894 (Dis/En)able data speculative scheduling before reload.
27895 This results in generation of @code{ld.a} instructions and
27896 the corresponding check instructions (@code{ld.c} / @code{chk.a}).
27897 The default setting is disabled.
27898
27899 @opindex msched-ar-data-spec
27900 @opindex mno-sched-ar-data-spec
27901 @item -msched-ar-data-spec
27902 @itemx -mno-sched-ar-data-spec
27903 (En/Dis)able data speculative scheduling after reload.
27904 This results in generation of @code{ld.a} instructions and
27905 the corresponding check instructions (@code{ld.c} / @code{chk.a}).
27906 The default setting is enabled.
27907
27908 @opindex mno-sched-control-spec
27909 @opindex msched-control-spec
27910 @item -mno-sched-control-spec
27911 @itemx -msched-control-spec
27912 (Dis/En)able control speculative scheduling. This feature is
27913 available only during region scheduling (i.e.@: before reload).
27914 This results in generation of the @code{ld.s} instructions and
27915 the corresponding check instructions @code{chk.s}.
27916 The default setting is disabled.
27917
27918 @opindex msched-br-in-data-spec
27919 @opindex mno-sched-br-in-data-spec
27920 @item -msched-br-in-data-spec
27921 @itemx -mno-sched-br-in-data-spec
27922 (En/Dis)able speculative scheduling of the instructions that
27923 are dependent on the data speculative loads before reload.
27924 This is effective only with @option{-msched-br-data-spec} enabled.
27925 The default setting is enabled.
27926
27927 @opindex msched-ar-in-data-spec
27928 @opindex mno-sched-ar-in-data-spec
27929 @item -msched-ar-in-data-spec
27930 @itemx -mno-sched-ar-in-data-spec
27931 (En/Dis)able speculative scheduling of the instructions that
27932 are dependent on the data speculative loads after reload.
27933 This is effective only with @option{-msched-ar-data-spec} enabled.
27934 The default setting is enabled.
27935
27936 @opindex msched-in-control-spec
27937 @opindex mno-sched-in-control-spec
27938 @item -msched-in-control-spec
27939 @itemx -mno-sched-in-control-spec
27940 (En/Dis)able speculative scheduling of the instructions that
27941 are dependent on the control speculative loads.
27942 This is effective only with @option{-msched-control-spec} enabled.
27943 The default setting is enabled.
27944
27945 @opindex mno-sched-prefer-non-data-spec-insns
27946 @opindex msched-prefer-non-data-spec-insns
27947 @item -mno-sched-prefer-non-data-spec-insns
27948 @itemx -msched-prefer-non-data-spec-insns
27949 If enabled, data-speculative instructions are chosen for schedule
27950 only if there are no other choices at the moment. This makes
27951 the use of the data speculation much more conservative.
27952 The default setting is disabled.
27953
27954 @opindex mno-sched-prefer-non-control-spec-insns
27955 @opindex msched-prefer-non-control-spec-insns
27956 @item -mno-sched-prefer-non-control-spec-insns
27957 @itemx -msched-prefer-non-control-spec-insns
27958 If enabled, control-speculative instructions are chosen for schedule
27959 only if there are no other choices at the moment. This makes
27960 the use of the control speculation much more conservative.
27961 The default setting is disabled.
27962
27963 @opindex mno-sched-count-spec-in-critical-path
27964 @opindex msched-count-spec-in-critical-path
27965 @item -mno-sched-count-spec-in-critical-path
27966 @itemx -msched-count-spec-in-critical-path
27967 If enabled, speculative dependencies are considered during
27968 computation of the instructions priorities. This makes the use of the
27969 speculation a bit more conservative.
27970 The default setting is disabled.
27971
27972 @opindex msched-spec-ldc
27973 @item -msched-spec-ldc
27974 Use a simple data speculation check. This option is on by default.
27975
27976 @opindex msched-spec-ldc
27977 @item -msched-control-spec-ldc
27978 Use a simple check for control speculation. This option is on by default.
27979
27980 @opindex msched-stop-bits-after-every-cycle
27981 @item -msched-stop-bits-after-every-cycle
27982 Place a stop bit after every cycle when scheduling. This option is on
27983 by default.
27984
27985 @opindex msched-fp-mem-deps-zero-cost
27986 @item -msched-fp-mem-deps-zero-cost
27987 Assume that floating-point stores and loads are not likely to cause a conflict
27988 when placed into the same instruction group. This option is disabled by
27989 default.
27990
27991 @opindex msel-sched-dont-check-control-spec
27992 @item -msel-sched-dont-check-control-spec
27993 Generate checks for control speculation in selective scheduling.
27994 This flag is disabled by default.
27995
27996 @opindex msched-max-memory-insns
27997 @item -msched-max-memory-insns=@var{max-insns}
27998 Limit on the number of memory insns per instruction group, giving lower
27999 priority to subsequent memory insns attempting to schedule in the same
28000 instruction group. Frequently useful to prevent cache bank conflicts.
28001 The default value is 1.
28002
28003 @opindex msched-max-memory-insns-hard-limit
28004 @item -msched-max-memory-insns-hard-limit
28005 Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
28006 disallowing more than that number in an instruction group.
28007 Otherwise, the limit is ``soft'', meaning that non-memory operations
28008 are preferred when the limit is reached, but memory operations may still
28009 be scheduled.
28010
28011 @end table
28012
28013 @node LM32 Options
28014 @subsection LM32 Options
28015 @cindex LM32 options
28016
28017 These @option{-m} options are defined for the LatticeMico32 architecture:
28018
28019 @table @gcctabopt
28020 @opindex mbarrel-shift-enabled
28021 @item -mbarrel-shift-enabled
28022 Enable barrel-shift instructions.
28023
28024 @opindex mdivide-enabled
28025 @item -mdivide-enabled
28026 Enable divide and modulus instructions.
28027
28028 @opindex multiply-enabled
28029 @item -mmultiply-enabled
28030 Enable multiply instructions.
28031
28032 @opindex msign-extend-enabled
28033 @item -msign-extend-enabled
28034 Enable sign extend instructions.
28035
28036 @opindex muser-enabled
28037 @item -muser-enabled
28038 Enable user-defined instructions.
28039
28040 @end table
28041
28042 @node LoongArch Options
28043 @subsection LoongArch Options
28044 @cindex LoongArch Options
28045
28046 These command-line options are defined for LoongArch targets:
28047
28048 @table @gcctabopt
28049 @opindex march
28050 @item -march=@var{arch-type}
28051 Generate instructions for the machine type @var{arch-type}.
28052 @option{-march=@var{arch-type}} allows GCC to generate code that
28053 may not run at all on processors other than the one indicated.
28054
28055 The choices for @var{arch-type} are:
28056
28057 @table @samp
28058 @item native
28059 Local processor type detected by the native compiler.
28060 @item loongarch64
28061 Generic LoongArch 64-bit processor.
28062 @item la464
28063 LoongArch LA464-based processor with LSX, LASX.
28064 @item la664
28065 LoongArch LA664-based processor with LSX, LASX
28066 and all LoongArch v1.1 instructions.
28067 @item la64v1.0
28068 LoongArch64 ISA version 1.0.
28069 @item la64v1.1
28070 LoongArch64 ISA version 1.1.
28071 @end table
28072
28073 More information about LoongArch ISA versions can be found at
28074 @uref{https://github.com/loongson/la-toolchain-conventions}.
28075
28076 @opindex mtune
28077 @item -mtune=@var{tune-type}
28078 Optimize the generated code for the given processor target.
28079
28080 The choices for @var{tune-type} are:
28081
28082 @table @samp
28083 @item native
28084 Local processor type detected by the native compiler.
28085 @item generic
28086 Generic LoongArch processor.
28087 @item loongarch64
28088 Generic LoongArch 64-bit processor.
28089 @item la464
28090 LoongArch LA464 core.
28091 @item la664
28092 LoongArch LA664 core.
28093 @end table
28094
28095
28096 @opindex mabi
28097 @item -mabi=@var{base-abi-type}
28098 Generate code for the specified calling convention.
28099 @var{base-abi-type} can be one of:
28100 @table @samp
28101 @item lp64d
28102 Uses 64-bit general purpose registers and 32/64-bit floating-point
28103 registers for parameter passing. Data model is LP64, where @samp{int}
28104 is 32 bits, while @samp{long int} and pointers are 64 bits.
28105 @item lp64f
28106 Uses 64-bit general purpose registers and 32-bit floating-point
28107 registers for parameter passing. Data model is LP64, where @samp{int}
28108 is 32 bits, while @samp{long int} and pointers are 64 bits.
28109 @item lp64s
28110 Uses 64-bit general purpose registers and no floating-point
28111 registers for parameter passing. Data model is LP64, where @samp{int}
28112 is 32 bits, while @samp{long int} and pointers are 64 bits.
28113 @end table
28114
28115 @opindex mfpu
28116 @item -mfpu=@var{fpu-type}
28117 Generate code for the specified FPU type, which can be one of:
28118 @table @samp
28119 @item 64
28120 Allow the use of hardware floating-point instructions for 32-bit
28121 and 64-bit operations.
28122 @item 32
28123 Allow the use of hardware floating-point instructions for 32-bit
28124 operations.
28125 @item none
28126 @item 0
28127 Prevent the use of hardware floating-point instructions.
28128 @end table
28129
28130 @opindex msimd
28131 @item -msimd=@var{simd-type}
28132 Enable generation of LoongArch SIMD instructions for vectorization
28133 and via builtin functions. The value can be one of:
28134 @table @samp
28135 @item lasx
28136 Enable generating instructions from the 256-bit LoongArch Advanced
28137 SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX).
28138 @item lsx
28139 Enable generating instructions from the 128-bit LoongArch SIMD
28140 Extension (LSX).
28141 @item none
28142 No LoongArch SIMD instruction may be generated.
28143 @end table
28144
28145 @opindex msoft-float
28146 @item -msoft-float
28147 Force @option{-mfpu=none} and prevents the use of floating-point
28148 registers for parameter passing. This option may change the target
28149 ABI.
28150
28151 @opindex msingle-float
28152 @item -msingle-float
28153 Force @option{-mfpu=32} and allow the use of 32-bit floating-point
28154 registers for parameter passing. This option may change the target
28155 ABI.
28156
28157 @opindex mdouble-float
28158 @item -mdouble-float
28159 Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
28160 registers for parameter passing. This option may change the target
28161 ABI.
28162
28163 @opindex ml[a]sx
28164 @item -mlasx
28165 @itemx -mno-lasx
28166 @item -mlsx
28167 @itemx -mno-lsx
28168 Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX)
28169 that can be used by the compiler for code generation. Enabling LASX with
28170 @option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx}
28171 automatically disables LASX. These driver-only options act upon the final
28172 @option{msimd} configuration state and make incremental changes in the order
28173 they appear on the GCC driver's command line, deriving the final / canonicalized
28174 @option{msimd} option that is passed to the compiler proper.
28175
28176 @opindex mbranch-cost
28177 @item -mbranch-cost=@var{n}
28178 Set the cost of branches to roughly @var{n} instructions.
28179
28180 @opindex maddr-reg-reg-cost
28181 @item -maddr-reg-reg-cost=@var{n}
28182 Set the cost of ADDRESS_REG_REG to the value calculated by @var{n}.
28183
28184 @opindex mcheck-zero-division
28185 @item -mcheck-zero-division
28186 @itemx -mno-check-zero-divison
28187 Trap (do not trap) on integer division by zero. The default is
28188 @option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
28189 @option{-mno-check-zero-division} for other optimization levels.
28190
28191 @opindex mcond-move-int
28192 @item -mcond-move-int
28193 @itemx -mno-cond-move-int
28194 Conditional moves for integral data in general-purpose registers
28195 are enabled (disabled). The default is @option{-mcond-move-int}.
28196
28197 @opindex mcond-move-float
28198 @item -mcond-move-float
28199 @itemx -mno-cond-move-float
28200 Conditional moves for floating-point registers are enabled (disabled).
28201 The default is @option{-mcond-move-float}.
28202
28203 @opindex mmemcpy
28204 @item -mmemcpy
28205 @itemx -mno-memcpy
28206 Force (do not force) the use of @code{memcpy} for non-trivial block moves.
28207 The default is @option{-mno-memcpy}, which allows GCC to inline most
28208 constant-sized copies. Setting optimization level to @option{-Os} also
28209 forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
28210 behavior if explicitly specified, regardless of the order these options on
28211 the command line.
28212
28213 @opindex mstrict-align
28214 @item -mstrict-align
28215 @itemx -mno-strict-align
28216 Avoid or allow generating memory accesses that may not be aligned on a natural
28217 object boundary as described in the architecture specification. The default is
28218 @option{-mno-strict-align}.
28219
28220 @opindex G
28221 @item -G @var{num}
28222 Put global and static data smaller than @var{num} bytes into a small data
28223 section. The default value is 0.
28224
28225 @opindex mmax-inline-memcpy-size
28226 @item -mmax-inline-memcpy-size=@var{n}
28227 Inline all block moves (such as calls to @code{memcpy} or structure copies)
28228 less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
28229
28230 @opindex mcmodel=
28231 @item -mcmodel=@var{code-model}
28232 Set the code model to one of:
28233 @table @samp
28234 @item tiny-static (Not implemented yet)
28235 @item tiny (Not implemented yet)
28236
28237 @item normal
28238 The text segment must be within 128MB addressing space. The data segment must
28239 be within 2GB addressing space.
28240
28241 @item medium
28242 The text segment and data segment must be within 2GB addressing space.
28243
28244 @item large (Not implemented yet)
28245
28246 @item extreme
28247 This mode does not limit the size of the code segment and data segment.
28248 The @option{-mcmodel=extreme} option is incompatible with @option{-fplt}
28249 and/or @option{-mexplicit-relocs=none}.
28250 @end table
28251 The default code model is @code{normal}.
28252
28253 @item -mexplicit-relocs=@var{style}
28254 Set when to use assembler relocation operators when dealing with symbolic
28255 addresses. The alternative is to use assembler macros instead, which may
28256 limit instruction scheduling but allow linker relaxation.
28257 with @option{-mexplicit-relocs=none} the assembler macros are always used,
28258 with @option{-mexplicit-relocs=always} the assembler relocation operators
28259 are always used, with @option{-mexplicit-relocs=auto} the compiler will
28260 use the relocation operators where the linker relaxation is impossible to
28261 improve the code quality, and macros elsewhere. The default
28262 value for the option is determined with the assembler capability detected
28263 during GCC build-time and the setting of @option{-mrelax}:
28264 @option{-mexplicit-relocs=none} if the assembler does not support
28265 relocation operators at all,
28266 @option{-mexplicit-relocs=always} if the assembler supports relocation
28267 operators but @option{-mrelax} is not enabled,
28268 @option{-mexplicit-relocs=auto} if the assembler supports relocation
28269 operators and @option{-mrelax} is enabled.
28270
28271 @opindex mexplicit-relocs
28272 @item -mexplicit-relocs
28273 An alias of @option{-mexplicit-relocs=always} for backward compatibility.
28274
28275 @opindex mno-explicit-relocs
28276 @item -mno-explicit-relocs
28277 An alias of @option{-mexplicit-relocs=none} for backward compatibility.
28278
28279 @opindex mdirect-extern-access
28280 @item -mdirect-extern-access
28281 @itemx -mno-direct-extern-access
28282 Do not use or use GOT to access external symbols. The default is
28283 @option{-mno-direct-extern-access}: GOT is used for external symbols with
28284 default visibility, but not used for other external symbols.
28285
28286 With @option{-mdirect-extern-access}, GOT is not used and all external
28287 symbols are PC-relatively addressed. It is @strong{only} suitable for
28288 environments where no dynamic link is performed, like firmwares, OS
28289 kernels, executables linked with @option{-static} or @option{-static-pie}.
28290 @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
28291 @option{-fpic}.
28292
28293 @opindex mrelax
28294 @opindex mno-relax
28295 @item -mrelax
28296 @itemx -mno-relax
28297 Take (do not take) advantage of linker relaxations. If
28298 @option{-mpass-mrelax-to-as} is enabled, this option is also passed to
28299 the assembler. The default is determined during GCC build-time by
28300 detecting corresponding assembler support:
28301 @option{-mrelax} if the assembler supports both the @option{-mrelax}
28302 option and the conditional branch relaxation (it's required or the
28303 @code{.align} directives and conditional branch instructions in the
28304 assembly code outputted by GCC may be rejected by the assembler because
28305 of a relocation overflow), @option{-mno-relax} otherwise.
28306
28307 @opindex mpass-mrelax-to-as
28308 @opindex mno-pass-mrelax-to-as
28309 @item -mpass-mrelax-to-as
28310 @itemx -mno-pass-mrelax-to-as
28311 Pass (do not pass) the @option{-mrelax} or @option{-mno-relax} option
28312 to the assembler. The default is determined during GCC build-time by
28313 detecting corresponding assembler support:
28314 @option{-mpass-mrelax-to-as} if the assembler supports the
28315 @option{-mrelax} option, @option{-mno-pass-mrelax-to-as} otherwise.
28316 This option is mostly useful for debugging, or interoperation with
28317 assemblers different from the build-time one.
28318
28319 @opindex mrecip
28320 @item -mrecip
28321 This option enables use of the reciprocal estimate and reciprocal square
28322 root estimate instructions with additional Newton-Raphson steps to increase
28323 precision instead of doing a divide or square root and divide for
28324 floating-point arguments.
28325 These instructions are generated only when @option{-funsafe-math-optimizations}
28326 is enabled together with @option{-ffinite-math-only} and
28327 @option{-fno-trapping-math}.
28328 This option is off by default. Before you can use this option, you must sure the
28329 target CPU supports frecipe and frsqrte instructions.
28330 Note that while the throughput of the sequence is higher than the throughput of
28331 the non-reciprocal instruction, the precision of the sequence can be decreased
28332 by up to 2 ulp (i.e. the inverse of 1.0 equals 0.99999994).
28333
28334 @opindex mrecip=opt
28335 @item -mrecip=@var{opt}
28336 This option controls which reciprocal estimate instructions
28337 may be used. @var{opt} is a comma-separated list of options, which may
28338 be preceded by a @samp{!} to invert the option:
28339
28340 @table @samp
28341 @item all
28342 Enable all estimate instructions.
28343
28344 @item default
28345 Enable the default instructions, equivalent to @option{-mrecip}.
28346
28347 @item none
28348 Disable all estimate instructions, equivalent to @option{-mno-recip}.
28349
28350 @item div
28351 Enable the approximation for scalar division.
28352
28353 @item vec-div
28354 Enable the approximation for vectorized division.
28355
28356 @item sqrt
28357 Enable the approximation for scalar square root.
28358
28359 @item vec-sqrt
28360 Enable the approximation for vectorized square root.
28361
28362 @item rsqrt
28363 Enable the approximation for scalar reciprocal square root.
28364
28365 @item vec-rsqrt
28366 Enable the approximation for vectorized reciprocal square root.
28367 @end table
28368
28369 So, for example, @option{-mrecip=all,!sqrt} enables
28370 all of the reciprocal approximations, except for scalar square root.
28371
28372 @opindex mfrecipe
28373 @opindex mno-frecipe
28374 @item -mfrecipe
28375 @itemx -mno-frecipe
28376 Use (do not use) @code{frecipe.@{s/d@}} and @code{frsqrte.@{s/d@}}
28377 instructions. When build with @option{-march=la664}, it is enabled by default.
28378 The default is @option{-mno-frecipe}.
28379
28380 @opindex mdiv32
28381 @opindex mno-div32
28382 @item -mdiv32
28383 @itemx -mno-div32
28384 Use (do not use) @code{div.w[u]} and @code{mod.w[u]} instructions with input
28385 not sign-extended. When build with @option{-march=la664}, it is enabled by
28386 default. The default is @option{-mno-div32}.
28387
28388 @opindex mlam-bh
28389 @opindex mno-lam-bh
28390 @item -mlam-bh
28391 @itemx -mno-lam-bh
28392 Use (do not use) @code{am@{swap/add@}[_db].@{b/h@}} instructions. When build
28393 with @option{-march=la664}, it is enabled by default. The default is
28394 @option{-mno-lam-bh}.
28395
28396 @opindex mlamcas
28397 @opindex mno-lamcas
28398 @item -mlamcas
28399 @itemx -mno-lamcas
28400 Use (do not use) @code{amcas[_db].@{b/h/w/d@}} instructions. When build with
28401 @option{-march=la664}, it is enabled by default. The default is
28402 @option{-mno-lamcas}.
28403
28404 @opindex mld-seq-sa
28405 @opindex mno-ld-seq-sa
28406 @item -mld-seq-sa
28407 @itemx -mno-ld-seq-sa
28408 Whether a same-address load-load barrier (@code{dbar 0x700}) is needed. When
28409 build with @option{-march=la664}, it is enabled by default. The default is
28410 @option{-mno-ld-seq-sa}, the load-load barrier is needed.
28411
28412 @opindex mtls-dialect
28413 @item -mtls-dialect=@var{opt}
28414 This option controls which tls dialect may be used for general dynamic and
28415 local dynamic TLS models.
28416
28417 @table @samp
28418 @item trad
28419 Use traditional TLS. This is the default.
28420
28421 @item desc
28422 Use TLS descriptors.
28423 @end table
28424
28425 @opindex mannotate-tablejump
28426 @opindex mno-annotate-tablejump
28427 @item -mannotate-tablejump
28428 @itemx -mno-annotate-tablejump
28429 Create an annotation section @code{.discard.tablejump_annotate} to
28430 correlate the @code{jirl} instruction and the jump table when a jump
28431 table is used to optimize the @code{switch} statement. Some external
28432 tools, for example @file{objtool} of the Linux kernel building system,
28433 need the annotation to analysis the control flow. The default is
28434 @option{-mno-annotate-tablejump}.
28435
28436 @item --param loongarch-vect-unroll-limit=@var{n}
28437 The vectorizer will use available tuning information to determine whether it
28438 would be beneficial to unroll the main vectorized loop and by how much. This
28439 parameter set's the upper bound of how much the vectorizer will unroll the main
28440 loop. The default value is six.
28441
28442 @end table
28443
28444
28445 @node M32C Options
28446 @subsection M32C Options
28447 @cindex M32C options
28448
28449 @table @gcctabopt
28450 @opindex mcpu=
28451 @item -mcpu=@var{name}
28452 Select the CPU for which code is generated. @var{name} may be one of
28453 @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
28454 /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
28455 the M32C/80 series.
28456
28457 @opindex msim
28458 @item -msim
28459 Specifies that the program will be run on the simulator. This causes
28460 an alternate runtime library to be linked in which supports, for
28461 example, file I/O@. You must not use this option when generating
28462 programs that will run on real hardware; you must provide your own
28463 runtime library for whatever I/O functions are needed.
28464
28465 @opindex memregs=
28466 @item -memregs=@var{number}
28467 Specifies the number of memory-based pseudo-registers GCC uses
28468 during code generation. These pseudo-registers are used like real
28469 registers, so there is a tradeoff between GCC's ability to fit the
28470 code into available registers, and the performance penalty of using
28471 memory instead of registers. Note that all modules in a program must
28472 be compiled with the same value for this option. Because of that, you
28473 must not use this option with GCC's default runtime libraries.
28474
28475 @end table
28476
28477 @node M32R/D Options
28478 @subsection M32R/D Options
28479 @cindex M32R/D options
28480
28481 These @option{-m} options are defined for Renesas M32R/D architectures:
28482
28483 @table @gcctabopt
28484 @opindex m32r2
28485 @item -m32r2
28486 Generate code for the M32R/2@.
28487
28488 @opindex m32rx
28489 @item -m32rx
28490 Generate code for the M32R/X@.
28491
28492 @opindex m32r
28493 @item -m32r
28494 Generate code for the M32R@. This is the default.
28495
28496 @opindex mmodel=small
28497 @item -mmodel=small
28498 Assume all objects live in the lower 16MB of memory (so that their addresses
28499 can be loaded with the @code{ld24} instruction), and assume all subroutines
28500 are reachable with the @code{bl} instruction.
28501 This is the default.
28502
28503 The addressability of a particular object can be set with the
28504 @code{model} attribute.
28505
28506 @opindex mmodel=medium
28507 @item -mmodel=medium
28508 Assume objects may be anywhere in the 32-bit address space (the compiler
28509 generates @code{seth/add3} instructions to load their addresses), and
28510 assume all subroutines are reachable with the @code{bl} instruction.
28511
28512 @opindex mmodel=large
28513 @item -mmodel=large
28514 Assume objects may be anywhere in the 32-bit address space (the compiler
28515 generates @code{seth/add3} instructions to load their addresses), and
28516 assume subroutines may not be reachable with the @code{bl} instruction
28517 (the compiler generates the much slower @code{seth/add3/jl}
28518 instruction sequence).
28519
28520 @opindex msdata=none
28521 @item -msdata=none
28522 Disable use of the small data area. Variables are put into
28523 one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
28524 @code{section} attribute has been specified).
28525 This is the default.
28526
28527 The small data area consists of sections @code{.sdata} and @code{.sbss}.
28528 Objects may be explicitly put in the small data area with the
28529 @code{section} attribute using one of these sections.
28530
28531 @opindex msdata=sdata
28532 @item -msdata=sdata
28533 Put small global and static data in the small data area, but do not
28534 generate special code to reference them.
28535
28536 @opindex msdata=use
28537 @item -msdata=use
28538 Put small global and static data in the small data area, and generate
28539 special instructions to reference them.
28540
28541 @opindex G
28542 @cindex smaller data references
28543 @item -G @var{num}
28544 Put global and static objects less than or equal to @var{num} bytes
28545 into the small data or BSS sections instead of the normal data or BSS
28546 sections. The default value of @var{num} is 8.
28547 The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
28548 for this option to have any effect.
28549
28550 All modules should be compiled with the same @option{-G @var{num}} value.
28551 Compiling with different values of @var{num} may or may not work; if it
28552 doesn't the linker gives an error message---incorrect code is not
28553 generated.
28554
28555 @opindex mdebug
28556 @item -mdebug
28557 Makes the M32R-specific code in the compiler display some statistics
28558 that might help in debugging programs.
28559
28560 @opindex malign-loops
28561 @item -malign-loops
28562 Align all loops to a 32-byte boundary.
28563
28564 @opindex mno-align-loops
28565 @item -mno-align-loops
28566 Do not enforce a 32-byte alignment for loops. This is the default.
28567
28568 @opindex missue-rate=@var{number}
28569 @item -missue-rate=@var{number}
28570 Issue @var{number} instructions per cycle. @var{number} can only be 1
28571 or 2.
28572
28573 @opindex mbranch-cost=@var{number}
28574 @item -mbranch-cost=@var{number}
28575 @var{number} can only be 1 or 2. If it is 1 then branches are
28576 preferred over conditional code, if it is 2, then the opposite applies.
28577
28578 @opindex mflush-trap=@var{number}
28579 @item -mflush-trap=@var{number}
28580 Specifies the trap number to use to flush the cache. The default is
28581 12. Valid numbers are between 0 and 15 inclusive.
28582
28583 @opindex mno-flush-trap
28584 @item -mno-flush-trap
28585 Specifies that the cache cannot be flushed by using a trap.
28586
28587 @opindex mflush-func=@var{name}
28588 @item -mflush-func=@var{name}
28589 Specifies the name of the operating system function to call to flush
28590 the cache. The default is @samp{_flush_cache}, but a function call
28591 is only used if a trap is not available.
28592
28593 @opindex mno-flush-func
28594 @item -mno-flush-func
28595 Indicates that there is no OS function for flushing the cache.
28596
28597 @end table
28598
28599 @node M680x0 Options
28600 @subsection M680x0 Options
28601 @cindex M680x0 options
28602
28603 These are the @samp{-m} options defined for M680x0 and ColdFire processors.
28604 The default settings depend on which architecture was selected when
28605 the compiler was configured; the defaults for the most common choices
28606 are given below.
28607
28608 @table @gcctabopt
28609 @opindex march
28610 @item -march=@var{arch}
28611 Generate code for a specific M680x0 or ColdFire instruction set
28612 architecture. Permissible values of @var{arch} for M680x0
28613 architectures are: @samp{68000}, @samp{68010}, @samp{68020},
28614 @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
28615 architectures are selected according to Freescale's ISA classification
28616 and the permissible values are: @samp{isaa}, @samp{isaaplus},
28617 @samp{isab} and @samp{isac}.
28618
28619 GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
28620 code for a ColdFire target. The @var{arch} in this macro is one of the
28621 @option{-march} arguments given above.
28622
28623 When used together, @option{-march} and @option{-mtune} select code
28624 that runs on a family of similar processors but that is optimized
28625 for a particular microarchitecture.
28626
28627 @opindex mcpu
28628 @item -mcpu=@var{cpu}
28629 Generate code for a specific M680x0 or ColdFire processor.
28630 The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
28631 @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
28632 and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
28633 below, which also classifies the CPUs into families:
28634
28635 @multitable @columnfractions 0.20 0.80
28636 @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
28637 @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}
28638 @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
28639 @item @samp{5206e} @tab @samp{5206e}
28640 @item @samp{5208} @tab @samp{5207} @samp{5208}
28641 @item @samp{5211a} @tab @samp{5210a} @samp{5211a}
28642 @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
28643 @item @samp{5216} @tab @samp{5214} @samp{5216}
28644 @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
28645 @item @samp{5225} @tab @samp{5224} @samp{5225}
28646 @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
28647 @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
28648 @item @samp{5249} @tab @samp{5249}
28649 @item @samp{5250} @tab @samp{5250}
28650 @item @samp{5271} @tab @samp{5270} @samp{5271}
28651 @item @samp{5272} @tab @samp{5272}
28652 @item @samp{5275} @tab @samp{5274} @samp{5275}
28653 @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
28654 @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
28655 @item @samp{5307} @tab @samp{5307}
28656 @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
28657 @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
28658 @item @samp{5407} @tab @samp{5407}
28659 @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}
28660 @end multitable
28661
28662 @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
28663 @var{arch} is compatible with @var{cpu}. Other combinations of
28664 @option{-mcpu} and @option{-march} are rejected.
28665
28666 GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
28667 @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
28668 where the value of @var{family} is given by the table above.
28669
28670 @opindex mtune
28671 @item -mtune=@var{tune}
28672 Tune the code for a particular microarchitecture within the
28673 constraints set by @option{-march} and @option{-mcpu}.
28674 The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
28675 @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
28676 and @samp{cpu32}. The ColdFire microarchitectures
28677 are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
28678
28679 You can also use @option{-mtune=68020-40} for code that needs
28680 to run relatively well on 68020, 68030 and 68040 targets.
28681 @option{-mtune=68020-60} is similar but includes 68060 targets
28682 as well. These two options select the same tuning decisions as
28683 @option{-m68020-40} and @option{-m68020-60} respectively.
28684
28685 GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
28686 when tuning for 680x0 architecture @var{arch}. It also defines
28687 @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
28688 option is used. If GCC is tuning for a range of architectures,
28689 as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
28690 it defines the macros for every architecture in the range.
28691
28692 GCC also defines the macro @code{__m@var{uarch}__} when tuning for
28693 ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
28694 of the arguments given above.
28695
28696 @opindex m68000
28697 @opindex mc68000
28698 @item -m68000
28699 @itemx -mc68000
28700 Generate output for a 68000. This is the default
28701 when the compiler is configured for 68000-based systems.
28702 It is equivalent to @option{-march=68000}.
28703
28704 Use this option for microcontrollers with a 68000 or EC000 core,
28705 including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
28706
28707 @opindex m68010
28708 @item -m68010
28709 Generate output for a 68010. This is the default
28710 when the compiler is configured for 68010-based systems.
28711 It is equivalent to @option{-march=68010}.
28712
28713 @opindex m68020
28714 @opindex mc68020
28715 @item -m68020
28716 @itemx -mc68020
28717 Generate output for a 68020. This is the default
28718 when the compiler is configured for 68020-based systems.
28719 It is equivalent to @option{-march=68020}.
28720
28721 @opindex m68030
28722 @item -m68030
28723 Generate output for a 68030. This is the default when the compiler is
28724 configured for 68030-based systems. It is equivalent to
28725 @option{-march=68030}.
28726
28727 @opindex m68040
28728 @item -m68040
28729 Generate output for a 68040. This is the default when the compiler is
28730 configured for 68040-based systems. It is equivalent to
28731 @option{-march=68040}.
28732
28733 This option inhibits the use of 68881/68882 instructions that have to be
28734 emulated by software on the 68040. Use this option if your 68040 does not
28735 have code to emulate those instructions.
28736
28737 @opindex m68060
28738 @item -m68060
28739 Generate output for a 68060. This is the default when the compiler is
28740 configured for 68060-based systems. It is equivalent to
28741 @option{-march=68060}.
28742
28743 This option inhibits the use of 68020 and 68881/68882 instructions that
28744 have to be emulated by software on the 68060. Use this option if your 68060
28745 does not have code to emulate those instructions.
28746
28747 @opindex mcpu32
28748 @item -mcpu32
28749 Generate output for a CPU32. This is the default
28750 when the compiler is configured for CPU32-based systems.
28751 It is equivalent to @option{-march=cpu32}.
28752
28753 Use this option for microcontrollers with a
28754 CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
28755 68336, 68340, 68341, 68349 and 68360.
28756
28757 @opindex m5200
28758 @item -m5200
28759 Generate output for a 520X ColdFire CPU@. This is the default
28760 when the compiler is configured for 520X-based systems.
28761 It is equivalent to @option{-mcpu=5206}, and is now deprecated
28762 in favor of that option.
28763
28764 Use this option for microcontroller with a 5200 core, including
28765 the MCF5202, MCF5203, MCF5204 and MCF5206.
28766
28767 @opindex m5206e
28768 @item -m5206e
28769 Generate output for a 5206e ColdFire CPU@. The option is now
28770 deprecated in favor of the equivalent @option{-mcpu=5206e}.
28771
28772 @opindex m528x
28773 @item -m528x
28774 Generate output for a member of the ColdFire 528X family.
28775 The option is now deprecated in favor of the equivalent
28776 @option{-mcpu=528x}.
28777
28778 @opindex m5307
28779 @item -m5307
28780 Generate output for a ColdFire 5307 CPU@. The option is now deprecated
28781 in favor of the equivalent @option{-mcpu=5307}.
28782
28783 @opindex m5407
28784 @item -m5407
28785 Generate output for a ColdFire 5407 CPU@. The option is now deprecated
28786 in favor of the equivalent @option{-mcpu=5407}.
28787
28788 @opindex mcfv4e
28789 @item -mcfv4e
28790 Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
28791 This includes use of hardware floating-point instructions.
28792 The option is equivalent to @option{-mcpu=547x}, and is now
28793 deprecated in favor of that option.
28794
28795 @opindex m68020-40
28796 @item -m68020-40
28797 Generate output for a 68040, without using any of the new instructions.
28798 This results in code that can run relatively efficiently on either a
28799 68020/68881 or a 68030 or a 68040. The generated code does use the
28800 68881 instructions that are emulated on the 68040.
28801
28802 The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
28803
28804 @opindex m68020-60
28805 @item -m68020-60
28806 Generate output for a 68060, without using any of the new instructions.
28807 This results in code that can run relatively efficiently on either a
28808 68020/68881 or a 68030 or a 68040. The generated code does use the
28809 68881 instructions that are emulated on the 68060.
28810
28811 The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
28812
28813 @opindex mhard-float
28814 @opindex m68881
28815 @item -mhard-float
28816 @itemx -m68881
28817 Generate floating-point instructions. This is the default for 68020
28818 and above, and for ColdFire devices that have an FPU@. It defines the
28819 macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
28820 on ColdFire targets.
28821
28822 @opindex msoft-float
28823 @item -msoft-float
28824 Do not generate floating-point instructions; use library calls instead.
28825 This is the default for 68000, 68010, and 68832 targets. It is also
28826 the default for ColdFire devices that have no FPU.
28827
28828 @opindex mdiv
28829 @opindex mno-div
28830 @item -mdiv
28831 @itemx -mno-div
28832 Generate (do not generate) ColdFire hardware divide and remainder
28833 instructions. If @option{-march} is used without @option{-mcpu},
28834 the default is ``on'' for ColdFire architectures and ``off'' for M680x0
28835 architectures. Otherwise, the default is taken from the target CPU
28836 (either the default CPU, or the one specified by @option{-mcpu}). For
28837 example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
28838 @option{-mcpu=5206e}.
28839
28840 GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
28841
28842 @opindex mshort
28843 @item -mshort
28844 Consider type @code{int} to be 16 bits wide, like @code{short int}.
28845 Additionally, parameters passed on the stack are also aligned to a
28846 16-bit boundary even on targets whose API mandates promotion to 32-bit.
28847
28848 @opindex mno-short
28849 @item -mno-short
28850 Do not consider type @code{int} to be 16 bits wide. This is the default.
28851
28852 @opindex mnobitfield
28853 @opindex mno-bitfield
28854 @item -mnobitfield
28855 @itemx -mno-bitfield
28856 Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
28857 and @option{-m5200} options imply @w{@option{-mnobitfield}}.
28858
28859 @opindex mbitfield
28860 @item -mbitfield
28861 Do use the bit-field instructions. The @option{-m68020} option implies
28862 @option{-mbitfield}. This is the default if you use a configuration
28863 designed for a 68020.
28864
28865 @opindex mrtd
28866 @item -mrtd
28867 Use a different function-calling convention, in which functions
28868 that take a fixed number of arguments return with the @code{rtd}
28869 instruction, which pops their arguments while returning. This
28870 saves one instruction in the caller since there is no need to pop
28871 the arguments there.
28872
28873 This calling convention is incompatible with the one normally
28874 used on Unix, so you cannot use it if you need to call libraries
28875 compiled with the Unix compiler.
28876
28877 Also, you must provide function prototypes for all functions that
28878 take variable numbers of arguments (including @code{printf});
28879 otherwise incorrect code is generated for calls to those
28880 functions.
28881
28882 In addition, seriously incorrect code results if you call a
28883 function with too many arguments. (Normally, extra arguments are
28884 harmlessly ignored.)
28885
28886 The @code{rtd} instruction is supported by the 68010, 68020, 68030,
28887 68040, 68060 and CPU32 processors, but not by the 68000 or 5200.
28888
28889 The default is @option{-mno-rtd}.
28890
28891 @opindex malign-int
28892 @opindex mno-align-int
28893 @item -malign-int
28894 @itemx -mno-align-int
28895 Control whether GCC aligns @code{int}, @code{long}, @code{long long},
28896 @code{float}, @code{double}, and @code{long double} variables on a 32-bit
28897 boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
28898 Aligning variables on 32-bit boundaries produces code that runs somewhat
28899 faster on processors with 32-bit busses at the expense of more memory.
28900
28901 @strong{Warning:} if you use the @option{-malign-int} switch, GCC
28902 aligns structures containing the above types differently than
28903 most published application binary interface specifications for the m68k.
28904
28905 @opindex mpcrel
28906 Use the pc-relative addressing mode of the 68000 directly, instead of
28907 using a global offset table. At present, this option implies @option{-fpic},
28908 allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
28909 not presently supported with @option{-mpcrel}, though this could be supported for
28910 68020 and higher processors.
28911
28912 @opindex mno-strict-align
28913 @opindex mstrict-align
28914 @item -mno-strict-align
28915 @itemx -mstrict-align
28916 Do not (do) assume that unaligned memory references are handled by
28917 the system.
28918
28919 @item -msep-data
28920 Generate code that allows the data segment to be located in a different
28921 area of memory from the text segment. This allows for execute-in-place in
28922 an environment without virtual memory management. This option implies
28923 @option{-fPIC}.
28924
28925 @item -mno-sep-data
28926 Generate code that assumes that the data segment follows the text segment.
28927 This is the default.
28928
28929 @item -mid-shared-library
28930 Generate code that supports shared libraries via the library ID method.
28931 This allows for execute-in-place and shared libraries in an environment
28932 without virtual memory management. This option implies @option{-fPIC}.
28933
28934 @item -mno-id-shared-library
28935 Generate code that doesn't assume ID-based shared libraries are being used.
28936 This is the default.
28937
28938 @item -mshared-library-id=n
28939 Specifies the identification number of the ID-based shared library being
28940 compiled. Specifying a value of 0 generates more compact code; specifying
28941 other values forces the allocation of that number to the current
28942 library, but is no more space- or time-efficient than omitting this option.
28943
28944 @opindex mxgot
28945 @opindex mno-xgot
28946 @item -mxgot
28947 @itemx -mno-xgot
28948 When generating position-independent code for ColdFire, generate code
28949 that works if the GOT has more than 8192 entries. This code is
28950 larger and slower than code generated without this option. On M680x0
28951 processors, this option is not needed; @option{-fPIC} suffices.
28952
28953 GCC normally uses a single instruction to load values from the GOT@.
28954 While this is relatively efficient, it only works if the GOT
28955 is smaller than about 64k. Anything larger causes the linker
28956 to report an error such as:
28957
28958 @cindex relocation truncated to fit (ColdFire)
28959 @smallexample
28960 relocation truncated to fit: R_68K_GOT16O foobar
28961 @end smallexample
28962
28963 If this happens, you should recompile your code with @option{-mxgot}.
28964 It should then work with very large GOTs. However, code generated with
28965 @option{-mxgot} is less efficient, since it takes 4 instructions to fetch
28966 the value of a global symbol.
28967
28968 Note that some linkers, including newer versions of the GNU linker,
28969 can create multiple GOTs and sort GOT entries. If you have such a linker,
28970 you should only need to use @option{-mxgot} when compiling a single
28971 object file that accesses more than 8192 GOT entries. Very few do.
28972
28973 These options have no effect unless GCC is generating
28974 position-independent code.
28975
28976 @opindex mlong-jump-table-offsets
28977 @item -mlong-jump-table-offsets
28978 Use 32-bit offsets in @code{switch} tables. The default is to use
28979 16-bit offsets.
28980
28981 @end table
28982
28983 @node MCore Options
28984 @subsection MCore Options
28985 @cindex MCore options
28986
28987 These are the @samp{-m} options defined for the Motorola M*Core
28988 processors.
28989
28990 @table @gcctabopt
28991
28992 @opindex mhardlit
28993 @opindex mno-hardlit
28994 @item -mhardlit
28995 @itemx -mno-hardlit
28996 Inline constants into the code stream if it can be done in two
28997 instructions or less.
28998
28999 @opindex mdiv
29000 @opindex mno-div
29001 @item -mdiv
29002 @itemx -mno-div
29003 Use the divide instruction. (Enabled by default).
29004
29005 @opindex mrelax-immediate
29006 @opindex mno-relax-immediate
29007 @item -mrelax-immediate
29008 @itemx -mno-relax-immediate
29009 Allow arbitrary-sized immediates in bit operations.
29010
29011 @opindex mwide-bitfields
29012 @opindex mno-wide-bitfields
29013 @item -mwide-bitfields
29014 @itemx -mno-wide-bitfields
29015 Always treat bit-fields as @code{int}-sized.
29016
29017 @opindex m4byte-functions
29018 @opindex mno-4byte-functions
29019 @item -m4byte-functions
29020 @itemx -mno-4byte-functions
29021 Force all functions to be aligned to a 4-byte boundary.
29022
29023 @opindex mcallgraph-data
29024 @opindex mno-callgraph-data
29025 @item -mcallgraph-data
29026 @itemx -mno-callgraph-data
29027 Emit callgraph information.
29028
29029 @opindex mslow-bytes
29030 @opindex mno-slow-bytes
29031 @item -mslow-bytes
29032 @itemx -mno-slow-bytes
29033 Prefer word access when reading byte quantities.
29034
29035 @opindex mlittle-endian
29036 @opindex mbig-endian
29037 @item -mlittle-endian
29038 @itemx -mbig-endian
29039 Generate code for a little-endian target.
29040
29041 @opindex m210
29042 @opindex m340
29043 @item -m210
29044 @itemx -m340
29045 Generate code for the 210 processor.
29046
29047 @opindex mno-lsim
29048 @item -mno-lsim
29049 Assume that runtime support has been provided and so omit the
29050 simulator library (@file{libsim.a)} from the linker command line.
29051
29052 @opindex mstack-increment
29053 @item -mstack-increment=@var{size}
29054 Set the maximum amount for a single stack increment operation. Large
29055 values can increase the speed of programs that contain functions
29056 that need a large amount of stack space, but they can also trigger a
29057 segmentation fault if the stack is extended too much. The default
29058 value is 0x1000.
29059
29060 @end table
29061
29062 @node MicroBlaze Options
29063 @subsection MicroBlaze Options
29064 @cindex MicroBlaze Options
29065
29066 @table @gcctabopt
29067
29068 @opindex msoft-float
29069 @item -msoft-float
29070 Use software emulation for floating point (default).
29071
29072 @opindex mhard-float
29073 @item -mhard-float
29074 Use hardware floating-point instructions.
29075
29076 @opindex mmemcpy
29077 @item -mmemcpy
29078 Do not optimize block moves, use @code{memcpy}.
29079
29080 @opindex mno-clearbss
29081 @item -mno-clearbss
29082 This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
29083
29084 @opindex mcpu=
29085 @item -mcpu=@var{cpu-type}
29086 Use features of, and schedule code for, the given CPU.
29087 Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
29088 where @var{X} is a major version, @var{YY} is the minor version, and
29089 @var{Z} is compatibility code. Example values are @samp{v3.00.a},
29090 @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
29091
29092 @opindex mxl-soft-mul
29093 @item -mxl-soft-mul
29094 Use software multiply emulation (default).
29095
29096 @opindex mxl-soft-div
29097 @item -mxl-soft-div
29098 Use software emulation for divides (default).
29099
29100 @opindex mxl-barrel-shift
29101 @item -mxl-barrel-shift
29102 Use the hardware barrel shifter.
29103
29104 @opindex mxl-pattern-compare
29105 @item -mxl-pattern-compare
29106 Use pattern compare instructions.
29107
29108 @opindex msmall-divides
29109 @item -msmall-divides
29110 Use table lookup optimization for small signed integer divisions.
29111
29112 @opindex mxl-stack-check
29113 @item -mxl-stack-check
29114 This option is deprecated. Use @option{-fstack-check} instead.
29115
29116 @opindex mxl-gp-opt
29117 @item -mxl-gp-opt
29118 Use GP-relative @code{.sdata}/@code{.sbss} sections.
29119
29120 @opindex mxl-multiply-high
29121 @item -mxl-multiply-high
29122 Use multiply high instructions for high part of 32x32 multiply.
29123
29124 @opindex mxl-float-convert
29125 @item -mxl-float-convert
29126 Use hardware floating-point conversion instructions.
29127
29128 @opindex mxl-float-sqrt
29129 @item -mxl-float-sqrt
29130 Use hardware floating-point square root instruction.
29131
29132 @opindex mbig-endian
29133 @item -mbig-endian
29134 Generate code for a big-endian target.
29135
29136 @opindex mlittle-endian
29137 @item -mlittle-endian
29138 Generate code for a little-endian target.
29139
29140 @opindex mxl-reorder
29141 @item -mxl-reorder
29142 Use reorder instructions (swap and byte reversed load/store).
29143
29144 @item -mxl-mode-@var{app-model}
29145 Select application model @var{app-model}. Valid models are
29146 @table @samp
29147 @item executable
29148 normal executable (default), uses startup code @file{crt0.o}.
29149
29150 @item xmdstub
29151 for use with Xilinx Microprocessor Debugger (XMD) based
29152 software intrusive debug agent called xmdstub. This uses startup file
29153 @file{crt1.o} and sets the start address of the program to 0x800.
29154
29155 @item bootstrap
29156 for applications that are loaded using a bootloader.
29157 This model uses startup file @file{crt2.o} which does not contain a processor
29158 reset vector handler. This is suitable for transferring control on a
29159 processor reset to the bootloader rather than the application.
29160
29161 @item novectors
29162 for applications that do not require any of the
29163 MicroBlaze vectors. This option may be useful for applications running
29164 within a monitoring application. This model uses @file{crt3.o} as a startup file.
29165 @end table
29166
29167 Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
29168 @option{-mxl-mode-@var{app-model}}.
29169
29170 @opindex mpic-data-is-text-relative
29171 @item -mpic-data-is-text-relative
29172 Assume that the displacement between the text and data segments is fixed
29173 at static link time. This allows data to be referenced by offset from start of
29174 text address instead of GOT since PC-relative addressing is not supported.
29175
29176 @end table
29177
29178 @node MIPS Options
29179 @subsection MIPS Options
29180 @cindex MIPS options
29181
29182 @table @gcctabopt
29183
29184 @opindex EB
29185 @item -EB
29186 Generate big-endian code.
29187
29188 @opindex EL
29189 @item -EL
29190 Generate little-endian code. This is the default for @samp{mips*el-*-*}
29191 configurations.
29192
29193 @opindex march
29194 @item -march=@var{arch}
29195 Generate code that runs on @var{arch}, which can be the name of a
29196 generic MIPS ISA, or the name of a particular processor.
29197 The ISA names are:
29198 @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
29199 @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
29200 @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
29201 @samp{mips64r5} and @samp{mips64r6}.
29202 The processor names are:
29203 @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
29204 @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
29205 @samp{5kc}, @samp{5kf},
29206 @samp{20kc},
29207 @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
29208 @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
29209 @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
29210 @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
29211 @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
29212 @samp{i6400}, @samp{i6500},
29213 @samp{interaptiv},
29214 @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
29215 @samp{gs464e}, @samp{gs264e},
29216 @samp{m4k},
29217 @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
29218 @samp{m5100}, @samp{m5101},
29219 @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
29220 @samp{orion},
29221 @samp{p5600}, @samp{p6600},
29222 @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
29223 @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
29224 @samp{r6000}, @samp{r8000},
29225 @samp{rm7000}, @samp{rm9000},
29226 @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
29227 @samp{sb1},
29228 @samp{sr71000},
29229 @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
29230 @samp{vr5000}, @samp{vr5400}, @samp{vr5500},
29231 @samp{xlr} and @samp{xlp}.
29232 The special value @samp{from-abi} selects the
29233 most compatible architecture for the selected ABI (that is,
29234 @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
29235
29236 The native Linux/GNU toolchain also supports the value @samp{native},
29237 which selects the best architecture option for the host processor.
29238 @option{-march=native} has no effect if GCC does not recognize
29239 the processor.
29240
29241 In processor names, a final @samp{000} can be abbreviated as @samp{k}
29242 (for example, @option{-march=r2k}). Prefixes are optional, and
29243 @samp{vr} may be written @samp{r}.
29244
29245 Names of the form @samp{@var{n}f2_1} refer to processors with
29246 FPUs clocked at half the rate of the core, names of the form
29247 @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
29248 rate as the core, and names of the form @samp{@var{n}f3_2} refer to
29249 processors with FPUs clocked a ratio of 3:2 with respect to the core.
29250 For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
29251 for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
29252 accepted as synonyms for @samp{@var{n}f1_1}.
29253
29254 GCC defines two macros based on the value of this option. The first
29255 is @code{_MIPS_ARCH}, which gives the name of target architecture, as
29256 a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
29257 where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
29258 For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
29259 to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
29260
29261 Note that the @code{_MIPS_ARCH} macro uses the processor names given
29262 above. In other words, it has the full prefix and does not
29263 abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
29264 the macro names the resolved architecture (either @code{"mips1"} or
29265 @code{"mips3"}). It names the default architecture when no
29266 @option{-march} option is given.
29267
29268 @opindex mtune
29269 @item -mtune=@var{arch}
29270 Optimize for @var{arch}. Among other things, this option controls
29271 the way instructions are scheduled, and the perceived cost of arithmetic
29272 operations. The list of @var{arch} values is the same as for
29273 @option{-march}.
29274
29275 When this option is not used, GCC optimizes for the processor
29276 specified by @option{-march}. By using @option{-march} and
29277 @option{-mtune} together, it is possible to generate code that
29278 runs on a family of processors, but optimize the code for one
29279 particular member of that family.
29280
29281 @option{-mtune} defines the macros @code{_MIPS_TUNE} and
29282 @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
29283 @option{-march} ones described above.
29284
29285 @opindex mips1
29286 @item -mips1
29287 Equivalent to @option{-march=mips1}.
29288
29289 @opindex mips2
29290 @item -mips2
29291 Equivalent to @option{-march=mips2}.
29292
29293 @opindex mips3
29294 @item -mips3
29295 Equivalent to @option{-march=mips3}.
29296
29297 @opindex mips4
29298 @item -mips4
29299 Equivalent to @option{-march=mips4}.
29300
29301 @opindex mips32
29302 @item -mips32
29303 Equivalent to @option{-march=mips32}.
29304
29305 @opindex mips32r3
29306 @item -mips32r3
29307 Equivalent to @option{-march=mips32r3}.
29308
29309 @opindex mips32r5
29310 @item -mips32r5
29311 Equivalent to @option{-march=mips32r5}.
29312
29313 @opindex mips32r6
29314 @item -mips32r6
29315 Equivalent to @option{-march=mips32r6}.
29316
29317 @opindex mips64
29318 @item -mips64
29319 Equivalent to @option{-march=mips64}.
29320
29321 @opindex mips64r2
29322 @item -mips64r2
29323 Equivalent to @option{-march=mips64r2}.
29324
29325 @opindex mips64r3
29326 @item -mips64r3
29327 Equivalent to @option{-march=mips64r3}.
29328
29329 @opindex mips64r5
29330 @item -mips64r5
29331 Equivalent to @option{-march=mips64r5}.
29332
29333 @opindex mips64r6
29334 @item -mips64r6
29335 Equivalent to @option{-march=mips64r6}.
29336
29337 @opindex mips16
29338 @opindex mno-mips16
29339 @item -mips16
29340 @itemx -mno-mips16
29341 Generate (do not generate) MIPS16 code. If GCC is targeting a
29342 MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
29343
29344 MIPS16 code generation can also be controlled on a per-function basis
29345 by means of @code{mips16} and @code{nomips16} attributes.
29346 @xref{Function Attributes}, for more information.
29347
29348 @opindex mmips16e2
29349 @opindex mno-mips16e2
29350 @item -mmips16e2
29351 @itemx -mno-mips16e2
29352 Use (do not use) the MIPS16e2 ASE. This option modifies the behavior
29353 of the @option{-mips16} option such that it targets the MIPS16e2 ASE@.
29354
29355 @opindex mflip-mips16
29356 @item -mflip-mips16
29357 Generate MIPS16 code on alternating functions. This option is provided
29358 for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
29359 not intended for ordinary use in compiling user code.
29360
29361 @opindex minterlink-compressed
29362 @opindex mno-interlink-compressed
29363 @item -minterlink-compressed
29364 @itemx -mno-interlink-compressed
29365 Require (do not require) that code using the standard (uncompressed) MIPS ISA
29366 be link-compatible with MIPS16 and microMIPS code, and vice versa.
29367
29368 For example, code using the standard ISA encoding cannot jump directly
29369 to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
29370 @option{-minterlink-compressed} therefore disables direct jumps unless GCC
29371 knows that the target of the jump is not compressed.
29372
29373 @opindex minterlink-mips16
29374 @opindex mno-interlink-mips16
29375 @item -minterlink-mips16
29376 @itemx -mno-interlink-mips16
29377 Aliases of @option{-minterlink-compressed} and
29378 @option{-mno-interlink-compressed}. These options predate the microMIPS ASE
29379 and are retained for backwards compatibility.
29380
29381 @opindex mabi
29382 @item -mabi=32
29383 @itemx -mabi=o64
29384 @itemx -mabi=n32
29385 @itemx -mabi=64
29386 @itemx -mabi=eabi
29387 Generate code for the given ABI@.
29388
29389 Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
29390 generates 64-bit code when you select a 64-bit architecture, but you
29391 can use @option{-mgp32} to get 32-bit code instead.
29392
29393 For information about the O64 ABI, see
29394 @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
29395
29396 GCC supports a variant of the o32 ABI in which floating-point registers
29397 are 64 rather than 32 bits wide. You can select this combination with
29398 @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
29399 and @code{mfhc1} instructions and is therefore only supported for
29400 MIPS32R2, MIPS32R3 and MIPS32R5 processors.
29401
29402 The register assignments for arguments and return values remain the
29403 same, but each scalar value is passed in a single 64-bit register
29404 rather than a pair of 32-bit registers. For example, scalar
29405 floating-point values are returned in @samp{$f0} only, not a
29406 @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
29407 remains the same in that the even-numbered double-precision registers
29408 are saved.
29409
29410 Two additional variants of the o32 ABI are supported to enable
29411 a transition from 32-bit to 64-bit registers. These are FPXX
29412 (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
29413 The FPXX extension mandates that all code must execute correctly
29414 when run using 32-bit or 64-bit registers. The code can be interlinked
29415 with either FP32 or FP64, but not both.
29416 The FP64A extension is similar to the FP64 extension but forbids the
29417 use of odd-numbered single-precision registers. This can be used
29418 in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
29419 processors and allows both FP32 and FP64A code to interlink and
29420 run in the same process without changing FPU modes.
29421
29422 @opindex mabicalls
29423 @opindex mno-abicalls
29424 @item -mabicalls
29425 @itemx -mno-abicalls
29426 Generate (do not generate) code that is suitable for SVR4-style
29427 dynamic objects. @option{-mabicalls} is the default for SVR4-based
29428 systems.
29429
29430 @item -mshared
29431 @itemx -mno-shared
29432 Generate (do not generate) code that is fully position-independent,
29433 and that can therefore be linked into shared libraries. This option
29434 only affects @option{-mabicalls}.
29435
29436 All @option{-mabicalls} code has traditionally been position-independent,
29437 regardless of options like @option{-fPIC} and @option{-fpic}. However,
29438 as an extension, the GNU toolchain allows executables to use absolute
29439 accesses for locally-binding symbols. It can also use shorter GP
29440 initialization sequences and generate direct calls to locally-defined
29441 functions. This mode is selected by @option{-mno-shared}.
29442
29443 @option{-mno-shared} depends on binutils 2.16 or higher and generates
29444 objects that can only be linked by the GNU linker. However, the option
29445 does not affect the ABI of the final executable; it only affects the ABI
29446 of relocatable objects. Using @option{-mno-shared} generally makes
29447 executables both smaller and quicker.
29448
29449 @option{-mshared} is the default.
29450
29451 @opindex mplt
29452 @opindex mno-plt
29453 @item -mplt
29454 @itemx -mno-plt
29455 Assume (do not assume) that the static and dynamic linkers
29456 support PLTs and copy relocations. This option only affects
29457 @option{-mno-shared -mabicalls}. For the n64 ABI, this option
29458 has no effect without @option{-msym32}.
29459
29460 You can make @option{-mplt} the default by configuring
29461 GCC with @option{--with-mips-plt}. The default is
29462 @option{-mno-plt} otherwise.
29463
29464 @opindex mxgot
29465 @opindex mno-xgot
29466 @item -mxgot
29467 @itemx -mno-xgot
29468 Lift (do not lift) the usual restrictions on the size of the global
29469 offset table.
29470
29471 GCC normally uses a single instruction to load values from the GOT@.
29472 While this is relatively efficient, it only works if the GOT
29473 is smaller than about 64k. Anything larger causes the linker
29474 to report an error such as:
29475
29476 @cindex relocation truncated to fit (MIPS)
29477 @smallexample
29478 relocation truncated to fit: R_MIPS_GOT16 foobar
29479 @end smallexample
29480
29481 If this happens, you should recompile your code with @option{-mxgot}.
29482 This works with very large GOTs, although the code is also
29483 less efficient, since it takes three instructions to fetch the
29484 value of a global symbol.
29485
29486 Note that some linkers can create multiple GOTs. If you have such a
29487 linker, you should only need to use @option{-mxgot} when a single object
29488 file accesses more than 64k's worth of GOT entries. Very few do.
29489
29490 These options have no effect unless GCC is generating position
29491 independent code.
29492
29493 @opindex mgp32
29494 @item -mgp32
29495 Assume that general-purpose registers are 32 bits wide.
29496
29497 @opindex mgp64
29498 @item -mgp64
29499 Assume that general-purpose registers are 64 bits wide.
29500
29501 @opindex mfp32
29502 @item -mfp32
29503 Assume that floating-point registers are 32 bits wide.
29504
29505 @opindex mfp64
29506 @item -mfp64
29507 Assume that floating-point registers are 64 bits wide.
29508
29509 @opindex mfpxx
29510 @item -mfpxx
29511 Do not assume the width of floating-point registers.
29512
29513 @opindex mhard-float
29514 @item -mhard-float
29515 Use floating-point coprocessor instructions.
29516
29517 @opindex msoft-float
29518 @item -msoft-float
29519 Do not use floating-point coprocessor instructions. Implement
29520 floating-point calculations using library calls instead.
29521
29522 @opindex mno-float
29523 @item -mno-float
29524 Equivalent to @option{-msoft-float}, but additionally asserts that the
29525 program being compiled does not perform any floating-point operations.
29526 This option is presently supported only by some bare-metal MIPS
29527 configurations, where it may select a special set of libraries
29528 that lack all floating-point support (including, for example, the
29529 floating-point @code{printf} formats).
29530 If code compiled with @option{-mno-float} accidentally contains
29531 floating-point operations, it is likely to suffer a link-time
29532 or run-time failure.
29533
29534 @opindex msingle-float
29535 @item -msingle-float
29536 Assume that the floating-point coprocessor only supports single-precision
29537 operations.
29538
29539 @opindex mdouble-float
29540 @item -mdouble-float
29541 Assume that the floating-point coprocessor supports double-precision
29542 operations. This is the default.
29543
29544 @opindex modd-spreg
29545 @opindex mno-odd-spreg
29546 @item -modd-spreg
29547 @itemx -mno-odd-spreg
29548 Enable the use of odd-numbered single-precision floating-point registers
29549 for the o32 ABI. This is the default for processors that are known to
29550 support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
29551 is set by default.
29552
29553 @opindex mabs=2008
29554 @opindex mabs=legacy
29555 @item -mabs=2008
29556 @itemx -mabs=legacy
29557 These options control the treatment of the special not-a-number (NaN)
29558 IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
29559 @code{neg.@i{fmt}} machine instructions.
29560
29561 By default or when @option{-mabs=legacy} is used the legacy
29562 treatment is selected. In this case these instructions are considered
29563 arithmetic and avoided where correct operation is required and the
29564 input operand might be a NaN. A longer sequence of instructions that
29565 manipulate the sign bit of floating-point datum manually is used
29566 instead unless the @option{-ffinite-math-only} option has also been
29567 specified.
29568
29569 The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
29570 this case these instructions are considered non-arithmetic and therefore
29571 operating correctly in all cases, including in particular where the
29572 input operand is a NaN. These instructions are therefore always used
29573 for the respective operations.
29574
29575 @opindex mnan=2008
29576 @opindex mnan=legacy
29577 @item -mnan=2008
29578 @itemx -mnan=legacy
29579 These options control the encoding of the special not-a-number (NaN)
29580 IEEE 754 floating-point data.
29581
29582 The @option{-mnan=legacy} option selects the legacy encoding. In this
29583 case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
29584 significand field being 0, whereas signaling NaNs (sNaNs) are denoted
29585 by the first bit of their trailing significand field being 1.
29586
29587 The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
29588 this case qNaNs are denoted by the first bit of their trailing
29589 significand field being 1, whereas sNaNs are denoted by the first bit of
29590 their trailing significand field being 0.
29591
29592 The default is @option{-mnan=legacy} unless GCC has been configured with
29593 @option{--with-nan=2008}.
29594
29595 @opindex mllsc
29596 @opindex mno-llsc
29597 @item -mllsc
29598 @itemx -mno-llsc
29599 Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
29600 implement atomic memory built-in functions. When neither option is
29601 specified, GCC uses the instructions if the target architecture
29602 supports them.
29603
29604 @option{-mllsc} is useful if the runtime environment can emulate the
29605 instructions and @option{-mno-llsc} can be useful when compiling for
29606 nonstandard ISAs. You can make either option the default by
29607 configuring GCC with @option{--with-llsc} and @option{--without-llsc}
29608 respectively. @option{--with-llsc} is the default for some
29609 configurations; see the installation documentation for details.
29610
29611 @opindex mdsp
29612 @opindex mno-dsp
29613 @item -mdsp
29614 @itemx -mno-dsp
29615 Use (do not use) revision 1 of the MIPS DSP ASE@.
29616 @xref{MIPS DSP Built-in Functions}. This option defines the
29617 preprocessor macro @code{__mips_dsp}. It also defines
29618 @code{__mips_dsp_rev} to 1.
29619
29620 @opindex mdspr2
29621 @opindex mno-dspr2
29622 @item -mdspr2
29623 @itemx -mno-dspr2
29624 Use (do not use) revision 2 of the MIPS DSP ASE@.
29625 @xref{MIPS DSP Built-in Functions}. This option defines the
29626 preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
29627 It also defines @code{__mips_dsp_rev} to 2.
29628
29629 @opindex msmartmips
29630 @opindex mno-smartmips
29631 @item -msmartmips
29632 @itemx -mno-smartmips
29633 Use (do not use) the MIPS SmartMIPS ASE.
29634
29635 @opindex mpaired-single
29636 @opindex mno-paired-single
29637 @item -mpaired-single
29638 @itemx -mno-paired-single
29639 Use (do not use) paired-single floating-point instructions.
29640 @xref{MIPS Paired-Single Support}. This option requires
29641 hardware floating-point support to be enabled.
29642
29643 @opindex mdmx
29644 @opindex mno-mdmx
29645 @item -mdmx
29646 @itemx -mno-mdmx
29647 Use (do not use) MIPS Digital Media Extension instructions.
29648 This option can only be used when generating 64-bit code and requires
29649 hardware floating-point support to be enabled.
29650
29651 @opindex mips3d
29652 @opindex mno-mips3d
29653 @item -mips3d
29654 @itemx -mno-mips3d
29655 Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
29656 The option @option{-mips3d} implies @option{-mpaired-single}.
29657
29658 @opindex mmicromips
29659 @opindex mno-mmicromips
29660 @item -mmicromips
29661 @itemx -mno-micromips
29662 Generate (do not generate) microMIPS code.
29663
29664 MicroMIPS code generation can also be controlled on a per-function basis
29665 by means of @code{micromips} and @code{nomicromips} attributes.
29666 @xref{Function Attributes}, for more information.
29667
29668 @opindex mmt
29669 @opindex mno-mt
29670 @item -mmt
29671 @itemx -mno-mt
29672 Use (do not use) MT Multithreading instructions.
29673
29674 @opindex mmcu
29675 @opindex mno-mcu
29676 @item -mmcu
29677 @itemx -mno-mcu
29678 Use (do not use) the MIPS MCU ASE instructions.
29679
29680 @opindex meva
29681 @opindex mno-eva
29682 @item -meva
29683 @itemx -mno-eva
29684 Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
29685
29686 @opindex mvirt
29687 @opindex mno-virt
29688 @item -mvirt
29689 @itemx -mno-virt
29690 Use (do not use) the MIPS Virtualization (VZ) instructions.
29691
29692 @opindex mxpa
29693 @opindex mno-xpa
29694 @item -mxpa
29695 @itemx -mno-xpa
29696 Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
29697
29698 @opindex mcrc
29699 @opindex mno-crc
29700 @item -mcrc
29701 @itemx -mno-crc
29702 Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
29703
29704 @opindex mginv
29705 @opindex mno-ginv
29706 @item -mginv
29707 @itemx -mno-ginv
29708 Use (do not use) the MIPS Global INValidate (GINV) instructions.
29709
29710 @opindex mloongson-mmi
29711 @opindex mno-loongson-mmi
29712 @item -mloongson-mmi
29713 @itemx -mno-loongson-mmi
29714 Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
29715
29716 @opindex mloongson-ext
29717 @opindex mno-loongson-ext
29718 @item -mloongson-ext
29719 @itemx -mno-loongson-ext
29720 Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
29721
29722 @opindex mloongson-ext2
29723 @opindex mno-loongson-ext2
29724 @item -mloongson-ext2
29725 @itemx -mno-loongson-ext2
29726 Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
29727
29728 @opindex mlong64
29729 @item -mlong64
29730 Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
29731 an explanation of the default and the way that the pointer size is
29732 determined.
29733
29734 @opindex mlong32
29735 @item -mlong32
29736 Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
29737
29738 The default size of @code{int}s, @code{long}s and pointers depends on
29739 the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
29740 uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
29741 32-bit @code{long}s. Pointers are the same size as @code{long}s,
29742 or the same size as integer registers, whichever is smaller.
29743
29744 @opindex msym32
29745 @opindex mno-sym32
29746 @item -msym32
29747 @itemx -mno-sym32
29748 Assume (do not assume) that all symbols have 32-bit values, regardless
29749 of the selected ABI@. This option is useful in combination with
29750 @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
29751 to generate shorter and faster references to symbolic addresses.
29752
29753 @opindex G
29754 @item -G @var{num}
29755 Put definitions of externally-visible data in a small data section
29756 if that data is no bigger than @var{num} bytes. GCC can then generate
29757 more efficient accesses to the data; see @option{-mgpopt} for details.
29758
29759 The default @option{-G} option depends on the configuration.
29760
29761 @opindex mlocal-sdata
29762 @opindex mno-local-sdata
29763 @item -mlocal-sdata
29764 @itemx -mno-local-sdata
29765 Extend (do not extend) the @option{-G} behavior to local data too,
29766 such as to static variables in C@. @option{-mlocal-sdata} is the
29767 default for all configurations.
29768
29769 If the linker complains that an application is using too much small data,
29770 you might want to try rebuilding the less performance-critical parts with
29771 @option{-mno-local-sdata}. You might also want to build large
29772 libraries with @option{-mno-local-sdata}, so that the libraries leave
29773 more room for the main program.
29774
29775 @opindex mextern-sdata
29776 @opindex mno-extern-sdata
29777 @item -mextern-sdata
29778 @itemx -mno-extern-sdata
29779 Assume (do not assume) that externally-defined data is in
29780 a small data section if the size of that data is within the @option{-G} limit.
29781 @option{-mextern-sdata} is the default for all configurations.
29782
29783 If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
29784 @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
29785 that is no bigger than @var{num} bytes, you must make sure that @var{Var}
29786 is placed in a small data section. If @var{Var} is defined by another
29787 module, you must either compile that module with a high-enough
29788 @option{-G} setting or attach a @code{section} attribute to @var{Var}'s
29789 definition. If @var{Var} is common, you must link the application
29790 with a high-enough @option{-G} setting.
29791
29792 The easiest way of satisfying these restrictions is to compile
29793 and link every module with the same @option{-G} option. However,
29794 you may wish to build a library that supports several different
29795 small data limits. You can do this by compiling the library with
29796 the highest supported @option{-G} setting and additionally using
29797 @option{-mno-extern-sdata} to stop the library from making assumptions
29798 about externally-defined data.
29799
29800 @opindex mgpopt
29801 @opindex mno-gpopt
29802 @item -mgpopt
29803 @itemx -mno-gpopt
29804 Use (do not use) GP-relative accesses for symbols that are known to be
29805 in a small data section; see @option{-G}, @option{-mlocal-sdata} and
29806 @option{-mextern-sdata}. @option{-mgpopt} is the default for all
29807 configurations.
29808
29809 @option{-mno-gpopt} is useful for cases where the @code{$gp} register
29810 might not hold the value of @code{_gp}. For example, if the code is
29811 part of a library that might be used in a boot monitor, programs that
29812 call boot monitor routines pass an unknown value in @code{$gp}.
29813 (In such situations, the boot monitor itself is usually compiled
29814 with @option{-G0}.)
29815
29816 @option{-mno-gpopt} implies @option{-mno-local-sdata} and
29817 @option{-mno-extern-sdata}.
29818
29819 @opindex membedded-data
29820 @opindex mno-embedded-data
29821 @item -membedded-data
29822 @itemx -mno-embedded-data
29823 Allocate variables to the read-only data section first if possible, then
29824 next in the small data section if possible, otherwise in data. This gives
29825 slightly slower code than the default, but reduces the amount of RAM required
29826 when executing, and thus may be preferred for some embedded systems.
29827
29828 @opindex muninit-const-in-rodata
29829 @opindex mno-uninit-const-in-rodata
29830 @item -muninit-const-in-rodata
29831 @itemx -mno-uninit-const-in-rodata
29832 Put uninitialized @code{const} variables in the read-only data section.
29833 This option is only meaningful in conjunction with @option{-membedded-data}.
29834
29835 @opindex mcode-readable
29836 @item -mcode-readable=@var{setting}
29837 Specify whether GCC may generate code that reads from executable sections.
29838 There are three possible settings:
29839
29840 @table @gcctabopt
29841 @item -mcode-readable=yes
29842 Instructions may freely access executable sections. This is the
29843 default setting.
29844
29845 @item -mcode-readable=pcrel
29846 MIPS16 PC-relative load instructions can access executable sections,
29847 but other instructions must not do so. This option is useful on 4KSc
29848 and 4KSd processors when the code TLBs have the Read Inhibit bit set.
29849 It is also useful on processors that can be configured to have a dual
29850 instruction/data SRAM interface and that, like the M4K, automatically
29851 redirect PC-relative loads to the instruction RAM.
29852
29853 @item -mcode-readable=no
29854 Instructions must not access executable sections. This option can be
29855 useful on targets that are configured to have a dual instruction/data
29856 SRAM interface but that (unlike the M4K) do not automatically redirect
29857 PC-relative loads to the instruction RAM.
29858 @end table
29859
29860 @opindex msplit-addresses
29861 @opindex mno-split-addresses
29862 @item -msplit-addresses
29863 @itemx -mno-split-addresses
29864 Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
29865 relocation operators. This option has been superseded by
29866 @option{-mexplicit-relocs} but is retained for backwards compatibility.
29867
29868 @opindex mexplicit-relocs
29869 @opindex mno-explicit-relocs
29870 @item -mexplicit-relocs=none
29871 @itemx -mexplicit-relocs=base
29872 @itemx -mexplicit-relocs=pcrel
29873 @itemx -mexplicit-relocs
29874 @itemx -mno-explicit-relocs
29875 These options control whether explicit relocs (such as @code{%gp_rel}) are used.
29876 The default value depends on the version of GAS when GCC itself was built.
29877
29878 The @code{base} explicit-relocs support was introduced into GAS in 2001.
29879 The @code{pcrel} explicit-relocs support was introduced into GAS in 2014,
29880 which supports @code{%pcrel_hi} and @code{%pcrel_lo}.
29881
29882 @opindex mcheck-zero-division
29883 @opindex mno-check-zero-division
29884 @item -mcheck-zero-division
29885 @itemx -mno-check-zero-division
29886 Trap (do not trap) on integer division by zero.
29887
29888 The default is @option{-mcheck-zero-division}.
29889
29890 @opindex mdivide-traps
29891 @opindex mdivide-breaks
29892 @item -mdivide-traps
29893 @itemx -mdivide-breaks
29894 MIPS systems check for division by zero by generating either a
29895 conditional trap or a break instruction. Using traps results in
29896 smaller code, but is only supported on MIPS II and later. Also, some
29897 versions of the Linux kernel have a bug that prevents trap from
29898 generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
29899 allow conditional traps on architectures that support them and
29900 @option{-mdivide-breaks} to force the use of breaks.
29901
29902 The default is usually @option{-mdivide-traps}, but this can be
29903 overridden at configure time using @option{--with-divide=breaks}.
29904 Divide-by-zero checks can be completely disabled using
29905 @option{-mno-check-zero-division}.
29906
29907 @opindex mload-store-pairs
29908 @opindex mno-load-store-pairs
29909 @item -mload-store-pairs
29910 @itemx -mno-load-store-pairs
29911 Enable (disable) an optimization that pairs consecutive load or store
29912 instructions to enable load/store bonding. This option is enabled by
29913 default but only takes effect when the selected architecture is known
29914 to support bonding.
29915
29916 @opindex mstrict-align
29917 @opindex mno-strict-align
29918 @opindex munaligned-access
29919 @opindex mno-unaligned-access
29920 @item -mstrict-align
29921 @itemx -mno-strict-align
29922 @itemx -munaligned-access
29923 @itemx -mno-unaligned-access
29924 Disable (enable) direct unaligned access for MIPS Release 6.
29925 MIPSr6 requires load/store unaligned-access support, by hardware or
29926 trap&emulate. So @option{-mstrict-align} may be needed by kernel. The
29927 options @option{-munaligned-access} and @option{-mno-unaligned-access}
29928 are obsoleted, and only for backward-compatible.
29929
29930 @opindex mmemcpy
29931 @opindex mno-memcpy
29932 @item -mmemcpy
29933 @itemx -mno-memcpy
29934 Force (do not force) the use of @code{memcpy} for non-trivial block
29935 moves. The default is @option{-mno-memcpy}, which allows GCC to inline
29936 most constant-sized copies.
29937
29938 @opindex mlong-calls
29939 @opindex mno-long-calls
29940 @item -mlong-calls
29941 @itemx -mno-long-calls
29942 Disable (do not disable) use of the @code{jal} instruction. Calling
29943 functions using @code{jal} is more efficient but requires the caller
29944 and callee to be in the same 256 megabyte segment.
29945
29946 This option has no effect on abicalls code. The default is
29947 @option{-mno-long-calls}.
29948
29949 @opindex mmad
29950 @opindex mno-mad
29951 @item -mmad
29952 @itemx -mno-mad
29953 Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
29954 instructions, as provided by the R4650 ISA@.
29955
29956 @opindex mimadd
29957 @opindex mno-imadd
29958 @item -mimadd
29959 @itemx -mno-imadd
29960 Enable (disable) use of the @code{madd} and @code{msub} integer
29961 instructions. The default is @option{-mimadd} on architectures
29962 that support @code{madd} and @code{msub} except for the 74k
29963 architecture where it was found to generate slower code.
29964
29965 @opindex mfused-madd
29966 @opindex mno-fused-madd
29967 @item -mfused-madd
29968 @itemx -mno-fused-madd
29969 Enable (disable) use of the floating-point multiply-accumulate
29970 instructions, when they are available. The default is
29971 @option{-mfused-madd}.
29972
29973 On the R8000 CPU when multiply-accumulate instructions are used,
29974 the intermediate product is calculated to infinite precision
29975 and is not subject to the FCSR Flush to Zero bit. This may be
29976 undesirable in some circumstances. On other processors the result
29977 is numerically identical to the equivalent computation using
29978 separate multiply, add, subtract and negate instructions.
29979
29980 @opindex nocpp
29981 @item -nocpp
29982 Tell the MIPS assembler to not run its preprocessor over user
29983 assembler files (with a @samp{.s} suffix) when assembling them.
29984
29985 @opindex mfix-24k
29986 @opindex mno-fix-24k
29987 @item -mfix-24k
29988 @itemx -mno-fix-24k
29989 Work around the 24K E48 (lost data on stores during refill) errata.
29990 The workarounds are implemented by the assembler rather than by GCC@.
29991
29992 @opindex mfix-r4000
29993 @opindex mno-fix-r4000
29994 @item -mfix-r4000
29995 @itemx -mno-fix-r4000
29996 Work around certain R4000 CPU errata:
29997 @itemize @minus
29998 @item
29999 A double-word or a variable shift may give an incorrect result if executed
30000 immediately after starting an integer division.
30001 @item
30002 A double-word or a variable shift may give an incorrect result if executed
30003 while an integer multiplication is in progress.
30004 @item
30005 An integer division may give an incorrect result if started in a delay slot
30006 of a taken branch or a jump.
30007 @end itemize
30008
30009 @opindex mfix-r4400
30010 @opindex mno-fix-r4400
30011 @item -mfix-r4400
30012 @itemx -mno-fix-r4400
30013 Work around certain R4400 CPU errata:
30014 @itemize @minus
30015 @item
30016 A double-word or a variable shift may give an incorrect result if executed
30017 immediately after starting an integer division.
30018 @end itemize
30019
30020 @opindex mfix-r10000
30021 @opindex mno-fix-r10000
30022 @item -mfix-r10000
30023 @itemx -mno-fix-r10000
30024 Work around certain R10000 errata:
30025 @itemize @minus
30026 @item
30027 @code{ll}/@code{sc} sequences may not behave atomically on revisions
30028 prior to 3.0. They may deadlock on revisions 2.6 and earlier.
30029 @end itemize
30030
30031 This option can only be used if the target architecture supports
30032 branch-likely instructions. @option{-mfix-r10000} is the default when
30033 @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
30034 otherwise.
30035
30036 @opindex mfix-r5900
30037 @item -mfix-r5900
30038 @itemx -mno-fix-r5900
30039 Do not attempt to schedule the preceding instruction into the delay slot
30040 of a branch instruction placed at the end of a short loop of six
30041 instructions or fewer and always schedule a @code{nop} instruction there
30042 instead. The short loop bug under certain conditions causes loops to
30043 execute only once or twice, due to a hardware bug in the R5900 chip. The
30044 workaround is implemented by the assembler rather than by GCC@.
30045
30046 @opindex mfix-rm7000
30047 @item -mfix-rm7000
30048 @itemx -mno-fix-rm7000
30049 Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
30050 workarounds are implemented by the assembler rather than by GCC@.
30051
30052 @opindex mfix-vr4120
30053 @item -mfix-vr4120
30054 @itemx -mno-fix-vr4120
30055 Work around certain VR4120 errata:
30056 @itemize @minus
30057 @item
30058 @code{dmultu} does not always produce the correct result.
30059 @item
30060 @code{div} and @code{ddiv} do not always produce the correct result if one
30061 of the operands is negative.
30062 @end itemize
30063 The workarounds for the division errata rely on special functions in
30064 @file{libgcc.a}. At present, these functions are only provided by
30065 the @code{mips64vr*-elf} configurations.
30066
30067 Other VR4120 errata require a NOP to be inserted between certain pairs of
30068 instructions. These errata are handled by the assembler, not by GCC itself.
30069
30070 @opindex mfix-vr4130
30071 @item -mfix-vr4130
30072 Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
30073 workarounds are implemented by the assembler rather than by GCC,
30074 although GCC avoids using @code{mflo} and @code{mfhi} if the
30075 VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
30076 instructions are available instead.
30077
30078 @opindex mfix-sb1
30079 @item -mfix-sb1
30080 @itemx -mno-fix-sb1
30081 Work around certain SB-1 CPU core errata.
30082 (This flag currently works around the SB-1 revision 2
30083 ``F1'' and ``F2'' floating-point errata.)
30084
30085 @opindex mr10k-cache-barrier
30086 @item -mr10k-cache-barrier=@var{setting}
30087 Specify whether GCC should insert cache barriers to avoid the
30088 side effects of speculation on R10K processors.
30089
30090 In common with many processors, the R10K tries to predict the outcome
30091 of a conditional branch and speculatively executes instructions from
30092 the ``taken'' branch. It later aborts these instructions if the
30093 predicted outcome is wrong. However, on the R10K, even aborted
30094 instructions can have side effects.
30095
30096 This problem only affects kernel stores and, depending on the system,
30097 kernel loads. As an example, a speculatively-executed store may load
30098 the target memory into cache and mark the cache line as dirty, even if
30099 the store itself is later aborted. If a DMA operation writes to the
30100 same area of memory before the ``dirty'' line is flushed, the cached
30101 data overwrites the DMA-ed data. See the R10K processor manual
30102 for a full description, including other potential problems.
30103
30104 One workaround is to insert cache barrier instructions before every memory
30105 access that might be speculatively executed and that might have side
30106 effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
30107 controls GCC's implementation of this workaround. It assumes that
30108 aborted accesses to any byte in the following regions does not have
30109 side effects:
30110
30111 @enumerate
30112 @item
30113 the memory occupied by the current function's stack frame;
30114
30115 @item
30116 the memory occupied by an incoming stack argument;
30117
30118 @item
30119 the memory occupied by an object with a link-time-constant address.
30120 @end enumerate
30121
30122 It is the kernel's responsibility to ensure that speculative
30123 accesses to these regions are indeed safe.
30124
30125 If the input program contains a function declaration such as:
30126
30127 @smallexample
30128 void foo (void);
30129 @end smallexample
30130
30131 then the implementation of @code{foo} must allow @code{j foo} and
30132 @code{jal foo} to be executed speculatively. GCC honors this
30133 restriction for functions it compiles itself. It expects non-GCC
30134 functions (such as hand-written assembly code) to do the same.
30135
30136 The option has three forms:
30137
30138 @table @gcctabopt
30139 @item -mr10k-cache-barrier=load-store
30140 Insert a cache barrier before a load or store that might be
30141 speculatively executed and that might have side effects even
30142 if aborted.
30143
30144 @item -mr10k-cache-barrier=store
30145 Insert a cache barrier before a store that might be speculatively
30146 executed and that might have side effects even if aborted.
30147
30148 @item -mr10k-cache-barrier=none
30149 Disable the insertion of cache barriers. This is the default setting.
30150 @end table
30151
30152 @opindex mflush-func
30153 @opindex mno-flush-func
30154 @item -mflush-func=@var{func}
30155 @itemx -mno-flush-func
30156 Specifies the function to call to flush the I and D caches, or to not
30157 call any such function. If called, the function must take the same
30158 arguments as the common @code{_flush_func}, that is, the address of the
30159 memory range for which the cache is being flushed, the size of the
30160 memory range, and the number 3 (to flush both caches). The default
30161 depends on the target GCC was configured for, but commonly is either
30162 @code{_flush_func} or @code{__cpu_flush}.
30163
30164 @opindex mbranch-cost
30165 @item -mbranch-cost=@var{num}
30166 Set the cost of branches to roughly @var{num} ``simple'' instructions.
30167 This cost is only a heuristic and is not guaranteed to produce
30168 consistent results across releases. A zero cost redundantly selects
30169 the default, which is based on the @option{-mtune} setting.
30170
30171 @opindex mbranch-likely
30172 @opindex mno-branch-likely
30173 @item -mbranch-likely
30174 @itemx -mno-branch-likely
30175 Enable or disable use of Branch Likely instructions, regardless of the
30176 default for the selected architecture. By default, Branch Likely
30177 instructions may be generated if they are supported by the selected
30178 architecture. An exception is for the MIPS32 and MIPS64 architectures
30179 and processors that implement those architectures; for those, Branch
30180 Likely instructions are not be generated by default because the MIPS32
30181 and MIPS64 architectures specifically deprecate their use.
30182
30183 @opindex mcompact-branches=never
30184 @opindex mcompact-branches=optimal
30185 @opindex mcompact-branches=always
30186 @item -mcompact-branches=never
30187 @itemx -mcompact-branches=optimal
30188 @itemx -mcompact-branches=always
30189 These options control which form of branches will be generated. The
30190 default is @option{-mcompact-branches=optimal}.
30191
30192 The @option{-mcompact-branches=never} option ensures that compact branch
30193 instructions will never be generated.
30194
30195 The @option{-mcompact-branches=always} option ensures that a compact
30196 branch instruction will be generated if available for MIPS Release 6 onwards.
30197 If a compact branch instruction is not available (or pre-R6),
30198 a delay slot form of the branch will be used instead.
30199
30200 If it is used for MIPS16/microMIPS targets, it will be just ignored now.
30201 The behavior for MIPS16/microMIPS may change in future,
30202 since they do have some compact branch instructions.
30203
30204 The @option{-mcompact-branches=optimal} option will cause a delay slot
30205 branch to be used if one is available in the current ISA and the delay
30206 slot is successfully filled. If the delay slot is not filled, a compact
30207 branch will be chosen if one is available.
30208
30209 @opindex mfp-exceptions
30210 @item -mfp-exceptions
30211 @itemx -mno-fp-exceptions
30212 Specifies whether FP exceptions are enabled. This affects how
30213 FP instructions are scheduled for some processors.
30214 The default is that FP exceptions are
30215 enabled.
30216
30217 For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
30218 64-bit code, then we can use both FP pipes. Otherwise, we can only use one
30219 FP pipe.
30220
30221 @opindex mvr4130-align
30222 @item -mvr4130-align
30223 @itemx -mno-vr4130-align
30224 The VR4130 pipeline is two-way superscalar, but can only issue two
30225 instructions together if the first one is 8-byte aligned. When this
30226 option is enabled, GCC aligns pairs of instructions that it
30227 thinks should execute in parallel.
30228
30229 This option only has an effect when optimizing for the VR4130.
30230 It normally makes code faster, but at the expense of making it bigger.
30231 It is enabled by default at optimization level @option{-O3}.
30232
30233 @opindex msynci
30234 @item -msynci
30235 @itemx -mno-synci
30236 Enable (disable) generation of @code{synci} instructions on
30237 architectures that support it. The @code{synci} instructions (if
30238 enabled) are generated when @code{__builtin___clear_cache} is
30239 compiled.
30240
30241 This option defaults to @option{-mno-synci}, but the default can be
30242 overridden by configuring GCC with @option{--with-synci}.
30243
30244 When compiling code for single processor systems, it is generally safe
30245 to use @code{synci}. However, on many multi-core (SMP) systems, it
30246 does not invalidate the instruction caches on all cores and may lead
30247 to undefined behavior.
30248
30249 @opindex mrelax-pic-calls
30250 @item -mrelax-pic-calls
30251 @itemx -mno-relax-pic-calls
30252 Try to turn PIC calls that are normally dispatched via register
30253 @code{$25} into direct calls. This is only possible if the linker can
30254 resolve the destination at link time and if the destination is within
30255 range for a direct call.
30256
30257 @option{-mrelax-pic-calls} is the default if GCC was configured to use
30258 an assembler and a linker that support the @code{.reloc} assembly
30259 directive and @option{-mexplicit-relocs} is in effect. With
30260 @option{-mno-explicit-relocs}, this optimization can be performed by the
30261 assembler and the linker alone without help from the compiler.
30262
30263 @opindex mmcount-ra-address
30264 @opindex mno-mcount-ra-address
30265 @item -mmcount-ra-address
30266 @itemx -mno-mcount-ra-address
30267 Emit (do not emit) code that allows @code{_mcount} to modify the
30268 calling function's return address. When enabled, this option extends
30269 the usual @code{_mcount} interface with a new @var{ra-address}
30270 parameter, which has type @code{intptr_t *} and is passed in register
30271 @code{$12}. @code{_mcount} can then modify the return address by
30272 doing both of the following:
30273 @itemize
30274 @item
30275 Returning the new address in register @code{$31}.
30276 @item
30277 Storing the new address in @code{*@var{ra-address}},
30278 if @var{ra-address} is nonnull.
30279 @end itemize
30280
30281 The default is @option{-mno-mcount-ra-address}.
30282
30283 @opindex mframe-header-opt
30284 @item -mframe-header-opt
30285 @itemx -mno-frame-header-opt
30286 Enable (disable) frame header optimization in the o32 ABI. When using the
30287 o32 ABI, calling functions will allocate 16 bytes on the stack for the called
30288 function to write out register arguments. When enabled, this optimization
30289 will suppress the allocation of the frame header if it can be determined that
30290 it is unused.
30291
30292 This optimization is off by default at all optimization levels.
30293
30294 @opindex mlxc1-sxc1
30295 @item -mlxc1-sxc1
30296 @itemx -mno-lxc1-sxc1
30297 When applicable, enable (disable) the generation of @code{lwxc1},
30298 @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
30299
30300 @opindex mmadd4
30301 @item -mmadd4
30302 @itemx -mno-madd4
30303 When applicable, enable (disable) the generation of 4-operand @code{madd.s},
30304 @code{madd.d} and related instructions. Enabled by default.
30305
30306 @end table
30307
30308 @node MMIX Options
30309 @subsection MMIX Options
30310 @cindex MMIX Options
30311
30312 These options are defined for the MMIX:
30313
30314 @table @gcctabopt
30315 @opindex mlibfuncs
30316 @opindex mno-libfuncs
30317 @item -mlibfuncs
30318 @itemx -mno-libfuncs
30319 Specify that intrinsic library functions are being compiled, passing all
30320 values in registers, no matter the size.
30321
30322 @opindex mepsilon
30323 @opindex mno-epsilon
30324 @item -mepsilon
30325 @itemx -mno-epsilon
30326 Generate floating-point comparison instructions that compare with respect
30327 to the @code{rE} epsilon register.
30328
30329 @opindex mabi=mmixware
30330 @opindex mabi=gnu
30331 @item -mabi=mmixware
30332 @itemx -mabi=gnu
30333 Generate code that passes function parameters and return values that (in
30334 the called function) are seen as registers @code{$0} and up, as opposed to
30335 the GNU ABI which uses global registers @code{$231} and up.
30336
30337 @opindex mzero-extend
30338 @opindex mno-zero-extend
30339 @item -mzero-extend
30340 @itemx -mno-zero-extend
30341 When reading data from memory in sizes shorter than 64 bits, use (do not
30342 use) zero-extending load instructions by default, rather than
30343 sign-extending ones.
30344
30345 @opindex mknuthdiv
30346 @opindex mno-knuthdiv
30347 @item -mknuthdiv
30348 @itemx -mno-knuthdiv
30349 Make the result of a division yielding a remainder have the same sign as
30350 the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
30351 remainder follows the sign of the dividend. Both methods are
30352 arithmetically valid, the latter being almost exclusively used.
30353
30354 @opindex mtoplevel-symbols
30355 @opindex mno-toplevel-symbols
30356 @item -mtoplevel-symbols
30357 @itemx -mno-toplevel-symbols
30358 Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
30359 code can be used with the @code{PREFIX} assembly directive.
30360
30361 @opindex melf
30362 @item -melf
30363 Generate an executable in the ELF format, rather than the default
30364 @samp{mmo} format used by the @command{mmix} simulator.
30365
30366 @opindex mbranch-predict
30367 @opindex mno-branch-predict
30368 @item -mbranch-predict
30369 @itemx -mno-branch-predict
30370 Use (do not use) the probable-branch instructions, when static branch
30371 prediction indicates a probable branch.
30372
30373 @opindex mbase-addresses
30374 @opindex mno-base-addresses
30375 @item -mbase-addresses
30376 @itemx -mno-base-addresses
30377 Generate (do not generate) code that uses @emph{base addresses}. Using a
30378 base address automatically generates a request (handled by the assembler
30379 and the linker) for a constant to be set up in a global register. The
30380 register is used for one or more base address requests within the range 0
30381 to 255 from the value held in the register. The generally leads to short
30382 and fast code, but the number of different data items that can be
30383 addressed is limited. This means that a program that uses lots of static
30384 data may require @option{-mno-base-addresses}.
30385
30386 @opindex msingle-exit
30387 @opindex mno-single-exit
30388 @item -msingle-exit
30389 @itemx -mno-single-exit
30390 Force (do not force) generated code to have a single exit point in each
30391 function.
30392 @end table
30393
30394 @node MN10300 Options
30395 @subsection MN10300 Options
30396 @cindex MN10300 options
30397
30398 These @option{-m} options are defined for Matsushita MN10300 architectures:
30399
30400 @table @gcctabopt
30401 @opindex mmult-bug
30402 @item -mmult-bug
30403 Generate code to avoid bugs in the multiply instructions for the MN10300
30404 processors. This is the default.
30405
30406 @opindex mno-mult-bug
30407 @item -mno-mult-bug
30408 Do not generate code to avoid bugs in the multiply instructions for the
30409 MN10300 processors.
30410
30411 @opindex mam33
30412 @item -mam33
30413 Generate code using features specific to the AM33 processor.
30414
30415 @opindex mno-am33
30416 @item -mno-am33
30417 Do not generate code using features specific to the AM33 processor. This
30418 is the default.
30419
30420 @opindex mam33-2
30421 @item -mam33-2
30422 Generate code using features specific to the AM33/2.0 processor.
30423
30424 @opindex mam34
30425 @item -mam34
30426 Generate code using features specific to the AM34 processor.
30427
30428 @opindex mtune
30429 @item -mtune=@var{cpu-type}
30430 Use the timing characteristics of the indicated CPU type when
30431 scheduling instructions. This does not change the targeted processor
30432 type. The CPU type must be one of @samp{mn10300}, @samp{am33},
30433 @samp{am33-2} or @samp{am34}.
30434
30435 @opindex mreturn-pointer-on-d0
30436 @item -mreturn-pointer-on-d0
30437 When generating a function that returns a pointer, return the pointer
30438 in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
30439 only in @code{a0}, and attempts to call such functions without a prototype
30440 result in errors. Note that this option is on by default; use
30441 @option{-mno-return-pointer-on-d0} to disable it.
30442
30443 @opindex mno-crt0
30444 @item -mno-crt0
30445 Do not link in the C run-time initialization object file.
30446
30447 @opindex mrelax
30448 @item -mrelax
30449 Indicate to the linker that it should perform a relaxation optimization pass
30450 to shorten branches, calls and absolute memory addresses. This option only
30451 has an effect when used on the command line for the final link step.
30452
30453 This option makes symbolic debugging impossible.
30454
30455 @opindex mliw
30456 @item -mliw
30457 Allow the compiler to generate @emph{Long Instruction Word}
30458 instructions if the target is the @samp{AM33} or later. This is the
30459 default. This option defines the preprocessor macro @code{__LIW__}.
30460
30461 @opindex mno-liw
30462 @item -mno-liw
30463 Do not allow the compiler to generate @emph{Long Instruction Word}
30464 instructions. This option defines the preprocessor macro
30465 @code{__NO_LIW__}.
30466
30467 @opindex msetlb
30468 @item -msetlb
30469 Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
30470 instructions if the target is the @samp{AM33} or later. This is the
30471 default. This option defines the preprocessor macro @code{__SETLB__}.
30472
30473 @opindex mno-setlb
30474 @item -mno-setlb
30475 Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
30476 instructions. This option defines the preprocessor macro
30477 @code{__NO_SETLB__}.
30478
30479 @end table
30480
30481 @node Moxie Options
30482 @subsection Moxie Options
30483 @cindex Moxie Options
30484
30485 @table @gcctabopt
30486
30487 @opindex meb
30488 @item -meb
30489 Generate big-endian code. This is the default for @samp{moxie-*-*}
30490 configurations.
30491
30492 @opindex mel
30493 @item -mel
30494 Generate little-endian code.
30495
30496 @opindex mmul.x
30497 @item -mmul.x
30498 Generate mul.x and umul.x instructions. This is the default for
30499 @samp{moxiebox-*-*} configurations.
30500
30501 @opindex mno-crt0
30502 @item -mno-crt0
30503 Do not link in the C run-time initialization object file.
30504
30505 @end table
30506
30507 @node MSP430 Options
30508 @subsection MSP430 Options
30509 @cindex MSP430 Options
30510
30511 These options are defined for the MSP430:
30512
30513 @table @gcctabopt
30514
30515 @opindex masm-hex
30516 @item -masm-hex
30517 Force assembly output to always use hex constants. Normally such
30518 constants are signed decimals, but this option is available for
30519 testsuite and/or aesthetic purposes.
30520
30521 @opindex mmcu=
30522 @item -mmcu=
30523 Select the MCU to target. This is used to create a C preprocessor
30524 symbol based upon the MCU name, converted to upper case and pre- and
30525 post-fixed with @samp{__}. This in turn is used by the
30526 @file{msp430.h} header file to select an MCU-specific supplementary
30527 header file.
30528
30529 The option also sets the ISA to use. If the MCU name is one that is
30530 known to only support the 430 ISA then that is selected, otherwise the
30531 430X ISA is selected. A generic MCU name of @samp{msp430} can also be
30532 used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
30533 name selects the 430X ISA.
30534
30535 In addition an MCU-specific linker script is added to the linker
30536 command line. The script's name is the name of the MCU with
30537 @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
30538 command line defines the C preprocessor symbol @code{__XXX__} and
30539 cause the linker to search for a script called @file{xxx.ld}.
30540
30541 The ISA and hardware multiply supported for the different MCUs is hard-coded
30542 into GCC. However, an external @samp{devices.csv} file can be used to
30543 extend device support beyond those that have been hard-coded.
30544
30545 GCC searches for the @samp{devices.csv} file using the following methods in the
30546 given precedence order, where the first method takes precedence over the
30547 second which takes precedence over the third.
30548
30549 @table @asis
30550 @item Include path specified with @code{-I} and @code{-L}
30551 @samp{devices.csv} is searched for in each of the directories specified by
30552 include paths and linker library search paths.
30553 @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
30554 Define the value of the global environment variable
30555 @samp{MSP430_GCC_INCLUDE_DIR}
30556 to the full path to the directory containing devices.csv, and GCC will search
30557 this directory for devices.csv. If devices.csv is found, this directory is
30558 also registered as an include path and linker library path. Header files
30559 and linker scripts in this directory can therefore be used without manually
30560 specifying @code{-I} and @code{-L} on the command line.
30561 @item The @samp{msp430-elf@{,bare@}/include/devices} directory
30562 Finally, GCC examines @samp{msp430-elf@{,bare@}/include/devices} from the
30563 toolchain root directory. This directory does not exist in a default
30564 installation, but if the user has created it and copied @samp{devices.csv}
30565 there, then the MCU data is read. As above, this directory is
30566 also registered as an include path and linker library path.
30567
30568 @end table
30569 If none of the above search methods find @samp{devices.csv}, then the
30570 hard-coded MCU data is used.
30571
30572
30573 @opindex mwarn-mcu
30574 @opindex mno-warn-mcu
30575 @item -mwarn-mcu
30576 @itemx -mno-warn-mcu
30577 This option enables or disables warnings about conflicts between the
30578 MCU name specified by the @option{-mmcu} option and the ISA set by the
30579 @option{-mcpu} option and/or the hardware multiply support set by the
30580 @option{-mhwmult} option. It also toggles warnings about unrecognized
30581 MCU names. This option is on by default.
30582
30583 @opindex mcpu=
30584 @item -mcpu=
30585 Specifies the ISA to use. Accepted values are @samp{msp430},
30586 @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
30587 @option{-mmcu=} option should be used to select the ISA.
30588
30589 @opindex msim
30590 @item -msim
30591 Link to the simulator runtime libraries and linker script. Overrides
30592 any scripts that would be selected by the @option{-mmcu=} option.
30593
30594 @opindex mlarge
30595 @item -mlarge
30596 Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
30597
30598 @opindex msmall
30599 @item -msmall
30600 Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
30601
30602 @opindex mrelax
30603 @item -mrelax
30604 This option is passed to the assembler and linker, and allows the
30605 linker to perform certain optimizations that cannot be done until
30606 the final link.
30607
30608 @opindex mhwmult=
30609 @item mhwmult=
30610 Describes the type of hardware multiply supported by the target.
30611 Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
30612 for the original 16-bit-only multiply supported by early MCUs.
30613 @samp{32bit} for the 16/32-bit multiply supported by later MCUs and
30614 @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
30615 A value of @samp{auto} can also be given. This tells GCC to deduce
30616 the hardware multiply support based upon the MCU name provided by the
30617 @option{-mmcu} option. If no @option{-mmcu} option is specified or if
30618 the MCU name is not recognized then no hardware multiply support is
30619 assumed. @code{auto} is the default setting.
30620
30621 Hardware multiplies are normally performed by calling a library
30622 routine. This saves space in the generated code. When compiling at
30623 @option{-O3} or higher however the hardware multiplier is invoked
30624 inline. This makes for bigger, but faster code.
30625
30626 The hardware multiply routines disable interrupts whilst running and
30627 restore the previous interrupt state when they finish. This makes
30628 them safe to use inside interrupt handlers as well as in normal code.
30629
30630 @opindex minrt
30631 @item -minrt
30632 Enable the use of a minimum runtime environment - no static
30633 initializers or constructors. This is intended for memory-constrained
30634 devices. The compiler includes special symbols in some objects
30635 that tell the linker and runtime which code fragments are required.
30636
30637 @opindex mtiny-printf
30638 @item -mtiny-printf
30639 Enable reduced code size @code{printf} and @code{puts} library functions.
30640 The @samp{tiny} implementations of these functions are not reentrant, so
30641 must be used with caution in multi-threaded applications.
30642
30643 Support for streams has been removed and the string to be printed will
30644 always be sent to stdout via the @code{write} syscall. The string is not
30645 buffered before it is sent to write.
30646
30647 This option requires Newlib Nano IO, so GCC must be configured with
30648 @samp{--enable-newlib-nano-formatted-io}.
30649
30650 @opindex mmax-inline-shift=
30651 @item -mmax-inline-shift=
30652 This option takes an integer between 0 and 64 inclusive, and sets
30653 the maximum number of inline shift instructions which should be emitted to
30654 perform a shift operation by a constant amount. When this value needs to be
30655 exceeded, an mspabi helper function is used instead. The default value is 4.
30656
30657 This only affects cases where a shift by multiple positions cannot be
30658 completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
30659
30660 Shifts of a 32-bit value are at least twice as costly, so the value passed for
30661 this option is divided by 2 and the resulting value used instead.
30662
30663 @opindex mcode-region
30664 @opindex mdata-region
30665 @item -mcode-region=
30666 @itemx -mdata-region=
30667 These options tell the compiler where to place functions and data that
30668 do not have one of the @code{lower}, @code{upper}, @code{either} or
30669 @code{section} attributes. Possible values are @code{lower},
30670 @code{upper}, @code{either} or @code{any}. The first three behave
30671 like the corresponding attribute. The fourth possible value -
30672 @code{any} - is the default. It leaves placement entirely up to the
30673 linker script and how it assigns the standard sections
30674 (@code{.text}, @code{.data}, etc) to the memory regions.
30675
30676 @opindex msilicon-errata
30677 @item -msilicon-errata=
30678 This option passes on a request to assembler to enable the fixes for
30679 the named silicon errata.
30680
30681 @opindex msilicon-errata-warn
30682 @item -msilicon-errata-warn=
30683 This option passes on a request to the assembler to enable warning
30684 messages when a silicon errata might need to be applied.
30685
30686 @opindex mwarn-devices-csv
30687 @opindex mno-warn-devices-csv
30688 @item -mwarn-devices-csv
30689 @itemx -mno-warn-devices-csv
30690 Warn if @samp{devices.csv} is not found or there are problem parsing it
30691 (default: on).
30692
30693 @end table
30694
30695 @node NDS32 Options
30696 @subsection NDS32 Options
30697 @cindex NDS32 Options
30698
30699 These options are defined for NDS32 implementations:
30700
30701 @table @gcctabopt
30702
30703 @opindex mbig-endian
30704 @item -mbig-endian
30705 Generate code in big-endian mode.
30706
30707 @opindex mlittle-endian
30708 @item -mlittle-endian
30709 Generate code in little-endian mode.
30710
30711 @opindex mreduced-regs
30712 @item -mreduced-regs
30713 Use reduced-set registers for register allocation.
30714
30715 @opindex mfull-regs
30716 @item -mfull-regs
30717 Use full-set registers for register allocation.
30718
30719 @opindex mcmov
30720 @item -mcmov
30721 Generate conditional move instructions.
30722
30723 @opindex mno-cmov
30724 @item -mno-cmov
30725 Do not generate conditional move instructions.
30726
30727 @opindex mext-perf
30728 @item -mext-perf
30729 Generate performance extension instructions.
30730
30731 @opindex mno-ext-perf
30732 @item -mno-ext-perf
30733 Do not generate performance extension instructions.
30734
30735 @opindex mext-perf2
30736 @item -mext-perf2
30737 Generate performance extension 2 instructions.
30738
30739 @opindex mno-ext-perf2
30740 @item -mno-ext-perf2
30741 Do not generate performance extension 2 instructions.
30742
30743 @opindex mext-string
30744 @item -mext-string
30745 Generate string extension instructions.
30746
30747 @opindex mno-ext-string
30748 @item -mno-ext-string
30749 Do not generate string extension instructions.
30750
30751 @opindex mv3push
30752 @item -mv3push
30753 Generate v3 push25/pop25 instructions.
30754
30755 @opindex mno-v3push
30756 @item -mno-v3push
30757 Do not generate v3 push25/pop25 instructions.
30758
30759 @opindex m16-bit
30760 @item -m16-bit
30761 Generate 16-bit instructions.
30762
30763 @opindex mno-16-bit
30764 @item -mno-16-bit
30765 Do not generate 16-bit instructions.
30766
30767 @opindex misr-vector-size
30768 @item -misr-vector-size=@var{num}
30769 Specify the size of each interrupt vector, which must be 4 or 16.
30770
30771 @opindex mcache-block-size
30772 @item -mcache-block-size=@var{num}
30773 Specify the size of each cache block,
30774 which must be a power of 2 between 4 and 512.
30775
30776 @opindex march
30777 @item -march=@var{arch}
30778 Specify the name of the target architecture.
30779
30780 @opindex mcmodel=
30781 @item -mcmodel=@var{code-model}
30782 Set the code model to one of
30783 @table @asis
30784 @item @samp{small}
30785 All the data and read-only data segments must be within 512KB addressing space.
30786 The text segment must be within 16MB addressing space.
30787 @item @samp{medium}
30788 The data segment must be within 512KB while the read-only data segment can be
30789 within 4GB addressing space. The text segment should be still within 16MB
30790 addressing space.
30791 @item @samp{large}
30792 All the text and data segments can be within 4GB addressing space.
30793 @end table
30794
30795 @opindex mctor-dtor
30796 @item -mctor-dtor
30797 Enable constructor/destructor feature.
30798
30799 @opindex mrelax
30800 @item -mrelax
30801 Guide linker to relax instructions.
30802
30803 @end table
30804
30805 @node Nvidia PTX Options
30806 @subsection Nvidia PTX Options
30807 @cindex Nvidia PTX options
30808 @cindex nvptx options
30809
30810 These options are defined for Nvidia PTX:
30811
30812 @table @gcctabopt
30813
30814 @opindex m64
30815 @item -m64
30816 Ignored, but preserved for backward compatibility. Only 64-bit ABI is
30817 supported.
30818
30819 @opindex march
30820 @item -march=@var{architecture-string}
30821 Generate code for the specified PTX ISA target architecture.
30822 Valid architecture strings are
30823 @samp{sm_30}, @samp{sm_35}, @samp{sm_37},
30824 @samp{sm_52}, @samp{sm_53},
30825 @samp{sm_61},
30826 @samp{sm_70}, @samp{sm_75},
30827 @samp{sm_80}, and @samp{sm_89}.
30828 The default depends on how the compiler has been configured, see
30829 @option{--with-arch}.
30830
30831 This option sets the value of the preprocessor macro
30832 @code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
30833 @samp{350}.
30834
30835 @opindex misa
30836 @item -misa=@var{architecture-string}
30837 Alias of @option{-march=}.
30838
30839 @opindex march
30840 @item -march-map=@var{architecture-string}
30841 Select the closest available @option{-march=} value that is not more
30842 capable. For instance, for @option{-march-map=sm_50} select
30843 @option{-march=sm_37}, and for @option{-march-map=sm_53} select
30844 @option{-march=sm_53}.
30845
30846 @opindex mptx
30847 @item -mptx=@var{version-string}
30848 Generate code for the specified PTX ISA version.
30849 Valid version strings are
30850 @samp{3.1},
30851 @samp{4.1}, @samp{4.2},
30852 @samp{5.0},
30853 @samp{6.0}, @samp{6.3},
30854 @samp{7.0}, @samp{7.3}, and @samp{7.8}.
30855 The default PTX ISA version is the one that added support for the
30856 selected PTX ISA target architecture, see @option{-march=}, but at
30857 least @samp{6.3}, or @samp{7.3} for @option{-march=sm_52} and higher.
30858
30859 This option sets the values of the preprocessor macros
30860 @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
30861 for instance, for @samp{3.1} the macros have the values @samp{3} and
30862 @samp{1}, respectively.
30863
30864 @opindex mmainkernel
30865 @item -mmainkernel
30866 Link in code for a __main kernel. This is for stand-alone instead of
30867 offloading execution.
30868
30869 @opindex moptimize
30870 @item -moptimize
30871 Apply partitioned execution optimizations. This is the default when any
30872 level of optimization is selected.
30873
30874 @opindex msoft-stack
30875 @opindex mno-soft-stack
30876 @item -msoft-stack
30877 @itemx -mno-soft-stack
30878 For @option{-mno-soft-stack} (the default, unless @option{-mgomp} has
30879 been specified), use PTX ``native'' stacks, that is,
30880 generate code that uses @code{.local} memory or PTX @code{alloca}
30881 directly for stack storage.
30882 Unless @option{-mptx=7.3} or higher and @option{-march=sm_52} or
30883 higher are active, variable-length arrays and dynamically allocating
30884 memory on the stack with @code{alloca} are not supported.
30885
30886 For @option{-msoft-stack} (implied by @option{-mgomp}),
30887 generate code that does not use @code{.local} memory or PTX @code{alloca}
30888 directly for stack storage. Instead, a per-warp stack pointer is
30889 maintained explicitly. This enables variable-length stack allocation (with
30890 variable-length arrays or @code{alloca}), and when global memory is used for
30891 underlying storage, makes it possible to access automatic variables from other
30892 threads, or with atomic instructions. This code generation variant is used
30893 for OpenMP offloading, but the option is exposed on its own for the purpose
30894 of testing the compiler; to generate code suitable for linking into programs
30895 using OpenMP offloading, use option @option{-mgomp}.
30896
30897 @opindex muniform-simt
30898 @item -muniform-simt
30899 Switch to code generation variant that allows to execute all threads in each
30900 warp, while maintaining memory state and side effects as if only one thread
30901 in each warp was active outside of OpenMP SIMD regions. All atomic operations
30902 and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
30903 current lane index equals the master lane index), and the register being
30904 assigned is copied via a shuffle instruction from the master lane. Outside of
30905 SIMD regions lane 0 is the master; inside, each thread sees itself as the
30906 master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
30907 all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
30908 regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
30909 with current lane index to compute the master lane index.
30910
30911 @opindex mgomp
30912 @item -mgomp
30913 Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
30914 @option{-muniform-simt} options, and selects corresponding multilib variant.
30915
30916 @end table
30917
30918 @node OpenRISC Options
30919 @subsection OpenRISC Options
30920 @cindex OpenRISC Options
30921
30922 These options are defined for OpenRISC:
30923
30924 @table @gcctabopt
30925
30926 @opindex mboard
30927 @item -mboard=@var{name}
30928 Configure a board specific runtime. This will be passed to the linker for
30929 newlib board library linking. The default is @code{or1ksim}.
30930
30931 @opindex mnewlib
30932 @item -mnewlib
30933 This option is ignored; it is for compatibility purposes only. This used to
30934 select linker and preprocessor options for use with newlib.
30935
30936 @opindex msoft-div
30937 @opindex mhard-div
30938 @item -msoft-div
30939 @itemx -mhard-div
30940 Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
30941 This default is hardware divide.
30942
30943 @opindex msoft-mul
30944 @opindex mhard-mul
30945 @item -msoft-mul
30946 @itemx -mhard-mul
30947 Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
30948 This default is hardware multiply.
30949
30950 @opindex msoft-float
30951 @opindex mhard-float
30952 @item -msoft-float
30953 @itemx -mhard-float
30954 Select software or hardware for floating point operations.
30955 The default is software.
30956
30957 @opindex mdouble-float
30958 @item -mdouble-float
30959 When @option{-mhard-float} is selected, enables generation of double-precision
30960 floating point instructions. By default functions from @file{libgcc} are used
30961 to perform double-precision floating point operations.
30962
30963 @opindex munordered-float
30964 @item -munordered-float
30965 When @option{-mhard-float} is selected, enables generation of unordered
30966 floating point compare and set flag (@code{lf.sfun*}) instructions. By default
30967 functions from @file{libgcc} are used to perform unordered floating point
30968 compare and set flag operations.
30969
30970 @opindex mcmov
30971 @item -mcmov
30972 Enable generation of conditional move (@code{l.cmov}) instructions. By
30973 default the equivalent will be generated using set and branch.
30974
30975 @opindex mror
30976 @item -mror
30977 Enable generation of rotate right (@code{l.ror}) instructions. By default
30978 functions from @file{libgcc} are used to perform rotate right operations.
30979
30980 @opindex mrori
30981 @item -mrori
30982 Enable generation of rotate right with immediate (@code{l.rori}) instructions.
30983 By default functions from @file{libgcc} are used to perform rotate right with
30984 immediate operations.
30985
30986 @opindex msext
30987 @item -msext
30988 Enable generation of sign extension (@code{l.ext*}) instructions. By default
30989 memory loads are used to perform sign extension.
30990
30991 @opindex msfimm
30992 @item -msfimm
30993 Enable generation of compare and set flag with immediate (@code{l.sf*i})
30994 instructions. By default extra instructions will be generated to store the
30995 immediate to a register first.
30996
30997 @opindex mshftimm
30998 @item -mshftimm
30999 Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
31000 @code{l.slli}) instructions. By default extra instructions will be generated
31001 to store the immediate to a register first.
31002
31003 @opindex mcmodel=
31004 @opindex mcmodel=small
31005 @item -mcmodel=small
31006 Generate OpenRISC code for the small model: The GOT is limited to 64k and
31007 function call jumps are limited to 64M offsets. This is the default model.
31008
31009 @opindex mcmodel=large
31010 @item -mcmodel=large
31011 Generate OpenRISC code for the large model: The GOT may grow up to 4G in size
31012 and function call jumps can target the full 4G address space.
31013
31014
31015 @end table
31016
31017 @node PDP-11 Options
31018 @subsection PDP-11 Options
31019 @cindex PDP-11 Options
31020
31021 These options are defined for the PDP-11:
31022
31023 @table @gcctabopt
31024 @opindex mfpu
31025 @item -mfpu
31026 Use hardware FPP floating point. This is the default. (FIS floating
31027 point on the PDP-11/40 is not supported.) Implies -m45.
31028
31029 @opindex msoft-float
31030 @item -msoft-float
31031 Do not use hardware floating point.
31032
31033 @opindex mac0
31034 @item -mac0
31035 Return floating-point results in ac0 (fr0 in Unix assembler syntax).
31036
31037 @opindex mno-ac0
31038 @item -mno-ac0
31039 Return floating-point results in memory. This is the default.
31040
31041 @opindex m40
31042 @item -m40
31043 Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
31044
31045 @opindex m45
31046 @item -m45
31047 Generate code for a PDP-11/45. This is the default.
31048
31049 @opindex m10
31050 @item -m10
31051 Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
31052
31053 @opindex mint16
31054 @opindex mno-int32
31055 @item -mint16
31056 @itemx -mno-int32
31057 Use 16-bit @code{int}. This is the default.
31058
31059 @opindex mint32
31060 @opindex mno-int16
31061 @item -mint32
31062 @itemx -mno-int16
31063 Use 32-bit @code{int}.
31064
31065 @opindex msplit
31066 @item -msplit
31067 Target has split instruction and data space. Implies -m45.
31068
31069 @opindex munix-asm
31070 @item -munix-asm
31071 Use Unix assembler syntax.
31072
31073 @opindex mdec-asm
31074 @item -mdec-asm
31075 Use DEC assembler syntax.
31076
31077 @opindex mgnu-asm
31078 @item -mgnu-asm
31079 Use GNU assembler syntax. This is the default.
31080
31081 @opindex mlra
31082 @item -mlra
31083 Use the new LRA register allocator. By default, the old ``reload''
31084 allocator is used.
31085 @end table
31086
31087 @node PowerPC Options
31088 @subsection PowerPC Options
31089 @cindex PowerPC options
31090
31091 These are listed under @xref{RS/6000 and PowerPC Options}.
31092
31093 @node PRU Options
31094 @subsection PRU Options
31095 @cindex PRU Options
31096
31097 These command-line options are defined for PRU target:
31098
31099 @table @gcctabopt
31100 @opindex minrt
31101 @item -minrt
31102 Link with a minimum runtime environment. This can significantly reduce
31103 the size of the final ELF binary, but some standard C runtime features
31104 are removed.
31105
31106 This option disables support for static initializers and constructors.
31107 Beware that the compiler could still generate code with static initializers
31108 and constructors. It is up to the programmer to ensure that the source
31109 program will not use those features.
31110
31111 The minimal startup code would not pass @code{argc} and @code{argv} arguments
31112 to @code{main}, so the latter must be declared as @code{int main (void)}.
31113 This is already the norm for most firmware projects.
31114
31115 @opindex mmcu
31116 @item -mmcu=@var{mcu}
31117 Specify the PRU hardware variant to use. A correspondingly named
31118 spec file would be loaded, passing the memory region sizes to
31119 the linker and defining hardware-specific C macros.
31120
31121 Newlib provides only the @code{sim} spec, intended for running
31122 regression tests using a simulator. Specs for real hardware can be
31123 obtained by installing the
31124 @w{@uref{https://github.com/dinuxbg/gnuprumcu/,GnuPruMcu}} package.
31125
31126 @opindex mno-relax
31127 @item -mno-relax
31128 Make GCC pass the @option{--no-relax} command-line option to the linker
31129 instead of the @option{--relax} option.
31130
31131 @opindex mloop
31132 @item -mloop
31133 Allow (or do not allow) GCC to use the LOOP instruction.
31134
31135 @opindex mabi
31136 @item -mabi=@var{variant}
31137 Specify the ABI variant to output code for. @option{-mabi=ti} selects the
31138 unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
31139 more naturally with certain GCC assumptions. These are the differences:
31140
31141 @table @samp
31142 @item Function Pointer Size
31143 TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
31144 supports only 32-bit data and code pointers.
31145
31146 @item Optional Return Value Pointer
31147 Function return values larger than 64 bits are passed by using a hidden
31148 pointer as the first argument of the function. TI ABI, though, mandates that
31149 the pointer can be NULL in case the caller is not using the returned value.
31150 GNU always passes and expects a valid return value pointer.
31151
31152 @end table
31153
31154 The current @option{-mabi=ti} implementation simply raises a compile error
31155 when any of the above code constructs is detected. As a consequence
31156 the standard C library cannot be built and it is omitted when linking with
31157 @option{-mabi=ti}.
31158
31159 Relaxation is a GNU feature and for safety reasons is disabled when using
31160 @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
31161 instructions, so the GNU linker cannot adjust them when shortening adjacent
31162 LDI32 pseudo instructions.
31163
31164 @end table
31165
31166 @node RISC-V Options
31167 @subsection RISC-V Options
31168 @cindex RISC-V Options
31169
31170 These command-line options are defined for RISC-V targets:
31171
31172 @table @gcctabopt
31173 @opindex mbranch-cost
31174 @item -mbranch-cost=@var{n}
31175 Set the cost of branches to roughly @var{n} instructions.
31176
31177 @opindex plt
31178 @item -mplt
31179 @itemx -mno-plt
31180 When generating PIC code, do or don't allow the use of PLTs. Ignored for
31181 non-PIC. The default is @option{-mplt}.
31182
31183 @opindex mabi
31184 @item -mabi=@var{ABI-string}
31185 Specify integer and floating-point calling convention. @var{ABI-string}
31186 contains two parts: the size of integer types and the registers used for
31187 floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
31188 @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
31189 32-bit), and that floating-point values up to 64 bits wide are passed in F
31190 registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
31191 allows the compiler to generate code that uses the F and D extensions but only
31192 allows floating-point values up to 32 bits long to be passed in registers; or
31193 @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
31194 passed in registers.
31195
31196 The default for this argument is system dependent, users who want a specific
31197 calling convention should specify one explicitly. The valid calling
31198 conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
31199 @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
31200 implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
31201 invalid because the ABI requires 64-bit values be passed in F registers, but F
31202 registers are only 32 bits wide. There are also the @samp{ilp32e} ABI that can
31203 only be used with the @samp{rv32e} architecture and the @samp{lp64e} ABI that
31204 can only be used with the @samp{rv64e}. Those ABIs are not well specified at
31205 present, and are subject to change.
31206
31207 @opindex mfdiv
31208 @item -mfdiv
31209 @itemx -mno-fdiv
31210 Do or don't use hardware floating-point divide and square root instructions.
31211 This requires the F or D extensions for floating-point registers. The default
31212 is to use them if the specified architecture has these instructions.
31213
31214 @opindex mfence-tso
31215 @item -mfence-tso
31216 @itemx -mno-fence-tso
31217 Do or don't use the @samp{fence.tso} instruction, which is unimplemented on
31218 some processors (including those from T-Head). If the @samp{fence.tso}
31219 instruction is not available then a stronger fence is used instead.
31220
31221 @opindex mdiv
31222 @item -mdiv
31223 @itemx -mno-div
31224 Do or don't use hardware instructions for integer division. This requires the
31225 M extension. The default is to use them if the specified architecture has
31226 these instructions.
31227
31228 @opindex misa-spec
31229 @item -misa-spec=@var{ISA-spec-string}
31230 Specify the version of the RISC-V Unprivileged (formerly User-Level)
31231 ISA specification to produce code conforming to. The possibilities
31232 for @var{ISA-spec-string} are:
31233 @table @code
31234 @item 2.2
31235 Produce code conforming to version 2.2.
31236 @item 20190608
31237 Produce code conforming to version 20190608.
31238 @item 20191213
31239 Produce code conforming to version 20191213.
31240 @end table
31241 The default is @option{-misa-spec=20191213} unless GCC has been configured
31242 with @option{--with-isa-spec=} specifying a different default version.
31243
31244 @opindex march
31245 @item -march=@var{ISA-string|Profiles|Profile_ISA-string}
31246 Generate code for given RISC-V ISA or Profiles or a combination of them
31247 (e.g.@: @samp{rv64im} @samp{rvi20u64} @samp{rvi20u64_zbb}). ISA strings and
31248 Profiles must be lower-case. Examples include @samp{rv64i}, @samp{rv32g},
31249 @samp{rv32e}, @samp{rv32imaf}, @samp{rva22u64} and @samp{rva23u64}.
31250 To combine Profiles and optional RISC-V ISA extention, the profile should start
31251 at the beginning of the option, then use underline connect ISA-string (e.g.@:
31252 @samp{rvi20u64_zca_zcb} @samp{rva23u64_zacas}). Additionally, a special value
31253 @option{help} (@option{-march=help}) is accepted to list all supported
31254 extensions.
31255
31256 The syntax of the ISA string is defined as follows:
31257
31258 @table @code
31259 @item The string must start with @samp{rv32} or @samp{rv64}, followed by
31260 @samp{i}, @samp{e}, or @samp{g}, referred to as the base ISA.
31261 @item The subsequent part of the string is a list of extension names. Extension
31262 names can be categorized as multi-letter (e.g.@: @samp{zba}) and single-letter
31263 (e.g.@: @samp{v}). Single-letter extensions can appear consecutively,
31264 but multi-letter extensions must be separated by underscores.
31265 @item An underscore can appear anywhere after the base ISA. It has no specific
31266 effect but is used to improve readability and can act as a separator.
31267 @item Extension names may include an optional version number, following the
31268 syntax @samp{<major>p<minor>} or @samp{<major>}, (e.g.@: @samp{m2p1} or
31269 @samp{m2}).
31270 @end table
31271
31272 Supported extension are listed below:
31273
31274 @include riscv-ext.texi
31275
31276 When @option{-march=} is not specified, use the setting from @option{-mcpu}.
31277
31278 If both @option{-march} and @option{-mcpu=} are not specified, the default for
31279 this argument is system dependent, users who want a specific architecture
31280 extensions should specify one explicitly.
31281
31282 When the RISC-V specifications define an extension as depending on other
31283 extensions, GCC will implicitly add the dependent extensions to the enabled
31284 extension set if they weren't added explicitly.
31285
31286 @opindex mcpu
31287 @item -mcpu=@var{processor-string}
31288 Use architecture of and optimize the output for the given processor, specified
31289 by particular CPU name.
31290 Permissible values for this option are: @samp{mips-p8700}, @samp{sifive-e20},
31291 @samp{sifive-e21}, @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34},
31292 @samp{sifive-e76}, @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54},
31293 @samp{sifive-s76}, @samp{sifive-u54}, @samp{sifive-u74}, @samp{sifive-x280},
31294 @samp{sifive-xp450}, @samp{sifive-x670}, @samp{thead-c906}, @samp{tt-ascalon-d8},
31295 @samp{xiangshan-nanhu}, @samp{xiangshan-kunminghu}, @samp{xt-c908}, @samp{xt-c908v},
31296 @samp{xt-c910}, @samp{xt-c910v2}, @samp{xt-c920}, @samp{xt-c920v2}.
31297
31298 Note that @option{-mcpu} does not override @option{-march} or @option{-mtune}.
31299
31300 @opindex mtune
31301 @item -mtune=@var{processor-string}
31302 Optimize the output for the given processor, specified by microarchitecture or
31303 particular CPU name. Permissible values for this option are:
31304 @samp{generic-ooo}, @samp{mips-p8700}, @samp{rocket}, @samp{sifive-3-series},
31305 @samp{sifive-5-series}, @samp{sifive-7-series}, @samp{size},
31306 @samp{sifive-p400-series}, @samp{sifive-p600-series}, and all valid options for
31307 @option{-mcpu=}.
31308
31309 When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
31310 the default is @samp{rocket} if both are not specified.
31311
31312 The @samp{size} choice is not intended for use by end-users. This is used
31313 when @option{-Os} is specified. It overrides the instruction cost info
31314 provided by @option{-mtune=}, but does not override the pipeline info. This
31315 helps reduce code size while still giving good performance.
31316
31317 @opindex mpreferred-stack-boundary
31318 @item -mpreferred-stack-boundary=@var{num}
31319 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
31320 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
31321 the default is 4 (16 bytes or 128-bits).
31322
31323 @strong{Warning:} If you use this switch, then you must build all modules with
31324 the same value, including any libraries. This includes the system libraries
31325 and startup modules.
31326
31327 @opindex msmall-data-limit
31328 @item -msmall-data-limit=@var{n}
31329 Put global and static data smaller than @var{n} bytes into a special section
31330 (on some targets).
31331
31332 @opindex msave-restore
31333 @item -msave-restore
31334 @itemx -mno-save-restore
31335 Do or don't use smaller but slower prologue and epilogue code that uses
31336 library function calls. The default is to use fast inline prologues and
31337 epilogues.
31338
31339 @opindex mmovcc
31340 @item -mmovcc
31341 @itemx -mno-movcc
31342 Do or don't produce branchless conditional-move code sequences even with
31343 targets that do not have specific instructions for conditional operations.
31344 If enabled, sequences of ALU operations are produced using base integer
31345 ISA instructions where profitable.
31346
31347 @opindex minline-atomics
31348 @item -minline-atomics
31349 @itemx -mno-inline-atomics
31350 Do or don't use smaller but slower subword atomic emulation code that uses
31351 libatomic function calls. The default is to use fast inline subword atomics
31352 that do not require libatomic.
31353
31354 @opindex minline-strlen
31355 @item -minline-strlen
31356 @itemx -mno-inline-strlen
31357 Do or do not attempt to inline strlen calls if possible.
31358 Inlining will only be done if the string is properly aligned
31359 and instructions for accelerated processing are available.
31360 The default is to not inline strlen calls.
31361
31362 @opindex minline-strcmp
31363 @item -minline-strcmp
31364 @itemx -mno-inline-strcmp
31365 Do or do not attempt to inline strcmp calls if possible.
31366 Inlining will only be done if the strings are properly aligned
31367 and instructions for accelerated processing are available.
31368 The default is to not inline strcmp calls.
31369
31370 The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls
31371 the maximum number of bytes compared by the inlined code.
31372 The default value is 64.
31373
31374 @opindex minline-strncmp
31375 @item -minline-strncmp
31376 @itemx -mno-inline-strncmp
31377 Do or do not attempt to inline strncmp calls if possible.
31378 Inlining will only be done if the strings are properly aligned
31379 and instructions for accelerated processing are available.
31380 The default is to not inline strncmp calls.
31381
31382 The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls
31383 the maximum number of bytes compared by the inlined code.
31384 The default value is 64.
31385
31386 @opindex mshorten-memrefs
31387 @item -mshorten-memrefs
31388 @itemx -mno-shorten-memrefs
31389 Do or do not attempt to make more use of compressed load/store instructions by
31390 replacing a load/store of 'base register + large offset' with a new load/store
31391 of 'new base + small offset'. If the new base gets stored in a compressed
31392 register, then the new load/store can be compressed. Currently targets 32-bit
31393 integer load/stores only.
31394
31395 @opindex mstrict-align
31396 @item -mstrict-align
31397 @itemx -mno-strict-align
31398 Do not or do generate unaligned memory accesses. The default is set depending
31399 on whether the processor we are optimizing for supports fast unaligned access
31400 or not.
31401
31402 @opindex mscalar-strict-align
31403 @opindex mno-scalar-strict-align
31404 @item -mscalar-strict-align
31405 @itemx -mno-scalar-strict-align
31406 Do not or do generate unaligned memory accesses. The default is set depending
31407 on whether the processor we are optimizing for supports fast unaligned access
31408 or not. This is an alias for @option{-mstrict-align}.
31409
31410 @opindex mvector-strict-align
31411 @opindex mno-vector-strict-align
31412 @item -mvector-strict-align
31413 @itemx -mno-vector-strict-align
31414 Do not or do generate unaligned vector memory accesses. The default is set
31415 to off unless the processor we are optimizing for explicitly supports
31416 element-misaligned vector memory access.
31417
31418
31419 @opindex mcmodel=
31420 @opindex mcmodel=medlow
31421 @item -mcmodel=medlow
31422 Generate code for the medium-low code model. The program and its statically
31423 defined symbols must lie within a single 2 GiB address range and must lie
31424 between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be statically
31425 or dynamically linked. This is the default code model unless GCC has been
31426 configured with @option{--with-cmodel=} specifying a different default code
31427 model.
31428
31429 @opindex mcmodel=medany
31430 @item -mcmodel=medany
31431 Generate code for the medium-any code model. The program and its statically
31432 defined symbols must be within any single 2 GiB address range. Programs can be
31433 statically or dynamically linked.
31434
31435 The code generated by the medium-any code model is position-independent, but is
31436 not guaranteed to function correctly when linked into position-independent
31437 executables or libraries.
31438
31439 @opindex mcmodel=large
31440 @item -mcmodel=large
31441 Generate code for a large code model, which has no restrictions on size or
31442 placement of symbols.
31443
31444 @item -mexplicit-relocs
31445 @itemx -mno-exlicit-relocs
31446 Use or do not use assembler relocation operators when dealing with symbolic
31447 addresses. The alternative is to use assembler macros instead, which may
31448 limit optimization.
31449
31450 @opindex mrelax
31451 @item -mrelax
31452 @itemx -mno-relax
31453 Take advantage of linker relaxations to reduce the number of instructions
31454 required to materialize symbol addresses. The default is to take advantage of
31455 linker relaxations.
31456
31457 @opindex mriscv-attribute
31458 @item -mriscv-attribute
31459 @itemx -mno-riscv-attribute
31460 Emit (do not emit) RISC-V attribute to record extra information into ELF
31461 objects. This feature requires at least binutils 2.32.
31462
31463 @opindex mcsr-check
31464 @item -mcsr-check
31465 @itemx -mno-csr-check
31466 Enables or disables the CSR checking.
31467
31468 @opindex malign-data
31469 @item -malign-data=@var{type}
31470 Control how GCC aligns variables and constants of array, structure, or union
31471 types. Supported values for @var{type} are @samp{xlen} which uses x register
31472 width as the alignment value, and @samp{natural} which uses natural alignment.
31473 @samp{xlen} is the default.
31474
31475 @opindex mbig-endian
31476 @item -mbig-endian
31477 Generate big-endian code. This is the default when GCC is configured for a
31478 @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
31479
31480 @opindex mlittle-endian
31481 @item -mlittle-endian
31482 Generate little-endian code. This is the default when GCC is configured for a
31483 @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
31484 @samp{riscv32be-*-*} target.
31485
31486 @opindex mstack-protector-guard
31487 @opindex mstack-protector-guard-reg
31488 @opindex mstack-protector-guard-offset
31489 @item -mstack-protector-guard=@var{guard}
31490 @itemx -mstack-protector-guard-reg=@var{reg}
31491 @itemx -mstack-protector-guard-offset=@var{offset}
31492 Generate stack protection code using canary at @var{guard}. Supported
31493 locations are @samp{global} for a global canary or @samp{tls} for per-thread
31494 canary in the TLS block.
31495
31496 With the latter choice the options
31497 @option{-mstack-protector-guard-reg=@var{reg}} and
31498 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
31499 which register to use as base register for reading the canary,
31500 and from what offset from that base register. There is no default
31501 register or offset as this is entirely for use within the Linux
31502 kernel.
31503
31504 @opindex mtls-dialect=desc
31505 @item -mtls-dialect=desc
31506 Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
31507 of TLS variables.
31508
31509 @opindex mtls-dialect=trad
31510 @item -mtls-dialect=trad
31511 Use traditional TLS as the thread-local storage mechanism for dynamic accesses
31512 of TLS variables. This is the default.
31513 @end table
31514
31515 @node RL78 Options
31516 @subsection RL78 Options
31517 @cindex RL78 Options
31518
31519 @table @gcctabopt
31520
31521 @opindex msim
31522 @item -msim
31523 Links in additional target libraries to support operation within a
31524 simulator.
31525
31526 @opindex mmul
31527 @item -mmul=none
31528 @itemx -mmul=g10
31529 @itemx -mmul=g13
31530 @itemx -mmul=g14
31531 @itemx -mmul=rl78
31532 Specifies the type of hardware multiplication and division support to
31533 be used. The simplest is @code{none}, which uses software for both
31534 multiplication and division. This is the default. The @code{g13}
31535 value is for the hardware multiply/divide peripheral found on the
31536 RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
31537 the multiplication and division instructions supported by the RL78/G14
31538 (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
31539 the value @code{mg10} is an alias for @code{none}.
31540
31541 In addition a C preprocessor macro is defined, based upon the setting
31542 of this option. Possible values are: @code{__RL78_MUL_NONE__},
31543 @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
31544
31545 @opindex mcpu
31546 @item -mcpu=g10
31547 @itemx -mcpu=g13
31548 @itemx -mcpu=g14
31549 @itemx -mcpu=rl78
31550 Specifies the RL78 core to target. The default is the G14 core, also
31551 known as an S3 core or just RL78. The G13 or S2 core does not have
31552 multiply or divide instructions, instead it uses a hardware peripheral
31553 for these operations. The G10 or S1 core does not have register
31554 banks, so it uses a different calling convention.
31555
31556 If this option is set it also selects the type of hardware multiply
31557 support to use, unless this is overridden by an explicit
31558 @option{-mmul=none} option on the command line. Thus specifying
31559 @option{-mcpu=g13} enables the use of the G13 hardware multiply
31560 peripheral and specifying @option{-mcpu=g10} disables the use of
31561 hardware multiplications altogether.
31562
31563 Note, although the RL78/G14 core is the default target, specifying
31564 @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
31565 change the behavior of the toolchain since it also enables G14
31566 hardware multiply support. If these options are not specified on the
31567 command line then software multiplication routines will be used even
31568 though the code targets the RL78 core. This is for backwards
31569 compatibility with older toolchains which did not have hardware
31570 multiply and divide support.
31571
31572 In addition a C preprocessor macro is defined, based upon the setting
31573 of this option. Possible values are: @code{__RL78_G10__},
31574 @code{__RL78_G13__} or @code{__RL78_G14__}.
31575
31576 @opindex mg10
31577 @opindex mg13
31578 @opindex mg14
31579 @opindex mrl78
31580 @item -mg10
31581 @itemx -mg13
31582 @itemx -mg14
31583 @itemx -mrl78
31584 These are aliases for the corresponding @option{-mcpu=} option. They
31585 are provided for backwards compatibility.
31586
31587 @opindex mallregs
31588 @item -mallregs
31589 Allow the compiler to use all of the available registers. By default
31590 registers @code{r24..r31} are reserved for use in interrupt handlers.
31591 With this option enabled these registers can be used in ordinary
31592 functions as well.
31593
31594 @opindex m64bit-doubles
31595 @opindex m32bit-doubles
31596 @item -m64bit-doubles
31597 @itemx -m32bit-doubles
31598 Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
31599 or 32 bits (@option{-m32bit-doubles}) in size. The default is
31600 @option{-m32bit-doubles}.
31601
31602 @opindex msave-mduc-in-interrupts
31603 @opindex mno-save-mduc-in-interrupts
31604 @item -msave-mduc-in-interrupts
31605 @itemx -mno-save-mduc-in-interrupts
31606 Specifies that interrupt handler functions should preserve the
31607 MDUC registers. This is only necessary if normal code might use
31608 the MDUC registers, for example because it performs multiplication
31609 and division operations. The default is to ignore the MDUC registers
31610 as this makes the interrupt handlers faster. The target option -mg13
31611 needs to be passed for this to work as this feature is only available
31612 on the G13 target (S2 core). The MDUC registers will only be saved
31613 if the interrupt handler performs a multiplication or division
31614 operation or it calls another function.
31615
31616 @end table
31617
31618 @node RS/6000 and PowerPC Options
31619 @subsection IBM RS/6000 and PowerPC Options
31620 @cindex RS/6000 and PowerPC Options
31621 @cindex IBM RS/6000 and PowerPC Options
31622
31623 These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
31624 @table @gcctabopt
31625 @item -mpowerpc-gpopt
31626 @itemx -mno-powerpc-gpopt
31627 @itemx -mpowerpc-gfxopt
31628 @itemx -mno-powerpc-gfxopt
31629 @need 800
31630 @itemx -mpowerpc64
31631 @itemx -mno-powerpc64
31632 @itemx -mmfcrf
31633 @itemx -mno-mfcrf
31634 @itemx -mpopcntb
31635 @itemx -mno-popcntb
31636 @itemx -mpopcntd
31637 @itemx -mno-popcntd
31638 @itemx -mfprnd
31639 @itemx -mno-fprnd
31640 @need 800
31641 @opindex mpowerpc-gpopt
31642 @opindex mno-powerpc-gpopt
31643 @opindex mpowerpc-gfxopt
31644 @opindex mno-powerpc-gfxopt
31645 @opindex mpowerpc64
31646 @opindex mno-powerpc64
31647 @opindex mmfcrf
31648 @opindex mno-mfcrf
31649 @opindex mpopcntb
31650 @opindex mno-popcntb
31651 @opindex mpopcntd
31652 @opindex mno-popcntd
31653 @opindex mfprnd
31654 @opindex mno-fprnd
31655 @opindex mcmpb
31656 @opindex mno-cmpb
31657 @opindex mhard-dfp
31658 @opindex mno-hard-dfp
31659 @itemx -mcmpb
31660 @itemx -mno-cmpb
31661 @itemx -mhard-dfp
31662 @itemx -mno-hard-dfp
31663 You use these options to specify which instructions are available on the
31664 processor you are using. The default value of these options is
31665 determined when configuring GCC@. Specifying the
31666 @option{-mcpu=@var{cpu_type}} overrides the specification of these
31667 options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
31668 rather than the options listed above.
31669
31670 Specifying @option{-mpowerpc-gpopt} allows
31671 GCC to use the optional PowerPC architecture instructions in the
31672 General Purpose group, including floating-point square root. Specifying
31673 @option{-mpowerpc-gfxopt} allows GCC to
31674 use the optional PowerPC architecture instructions in the Graphics
31675 group, including floating-point select.
31676
31677 The @option{-mmfcrf} option allows GCC to generate the move from
31678 condition register field instruction implemented on the POWER4
31679 processor and other processors that support the PowerPC V2.01
31680 architecture.
31681 The @option{-mpopcntb} option allows GCC to generate the popcount and
31682 double-precision FP reciprocal estimate instruction implemented on the
31683 POWER5 processor and other processors that support the PowerPC V2.02
31684 architecture.
31685 The @option{-mpopcntd} option allows GCC to generate the popcount
31686 instruction implemented on the POWER7 processor and other processors
31687 that support the PowerPC V2.06 architecture.
31688 The @option{-mfprnd} option allows GCC to generate the FP round to
31689 integer instructions implemented on the POWER5+ processor and other
31690 processors that support the PowerPC V2.03 architecture.
31691 The @option{-mcmpb} option allows GCC to generate the compare bytes
31692 instruction implemented on the POWER6 processor and other processors
31693 that support the PowerPC V2.05 architecture.
31694 The @option{-mhard-dfp} option allows GCC to generate the decimal
31695 floating-point instructions implemented on some POWER processors.
31696
31697 The @option{-mpowerpc64} option allows GCC to generate the additional
31698 64-bit instructions that are found in the full PowerPC64 architecture
31699 and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
31700 @option{-mno-powerpc64}.
31701
31702 @opindex mcpu
31703 @item -mcpu=@var{cpu_type}
31704 Set architecture type, register usage, and
31705 instruction scheduling parameters for machine type @var{cpu_type}.
31706 Supported values for @var{cpu_type} are @samp{401}, @samp{403},
31707 @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
31708 @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
31709 @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
31710 @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
31711 @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
31712 @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
31713 @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
31714 @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
31715 @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
31716 @samp{power9}, @samp{power10}, @samp{power11}, @samp{powerpc}, @samp{powerpc64},
31717 @samp{powerpc64le}, @samp{rs64}, and @samp{native}.
31718
31719 @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
31720 @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
31721 endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
31722 architecture machine types, with an appropriate, generic processor
31723 model assumed for scheduling purposes.
31724
31725 Specifying @samp{native} as cpu type detects and selects the
31726 architecture option that corresponds to the host processor of the
31727 system performing the compilation.
31728 @option{-mcpu=native} has no effect if GCC does not recognize the
31729 processor.
31730
31731 The other options specify a specific processor. Code generated under
31732 those options runs best on that processor, and may not run at all on
31733 others.
31734
31735 The @option{-mcpu} options automatically enable or disable the
31736 following options:
31737
31738 @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple
31739 -mpopcntb -mpopcntd -mpowerpc64
31740 -mpowerpc-gpopt -mpowerpc-gfxopt
31741 -mmulhw -mdlmzb -mmfpgpr -mvsx
31742 -mcrypto -mhtm -mpower8-fusion
31743 -mquad-memory -mquad-memory-atomic -mfloat128
31744 -mfloat128-hardware -mprefixed -mpcrel -mmma
31745 -mrop-protect}
31746
31747 The particular options set for any particular CPU varies between
31748 compiler versions, depending on what setting seems to produce optimal
31749 code for that CPU; it doesn't necessarily reflect the actual hardware's
31750 capabilities. If you wish to set an individual option to a particular
31751 value, you may specify it after the @option{-mcpu} option, like
31752 @option{-mcpu=970 -mno-altivec}.
31753
31754 On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
31755 not enabled or disabled by the @option{-mcpu} option at present because
31756 AIX does not have full support for these options. You may still
31757 enable or disable them individually if you're sure it'll work in your
31758 environment.
31759
31760 @opindex mtune
31761 @item -mtune=@var{cpu_type}
31762 Set the instruction scheduling parameters for machine type
31763 @var{cpu_type}, but do not set the architecture type or register usage,
31764 as @option{-mcpu=@var{cpu_type}} does. The same
31765 values for @var{cpu_type} are used for @option{-mtune} as for
31766 @option{-mcpu}. If both are specified, the code generated uses the
31767 architecture and registers set by @option{-mcpu}, but the
31768 scheduling parameters set by @option{-mtune}.
31769
31770 @opindex mcmodel=
31771 @opindex mcmodel=small
31772 @item -mcmodel=small
31773 Generate PowerPC64 code for the small model: The TOC is limited to
31774 64k.
31775
31776 @opindex mcmodel=medium
31777 @item -mcmodel=medium
31778 Generate PowerPC64 code for the medium model: The TOC and other static
31779 data may be up to a total of 4G in size. This is the default for 64-bit
31780 Linux.
31781
31782 @opindex mcmodel=large
31783 @item -mcmodel=large
31784 Generate PowerPC64 code for the large model: The TOC may be up to 4G
31785 in size. Other data and code is only limited by the 64-bit address
31786 space.
31787
31788 @opindex maltivec
31789 @opindex mno-altivec
31790 @item -maltivec
31791 @itemx -mno-altivec
31792 Generate code that uses (does not use) AltiVec instructions, and also
31793 enable the use of built-in functions that allow more direct access to
31794 the AltiVec instruction set. You may also need to set
31795 @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
31796 enhancements.
31797
31798 When @option{-maltivec} is used, the element order for AltiVec intrinsics
31799 such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
31800 match array element order corresponding to the endianness of the
31801 target. That is, element zero identifies the leftmost element in a
31802 vector register when targeting a big-endian platform, and identifies
31803 the rightmost element in a vector register when targeting a
31804 little-endian platform.
31805
31806 @opindex mvrsave
31807 @opindex mno-vrsave
31808 @item -mvrsave
31809 @itemx -mno-vrsave
31810 Generate VRSAVE instructions when generating AltiVec code.
31811
31812 @opindex msecure-plt
31813 @item -msecure-plt
31814 Generate code that allows @command{ld} and @command{ld.so}
31815 to build executables and shared
31816 libraries with non-executable @code{.plt} and @code{.got} sections.
31817 This is a PowerPC
31818 32-bit SYSV ABI option.
31819
31820 @opindex mbss-plt
31821 @item -mbss-plt
31822 Generate code that uses a BSS @code{.plt} section that @command{ld.so}
31823 fills in, and
31824 requires @code{.plt} and @code{.got}
31825 sections that are both writable and executable.
31826 This is a PowerPC 32-bit SYSV ABI option.
31827
31828 @opindex msplit-patch-nops
31829 @item -msplit-patch-nops
31830 When adding NOPs for a patchable area via the
31831 @option{-fpatchable-function-entry} option emit the ``before'' NOPs in front
31832 of the global entry point and the ``after'' NOPs after the local entry point.
31833 This makes the sequence of NOPs not consecutive when a global entry point
31834 is generated. Without this option the NOPs are emitted directly before and
31835 after the local entry point, making them consecutive but moving global and
31836 local entry point further apart. If only a single entry point is generated
31837 this option has no effect.
31838
31839 @opindex misel
31840 @opindex mno-isel
31841 @item -misel
31842 @itemx -mno-isel
31843 This switch enables or disables the generation of ISEL instructions.
31844
31845 @opindex mvsx
31846 @opindex mno-vsx
31847 @item -mvsx
31848 @itemx -mno-vsx
31849 Generate code that uses (does not use) vector/scalar (VSX)
31850 instructions, and also enable the use of built-in functions that allow
31851 more direct access to the VSX instruction set.
31852
31853 @opindex mcrypto
31854 @opindex mno-crypto
31855 @item -mcrypto
31856 @itemx -mno-crypto
31857 Enable the use (disable) of the built-in functions that allow direct
31858 access to the cryptographic instructions that were added in version
31859 2.07 of the PowerPC ISA.
31860
31861 @opindex mhtm
31862 @opindex mno-htm
31863 @item -mhtm
31864 @itemx -mno-htm
31865 Enable (disable) the use of the built-in functions that allow direct
31866 access to the Hardware Transactional Memory (HTM) instructions that
31867 were added in version 2.07 of the PowerPC ISA.
31868
31869 @opindex mpower8-fusion
31870 @opindex mno-power8-fusion
31871 @item -mpower8-fusion
31872 @itemx -mno-power8-fusion
31873 Generate code that keeps (does not keeps) some integer operations
31874 adjacent so that the instructions can be fused together on power8 and
31875 later processors.
31876
31877 @opindex mquad-memory
31878 @opindex mno-quad-memory
31879 @item -mquad-memory
31880 @itemx -mno-quad-memory
31881 Generate code that uses (does not use) the non-atomic quad word memory
31882 instructions. The @option{-mquad-memory} option requires use of
31883 64-bit mode.
31884
31885 @opindex mquad-memory-atomic
31886 @opindex mno-quad-memory-atomic
31887 @item -mquad-memory-atomic
31888 @itemx -mno-quad-memory-atomic
31889 Generate code that uses (does not use) the atomic quad word memory
31890 instructions. The @option{-mquad-memory-atomic} option requires use of
31891 64-bit mode.
31892
31893 @opindex mfloat128
31894 @opindex mno-float128
31895 @item -mfloat128
31896 @itemx -mno-float128
31897 Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
31898 and use either software emulation for IEEE 128-bit floating point or
31899 hardware instructions.
31900
31901 The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
31902 128-bit floating point support. The IEEE 128-bit floating point is only
31903 supported on Linux.
31904
31905 The default for @option{-mfloat128} is enabled on PowerPC Linux
31906 systems using the VSX instruction set, and disabled on other systems.
31907
31908 If you use the ISA 3.0 instruction set (@option{-mcpu=power9}) on a
31909 64-bit system, the IEEE 128-bit floating point support will also enable
31910 the generation of ISA 3.0 IEEE 128-bit floating point instructions.
31911 Otherwise, if you do not specify to generate ISA 3.0 instructions or you
31912 are targeting a 32-bit big endian system, IEEE 128-bit floating point
31913 will be done with software emulation.
31914
31915 @opindex mfloat128-hardware
31916 @opindex mno-float128-hardware
31917 @item -mfloat128-hardware
31918 @itemx -mno-float128-hardware
31919 Enable/disable using ISA 3.0 hardware instructions to support the
31920 @var{__float128} data type.
31921
31922 The default for @option{-mfloat128-hardware} is enabled on PowerPC
31923 Linux systems using the ISA 3.0 instruction set, and disabled on other
31924 systems.
31925
31926 @opindex m32
31927 @opindex m64
31928 @item -m32
31929 @itemx -m64
31930 Generate code for 32-bit or 64-bit environments of Darwin and SVR4
31931 targets (including GNU/Linux). The 32-bit environment sets int, long
31932 and pointer to 32 bits and generates code that runs on any PowerPC
31933 variant. The 64-bit environment sets int to 32 bits and long and
31934 pointer to 64 bits, and generates code for PowerPC64, as for
31935 @option{-mpowerpc64}.
31936
31937 @opindex mfull-toc
31938 @opindex mno-fp-in-toc
31939 @opindex mno-sum-in-toc
31940 @opindex mminimal-toc
31941 @item -mfull-toc
31942 @itemx -mno-fp-in-toc
31943 @itemx -mno-sum-in-toc
31944 @itemx -mminimal-toc
31945 Modify generation of the TOC (Table Of Contents), which is created for
31946 every executable file. The @option{-mfull-toc} option is selected by
31947 default. In that case, GCC allocates at least one TOC entry for
31948 each unique non-automatic variable reference in your program. GCC
31949 also places floating-point constants in the TOC@. However, only
31950 16,384 entries are available in the TOC@.
31951
31952 If you receive a linker error message that saying you have overflowed
31953 the available TOC space, you can reduce the amount of TOC space used
31954 with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
31955 @option{-mno-fp-in-toc} prevents GCC from putting floating-point
31956 constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
31957 generate code to calculate the sum of an address and a constant at
31958 run time instead of putting that sum into the TOC@. You may specify one
31959 or both of these options. Each causes GCC to produce very slightly
31960 slower and larger code at the expense of conserving TOC space.
31961
31962 If you still run out of space in the TOC even when you specify both of
31963 these options, specify @option{-mminimal-toc} instead. This option causes
31964 GCC to make only one TOC entry for every file. When you specify this
31965 option, GCC produces code that is slower and larger but which
31966 uses extremely little TOC space. You may wish to use this option
31967 only on files that contain less frequently-executed code.
31968
31969 @opindex maix64
31970 @opindex maix32
31971 @item -maix64
31972 @itemx -maix32
31973 Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
31974 @code{long} type, and the infrastructure needed to support them.
31975 Specifying @option{-maix64} implies @option{-mpowerpc64},
31976 while @option{-maix32} disables the 64-bit ABI and
31977 implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
31978
31979 @opindex mxl-compat
31980 @opindex mno-xl-compat
31981 @item -mxl-compat
31982 @itemx -mno-xl-compat
31983 Produce code that conforms more closely to IBM XL compiler semantics
31984 when using AIX-compatible ABI@. Pass floating-point arguments to
31985 prototyped functions beyond the register save area (RSA) on the stack
31986 in addition to argument FPRs. Do not assume that most significant
31987 double in 128-bit long double value is properly rounded when comparing
31988 values and converting to double. Use XL symbol names for long double
31989 support routines.
31990
31991 The AIX calling convention was extended but not initially documented to
31992 handle an obscure K&R C case of calling a function that takes the
31993 address of its arguments with fewer arguments than declared. IBM XL
31994 compilers access floating-point arguments that do not fit in the
31995 RSA from the stack when a subroutine is compiled without
31996 optimization. Because always storing floating-point arguments on the
31997 stack is inefficient and rarely needed, this option is not enabled by
31998 default and only is necessary when calling subroutines compiled by IBM
31999 XL compilers without optimization.
32000
32001 @opindex mpe
32002 @item -mpe
32003 Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
32004 application written to use message passing with special startup code to
32005 enable the application to run. The system must have PE installed in the
32006 standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
32007 must be overridden with the @option{-specs=} option to specify the
32008 appropriate directory location. The Parallel Environment does not
32009 support threads, so the @option{-mpe} option and the @option{-pthread}
32010 option are incompatible.
32011
32012 @opindex malign-natural
32013 @opindex malign-power
32014 @item -malign-natural
32015 @itemx -malign-power
32016 On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
32017 @option{-malign-natural} overrides the ABI-defined alignment of larger
32018 types, such as floating-point doubles, on their natural size-based boundary.
32019 The option @option{-malign-power} instructs GCC to follow the ABI-specified
32020 alignment rules. GCC defaults to the standard alignment defined in the ABI@.
32021
32022 On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
32023 is not supported.
32024
32025 @opindex msoft-float
32026 @opindex mhard-float
32027 @item -msoft-float
32028 @itemx -mhard-float
32029 Generate code that does not use (uses) the floating-point register set.
32030 Software floating-point emulation is provided if you use the
32031 @option{-msoft-float} option, and pass the option to GCC when linking.
32032
32033 @opindex mmultiple
32034 @opindex mno-multiple
32035 @item -mmultiple
32036 @itemx -mno-multiple
32037 Generate code that uses (does not use) the load multiple word
32038 instructions and the store multiple word instructions. These
32039 instructions are generated by default on POWER systems, and not
32040 generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
32041 PowerPC systems, since those instructions do not work when the
32042 processor is in little-endian mode. The exceptions are PPC740 and
32043 PPC750 which permit these instructions in little-endian mode.
32044
32045 @opindex mupdate
32046 @opindex mno-update
32047 @item -mupdate
32048 @itemx -mno-update
32049 Generate code that uses (does not use) the load or store instructions
32050 that update the base register to the address of the calculated memory
32051 location. These instructions are generated by default. If you use
32052 @option{-mno-update}, there is a small window between the time that the
32053 stack pointer is updated and the address of the previous frame is
32054 stored, which means code that walks the stack frame across interrupts or
32055 signals may get corrupted data.
32056
32057 @opindex mavoid-indexed-addresses
32058 @opindex mno-avoid-indexed-addresses
32059 @item -mavoid-indexed-addresses
32060 @itemx -mno-avoid-indexed-addresses
32061 Generate code that tries to avoid (not avoid) the use of indexed load
32062 or store instructions. These instructions can incur a performance
32063 penalty on Power6 processors in certain situations, such as when
32064 stepping through large arrays that cross a 16M boundary. This option
32065 is enabled by default when targeting Power6 and disabled otherwise.
32066
32067 @opindex mfused-madd
32068 @opindex mno-fused-madd
32069 @item -mfused-madd
32070 @itemx -mno-fused-madd
32071 Generate code that uses (does not use) the floating-point multiply and
32072 accumulate instructions. These instructions are generated by default
32073 if hardware floating point is used. The machine-dependent
32074 @option{-mfused-madd} option is now mapped to the machine-independent
32075 @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
32076 mapped to @option{-ffp-contract=off}.
32077
32078 @opindex mmulhw
32079 @opindex mno-mulhw
32080 @item -mmulhw
32081 @itemx -mno-mulhw
32082 Generate code that uses (does not use) the half-word multiply and
32083 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
32084 These instructions are generated by default when targeting those
32085 processors.
32086
32087 @opindex mdlmzb
32088 @opindex mno-dlmzb
32089 @item -mdlmzb
32090 @itemx -mno-dlmzb
32091 Generate code that uses (does not use) the string-search @samp{dlmzb}
32092 instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
32093 generated by default when targeting those processors.
32094
32095 @opindex mno-bit-align
32096 @opindex mbit-align
32097 @item -mno-bit-align
32098 @itemx -mbit-align
32099 On System V.4 and embedded PowerPC systems do not (do) force structures
32100 and unions that contain bit-fields to be aligned to the base type of the
32101 bit-field.
32102
32103 For example, by default a structure containing nothing but 8
32104 @code{unsigned} bit-fields of length 1 is aligned to a 4-byte
32105 boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
32106 the structure is aligned to a 1-byte boundary and is 1 byte in
32107 size.
32108
32109 @opindex mno-strict-align
32110 @opindex mstrict-align
32111 @item -mno-strict-align
32112 @itemx -mstrict-align
32113 On System V.4 and embedded PowerPC systems do not (do) assume that
32114 unaligned memory references are handled by the system.
32115
32116 @opindex mrelocatable
32117 @opindex mno-relocatable
32118 @item -mrelocatable
32119 @itemx -mno-relocatable
32120 Generate code that allows (does not allow) a static executable to be
32121 relocated to a different address at run time. A simple embedded
32122 PowerPC system loader should relocate the entire contents of
32123 @code{.got2} and 4-byte locations listed in the @code{.fixup} section,
32124 a table of 32-bit addresses generated by this option. For this to
32125 work, all objects linked together must be compiled with
32126 @option{-mrelocatable} or @option{-mrelocatable-lib}.
32127 @option{-mrelocatable} code aligns the stack to an 8-byte boundary.
32128
32129 @opindex mrelocatable-lib
32130 @opindex mno-relocatable-lib
32131 @item -mrelocatable-lib
32132 @itemx -mno-relocatable-lib
32133 Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
32134 @code{.fixup} section to allow static executables to be relocated at
32135 run time, but @option{-mrelocatable-lib} does not use the smaller stack
32136 alignment of @option{-mrelocatable}. Objects compiled with
32137 @option{-mrelocatable-lib} may be linked with objects compiled with
32138 any combination of the @option{-mrelocatable} options.
32139
32140 @opindex mno-toc
32141 @opindex mtoc
32142 @item -mno-toc
32143 @itemx -mtoc
32144 On System V.4 and embedded PowerPC systems do not (do) assume that
32145 register 2 contains a pointer to a global area pointing to the addresses
32146 used in the program.
32147
32148 @opindex mlittle
32149 @opindex mlittle-endian
32150 @item -mlittle
32151 @itemx -mlittle-endian
32152 On System V.4 and embedded PowerPC systems compile code for the
32153 processor in little-endian mode. The @option{-mlittle-endian} option is
32154 the same as @option{-mlittle}.
32155
32156 @opindex mbig
32157 @opindex mbig-endian
32158 @item -mbig
32159 @itemx -mbig-endian
32160 On System V.4 and embedded PowerPC systems compile code for the
32161 processor in big-endian mode. The @option{-mbig-endian} option is
32162 the same as @option{-mbig}.
32163
32164 @opindex mdynamic-no-pic
32165 @item -mdynamic-no-pic
32166 On Darwin / macOS systems, compile code so that it is not
32167 relocatable, but that its external references are relocatable. The
32168 resulting code is suitable for applications, but not shared
32169 libraries.
32170
32171 @opindex msingle-pic-base
32172 @item -msingle-pic-base
32173 Treat the register used for PIC addressing as read-only, rather than
32174 loading it in the prologue for each function. The runtime system is
32175 responsible for initializing this register with an appropriate value
32176 before execution begins.
32177
32178 @opindex mprioritize-restricted-insns
32179 @item -mprioritize-restricted-insns=@var{priority}
32180 This option controls the priority that is assigned to
32181 dispatch-slot restricted instructions during the second scheduling
32182 pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
32183 or @samp{2} to assign no, highest, or second-highest (respectively)
32184 priority to dispatch-slot restricted
32185 instructions.
32186
32187 @opindex msched-costly-dep
32188 @item -msched-costly-dep=@var{dependence_type}
32189 This option controls which dependences are considered costly
32190 by the target during instruction scheduling. The argument
32191 @var{dependence_type} takes one of the following values:
32192
32193 @table @asis
32194 @item @samp{no}
32195 No dependence is costly.
32196
32197 @item @samp{all}
32198 All dependences are costly.
32199
32200 @item @samp{true_store_to_load}
32201 A true dependence from store to load is costly.
32202
32203 @item @samp{store_to_load}
32204 Any dependence from store to load is costly.
32205
32206 @item @var{number}
32207 Any dependence for which the latency is greater than or equal to
32208 @var{number} is costly.
32209 @end table
32210
32211 @opindex minsert-sched-nops
32212 @item -minsert-sched-nops=@var{scheme}
32213 This option controls which NOP insertion scheme is used during
32214 the second scheduling pass. The argument @var{scheme} takes one of the
32215 following values:
32216
32217 @table @asis
32218 @item @samp{no}
32219 Don't insert NOPs.
32220
32221 @item @samp{pad}
32222 Pad with NOPs any dispatch group that has vacant issue slots,
32223 according to the scheduler's grouping.
32224
32225 @item @samp{regroup_exact}
32226 Insert NOPs to force costly dependent insns into
32227 separate groups. Insert exactly as many NOPs as needed to force an insn
32228 to a new group, according to the estimated processor grouping.
32229
32230 @item @var{number}
32231 Insert NOPs to force costly dependent insns into
32232 separate groups. Insert @var{number} NOPs to force an insn to a new group.
32233 @end table
32234
32235 @opindex mcall-sysv
32236 @item -mcall-sysv
32237 On System V.4 and embedded PowerPC systems compile code using calling
32238 conventions that adhere to the March 1995 draft of the System V
32239 Application Binary Interface, PowerPC processor supplement. This is the
32240 default unless you configured GCC using @samp{powerpc-*-eabiaix}.
32241
32242 @opindex mcall-sysv-eabi
32243 @opindex mcall-eabi
32244 @item -mcall-sysv-eabi
32245 @itemx -mcall-eabi
32246 Specify both @option{-mcall-sysv} and @option{-meabi} options.
32247
32248 @opindex mcall-sysv-noeabi
32249 @item -mcall-sysv-noeabi
32250 Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
32251
32252 @opindex mcall-aixdesc
32253 @item -mcall-aixdesc
32254 On System V.4 and embedded PowerPC systems compile code for the AIX
32255 operating system.
32256
32257 @opindex mcall-linux
32258 @item -mcall-linux
32259 On System V.4 and embedded PowerPC systems compile code for the
32260 Linux-based GNU system.
32261
32262 @opindex mcall-freebsd
32263 @item -mcall-freebsd
32264 On System V.4 and embedded PowerPC systems compile code for the
32265 FreeBSD operating system.
32266
32267 @opindex mcall-netbsd
32268 @item -mcall-netbsd
32269 On System V.4 and embedded PowerPC systems compile code for the
32270 NetBSD operating system.
32271
32272 @opindex mcall-openbsd
32273 @item -mcall-openbsd
32274 On System V.4 and embedded PowerPC systems compile code for the
32275 OpenBSD operating system.
32276
32277 @opindex mtraceback
32278 @item -mtraceback=@var{traceback_type}
32279 Select the type of traceback table. Valid values for @var{traceback_type}
32280 are @samp{full}, @samp{part}, and @samp{no}.
32281
32282 @opindex maix-struct-return
32283 @item -maix-struct-return
32284 Return all structures in memory (as specified by the AIX ABI)@.
32285
32286 @opindex msvr4-struct-return
32287 @item -msvr4-struct-return
32288 Return structures smaller than 8 bytes in registers (as specified by the
32289 SVR4 ABI)@.
32290
32291 @opindex mabi
32292 @item -mabi=@var{abi-type}
32293 Extend the current ABI with a particular extension, or remove such extension.
32294 Valid values are: @samp{altivec}, @samp{no-altivec},
32295 @samp{ibmlongdouble}, @samp{ieeelongdouble},
32296 @samp{elfv1}, @samp{elfv2},
32297 and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
32298
32299 @opindex mabi=ibmlongdouble
32300 @item -mabi=ibmlongdouble
32301 Change the current ABI to use IBM extended-precision long double.
32302 This is not likely to work if your system defaults to using IEEE
32303 extended-precision long double. If you change the long double type
32304 from IEEE extended-precision, the compiler issues a warning unless
32305 you use the @option{-Wno-psabi} option (@pxref{Warning Options}).
32306 Requires @option{-mlong-double-128} to be enabled.
32307
32308 @opindex mabi=ieeelongdouble
32309 @item -mabi=ieeelongdouble
32310 Change the current ABI to use IEEE extended-precision long double.
32311 This is not likely to work if your system defaults to using IBM
32312 extended-precision long double. If you change the long double type
32313 from IBM extended-precision, the compiler issues a warning unless
32314 you use the @option{-Wno-psabi} option (@pxref{Warning Options}).
32315 Requires @option{-mlong-double-128} to be enabled.
32316
32317 @opindex mabi=elfv1
32318 @item -mabi=elfv1
32319 Change the current ABI to use the ELFv1 ABI.
32320 This is the default ABI for big-endian PowerPC 64-bit Linux.
32321 Overriding the default ABI requires special system support and is
32322 likely to fail in spectacular ways.
32323
32324 @opindex mabi=elfv2
32325 @item -mabi=elfv2
32326 Change the current ABI to use the ELFv2 ABI.
32327 This is the default ABI for little-endian PowerPC 64-bit Linux.
32328 Overriding the default ABI requires special system support and is
32329 likely to fail in spectacular ways.
32330
32331 @opindex mgnu-attribute
32332 @opindex mno-gnu-attribute
32333 @item -mgnu-attribute
32334 @itemx -mno-gnu-attribute
32335 Emit .gnu_attribute assembly directives to set tag/value pairs in a
32336 .gnu.attributes section that specify ABI variations in function
32337 parameters or return values.
32338
32339 @opindex mprototype
32340 @opindex mno-prototype
32341 @item -mprototype
32342 @itemx -mno-prototype
32343 On System V.4 and embedded PowerPC systems assume that all calls to
32344 variable argument functions are properly prototyped. Otherwise, the
32345 compiler must insert an instruction before every non-prototyped call to
32346 set or clear bit 6 of the condition code register (@code{CR}) to
32347 indicate whether floating-point values are passed in the floating-point
32348 registers in case the function takes variable arguments. With
32349 @option{-mprototype}, only calls to prototyped variable argument functions
32350 set or clear the bit.
32351
32352 @opindex msim
32353 @item -msim
32354 On embedded PowerPC systems, assume that the startup module is called
32355 @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
32356 @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
32357 configurations.
32358
32359 @opindex mmvme
32360 @item -mmvme
32361 On embedded PowerPC systems, assume that the startup module is called
32362 @file{crt0.o} and the standard C libraries are @file{libmvme.a} and
32363 @file{libc.a}.
32364
32365 @opindex mads
32366 @item -mads
32367 On embedded PowerPC systems, assume that the startup module is called
32368 @file{crt0.o} and the standard C libraries are @file{libads.a} and
32369 @file{libc.a}.
32370
32371 @opindex myellowknife
32372 @item -myellowknife
32373 On embedded PowerPC systems, assume that the startup module is called
32374 @file{crt0.o} and the standard C libraries are @file{libyk.a} and
32375 @file{libc.a}.
32376
32377 @opindex mvxworks
32378 @item -mvxworks
32379 On System V.4 and embedded PowerPC systems, specify that you are
32380 compiling for a VxWorks system.
32381
32382 @opindex memb
32383 @item -memb
32384 On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
32385 header to indicate that @samp{eabi} extended relocations are used.
32386
32387 @opindex meabi
32388 @opindex mno-eabi
32389 @item -meabi
32390 @itemx -mno-eabi
32391 On System V.4 and embedded PowerPC systems do (do not) adhere to the
32392 Embedded Applications Binary Interface (EABI), which is a set of
32393 modifications to the System V.4 specifications. Selecting @option{-meabi}
32394 means that the stack is aligned to an 8-byte boundary, a function
32395 @code{__eabi} is called from @code{main} to set up the EABI
32396 environment, and the @option{-msdata} option can use both @code{r2} and
32397 @code{r13} to point to two separate small data areas. Selecting
32398 @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
32399 no EABI initialization function is called from @code{main}, and the
32400 @option{-msdata} option only uses @code{r13} to point to a single
32401 small data area. The @option{-meabi} option is on by default if you
32402 configured GCC using one of the @samp{powerpc*-*-eabi*} options.
32403
32404 @opindex msdata=eabi
32405 @item -msdata=eabi
32406 On System V.4 and embedded PowerPC systems, put small initialized
32407 @code{const} global and static data in the @code{.sdata2} section, which
32408 is pointed to by register @code{r2}. Put small initialized
32409 non-@code{const} global and static data in the @code{.sdata} section,
32410 which is pointed to by register @code{r13}. Put small uninitialized
32411 global and static data in the @code{.sbss} section, which is adjacent to
32412 the @code{.sdata} section. The @option{-msdata=eabi} option is
32413 incompatible with the @option{-mrelocatable} option. The
32414 @option{-msdata=eabi} option also sets the @option{-memb} option.
32415
32416 @opindex msdata=sysv
32417 @item -msdata=sysv
32418 On System V.4 and embedded PowerPC systems, put small global and static
32419 data in the @code{.sdata} section, which is pointed to by register
32420 @code{r13}. Put small uninitialized global and static data in the
32421 @code{.sbss} section, which is adjacent to the @code{.sdata} section.
32422 The @option{-msdata=sysv} option is incompatible with the
32423 @option{-mrelocatable} option.
32424
32425 @opindex msdata=default
32426 @opindex msdata
32427 @item -msdata=default
32428 @itemx -msdata
32429 On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
32430 compile code the same as @option{-msdata=eabi}, otherwise compile code the
32431 same as @option{-msdata=sysv}.
32432
32433 @opindex msdata=data
32434 @item -msdata=data
32435 On System V.4 and embedded PowerPC systems, put small global
32436 data in the @code{.sdata} section. Put small uninitialized global
32437 data in the @code{.sbss} section. Do not use register @code{r13}
32438 to address small data however. This is the default behavior unless
32439 other @option{-msdata} options are used.
32440
32441 @opindex msdata=none
32442 @opindex mno-sdata
32443 @item -msdata=none
32444 @itemx -mno-sdata
32445 On embedded PowerPC systems, put all initialized global and static data
32446 in the @code{.data} section, and all uninitialized data in the
32447 @code{.bss} section.
32448
32449 @opindex mreadonly-in-sdata
32450 @opindex mno-readonly-in-sdata
32451 @item -mreadonly-in-sdata
32452 Put read-only objects in the @code{.sdata} section as well. This is the
32453 default.
32454
32455 @opindex mblock-move-inline-limit
32456 @item -mblock-move-inline-limit=@var{num}
32457 Inline all block moves (such as calls to @code{memcpy} or structure
32458 copies) less than or equal to @var{num} bytes. The minimum value for
32459 @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
32460 targets. The default value is target-specific.
32461
32462 @opindex mblock-compare-inline-limit
32463 @item -mblock-compare-inline-limit=@var{num}
32464 Generate non-looping inline code for all block compares (such as calls
32465 to @code{memcmp} or structure compares) less than or equal to @var{num}
32466 bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
32467 block compare is disabled. The default value is target-specific.
32468
32469 @opindex mblock-compare-inline-loop-limit
32470 @item -mblock-compare-inline-loop-limit=@var{num}
32471 Generate an inline expansion using loop code for all block compares that
32472 are less than or equal to @var{num} bytes, but greater than the limit
32473 for non-loop inline block compare expansion. If the block length is not
32474 constant, at most @var{num} bytes will be compared before @code{memcmp}
32475 is called to compare the remainder of the block. The default value is
32476 target-specific.
32477
32478 @opindex mstring-compare-inline-limit
32479 @item -mstring-compare-inline-limit=@var{num}
32480 Compare at most @var{num} string bytes with inline code.
32481 If the difference or end of string is not found at the
32482 end of the inline compare a call to @code{strcmp} or @code{strncmp} will
32483 take care of the rest of the comparison. The default is 64 bytes.
32484
32485 @opindex G
32486 @cindex smaller data references (PowerPC)
32487 @cindex .sdata/.sdata2 references (PowerPC)
32488 @item -G @var{num}
32489 On embedded PowerPC systems, put global and static items less than or
32490 equal to @var{num} bytes into the small data or BSS sections instead of
32491 the normal data or BSS section. By default, @var{num} is 8. The
32492 @option{-G @var{num}} switch is also passed to the linker.
32493 All modules should be compiled with the same @option{-G @var{num}} value.
32494
32495 @opindex mregnames
32496 @opindex mno-regnames
32497 @item -mregnames
32498 @itemx -mno-regnames
32499 On System V.4 and embedded PowerPC systems do (do not) emit register
32500 names in the assembly language output using symbolic forms.
32501
32502 @opindex mlongcall
32503 @opindex mno-longcall
32504 @item -mlongcall
32505 @itemx -mno-longcall
32506 By default assume that all calls are far away so that a longer and more
32507 expensive calling sequence is required. This is required for calls
32508 farther than 32 megabytes (33,554,432 bytes) from the current location.
32509 A short call is generated if the compiler knows
32510 the call cannot be that far away. This setting can be overridden by
32511 the @code{shortcall} function attribute, or by @code{#pragma
32512 longcall(0)}.
32513
32514 Some linkers are capable of detecting out-of-range calls and generating
32515 glue code on the fly. On these systems, long calls are unnecessary and
32516 generate slower code. As of this writing, the AIX linker can do this,
32517 as can the GNU linker for PowerPC/64. It is planned to add this feature
32518 to the GNU linker for 32-bit PowerPC systems as well.
32519
32520 On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
32521 GCC can generate long calls using an inline PLT call sequence (see
32522 @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
32523 ELFv1 (big-endian) do not support inline PLT calls.
32524
32525 On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
32526 callee, L42}, plus a @dfn{branch island} (glue code). The two target
32527 addresses represent the callee and the branch island. The
32528 Darwin/PPC linker prefers the first address and generates a @code{bl
32529 callee} if the PPC @code{bl} instruction reaches the callee directly;
32530 otherwise, the linker generates @code{bl L42} to call the branch
32531 island. The branch island is appended to the body of the
32532 calling function; it computes the full 32-bit address of the callee
32533 and jumps to it.
32534
32535 On Mach-O (Darwin) systems, this option directs the compiler emit to
32536 the glue for every direct call, and the Darwin linker decides whether
32537 to use or discard it.
32538
32539 In the future, GCC may ignore all longcall specifications
32540 when the linker is known to generate glue.
32541
32542 @opindex mpltseq
32543 @opindex mno-pltseq
32544 @item -mpltseq
32545 @itemx -mno-pltseq
32546 Implement (do not implement) -fno-plt and long calls using an inline
32547 PLT call sequence that supports lazy linking and long calls to
32548 functions in dlopen'd shared libraries. Inline PLT calls are only
32549 supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
32550 linkers, and are enabled by default if the support is detected when
32551 configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
32552 configured with @option{--enable-secureplt}. @option{-mpltseq} code
32553 and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
32554 linked together.
32555
32556 @opindex mtls-markers
32557 @opindex mno-tls-markers
32558 @item -mtls-markers
32559 @itemx -mno-tls-markers
32560 Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
32561 specifying the function argument. The relocation allows the linker to
32562 reliably associate function call with argument setup instructions for
32563 TLS optimization, which in turn allows GCC to better schedule the
32564 sequence.
32565
32566 @opindex mrecip
32567 @item -mrecip
32568 @itemx -mno-recip
32569 This option enables use of the reciprocal estimate and
32570 reciprocal square root estimate instructions with additional
32571 Newton-Raphson steps to increase precision instead of doing a divide or
32572 square root and divide for floating-point arguments. You should use
32573 the @option{-ffast-math} option when using @option{-mrecip} (or at
32574 least @option{-funsafe-math-optimizations},
32575 @option{-ffinite-math-only}, @option{-freciprocal-math} and
32576 @option{-fno-trapping-math}). Note that while the throughput of the
32577 sequence is generally higher than the throughput of the non-reciprocal
32578 instruction, the precision of the sequence can be decreased by up to 2
32579 ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
32580 roots.
32581
32582 @opindex mrecip=opt
32583 @item -mrecip=@var{opt}
32584 This option controls which reciprocal estimate instructions
32585 may be used. @var{opt} is a comma-separated list of options, which may
32586 be preceded by a @code{!} to invert the option:
32587
32588 @table @samp
32589
32590 @item all
32591 Enable all estimate instructions.
32592
32593 @item default
32594 Enable the default instructions, equivalent to @option{-mrecip}.
32595
32596 @item none
32597 Disable all estimate instructions, equivalent to @option{-mno-recip}.
32598
32599 @item div
32600 Enable the reciprocal approximation instructions for both
32601 single and double precision.
32602
32603 @item divf
32604 Enable the single-precision reciprocal approximation instructions.
32605
32606 @item divd
32607 Enable the double-precision reciprocal approximation instructions.
32608
32609 @item rsqrt
32610 Enable the reciprocal square root approximation instructions for both
32611 single and double precision.
32612
32613 @item rsqrtf
32614 Enable the single-precision reciprocal square root approximation instructions.
32615
32616 @item rsqrtd
32617 Enable the double-precision reciprocal square root approximation instructions.
32618
32619 @end table
32620
32621 So, for example, @option{-mrecip=all,!rsqrtd} enables
32622 all of the reciprocal estimate instructions, except for the
32623 @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
32624 which handle the double-precision reciprocal square root calculations.
32625
32626 @opindex mrecip-precision
32627 @item -mrecip-precision
32628 @itemx -mno-recip-precision
32629 Assume (do not assume) that the reciprocal estimate instructions
32630 provide higher-precision estimates than is mandated by the PowerPC
32631 ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
32632 @option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
32633 The double-precision square root estimate instructions are not generated by
32634 default on low-precision machines, since they do not provide an
32635 estimate that converges after three steps.
32636
32637 @opindex mveclibabi
32638 @item -mveclibabi=@var{type}
32639 Specifies the ABI type to use for vectorizing intrinsics using an
32640 external library. The only type supported at present is @samp{mass},
32641 which specifies to use IBM's Mathematical Acceleration Subsystem
32642 (MASS) libraries for vectorizing intrinsics using external libraries.
32643 GCC currently emits calls to @code{acosd2}, @code{acosf4},
32644 @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
32645 @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
32646 @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
32647 @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
32648 @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
32649 @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
32650 @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
32651 @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
32652 @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
32653 @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
32654 @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
32655 @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
32656 @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
32657 for power7. Both @option{-ftree-vectorize} and
32658 @option{-funsafe-math-optimizations} must also be enabled. The MASS
32659 libraries must be specified at link time.
32660
32661 @opindex mfriz
32662 @item -mfriz
32663 @itemx -mno-friz
32664 Generate (do not generate) the @code{friz} instruction when the
32665 @option{-funsafe-math-optimizations} option is used to optimize
32666 rounding of floating-point values to 64-bit integer and back to floating
32667 point. The @code{friz} instruction does not return the same value if
32668 the floating-point number is too large to fit in an integer.
32669
32670 @opindex mpointers-to-nested-functions
32671 @item -mpointers-to-nested-functions
32672 @itemx -mno-pointers-to-nested-functions
32673 Generate (do not generate) code to load up the static chain register
32674 (@code{r11}) when calling through a pointer on AIX and 64-bit Linux
32675 systems where a function pointer points to a 3-word descriptor giving
32676 the function address, TOC value to be loaded in register @code{r2}, and
32677 static chain value to be loaded in register @code{r11}. The
32678 @option{-mpointers-to-nested-functions} is on by default. You cannot
32679 call through pointers to nested functions or pointers
32680 to functions compiled in other languages that use the static chain if
32681 you use @option{-mno-pointers-to-nested-functions}.
32682
32683 @opindex msave-toc-indirect
32684 @item -msave-toc-indirect
32685 @itemx -mno-save-toc-indirect
32686 Generate (do not generate) code to save the TOC value in the reserved
32687 stack location in the function prologue if the function calls through
32688 a pointer on AIX and 64-bit Linux systems. If the TOC value is not
32689 saved in the prologue, it is saved just before the call through the
32690 pointer. The @option{-mno-save-toc-indirect} option is the default.
32691
32692 @opindex mcompat-align-parm
32693 @item -mcompat-align-parm
32694 @itemx -mno-compat-align-parm
32695 Generate (do not generate) code to pass structure parameters with a
32696 maximum alignment of 64 bits, for compatibility with older versions
32697 of GCC.
32698
32699 Older versions of GCC (prior to 4.9.0) incorrectly did not align a
32700 structure parameter on a 128-bit boundary when that structure contained
32701 a member requiring 128-bit alignment. This is corrected in more
32702 recent versions of GCC. This option may be used to generate code
32703 that is compatible with functions compiled with older versions of
32704 GCC.
32705
32706 The @option{-mno-compat-align-parm} option is the default.
32707
32708 @opindex mstack-protector-guard
32709 @opindex mstack-protector-guard-reg
32710 @opindex mstack-protector-guard-offset
32711 @item -mstack-protector-guard=@var{guard}
32712 @itemx -mstack-protector-guard-reg=@var{reg}
32713 @itemx -mstack-protector-guard-offset=@var{offset}
32714 Generate stack protection code using canary at @var{guard}. Supported
32715 locations are @samp{global} for global canary or @samp{tls} for per-thread
32716 canary in the TLS block (the default with GNU libc version 2.4 or later).
32717
32718 With the latter choice the options
32719 @option{-mstack-protector-guard-reg=@var{reg}} and
32720 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
32721 which register to use as base register for reading the canary, and from what
32722 offset from that base register. The default for those is as specified in the
32723 relevant ABI.
32724
32725 @opindex mpcrel
32726 @opindex mno-pcrel
32727 @item -mpcrel
32728 @itemx -mno-pcrel
32729 Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
32730 option requires that the medium code model (@option{-mcmodel=medium})
32731 and prefixed addressing (@option{-mprefixed}) options are enabled.
32732
32733 @opindex mprefixed
32734 @opindex mno-prefixed
32735 @item -mprefixed
32736 @itemx -mno-prefixed
32737 Generate (do not generate) addressing modes using prefixed load and
32738 store instructions. The @option{-mprefixed} option requires that
32739 the option @option{-mcpu=power10} (or later) is enabled.
32740
32741 @opindex mmma
32742 @opindex mno-mma
32743 @item -mmma
32744 @itemx -mno-mma
32745 Generate (do not generate) the MMA instructions. The @option{-mma}
32746 option requires that the option @option{-mcpu=power10} (or later)
32747 is enabled.
32748
32749 @opindex mrop-protect
32750 @opindex mno-rop-protect
32751 @item -mrop-protect
32752 @itemx -mno-rop-protect
32753 Generate (do not generate) ROP protection instructions when the target
32754 processor supports them. Currently this option disables the shrink-wrap
32755 optimization (@option{-fshrink-wrap}).
32756
32757 @opindex mprivileged
32758 @opindex mno-privileged
32759 @item -mprivileged
32760 @itemx -mno-privileged
32761 Generate (do not generate) code that will run in privileged state.
32762
32763 @opindex block-ops-unaligned-vsx
32764 @opindex no-block-ops-unaligned-vsx
32765 @item -mblock-ops-unaligned-vsx
32766 @itemx -mno-block-ops-unaligned-vsx
32767 Generate (do not generate) unaligned vsx loads and stores for
32768 inline expansion of @code{memcpy} and @code{memmove}.
32769
32770 @item --param rs6000-vect-unroll-limit=
32771 The vectorizer will check with target information to determine whether it
32772 would be beneficial to unroll the main vectorized loop and by how much. This
32773 parameter sets the upper bound of how much the vectorizer will unroll the main
32774 loop. The default value is four.
32775
32776 @end table
32777
32778 @node RX Options
32779 @subsection RX Options
32780 @cindex RX Options
32781
32782 These command-line options are defined for RX targets:
32783
32784 @table @gcctabopt
32785 @opindex m64bit-doubles
32786 @opindex m32bit-doubles
32787 @item -m64bit-doubles
32788 @itemx -m32bit-doubles
32789 Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
32790 or 32 bits (@option{-m32bit-doubles}) in size. The default is
32791 @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
32792 works on 32-bit values, which is why the default is
32793 @option{-m32bit-doubles}.
32794
32795 @opindex fpu
32796 @opindex nofpu
32797 @item -fpu
32798 @itemx -nofpu
32799 Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
32800 floating-point hardware. The default is enabled for the RX600
32801 series and disabled for the RX200 series.
32802
32803 Floating-point instructions are only generated for 32-bit floating-point
32804 values, however, so the FPU hardware is not used for doubles if the
32805 @option{-m64bit-doubles} option is used.
32806
32807 @emph{Note} If the @option{-fpu} option is enabled then
32808 @option{-funsafe-math-optimizations} is also enabled automatically.
32809 This is because the RX FPU instructions are themselves unsafe.
32810
32811 @opindex mcpu
32812 @item -mcpu=@var{name}
32813 Selects the type of RX CPU to be targeted. Currently three types are
32814 supported, the generic @samp{RX600} and @samp{RX200} series hardware and
32815 the specific @samp{RX610} CPU. The default is @samp{RX600}.
32816
32817 The only difference between @samp{RX600} and @samp{RX610} is that the
32818 @samp{RX610} does not support the @code{MVTIPL} instruction.
32819
32820 The @samp{RX200} series does not have a hardware floating-point unit
32821 and so @option{-nofpu} is enabled by default when this type is
32822 selected.
32823
32824 @opindex mbig-endian-data
32825 @opindex mlittle-endian-data
32826 @item -mbig-endian-data
32827 @itemx -mlittle-endian-data
32828 Store data (but not code) in the big-endian format. The default is
32829 @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
32830 format.
32831
32832 @opindex msmall-data-limit
32833 @item -msmall-data-limit=@var{N}
32834 Specifies the maximum size in bytes of global and static variables
32835 which can be placed into the small data area. Using the small data
32836 area can lead to smaller and faster code, but the size of area is
32837 limited and it is up to the programmer to ensure that the area does
32838 not overflow. Also when the small data area is used one of the RX's
32839 registers (usually @code{r13}) is reserved for use pointing to this
32840 area, so it is no longer available for use by the compiler. This
32841 could result in slower and/or larger code if variables are pushed onto
32842 the stack instead of being held in this register.
32843
32844 Note, common variables (variables that have not been initialized) and
32845 constants are not placed into the small data area as they are assigned
32846 to other sections in the output executable.
32847
32848 The default value is zero, which disables this feature. Note, this
32849 feature is not enabled by default with higher optimization levels
32850 (@option{-O2} etc) because of the potentially detrimental effects of
32851 reserving a register. It is up to the programmer to experiment and
32852 discover whether this feature is of benefit to their program. See the
32853 description of the @option{-mpid} option for a description of how the
32854 actual register to hold the small data area pointer is chosen.
32855
32856 @opindex msim
32857 @opindex mno-sim
32858 @item -msim
32859 @itemx -mno-sim
32860 Use the simulator runtime. The default is to use the libgloss
32861 board-specific runtime.
32862
32863 @opindex mas100-syntax
32864 @opindex mno-as100-syntax
32865 @item -mas100-syntax
32866 @itemx -mno-as100-syntax
32867 When generating assembler output use a syntax that is compatible with
32868 Renesas's AS100 assembler. This syntax can also be handled by the GAS
32869 assembler, but it has some restrictions so it is not generated by default.
32870
32871 @opindex mmax-constant-size
32872 @item -mmax-constant-size=@var{N}
32873 Specifies the maximum size, in bytes, of a constant that can be used as
32874 an operand in a RX instruction. Although the RX instruction set does
32875 allow constants of up to 4 bytes in length to be used in instructions,
32876 a longer value equates to a longer instruction. Thus in some
32877 circumstances it can be beneficial to restrict the size of constants
32878 that are used in instructions. Constants that are too big are instead
32879 placed into a constant pool and referenced via register indirection.
32880
32881 The value @var{N} can be between 0 and 4. A value of 0 (the default)
32882 or 4 means that constants of any size are allowed.
32883
32884 @opindex mrelax
32885 @item -mrelax
32886 Enable linker relaxation. Linker relaxation is a process whereby the
32887 linker attempts to reduce the size of a program by finding shorter
32888 versions of various instructions. Disabled by default.
32889
32890 @opindex mint-register
32891 @item -mint-register=@var{N}
32892 Specify the number of registers to reserve for fast interrupt handler
32893 functions. The value @var{N} can be between 0 and 4. A value of 1
32894 means that register @code{r13} is reserved for the exclusive use
32895 of fast interrupt handlers. A value of 2 reserves @code{r13} and
32896 @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
32897 @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
32898 A value of 0, the default, does not reserve any registers.
32899
32900 @opindex msave-acc-in-interrupts
32901 @item -msave-acc-in-interrupts
32902 Specifies that interrupt handler functions should preserve the
32903 accumulator register. This is only necessary if normal code might use
32904 the accumulator register, for example because it performs 64-bit
32905 multiplications. The default is to ignore the accumulator as this
32906 makes the interrupt handlers faster.
32907
32908 @opindex mpid
32909 @opindex mno-pid
32910 @item -mpid
32911 @itemx -mno-pid
32912 Enables the generation of position independent data. When enabled any
32913 access to constant data is done via an offset from a base address
32914 held in a register. This allows the location of constant data to be
32915 determined at run time without requiring the executable to be
32916 relocated, which is a benefit to embedded applications with tight
32917 memory constraints. Data that can be modified is not affected by this
32918 option.
32919
32920 Note, using this feature reserves a register, usually @code{r13}, for
32921 the constant data base address. This can result in slower and/or
32922 larger code, especially in complicated functions.
32923
32924 The actual register chosen to hold the constant data base address
32925 depends upon whether the @option{-msmall-data-limit} and/or the
32926 @option{-mint-register} command-line options are enabled. Starting
32927 with register @code{r13} and proceeding downwards, registers are
32928 allocated first to satisfy the requirements of @option{-mint-register},
32929 then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
32930 is possible for the small data area register to be @code{r8} if both
32931 @option{-mint-register=4} and @option{-mpid} are specified on the
32932 command line.
32933
32934 By default this feature is not enabled. The default can be restored
32935 via the @option{-mno-pid} command-line option.
32936
32937 @opindex mno-warn-multiple-fast-interrupts
32938 @opindex mwarn-multiple-fast-interrupts
32939 @item -mno-warn-multiple-fast-interrupts
32940 @itemx -mwarn-multiple-fast-interrupts
32941 Prevents GCC from issuing a warning message if it finds more than one
32942 fast interrupt handler when it is compiling a file. The default is to
32943 issue a warning for each extra fast interrupt handler found, as the RX
32944 only supports one such interrupt.
32945
32946 @opindex mallow-string-insns
32947 @opindex mno-allow-string-insns
32948 @item -mallow-string-insns
32949 @itemx -mno-allow-string-insns
32950 Enables or disables the use of the string manipulation instructions
32951 @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
32952 @code{SWHILE} and also the @code{RMPA} instruction. These
32953 instructions may prefetch data, which is not safe to do if accessing
32954 an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
32955 for more information).
32956
32957 The default is to allow these instructions, but it is not possible for
32958 GCC to reliably detect all circumstances where a string instruction
32959 might be used to access an I/O register, so their use cannot be
32960 disabled automatically. Instead it is reliant upon the programmer to
32961 use the @option{-mno-allow-string-insns} option if their program
32962 accesses I/O space.
32963
32964 When the instructions are enabled GCC defines the C preprocessor
32965 symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
32966 symbol @code{__RX_DISALLOW_STRING_INSNS__}.
32967
32968 @opindex mjsr
32969 @opindex mno-jsr
32970 @item -mjsr
32971 @itemx -mno-jsr
32972 Use only (or not only) @code{JSR} instructions to access functions.
32973 This option can be used when code size exceeds the range of @code{BSR}
32974 instructions. Note that @option{-mno-jsr} does not mean to not use
32975 @code{JSR} but instead means that any type of branch may be used.
32976 @end table
32977
32978 @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
32979 has special significance to the RX port when used with the
32980 @code{interrupt} function attribute. This attribute indicates a
32981 function intended to process fast interrupts. GCC ensures
32982 that it only uses the registers @code{r10}, @code{r11}, @code{r12}
32983 and/or @code{r13} and only provided that the normal use of the
32984 corresponding registers have been restricted via the
32985 @option{-ffixed-@var{reg}} or @option{-mint-register} command-line
32986 options.
32987
32988 @node S/390 and zSeries Options
32989 @subsection S/390 and zSeries Options
32990 @cindex S/390 and zSeries Options
32991
32992 These are the @samp{-m} options defined for the S/390 and zSeries architecture.
32993
32994 @table @gcctabopt
32995 @opindex mhard-float
32996 @opindex msoft-float
32997 @item -mhard-float
32998 @itemx -msoft-float
32999 Use (do not use) the hardware floating-point instructions and registers
33000 for floating-point operations. When @option{-msoft-float} is specified,
33001 functions in @file{libgcc.a} are used to perform floating-point
33002 operations. When @option{-mhard-float} is specified, the compiler
33003 generates IEEE floating-point instructions. This is the default.
33004
33005 @opindex mhard-dfp
33006 @opindex mno-hard-dfp
33007 @item -mhard-dfp
33008 @itemx -mno-hard-dfp
33009 Use (do not use) the hardware decimal-floating-point instructions for
33010 decimal-floating-point operations. When @option{-mno-hard-dfp} is
33011 specified, functions in @file{libgcc.a} are used to perform
33012 decimal-floating-point operations. When @option{-mhard-dfp} is
33013 specified, the compiler generates decimal-floating-point hardware
33014 instructions. This is the default for @option{-march=z9-ec} or higher.
33015
33016 @opindex mlong-double-64
33017 @opindex mlong-double-128
33018 @item -mlong-double-64
33019 @itemx -mlong-double-128
33020 These switches control the size of @code{long double} type. A size
33021 of 64 bits makes the @code{long double} type equivalent to the @code{double}
33022 type. This is the default.
33023
33024 @opindex mbackchain
33025 @opindex mno-backchain
33026 @item -mbackchain
33027 @itemx -mno-backchain
33028 Store (do not store) the address of the caller's frame as backchain pointer
33029 into the callee's stack frame.
33030 A backchain may be needed to allow debugging using tools that do not understand
33031 DWARF call frame information.
33032 When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
33033 at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
33034 the backchain is placed into the topmost word of the 96/160 byte register
33035 save area.
33036
33037 In general, code compiled with @option{-mbackchain} is call-compatible with
33038 code compiled with @option{-mno-backchain}; however, use of the backchain
33039 for debugging purposes usually requires that the whole binary is built with
33040 @option{-mbackchain}. Note that the combination of @option{-mbackchain},
33041 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
33042 to build a linux kernel use @option{-msoft-float}.
33043
33044 The default is to not maintain the backchain.
33045
33046 @opindex mpacked-stack
33047 @opindex mno-packed-stack
33048 @item -mpacked-stack
33049 @itemx -mno-packed-stack
33050 Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
33051 specified, the compiler uses the all fields of the 96/160 byte register save
33052 area only for their default purpose; unused fields still take up stack space.
33053 When @option{-mpacked-stack} is specified, register save slots are densely
33054 packed at the top of the register save area; unused space is reused for other
33055 purposes, allowing for more efficient use of the available stack space.
33056 However, when @option{-mbackchain} is also in effect, the topmost word of
33057 the save area is always used to store the backchain, and the return address
33058 register is always saved two words below the backchain.
33059
33060 As long as the stack frame backchain is not used, code generated with
33061 @option{-mpacked-stack} is call-compatible with code generated with
33062 @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
33063 S/390 or zSeries generated code that uses the stack frame backchain at run
33064 time, not just for debugging purposes. Such code is not call-compatible
33065 with code compiled with @option{-mpacked-stack}. Also, note that the
33066 combination of @option{-mbackchain},
33067 @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
33068 to build a linux kernel use @option{-msoft-float}.
33069
33070 The default is to not use the packed stack layout.
33071
33072 @opindex msmall-exec
33073 @opindex mno-small-exec
33074 @item -msmall-exec
33075 @itemx -mno-small-exec
33076 Generate (or do not generate) code using the @code{bras} instruction
33077 to do subroutine calls.
33078 This only works reliably if the total executable size does not
33079 exceed 64k. The default is to use the @code{basr} instruction instead,
33080 which does not have this limitation.
33081
33082 @opindex m64
33083 @opindex m31
33084 @item -m64
33085 @itemx -m31
33086 When @option{-m31} is specified, generate code compliant to the
33087 GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
33088 code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
33089 particular to generate 64-bit instructions. For the @samp{s390}
33090 targets, the default is @option{-m31}, while the @samp{s390x}
33091 targets default to @option{-m64}.
33092
33093 @opindex mzarch
33094 @opindex mesa
33095 @item -mzarch
33096 @itemx -mesa
33097 When @option{-mzarch} is specified, generate code using the
33098 instructions available on z/Architecture.
33099 When @option{-mesa} is specified, generate code using the
33100 instructions available on ESA/390. Note that @option{-mesa} is
33101 not possible with @option{-m64}.
33102 When generating code compliant to the GNU/Linux for S/390 ABI,
33103 the default is @option{-mesa}. When generating code compliant
33104 to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
33105
33106 @opindex mhtm
33107 @opindex mno-htm
33108 @item -mhtm
33109 @itemx -mno-htm
33110 The @option{-mhtm} option enables a set of builtins making use of
33111 instructions available with the transactional execution facility
33112 introduced with the IBM zEnterprise EC12 machine generation
33113 @ref{S/390 System z Built-in Functions}.
33114 @option{-mhtm} is enabled by default when using @option{-march=zEC12}.
33115
33116 @opindex mvx
33117 @opindex mno-vx
33118 @item -mvx
33119 @itemx -mno-vx
33120 When @option{-mvx} is specified, generate code using the instructions
33121 available with the vector extension facility introduced with the IBM
33122 z13 machine generation.
33123 This option changes the ABI for some vector type values with regard to
33124 alignment and calling conventions. In case vector type values are
33125 being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
33126 command will be added to mark the resulting binary with the ABI used.
33127 @option{-mvx} is enabled by default when using @option{-march=z13}.
33128
33129 @opindex mzvector
33130 @opindex mno-zvector
33131 @item -mzvector
33132 @itemx -mno-zvector
33133 The @option{-mzvector} option enables vector language extensions and
33134 builtins using instructions available with the vector extension
33135 facility introduced with the IBM z13 machine generation.
33136 This option adds support for @samp{vector} to be used as a keyword to
33137 define vector type variables and arguments. @samp{vector} is only
33138 available when GNU extensions are enabled. It will not be expanded
33139 when requesting strict standard compliance e.g.@: with @option{-std=c99}.
33140 In addition to the GCC low-level builtins @option{-mzvector} enables
33141 a set of builtins added for compatibility with AltiVec-style
33142 implementations like Power and Cell. In order to make use of these
33143 builtins the header file @file{vecintrin.h} needs to be included.
33144 @option{-mzvector} is disabled by default.
33145
33146 @opindex mmvcle
33147 @opindex mno-mvcle
33148 @item -mmvcle
33149 @itemx -mno-mvcle
33150 Generate (or do not generate) code using the @code{mvcle} instruction
33151 to perform block moves. When @option{-mno-mvcle} is specified,
33152 use a @code{mvc} loop instead. This is the default unless optimizing for
33153 size.
33154
33155 @opindex mdebug
33156 @opindex mno-debug
33157 @item -mdebug
33158 @itemx -mno-debug
33159 Print (or do not print) additional debug information when compiling.
33160 The default is to not print debug information.
33161
33162 @opindex march
33163 @item -march=@var{cpu-type}
33164 Generate code that runs on @var{cpu-type}, which is the name of a
33165 system representing a certain processor type. Possible values for
33166 @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
33167 @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
33168 @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
33169 @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
33170 @samp{z16}/@samp{arch14}, @samp{z17}/@samp{arch15}, and @samp{native}.
33171
33172 The default is @option{-march=z900}.
33173
33174 Specifying @samp{native} as cpu type can be used to select the best
33175 architecture option for the host processor.
33176 @option{-march=native} has no effect if GCC does not recognize the
33177 processor.
33178
33179 @opindex mtune
33180 @item -mtune=@var{cpu-type}
33181 Tune to @var{cpu-type} everything applicable about the generated code,
33182 except for the ABI and the set of available instructions.
33183 The list of @var{cpu-type} values is the same as for @option{-march}.
33184 The default is the value used for @option{-march}.
33185
33186 @opindex mtpf-trace
33187 @opindex mno-tpf-trace
33188 @item -mtpf-trace
33189 @itemx -mno-tpf-trace
33190 Generate code that adds (does not add) in TPF OS specific branches to trace
33191 routines in the operating system. This option is off by default, even
33192 when compiling for the TPF OS@.
33193
33194 @opindex mtpf-trace-skip
33195 @opindex mno-tpf-trace-skip
33196 @item -mtpf-trace-skip
33197 @itemx -mno-tpf-trace-skip
33198 Generate code that changes (does not change) the default branch
33199 targets enabled by @option{-mtpf-trace} to point to specialized trace
33200 routines providing the ability of selectively skipping function trace
33201 entries for the TPF OS. This option is off by default, even when
33202 compiling for the TPF OS and specifying @option{-mtpf-trace}.
33203
33204 @opindex mfused-madd
33205 @opindex mno-fused-madd
33206 @item -mfused-madd
33207 @itemx -mno-fused-madd
33208 Generate code that uses (does not use) the floating-point multiply and
33209 accumulate instructions. These instructions are generated by default if
33210 hardware floating point is used.
33211
33212 @opindex mwarn-framesize
33213 @item -mwarn-framesize=@var{framesize}
33214 Emit a warning if the current function exceeds the given frame size. Because
33215 this is a compile-time check it doesn't need to be a real problem when the program
33216 runs. It is intended to identify functions that most probably cause
33217 a stack overflow. It is useful to be used in an environment with limited stack
33218 size e.g.@: the linux kernel.
33219
33220 @opindex mwarn-dynamicstack
33221 @item -mwarn-dynamicstack
33222 Emit a warning if the function calls @code{alloca} or uses dynamically-sized
33223 arrays. This is generally a bad idea with a limited stack size.
33224
33225 @opindex mstack-guard
33226 @opindex mstack-size
33227 @item -mstack-guard=@var{stack-guard}
33228 @itemx -mstack-size=@var{stack-size}
33229 If these options are provided the S/390 back end emits additional instructions in
33230 the function prologue that trigger a trap if the stack size is @var{stack-guard}
33231 bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
33232 If the @var{stack-guard} option is omitted the smallest power of 2 larger than
33233 the frame size of the compiled function is chosen.
33234 These options are intended to be used to help debugging stack overflow problems.
33235 The additionally emitted code causes only little overhead and hence can also be
33236 used in production-like systems without greater performance degradation. The given
33237 values have to be exact powers of 2 and @var{stack-size} has to be greater than
33238 @var{stack-guard} without exceeding 64k.
33239 In order to be efficient the extra code makes the assumption that the stack starts
33240 at an address aligned to the value given by @var{stack-size}.
33241 The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
33242
33243 @opindex mhotpatch
33244 @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
33245 If the hotpatch option is enabled, a ``hot-patching'' function
33246 prologue is generated for all functions in the compilation unit.
33247 The funtion label is prepended with the given number of two-byte
33248 NOP instructions (@var{pre-halfwords}, maximum 1000000). After
33249 the label, 2 * @var{post-halfwords} bytes are appended, using the
33250 largest NOP like instructions the architecture allows (maximum
33251 1000000).
33252
33253 If both arguments are zero, hotpatching is disabled.
33254
33255 This option can be overridden for individual functions with the
33256 @code{hotpatch} attribute.
33257 @end table
33258
33259 @node SH Options
33260 @subsection SH Options
33261
33262 These @samp{-m} options are defined for the SH implementations:
33263
33264 @table @gcctabopt
33265 @opindex m1
33266 @item -m1
33267 Generate code for the SH1.
33268
33269 @opindex m2
33270 @item -m2
33271 Generate code for the SH2.
33272
33273 @item -m2e
33274 Generate code for the SH2e.
33275
33276 @opindex m2a-nofpu
33277 @item -m2a-nofpu
33278 Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
33279 that the floating-point unit is not used.
33280
33281 @opindex m2a-single-only
33282 @item -m2a-single-only
33283 Generate code for the SH2a-FPU, in such a way that no double-precision
33284 floating-point operations are used.
33285
33286 @opindex m2a-single
33287 @item -m2a-single
33288 Generate code for the SH2a-FPU assuming the floating-point unit is in
33289 single-precision mode by default.
33290
33291 @opindex m2a
33292 @item -m2a
33293 Generate code for the SH2a-FPU assuming the floating-point unit is in
33294 double-precision mode by default.
33295
33296 @opindex m3
33297 @item -m3
33298 Generate code for the SH3.
33299
33300 @opindex m3e
33301 @item -m3e
33302 Generate code for the SH3e.
33303
33304 @opindex m4-nofpu
33305 @item -m4-nofpu
33306 Generate code for the SH4 without a floating-point unit.
33307
33308 @opindex m4-single-only
33309 @item -m4-single-only
33310 Generate code for the SH4 with a floating-point unit that only
33311 supports single-precision arithmetic.
33312
33313 @opindex m4-single
33314 @item -m4-single
33315 Generate code for the SH4 assuming the floating-point unit is in
33316 single-precision mode by default.
33317
33318 @opindex m4
33319 @item -m4
33320 Generate code for the SH4.
33321
33322 @opindex m4-100
33323 @item -m4-100
33324 Generate code for SH4-100.
33325
33326 @opindex m4-100-nofpu
33327 @item -m4-100-nofpu
33328 Generate code for SH4-100 in such a way that the
33329 floating-point unit is not used.
33330
33331 @opindex m4-100-single
33332 @item -m4-100-single
33333 Generate code for SH4-100 assuming the floating-point unit is in
33334 single-precision mode by default.
33335
33336 @opindex m4-100-single-only
33337 @item -m4-100-single-only
33338 Generate code for SH4-100 in such a way that no double-precision
33339 floating-point operations are used.
33340
33341 @opindex m4-200
33342 @item -m4-200
33343 Generate code for SH4-200.
33344
33345 @opindex m4-200-nofpu
33346 @item -m4-200-nofpu
33347 Generate code for SH4-200 without in such a way that the
33348 floating-point unit is not used.
33349
33350 @opindex m4-200-single
33351 @item -m4-200-single
33352 Generate code for SH4-200 assuming the floating-point unit is in
33353 single-precision mode by default.
33354
33355 @opindex m4-200-single-only
33356 @item -m4-200-single-only
33357 Generate code for SH4-200 in such a way that no double-precision
33358 floating-point operations are used.
33359
33360 @opindex m4-300
33361 @item -m4-300
33362 Generate code for SH4-300.
33363
33364 @opindex m4-300-nofpu
33365 @item -m4-300-nofpu
33366 Generate code for SH4-300 without in such a way that the
33367 floating-point unit is not used.
33368
33369 @opindex m4-300-single
33370 @item -m4-300-single
33371 Generate code for SH4-300 in such a way that no double-precision
33372 floating-point operations are used.
33373
33374 @opindex m4-300-single-only
33375 @item -m4-300-single-only
33376 Generate code for SH4-300 in such a way that no double-precision
33377 floating-point operations are used.
33378
33379 @opindex m4-340
33380 @item -m4-340
33381 Generate code for SH4-340 (no MMU, no FPU).
33382
33383 @opindex m4-500
33384 @item -m4-500
33385 Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
33386 assembler.
33387
33388 @opindex m4a-nofpu
33389 @item -m4a-nofpu
33390 Generate code for the SH4al-dsp, or for a SH4a in such a way that the
33391 floating-point unit is not used.
33392
33393 @opindex m4a-single-only
33394 @item -m4a-single-only
33395 Generate code for the SH4a, in such a way that no double-precision
33396 floating-point operations are used.
33397
33398 @opindex m4a-single
33399 @item -m4a-single
33400 Generate code for the SH4a assuming the floating-point unit is in
33401 single-precision mode by default.
33402
33403 @opindex m4a
33404 @item -m4a
33405 Generate code for the SH4a.
33406
33407 @opindex m4al
33408 @item -m4al
33409 Same as @option{-m4a-nofpu}, except that it implicitly passes
33410 @option{-dsp} to the assembler. GCC doesn't generate any DSP
33411 instructions at the moment.
33412
33413 @opindex mb
33414 @item -mb
33415 Compile code for the processor in big-endian mode.
33416
33417 @opindex ml
33418 @item -ml
33419 Compile code for the processor in little-endian mode.
33420
33421 @opindex mdalign
33422 @item -mdalign
33423 Align doubles at 64-bit boundaries. Note that this changes the calling
33424 conventions, and thus some functions from the standard C library do
33425 not work unless you recompile it first with @option{-mdalign}.
33426
33427 @opindex mrelax
33428 @item -mrelax
33429 Shorten some address references at link time, when possible; uses the
33430 linker option @option{-relax}.
33431
33432 @opindex mbigtable
33433 @item -mbigtable
33434 Use 32-bit offsets in @code{switch} tables. The default is to use
33435 16-bit offsets.
33436
33437 @opindex mbitops
33438 @item -mbitops
33439 Enable the use of bit manipulation instructions on SH2A.
33440
33441 @opindex mfmovd
33442 @item -mfmovd
33443 Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
33444 alignment constraints.
33445
33446 @opindex mrenesas
33447 @item -mrenesas
33448 Comply with the calling conventions defined by Renesas.
33449
33450 @opindex mno-renesas
33451 @item -mno-renesas
33452 Comply with the calling conventions defined for GCC before the Renesas
33453 conventions were available. This option is the default for all
33454 targets of the SH toolchain.
33455
33456 @opindex mnomacsave
33457 @item -mnomacsave
33458 Mark the @code{MAC} register as call-clobbered, even if
33459 @option{-mrenesas} is given.
33460
33461 @opindex mieee
33462 @opindex mno-ieee
33463 @item -mieee
33464 @itemx -mno-ieee
33465 Control the IEEE compliance of floating-point comparisons, which affects the
33466 handling of cases where the result of a comparison is unordered. By default
33467 @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
33468 enabled @option{-mno-ieee} is implicitly set, which results in faster
33469 floating-point greater-equal and less-equal comparisons. The implicit settings
33470 can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
33471
33472 @opindex minline-ic_invalidate
33473 @item -minline-ic_invalidate
33474 Inline code to invalidate instruction cache entries after setting up
33475 nested function trampolines.
33476 This option has no effect if @option{-musermode} is in effect and the selected
33477 code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
33478 instruction.
33479 If the selected code generation option does not allow the use of the @code{icbi}
33480 instruction, and @option{-musermode} is not in effect, the inlined code
33481 manipulates the instruction cache address array directly with an associative
33482 write. This not only requires privileged mode at run time, but it also
33483 fails if the cache line had been mapped via the TLB and has become unmapped.
33484
33485 @opindex misize
33486 @item -misize
33487 Dump instruction size and location in the assembly code.
33488
33489 @opindex mpadstruct
33490 @item -mpadstruct
33491 This option is deprecated. It pads structures to multiple of 4 bytes,
33492 which is incompatible with the SH ABI@.
33493
33494 @opindex matomic-model=@var{model}
33495 @item -matomic-model=@var{model}
33496 Sets the model of atomic operations and additional parameters as a comma
33497 separated list. For details on the atomic built-in functions see
33498 @ref{__atomic Builtins}. The following models and parameters are supported:
33499
33500 @table @samp
33501
33502 @item none
33503 Disable compiler generated atomic sequences and emit library calls for atomic
33504 operations. This is the default if the target is not @code{sh*-*-linux*}.
33505
33506 @item soft-gusa
33507 Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
33508 built-in functions. The generated atomic sequences require additional support
33509 from the interrupt/exception handling code of the system and are only suitable
33510 for SH3* and SH4* single-core systems. This option is enabled by default when
33511 the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
33512 this option also partially utilizes the hardware atomic instructions
33513 @code{movli.l} and @code{movco.l} to create more efficient code, unless
33514 @samp{strict} is specified.
33515
33516 @item soft-tcb
33517 Generate software atomic sequences that use a variable in the thread control
33518 block. This is a variation of the gUSA sequences which can also be used on
33519 SH1* and SH2* targets. The generated atomic sequences require additional
33520 support from the interrupt/exception handling code of the system and are only
33521 suitable for single-core systems. When using this model, the @samp{gbr-offset=}
33522 parameter has to be specified as well.
33523
33524 @item soft-imask
33525 Generate software atomic sequences that temporarily disable interrupts by
33526 setting @code{SR.IMASK = 1111}. This model works only when the program runs
33527 in privileged mode and is only suitable for single-core systems. Additional
33528 support from the interrupt/exception handling code of the system is not
33529 required. This model is enabled by default when the target is
33530 @code{sh*-*-linux*} and SH1* or SH2*.
33531
33532 @item hard-llcs
33533 Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
33534 instructions only. This is only available on SH4A and is suitable for
33535 multi-core systems. Since the hardware instructions support only 32 bit atomic
33536 variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
33537 Code compiled with this option is also compatible with other software
33538 atomic model interrupt/exception handling systems if executed on an SH4A
33539 system. Additional support from the interrupt/exception handling code of the
33540 system is not required for this model.
33541
33542 @item gbr-offset=
33543 This parameter specifies the offset in bytes of the variable in the thread
33544 control block structure that should be used by the generated atomic sequences
33545 when the @samp{soft-tcb} model has been selected. For other models this
33546 parameter is ignored. The specified value must be an integer multiple of four
33547 and in the range 0-1020.
33548
33549 @item strict
33550 This parameter prevents mixed usage of multiple atomic models, even if they
33551 are compatible, and makes the compiler generate atomic sequences of the
33552 specified model only.
33553
33554 @end table
33555
33556 @opindex mtas
33557 @item -mtas
33558 Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
33559 Notice that depending on the particular hardware and software configuration
33560 this can degrade overall performance due to the operand cache line flushes
33561 that are implied by the @code{tas.b} instruction. On multi-core SH4A
33562 processors the @code{tas.b} instruction must be used with caution since it
33563 can result in data corruption for certain cache configurations.
33564
33565 @opindex mprefergot
33566 @item -mprefergot
33567 When generating position-independent code, emit function calls using
33568 the Global Offset Table instead of the Procedure Linkage Table.
33569
33570 @opindex musermode
33571 @opindex mno-usermode
33572 @item -musermode
33573 @itemx -mno-usermode
33574 Don't allow (allow) the compiler generating privileged mode code. Specifying
33575 @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
33576 inlined code would not work in user mode. @option{-musermode} is the default
33577 when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
33578 @option{-musermode} has no effect, since there is no user mode.
33579
33580 @opindex multcost=@var{number}
33581 @item -multcost=@var{number}
33582 Set the cost to assume for a multiply insn.
33583
33584 @opindex mdiv=@var{strategy}
33585 @item -mdiv=@var{strategy}
33586 Set the division strategy to be used for integer division operations.
33587 @var{strategy} can be one of:
33588
33589 @table @samp
33590
33591 @item call-div1
33592 Calls a library function that uses the single-step division instruction
33593 @code{div1} to perform the operation. Division by zero calculates an
33594 unspecified result and does not trap. This is the default except for SH4,
33595 SH2A and SHcompact.
33596
33597 @item call-fp
33598 Calls a library function that performs the operation in double precision
33599 floating point. Division by zero causes a floating-point exception. This is
33600 the default for SHcompact with FPU. Specifying this for targets that do not
33601 have a double precision FPU defaults to @code{call-div1}.
33602
33603 @item call-table
33604 Calls a library function that uses a lookup table for small divisors and
33605 the @code{div1} instruction with case distinction for larger divisors. Division
33606 by zero calculates an unspecified result and does not trap. This is the default
33607 for SH4. Specifying this for targets that do not have dynamic shift
33608 instructions defaults to @code{call-div1}.
33609
33610 @end table
33611
33612 When a division strategy has not been specified the default strategy is
33613 selected based on the current target. For SH2A the default strategy is to
33614 use the @code{divs} and @code{divu} instructions instead of library function
33615 calls.
33616
33617 @opindex maccumulate-outgoing-args
33618 @item -maccumulate-outgoing-args
33619 Reserve space once for outgoing arguments in the function prologue rather
33620 than around each call. Generally beneficial for performance and size. Also
33621 needed for unwinding to avoid changing the stack frame around conditional code.
33622
33623 @opindex mdivsi3_libfunc=@var{name}
33624 @item -mdivsi3_libfunc=@var{name}
33625 Set the name of the library function used for 32-bit signed division to
33626 @var{name}.
33627 This only affects the name used in the @samp{call} division strategies, and
33628 the compiler still expects the same sets of input/output/clobbered registers as
33629 if this option were not present.
33630
33631 @opindex mfixed-range
33632 @item -mfixed-range=@var{register-range}
33633 Generate code treating the given register range as fixed registers.
33634 A fixed register is one that the register allocator cannot use. This is
33635 useful when compiling kernel code. A register range is specified as
33636 two registers separated by a dash. Multiple register ranges can be
33637 specified separated by a comma.
33638
33639 @opindex mbranch-cost=@var{num}
33640 @item -mbranch-cost=@var{num}
33641 Assume @var{num} to be the cost for a branch instruction. Higher numbers
33642 make the compiler try to generate more branch-free code if possible.
33643 If not specified the value is selected depending on the processor type that
33644 is being compiled for.
33645
33646 @opindex mzdcbranch
33647 @opindex mno-zdcbranch
33648 @item -mzdcbranch
33649 @itemx -mno-zdcbranch
33650 Assume (do not assume) that zero displacement conditional branch instructions
33651 @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
33652 compiler prefers zero displacement branch code sequences. This is
33653 enabled by default when generating code for SH4 and SH4A. It can be explicitly
33654 disabled by specifying @option{-mno-zdcbranch}.
33655
33656 @opindex mcbranch-force-delay-slot
33657 @item -mcbranch-force-delay-slot
33658 Force the usage of delay slots for conditional branches, which stuffs the delay
33659 slot with a @code{nop} if a suitable instruction cannot be found. By default
33660 this option is disabled. It can be enabled to work around hardware bugs as
33661 found in the original SH7055.
33662
33663 @opindex mfused-madd
33664 @opindex mno-fused-madd
33665 @item -mfused-madd
33666 @itemx -mno-fused-madd
33667 Generate code that uses (does not use) the floating-point multiply and
33668 accumulate instructions. These instructions are generated by default
33669 if hardware floating point is used. The machine-dependent
33670 @option{-mfused-madd} option is now mapped to the machine-independent
33671 @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
33672 mapped to @option{-ffp-contract=off}.
33673
33674 @opindex mfsca
33675 @opindex mno-fsca
33676 @item -mfsca
33677 @itemx -mno-fsca
33678 Allow or disallow the compiler to emit the @code{fsca} instruction for sine
33679 and cosine approximations. The option @option{-mfsca} must be used in
33680 combination with @option{-funsafe-math-optimizations}. It is enabled by default
33681 when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
33682 approximations even if @option{-funsafe-math-optimizations} is in effect.
33683
33684 @opindex mfsrra
33685 @opindex mno-fsrra
33686 @item -mfsrra
33687 @itemx -mno-fsrra
33688 Allow or disallow the compiler to emit the @code{fsrra} instruction for
33689 reciprocal square root approximations. The option @option{-mfsrra} must be used
33690 in combination with @option{-funsafe-math-optimizations} and
33691 @option{-ffinite-math-only}. It is enabled by default when generating code for
33692 SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
33693 even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
33694 in effect.
33695
33696 @opindex mpretend-cmove
33697 @item -mpretend-cmove
33698 Prefer zero-displacement conditional branches for conditional move instruction
33699 patterns. This can result in faster code on the SH4 processor.
33700
33701 @opindex fdpic
33702 @item -mfdpic
33703 Generate code using the FDPIC ABI.
33704
33705 @end table
33706
33707 @node Solaris 2 Options
33708 @subsection Solaris 2 Options
33709 @cindex Solaris 2 options
33710
33711 These @samp{-m} options are supported on Solaris 2:
33712
33713 @table @gcctabopt
33714 @opindex mclear-hwcap
33715 @item -mclear-hwcap
33716 @option{-mclear-hwcap} tells the compiler to remove the hardware
33717 capabilities generated by the Solaris assembler. This is only necessary
33718 when object files use ISA extensions not supported by the current
33719 machine, but check at runtime whether or not to use them.
33720
33721 @opindex mimpure-text
33722 @item -mimpure-text
33723 @option{-mimpure-text}, used in addition to @option{-shared}, tells
33724 the compiler to not pass @option{-z text} to the linker when linking a
33725 shared object. Using this option, you can link position-dependent
33726 code into a shared object.
33727
33728 @option{-mimpure-text} suppresses the ``relocations remain against
33729 allocatable but non-writable sections'' linker error message.
33730 However, the necessary relocations trigger copy-on-write, and the
33731 shared object is not actually shared across processes. Instead of
33732 using @option{-mimpure-text}, you should compile all source code with
33733 @option{-fpic} or @option{-fPIC}.
33734
33735 @end table
33736
33737 These switches are supported in addition to the above on Solaris 2:
33738
33739 @table @gcctabopt
33740 @opindex pthreads
33741 @item -pthreads
33742 This is a synonym for @option{-pthread}.
33743 @end table
33744
33745 @node SPARC Options
33746 @subsection SPARC Options
33747 @cindex SPARC options
33748
33749 These @samp{-m} options are supported on the SPARC:
33750
33751 @table @gcctabopt
33752 @opindex mno-app-regs
33753 @opindex mapp-regs
33754 @item -mno-app-regs
33755 @itemx -mapp-regs
33756 Specify @option{-mapp-regs} to generate output using the global registers
33757 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
33758 global register 1, each global register 2 through 4 is then treated as an
33759 allocable register that is clobbered by function calls. This is the default.
33760
33761 To be fully SVR4 ABI-compliant at the cost of some performance loss,
33762 specify @option{-mno-app-regs}. You should compile libraries and system
33763 software with this option.
33764
33765 @opindex mflat
33766 @opindex mno-flat
33767 @item -mflat
33768 @itemx -mno-flat
33769 With @option{-mflat}, the compiler does not generate save/restore instructions
33770 and uses a ``flat'' or single register window model. This model is compatible
33771 with the regular register window model. The local registers and the input
33772 registers (0--5) are still treated as ``call-saved'' registers and are
33773 saved on the stack as needed.
33774
33775 With @option{-mno-flat} (the default), the compiler generates save/restore
33776 instructions (except for leaf functions). This is the normal operating mode.
33777
33778 @opindex mfpu
33779 @opindex mhard-float
33780 @item -mfpu
33781 @itemx -mhard-float
33782 Generate output containing floating-point instructions. This is the
33783 default.
33784
33785 @opindex mno-fpu
33786 @opindex msoft-float
33787 @item -mno-fpu
33788 @itemx -msoft-float
33789 Generate output containing library calls for floating point.
33790 @strong{Warning:} the requisite libraries are not available for all SPARC
33791 targets. Normally the facilities of the machine's usual C compiler are
33792 used, but this cannot be done directly in cross-compilation. You must make
33793 your own arrangements to provide suitable library functions for
33794 cross-compilation. The embedded targets @samp{sparc-*-aout} and
33795 @samp{sparclite-*-*} do provide software floating-point support.
33796
33797 @option{-msoft-float} changes the calling convention in the output file;
33798 therefore, it is only useful if you compile @emph{all} of a program with
33799 this option. In particular, you need to compile @file{libgcc.a}, the
33800 library that comes with GCC, with @option{-msoft-float} in order for
33801 this to work.
33802
33803 @opindex mhard-quad-float
33804 @item -mhard-quad-float
33805 Generate output containing quad-word (long double) floating-point
33806 instructions.
33807
33808 @opindex msoft-quad-float
33809 @item -msoft-quad-float
33810 Generate output containing library calls for quad-word (long double)
33811 floating-point instructions. The functions called are those specified
33812 in the SPARC ABI@. This is the default.
33813
33814 As of this writing, there are no SPARC implementations that have hardware
33815 support for the quad-word floating-point instructions. They all invoke
33816 a trap handler for one of these instructions, and then the trap handler
33817 emulates the effect of the instruction. Because of the trap handler overhead,
33818 this is much slower than calling the ABI library routines. Thus the
33819 @option{-msoft-quad-float} option is the default.
33820
33821 @opindex mno-unaligned-doubles
33822 @opindex munaligned-doubles
33823 @item -mno-unaligned-doubles
33824 @itemx -munaligned-doubles
33825 Assume that doubles have 8-byte alignment. This is the default.
33826
33827 With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
33828 alignment only if they are contained in another type, or if they have an
33829 absolute address. Otherwise, it assumes they have 4-byte alignment.
33830 Specifying this option avoids some rare compatibility problems with code
33831 generated by other compilers. It is not the default because it results
33832 in a performance loss, especially for floating-point code.
33833
33834 @opindex muser-mode
33835 @opindex mno-user-mode
33836 @item -muser-mode
33837 @itemx -mno-user-mode
33838 Do not generate code that can only run in supervisor mode. This is relevant
33839 only for the @code{casa} instruction emitted for the LEON3 processor. This
33840 is the default.
33841
33842 @opindex mfaster-structs
33843 @opindex mno-faster-structs
33844 @item -mfaster-structs
33845 @itemx -mno-faster-structs
33846 With @option{-mfaster-structs}, the compiler assumes that structures
33847 should have 8-byte alignment. This enables the use of pairs of
33848 @code{ldd} and @code{std} instructions for copies in structure
33849 assignment, in place of twice as many @code{ld} and @code{st} pairs.
33850 However, the use of this changed alignment directly violates the SPARC
33851 ABI@. Thus, it's intended only for use on targets where the developer
33852 acknowledges that their resulting code is not directly in line with
33853 the rules of the ABI@.
33854
33855 @opindex mstd-struct-return
33856 @opindex mno-std-struct-return
33857 @item -mstd-struct-return
33858 @itemx -mno-std-struct-return
33859 With @option{-mstd-struct-return}, the compiler generates checking code
33860 in functions returning structures or unions to detect size mismatches
33861 between the two sides of function calls, as per the 32-bit ABI@.
33862
33863 The default is @option{-mno-std-struct-return}. This option has no effect
33864 in 64-bit mode.
33865
33866 @opindex mcpu
33867 @item -mcpu=@var{cpu_type}
33868 Set the instruction set, register set, and instruction scheduling parameters
33869 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
33870 @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
33871 @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
33872 @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
33873 @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
33874 @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
33875 @samp{m8}.
33876
33877 Native Solaris and GNU/Linux toolchains also support the value @samp{native},
33878 which selects the best architecture option for the host processor.
33879 @option{-mcpu=native} has no effect if GCC does not recognize
33880 the processor.
33881
33882 Default instruction scheduling parameters are used for values that select
33883 an architecture and not an implementation. These are @samp{v7}, @samp{v8},
33884 @samp{sparclite}, @samp{sparclet}, @samp{v9}.
33885
33886 Here is a list of each supported architecture and their supported
33887 implementations.
33888
33889 @table @asis
33890 @item v7
33891 cypress, leon3v7
33892
33893 @item v8
33894 supersparc, hypersparc, leon, leon3, leon5
33895
33896 @item sparclite
33897 f930, f934, sparclite86x
33898
33899 @item sparclet
33900 tsc701
33901
33902 @item v9
33903 ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
33904 niagara7, m8
33905 @end table
33906
33907 By default (unless configured otherwise), GCC generates code for the V7
33908 variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
33909 additionally optimizes it for the Cypress CY7C602 chip, as used in the
33910 SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
33911 SPARCStation 1, 2, IPX etc.
33912
33913 With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
33914 architecture. The only difference from V7 code is that the compiler emits
33915 the integer multiply and integer divide instructions which exist in SPARC-V8
33916 but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
33917 optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
33918 2000 series.
33919
33920 With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
33921 the SPARC architecture. This adds the integer multiply, integer divide step
33922 and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
33923 With @option{-mcpu=f930}, the compiler additionally optimizes it for the
33924 Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
33925 @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
33926 MB86934 chip, which is the more recent SPARClite with FPU@.
33927
33928 With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
33929 the SPARC architecture. This adds the integer multiply, multiply/accumulate,
33930 integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
33931 but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
33932 optimizes it for the TEMIC SPARClet chip.
33933
33934 With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
33935 architecture. This adds 64-bit integer and floating-point move instructions,
33936 3 additional floating-point condition code registers and conditional move
33937 instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
33938 optimizes it for the Sun UltraSPARC I/II/IIi chips. With
33939 @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
33940 Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
33941 @option{-mcpu=niagara}, the compiler additionally optimizes it for
33942 Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
33943 additionally optimizes it for Sun UltraSPARC T2 chips. With
33944 @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
33945 UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
33946 additionally optimizes it for Sun UltraSPARC T4 chips. With
33947 @option{-mcpu=niagara7}, the compiler additionally optimizes it for
33948 Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
33949 additionally optimizes it for Oracle M8 chips.
33950
33951 @opindex mtune
33952 @item -mtune=@var{cpu_type}
33953 Set the instruction scheduling parameters for machine type
33954 @var{cpu_type}, but do not set the instruction set or register set that the
33955 option @option{-mcpu=@var{cpu_type}} does.
33956
33957 The same values for @option{-mcpu=@var{cpu_type}} can be used for
33958 @option{-mtune=@var{cpu_type}}, but the only useful values are those
33959 that select a particular CPU implementation. Those are
33960 @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
33961 @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
33962 @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
33963 @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
33964 @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
33965 and GNU/Linux toolchains, @samp{native} can also be used.
33966
33967 @opindex mv8plus
33968 @opindex mno-v8plus
33969 @item -mv8plus
33970 @itemx -mno-v8plus
33971 With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
33972 difference from the V8 ABI is that the global and out registers are
33973 considered 64 bits wide. This is enabled by default on Solaris in 32-bit
33974 mode for all SPARC-V9 processors.
33975
33976 @opindex mvis
33977 @opindex mno-vis
33978 @item -mvis
33979 @itemx -mno-vis
33980 With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
33981 Visual Instruction Set extensions. The default is @option{-mno-vis}.
33982
33983 @opindex mvis2
33984 @opindex mno-vis2
33985 @item -mvis2
33986 @itemx -mno-vis2
33987 With @option{-mvis2}, GCC generates code that takes advantage of
33988 version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
33989 default is @option{-mvis2} when targeting a cpu that supports such
33990 instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
33991 also sets @option{-mvis}.
33992
33993 @opindex mvis3
33994 @opindex mno-vis3
33995 @item -mvis3
33996 @itemx -mno-vis3
33997 With @option{-mvis3}, GCC generates code that takes advantage of
33998 version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
33999 default is @option{-mvis3} when targeting a cpu that supports such
34000 instructions, such as niagara-3 and later. Setting @option{-mvis3}
34001 also sets @option{-mvis2} and @option{-mvis}.
34002
34003 @opindex mvis3b
34004 @opindex mno-vis3b
34005 @item -mvis3b
34006 @itemx -mno-vis3b
34007 With @option{-mvis3b}, GCC generates code that takes advantage of
34008 version 3.0 of the UltraSPARC Visual Instruction Set extensions, plus
34009 the additional VIS instructions introduced in the Oracle SPARC
34010 Architecture 2011. The default is @option{-mvis3b} when targeting
34011 a cpu that supports such instructions, such as niagara-7 and later.
34012 Setting @option{-mvis3b} also sets @option{-mvis3}, @option{-mvis2}
34013 and @option{-mvis}.
34014
34015 @opindex mvis4
34016 @opindex mno-vis4
34017 @item -mvis4
34018 @itemx -mno-vis4
34019 With @option{-mvis4}, GCC generates code that takes advantage of
34020 version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
34021 default is @option{-mvis4} when targeting a cpu that supports such
34022 instructions, such as niagara-7 and later. Setting @option{-mvis4}
34023 also sets @option{-mvis3b}, @option{-mvis3}, @option{-mvis2} and
34024 @option{-mvis}.
34025
34026 @opindex mvis4b
34027 @opindex mno-vis4b
34028 @item -mvis4b
34029 @itemx -mno-vis4b
34030 With @option{-mvis4b}, GCC generates code that takes advantage of
34031 version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
34032 the additional VIS instructions introduced in the Oracle SPARC
34033 Architecture 2017. The default is @option{-mvis4b} when targeting a
34034 cpu that supports such instructions, such as m8 and later. Setting
34035 @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3b},
34036 @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
34037
34038 @opindex mcbcond
34039 @opindex mno-cbcond
34040 @item -mcbcond
34041 @itemx -mno-cbcond
34042 With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
34043 Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
34044 when targeting a CPU that supports such instructions, such as Niagara-4 and
34045 later.
34046
34047 @opindex mfmaf
34048 @opindex mno-fmaf
34049 @item -mfmaf
34050 @itemx -mno-fmaf
34051 With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
34052 Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
34053 when targeting a CPU that supports such instructions, such as Niagara-3 and
34054 later.
34055
34056 @opindex mfsmuld
34057 @opindex mno-fsmuld
34058 @item -mfsmuld
34059 @itemx -mno-fsmuld
34060 With @option{-mfsmuld}, GCC generates code that takes advantage of the
34061 Floating-point Multiply Single to Double (FsMULd) instruction. The default is
34062 @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
34063 or V9 with FPU except @option{-mcpu=leon}.
34064
34065 @opindex mpopc
34066 @opindex mno-popc
34067 @item -mpopc
34068 @itemx -mno-popc
34069 With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
34070 Population Count instruction. The default is @option{-mpopc}
34071 when targeting a CPU that supports such an instruction, such as Niagara-2 and
34072 later.
34073
34074 @opindex msubxc
34075 @opindex mno-subxc
34076 @item -msubxc
34077 @itemx -mno-subxc
34078 With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
34079 Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
34080 when targeting a CPU that supports such an instruction, such as Niagara-7 and
34081 later.
34082
34083 @opindex mfix-at697f
34084 @item -mfix-at697f
34085 Enable the documented workaround for the single erratum of the Atmel AT697F
34086 processor (which corresponds to erratum #13 of the AT697E processor).
34087
34088 @opindex mfix-ut699
34089 @item -mfix-ut699
34090 Enable the documented workarounds for the floating-point errata and the data
34091 cache nullify errata of the UT699 processor.
34092
34093 @opindex mfix-ut700
34094 @item -mfix-ut700
34095 Enable the documented workaround for the back-to-back store errata of
34096 the UT699E/UT700 processor.
34097
34098 @opindex mfix-gr712rc
34099 @item -mfix-gr712rc
34100 Enable the documented workaround for the back-to-back store errata of
34101 the GR712RC processor.
34102 @end table
34103
34104 These @samp{-m} options are supported in addition to the above
34105 on SPARC-V9 processors in 64-bit environments:
34106
34107 @table @gcctabopt
34108 @opindex m32
34109 @opindex m64
34110 @item -m32
34111 @itemx -m64
34112 Generate code for a 32-bit or 64-bit environment.
34113 The 32-bit environment sets int, long and pointer to 32 bits.
34114 The 64-bit environment sets int to 32 bits and long and pointer
34115 to 64 bits.
34116
34117 @opindex mcmodel=
34118 @item -mcmodel=@var{which}
34119 Set the code model to one of
34120
34121 @table @samp
34122 @item medlow
34123 The Medium/Low code model: 64-bit addresses, programs
34124 must be linked in the low 32 bits of memory. Programs can be statically
34125 or dynamically linked.
34126
34127 @item medmid
34128 The Medium/Middle code model: 64-bit addresses, programs
34129 must be linked in the low 44 bits of memory, the text and data segments must
34130 be less than 2GB in size and the data segment must be located within 2GB of
34131 the text segment.
34132
34133 @item medany
34134 The Medium/Anywhere code model: 64-bit addresses, programs
34135 may be linked anywhere in memory, the text and data segments must be less
34136 than 2GB in size and the data segment must be located within 2GB of the
34137 text segment.
34138
34139 @item embmedany
34140 The Medium/Anywhere code model for embedded systems:
34141 64-bit addresses, the text and data segments must be less than 2GB in
34142 size, both starting anywhere in memory (determined at link time). The
34143 global register %g4 points to the base of the data segment. Programs
34144 are statically linked and PIC is not supported.
34145 @end table
34146
34147 @opindex mmemory-model
34148 @item -mmemory-model=@var{mem-model}
34149 Set the memory model in force on the processor to one of
34150
34151 @table @samp
34152 @item default
34153 The default memory model for the processor and operating system.
34154
34155 @item rmo
34156 Relaxed Memory Order
34157
34158 @item pso
34159 Partial Store Order
34160
34161 @item tso
34162 Total Store Order
34163
34164 @item sc
34165 Sequential Consistency
34166 @end table
34167
34168 These memory models are formally defined in Appendix D of the SPARC-V9
34169 architecture manual, as set in the processor's @code{PSTATE.MM} field.
34170
34171 @opindex mstack-bias
34172 @opindex mno-stack-bias
34173 @item -mstack-bias
34174 @itemx -mno-stack-bias
34175 With @option{-mstack-bias}, GCC assumes that the stack pointer, and
34176 frame pointer if present, are offset by @minus{}2047 which must be added back
34177 when making stack frame references. This is the default in 64-bit mode.
34178 Otherwise, assume no such offset is present.
34179 @end table
34180
34181 @node System V Options
34182 @subsection Options for System V
34183
34184 These additional options are available on System V Release 4 for
34185 compatibility with other compilers on those systems:
34186
34187 @table @gcctabopt
34188 @opindex G
34189 @item -G
34190 Create a shared object.
34191 It is recommended that @option{-symbolic} or @option{-shared} be used instead.
34192
34193 @opindex Qy
34194 @item -Qy
34195 Identify the versions of each tool used by the compiler, in a
34196 @code{.ident} assembler directive in the output.
34197
34198 @opindex Qn
34199 @item -Qn
34200 Refrain from adding @code{.ident} directives to the output file (this is
34201 the default).
34202
34203 @opindex YP
34204 @item -YP,@var{dirs}
34205 Search the directories @var{dirs}, and no others, for libraries
34206 specified with @option{-l}.
34207
34208 @opindex Ym
34209 @item -Ym,@var{dir}
34210 Look in the directory @var{dir} to find the M4 preprocessor.
34211 The assembler uses this option.
34212 @c This is supposed to go with a -Yd for predefined M4 macro files, but
34213 @c the generic assembler that comes with Solaris takes just -Ym.
34214 @end table
34215
34216 @node V850 Options
34217 @subsection V850 Options
34218 @cindex V850 Options
34219
34220 These @samp{-m} options are defined for V850 implementations:
34221
34222 @table @gcctabopt
34223 @opindex mlong-calls
34224 @opindex mno-long-calls
34225 @item -mlong-calls
34226 @itemx -mno-long-calls
34227 Treat all calls as being far away (near). If calls are assumed to be
34228 far away, the compiler always loads the function's address into a
34229 register, and calls indirect through the pointer.
34230
34231 @opindex mno-ep
34232 @opindex mep
34233 @item -mno-ep
34234 @itemx -mep
34235 Do not optimize (do optimize) basic blocks that use the same index
34236 pointer 4 or more times to copy pointer into the @code{ep} register, and
34237 use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
34238 option is on by default if you optimize.
34239
34240 @opindex mno-prolog-function
34241 @opindex mprolog-function
34242 @item -mno-prolog-function
34243 @itemx -mprolog-function
34244 Do not use (do use) external functions to save and restore registers
34245 at the prologue and epilogue of a function. The external functions
34246 are slower, but use less code space if more than one function saves
34247 the same number of registers. The @option{-mprolog-function} option
34248 is on by default if you optimize.
34249
34250 @opindex mspace
34251 @item -mspace
34252 Try to make the code as small as possible. At present, this just turns
34253 on the @option{-mep} and @option{-mprolog-function} options.
34254
34255 @opindex mtda
34256 @item -mtda=@var{n}
34257 Put static or global variables whose size is @var{n} bytes or less into
34258 the tiny data area that register @code{ep} points to. The tiny data
34259 area can hold up to 256 bytes in total (128 bytes for byte references).
34260
34261 @opindex msda
34262 @item -msda=@var{n}
34263 Put static or global variables whose size is @var{n} bytes or less into
34264 the small data area that register @code{gp} points to. The small data
34265 area can hold up to 64 kilobytes.
34266
34267 @opindex mzda
34268 @item -mzda=@var{n}
34269 Put static or global variables whose size is @var{n} bytes or less into
34270 the first 32 kilobytes of memory.
34271
34272 @opindex mv850
34273 @item -mv850
34274 Specify that the target processor is the V850.
34275
34276 @opindex mv850e3v5
34277 @item -mv850e3v5
34278 Specify that the target processor is the V850E3V5. The preprocessor
34279 constant @code{__v850e3v5__} is defined if this option is used.
34280
34281 @opindex mv850e2v4
34282 @item -mv850e2v4
34283 Specify that the target processor is the V850E3V5. This is an alias for
34284 the @option{-mv850e3v5} option.
34285
34286 @opindex mv850e2v3
34287 @item -mv850e2v3
34288 Specify that the target processor is the V850E2V3. The preprocessor
34289 constant @code{__v850e2v3__} is defined if this option is used.
34290
34291 @opindex mv850e2
34292 @item -mv850e2
34293 Specify that the target processor is the V850E2. The preprocessor
34294 constant @code{__v850e2__} is defined if this option is used.
34295
34296 @opindex mv850e1
34297 @item -mv850e1
34298 Specify that the target processor is the V850E1. The preprocessor
34299 constants @code{__v850e1__} and @code{__v850e__} are defined if
34300 this option is used.
34301
34302 @opindex mv850es
34303 @item -mv850es
34304 Specify that the target processor is the V850ES. This is an alias for
34305 the @option{-mv850e1} option.
34306
34307 @opindex mv850e
34308 @item -mv850e
34309 Specify that the target processor is the V850E@. The preprocessor
34310 constant @code{__v850e__} is defined if this option is used.
34311
34312 If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
34313 nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
34314 are defined then a default target processor is chosen and the
34315 relevant @samp{__v850*__} preprocessor constant is defined.
34316
34317 The preprocessor constants @code{__v850} and @code{__v851__} are always
34318 defined, regardless of which processor variant is the target.
34319
34320 @opindex mdisable-callt
34321 @opindex mno-disable-callt
34322 @item -mdisable-callt
34323 @itemx -mno-disable-callt
34324 This option suppresses generation of the @code{CALLT} instruction for the
34325 v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
34326 architecture.
34327
34328 This option is enabled by default when the RH850 ABI is
34329 in use (see @option{-mrh850-abi}), and disabled by default when the
34330 GCC ABI is in use. If @code{CALLT} instructions are being generated
34331 then the C preprocessor symbol @code{__V850_CALLT__} is defined.
34332
34333 @opindex mrelax
34334 @opindex mno-relax
34335 @item -mrelax
34336 @itemx -mno-relax
34337 Pass on (or do not pass on) the @option{-mrelax} command-line option
34338 to the assembler.
34339
34340 @opindex mlong-jumps
34341 @opindex mno-long-jumps
34342 @item -mlong-jumps
34343 @itemx -mno-long-jumps
34344 Disable (or re-enable) the generation of PC-relative jump instructions.
34345
34346 @opindex msoft-float
34347 @opindex mhard-float
34348 @item -msoft-float
34349 @itemx -mhard-float
34350 Disable (or re-enable) the generation of hardware floating point
34351 instructions. This option is only significant when the target
34352 architecture is @samp{V850E2V3} or higher. If hardware floating point
34353 instructions are being generated then the C preprocessor symbol
34354 @code{__FPU_OK__} is defined, otherwise the symbol
34355 @code{__NO_FPU__} is defined.
34356
34357 @opindex mloop
34358 @item -mloop
34359 Enables the use of the e3v5 LOOP instruction. The use of this
34360 instruction is not enabled by default when the e3v5 architecture is
34361 selected because its use is still experimental.
34362
34363 @opindex mrh850-abi
34364 @opindex mghs
34365 @item -mrh850-abi
34366 @itemx -mghs
34367 Enables support for the RH850 version of the V850 ABI. This is the
34368 default. With this version of the ABI the following rules apply:
34369
34370 @itemize
34371 @item
34372 Integer sized structures and unions are returned via a memory pointer
34373 rather than a register.
34374
34375 @item
34376 Large structures and unions (more than 8 bytes in size) are passed by
34377 value.
34378
34379 @item
34380 Functions are aligned to 16-bit boundaries.
34381
34382 @item
34383 The @option{-m8byte-align} command-line option is supported.
34384
34385 @item
34386 The @option{-mdisable-callt} command-line option is enabled by
34387 default. The @option{-mno-disable-callt} command-line option is not
34388 supported.
34389 @end itemize
34390
34391 When this version of the ABI is enabled the C preprocessor symbol
34392 @code{__V850_RH850_ABI__} is defined.
34393
34394 @opindex mgcc-abi
34395 @item -mgcc-abi
34396 Enables support for the old GCC version of the V850 ABI. With this
34397 version of the ABI the following rules apply:
34398
34399 @itemize
34400 @item
34401 Integer sized structures and unions are returned in register @code{r10}.
34402
34403 @item
34404 Large structures and unions (more than 8 bytes in size) are passed by
34405 reference.
34406
34407 @item
34408 Functions are aligned to 32-bit boundaries, unless optimizing for
34409 size.
34410
34411 @item
34412 The @option{-m8byte-align} command-line option is not supported.
34413
34414 @item
34415 The @option{-mdisable-callt} command-line option is supported but not
34416 enabled by default.
34417 @end itemize
34418
34419 When this version of the ABI is enabled the C preprocessor symbol
34420 @code{__V850_GCC_ABI__} is defined.
34421
34422 @opindex m8byte-align
34423 @opindex mno-8byte-align
34424 @item -m8byte-align
34425 @itemx -mno-8byte-align
34426 Enables support for @code{double} and @code{long long} types to be
34427 aligned on 8-byte boundaries. The default is to restrict the
34428 alignment of all objects to at most 4-bytes. When
34429 @option{-m8byte-align} is in effect the C preprocessor symbol
34430 @code{__V850_8BYTE_ALIGN__} is defined.
34431
34432 @opindex mbig-switch
34433 @item -mbig-switch
34434 Generate code suitable for big switch tables. Use this option only if
34435 the assembler/linker complain about out of range branches within a switch
34436 table.
34437
34438 @opindex mapp-regs
34439 @item -mapp-regs
34440 This option causes r2 and r5 to be used in the code generated by
34441 the compiler. This setting is the default.
34442
34443 @opindex mno-app-regs
34444 @item -mno-app-regs
34445 This option causes r2 and r5 to be treated as fixed registers.
34446
34447 @end table
34448
34449 @node VAX Options
34450 @subsection VAX Options
34451 @cindex VAX options
34452
34453 These @samp{-m} options are defined for the VAX:
34454
34455 @table @gcctabopt
34456 @opindex munix
34457 @item -munix
34458 Do not output certain jump instructions (@code{aobleq} and so on)
34459 that the Unix assembler for the VAX cannot handle across long
34460 ranges.
34461
34462 @opindex mgnu
34463 @item -mgnu
34464 Do output those jump instructions, on the assumption that the
34465 GNU assembler is being used.
34466
34467 @opindex md
34468 @opindex md-float
34469 @item -md
34470 @itemx -md-float
34471 Use the D_floating data format for double-precision floating-point numbers
34472 instead of G_floating.
34473
34474 @opindex mg
34475 @opindex mg-float
34476 @item -mg
34477 @itemx -mg-float
34478 Use the G_floating data format for double-precision floating-point numbers
34479 instead of D_floating.
34480
34481 @opindex mlra
34482 @opindex mno-lra
34483 @item -mlra
34484 @itemx -mno-lra
34485 Enable Local Register Allocation. This is still experimental for the VAX,
34486 so by default the compiler uses standard reload.
34487 @end table
34488
34489 @node Visium Options
34490 @subsection Visium Options
34491 @cindex Visium options
34492
34493 @table @gcctabopt
34494
34495 @opindex mdebug
34496 @item -mdebug
34497 A program which performs file I/O and is destined to run on an MCM target
34498 should be linked with this option. It causes the libraries libc.a and
34499 libdebug.a to be linked. The program should be run on the target under
34500 the control of the GDB remote debugging stub.
34501
34502 @opindex msim
34503 @item -msim
34504 A program which performs file I/O and is destined to run on the simulator
34505 should be linked with option. This causes libraries libc.a and libsim.a to
34506 be linked.
34507
34508 @opindex mfpu
34509 @opindex mhard-float
34510 @item -mfpu
34511 @itemx -mhard-float
34512 Generate code containing floating-point instructions. This is the
34513 default.
34514
34515 @opindex mno-fpu
34516 @opindex msoft-float
34517 @item -mno-fpu
34518 @itemx -msoft-float
34519 Generate code containing library calls for floating-point.
34520
34521 @option{-msoft-float} changes the calling convention in the output file;
34522 therefore, it is only useful if you compile @emph{all} of a program with
34523 this option. In particular, you need to compile @file{libgcc.a}, the
34524 library that comes with GCC, with @option{-msoft-float} in order for
34525 this to work.
34526
34527 @opindex mcpu
34528 @item -mcpu=@var{cpu_type}
34529 Set the instruction set, register set, and instruction scheduling parameters
34530 for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
34531 @samp{mcm}, @samp{gr5} and @samp{gr6}.
34532
34533 @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
34534
34535 By default (unless configured otherwise), GCC generates code for the GR5
34536 variant of the Visium architecture.
34537
34538 With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
34539 architecture. The only difference from GR5 code is that the compiler will
34540 generate block move instructions.
34541
34542 @opindex mtune
34543 @item -mtune=@var{cpu_type}
34544 Set the instruction scheduling parameters for machine type @var{cpu_type},
34545 but do not set the instruction set or register set that the option
34546 @option{-mcpu=@var{cpu_type}} would.
34547
34548 @opindex msv-mode
34549 @item -msv-mode
34550 Generate code for the supervisor mode, where there are no restrictions on
34551 the access to general registers. This is the default.
34552
34553 @opindex muser-mode
34554 @item -muser-mode
34555 Generate code for the user mode, where the access to some general registers
34556 is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
34557 mode; on the GR6, only registers r29 to r31 are affected.
34558 @end table
34559
34560 @node VMS Options
34561 @subsection VMS Options
34562
34563 These @samp{-m} options are defined for the VMS implementations:
34564
34565 @table @gcctabopt
34566 @opindex mvms-return-codes
34567 @item -mvms-return-codes
34568 Return VMS condition codes from @code{main}. The default is to return POSIX-style
34569 condition (e.g.@: error) codes.
34570
34571 @opindex mdebug-main=@var{prefix}
34572 @item -mdebug-main=@var{prefix}
34573 Flag the first routine whose name starts with @var{prefix} as the main
34574 routine for the debugger.
34575
34576 @opindex mmalloc64
34577 @item -mmalloc64
34578 Default to 64-bit memory allocation routines.
34579
34580 @opindex mpointer-size=@var{size}
34581 @item -mpointer-size=@var{size}
34582 Set the default size of pointers. Possible options for @var{size} are
34583 @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
34584 for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
34585 The later option disables @code{pragma pointer_size}.
34586 @end table
34587
34588 @node VxWorks Options
34589 @subsection VxWorks Options
34590 @cindex VxWorks Options
34591
34592 The options in this section are defined for all VxWorks targets.
34593 Options specific to the target hardware are listed with the other
34594 options for that target.
34595
34596 @table @gcctabopt
34597 @opindex mrtp
34598 @item -mrtp
34599 GCC can generate code for both VxWorks kernels and real time processes
34600 (RTPs). This option switches from the former to the latter. It also
34601 defines the preprocessor macro @code{__RTP__}.
34602
34603 @opindex msmp
34604 @item -msmp
34605 Select SMP runtimes for linking. Not available on architectures other
34606 than PowerPC, nor on VxWorks version 7 or later, in which the selection
34607 is part of the VxWorks build configuration and the library paths are the
34608 same for either choice.
34609
34610 @opindex non-static
34611 @item -non-static
34612 Link an RTP executable against shared libraries rather than static
34613 libraries. The options @option{-static} and @option{-shared} can
34614 also be used for RTPs (@pxref{Link Options}); @option{-static}
34615 is the default.
34616
34617 @opindex Bstatic
34618 @opindex Bdynamic
34619 @item -Bstatic
34620 @itemx -Bdynamic
34621 These options are passed down to the linker. They are defined for
34622 compatibility with Diab.
34623
34624 @opindex Xbind-lazy
34625 @item -Xbind-lazy
34626 Enable lazy binding of function calls. This option is equivalent to
34627 @option{-Wl,-z,now} and is defined for compatibility with Diab.
34628
34629 @opindex Xbind-now
34630 @item -Xbind-now
34631 Disable lazy binding of function calls. This option is the default and
34632 is defined for compatibility with Diab.
34633 @end table
34634
34635 @node x86 Options
34636 @subsection x86 Options
34637 @cindex x86 Options
34638
34639 These @samp{-m} options are defined for the x86 family of computers.
34640
34641 @table @gcctabopt
34642
34643 @opindex march
34644 @item -march=@var{cpu-type}
34645 Generate instructions for the machine type @var{cpu-type}. In contrast to
34646 @option{-mtune=@var{cpu-type}}, which merely tunes the generated code
34647 for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
34648 to generate code that may not run at all on processors other than the one
34649 indicated. Specifying @option{-march=@var{cpu-type}} implies
34650 @option{-mtune=@var{cpu-type}}, except where noted otherwise.
34651
34652 The choices for @var{cpu-type} are:
34653
34654 @table @samp
34655 @item native
34656 This selects the CPU to generate code for at compilation time by determining
34657 the processor type of the compiling machine. Using @option{-march=native}
34658 enables all instruction subsets supported by the local machine (hence
34659 the result might not run on different machines). Using @option{-mtune=native}
34660 produces code optimized for the local machine under the constraints
34661 of the selected instruction set.
34662
34663 @item x86-64
34664 A generic CPU with 64-bit extensions, MMX, SSE, SSE2, and FXSR instruction set
34665 support.
34666
34667 @item x86-64-v2
34668 @itemx x86-64-v3
34669 @itemx x86-64-v4
34670 These choices for @var{cpu-type} select the corresponding
34671 micro-architecture level from the x86-64 psABI. On ABIs other than
34672 the x86-64 psABI they select the same CPU features as the x86-64 psABI
34673 documents for the particular micro-architecture level.
34674
34675 Since these @var{cpu-type} values do not have a corresponding
34676 @option{-mtune} setting, using @option{-march} with these values enables
34677 generic tuning. Specific tuning can be enabled using the
34678 @option{-mtune=@var{other-cpu-type}} option with an appropriate
34679 @var{other-cpu-type} value.
34680
34681 @item i386
34682 Original Intel i386 CPU@.
34683
34684 @item i486
34685 Intel i486 CPU@. (No scheduling is implemented for this chip.)
34686
34687 @item i586
34688 @itemx pentium
34689 Intel Pentium CPU with no MMX support.
34690
34691 @item lakemont
34692 Intel Lakemont MCU, based on Intel Pentium CPU.
34693
34694 @item pentium-mmx
34695 Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
34696
34697 @item pentiumpro
34698 Intel Pentium Pro CPU with no MMX support.
34699
34700 @item i686
34701 When used with @option{-march}, the Pentium Pro
34702 instruction set is used, so the code runs on all i686 family chips.
34703 When used with @option{-mtune}, it has the same meaning as @samp{generic}.
34704
34705 @item pentium2
34706 Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
34707 set support.
34708
34709 @item pentium3
34710 @itemx pentium3m
34711 Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
34712 instruction set support.
34713
34714 @item pentium-m
34715 Intel Pentium M; low-power version of Intel Pentium III CPU
34716 with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
34717 notebooks.
34718
34719 @item pentium4
34720 @itemx pentium4m
34721 Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
34722
34723 @item prescott
34724 Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
34725 instruction set support.
34726
34727 @item nocona
34728 Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
34729 SSE2, SSE3 and FXSR instruction set support.
34730
34731 @item core2
34732 Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
34733 SAHF and FXSR instruction set support.
34734
34735 @item nehalem
34736 @itemx corei7
34737 Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34738 SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
34739
34740 @item westmere
34741 Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34742 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
34743
34744 @item sandybridge
34745 @itemx corei7-avx
34746 Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34747 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
34748 support.
34749
34750 @item ivybridge
34751 @itemx core-avx-i
34752 Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34753 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
34754 and F16C instruction set support.
34755
34756 @item haswell
34757 @itemx core-avx2
34758 Intel Haswell CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34759 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34760 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
34761
34762 @item broadwell
34763 Intel Broadwell CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34764 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34765 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
34766 instruction set support.
34767
34768 @item skylake
34769 Intel Skylake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34770 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34771 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34772 CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
34773
34774 @item skylake-avx512
34775 Intel Skylake Server CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
34776 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34777 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34778 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
34779 AVX512DQ and AVX512CD instruction set support.
34780
34781 @item cascadelake
34782 Intel Cascade Lake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34783 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34784 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34785 CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
34786 AVX512CD and AVX512VNNI instruction set support.
34787
34788 @item cannonlake
34789 Intel Cannon Lake Server CPU with 64-bit extensions, MMX, SSE, SSE2,
34790 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
34791 FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
34792 PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
34793 AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
34794 support.
34795
34796 @item cooperlake
34797 Intel Cooper Lake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34798 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34799 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34800 CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
34801 AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
34802
34803 @item icelake-client
34804 Intel Ice Lake Client CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
34805 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34806 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34807 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34808 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
34809 , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
34810
34811 @item icelake-server
34812 Intel Ice Lake Server CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
34813 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34814 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34815 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34816 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
34817 , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
34818 instruction set support.
34819
34820 @item tigerlake
34821 Intel Tiger Lake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34822 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34823 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34824 CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
34825 PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34826 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
34827 AVX512VP2INTERSECT and KEYLOCKER instruction set support.
34828
34829 @item rocketlake
34830 Intel Rocket Lake CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34831 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34832 F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34833 CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
34834 PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34835 VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
34836
34837 @item alderlake
34838 @itemx raptorlake
34839 @itemx meteorlake
34840 @itemx gracemont
34841 Intel Alder Lake/Raptor Lake/Meteor Lake/Gracemont CPU with 64-bit extensions,
34842 MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW,
34843 PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX,
34844 GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C,
34845 FMA, LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and
34846 AVX-VNNI instruction set support.
34847
34848 @item arrowlake
34849 Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34850 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34851 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34852 MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
34853 VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR, AVXIFMA,
34854 AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
34855
34856 @item arrowlake-s
34857 @itemx lunarlake
34858 Intel Arrow Lake S/Lunar Lake CPU with 64-bit extensions, MOVBE, MMX, SSE,
34859 SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND,
34860 XSAVE, XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
34861 MOVDIRI, MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34862 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR,
34863 AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3 and
34864 SM4 instruction set support.
34865
34866 @item pantherlake
34867 Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34868 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34869 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34870 MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
34871 VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR, AVXIFMA,
34872 AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4 and
34873 PREFETCHI instruction set support.
34874
34875 @item sapphirerapids
34876 @itemx emeraldrapids
34877 Intel Sapphire Rapids/Emerald Rapids CPU with 64-bit extensions, MMX, SSE,
34878 SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
34879 FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
34880 PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
34881 AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES,
34882 AVX512VBMI2, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG,
34883 WBNOINVD, CLWB, MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
34884 SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16
34885 and AVX512BF16 instruction set support.
34886
34887 @item graniterapids
34888 Intel Granite Rapids CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
34889 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34890 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34891 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34892 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34893 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
34894 MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34895 UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16
34896 and PREFETCHI instruction set support.
34897
34898 @item graniterapids-d
34899 Intel Granite Rapids D CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3,
34900 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34901 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34902 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34903 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34904 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
34905 MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34906 UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16,
34907 PREFETCHI and AMX-COMPLEX instruction set support.
34908
34909 @item diamondrapids
34910 Intel Diamond Rapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34911 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34912 RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34913 AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34914 AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34915 VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
34916 MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34917 UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16,
34918 PREFETCHI, AMX-COMPLEX, AVX10.1-512, AVX-IFMA, AVX-NE-CONVERT, AVX-VNNI-INT16,
34919 AVX-VNNI-INT8, CMPccXADD, SHA512, SM3, SM4, AVX10.2-512, APX_F, AMX-AVX512,
34920 AMX-FP8, AMX-TF32, AMX-TRANSPOSE, MOVRS, AMX-MOVRS and USER_MSR instruction set
34921 support.
34922
34923 @item bonnell
34924 @itemx atom
34925 Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
34926 instruction set support.
34927
34928 @item silvermont
34929 @itemx slm
34930 Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34931 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
34932 instruction set support.
34933
34934 @item goldmont
34935 Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34936 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
34937 RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
34938 set support.
34939
34940 @item goldmont-plus
34941 Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34942 SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
34943 SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
34944 RDPID and SGX instruction set support.
34945
34946 @item tremont
34947 Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34948 SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
34949 RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
34950 SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
34951 support.
34952
34953 @item sierraforest
34954 Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34955 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34956 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34957 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34958 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34959 AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
34960 support.
34961
34962 @item grandridge
34963 Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34964 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34965 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34966 MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34967 PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34968 AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
34969 support.
34970
34971 @item clearwaterforest
34972 Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
34973 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE,
34974 XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
34975 MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA,
34976 LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34977 ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16,
34978 SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support.
34979
34980 @item k6
34981 AMD K6 CPU with MMX instruction set support.
34982
34983 @item k6-2
34984 @itemx k6-3
34985 Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
34986
34987 @item athlon
34988 @itemx athlon-tbird
34989 AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
34990 support.
34991
34992 @item athlon-4
34993 @itemx athlon-xp
34994 @itemx athlon-mp
34995 Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
34996 instruction set support.
34997
34998 @item k8
34999 @itemx opteron
35000 @itemx athlon64
35001 @itemx athlon-fx
35002 Processors based on the AMD K8 core with x86-64 instruction set support,
35003 including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
35004 (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
35005 instruction set extensions.)
35006
35007 @item k8-sse3
35008 @itemx opteron-sse3
35009 @itemx athlon64-sse3
35010 Improved versions of AMD K8 cores with SSE3 instruction set support.
35011
35012 @item amdfam10
35013 @itemx barcelona
35014 CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
35015 supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
35016 instruction set extensions.)
35017
35018 @item bdver1
35019 CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
35020 supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
35021 SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
35022
35023 @item bdver2
35024 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
35025 supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
35026 SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
35027 extensions.)
35028
35029 @item bdver3
35030 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
35031 supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
35032 PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
35033 64-bit instruction set extensions.)
35034
35035 @item bdver4
35036 AMD Family 15h core based CPUs with x86-64 instruction set support. (This
35037 supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
35038 AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
35039 SSE4.2, ABM and 64-bit instruction set extensions.)
35040
35041 @item znver1
35042 AMD Family 17h core based CPUs with x86-64 instruction set support. (This
35043 supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
35044 SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
35045 SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
35046 instruction set extensions.)
35047
35048 @item znver2
35049 AMD Family 17h core based CPUs with x86-64 instruction set support. (This
35050 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
35051 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
35052 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
35053 WBNOINVD, and 64-bit instruction set extensions.)
35054
35055 @item znver3
35056 AMD Family 19h core based CPUs with x86-64 instruction set support. (This
35057 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
35058 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
35059 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
35060 WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
35061
35062 @item znver4
35063 AMD Family 19h core based CPUs with x86-64 instruction set support. (This
35064 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
35065 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
35066 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
35067 WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
35068 AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
35069 AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
35070
35071 @item znver5
35072 AMD Family 1ah core based CPUs with x86-64 instruction set support. (This
35073 supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
35074 MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
35075 SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
35076 WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
35077 AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
35078 AVX512BITALG, AVX512VPOPCNTDQ, GFNI, AVXVNNI, MOVDIRI, MOVDIR64B,
35079 AVX512VP2INTERSECT, PREFETCHI and 64-bit instruction set extensions.)
35080
35081 @item btver1
35082 CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
35083 supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
35084 instruction set extensions.)
35085
35086 @item btver2
35087 CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
35088 includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
35089 SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
35090
35091 @item winchip-c6
35092 IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
35093 set support.
35094
35095 @item winchip2
35096 IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
35097 instruction set support.
35098
35099 @item c3
35100 VIA C3 CPU with MMX and 3DNow!@: instruction set support.
35101 (No scheduling is implemented for this chip.)
35102
35103 @item c3-2
35104 VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
35105 (No scheduling is implemented for this chip.)
35106
35107 @item c7
35108 VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
35109 (No scheduling is implemented for this chip.)
35110
35111 @item samuel-2
35112 VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
35113 (No scheduling is implemented for this chip.)
35114
35115 @item nehemiah
35116 VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
35117 (No scheduling is implemented for this chip.)
35118
35119 @item esther
35120 VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
35121 (No scheduling is implemented for this chip.)
35122
35123 @item eden-x2
35124 VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
35125 (No scheduling is implemented for this chip.)
35126
35127 @item eden-x4
35128 VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
35129 AVX and AVX2 instruction set support.
35130 (No scheduling is implemented for this chip.)
35131
35132 @item nano
35133 Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
35134 instruction set support.
35135 (No scheduling is implemented for this chip.)
35136
35137 @item nano-1000
35138 VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
35139 instruction set support.
35140 (No scheduling is implemented for this chip.)
35141
35142 @item nano-2000
35143 VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
35144 instruction set support.
35145 (No scheduling is implemented for this chip.)
35146
35147 @item nano-3000
35148 VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
35149 instruction set support.
35150 (No scheduling is implemented for this chip.)
35151
35152 @item nano-x2
35153 VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
35154 instruction set support.
35155 (No scheduling is implemented for this chip.)
35156
35157 @item nano-x4
35158 VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
35159 instruction set support.
35160 (No scheduling is implemented for this chip.)
35161
35162 @item lujiazui
35163 ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
35164 SSE4.2, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
35165 ABM, BMI, BMI2, FXSR, RDSEED instruction set support. While the CPUs
35166 do support AVX and F16C, these aren't enabled by @code{-march=lujiazui}
35167 for performance reasons.
35168
35169 @item yongfeng
35170 ZHAOXIN yongfeng CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
35171 SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
35172 ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT
35173 instruction set support.
35174
35175 @item shijidadao
35176 ZHAOXIN shijidadao CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
35177 SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
35178 ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT
35179 instruction set support.
35180
35181 @item geode
35182 AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
35183 @end table
35184
35185 @opindex mtune
35186 @item -mtune=@var{cpu-type}
35187 Tune to @var{cpu-type} everything applicable about the generated code, except
35188 for the ABI and the set of available instructions.
35189 While picking a specific @var{cpu-type} schedules things appropriately
35190 for that particular chip, the compiler does not generate any code that
35191 cannot run on the default machine type unless you use a
35192 @option{-march=@var{cpu-type}} option.
35193 For example, if GCC is configured for i686-pc-linux-gnu
35194 then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
35195 but still runs on i686 machines.
35196
35197 The choices for @var{cpu-type} are the same as for @option{-march}.
35198 In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
35199
35200 @table @samp
35201 @item generic
35202 Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
35203 If you know the CPU on which your code will run, then you should use
35204 the corresponding @option{-mtune} or @option{-march} option instead of
35205 @option{-mtune=generic}. But, if you do not know exactly what CPU users
35206 of your application will have, then you should use this option.
35207
35208 As new processors are deployed in the marketplace, the behavior of this
35209 option will change. Therefore, if you upgrade to a newer version of
35210 GCC, code generation controlled by this option will change to reflect
35211 the processors
35212 that are most common at the time that version of GCC is released.
35213
35214 There is no @option{-march=generic} option because @option{-march}
35215 indicates the instruction set the compiler can use, and there is no
35216 generic instruction set applicable to all processors. In contrast,
35217 @option{-mtune} indicates the processor (or, in this case, collection of
35218 processors) for which the code is optimized.
35219
35220 @item intel
35221 Produce code optimized for the most current Intel processors, which are
35222 Haswell and Silvermont for this version of GCC. If you know the CPU
35223 on which your code will run, then you should use the corresponding
35224 @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
35225 But, if you want your application performs better on both Diamond Rapids
35226 and Clearwater Forest, then you should use this option.
35227
35228 As new Intel processors are deployed in the marketplace, the behavior of
35229 this option will change. Therefore, if you upgrade to a newer version of
35230 GCC, code generation controlled by this option will change to reflect
35231 the most current Intel processors at the time that version of GCC is
35232 released.
35233
35234 There is no @option{-march=intel} option because @option{-march} indicates
35235 the instruction set the compiler can use, and there is no common
35236 instruction set applicable to all processors. In contrast,
35237 @option{-mtune} indicates the processor (or, in this case, collection of
35238 processors) for which the code is optimized.
35239 @end table
35240
35241 @opindex mcpu
35242 @item -mcpu=@var{cpu-type}
35243 A deprecated synonym for @option{-mtune}.
35244
35245 @opindex mfpmath
35246 @item -mfpmath=@var{unit}
35247 Generate floating-point arithmetic for selected unit @var{unit}. The choices
35248 for @var{unit} are:
35249
35250 @table @samp
35251 @item 387
35252 Use the standard 387 floating-point coprocessor present on the majority of chips and
35253 emulated otherwise. Code compiled with this option runs almost everywhere.
35254 The temporary results are computed in 80-bit precision instead of the precision
35255 specified by the type, resulting in slightly different results compared to most
35256 of other chips. See @option{-ffloat-store} for more detailed description.
35257
35258 This is the default choice for non-Darwin x86-32 targets.
35259
35260 @item sse
35261 Use scalar floating-point instructions present in the SSE instruction set.
35262 This instruction set is supported by Pentium III and newer chips,
35263 and in the AMD line
35264 by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
35265 instruction set supports only single-precision arithmetic, thus the double and
35266 extended-precision arithmetic are still done using 387. A later version, present
35267 only in Pentium 4 and AMD x86-64 chips, supports double-precision
35268 arithmetic too.
35269
35270 For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
35271 or @option{-msse2} switches to enable SSE extensions and make this option
35272 effective. For the x86-64 compiler, these extensions are enabled by default.
35273
35274 The resulting code should be considerably faster in the majority of cases and avoid
35275 the numerical instability problems of 387 code, but may break some existing
35276 code that expects temporaries to be 80 bits.
35277
35278 This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
35279 and the default choice for x86-32 targets with the SSE2 instruction set
35280 when @option{-ffast-math} is enabled.
35281
35282 @item sse,387
35283 @itemx sse+387
35284 @itemx both
35285 Attempt to utilize both instruction sets at once. This effectively doubles the
35286 amount of available registers, and on chips with separate execution units for
35287 387 and SSE the execution resources too. Use this option with care, as it is
35288 still experimental, because the GCC register allocator does not model separate
35289 functional units well, resulting in unstable performance.
35290 @end table
35291
35292 @opindex masm=@var{dialect}
35293 @item -masm=@var{dialect}
35294 Output assembly instructions using selected @var{dialect}. Also affects
35295 which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
35296 extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
35297 order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
35298 not support @samp{intel}.
35299
35300 @opindex mieee-fp
35301 @opindex mno-ieee-fp
35302 @item -mieee-fp
35303 @itemx -mno-ieee-fp
35304 Control whether or not the compiler uses IEEE floating-point
35305 comparisons. These correctly handle the case where the result of a
35306 comparison is unordered.
35307
35308 @opindex m80387
35309 @opindex mhard-float
35310 @item -m80387
35311 @itemx -mhard-float
35312 Generate output containing 80387 instructions for floating point.
35313
35314 @opindex no-80387
35315 @opindex msoft-float
35316 @item -mno-80387
35317 @itemx -msoft-float
35318 Generate output containing library calls for floating point.
35319
35320 @strong{Warning:} the requisite libraries are not part of GCC@.
35321 Normally the facilities of the machine's usual C compiler are used, but
35322 this cannot be done directly in cross-compilation. You must make your
35323 own arrangements to provide suitable library functions for
35324 cross-compilation.
35325
35326 On machines where a function returns floating-point results in the 80387
35327 register stack, some floating-point opcodes may be emitted even if
35328 @option{-msoft-float} is used.
35329
35330 @opindex mno-fp-ret-in-387
35331 @opindex mfp-ret-in-387
35332 @item -mno-fp-ret-in-387
35333 Do not use the FPU registers for return values of functions.
35334
35335 The usual calling convention has functions return values of types
35336 @code{float} and @code{double} in an FPU register, even if there
35337 is no FPU@. The idea is that the operating system should emulate
35338 an FPU@.
35339
35340 The option @option{-mno-fp-ret-in-387} causes such values to be returned
35341 in ordinary CPU registers instead.
35342
35343 @opindex mno-fancy-math-387
35344 @opindex mfancy-math-387
35345 @item -mno-fancy-math-387
35346 Some 387 emulators do not support the @code{sin}, @code{cos} and
35347 @code{sqrt} instructions for the 387. Specify this option to avoid
35348 generating those instructions.
35349 This option is overridden when @option{-march}
35350 indicates that the target CPU always has an FPU and so the
35351 instruction does not need emulation. These
35352 instructions are not generated unless you also use the
35353 @option{-funsafe-math-optimizations} switch.
35354
35355 @opindex malign-double
35356 @opindex mno-align-double
35357 @item -malign-double
35358 @itemx -mno-align-double
35359 Control whether GCC aligns @code{double}, @code{long double}, and
35360 @code{long long} variables on a two-word boundary or a one-word
35361 boundary. Aligning @code{double} variables on a two-word boundary
35362 produces code that runs somewhat faster on a Pentium at the
35363 expense of more memory.
35364
35365 On x86-64, @option{-malign-double} is enabled by default.
35366
35367 @strong{Warning:} if you use the @option{-malign-double} switch,
35368 structures containing the above types are aligned differently than
35369 the published application binary interface specifications for the x86-32
35370 and are not binary compatible with structures in code compiled
35371 without that switch.
35372
35373 @opindex m96bit-long-double
35374 @opindex m128bit-long-double
35375 @item -m96bit-long-double
35376 @itemx -m128bit-long-double
35377 These switches control the size of @code{long double} type. The x86-32
35378 application binary interface specifies the size to be 96 bits,
35379 so @option{-m96bit-long-double} is the default in 32-bit mode.
35380
35381 Modern architectures (Pentium and newer) prefer @code{long double}
35382 to be aligned to an 8- or 16-byte boundary. In arrays or structures
35383 conforming to the ABI, this is not possible. So specifying
35384 @option{-m128bit-long-double} aligns @code{long double}
35385 to a 16-byte boundary by padding the @code{long double} with an additional
35386 32-bit zero.
35387
35388 In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
35389 its ABI specifies that @code{long double} is aligned on 16-byte boundary.
35390
35391 Notice that neither of these options enable any extra precision over the x87
35392 standard of 80 bits for a @code{long double}.
35393
35394 @strong{Warning:} if you override the default value for your target ABI, this
35395 changes the size of
35396 structures and arrays containing @code{long double} variables,
35397 as well as modifying the function calling convention for functions taking
35398 @code{long double}. Hence they are not binary-compatible
35399 with code compiled without that switch.
35400
35401 @opindex mlong-double-64
35402 @opindex mlong-double-80
35403 @opindex mlong-double-128
35404 @item -mlong-double-64
35405 @itemx -mlong-double-80
35406 @itemx -mlong-double-128
35407 These switches control the size of @code{long double} type. A size
35408 of 64 bits makes the @code{long double} type equivalent to the @code{double}
35409 type. This is the default for 32-bit Bionic C library. A size
35410 of 128 bits makes the @code{long double} type equivalent to the
35411 @code{__float128} type. This is the default for 64-bit Bionic C library.
35412
35413 @strong{Warning:} if you override the default value for your target ABI, this
35414 changes the size of
35415 structures and arrays containing @code{long double} variables,
35416 as well as modifying the function calling convention for functions taking
35417 @code{long double}. Hence they are not binary-compatible
35418 with code compiled without that switch.
35419
35420 @opindex malign-data
35421 @item -malign-data=@var{type}
35422 Control how GCC aligns variables. Supported values for @var{type} are
35423 @samp{compat} uses increased alignment value compatible uses GCC 4.8
35424 and earlier, @samp{abi} uses alignment value as specified by the
35425 psABI, and @samp{cacheline} uses increased alignment value to match
35426 the cache line size. @samp{compat} is the default.
35427
35428 @opindex mlarge-data-threshold
35429 @item -mlarge-data-threshold=@var{threshold}
35430 When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data
35431 objects larger than @var{threshold} are placed in large data sections. The
35432 default is 65535.
35433
35434 @opindex mrtd
35435 @item -mrtd
35436 Use a different function-calling convention, in which functions that
35437 take a fixed number of arguments return with the @code{ret @var{num}}
35438 instruction, which pops their arguments while returning. This saves one
35439 instruction in the caller since there is no need to pop the arguments
35440 there.
35441
35442 You can specify that an individual function is called with this calling
35443 sequence with the function attribute @code{stdcall}. You can also
35444 override the @option{-mrtd} option by using the function attribute
35445 @code{cdecl}. @xref{Function Attributes}.
35446
35447 @strong{Warning:} this calling convention is incompatible with the one
35448 normally used on Unix, so you cannot use it if you need to call
35449 libraries compiled with the Unix compiler.
35450
35451 Also, you must provide function prototypes for all functions that
35452 take variable numbers of arguments (including @code{printf});
35453 otherwise incorrect code is generated for calls to those
35454 functions.
35455
35456 In addition, seriously incorrect code results if you call a
35457 function with too many arguments. (Normally, extra arguments are
35458 harmlessly ignored.)
35459
35460 @opindex mregparm
35461 @item -mregparm=@var{num}
35462 Control how many registers are used to pass integer arguments. By
35463 default, no registers are used to pass arguments, and at most 3
35464 registers can be used. You can control this behavior for a specific
35465 function by using the function attribute @code{regparm}.
35466 @xref{Function Attributes}.
35467
35468 @strong{Warning:} if you use this switch, and
35469 @var{num} is nonzero, then you must build all modules with the same
35470 value, including any libraries. This includes the system libraries and
35471 startup modules.
35472
35473 @opindex msseregparm
35474 @item -msseregparm
35475 Use SSE register passing conventions for float and double arguments
35476 and return values. You can control this behavior for a specific
35477 function by using the function attribute @code{sseregparm}.
35478 @xref{Function Attributes}.
35479
35480 @strong{Warning:} if you use this switch then you must build all
35481 modules with the same value, including any libraries. This includes
35482 the system libraries and startup modules.
35483
35484 @opindex mvect8-ret-in-mem
35485 @item -mvect8-ret-in-mem
35486 Return 8-byte vectors in memory instead of MMX registers. This is the
35487 default on VxWorks to match the ABI of the Sun Studio compilers until
35488 version 12. @emph{Only} use this option if you need to remain
35489 compatible with existing code produced by those previous compiler
35490 versions or older versions of GCC@.
35491
35492 @opindex mpc32
35493 @opindex mpc64
35494 @opindex mpc80
35495 @item -mpc32
35496 @itemx -mpc64
35497 @itemx -mpc80
35498
35499 Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
35500 is specified, the significands of results of floating-point operations are
35501 rounded to 24 bits (single precision); @option{-mpc64} rounds the
35502 significands of results of floating-point operations to 53 bits (double
35503 precision) and @option{-mpc80} rounds the significands of results of
35504 floating-point operations to 64 bits (extended double precision), which is
35505 the default. When this option is used, floating-point operations in higher
35506 precisions are not available to the programmer without setting the FPU
35507 control word explicitly.
35508
35509 Setting the rounding of floating-point operations to less than the default
35510 80 bits can speed some programs by 2% or more. Note that some mathematical
35511 libraries assume that extended-precision (80-bit) floating-point operations
35512 are enabled by default; routines in such libraries could suffer significant
35513 loss of accuracy, typically through so-called ``catastrophic cancellation'',
35514 when this option is used to set the precision to less than extended precision.
35515
35516 @opindex mdaz-ftz
35517 @item -mdaz-ftz
35518
35519 The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
35520 are used to control floating-point calculations.SSE and AVX instructions
35521 including scalar and vector instructions could benefit from enabling the FTZ
35522 and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
35523 when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
35524 will set FTZ/DAZ flags even with @option{-shared}.
35525
35526 @opindex mstackrealign
35527 @item -mstackrealign
35528 Realign the stack at entry. On the x86, the @option{-mstackrealign}
35529 option generates an alternate prologue and epilogue that realigns the
35530 run-time stack if necessary. This supports mixing legacy codes that keep
35531 4-byte stack alignment with modern codes that keep 16-byte stack alignment for
35532 SSE compatibility. See also the attribute @code{force_align_arg_pointer},
35533 applicable to individual functions.
35534
35535 @opindex mpreferred-stack-boundary
35536 @item -mpreferred-stack-boundary=@var{num}
35537 Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
35538 byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
35539 the default is 4 (16 bytes or 128 bits).
35540
35541 @strong{Warning:} When generating code for the x86-64 architecture with
35542 SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
35543 used to keep the stack boundary aligned to 8 byte boundary. Since
35544 x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
35545 intended to be used in controlled environment where stack space is
35546 important limitation. This option leads to wrong code when functions
35547 compiled with 16 byte stack alignment (such as functions from a standard
35548 library) are called with misaligned stack. In this case, SSE
35549 instructions may lead to misaligned memory access traps. In addition,
35550 variable arguments are handled incorrectly for 16 byte aligned
35551 objects (including x87 long double and __int128), leading to wrong
35552 results. You must build all modules with
35553 @option{-mpreferred-stack-boundary=3}, including any libraries. This
35554 includes the system libraries and startup modules.
35555
35556 @opindex mincoming-stack-boundary
35557 @item -mincoming-stack-boundary=@var{num}
35558 Assume the incoming stack is aligned to a 2 raised to @var{num} byte
35559 boundary. If @option{-mincoming-stack-boundary} is not specified,
35560 the one specified by @option{-mpreferred-stack-boundary} is used.
35561
35562 On Pentium and Pentium Pro, @code{double} and @code{long double} values
35563 should be aligned to an 8-byte boundary (see @option{-malign-double}) or
35564 suffer significant run time performance penalties. On Pentium III, the
35565 Streaming SIMD Extension (SSE) data type @code{__m128} may not work
35566 properly if it is not 16-byte aligned.
35567
35568 To ensure proper alignment of this values on the stack, the stack boundary
35569 must be as aligned as that required by any value stored on the stack.
35570 Further, every function must be generated such that it keeps the stack
35571 aligned. Thus calling a function compiled with a higher preferred
35572 stack boundary from a function compiled with a lower preferred stack
35573 boundary most likely misaligns the stack. It is recommended that
35574 libraries that use callbacks always use the default setting.
35575
35576 This extra alignment does consume extra stack space, and generally
35577 increases code size. Code that is sensitive to stack space usage, such
35578 as embedded systems and operating system kernels, may want to reduce the
35579 preferred alignment to @option{-mpreferred-stack-boundary=2}.
35580
35581 @need 200
35582 @opindex mmmx
35583 @item -mmmx
35584 @need 200
35585 @opindex msse
35586 @itemx -msse
35587 @need 200
35588 @opindex msse2
35589 @itemx -msse2
35590 @need 200
35591 @opindex msse3
35592 @itemx -msse3
35593 @need 200
35594 @opindex mssse3
35595 @itemx -mssse3
35596 @need 200
35597 @opindex msse4
35598 @itemx -msse4
35599 @need 200
35600 @opindex msse4a
35601 @itemx -msse4a
35602 @need 200
35603 @opindex msse4.1
35604 @itemx -msse4.1
35605 @need 200
35606 @opindex msse4.2
35607 @itemx -msse4.2
35608 @need 200
35609 @opindex mavx
35610 @itemx -mavx
35611 @need 200
35612 @opindex mavx2
35613 @itemx -mavx2
35614 @need 200
35615 @opindex mavx512f
35616 @itemx -mavx512f
35617 @need 200
35618 @opindex mavx512cd
35619 @itemx -mavx512cd
35620 @need 200
35621 @opindex mavx512vl
35622 @itemx -mavx512vl
35623 @need 200
35624 @opindex mavx512bw
35625 @itemx -mavx512bw
35626 @need 200
35627 @opindex mavx512dq
35628 @itemx -mavx512dq
35629 @need 200
35630 @opindex mavx512ifma
35631 @itemx -mavx512ifma
35632 @need 200
35633 @opindex mavx512vbmi
35634 @itemx -mavx512vbmi
35635 @need 200
35636 @opindex msha
35637 @itemx -msha
35638 @need 200
35639 @opindex maes
35640 @itemx -maes
35641 @need 200
35642 @opindex mpclmul
35643 @itemx -mpclmul
35644 @need 200
35645 @opindex mclflushopt
35646 @itemx -mclflushopt
35647 @need 200
35648 @opindex mclwb
35649 @itemx -mclwb
35650 @need 200
35651 @opindex mfsgsbase
35652 @itemx -mfsgsbase
35653 @need 200
35654 @opindex mptwrite
35655 @itemx -mptwrite
35656 @need 200
35657 @opindex mrdrnd
35658 @itemx -mrdrnd
35659 @need 200
35660 @opindex mf16c
35661 @itemx -mf16c
35662 @need 200
35663 @opindex mfma
35664 @itemx -mfma
35665 @need 200
35666 @opindex mpconfig
35667 @itemx -mpconfig
35668 @need 200
35669 @opindex mwbnoinvd
35670 @itemx -mwbnoinvd
35671 @need 200
35672 @opindex mfma4
35673 @itemx -mfma4
35674 @need 200
35675 @opindex mprfchw
35676 @itemx -mprfchw
35677 @need 200
35678 @opindex mrdpid
35679 @itemx -mrdpid
35680 @need 200
35681 @opindex mrdseed
35682 @itemx -mrdseed
35683 @need 200
35684 @opindex msgx
35685 @itemx -msgx
35686 @need 200
35687 @opindex mxop
35688 @itemx -mxop
35689 @need 200
35690 @opindex mlwp
35691 @itemx -mlwp
35692 @need 200
35693 @opindex m3dnow
35694 @itemx -m3dnow
35695 @need 200
35696 @opindex m3dnowa
35697 @itemx -m3dnowa
35698 @need 200
35699 @opindex mpopcnt
35700 @itemx -mpopcnt
35701 @need 200
35702 @opindex mabm
35703 @itemx -mabm
35704 @need 200
35705 @opindex madx
35706 @itemx -madx
35707 @need 200
35708 @opindex mbmi
35709 @itemx -mbmi
35710 @need 200
35711 @opindex mbmi2
35712 @itemx -mbmi2
35713 @need 200
35714 @opindex mlzcnt
35715 @itemx -mlzcnt
35716 @need 200
35717 @opindex mfxsr
35718 @itemx -mfxsr
35719 @need 200
35720 @opindex mxsave
35721 @itemx -mxsave
35722 @need 200
35723 @opindex mxsaveopt
35724 @itemx -mxsaveopt
35725 @need 200
35726 @opindex mxsavec
35727 @itemx -mxsavec
35728 @need 200
35729 @opindex mxsaves
35730 @itemx -mxsaves
35731 @need 200
35732 @opindex mrtm
35733 @itemx -mrtm
35734 @need 200
35735 @opindex mhle
35736 @itemx -mhle
35737 @need 200
35738 @opindex mtbm
35739 @itemx -mtbm
35740 @need 200
35741 @opindex mmwaitx
35742 @itemx -mmwaitx
35743 @need 200
35744 @opindex mclzero
35745 @itemx -mclzero
35746 @need 200
35747 @opindex mpku
35748 @itemx -mpku
35749 @need 200
35750 @opindex mavx512vbmi2
35751 @itemx -mavx512vbmi2
35752 @need 200
35753 @opindex mavx512bf16
35754 @itemx -mavx512bf16
35755 @need 200
35756 @opindex mavx512fp16
35757 @itemx -mavx512fp16
35758 @need 200
35759 @opindex mgfni
35760 @itemx -mgfni
35761 @need 200
35762 @opindex mvaes
35763 @itemx -mvaes
35764 @need 200
35765 @opindex mwaitpkg
35766 @itemx -mwaitpkg
35767 @need 200
35768 @opindex mvpclmulqdq
35769 @itemx -mvpclmulqdq
35770 @need 200
35771 @opindex mavx512bitalg
35772 @itemx -mavx512bitalg
35773 @need 200
35774 @opindex mmovdiri
35775 @itemx -mmovdiri
35776 @need 200
35777 @opindex mmovdir64b
35778 @itemx -mmovdir64b
35779 @need 200
35780 @opindex menqcmd
35781 @opindex muintr
35782 @itemx -menqcmd
35783 @itemx -muintr
35784 @need 200
35785 @opindex mtsxldtrk
35786 @itemx -mtsxldtrk
35787 @need 200
35788 @opindex mavx512vpopcntdq
35789 @itemx -mavx512vpopcntdq
35790 @need 200
35791 @opindex mavx512vp2intersect
35792 @itemx -mavx512vp2intersect
35793 @need 200
35794 @opindex mavx512vnni
35795 @itemx -mavx512vnni
35796 @need 200
35797 @opindex mavxvnni
35798 @itemx -mavxvnni
35799 @need 200
35800 @opindex mcldemote
35801 @itemx -mcldemote
35802 @need 200
35803 @opindex mserialize
35804 @itemx -mserialize
35805 @need 200
35806 @opindex mamx-tile
35807 @itemx -mamx-tile
35808 @need 200
35809 @opindex mamx-int8
35810 @itemx -mamx-int8
35811 @need 200
35812 @opindex mamx-bf16
35813 @itemx -mamx-bf16
35814 @need 200
35815 @opindex mhreset
35816 @opindex mkl
35817 @itemx -mhreset
35818 @itemx -mkl
35819 @need 200
35820 @opindex mwidekl
35821 @itemx -mwidekl
35822 @need 200
35823 @opindex mavxifma
35824 @itemx -mavxifma
35825 @need 200
35826 @opindex mavxvnniint8
35827 @itemx -mavxvnniint8
35828 @need 200
35829 @opindex mavxneconvert
35830 @itemx -mavxneconvert
35831 @need 200
35832 @opindex mcmpccxadd
35833 @itemx -mcmpccxadd
35834 @need 200
35835 @opindex mamx-fp16
35836 @itemx -mamx-fp16
35837 @need 200
35838 @opindex mprefetchi
35839 @itemx -mprefetchi
35840 @need 200
35841 @opindex mraoint
35842 @itemx -mraoint
35843 @need 200
35844 @opindex mamx-complex
35845 @itemx -mamx-complex
35846 @need 200
35847 @opindex mavxvnniint16
35848 @itemx -mavxvnniint16
35849 @need 200
35850 @opindex msm3
35851 @itemx -msm3
35852 @need 200
35853 @opindex msha512
35854 @itemx -msha512
35855 @need 200
35856 @opindex msm4
35857 @itemx -msm4
35858 @need 200
35859 @opindex mapxf
35860 @itemx -mapxf
35861 @need 200
35862 @opindex musermsr
35863 @itemx -musermsr
35864 @need 200
35865 @opindex mavx10.1
35866 @itemx -mavx10.1
35867 @need 200
35868 @opindex mavx10.2
35869 @itemx -mavx10.2
35870 @need 200
35871 @opindex mamx-avx512
35872 @itemx -mamx-avx512
35873 @need 200
35874 @opindex mamx-tf32
35875 @itemx -mamx-tf32
35876 @need 200
35877 @opindex mamx-transpose
35878 @itemx -mamx-transpose
35879 @need 200
35880 @itemx -mamx-fp8
35881 @opindex mamx-fp8
35882 @need 200
35883 @opindex mmovrs
35884 @itemx -mmovrs
35885 @need 200
35886 @opindex mamx-movrs
35887 @itemx -mamx-movrs
35888 These switches enable the use of instructions in the MMX, SSE,
35889 AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA, AES,
35890 PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
35891 WBNOINVD, FMA4, PREFETCHW, RDPID, RDSEED, SGX, XOP, LWP, 3DNow!@:,
35892 enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE, XSAVEOPT,
35893 XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2, GFNI, VAES,
35894 WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16, ENQCMD,
35895 AVX512VPOPCNTDQ, AVX512VNNI, SERIALIZE, UINTR, HRESET, AMXTILE, AMXINT8,
35896 AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16, AVXIFMA, AVXVNNIINT8, AVXNECONVERT,
35897 CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT, AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512,
35898 SM4, APX_F, USER_MSR, AVX10.1, AVX10.2, AMX-AVX512, AMX-TF32, AMX-TRANSPOSE,
35899 AMX-FP8, MOVRS, AMX-MOVRS or CLDEMOTE extended instruction sets. Each has a
35900 corresponding @option{-mno-} option to disable use of these instructions.
35901
35902 These extensions are also available as built-in functions: see
35903 @ref{x86 Built-in Functions}, for details of the functions enabled and
35904 disabled by these switches.
35905
35906 Note that @option{-msse4} enables both SSE4.1 and SSE4.2 support,
35907 while @option{-mno-sse4} turns off those features; neither form of the
35908 option affects SSE4A support, controlled separately by
35909 @option{-msse4a}.
35910
35911 To generate SSE/SSE2 instructions automatically from floating-point
35912 code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
35913
35914 GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
35915 generates new AVX instructions or AVX equivalence for all SSEx instructions
35916 when needed.
35917
35918 These options enable GCC to use these extended instructions in
35919 generated code, even without @option{-mfpmath=sse}. Applications that
35920 perform run-time CPU detection must compile separate files for each
35921 supported architecture, using the appropriate flags. In particular,
35922 the file containing the CPU detection code should be compiled without
35923 these options.
35924
35925 @opindex mdump-tune-features
35926 @item -mdump-tune-features
35927 This option instructs GCC to dump the names of the x86 performance
35928 tuning features and default settings. The names can be used in
35929 @option{-mtune-ctrl=@var{feature-list}}.
35930
35931 @opindex mtune-ctrl=@var{feature-list}
35932 @item -mtune-ctrl=@var{feature-list}
35933 This option is used to do fine grain control of x86 code generation features.
35934 @var{feature-list} is a comma separated list of @var{feature} names. See also
35935 @option{-mdump-tune-features}. When specified, the @var{feature} is turned
35936 on if it is not preceded with @samp{^}, otherwise, it is turned off.
35937 @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
35938 developers. Using it may lead to code paths not covered by testing and can
35939 potentially result in compiler ICEs or runtime errors.
35940
35941 @opindex mno-default
35942 @item -mno-default
35943 This option instructs GCC to turn off all tunable features. See also
35944 @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
35945
35946 @opindex mcld
35947 @item -mcld
35948 This option instructs GCC to emit a @code{cld} instruction in the prologue
35949 of functions that use string instructions. String instructions depend on
35950 the DF flag to select between autoincrement or autodecrement mode. While the
35951 ABI specifies the DF flag to be cleared on function entry, some operating
35952 systems violate this specification by not clearing the DF flag in their
35953 exception dispatchers. The exception handler can be invoked with the DF flag
35954 set, which leads to wrong direction mode when string instructions are used.
35955 This option can be enabled by default on 32-bit x86 targets by configuring
35956 GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
35957 instructions can be suppressed with the @option{-mno-cld} compiler option
35958 in this case.
35959
35960 @opindex mvzeroupper
35961 @item -mvzeroupper
35962 This option instructs GCC to emit a @code{vzeroupper} instruction
35963 before a transfer of control flow out of the function to minimize
35964 the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
35965 intrinsics.
35966
35967 @opindex mprefer-avx128
35968 @item -mprefer-avx128
35969 This option instructs GCC to use 128-bit AVX instructions instead of
35970 256-bit AVX instructions in the auto-vectorizer.
35971
35972 @opindex mprefer-vector-width
35973 @item -mprefer-vector-width=@var{opt}
35974 This option instructs GCC to use @var{opt}-bit vector width in instructions
35975 instead of default on the selected platform.
35976
35977 @opindex mpartial-vector-fp-math
35978 @item -mpartial-vector-fp-math
35979 This option enables GCC to generate floating-point operations that might
35980 affect the set of floating-point status flags on partial vectors, where
35981 vector elements reside in the low part of the 128-bit SSE register. Unless
35982 @option{-fno-trapping-math} is specified, the compiler guarantees correct
35983 behavior by sanitizing all input operands to have zeroes in the unused
35984 upper part of the vector register. Note that by using built-in functions
35985 or inline assembly with partial vector arguments, NaNs, denormal or invalid
35986 values can leak into the upper part of the vector, causing possible
35987 performance issues when @option{-fno-trapping-math} is in effect. These
35988 issues can be mitigated by manually sanitizing the upper part of the partial
35989 vector argument register or by using @option{-mdaz-ftz} to set
35990 denormals-are-zero (DAZ) flag in the MXCSR register.
35991
35992 This option is enabled by default.
35993
35994 @opindex mmove-max
35995 @item -mmove-max=@var{bits}
35996 This option instructs GCC to set the maximum number of bits can be
35997 moved from memory to memory efficiently to @var{bits}. The valid
35998 @var{bits} are 128, 256 and 512.
35999
36000 @opindex mstore-max
36001 @item -mstore-max=@var{bits}
36002 This option instructs GCC to set the maximum number of bits can be
36003 stored to memory efficiently to @var{bits}. The valid @var{bits} are
36004 128, 256 and 512.
36005
36006 @table @samp
36007 @item none
36008 No extra limitations applied to GCC other than defined by the selected platform.
36009
36010 @item 128
36011 Prefer 128-bit vector width for instructions.
36012
36013 @item 256
36014 Prefer 256-bit vector width for instructions.
36015
36016 @item 512
36017 Prefer 512-bit vector width for instructions.
36018 @end table
36019
36020 @opindex mnoreturn-no-callee-saved-registers
36021 @item -mnoreturn-no-callee-saved-registers
36022 This option optimizes functions with @code{noreturn} attribute or
36023 @code{_Noreturn} specifier by not saving in the function prologue callee-saved
36024 registers which are used in the function (except for the @code{BP}
36025 register). This option can interfere with debugging of the caller of the
36026 @code{noreturn} function or any function further up in the call stack, so it
36027 is not enabled by default.
36028
36029 @opindex mcx16
36030 @item -mcx16
36031 This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
36032 code to implement compare-and-exchange operations on 16-byte aligned 128-bit
36033 objects. This is useful for atomic updates of data structures exceeding one
36034 machine word in size. The compiler uses this instruction to implement
36035 @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
36036 128-bit integers, a library call is always used.
36037
36038 @opindex msahf
36039 @item -msahf
36040 This option enables generation of @code{SAHF} instructions in 64-bit code.
36041 Early Intel Pentium 4 CPUs with Intel 64 support,
36042 prior to the introduction of Pentium 4 G1 step in December 2005,
36043 lacked the @code{LAHF} and @code{SAHF} instructions
36044 which are supported by AMD64.
36045 These are load and store instructions, respectively, for certain status flags.
36046 In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
36047 @code{drem}, and @code{remainder} built-in functions;
36048 see @ref{Other Builtins} for details.
36049
36050 @opindex mmovbe
36051 @item -mmovbe
36052 This option enables use of the @code{movbe} instruction to optimize
36053 byte swapping of four and eight byte entities.
36054
36055 @opindex mshstk
36056 @item -mshstk
36057 The @option{-mshstk} option enables shadow stack built-in functions
36058 from x86 Control-flow Enforcement Technology (CET).
36059
36060 @opindex mcrc32
36061 @item -mcrc32
36062 This option enables built-in functions @code{__builtin_ia32_crc32qi},
36063 @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
36064 @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
36065
36066 @opindex mmwait
36067 @item -mmwait
36068 This option enables built-in functions @code{__builtin_ia32_monitor},
36069 and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
36070 @code{mwait} machine instructions.
36071
36072 @opindex mrecip
36073 @item -mrecip
36074 This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
36075 (and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
36076 with an additional Newton-Raphson step
36077 to increase precision instead of @code{DIVSS} and @code{SQRTSS}
36078 (and their vectorized
36079 variants) for single-precision floating-point arguments. These instructions
36080 are generated only when @option{-funsafe-math-optimizations} is enabled
36081 together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
36082 Note that while the throughput of the sequence is higher than the throughput
36083 of the non-reciprocal instruction, the precision of the sequence can be
36084 decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
36085
36086 Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
36087 (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
36088 combination), and doesn't need @option{-mrecip}.
36089
36090 Also note that GCC emits the above sequence with additional Newton-Raphson step
36091 for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
36092 already with @option{-ffast-math} (or the above option combination), and
36093 doesn't need @option{-mrecip}.
36094
36095 @opindex mrecip=opt
36096 @item -mrecip=@var{opt}
36097 This option controls which reciprocal estimate instructions
36098 may be used. @var{opt} is a comma-separated list of options, which may
36099 be preceded by a @samp{!} to invert the option:
36100
36101 @table @samp
36102 @item all
36103 Enable all estimate instructions.
36104
36105 @item default
36106 Enable the default instructions, equivalent to @option{-mrecip}.
36107
36108 @item none
36109 Disable all estimate instructions, equivalent to @option{-mno-recip}.
36110
36111 @item div
36112 Enable the approximation for scalar division.
36113
36114 @item vec-div
36115 Enable the approximation for vectorized division.
36116
36117 @item sqrt
36118 Enable the approximation for scalar square root.
36119
36120 @item vec-sqrt
36121 Enable the approximation for vectorized square root.
36122 @end table
36123
36124 So, for example, @option{-mrecip=all,!sqrt} enables
36125 all of the reciprocal approximations, except for square root.
36126
36127 @opindex mveclibabi
36128 @item -mveclibabi=@var{type}
36129 Specifies the ABI type to use for vectorizing intrinsics using an external
36130 library. Supported values for @var{type} are @samp{svml} for the Intel short
36131 vector math library, @samp{aocl} for the math library (LibM) from AMD
36132 Optimizing CPU Libraries (AOCL) and @samp{acml} for the end-of-life AMD core
36133 math library (to which AOCL-LibM is the successor).
36134 To use this option, both @option{-ftree-vectorize} and
36135 @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
36136 ABI-compatible library must be specified at link time.
36137
36138 GCC currently emits calls to @code{vmldExp2}, @code{vmldLn2},
36139 @code{vmldLog102}, @code{vmldPow2}, @code{vmldTanh2}, @code{vmldTan2},
36140 @code{vmldAtan2}, @code{vmldAtanh2}, @code{vmldCbrt2}, @code{vmldSinh2},
36141 @code{vmldSin2}, @code{vmldAsinh2}, @code{vmldAsin2}, @code{vmldCosh2},
36142 @code{vmldCos2}, @code{vmldAcosh2}, @code{vmldAcos2}, @code{vmlsExp4},
36143 @code{vmlsLn4}, @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4},
36144 @code{vmlsTan4}, @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4},
36145 @code{vmlsSinh4}, @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4},
36146 @code{vmlsCosh4}, @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for
36147 corresponding function type when @option{-mveclibabi=svml} is used,
36148 @code{amd_vrs4_acosf}, @code{amd_vrs16_acosf}, @code{amd_vrd8_asin},
36149 @code{amd_vrs4_asinf}, @code{amd_vrs8_asinf}, @code{amd_vrs16_asinf},
36150 @code{amd_vrd2_atan}, @code{amd_vrd8_atan}, @code{amd_vrs4_atanf},
36151 @code{amd_vrs8_atanf}, @code{amd_vrs16_atanf}, @code{amd_vrd2_cos},
36152 @code{amd_vrd4_cos}, @code{amd_vrd8_cos}, @code{amd_vrs4_cosf},
36153 @code{amd_vrs8_cosf}, @code{amd_vrs16_cosf}, @code{amd_vrs4_coshf},
36154 @code{amd_vrs8_coshf}, @code{amd_vrd2_erf}, @code{amd_vrd4_erf},
36155 @code{amd_vrd8_erf}, @code{amd_vrs4_erff}, @code{amd_vrs8_erff},
36156 @code{amd_vrs16_erff}, @code{amd_vrd2_exp}, @code{amd_vrd4_exp},
36157 @code{amd_vrd8_exp}, @code{amd_vrs4_expf}, @code{amd_vrs8_expf},
36158 @code{amd_vrs16_expf}, @code{amd_vrd2_exp10}, @code{amd_vrs4_exp10f},
36159 @code{amd_vrd2_exp2}, @code{amd_vrd4_exp2}, @code{amd_vrd8_exp2},
36160 @code{amd_vrs4_exp2f}, @code{amd_vrs8_exp2f}, @code{amd_vrs16_exp2f},
36161 @code{amd_vrs4_expm1f}, @code{amd_vrd2_log}, @code{amd_vrd4_log},
36162 @code{amd_vrd8_log}, @code{amd_vrs4_logf}, @code{amd_vrs8_logf},
36163 @code{amd_vrs16_logf}, @code{amd_vrd2_log10}, @code{amd_vrs4_log10f},
36164 @code{amd_vrs8_log10f}, @code{amd_vrs16_log10f}, @code{amd_vrd2_log1p},
36165 @code{amd_vrs4_log1pf}, @code{amd_vrd2_log2}, @code{amd_vrd4_log2},
36166 @code{amd_vrd8_log2}, @code{amd_vrs4_log2f}, @code{amd_vrs8_log2f},
36167 @code{amd_vrs16_log2f}, @code{amd_vrd2_pow}, @code{amd_vrd4_pow},
36168 @code{amd_vrd8_pow}, @code{amd_vrs4_powf}, @code{amd_vrs8_powf},
36169 @code{amd_vrs16_powf}, @code{amd_vrd2_sin}, @code{amd_vrd4_sin},
36170 @code{amd_vrd8_sin}, @code{amd_vrs4_sinf}, @code{amd_vrs8_sinf},
36171 @code{amd_vrs16_sinf}, @code{amd_vrd2_tan}, @code{amd_vrd4_tan},
36172 @code{amd_vrd8_tan}, @code{amd_vrs16_tanf}, @code{amd_vrs4_tanhf},
36173 @code{amd_vrs8_tanhf}, @code{amd_vrs16_tanhf} for the corresponding function
36174 type when @option{-mveclibabi=aocl} is used, and @code{__vrd2_sin},
36175 @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
36176 @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
36177 @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
36178 @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
36179 when @option{-mveclibabi=acml} is used.
36180
36181 @opindex mabi
36182 @item -mabi=@var{name}
36183 Generate code for the specified calling convention. Permissible values
36184 are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
36185 @samp{ms} for the Microsoft ABI. The default is to use the Microsoft
36186 ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
36187 You can control this behavior for specific functions by
36188 using the function attributes @code{ms_abi} and @code{sysv_abi}.
36189 @xref{Function Attributes}.
36190
36191 @opindex mforce-indirect-call
36192 @item -mforce-indirect-call
36193 Force all calls to functions to be indirect. This is useful
36194 when using Intel Processor Trace where it generates more precise timing
36195 information for function calls.
36196
36197 @opindex mmanual-endbr
36198 @item -mmanual-endbr
36199 Insert ENDBR instruction at function entry only via the @code{cf_check}
36200 function attribute. This is useful when used with the option
36201 @option{-fcf-protection=branch} to control ENDBR insertion at the
36202 function entry.
36203
36204 @opindex mcet-switch
36205 @item -mcet-switch
36206 By default, CET instrumentation is turned off on switch statements that
36207 use a jump table and indirect branch track is disabled. Since jump
36208 tables are stored in read-only memory, this does not result in a direct
36209 loss of hardening. But if the jump table index is attacker-controlled,
36210 the indirect jump may not be constrained by CET. This option turns on
36211 CET instrumentation to enable indirect branch track for switch statements
36212 with jump tables which leads to the jump targets reachable via any indirect
36213 jumps.
36214
36215 @opindex mcall-ms2sysv-xlogues
36216 @opindex mno-call-ms2sysv-xlogues
36217 @item -mcall-ms2sysv-xlogues
36218 Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
36219 System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
36220 default, the code for saving and restoring these registers is emitted inline,
36221 resulting in fairly lengthy prologues and epilogues. Using
36222 @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
36223 use stubs in the static portion of libgcc to perform these saves and restores,
36224 thus reducing function size at the cost of a few extra instructions.
36225
36226 @opindex mtls-dialect
36227 @item -mtls-dialect=@var{type}
36228 Generate code to access thread-local storage using the @samp{gnu} or
36229 @samp{gnu2} conventions. @samp{gnu} is the conservative default;
36230 @samp{gnu2} is more efficient, but it may add compile- and run-time
36231 requirements that cannot be satisfied on all systems.
36232
36233 @opindex mpush-args
36234 @opindex mno-push-args
36235 @item -mpush-args
36236 @itemx -mno-push-args
36237 Use PUSH operations to store outgoing parameters. This method is shorter
36238 and usually equally fast as method using SUB/MOV operations and is enabled
36239 by default. In some cases disabling it may improve performance because of
36240 improved scheduling and reduced dependencies.
36241
36242 @opindex maccumulate-outgoing-args
36243 @item -maccumulate-outgoing-args
36244 If enabled, the maximum amount of space required for outgoing arguments is
36245 computed in the function prologue. This is faster on most modern CPUs
36246 because of reduced dependencies, improved scheduling and reduced stack usage
36247 when the preferred stack boundary is not equal to 2. The drawback is a notable
36248 increase in code size. This switch implies @option{-mno-push-args}.
36249
36250 @opindex mthreads
36251 @item -mthreads
36252 Support thread-safe exception handling on MinGW. Programs that rely
36253 on thread-safe exception handling must compile and link all code with the
36254 @option{-mthreads} option. When compiling, @option{-mthreads} defines
36255 @option{-D_MT}; when linking, it links in a special thread helper library
36256 @option{-lmingwthrd} which cleans up per-thread exception-handling data.
36257
36258 @opindex mms-bitfields
36259 @opindex mno-ms-bitfields
36260 @item -mms-bitfields
36261 @itemx -mno-ms-bitfields
36262
36263 Enable/disable bit-field layout compatible with the native Microsoft
36264 Windows compiler.
36265
36266 If @code{packed} is used on a structure, or if bit-fields are used,
36267 it may be that the Microsoft ABI lays out the structure differently
36268 than the way GCC normally does. Particularly when moving packed
36269 data between functions compiled with GCC and the native Microsoft compiler
36270 (either via function call or as data in a file), it may be necessary to access
36271 either format.
36272
36273 This option is enabled by default for Microsoft Windows
36274 targets. This behavior can also be controlled locally by use of variable
36275 or type attributes. For more information, see @ref{x86 Variable Attributes}
36276 and @ref{x86 Type Attributes}.
36277
36278 The Microsoft structure layout algorithm is fairly simple with the exception
36279 of the bit-field packing.
36280 The padding and alignment of members of structures and whether a bit-field
36281 can straddle a storage-unit boundary are determine by these rules:
36282
36283 @enumerate
36284 @item Structure members are stored sequentially in the order in which they are
36285 declared: the first member has the lowest memory address and the last member
36286 the highest.
36287
36288 @item Every data object has an alignment requirement. The alignment requirement
36289 for all data except structures, unions, and arrays is either the size of the
36290 object or the current packing size (specified with either the
36291 @code{aligned} attribute or the @code{pack} pragma),
36292 whichever is less. For structures, unions, and arrays,
36293 the alignment requirement is the largest alignment requirement of its members.
36294 Every object is allocated an offset so that:
36295
36296 @smallexample
36297 offset % alignment_requirement == 0
36298 @end smallexample
36299
36300 @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
36301 unit if the integral types are the same size and if the next bit-field fits
36302 into the current allocation unit without crossing the boundary imposed by the
36303 common alignment requirements of the bit-fields.
36304 @end enumerate
36305
36306 MSVC interprets zero-length bit-fields in the following ways:
36307
36308 @enumerate
36309 @item If a zero-length bit-field is inserted between two bit-fields that
36310 are normally coalesced, the bit-fields are not coalesced.
36311
36312 For example:
36313
36314 @smallexample
36315 struct
36316 @{
36317 unsigned long bf_1 : 12;
36318 unsigned long : 0;
36319 unsigned long bf_2 : 12;
36320 @} t1;
36321 @end smallexample
36322
36323 @noindent
36324 The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
36325 zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
36326
36327 @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
36328 alignment of the zero-length bit-field is greater than the member that follows it,
36329 @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
36330
36331 For example:
36332
36333 @smallexample
36334 struct
36335 @{
36336 char foo : 4;
36337 short : 0;
36338 char bar;
36339 @} t2;
36340
36341 struct
36342 @{
36343 char foo : 4;
36344 short : 0;
36345 double bar;
36346 @} t3;
36347 @end smallexample
36348
36349 @noindent
36350 For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
36351 Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
36352 bit-field does not affect the alignment of @code{bar} or, as a result, the size
36353 of the structure.
36354
36355 Taking this into account, it is important to note the following:
36356
36357 @enumerate
36358 @item If a zero-length bit-field follows a normal bit-field, the type of the
36359 zero-length bit-field may affect the alignment of the structure as whole. For
36360 example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
36361 normal bit-field, and is of type short.
36362
36363 @item Even if a zero-length bit-field is not followed by a normal bit-field, it may
36364 still affect the alignment of the structure:
36365
36366 @smallexample
36367 struct
36368 @{
36369 char foo : 6;
36370 long : 0;
36371 @} t4;
36372 @end smallexample
36373
36374 @noindent
36375 Here, @code{t4} takes up 4 bytes.
36376 @end enumerate
36377
36378 @item Zero-length bit-fields following non-bit-field members are ignored:
36379
36380 @smallexample
36381 struct
36382 @{
36383 char foo;
36384 long : 0;
36385 char bar;
36386 @} t5;
36387 @end smallexample
36388
36389 @noindent
36390 Here, @code{t5} takes up 2 bytes.
36391 @end enumerate
36392
36393
36394 @opindex mno-align-stringops
36395 @opindex malign-stringops
36396 @item -mno-align-stringops
36397 Do not align the destination of inlined string operations. This switch reduces
36398 code size and improves performance in case the destination is already aligned,
36399 but GCC doesn't know about it.
36400
36401 @opindex minline-all-stringops
36402 @item -minline-all-stringops
36403 By default GCC inlines string operations only when the destination is
36404 known to be aligned to least a 4-byte boundary.
36405 This enables more inlining and increases code
36406 size, but may improve performance of code that depends on fast
36407 @code{memcpy} and @code{memset} for short lengths.
36408 The option enables inline expansion of @code{strlen} for all
36409 pointer alignments.
36410
36411 @opindex minline-stringops-dynamically
36412 @item -minline-stringops-dynamically
36413 For string operations of unknown size, use run-time checks with
36414 inline code for small blocks and a library call for large blocks.
36415
36416 @opindex mstringop-strategy=@var{alg}
36417 @item -mstringop-strategy=@var{alg}
36418 Override the internal decision heuristic for the particular algorithm to use
36419 for inlining string operations. The allowed values for @var{alg} are:
36420
36421 @table @samp
36422 @item rep_byte
36423 @itemx rep_4byte
36424 @itemx rep_8byte
36425 Expand using i386 @code{rep} prefix of the specified size.
36426
36427 @item byte_loop
36428 @itemx loop
36429 @itemx unrolled_loop
36430 Expand into an inline loop.
36431
36432 @item libcall
36433 Always use a library call.
36434 @end table
36435
36436 @opindex mmemcpy-strategy=@var{strategy}
36437 @item -mmemcpy-strategy=@var{strategy}
36438 Override the internal decision heuristic to decide if @code{__builtin_memcpy}
36439 should be inlined and what inline algorithm to use when the expected size
36440 of the copy operation is known. @var{strategy}
36441 is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
36442 @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
36443 the max byte size with which inline algorithm @var{alg} is allowed. For the last
36444 triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
36445 in the list must be specified in increasing order. The minimal byte size for
36446 @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
36447 preceding range.
36448
36449 @opindex mmemset-strategy=@var{strategy}
36450 @item -mmemset-strategy=@var{strategy}
36451 The option is similar to @option{-mmemcpy-strategy=} except that it is to control
36452 @code{__builtin_memset} expansion.
36453
36454 @opindex momit-leaf-frame-pointer
36455 @item -momit-leaf-frame-pointer
36456 Don't keep the frame pointer in a register for leaf functions. This
36457 avoids the instructions to save, set up, and restore frame pointers and
36458 makes an extra register available in leaf functions. The option
36459 @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
36460 which might make debugging harder.
36461
36462 @opindex mtls-direct-seg-refs
36463 @item -mtls-direct-seg-refs
36464 @itemx -mno-tls-direct-seg-refs
36465 Controls whether TLS variables may be accessed with offsets from the
36466 TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
36467 or whether the thread base pointer must be added. Whether or not this
36468 is valid depends on the operating system, and whether it maps the
36469 segment to cover the entire TLS area.
36470
36471 For systems that use the GNU C Library, the default is on.
36472
36473 @opindex msse2avx
36474 @item -msse2avx
36475 @itemx -mno-sse2avx
36476 Specify that the assembler should encode SSE instructions with VEX
36477 prefix. The option @option{-mavx} turns this on by default.
36478
36479 @opindex mfentry
36480 @item -mfentry
36481 @itemx -mno-fentry
36482 If profiling is active (@option{-pg}), put the profiling
36483 counter call before the prologue.
36484 Note: On x86 architectures the attribute @code{ms_hook_prologue}
36485 isn't possible at the moment for @option{-mfentry} and @option{-pg}.
36486
36487 @opindex mrecord-mcount
36488 @item -mrecord-mcount
36489 @itemx -mno-record-mcount
36490 If profiling is active (@option{-pg}), generate a __mcount_loc section
36491 that contains pointers to each profiling call. This is useful for
36492 automatically patching and out calls.
36493
36494 @opindex mnop-mcount
36495 @item -mnop-mcount
36496 @itemx -mno-nop-mcount
36497 If profiling is active (@option{-pg}), generate the calls to
36498 the profiling functions as NOPs. This is useful when they
36499 should be patched in later dynamically. This is likely only
36500 useful together with @option{-mrecord-mcount}.
36501
36502 @opindex minstrument-return
36503 @item -minstrument-return=@var{type}
36504 Instrument function exit in -pg -mfentry instrumented functions with
36505 call to specified function. This only instruments true returns ending
36506 with ret, but not sibling calls ending with jump. Valid types
36507 are @var{none} to not instrument, @var{call} to generate a call to __return__,
36508 or @var{nop5} to generate a 5 byte nop.
36509
36510 @opindex mrecord-return
36511 @item -mrecord-return
36512 @itemx -mno-record-return
36513 Generate a __return_loc section pointing to all return instrumentation code.
36514
36515 @opindex mfentry-name
36516 @item -mfentry-name=@var{name}
36517 Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
36518
36519 @opindex mfentry-section
36520 @item -mfentry-section=@var{name}
36521 Set name of section to record -mrecord-mcount calls (default __mcount_loc).
36522
36523 @opindex mskip-rax-setup
36524 @item -mskip-rax-setup
36525 @itemx -mno-skip-rax-setup
36526 When generating code for the x86-64 architecture with SSE extensions
36527 disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
36528 register when there are no variable arguments passed in vector registers.
36529
36530 @strong{Warning:} Since RAX register is used to avoid unnecessarily
36531 saving vector registers on stack when passing variable arguments, the
36532 impacts of this option are callees may waste some stack space,
36533 misbehave or jump to a random location. GCC 4.4 or newer don't have
36534 those issues, regardless the RAX register value.
36535
36536 @opindex m8bit-idiv
36537 @item -m8bit-idiv
36538 @itemx -mno-8bit-idiv
36539 On some processors, like Intel Atom, 8-bit unsigned integer divide is
36540 much faster than 32-bit/64-bit integer divide. This option generates a
36541 run-time check. If both dividend and divisor are within range of 0
36542 to 255, 8-bit unsigned integer divide is used instead of
36543 32-bit/64-bit integer divide.
36544
36545 @opindex mavx256-split-unaligned-load
36546 @opindex mavx256-split-unaligned-store
36547 @item -mavx256-split-unaligned-load
36548 @itemx -mavx256-split-unaligned-store
36549 Split 32-byte AVX unaligned load and store.
36550
36551 @opindex mstack-protector-guard
36552 @opindex mstack-protector-guard-reg
36553 @opindex mstack-protector-guard-offset
36554 @opindex mstack-protector-guard-symbol
36555 @item -mstack-protector-guard=@var{guard}
36556 @itemx -mstack-protector-guard-reg=@var{reg}
36557 @itemx -mstack-protector-guard-offset=@var{offset}
36558 @itemx -mstack-protector-guard-symbol=@var{symbol}
36559 Generate stack protection code using canary at @var{guard}. Supported
36560 locations are @samp{global} for global canary or @samp{tls} for per-thread
36561 canary in the TLS block (the default). This option has effect only when
36562 @option{-fstack-protector} or @option{-fstack-protector-all} is specified.
36563
36564 With the latter choice the options
36565 @option{-mstack-protector-guard-reg=@var{reg}} and
36566 @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
36567 which segment register (@code{%fs} or @code{%gs}) to use as base register
36568 for reading the canary, and from what offset from that base register.
36569 The default for those is as specified in the relevant ABI.
36570
36571 @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
36572 the offset with a symbol reference to a canary in the TLS block.
36573
36574 @opindex mgeneral-regs-only
36575 @item -mgeneral-regs-only
36576 Generate code that uses only the general-purpose registers. This
36577 prevents the compiler from using floating-point, vector, mask and bound
36578 registers.
36579
36580 @opindex mrelax-cmpxchg-loop
36581 @item -mrelax-cmpxchg-loop
36582 When emitting a compare-and-swap loop for @ref{__sync Builtins}
36583 and @ref{__atomic Builtins} lacking a native instruction, optimize
36584 for the highly contended case by issuing an atomic load before the
36585 @code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
36586 to save CPU power when restarting the loop.
36587
36588 @opindex mindirect-branch
36589 @item -mindirect-branch=@var{choice}
36590 Convert indirect call and jump with @var{choice}. The default is
36591 @samp{keep}, which keeps indirect call and jump unmodified.
36592 @samp{thunk} converts indirect call and jump to call and return thunk.
36593 @samp{thunk-inline} converts indirect call and jump to inlined call
36594 and return thunk. @samp{thunk-extern} converts indirect call and jump
36595 to external call and return thunk provided in a separate object file.
36596 You can control this behavior for a specific function by using the
36597 function attribute @code{indirect_branch}. @xref{Function Attributes}.
36598
36599 Note that @option{-mcmodel=large} is incompatible with
36600 @option{-mindirect-branch=thunk} and
36601 @option{-mindirect-branch=thunk-extern} since the thunk function may
36602 not be reachable in the large code model.
36603
36604 Note that @option{-mindirect-branch=thunk-extern} is compatible with
36605 @option{-fcf-protection=branch} since the external thunk can be made
36606 to enable control-flow check.
36607
36608 @opindex mfunction-return
36609 @item -mfunction-return=@var{choice}
36610 Convert function return with @var{choice}. The default is @samp{keep},
36611 which keeps function return unmodified. @samp{thunk} converts function
36612 return to call and return thunk. @samp{thunk-inline} converts function
36613 return to inlined call and return thunk. @samp{thunk-extern} converts
36614 function return to external call and return thunk provided in a separate
36615 object file. You can control this behavior for a specific function by
36616 using the function attribute @code{function_return}.
36617 @xref{Function Attributes}.
36618
36619 Note that @option{-mindirect-return=thunk-extern} is compatible with
36620 @option{-fcf-protection=branch} since the external thunk can be made
36621 to enable control-flow check.
36622
36623 Note that @option{-mcmodel=large} is incompatible with
36624 @option{-mfunction-return=thunk} and
36625 @option{-mfunction-return=thunk-extern} since the thunk function may
36626 not be reachable in the large code model.
36627
36628
36629 @opindex mindirect-branch-register
36630 @item -mindirect-branch-register
36631 Force indirect call and jump via register.
36632
36633 @opindex mharden-sls
36634 @item -mharden-sls=@var{choice}
36635 Generate code to mitigate against straight line speculation (SLS) with
36636 @var{choice}. The default is @samp{none} which disables all SLS
36637 hardening. @samp{return} enables SLS hardening for function returns.
36638 @samp{indirect-jmp} enables SLS hardening for indirect jumps.
36639 @samp{all} enables all SLS hardening.
36640
36641 @opindex mindirect-branch-cs-prefix
36642 @item -mindirect-branch-cs-prefix
36643 Add CS prefix to call and jmp to indirect thunk with branch target in
36644 r8-r15 registers so that the call and jmp instruction length is 6 bytes
36645 to allow them to be replaced with @samp{lfence; call *%r8-r15} or
36646 @samp{lfence; jmp *%r8-r15} at run-time.
36647
36648 @opindex mapx-inline-asm-use-gpr32
36649 @item -mapx-inline-asm-use-gpr32
36650 For inline asm support with APX, by default the EGPR feature was
36651 disabled to prevent potential illegal instruction with EGPR occurs.
36652 To invoke egpr usage in inline asm, use new compiler option
36653 -mapx-inline-asm-use-gpr32 and user should ensure the instruction
36654 supports EGPR.
36655
36656 @end table
36657
36658 These @samp{-m} switches are supported in addition to the above
36659 on x86-64 processors in 64-bit environments.
36660
36661 @table @gcctabopt
36662 @opindex m32
36663 @opindex m64
36664 @opindex mx32
36665 @opindex m16
36666 @opindex miamcu
36667 @item -m32
36668 @itemx -m64
36669 @itemx -mx32
36670 @itemx -m16
36671 @itemx -miamcu
36672 Generate code for a 16-bit, 32-bit or 64-bit environment.
36673 The @option{-m32} option sets @code{int}, @code{long}, and pointer types
36674 to 32 bits, and
36675 generates code that runs in 32-bit mode.
36676
36677 The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
36678 types to 64 bits, and generates code for the x86-64 architecture.
36679 For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
36680 and @option{-mdynamic-no-pic} options.
36681
36682 The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
36683 to 32 bits, and
36684 generates code for the x86-64 architecture.
36685
36686 The @option{-m16} option is the same as @option{-m32}, except for that
36687 it outputs the @code{.code16gcc} assembly directive at the beginning of
36688 the assembly output so that the binary can run in 16-bit mode.
36689
36690 The @option{-miamcu} option generates code which conforms to Intel MCU
36691 psABI. It requires the @option{-m32} option to be turned on.
36692
36693 @opindex mno-red-zone
36694 @opindex mred-zone
36695 @item -mno-red-zone
36696 Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
36697 by the x86-64 ABI; it is a 128-byte area beyond the location of the
36698 stack pointer that is not modified by signal or interrupt handlers
36699 and therefore can be used for temporary data without adjusting the stack
36700 pointer. The flag @option{-mno-red-zone} disables this red zone.
36701
36702 @opindex mcmodel=
36703 @opindex mcmodel=small
36704 @item -mcmodel=small
36705 Generate code for the small code model: the program and its symbols must
36706 be linked in the lower 2 GB of the address space. Pointers are 64 bits.
36707 Programs can be statically or dynamically linked. This is the default
36708 code model.
36709
36710 @opindex mcmodel=kernel
36711 @item -mcmodel=kernel
36712 Generate code for the kernel code model. The kernel runs in the
36713 negative 2 GB of the address space.
36714 This model has to be used for Linux kernel code.
36715
36716 @opindex mcmodel=medium
36717 @item -mcmodel=medium
36718 Generate code for the medium model: the program is linked in the lower 2
36719 GB of the address space. Small symbols are also placed there. Symbols
36720 with sizes larger than @option{-mlarge-data-threshold} are put into
36721 large data or BSS sections and can be located above 2GB. Programs can
36722 be statically or dynamically linked.
36723
36724 @opindex mcmodel=large
36725 @item -mcmodel=large
36726 Generate code for the large model. This model makes no assumptions
36727 about addresses and sizes of sections.
36728
36729 @opindex maddress-mode=long
36730 @item -maddress-mode=long
36731 Generate code for long address mode. This is only supported for 64-bit
36732 and x32 environments. It is the default address mode for 64-bit
36733 environments.
36734
36735 @opindex maddress-mode=short
36736 @item -maddress-mode=short
36737 Generate code for short address mode. This is only supported for 32-bit
36738 and x32 environments. It is the default address mode for 32-bit and
36739 x32 environments.
36740
36741 @opindex mneeded
36742 @item -mneeded
36743 @itemx -mno-needed
36744 Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
36745 indicate the micro-architecture ISA level required to execute the binary.
36746
36747 @opindex mno-direct-extern-access
36748 @opindex mdirect-extern-access
36749 @item -mno-direct-extern-access
36750 Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
36751 to access external symbols. With @option{-fpic} or @option{-fPIC},
36752 treat access to protected symbols as local symbols. The default is
36753 @option{-mdirect-extern-access}.
36754
36755 @strong{Warning:} shared libraries compiled with
36756 @option{-mno-direct-extern-access} and executable compiled with
36757 @option{-mdirect-extern-access} may not be binary compatible if
36758 protected symbols are used in shared libraries and executable.
36759
36760 @opindex munroll-only-small-loops
36761 @opindex mno-unroll-only-small-loops
36762 @item -munroll-only-small-loops
36763 Controls conservative small loop unrolling. It is default enabled by
36764 O2, and unrolls loop with less than 4 insns by 1 time. Explicit
36765 -f[no-]unroll-[all-]loops would disable this flag to avoid any
36766 unintended unrolling behavior that user does not want.
36767
36768 @opindex mlam
36769 @item -mlam=@var{choice}
36770 LAM(linear-address masking) allows special bits in the pointer to be used
36771 for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
36772 positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
36773 positions 62:57 can be used for metadata.
36774 @end table
36775
36776 @node x86 Windows Options
36777 @subsection x86 Windows Options
36778 @cindex x86 Windows Options
36779 @cindex Windows Options for x86
36780
36781 @xref{Cygwin and MinGW Options}.
36782
36783 @node Xstormy16 Options
36784 @subsection Xstormy16 Options
36785 @cindex Xstormy16 Options
36786
36787 These options are defined for Xstormy16:
36788
36789 @table @gcctabopt
36790 @opindex msim
36791 @item -msim
36792 Choose startup files and linker script suitable for the simulator.
36793 @end table
36794
36795 @node Xtensa Options
36796 @subsection Xtensa Options
36797 @cindex Xtensa Options
36798
36799 These options are supported for Xtensa targets:
36800
36801 @table @gcctabopt
36802 @opindex mconst16
36803 @opindex mno-const16
36804 @item -mconst16
36805 @itemx -mno-const16
36806 Enable or disable use of @code{CONST16} instructions for loading
36807 constant values. The @code{CONST16} instruction is currently not a
36808 standard option from Tensilica. When enabled, @code{CONST16}
36809 instructions are always used in place of the standard @code{L32R}
36810 instructions. The use of @code{CONST16} is enabled by default only if
36811 the @code{L32R} instruction is not available.
36812
36813 @opindex mfused-madd
36814 @opindex mno-fused-madd
36815 @item -mfused-madd
36816 @itemx -mno-fused-madd
36817 Enable or disable use of fused multiply/add and multiply/subtract
36818 instructions in the floating-point option. This has no effect if the
36819 floating-point option is not also enabled. Disabling fused multiply/add
36820 and multiply/subtract instructions forces the compiler to use separate
36821 instructions for the multiply and add/subtract operations. This may be
36822 desirable in some cases where strict IEEE 754-compliant results are
36823 required: the fused multiply add/subtract instructions do not round the
36824 intermediate result, thereby producing results with @emph{more} bits of
36825 precision than specified by the IEEE standard. Disabling fused multiply
36826 add/subtract instructions also ensures that the program output is not
36827 sensitive to the compiler's ability to combine multiply and add/subtract
36828 operations.
36829
36830 @opindex mserialize-volatile
36831 @opindex mno-serialize-volatile
36832 @item -mserialize-volatile
36833 @itemx -mno-serialize-volatile
36834 When this option is enabled, GCC inserts @code{MEMW} instructions before
36835 @code{volatile} memory references to guarantee sequential consistency.
36836 The default is @option{-mserialize-volatile}. Use
36837 @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
36838
36839 @opindex mforce-no-pic
36840 @item -mforce-no-pic
36841 For targets, like GNU/Linux, where all user-mode Xtensa code must be
36842 position-independent code (PIC), this option disables PIC for compiling
36843 kernel code.
36844
36845 @opindex mtext-section-literals
36846 @opindex mno-text-section-literals
36847 @item -mtext-section-literals
36848 @itemx -mno-text-section-literals
36849 These options control the treatment of literal pools. The default is
36850 @option{-mno-text-section-literals}, which places literals in a separate
36851 section in the output file. This allows the literal pool to be placed
36852 in a data RAM/ROM, and it also allows the linker to combine literal
36853 pools from separate object files to remove redundant literals and
36854 improve code size. With @option{-mtext-section-literals}, the literals
36855 are interspersed in the text section in order to keep them as close as
36856 possible to their references. This may be necessary for large assembly
36857 files. Literals for each function are placed right before that function.
36858
36859 @opindex mauto-litpools
36860 @opindex mno-auto-litpools
36861 @item -mauto-litpools
36862 @itemx -mno-auto-litpools
36863 These options control the treatment of literal pools. The default is
36864 @option{-mno-auto-litpools}, which places literals in a separate
36865 section in the output file unless @option{-mtext-section-literals} is
36866 used. With @option{-mauto-litpools} the literals are interspersed in
36867 the text section by the assembler. Compiler does not produce explicit
36868 @code{.literal} directives and loads literals into registers with
36869 @code{MOVI} instructions instead of @code{L32R} to let the assembler
36870 do relaxation and place literals as necessary. This option allows
36871 assembler to create several literal pools per function and assemble
36872 very big functions, which may not be possible with
36873 @option{-mtext-section-literals}.
36874
36875 @opindex mtarget-align
36876 @opindex mno-target-align
36877 @item -mtarget-align
36878 @itemx -mno-target-align
36879 When this option is enabled, GCC instructs the assembler to
36880 automatically align instructions to reduce branch penalties at the
36881 expense of some code density. The assembler attempts to widen density
36882 instructions to align branch targets and the instructions following call
36883 instructions. If there are not enough preceding safe density
36884 instructions to align a target, no widening is performed. The
36885 default is @option{-mtarget-align}. These options do not affect the
36886 treatment of auto-aligned instructions like @code{LOOP}, which the
36887 assembler always aligns, either by widening density instructions or
36888 by inserting NOP instructions.
36889
36890 @opindex mlongcalls
36891 @opindex mno-longcalls
36892 @item -mlongcalls
36893 @itemx -mno-longcalls
36894 When this option is enabled, GCC instructs the assembler to translate
36895 direct calls to indirect calls unless it can determine that the target
36896 of a direct call is in the range allowed by the call instruction. This
36897 translation typically occurs for calls to functions in other source
36898 files. Specifically, the assembler translates a direct @code{CALL}
36899 instruction into an @code{L32R} followed by a @code{CALLX} instruction.
36900 The default is @option{-mno-longcalls}. This option should be used in
36901 programs where the call target can potentially be out of range. This
36902 option is implemented in the assembler, not the compiler, so the
36903 assembly code generated by GCC still shows direct call
36904 instructions---look at the disassembled object code to see the actual
36905 instructions. Note that the assembler uses an indirect call for
36906 every cross-file call, not just those that really are out of range.
36907
36908 @opindex mabi
36909 @item -mabi=@var{name}
36910 Generate code for the specified ABI@. Permissible values are: @samp{call0},
36911 @samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
36912
36913 @opindex mabi=call0
36914 @item -mabi=call0
36915 When this option is enabled function parameters are passed in registers
36916 @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
36917 caller-saved, and register @code{a15} may be used as a frame pointer.
36918 When this version of the ABI is enabled the C preprocessor symbol
36919 @code{__XTENSA_CALL0_ABI__} is defined.
36920
36921 @opindex mabi=windowed
36922 @item -mabi=windowed
36923 When this option is enabled function parameters are passed in registers
36924 @code{a10} through @code{a15}, and called function rotates register window
36925 by 8 registers on entry so that its arguments are found in registers
36926 @code{a2} through @code{a7}. Register @code{a7} may be used as a frame
36927 pointer. Register window is rotated 8 registers back upon return.
36928 When this version of the ABI is enabled the C preprocessor symbol
36929 @code{__XTENSA_WINDOWED_ABI__} is defined.
36930
36931 @opindex mextra-l32r-costs
36932 @item -mextra-l32r-costs=@var{n}
36933 Specify an extra cost of instruction RAM/ROM access for @code{L32R}
36934 instructions, in clock cycles. This affects, when optimizing for speed,
36935 whether loading a constant from literal pool using @code{L32R} or
36936 synthesizing the constant from a small one with a couple of arithmetic
36937 instructions. The default value is 0.
36938
36939 @opindex mstrict-align
36940 @opindex mno-strict-align
36941 @item -mstrict-align
36942 @itemx -mno-strict-align
36943 Avoid or allow generating memory accesses that may not be aligned on a natural
36944 object boundary as described in the architecture specification.
36945 The default is @option{-mno-strict-align} for cores that support both
36946 unaligned loads and stores in hardware and @option{-mstrict-align} for all
36947 other cores.
36948
36949 @end table
36950
36951 @node zSeries Options
36952 @subsection zSeries Options
36953 @cindex zSeries options
36954
36955 These are listed under @xref{S/390 and zSeries Options}.
36956
36957
36958 @c man end
36959
36960 @node Spec Files
36961 @section Specifying Subprocesses and the Switches to Pass to Them
36962 @cindex Spec Files
36963
36964 @command{gcc} is a driver program. It performs its job by invoking a
36965 sequence of other programs to do the work of compiling, assembling and
36966 linking. GCC interprets its command-line parameters and uses these to
36967 deduce which programs it should invoke, and which command-line options
36968 it ought to place on their command lines. This behavior is controlled
36969 by @dfn{spec strings}. In most cases there is one spec string for each
36970 program that GCC can invoke, but a few programs have multiple spec
36971 strings to control their behavior. The spec strings built into GCC can
36972 be overridden by using the @option{-specs=} command-line switch to specify
36973 a spec file.
36974
36975 @dfn{Spec files} are plain-text files that are used to construct spec
36976 strings. They consist of a sequence of directives separated by blank
36977 lines. The type of directive is determined by the first non-whitespace
36978 character on the line, which can be one of the following:
36979
36980 @table @code
36981 @item %@var{command}
36982 Issues a @var{command} to the spec file processor. The commands that can
36983 appear here are:
36984
36985 @table @code
36986 @cindex @code{%include}
36987 @item %include <@var{file}>
36988 Search for @var{file} and insert its text at the current point in the
36989 specs file.
36990
36991 @cindex @code{%include_noerr}
36992 @item %include_noerr <@var{file}>
36993 Just like @samp{%include}, but do not generate an error message if the include
36994 file cannot be found.
36995
36996 @cindex @code{%rename}
36997 @item %rename @var{old_name} @var{new_name}
36998 Rename the spec string @var{old_name} to @var{new_name}.
36999
37000 @end table
37001
37002 @item *[@var{spec_name}]:
37003 This tells the compiler to create, override or delete the named spec
37004 string. All lines after this directive up to the next directive or
37005 blank line are considered to be the text for the spec string. If this
37006 results in an empty string then the spec is deleted. (Or, if the
37007 spec did not exist, then nothing happens.) Otherwise, if the spec
37008 does not currently exist a new spec is created. If the spec does
37009 exist then its contents are overridden by the text of this
37010 directive, unless the first character of that text is the @samp{+}
37011 character, in which case the text is appended to the spec.
37012
37013 @item [@var{suffix}]:
37014 Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
37015 and up to the next directive or blank line are considered to make up the
37016 spec string for the indicated suffix. When the compiler encounters an
37017 input file with the named suffix, it processes the spec string in
37018 order to work out how to compile that file. For example:
37019
37020 @smallexample
37021 .ZZ:
37022 z-compile -input %i
37023 @end smallexample
37024
37025 This says that any input file whose name ends in @samp{.ZZ} should be
37026 passed to the program @samp{z-compile}, which should be invoked with the
37027 command-line switch @option{-input} and with the result of performing the
37028 @samp{%i} substitution. (See below.)
37029
37030 As an alternative to providing a spec string, the text following a
37031 suffix directive can be one of the following:
37032
37033 @table @code
37034 @item @@@var{language}
37035 This says that the suffix is an alias for a known @var{language}. This is
37036 similar to using the @option{-x} command-line switch to GCC to specify a
37037 language explicitly. For example:
37038
37039 @smallexample
37040 .ZZ:
37041 @@c++
37042 @end smallexample
37043
37044 Says that .ZZ files are, in fact, C++ source files.
37045
37046 @item #@var{name}
37047 This causes an error messages saying:
37048
37049 @smallexample
37050 @var{name} compiler not installed on this system.
37051 @end smallexample
37052 @end table
37053
37054 GCC already has an extensive list of suffixes built into it.
37055 This directive adds an entry to the end of the list of suffixes, but
37056 since the list is searched from the end backwards, it is effectively
37057 possible to override earlier entries using this technique.
37058
37059 @end table
37060
37061 GCC has the following spec strings built into it. Spec files can
37062 override these strings or create their own. Note that individual
37063 targets can also add their own spec strings to this list.
37064
37065 @smallexample
37066 asm Options to pass to the assembler
37067 asm_final Options to pass to the assembler post-processor
37068 cpp Options to pass to the C preprocessor
37069 cc1 Options to pass to the C compiler
37070 cc1plus Options to pass to the C++ compiler
37071 endfile Object files to include at the end of the link
37072 link Options to pass to the linker
37073 lib Libraries to include on the command line to the linker
37074 libgcc Decides which GCC support library to pass to the linker
37075 linker Sets the name of the linker
37076 startfile Object files to include at the start of the link
37077 @end smallexample
37078
37079 Here is a small example of a spec file:
37080
37081 @smallexample
37082 %rename lib old_lib
37083
37084 *lib:
37085 --start-group -lgcc -lc -leval1 --end-group %(old_lib)
37086 @end smallexample
37087
37088 This example renames the spec called @samp{lib} to @samp{old_lib} and
37089 then overrides the previous definition of @samp{lib} with a new one.
37090 The new definition adds in some extra command-line options before
37091 including the text of the old definition.
37092
37093 @dfn{Spec strings} are a list of command-line options to be passed to their
37094 corresponding program. In addition, the spec strings can contain
37095 @samp{%}-prefixed sequences to substitute variable text or to
37096 conditionally insert text into the command line. Using these constructs
37097 it is possible to generate quite complex command lines.
37098
37099 Here is a table of all defined @samp{%}-sequences for spec
37100 strings. Note that spaces are not generated automatically around the
37101 results of expanding these sequences. Therefore you can concatenate them
37102 together or combine them with constant text in a single argument.
37103
37104 @table @code
37105 @item %%
37106 Substitute one @samp{%} into the program name or argument.
37107
37108 @item %"
37109 Substitute an empty argument.
37110
37111 @item %i
37112 Substitute the name of the input file being processed.
37113
37114 @item %b
37115 Substitute the basename for outputs related with the input file being
37116 processed. This is often the substring up to (and not including) the
37117 last period and not including the directory but, unless %w is active, it
37118 expands to the basename for auxiliary outputs, which may be influenced
37119 by an explicit output name, and by various other options that control
37120 how auxiliary outputs are named.
37121
37122 @item %B
37123 This is the same as @samp{%b}, but include the file suffix (text after
37124 the last period). Without %w, it expands to the basename for dump
37125 outputs.
37126
37127 @item %d
37128 Marks the argument containing or following the @samp{%d} as a
37129 temporary file name, so that that file is deleted if GCC exits
37130 successfully. Unlike @samp{%g}, this contributes no text to the
37131 argument.
37132
37133 @item %g@var{suffix}
37134 Substitute a file name that has suffix @var{suffix} and is chosen
37135 once per compilation, and mark the argument in the same way as
37136 @samp{%d}. To reduce exposure to denial-of-service attacks, the file
37137 name is now chosen in a way that is hard to predict even when previously
37138 chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
37139 might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
37140 the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
37141 treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
37142 was simply substituted with a file name chosen once per compilation,
37143 without regard to any appended suffix (which was therefore treated
37144 just like ordinary text), making such attacks more likely to succeed.
37145
37146 @item %u@var{suffix}
37147 Like @samp{%g}, but generates a new temporary file name
37148 each time it appears instead of once per compilation.
37149
37150 @item %U@var{suffix}
37151 Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
37152 new one if there is no such last file name. In the absence of any
37153 @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
37154 the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
37155 involves the generation of two distinct file names, one
37156 for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
37157 simply substituted with a file name chosen for the previous @samp{%u},
37158 without regard to any appended suffix.
37159
37160 @item %j@var{suffix}
37161 Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
37162 writable, and if @option{-save-temps} is not used;
37163 otherwise, substitute the name
37164 of a temporary file, just like @samp{%u}. This temporary file is not
37165 meant for communication between processes, but rather as a junk
37166 disposal mechanism.
37167
37168 @item %|@var{suffix}
37169 @itemx %m@var{suffix}
37170 Like @samp{%g}, except if @option{-pipe} is in effect. In that case
37171 @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
37172 all. These are the two most common ways to instruct a program that it
37173 should read from standard input or write to standard output. If you
37174 need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
37175 construct: see for example @file{gcc/fortran/lang-specs.h}.
37176
37177 @item %.@var{SUFFIX}
37178 Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
37179 when it is subsequently output with @samp{%*}. @var{SUFFIX} is
37180 terminated by the next space or %.
37181
37182 @item %w
37183 Marks the argument containing or following the @samp{%w} as the
37184 designated output file of this compilation. This puts the argument
37185 into the sequence of arguments that @samp{%o} substitutes.
37186
37187 @item %V
37188 Indicates that this compilation produces no output file.
37189
37190 @item %o
37191 Substitutes the names of all the output files, with spaces
37192 automatically placed around them. You should write spaces
37193 around the @samp{%o} as well or the results are undefined.
37194 @samp{%o} is for use in the specs for running the linker.
37195 Input files whose names have no recognized suffix are not compiled
37196 at all, but they are included among the output files, so they are
37197 linked.
37198
37199 @item %O
37200 Substitutes the suffix for object files. Note that this is
37201 handled specially when it immediately follows @samp{%g, %u, or %U},
37202 because of the need for those to form complete file names. The
37203 handling is such that @samp{%O} is treated exactly as if it had already
37204 been substituted, except that @samp{%g, %u, and %U} do not currently
37205 support additional @var{suffix} characters following @samp{%O} as they do
37206 following, for example, @samp{.o}.
37207
37208 @item %I
37209 Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
37210 @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
37211 @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
37212 and @option{-imultilib} as necessary.
37213
37214 @item %s
37215 Current argument is the name of a library or startup file of some sort.
37216 Search for that file in a standard list of directories and substitute
37217 the full name found. The current working directory is included in the
37218 list of directories scanned.
37219
37220 @item %T
37221 Current argument is the name of a linker script. Search for that file
37222 in the current list of directories to scan for libraries. If the file
37223 is located insert a @option{--script} option into the command line
37224 followed by the full path name found. If the file is not found then
37225 generate an error message. Note: the current working directory is not
37226 searched.
37227
37228 @item %e@var{str}
37229 Print @var{str} as an error message. @var{str} is terminated by a newline.
37230 Use this when inconsistent options are detected.
37231
37232 @item %n@var{str}
37233 Print @var{str} as a notice. @var{str} is terminated by a newline.
37234
37235 @item %(@var{name})
37236 Substitute the contents of spec string @var{name} at this point.
37237
37238 @item %x@{@var{option}@}
37239 Accumulate an option for @samp{%X}.
37240
37241 @item %X
37242 Output the accumulated linker options specified by a @samp{%x} spec string.
37243
37244 @item %Y
37245 Output the accumulated assembler options specified by @option{-Wa}.
37246
37247 @item %Z
37248 Output the accumulated preprocessor options specified by @option{-Wp}.
37249
37250 @item %M
37251 Output @code{multilib_os_dir}.
37252
37253 @item %R
37254 Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
37255
37256 @item %a
37257 Process the @code{asm} spec. This is used to compute the
37258 switches to be passed to the assembler.
37259
37260 @item %A
37261 Process the @code{asm_final} spec. This is a spec string for
37262 passing switches to an assembler post-processor, if such a program is
37263 needed.
37264
37265 @item %l
37266 Process the @code{link} spec. This is the spec for computing the
37267 command line passed to the linker. Typically it makes use of the
37268 @samp{%L %G %S %D and %E} sequences.
37269
37270 @item %D
37271 Dump out a @option{-L} option for each directory that GCC believes might
37272 contain startup files. If the target supports multilibs then the
37273 current multilib directory is prepended to each of these paths.
37274
37275 @item %L
37276 Process the @code{lib} spec. This is a spec string for deciding which
37277 libraries are included on the command line to the linker.
37278
37279 @item %G
37280 Process the @code{libgcc} spec. This is a spec string for deciding
37281 which GCC support library is included on the command line to the linker.
37282
37283 @item %S
37284 Process the @code{startfile} spec. This is a spec for deciding which
37285 object files are the first ones passed to the linker. Typically
37286 this might be a file named @file{crt0.o}.
37287
37288 @item %E
37289 Process the @code{endfile} spec. This is a spec string that specifies
37290 the last object files that are passed to the linker.
37291
37292 @item %C
37293 Process the @code{cpp} spec. This is used to construct the arguments
37294 to be passed to the C preprocessor.
37295
37296 @item %1
37297 Process the @code{cc1} spec. This is used to construct the options to be
37298 passed to the actual C compiler (@command{cc1}).
37299
37300 @item %2
37301 Process the @code{cc1plus} spec. This is used to construct the options to be
37302 passed to the actual C++ compiler (@command{cc1plus}).
37303
37304 @item %*
37305 Substitute the variable part of a matched option. See below.
37306 Note that each comma in the substituted string is replaced by
37307 a single space.
37308
37309 @item %<@var{S}
37310 Remove all occurrences of @code{-@var{S}} from the command line. Note---this
37311 command is position dependent. @samp{%} commands in the spec string
37312 before this one see @code{-@var{S}}, @samp{%} commands in the spec string
37313 after this one do not.
37314
37315 @item %<@var{S}*
37316 Similar to @samp{%<@var{S}}, but match all switches beginning with @code{-@var{S}}.
37317
37318 @item %>@var{S}
37319 Similar to @samp{%<@var{S}}, but keep @code{-@var{S}} in the GCC command line.
37320
37321 @item %:@var{function}(@var{args})
37322 Call the named function @var{function}, passing it @var{args}.
37323 @var{args} is first processed as a nested spec string, then split
37324 into an argument vector in the usual fashion. The function returns
37325 a string which is processed as if it had appeared literally as part
37326 of the current spec.
37327
37328 The following built-in spec functions are provided:
37329
37330 @table @code
37331 @item @code{getenv}
37332 The @code{getenv} spec function takes two arguments: an environment
37333 variable name and a string. If the environment variable is not
37334 defined, a fatal error is issued. Otherwise, the return value is the
37335 value of the environment variable concatenated with the string. For
37336 example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
37337
37338 @smallexample
37339 %:getenv(TOPDIR /include)
37340 @end smallexample
37341
37342 expands to @file{/path/to/top/include}.
37343
37344 @item @code{if-exists}
37345 The @code{if-exists} spec function takes one argument, an absolute
37346 pathname to a file. If the file exists, @code{if-exists} returns the
37347 pathname. Here is a small example of its usage:
37348
37349 @smallexample
37350 *startfile:
37351 crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
37352 @end smallexample
37353
37354 @item @code{if-exists-else}
37355 The @code{if-exists-else} spec function is similar to the @code{if-exists}
37356 spec function, except that it takes two arguments. The first argument is
37357 an absolute pathname to a file. If the file exists, @code{if-exists-else}
37358 returns the pathname. If it does not exist, it returns the second argument.
37359 This way, @code{if-exists-else} can be used to select one file or another,
37360 based on the existence of the first. Here is a small example of its usage:
37361
37362 @smallexample
37363 *startfile:
37364 crt0%O%s %:if-exists(crti%O%s) \
37365 %:if-exists-else(crtbeginT%O%s crtbegin%O%s)
37366 @end smallexample
37367
37368 @item @code{if-exists-then-else}
37369 The @code{if-exists-then-else} spec function takes at least two arguments
37370 and an optional third one. The first argument is an absolute pathname to a
37371 file. If the file exists, the function returns the second argument.
37372 If the file does not exist, the function returns the third argument if there
37373 is one, or NULL otherwise. This can be used to expand one text, or optionally
37374 another, based on the existence of a file. Here is a small example of its
37375 usage:
37376
37377 @smallexample
37378 -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
37379 @end smallexample
37380
37381 @item @code{sanitize}
37382 The @code{sanitize} spec function takes no arguments. It returns non-NULL if
37383 any address, thread or undefined behavior sanitizers are active.
37384
37385 @smallexample
37386 %@{%:sanitize(address):-funwind-tables@}
37387 @end smallexample
37388
37389 @item @code{replace-outfile}
37390 The @code{replace-outfile} spec function takes two arguments. It looks for the
37391 first argument in the outfiles array and replaces it with the second argument. Here
37392 is a small example of its usage:
37393
37394 @smallexample
37395 %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
37396 @end smallexample
37397
37398 @item @code{remove-outfile}
37399 The @code{remove-outfile} spec function takes one argument. It looks for the
37400 first argument in the outfiles array and removes it. Here is a small example
37401 its usage:
37402
37403 @smallexample
37404 %:remove-outfile(-lm)
37405 @end smallexample
37406
37407 @item @code{version-compare}
37408 The @code{version-compare} spec function takes four or five arguments of the following
37409 form:
37410
37411 @smallexample
37412 <comparison-op> <arg1> [<arg2>] <switch> <result>
37413 @end smallexample
37414
37415 It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
37416 The supported @code{comparison-op} values are:
37417
37418 @table @code
37419 @item >=
37420 True if @code{switch} is a later (or same) version than @code{arg1}
37421
37422 @item !>
37423 Opposite of @code{>=}
37424
37425 @item <
37426 True if @code{switch} is an earlier version than @code{arg1}
37427
37428 @item !<
37429 Opposite of @code{<}
37430
37431 @item ><
37432 True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
37433
37434 @item <>
37435 True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
37436 @end table
37437
37438 If the @code{switch} is not present at all, the condition is false unless the first character
37439 of the @code{comparison-op} is @code{!}.
37440
37441 @smallexample
37442 %:version-compare(>= 10.3 mmacosx-version-min= -lmx)
37443 @end smallexample
37444
37445 The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
37446 passed.
37447
37448 @item @code{include}
37449 The @code{include} spec function behaves much like @code{%include}, with the advantage
37450 that it can be nested inside a spec and thus be conditionalized. It takes one argument,
37451 the filename, and looks for it in the startfile path. It always returns NULL.
37452
37453 @smallexample
37454 %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
37455 @end smallexample
37456
37457 @item @code{pass-through-libs}
37458 The @code{pass-through-libs} spec function takes any number of arguments. It
37459 finds any @option{-l} options and any non-options ending in @file{.a} (which it
37460 assumes are the names of linker input library archive files) and returns a
37461 result containing all the found arguments each prepended by
37462 @option{-plugin-opt=-pass-through=} and joined by spaces. This list is
37463 intended to be passed to the LTO linker plugin.
37464
37465 @smallexample
37466 %:pass-through-libs(%G %L %G)
37467 @end smallexample
37468
37469 @item @code{print-asm-header}
37470 The @code{print-asm-header} function takes no arguments and simply
37471 prints a banner like:
37472
37473 @smallexample
37474 Assembler options
37475 =================
37476
37477 Use "-Wa,OPTION" to pass "OPTION" to the assembler.
37478 @end smallexample
37479
37480 It is used to separate compiler options from assembler options
37481 in the @option{--target-help} output.
37482
37483 @item @code{gt}
37484 The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
37485 empty string) if the second-to-last argument is greater than the last argument, and NULL
37486 otherwise. The following example inserts the @code{link_gomp} spec if the last
37487 @option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
37488
37489 @smallexample
37490 %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
37491 @end smallexample
37492
37493 @item @code{debug-level-gt}
37494 The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
37495 empty string) if @code{debug_info_level} is greater than the specified number, and NULL
37496 otherwise.
37497
37498 @smallexample
37499 %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
37500 @end smallexample
37501 @end table
37502
37503 @item %@{@var{S}@}
37504 Substitutes the @code{-@var{S}} switch, if that switch is given to GCC@.
37505 If that switch is not specified, this substitutes nothing. Note that
37506 the leading dash is omitted when specifying this option, and it is
37507 automatically inserted if the substitution is performed. Thus the spec
37508 string @samp{%@{foo@}} matches the command-line option @option{-foo}
37509 and outputs the command-line option @option{-foo}.
37510
37511 @item %W@{@var{S}@}
37512 Like %@{@code{@var{S}}@} but mark last argument supplied within as a file to be
37513 deleted on failure.
37514
37515 @item %@@@{@var{S}@}
37516 Like %@{@code{@var{S}}@} but puts the result into a @code{FILE} and substitutes
37517 @code{@@FILE} if an @code{@@file} argument has been supplied.
37518
37519 @item %@{@var{S}*@}
37520 Substitutes all the switches specified to GCC whose names start
37521 with @code{-@var{S}}, but which also take an argument. This is used for
37522 switches like @option{-o}, @option{-D}, @option{-I}, etc.
37523 GCC considers @option{-o foo} as being
37524 one switch whose name starts with @samp{o}. %@{o*@} substitutes this
37525 text, including the space. Thus two arguments are generated.
37526
37527 @item %@{@var{S}*&@var{T}*@}
37528 Like %@{@code{@var{S}}*@}, but preserve order of @code{@var{S}} and @code{@var{T}} options
37529 (the order of @code{@var{S}} and @code{@var{T}} in the spec is not significant).
37530 There can be any number of ampersand-separated variables; for each the
37531 wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
37532
37533 @item %@{@var{S}:@var{X}@}
37534 Substitutes @code{@var{X}}, if the @option{-@var{S}} switch is given to GCC@.
37535
37536 @item %@{!@var{S}:@var{X}@}
37537 Substitutes @code{@var{X}}, if the @option{-@var{S}} switch is @emph{not} given to GCC@.
37538
37539 @item %@{@var{S}*:@var{X}@}
37540 Substitutes @code{@var{X}} if one or more switches whose names start with
37541 @code{-@var{S}} are specified to GCC@. Normally @code{@var{X}} is substituted only
37542 once, no matter how many such switches appeared. However, if @code{%*}
37543 appears somewhere in @code{@var{X}}, then @code{@var{X}} is substituted once
37544 for each matching switch, with the @code{%*} replaced by the part of
37545 that switch matching the @code{*}.
37546
37547 If @code{%*} appears as the last part of a spec sequence then a space
37548 is added after the end of the last substitution. If there is more
37549 text in the sequence, however, then a space is not generated. This
37550 allows the @code{%*} substitution to be used as part of a larger
37551 string. For example, a spec string like this:
37552
37553 @smallexample
37554 %@{mcu=*:--script=%*/memory.ld@}
37555 @end smallexample
37556
37557 @noindent
37558 when matching an option like @option{-mcu=newchip} produces:
37559
37560 @smallexample
37561 --script=newchip/memory.ld
37562 @end smallexample
37563
37564 @item %@{.@var{S}:@var{X}@}
37565 Substitutes @code{@var{X}}, if processing a file with suffix @code{@var{S}}.
37566
37567 @item %@{!.@var{S}:@var{X}@}
37568 Substitutes @code{@var{X}}, if @emph{not} processing a file with suffix @code{@var{S}}.
37569
37570 @item %@{,@var{S}:@var{X}@}
37571 Substitutes @code{@var{X}}, if processing a file for language @code{@var{S}}.
37572
37573 @item %@{!,@var{S}:@var{X}@}
37574 Substitutes @code{@var{X}}, if not processing a file for language @code{@var{S}}.
37575
37576 @item %@{@var{S}|@var{P}:@var{X}@}
37577 Substitutes @code{@var{X}} if either @code{-@var{S}} or @code{-@var{P}} is given to
37578 GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
37579 @code{*} sequences as well, although they have a stronger binding than
37580 the @samp{|}. If @code{%*} appears in @code{@var{X}}, all of the
37581 alternatives must be starred, and only the first matching alternative
37582 is substituted.
37583
37584 For example, a spec string like this:
37585
37586 @smallexample
37587 %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
37588 @end smallexample
37589
37590 @noindent
37591 outputs the following command-line options from the following input
37592 command-line options:
37593
37594 @smallexample
37595 fred.c -foo -baz
37596 jim.d -bar -boggle
37597 -d fred.c -foo -baz -boggle
37598 -d jim.d -bar -baz -boggle
37599 @end smallexample
37600
37601 @item %@{%:@var{function}(@var{args}):@var{X}@}
37602
37603 Call function named @var{function} with args @var{args}. If the
37604 function returns non-NULL, then @code{@var{X}} is substituted, if it returns
37605 NULL, it isn't substituted.
37606
37607 @item %@{@var{S}:@var{X}; @var{T}:@var{Y}; :@var{D}@}
37608
37609 If @code{@var{S}} is given to GCC, substitutes @code{@var{X}}; else if @code{@var{T}} is
37610 given to GCC, substitutes @code{@var{Y}}; else substitutes @code{@var{D}}. There can
37611 be as many clauses as you need. This may be combined with @code{.},
37612 @code{,}, @code{!}, @code{|}, and @code{*} as needed.
37613
37614
37615 @end table
37616
37617 The switch matching text @code{@var{S}} in a @samp{%@{@var{S}@}}, @samp{%@{@var{S}:@var{X}@}}
37618 or similar construct can use a backslash to ignore the special meaning
37619 of the character following it, thus allowing literal matching of a
37620 character that is otherwise specially treated. For example,
37621 @samp{%@{std=iso9899\:1999:@var{X}@}} substitutes @code{@var{X}} if the
37622 @option{-std=iso9899:1999} option is given.
37623
37624 The conditional text @code{@var{X}} in a @samp{%@{@var{S}:@var{X}@}} or similar
37625 construct may contain other nested @samp{%} constructs or spaces, or
37626 even newlines. They are processed as usual, as described above.
37627 Trailing white space in @code{@var{X}} is ignored. White space may also
37628 appear anywhere on the left side of the colon in these constructs,
37629 except between @code{.} or @code{*} and the corresponding word.
37630
37631 The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
37632 handled specifically in these constructs. If another value of
37633 @option{-O} or the negated form of a @option{-f}, @option{-m}, or
37634 @option{-W} switch is found later in the command line, the earlier
37635 switch value is ignored, except with @{@code{@var{S}}*@} where @code{@var{S}} is
37636 just one letter, which passes all matching options.
37637
37638 The character @samp{|} at the beginning of the predicate text is used to
37639 indicate that a command should be piped to the following command, but
37640 only if @option{-pipe} is specified.
37641
37642 It is built into GCC which switches take arguments and which do not.
37643 (You might think it would be useful to generalize this to allow each
37644 compiler's spec to say which switches take arguments. But this cannot
37645 be done in a consistent fashion. GCC cannot even decide which input
37646 files have been specified without knowing which switches take arguments,
37647 and it must know which input files to compile in order to tell which
37648 compilers to run).
37649
37650 GCC also knows implicitly that arguments starting in @option{-l} are to be
37651 treated as compiler output files, and passed to the linker in their
37652 proper position among the other output files.
37653
37654 @node Environment Variables
37655 @section Environment Variables Affecting GCC
37656 @cindex environment variables
37657
37658 @c man begin ENVIRONMENT
37659 This section describes several environment variables that affect how GCC
37660 operates. Some of them work by specifying directories or prefixes to use
37661 when searching for various kinds of files. Some are used to specify other
37662 aspects of the compilation environment.
37663
37664 Note that you can also specify places to search using options such as
37665 @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
37666 take precedence over places specified using environment variables, which
37667 in turn take precedence over those specified by the configuration of GCC@.
37668 @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
37669 GNU Compiler Collection (GCC) Internals}.
37670
37671 @table @env
37672 @vindex LANG
37673 @vindex LC_CTYPE
37674 @c @vindex LC_COLLATE
37675 @vindex LC_MESSAGES
37676 @c @vindex LC_MONETARY
37677 @c @vindex LC_NUMERIC
37678 @c @vindex LC_TIME
37679 @vindex LC_ALL
37680 @cindex locale
37681 @item LANG
37682 @itemx LC_CTYPE
37683 @c @itemx LC_COLLATE
37684 @itemx LC_MESSAGES
37685 @c @itemx LC_MONETARY
37686 @c @itemx LC_NUMERIC
37687 @c @itemx LC_TIME
37688 @itemx LC_ALL
37689 These environment variables control the way that GCC uses
37690 localization information which allows GCC to work with different
37691 national conventions. GCC inspects the locale categories
37692 @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
37693 so. These locale categories can be set to any value supported by your
37694 installation. A typical value is @samp{en_GB.UTF-8} for English in the United
37695 Kingdom encoded in UTF-8.
37696
37697 The @env{LC_CTYPE} environment variable specifies character
37698 classification. GCC uses it to determine the character boundaries in
37699 a string; this is needed for some multibyte encodings that contain quote
37700 and escape characters that are otherwise interpreted as a string
37701 end or escape.
37702
37703 The @env{LC_MESSAGES} environment variable specifies the language to
37704 use in diagnostic messages.
37705
37706 If the @env{LC_ALL} environment variable is set, it overrides the value
37707 of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
37708 and @env{LC_MESSAGES} default to the value of the @env{LANG}
37709 environment variable. If none of these variables are set, GCC
37710 defaults to traditional C English behavior.
37711
37712 @vindex TMPDIR
37713 @item TMPDIR
37714 If @env{TMPDIR} is set, it specifies the directory to use for temporary
37715 files. GCC uses temporary files to hold the output of one stage of
37716 compilation which is to be used as input to the next stage: for example,
37717 the output of the preprocessor, which is the input to the compiler
37718 proper.
37719
37720 @vindex GCC_COMPARE_DEBUG
37721 @item GCC_COMPARE_DEBUG
37722 Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
37723 @option{-fcompare-debug} to the compiler driver. See the documentation
37724 of this option for more details.
37725
37726 @vindex GCC_EXEC_PREFIX
37727 @item GCC_EXEC_PREFIX
37728 If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
37729 names of the subprograms executed by the compiler. No slash is added
37730 when this prefix is combined with the name of a subprogram, but you can
37731 specify a prefix that ends with a slash if you wish.
37732
37733 If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
37734 an appropriate prefix to use based on the pathname it is invoked with.
37735
37736 If GCC cannot find the subprogram using the specified prefix, it
37737 tries looking in the usual places for the subprogram.
37738
37739 The default value of @env{GCC_EXEC_PREFIX} is
37740 @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
37741 the installed compiler. In many cases @var{prefix} is the value
37742 of @code{prefix} when you ran the @file{configure} script.
37743
37744 Other prefixes specified with @option{-B} take precedence over this prefix.
37745
37746 This prefix is also used for finding files such as @file{crt0.o} that are
37747 used for linking.
37748
37749 In addition, the prefix is used in an unusual way in finding the
37750 directories to search for header files. For each of the standard
37751 directories whose name normally begins with @samp{/usr/local/lib/gcc}
37752 (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
37753 replacing that beginning with the specified prefix to produce an
37754 alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
37755 @file{foo/bar} just before it searches the standard directory
37756 @file{/usr/local/lib/bar}.
37757 If a standard directory begins with the configured
37758 @var{prefix} then the value of @var{prefix} is replaced by
37759 @env{GCC_EXEC_PREFIX} when looking for header files.
37760
37761 @vindex COMPILER_PATH
37762 @item COMPILER_PATH
37763 The value of @env{COMPILER_PATH} is a colon-separated list of
37764 directories, much like @env{PATH}. GCC tries the directories thus
37765 specified when searching for subprograms, if it cannot find the
37766 subprograms using @env{GCC_EXEC_PREFIX}.
37767
37768 @vindex LIBRARY_PATH
37769 @item LIBRARY_PATH
37770 The value of @env{LIBRARY_PATH} is a colon-separated list of
37771 directories, much like @env{PATH}. When configured as a native compiler,
37772 GCC tries the directories thus specified when searching for special
37773 linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
37774 using GCC also uses these directories when searching for ordinary
37775 libraries for the @option{-l} option (but directories specified with
37776 @option{-L} come first).
37777
37778 @vindex LANG
37779 @cindex locale definition
37780 @item LANG
37781 This variable is used to pass locale information to the compiler. One way in
37782 which this information is used is to determine the character set to be used
37783 when character literals, string literals and comments are parsed in C and C++.
37784 When the compiler is configured to allow multibyte characters,
37785 the following values for @env{LANG} are recognized:
37786
37787 @table @samp
37788 @item C-JIS
37789 Recognize JIS characters.
37790 @item C-SJIS
37791 Recognize SJIS characters.
37792 @item C-EUCJP
37793 Recognize EUCJP characters.
37794 @end table
37795
37796 If @env{LANG} is not defined, or if it has some other value, then the
37797 compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
37798 recognize and translate multibyte characters.
37799
37800 @vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
37801 @item GCC_EXTRA_DIAGNOSTIC_OUTPUT
37802 If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
37803 then additional text will be emitted to stderr when fix-it hints are
37804 emitted. @option{-fdiagnostics-parseable-fixits} and
37805 @option{-fno-diagnostics-parseable-fixits} take precedence over this
37806 environment variable.
37807
37808 @table @samp
37809 @item fixits-v1
37810 Emit parseable fix-it hints, equivalent to
37811 @option{-fdiagnostics-parseable-fixits}. In particular, columns are
37812 expressed as a count of bytes, starting at byte 1 for the initial column.
37813
37814 @item fixits-v2
37815 As @code{fixits-v1}, but columns are expressed as display columns,
37816 as per @option{-fdiagnostics-column-unit=display}.
37817 @end table
37818
37819 @end table
37820
37821 @noindent
37822 Some additional environment variables affect the behavior of the
37823 preprocessor.
37824
37825 @include cppenv.texi
37826
37827 @c man end
37828
37829 @node Precompiled Headers
37830 @section Using Precompiled Headers
37831 @cindex precompiled headers
37832 @cindex speed of compilation
37833
37834 Often large projects have many header files that are included in every
37835 source file. The time the compiler takes to process these header files
37836 over and over again can account for nearly all of the time required to
37837 build the project. To make builds faster, GCC allows you to
37838 @dfn{precompile} a header file.
37839
37840 To create a precompiled header file, simply compile it as you would any
37841 other file, if necessary using the @option{-x} option to make the driver
37842 treat it as a C or C++ header file. You may want to use a
37843 tool like @command{make} to keep the precompiled header up-to-date when
37844 the headers it contains change.
37845
37846 A precompiled header file is searched for when @code{#include} is
37847 seen in the compilation. As it searches for the included file
37848 (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
37849 compiler looks for a precompiled header in each directory just before it
37850 looks for the include file in that directory. The name searched for is
37851 the name specified in the @code{#include} with @samp{.gch} appended. If
37852 the precompiled header file cannot be used, it is ignored.
37853
37854 For instance, if you have @code{#include "all.h"}, and you have
37855 @file{all.h.gch} in the same directory as @file{all.h}, then the
37856 precompiled header file is used if possible, and the original
37857 header is used otherwise.
37858
37859 Alternatively, you might decide to put the precompiled header file in a
37860 directory and use @option{-I} to ensure that directory is searched
37861 before (or instead of) the directory containing the original header.
37862 Then, if you want to check that the precompiled header file is always
37863 used, you can put a file of the same name as the original header in this
37864 directory containing an @code{#error} command.
37865
37866 This also works with @option{-include}. So yet another way to use
37867 precompiled headers, good for projects not designed with precompiled
37868 header files in mind, is to simply take most of the header files used by
37869 a project, include them from another header file, precompile that header
37870 file, and @option{-include} the precompiled header. If the header files
37871 have guards against multiple inclusion, they are skipped because
37872 they've already been included (in the precompiled header).
37873
37874 If you need to precompile the same header file for different
37875 languages, targets, or compiler options, you can instead make a
37876 @emph{directory} named like @file{all.h.gch}, and put each precompiled
37877 header in the directory, perhaps using @option{-o}. It doesn't matter
37878 what you call the files in the directory; every precompiled header in
37879 the directory is considered. The first precompiled header
37880 encountered in the directory that is valid for this compilation is
37881 used; they're searched in no particular order.
37882
37883 There are many other possibilities, limited only by your imagination,
37884 good sense, and the constraints of your build system.
37885
37886 A precompiled header file can be used only when these conditions apply:
37887
37888 @itemize
37889 @item
37890 Only one precompiled header can be used in a particular compilation.
37891
37892 @item
37893 A precompiled header cannot be used once the first C token is seen. You
37894 can have preprocessor directives before a precompiled header; you cannot
37895 include a precompiled header from inside another header.
37896
37897 @item
37898 The precompiled header file must be produced for the same language as
37899 the current compilation. You cannot use a C precompiled header for a C++
37900 compilation.
37901
37902 @item
37903 The precompiled header file must have been produced by the same compiler
37904 binary as the current compilation is using.
37905
37906 @item
37907 Any macros defined before the precompiled header is included must
37908 either be defined in the same way as when the precompiled header was
37909 generated, or must not affect the precompiled header, which usually
37910 means that they don't appear in the precompiled header at all.
37911
37912 The @option{-D} option is one way to define a macro before a
37913 precompiled header is included; using a @code{#define} can also do it.
37914 There are also some options that define macros implicitly, like
37915 @option{-O} and @option{-Wdeprecated}; the same rule applies to macros
37916 defined this way.
37917
37918 @item If debugging information is output when using the precompiled
37919 header, using @option{-g} or similar, the same kind of debugging information
37920 must have been output when building the precompiled header. However,
37921 a precompiled header built using @option{-g} can be used in a compilation
37922 when no debugging information is being output.
37923
37924 @item The same @option{-m} options must generally be used when building
37925 and using the precompiled header. @xref{Submodel Options},
37926 for any cases where this rule is relaxed.
37927
37928 @item Each of the following options must be the same when building and using
37929 the precompiled header:
37930
37931 @gccoptlist{-fexceptions}
37932
37933 @item
37934 Some other command-line options starting with @option{-f},
37935 @option{-p}, or @option{-O} must be defined in the same way as when
37936 the precompiled header was generated. At present, it's not clear
37937 which options are safe to change and which are not; the safest choice
37938 is to use exactly the same options when generating and using the
37939 precompiled header. The following are known to be safe:
37940
37941 @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock
37942 -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
37943 -fsched-verbose=@var{number} -fschedule-insns -fvisibility=
37944 -pedantic-errors}
37945
37946 @item Address space layout randomization (ASLR) can lead to not binary identical
37947 PCH files. If you rely on stable PCH file contents disable ASLR when generating
37948 PCH files.
37949
37950 @end itemize
37951
37952 For all of these except the last, the compiler automatically
37953 ignores the precompiled header if the conditions aren't met. If you
37954 find an option combination that doesn't work and doesn't cause the
37955 precompiled header to be ignored, please consider filing a bug report,
37956 see @ref{Bugs}.
37957
37958 If you do use differing options when generating and using the
37959 precompiled header, the actual behavior is a mixture of the
37960 behavior for the options. For instance, if you use @option{-g} to
37961 generate the precompiled header but not when using it, you may or may
37962 not get debugging information for routines in the precompiled header.
37963
37964 @node C++ Modules
37965 @section C++ Modules
37966 @cindex speed of compilation
37967
37968 Modules are a C++20 language feature. As the name suggests, they
37969 provide a modular compilation system, intending to provide both
37970 faster builds and better library isolation. The ``Merging Modules''
37971 paper @uref{https://wg21.link/p1103}, provides the easiest to read set
37972 of changes to the standard, although it does not capture later
37973 changes.
37974
37975 @emph{G++'s modules support is not complete.} Other than bugs, the
37976 known missing pieces are:
37977
37978 @table @emph
37979
37980 @item Private Module Fragment
37981 The Private Module Fragment is recognized, but an error is emitted.
37982
37983 @item Partition definition visibility rules
37984 Entities may be defined in implementation partitions, and those
37985 definitions are not available outside of the module. This is not
37986 implemented, and the definitions are available to extra-module use.
37987
37988 @item Textual merging of reachable GM entities
37989 Entities may be multiply defined across different header-units.
37990 These must be de-duplicated, and this is implemented across imports,
37991 or when an import redefines a textually-defined entity. However the
37992 reverse is not implemented---textually redefining an entity that has
37993 been defined in an imported header-unit. A redefinition error is
37994 emitted.
37995
37996 @item Translation-Unit local referencing rules
37997 Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
37998 (@uref{https://wg21.link/p2003}) add limitations on which entities an
37999 exported region may reference (for instance, the entities an exported
38000 template definition may reference). These are not fully implemented.
38001
38002 @item Standard Library Header Units
38003 The Standard Library is not provided as importable header units. If
38004 you want to import such units, you must explicitly build them first.
38005 If you do not do this with care, you may have multiple declarations,
38006 which the module machinery must merge---compiler resource usage can be
38007 affected by how you partition header files into header units.
38008
38009 @end table
38010
38011 Modular compilation is @emph{not} enabled with just the
38012 @option{-std=c++20} option. You must explicitly enable it with the
38013 @option{-fmodules-ts} option. It is independent of the language
38014 version selected, although in pre-C++20 versions, it is of course an
38015 extension.
38016
38017 No new source file suffixes are required. A few suffixes preferred
38018 for module interface units by other compilers (e.g. @samp{.ixx},
38019 @samp{.cppm}) are supported, but files with these suffixes are treated
38020 the same as any other C++ source file.
38021
38022 Compiling a module interface unit produces an additional output (to
38023 the assembly or object file), called a Compiled Module Interface
38024 (CMI). This encodes the exported declarations of the module.
38025 Importing a module reads in the CMI. The import graph is a Directed
38026 Acyclic Graph (DAG). You must build imports before the importer.
38027
38028 Header files may themselves be compiled to header units, which are a
38029 transitional ability aiming at faster compilation. The
38030 @option{-fmodule-header} option is used to enable this, and implies
38031 the @option{-fmodules} option. These CMIs are named by the fully
38032 resolved underlying header file, and thus may be a complete pathname
38033 containing subdirectories. If the header file is found at an absolute
38034 pathname, the CMI location is still relative to a CMI root directory.
38035
38036 As header files often have no suffix, you commonly have to specify a
38037 @option{-x} option to tell the compiler the source is a header file.
38038 You may use @option{-x c++-header}, @option{-x c++-user-header} or
38039 @option{-x c++-system-header}. When used in conjunction with
38040 @option{-fmodules}, these all imply an appropriate
38041 @option{-fmodule-header} option. The latter two variants use the
38042 user or system include path to search for the file specified. This
38043 allows you to, for instance, compile standard library header files as
38044 header units, without needing to know exactly where they are
38045 installed. Specifying the language as one of these variants also
38046 inhibits output of the object file, as header files have no associated
38047 object file.
38048
38049 Alternately, or for a module interface unit in an installed location,
38050 you can use @option{-fsearch-include-path} to specify that the main
38051 source file should be found on the include path rather than the
38052 current directory.
38053
38054 Header units can be used in much the same way as precompiled headers
38055 (@pxref{Precompiled Headers}), but with fewer restrictions: an
38056 #include that is translated to a header unit import can appear at any
38057 point in the source file, and multiple header units can be used
38058 together. In particular, the @option{-include} strategy works: with
38059 the bits/stdc++.h header used for libstdc++ precompiled headers you
38060 can
38061
38062 @smallexample
38063 g++ -fmodules -x c++-system-header -c bits/stdc++.h
38064 g++ -fmodules -include bits/stdc++.h mycode.C
38065 @end smallexample
38066
38067 and any standard library #includes in mycode.C will be skipped,
38068 because the import brought in the whole library. This can be a simple
38069 way to use modules to speed up compilation without any code changes.
38070
38071 The @option{-fmodule-only} option disables generation of the
38072 associated object file for compiling a module interface. Only the CMI
38073 is generated. This option is implied when using the
38074 @option{-fmodule-header} option.
38075
38076 The @option{-flang-info-include-translate} and
38077 @option{-flang-info-include-translate-not} options notes whether
38078 include translation occurs or not. With no argument, the first will
38079 note all include translation. The second will note all
38080 non-translations of include files not known to intentionally be
38081 textual. With an argument, queries about include translation of a
38082 header files with that particular trailing pathname are noted. You
38083 may repeat this form to cover several different header files. This
38084 option may be helpful in determining whether include translation is
38085 happening---if it is working correctly, it behaves as if it isn't
38086 there at all.
38087
38088 The @option{-flang-info-module-cmi} option can be used to determine
38089 where the compiler is reading a CMI from. Without the option, the
38090 compiler is silent when such a read is successful. This option has an
38091 optional argument, which will restrict the notification to just the
38092 set of named modules or header units specified.
38093
38094 The @option{-Winvalid-imported-macros} option causes all imported macros
38095 to be resolved at the end of compilation. Without this, imported
38096 macros are only resolved when expanded or (re)defined. This option
38097 detects conflicting import definitions for all macros.
38098
38099 For details of the @option{-fmodule-mapper} family of options,
38100 @pxref{C++ Module Mapper}.
38101
38102 @menu
38103 * C++ Module Mapper:: Module Mapper
38104 * C++ Module Preprocessing:: Module Preprocessing
38105 * C++ Compiled Module Interface:: Compiled Module Interface
38106 @end menu
38107
38108 @node C++ Module Mapper
38109 @subsection Module Mapper
38110 @cindex C++ Module Mapper
38111
38112 A module mapper provides a server or file that the compiler queries to
38113 determine the mapping between module names and CMI files. It is also
38114 used to build CMIs on demand. @emph{Mapper functionality is in its
38115 infancy and is intended for experimentation with build system
38116 interactions.}
38117
38118 You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
38119 option or @env{CXX_MODULE_MAPPER} environment variable. The value may
38120 have one of the following forms:
38121
38122 @table @gcctabopt
38123
38124 @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
38125 An optional hostname and a numeric port number to connect to. If the
38126 hostname is omitted, the loopback address is used. If the hostname
38127 corresponds to multiple IPV6 addresses, these are tried in turn, until
38128 one is successful. If your host lacks IPv6, this form is
38129 non-functional. If you must use IPv4 use
38130 @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
38131
38132 @item =@var{socket}@r{[}?@var{ident}@r{]}
38133 A local domain socket. If your host lacks local domain sockets, this
38134 form is non-functional.
38135
38136 @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
38137 A program to spawn, and communicate with on its stdin/stdout streams.
38138 Your @var{PATH} environment variable is searched for the program.
38139 Arguments are separated by space characters, (it is not possible for
38140 one of the arguments delivered to the program to contain a space). An
38141 exception is if @var{program} begins with @@. In that case
38142 @var{program} (sans @@) is looked for in the compiler's internal
38143 binary directory. Thus the sample mapper-server can be specified
38144 with @code{@@g++-mapper-server}.
38145
38146 @item <>@r{[}?@var{ident}@r{]}
38147 @item <>@var{inout}@r{[}?@var{ident}@r{]}
38148 @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
38149 Named pipes or file descriptors to communicate over. The first form,
38150 @option{<>}, communicates over stdin and stdout. The other forms
38151 allow you to specify a file descriptor or name a pipe. A numeric value
38152 is interpreted as a file descriptor, otherwise named pipe is opened.
38153 The second form specifies a bidirectional pipe and the last form
38154 allows specifying two independent pipes. Using file descriptors
38155 directly in this manner is fragile in general, as it can require the
38156 cooperation of intermediate processes. In particular using stdin &
38157 stdout is fraught with danger as other compiler options might also
38158 cause the compiler to read stdin or write stdout, and it can have
38159 unfortunate interactions with signal delivery from the terminal.
38160
38161 @item @var{file}@r{[}?@var{ident}@r{]}
38162 A mapping file consisting of space-separated module-name, filename
38163 pairs, one per line. Only the mappings for the direct imports and any
38164 module export name need be provided. If other mappings are provided,
38165 they override those stored in any imported CMI files. A repository
38166 root may be specified in the mapping file by using @samp{$root} as the
38167 module name in the first active line. Use of this option will disable
38168 any default module->CMI name mapping.
38169
38170 @end table
38171
38172 As shown, an optional @var{ident} may suffix the first word of the
38173 option, indicated by a @samp{?} prefix. The value is used in the
38174 initial handshake with the module server, or to specify a prefix on
38175 mapping file lines. In the server case, the main source file name is
38176 used if no @var{ident} is specified. In the file case, all non-blank
38177 lines are significant, unless a value is specified, in which case only
38178 lines beginning with @var{ident} are significant. The @var{ident}
38179 must be separated by whitespace from the module name. Be aware that
38180 @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
38181 significant to the shell, and therefore may need quoting.
38182
38183 The mapper is connected to or loaded lazily, when the first module
38184 mapping is required. The networking protocols are only supported on
38185 hosts that provide networking. If no mapper is specified a default is
38186 provided.
38187
38188 A project-specific mapper is expected to be provided by the build
38189 system that invokes the compiler. It is not expected that a
38190 general-purpose server is provided for all compilations. As such, the
38191 server will know the build configuration, the compiler it invoked, and
38192 the environment (such as working directory) in which that is
38193 operating. As it may parallelize builds, several compilations may
38194 connect to the same socket.
38195
38196 The default mapper generates CMI files in a @samp{gcm.cache}
38197 directory. CMI files have a @samp{.gcm} suffix. The module unit name
38198 is used directly to provide the basename. Header units construct a
38199 relative path using the underlying header file name. If the path is
38200 already relative, a @samp{,} directory is prepended. Internal
38201 @samp{..} components are translated to @samp{,,}. No attempt is made
38202 to canonicalize these filenames beyond that done by the preprocessor's
38203 include search algorithm, as in general it is ambiguous when symbolic
38204 links are present.
38205
38206 The mapper protocol was published as ``A Module Mapper''
38207 @uref{https://wg21.link/p1184}. The implementation is provided by
38208 @command{libcody}, @uref{https://github.com/urnathan/libcody},
38209 which specifies the canonical protocol definition. A proof of concept
38210 server implementation embedded in @command{make} was described in
38211 ''Make Me A Module'', @uref{https://wg21.link/p1602}.
38212
38213 @node C++ Module Preprocessing
38214 @subsection Module Preprocessing
38215 @cindex C++ Module Preprocessing
38216
38217 Modules affect preprocessing because of header units and include
38218 translation. Some uses of the preprocessor as a separate step either
38219 do not produce a correct output, or require CMIs to be available.
38220
38221 Header units import macros. These macros can affect later conditional
38222 inclusion, which therefore can cascade to differing import sets. When
38223 preprocessing, it is necessary to load the CMI. If a header unit is
38224 unavailable, the preprocessor issues a warning and continue (when
38225 not just preprocessing, an error is emitted). Detecting such imports
38226 requires preprocessor tokenization of the input stream to phase 4
38227 (macro expansion).
38228
38229 Include translation converts @code{#include}, @code{#include_next} and
38230 @code{#import} directives to internal @code{import} declarations.
38231 Whether a particular directive is translated is controlled by the
38232 module mapper. Header unit names are canonicalized during
38233 preprocessing.
38234
38235 Dependency information can be emitted for module import, extending the
38236 functionality of the various @option{-M} options. Detection of import
38237 declarations requires phase 4 handling of preprocessor directives, but
38238 does not require macro expansion, so it is not necessary to use
38239 @option{-MD}. See also @option{-fdeps-*} for an alternate format for
38240 module dependency information.
38241
38242 The @option{-save-temps} option uses @option{-fdirectives-only} for
38243 preprocessing, and preserve the macro definitions in the preprocessed
38244 output. Usually you also want to use this option when explicitly
38245 preprocessing a header-unit, or consuming such preprocessed output:
38246
38247 @smallexample
38248 g++ -fmodules -E -fdirectives-only my-header.hh -o my-header.ii
38249 g++ -x c++-header -fmodules -fpreprocessed -fdirectives-only my-header.ii
38250 @end smallexample
38251
38252 @node C++ Compiled Module Interface
38253 @subsection Compiled Module Interface
38254 @cindex C++ Compiled Module Interface
38255
38256 CMIs are an additional artifact when compiling named module
38257 interfaces, partitions or header units. These are read when
38258 importing. CMI contents are implementation-specific, and in GCC's
38259 case tied to the compiler version. Consider them a rebuildable cache
38260 artifact, not a distributable object.
38261
38262 When creating an output CMI, any missing directory components are
38263 created in a manner that is safe for concurrent builds creating
38264 multiple, different, CMIs within a common subdirectory tree.
38265
38266 CMI contents are written to a temporary file, which is then atomically
38267 renamed. Observers either see old contents (if there is an
38268 existing file), or complete new contents. They do not observe the
38269 CMI during its creation. This is unlike object file writing, which
38270 may be observed by an external process.
38271
38272 CMIs are read in lazily, if the host OS provides @code{mmap}
38273 functionality. Generally blocks are read when name lookup or template
38274 instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
38275 option may be used.
38276
38277 The @option{--param lazy-modules=@var{n}} parameter controls the limit
38278 on the number of concurrently open module files during lazy loading.
38279 Should more modules be imported, an LRU algorithm is used to determine
38280 which files to close---until that file is needed again. This limit
38281 may be exceeded with deep module dependency hierarchies. With large
38282 code bases there may be more imports than the process limit of file
38283 descriptors. By default, the limit is a few less than the per-process
38284 file descriptor hard limit, if that is determinable.@footnote{Where
38285 applicable the soft limit is incremented as needed towards the hard limit.}
38286
38287 GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
38288 You may use @command{readelf} to inspect them, although section
38289 contents are largely undecipherable. There is a section named
38290 @code{.gnu.c++.README}, which contains human-readable text. Other
38291 than the first line, each line consists of @code{@var{tag}: @code{value}}
38292 tuples.
38293
38294 @smallexample
38295 > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
38296
38297 String dump of section '.gnu.c++.README':
38298 [ 0] GNU C++ primary module interface
38299 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
38300 [ 6f] version: 2020/11/16-04:54
38301 [ 89] module: foo
38302 [ 95] source: c_b.ii
38303 [ a4] dialect: C++20/coroutines
38304 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
38305 [ ee] repository: gcm.cache
38306 [ 104] buildtime: 2020/11/16 15:03:21 UTC
38307 [ 127] localtime: 2020/11/16 07:03:21 PST
38308 [ 14a] export: foo:part1 foo-part1.gcm
38309 @end smallexample
38310
38311 Amongst other things, this lists the source that was built, C++
38312 dialect used and imports of the module.@footnote{The precise contents
38313 of this output may change.} The timestamp is the same value as that
38314 provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
38315 explicitly specified with the environment variable
38316 @code{SOURCE_DATE_EPOCH}. For further details
38317 @pxref{Environment Variables}.
38318
38319 A set of related CMIs may be copied, provided the relative pathnames
38320 are preserved.
38321
38322 The @code{.gnu.c++.README} contents do not affect CMI integrity, and
38323 it may be removed or altered. The section numbering of the sections
38324 whose names do not begin with @code{.gnu.c++.}, or are not the string
38325 section is significant and must not be altered.