]> gcc.gnu.org Git - gcc.git/blame - gcc/doc/invoke.texi
Add -mcpu=power11 support.
[gcc.git] / gcc / doc / invoke.texi
CommitLineData
a945c346 1@c Copyright (C) 1988-2024 Free Software Foundation, Inc.
d77de738
ML
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
4e053a7e 11Copyright @copyright{} 1988-2024 Free Software Foundation, Inc.
d77de738
ML
12
13Permission is granted to copy, distribute and/or modify this document
14under the terms of the GNU Free Documentation License, Version 1.3 or
15any later version published by the Free Software Foundation; with the
16Invariant Sections being ``GNU General Public License'' and ``Funding
17Free Software'', the Front-Cover texts being (a) (see below), and with
18the Back-Cover Texts being (b) (see below). A copy of the license is
19included 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
35gcc [@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
43Only the most useful options are listed here; see below for the
44remainder. @command{g++} accepts mostly the same options as @command{gcc}.
45@c man end
46@c man begin SEEALSO
47gpl(7), gfdl(7), fsf-funding(7),
48cpp(1), gcov(1), as(1), ld(1), gdb(1)
49and 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
53For instructions on reporting bugs, see
54@w{@value{BUGURL}}.
55@c man end
56@c man begin AUTHOR
57See the Info entry for @command{gcc}, or
58@w{@uref{https://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
59for 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
70When you invoke GCC, it normally does preprocessing, compilation,
71assembly and linking. The ``overall options'' allow you to stop this
72process at an intermediate stage. For example, the @option{-c} option
73says not to run the linker. Then the output consists of object files
74output by the assembler.
75@xref{Overall Options,,Options Controlling the Kind of Output}.
76
77Other options are passed on to one or more stages of processing. Some options
78control the preprocessor and others the compiler itself. Yet other
79options control the assembler and linker; most of these are not
80documented here, since you rarely need to use any of them.
81
82@cindex C compilation options
83Most of the command-line options that you can use with GCC are useful
84for C programs; when an option is only useful with another language
85(usually C++), the explanation says so explicitly. If the description
86for a particular option does not mention a source language, you can use
87that 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
94The 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.
97When you compile C++ programs, you should invoke GCC as @command{g++}
98instead. @xref{Invoking G++,,Compiling C++ Programs},
99for information about the differences in behavior between @command{gcc}
100and @command{g++} when compiling C++ programs.
101
102@cindex grouping options
103@cindex options, grouping
104The @command{gcc} program accepts options and file names as operands. Many
105options have multi-letter names; therefore multiple single-letter options
106may @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
111You can mix options and other arguments. For the most part, the order
112you use doesn't matter. Order does matter when you use several
113options of the same kind; for example, if you specify @option{-L} more
114than once, the directories are searched in the order specified. Also,
115the placement of the @option{-l} option is significant.
116
117Many 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
120these have both positive and negative forms; the negative form of
121@option{-ffoo} is @option{-fno-foo}. This manual documents
122only one of these two forms, whichever one is not the default.
123
124Some options take one or more arguments typically separated either
125by a space or by the equals sign (@samp{=}) from the option name.
126Unless documented otherwise, an argument can be either numeric or
127a string. Numeric arguments must typically be small unsigned decimal
128or hexadecimal integers. Hexadecimal arguments must begin with
129the @samp{0x} prefix. Arguments to options that specify a size
130threshold of some sort may be arbitrarily large decimal or hexadecimal
131integers followed by a byte size suffix designating a multiple of bytes
132such 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
135designated by @var{byte-size} in the following text. Refer to the NIST,
136IEC, and other relevant national and international standards for the full
137listing 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* Diagnostic Message Formatting Options:: Controlling how diagnostics should
154 be formatted.
155* Warning Options:: How picky should the compiler be?
156* Static Analyzer Options:: More expensive warnings.
157* Debugging Options:: Producing debuggable code.
158* Optimize Options:: How much optimization?
159* Instrumentation Options:: Enabling profiling and extra run-time error checking.
160* Preprocessor Options:: Controlling header files and macro definitions.
161 Also, getting dependency information for Make.
162* Assembler Options:: Passing options to the assembler.
163* Link Options:: Specifying libraries and so on.
164* Directory Options:: Where to find header files and libraries.
165 Where to find the compiler executable files.
166* Code Gen Options:: Specifying conventions for function calls, data layout
167 and register usage.
168* Developer Options:: Printing GCC configuration info, statistics, and
169 debugging dumps.
170* Submodel Options:: Target-specific options, such as compiling for a
171 specific processor variant.
172* Spec Files:: How to pass switches to sub-processes.
173* Environment Variables:: Env vars that affect GCC.
174* Precompiled Headers:: Compiling a header once, and using it many times.
175* C++ Modules:: Experimental C++20 module system.
176@end menu
177
178@c man begin OPTIONS
179
180@node Option Summary
181@section Option Summary
182
183Here is a summary of all the options, grouped by type. Explanations are
184in the following sections.
185
186@table @emph
187@item Overall Options
188@xref{Overall Options,,Options Controlling the Kind of Output}.
43b72ede
AA
189@gccoptlist{-c -S -E -o @var{file}
190-dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf}
191-dumpdir @var{dumppfx} -x @var{language}
192-v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version
193-pass-exit-codes -pipe -specs=@var{file} -wrapper
194@@@var{file} -ffile-prefix-map=@var{old}=@var{new} -fcanon-prefix-map
195-fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg}
d77de738
ML
196-fdump-ada-spec@r{[}-slim@r{]} -fada-spec-parent=@var{unit} -fdump-go-spec=@var{file}}
197
198@item C Language Options
199@xref{C Dialect Options,,Options Controlling C Dialect}.
43b72ede
AA
200@gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename}
201-fno-asm
202-fno-builtin -fno-builtin-@var{function} -fcond-mismatch
203-ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted
204-flax-vector-conversions -fms-extensions
205-foffload=@var{arg} -foffload-options=@var{arg}
206-fopenacc -fopenacc-dim=@var{geom}
207-fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]}
208-fpermitted-flt-eval-methods=@var{standard}
209-fplan9-extensions -fsigned-bitfields -funsigned-bitfields
eb71695f 210-fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}]
d77de738
ML
211-fsso-struct=@var{endianness}}
212
213@item C++ Language Options
214@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
43b72ede
AA
215@gccoptlist{-fabi-version=@var{n} -fno-access-control
216-faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new
217-fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n}
218-fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n}
219-fno-elide-constructors
220-fno-enforce-eh-specs
221-fno-gnu-keywords
1f1c4322 222-fno-immediate-escalation
43b72ede
AA
223-fno-implicit-templates
224-fno-implicit-inline-templates
225-fno-implement-inlines
226-fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts
227-fmodule-implicit-inline
228-fno-module-lazy
229-fmodule-mapper=@var{specification}
230-fmodule-version-ignore
231-fms-extensions
232-fnew-inheriting-ctors
233-fnew-ttp-matching
234-fno-nonansi-builtins -fnothrow-opt -fno-operator-names
ef10cb86 235-fno-optional-diags
43b72ede
AA
236-fno-pretty-templates
237-fno-rtti -fsized-deallocation
238-ftemplate-backtrace-limit=@var{n}
239-ftemplate-depth=@var{n}
240-fno-threadsafe-statics -fuse-cxa-atexit
241-fno-weak -nostdinc++
242-fvisibility-inlines-hidden
243-fvisibility-ms-compat
244-fext-numeric-literals
245-flang-info-include-translate@r{[}=@var{header}@r{]}
246-flang-info-include-translate-not
247-flang-info-module-cmi@r{[}=@var{module}@r{]}
248-stdlib=@var{libstdc++,libc++}
249-Wabi-tag -Wcatch-value -Wcatch-value=@var{n}
250-Wno-class-conversion -Wclass-memaccess
251-Wcomma-subscript -Wconditionally-supported
252-Wno-conversion-null -Wctad-maybe-unsupported
253-Wctor-dtor-privacy -Wdangling-reference
254-Wno-delete-incomplete
255-Wdelete-non-virtual-dtor -Wno-deprecated-array-compare
256-Wdeprecated-copy -Wdeprecated-copy-dtor
257-Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion
b106f11d 258-Weffc++ -Wno-elaborated-enum-base
08edf85f 259-Wno-exceptions -Wextra-semi -Wno-global-module -Wno-inaccessible-base
43b72ede
AA
260-Wno-inherited-variadic-ctor -Wno-init-list-lifetime
261-Winvalid-constexpr -Winvalid-imported-macros
262-Wno-invalid-offsetof -Wno-literal-suffix
263-Wmismatched-new-delete -Wmismatched-tags
264-Wmultiple-inheritance -Wnamespaces -Wnarrowing
265-Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor
266-Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n}
267-Wrange-loop-construct -Wredundant-move -Wredundant-tags
268-Wreorder -Wregister
269-Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates
270-Wno-non-template-friend -Wold-style-cast
271-Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo
272-Wsized-deallocation -Wsuggest-final-methods
cff174fa 273-Wsuggest-final-types -Wsuggest-override -Wno-template-id-cdtor
25bb8a40 274-Wno-terminate -Wno-vexing-parse -Wvirtual-inheritance
d77de738
ML
275-Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant}
276
277@item Objective-C and Objective-C++ Language Options
278@xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling
279Objective-C and Objective-C++ Dialects}.
43b72ede
AA
280@gccoptlist{-fconstant-string-class=@var{class-name}
281-fgnu-runtime -fnext-runtime
282-fno-nil-receivers
283-fobjc-abi-version=@var{n}
284-fobjc-call-cxx-cdtors
285-fobjc-direct-dispatch
286-fobjc-exceptions
287-fobjc-gc
288-fobjc-nilcheck
289-fobjc-std=objc1
290-fno-local-ivars
291-fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
292-freplace-objc-classes
293-fzero-link
294-gen-decls
295-Wassign-intercept -Wno-property-assign-default
296-Wno-protocol -Wobjc-root-class -Wselector
297-Wstrict-selector-match
d77de738
ML
298-Wundeclared-selector}
299
300@item Diagnostic Message Formatting Options
301@xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
43b72ede
AA
302@gccoptlist{-fmessage-length=@var{n}
303-fdiagnostics-plain-output
304-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}
305-fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]}
306-fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]}
307-fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]}
3bd8241a 308-fno-diagnostics-json-formatting
43b72ede
AA
309-fno-diagnostics-show-option -fno-diagnostics-show-caret
310-fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers
311-fno-diagnostics-show-cwe
312-fno-diagnostics-show-rule
313-fdiagnostics-minimum-margin-width=@var{width}
314-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
315-fdiagnostics-show-template-tree -fno-elide-type
316-fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]}
317-fdiagnostics-show-path-depths
318-fno-show-column
319-fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]}
320-fdiagnostics-column-origin=@var{origin}
4f01ae37
DM
321-fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}
322-fdiagnostics-text-art-charset=@r{[}none@r{|}ascii@r{|}unicode@r{|}emoji@r{]}}
d77de738
ML
323
324@item Warning Options
325@xref{Warning Options,,Options to Request or Suppress Warnings}.
43b72ede 326@gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic
ef10cb86 327-pedantic-errors -fpermissive
43b72ede
AA
328-w -Wextra -Wall -Wabi=@var{n}
329-Waddress -Wno-address-of-packed-member -Waggregate-return
e7dd72ae 330-Walloc-size -Walloc-size-larger-than=@var{byte-size} -Walloc-zero
43b72ede
AA
331-Walloca -Walloca-larger-than=@var{byte-size}
332-Wno-aggressive-loop-optimizations
333-Warith-conversion
334-Warray-bounds -Warray-bounds=@var{n} -Warray-compare
8fd992a3 335-Warray-parameter -Warray-parameter=@var{n}
43b72ede
AA
336-Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias
337-Wno-attribute-warning
338-Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
339-Wbool-compare -Wbool-operation
340-Wno-builtin-declaration-mismatch
341-Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat
fad61bf7 342-Wc11-c23-compat
43b72ede
AA
343-Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat
344-Wc++20-compat
345-Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions
346-Wno-c++20-extensions -Wno-c++23-extensions
e7dd72ae 347-Wcalloc-transposed-args
43b72ede
AA
348-Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual
349-Wchar-subscripts
350-Wclobbered -Wcomment
e1f45bea 351-Wcompare-distinct-pointer-types
43b72ede
AA
352-Wno-complain-wrong-lang
353-Wconversion -Wno-coverage-mismatch -Wno-cpp
354-Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n}
355-Wdate-time
356-Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init
357-Wdisabled-optimization
358-Wno-discarded-array-qualifiers -Wno-discarded-qualifiers
359-Wno-div-by-zero -Wdouble-promotion
360-Wduplicated-branches -Wduplicated-cond
361-Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion
362-Wenum-int-mismatch
363-Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors
44e3f39a 364-Wflex-array-member-not-at-end
43b72ede
AA
365-Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2
366-Wno-format-contains-nul -Wno-format-extra-args
367-Wformat-nonliteral -Wformat-overflow=@var{n}
368-Wformat-security -Wformat-signedness -Wformat-truncation=@var{n}
369-Wformat-y2k -Wframe-address
370-Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object
371-Wno-if-not-aligned -Wno-ignored-attributes
24592abd 372-Wignored-qualifiers -Wno-incompatible-pointer-types -Whardened
43b72ede
AA
373-Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n}
374-Wno-implicit-function-declaration -Wno-implicit-int
375-Winfinite-recursion
376-Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context
377-Wno-int-to-pointer-cast -Wno-invalid-memory-model
378-Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init
379-Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op
380-Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized
381-Wmemset-elt-size -Wmemset-transposed-args
382-Wmisleading-indentation -Wmissing-attributes -Wmissing-braces
383-Wmissing-field-initializers -Wmissing-format-attribute
384-Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile
385-Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare
386-Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
387-Wnull-dereference -Wno-odr
388-Wopenacc-parallelism
449b6b81 389-Wopenmp -Wopenmp-simd
43b72ede
AA
390-Wno-overflow -Woverlength-strings -Wno-override-init-side-effects
391-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
392-Wparentheses -Wno-pedantic-ms-format
393-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
394-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls
395-Wrestrict -Wno-return-local-addr -Wreturn-type
396-Wno-scalar-storage-order -Wsequence-point
397-Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local
398-Wno-shadow-ivar
399-Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value
400-Wno-shift-overflow -Wshift-overflow=@var{n}
401-Wsign-compare -Wsign-conversion
402-Wno-sizeof-array-argument
403-Wsizeof-array-div
404-Wsizeof-pointer-div -Wsizeof-pointer-memaccess
405-Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing
406-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n}
407-Wstring-compare
408-Wno-stringop-overflow -Wno-stringop-overread
eb71695f 409-Wno-stringop-truncation -Wstrict-flex-arrays
43b72ede
AA
410-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]}
411-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum
412-Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand
413-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs
9a5e8f9d 414-Wtrivial-auto-var-init -Wno-tsan -Wtype-limits -Wundef
43b72ede
AA
415-Wuninitialized -Wunknown-pragmas
416-Wunsuffixed-float-constants -Wunused
417-Wunused-but-set-parameter -Wunused-but-set-variable
418-Wunused-const-variable -Wunused-const-variable=@var{n}
419-Wunused-function -Wunused-label -Wunused-local-typedefs
420-Wunused-macros
421-Wunused-parameter -Wno-unused-result
422-Wunused-value -Wunused-variable
25bb8a40 423-Wuse-after-free -Wuse-after-free=@var{n} -Wuseless-cast
43b72ede
AA
424-Wno-varargs -Wvariadic-macros
425-Wvector-operation-performance
426-Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than
427-Wvolatile-register-var -Wwrite-strings
9a5e8f9d 428-Wno-xor-used-as-pow
d77de738
ML
429-Wzero-length-bounds}
430
431@item Static Analyzer Options
432@gccoptlist{
43b72ede
AA
433-fanalyzer
434-fanalyzer-call-summaries
435-fanalyzer-checker=@var{name}
436-fno-analyzer-feasibility
437-fanalyzer-fine-grained
ce8cdf5b 438-fanalyzer-show-events-in-system-headers
43b72ede
AA
439-fno-analyzer-state-merge
440-fno-analyzer-state-purge
441-fno-analyzer-suppress-followups
442-fanalyzer-transitivity
443-fno-analyzer-undo-inlining
444-fanalyzer-verbose-edges
445-fanalyzer-verbose-state-changes
446-fanalyzer-verbosity=@var{level}
447-fdump-analyzer
448-fdump-analyzer-callgraph
449-fdump-analyzer-exploded-graph
450-fdump-analyzer-exploded-nodes
451-fdump-analyzer-exploded-nodes-2
452-fdump-analyzer-exploded-nodes-3
453-fdump-analyzer-exploded-paths
454-fdump-analyzer-feasibility
841008d3 455-fdump-analyzer-infinite-loop
43b72ede
AA
456-fdump-analyzer-json
457-fdump-analyzer-state-purge
458-fdump-analyzer-stderr
459-fdump-analyzer-supergraph
460-fdump-analyzer-untracked
461-Wno-analyzer-double-fclose
462-Wno-analyzer-double-free
463-Wno-analyzer-exposure-through-output-file
464-Wno-analyzer-exposure-through-uninit-copy
465-Wno-analyzer-fd-access-mode-mismatch
466-Wno-analyzer-fd-double-close
467-Wno-analyzer-fd-leak
468-Wno-analyzer-fd-phase-mismatch
469-Wno-analyzer-fd-type-mismatch
470-Wno-analyzer-fd-use-after-close
471-Wno-analyzer-fd-use-without-check
472-Wno-analyzer-file-leak
473-Wno-analyzer-free-of-non-heap
474-Wno-analyzer-imprecise-fp-arithmetic
841008d3 475-Wno-analyzer-infinite-loop
43b72ede
AA
476-Wno-analyzer-infinite-recursion
477-Wno-analyzer-jump-through-null
478-Wno-analyzer-malloc-leak
479-Wno-analyzer-mismatching-deallocation
480-Wno-analyzer-null-argument
481-Wno-analyzer-null-dereference
482-Wno-analyzer-out-of-bounds
034d99e8 483-Wno-analyzer-overlapping-buffers
43b72ede
AA
484-Wno-analyzer-possible-null-argument
485-Wno-analyzer-possible-null-dereference
486-Wno-analyzer-putenv-of-auto-var
487-Wno-analyzer-shift-count-negative
488-Wno-analyzer-shift-count-overflow
489-Wno-analyzer-stale-setjmp-buffer
490-Wno-analyzer-tainted-allocation-size
491-Wno-analyzer-tainted-assertion
492-Wno-analyzer-tainted-array-index
493-Wno-analyzer-tainted-divisor
494-Wno-analyzer-tainted-offset
495-Wno-analyzer-tainted-size
08b7462d 496-Wanalyzer-symbol-too-complex
43b72ede 497-Wanalyzer-too-complex
f65f63c4 498-Wno-analyzer-undefined-behavior-strtok
43b72ede
AA
499-Wno-analyzer-unsafe-call-within-signal-handler
500-Wno-analyzer-use-after-free
501-Wno-analyzer-use-of-pointer-in-stale-stack-frame
502-Wno-analyzer-use-of-uninitialized-value
503-Wno-analyzer-va-arg-type-mismatch
504-Wno-analyzer-va-list-exhausted
505-Wno-analyzer-va-list-leak
506-Wno-analyzer-va-list-use-after-va-end
507-Wno-analyzer-write-to-const
508-Wno-analyzer-write-to-string-literal
d77de738
ML
509}
510
511@item C and Objective-C-only Warning Options
43b72ede 512@gccoptlist{-Wbad-function-cast -Wmissing-declarations
ff9efa3f
FW
513-Wmissing-parameter-type -Wdeclaration-missing-parameter-type
514-Wmissing-prototypes -Wmissing-variable-declarations
ffc74822 515-Wnested-externs -Wold-style-declaration -Wold-style-definition
43b72ede 516-Wstrict-prototypes -Wtraditional -Wtraditional-conversion
d77de738
ML
517-Wdeclaration-after-statement -Wpointer-sign}
518
519@item Debugging Options
520@xref{Debugging Options,,Options for Debugging Your Program}.
43b72ede
AA
521@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version}
522-gbtf -gctf -gctf@var{level}
523-ggdb -grecord-gcc-switches -gno-record-gcc-switches
524-gstrict-dwarf -gno-strict-dwarf
525-gas-loc-support -gno-as-loc-support
526-gas-locview-support -gno-as-locview-support
3eeb4801 527-gcodeview
43b72ede
AA
528-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64
529-gstatement-frontiers -gno-statement-frontiers
530-gvariable-location-views -gno-variable-location-views
531-ginternal-reset-location-views -gno-internal-reset-location-views
532-ginline-points -gno-inline-points
533-gvms -gz@r{[}=@var{type}@r{]}
534-gsplit-dwarf -gdescribe-dies -gno-describe-dies
535-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section
536-fno-eliminate-unused-debug-types
537-femit-struct-debug-baseonly -femit-struct-debug-reduced
538-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
539-fno-eliminate-unused-debug-symbols -femit-class-debug-always
540-fno-merge-debug-strings -fno-dwarf2-cfi-asm
d77de738
ML
541-fvar-tracking -fvar-tracking-assignments}
542
543@item Optimization Options
544@xref{Optimize Options,,Options that Control Optimization}.
43b72ede
AA
545@gccoptlist{-faggressive-loop-optimizations
546-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
547-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
548-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
549-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
0f5a9a00 550-fmin-function-alignment=[@var{n}]
43b72ede
AA
551-fno-allocation-dce -fallow-store-data-races
552-fassociative-math -fauto-profile -fauto-profile[=@var{path}]
553-fauto-inc-dec -fbranch-probabilities
554-fcaller-saves
555-fcombine-stack-adjustments -fconserve-stack
04c9cf5c 556-ffold-mem-offsets
43b72ede
AA
557-fcompare-elim -fcprop-registers -fcrossjumping
558-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules
559-fcx-limited-range
560-fdata-sections -fdce -fdelayed-branch
561-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively
562-fdevirtualize-at-ltrans -fdse
563-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects
564-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style}
565-ffinite-loops
566-fforward-propagate -ffp-contract=@var{style} -ffunction-sections
567-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity
568-fgcse-sm -fhoist-adjacent-loads -fif-conversion
569-fif-conversion2 -findirect-inlining
1ff6d9f7 570-finline-stringops[=@var{fn}]
43b72ede
AA
571-finline-functions -finline-functions-called-once -finline-limit=@var{n}
572-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone
573-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const
574-fipa-reference -fipa-reference-addressable
575-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm}
576-flive-patching=@var{level}
577-fira-region=@var{region} -fira-hoist-pressure
578-fira-loop-pressure -fno-ira-share-save-slots
579-fno-ira-share-spill-slots
580-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute
581-fivopts -fkeep-inline-functions -fkeep-static-functions
582-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage
583-floop-block -floop-interchange -floop-strip-mine
584-floop-unroll-and-jam -floop-nest-optimize
585-floop-parallelize-all -flra-remat -flto -flto-compression-level
586-flto-partition=@var{alg} -fmerge-all-constants
587-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
588-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg
589-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
590-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole
591-fno-peephole2 -fno-printf-return-value -fno-sched-interblock
592-fno-sched-spec -fno-signed-zeros
593-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
594-fomit-frame-pointer -foptimize-sibling-calls
595-fpartial-inlining -fpeel-loops -fpredictive-commoning
596-fprefetch-loop-arrays
597-fprofile-correction
598-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training
599-fprofile-values -fprofile-reorder-functions
600-freciprocal-math -free -frename-registers -freorder-blocks
601-freorder-blocks-algorithm=@var{algorithm}
602-freorder-blocks-and-partition -freorder-functions
603-frerun-cse-after-loop -freschedule-modulo-scheduled-loops
604-frounding-math -fsave-optimization-record
605-fsched2-use-superblocks -fsched-pressure
606-fsched-spec-load -fsched-spec-load-dangerous
607-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}]
608-fsched-group-heuristic -fsched-critical-path-heuristic
609-fsched-spec-insn-heuristic -fsched-rank-heuristic
610-fsched-last-insn-heuristic -fsched-dep-count-heuristic
611-fschedule-fusion
612-fschedule-insns -fschedule-insns2 -fsection-anchors
613-fselective-scheduling -fselective-scheduling2
614-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
615-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate
616-fsignaling-nans
617-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops
618-fsplit-paths
619-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt
620-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing
621-fthread-jumps -ftracer -ftree-bit-ccp
622-ftree-builtin-call-dce -ftree-ccp -ftree-ch
623-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts
624-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting
625-ftree-loop-if-convert -ftree-loop-im
626-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns
627-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
628-ftree-loop-vectorize
629-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta
630-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra
631-ftree-switch-conversion -ftree-tail-merge
632-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init
633-funconstrained-commons -funit-at-a-time -funroll-all-loops
634-funroll-loops -funsafe-math-optimizations -funswitch-loops
635-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt
636-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs
d77de738
ML
637--param @var{name}=@var{value}
638-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
639
640@item Program Instrumentation Options
641@xref{Instrumentation Options,,Program Instrumentation Options}.
43b72ede
AA
642@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage
643-fprofile-abs-path
644-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path}
645-fprofile-info-section -fprofile-info-section=@var{name}
646-fprofile-note=@var{path} -fprofile-prefix-path=@var{path}
647-fprofile-update=@var{method} -fprofile-filter-files=@var{regex}
648-fprofile-exclude-files=@var{regex}
649-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
650-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style}
651-fsanitize-trap -fsanitize-trap=@var{style}
652-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},...
653-fsanitize-undefined-trap-on-error -fbounds-check
654-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
24592abd 655-fharden-compares -fharden-conditional-branches -fhardened
551935d1
AO
656-fharden-control-flow-redundancy -fhardcfr-skip-leaf
657-fhardcfr-check-exceptions -fhardcfr-check-returning-calls
658-fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
43b72ede
AA
659-fstack-protector -fstack-protector-all -fstack-protector-strong
660-fstack-protector-explicit -fstack-check
661-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym}
662-fno-stack-limit -fsplit-stack
f0a90c7d
AO
663-fstrub=disable -fstrub=strict -fstrub=relaxed
664-fstrub=all -fstrub=at-calls -fstrub=internal
43b72ede
AA
665-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
666-fvtv-counts -fvtv-debug
667-finstrument-functions -finstrument-functions-once
668-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
669-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
b42dd137
M
670-fprofile-prefix-map=@var{old}=@var{new}
671-fpatchable-function-entry=@var{N}@r{[},@var{M}@r{]}}
d77de738
ML
672
673@item Preprocessor Options
674@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
43b72ede
AA
675@gccoptlist{-A@var{question}=@var{answer}
676-A-@var{question}@r{[}=@var{answer}@r{]}
677-C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
678-dD -dI -dM -dN -dU
679-fdebug-cpp -fdirectives-only -fdollars-in-identifiers
680-fexec-charset=@var{charset} -fextended-identifiers
681-finput-charset=@var{charset} -flarge-source-files
682-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth}
683-fno-canonical-system-headers -fpch-deps -fpch-preprocess
684-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion
685-fwide-exec-charset=@var{charset} -fworking-directory
686-H -imacros @var{file} -include @var{file}
687-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules
688-no-integrated-cpp -P -pthread -remap
689-traditional -traditional-cpp -trigraphs
690-U@var{macro} -undef
d77de738
ML
691-Wp,@var{option} -Xpreprocessor @var{option}}
692
693@item Assembler Options
694@xref{Assembler Options,,Passing Options to the Assembler}.
695@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
696
697@item Linker Options
698@xref{Link Options,,Options for Linking}.
43b72ede
AA
699@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library}
700-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++
701-e @var{entry} --entry=@var{entry}
702-pie -pthread -r -rdynamic
703-s -static -static-pie -static-libgcc -static-libstdc++
704-static-libasan -static-libtsan -static-liblsan -static-libubsan
705-shared -shared-libgcc -symbolic
706-T @var{script} -Wl,@var{option} -Xlinker @var{option}
d77de738
ML
707-u @var{symbol} -z @var{keyword}}
708
709@item Directory Options
710@xref{Directory Options,,Options for Directory Search}.
43b72ede
AA
711@gccoptlist{-B@var{prefix} -I@var{dir} -I-
712-idirafter @var{dir}
713-imacros @var{file} -imultilib @var{dir}
714-iplugindir=@var{dir} -iprefix @var{file}
715-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir}
716-iwithprefix @var{dir} -iwithprefixbefore @var{dir}
717-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix
d77de738
ML
718-nostdinc -nostdinc++ --sysroot=@var{dir}}
719
720@item Code Generation Options
721@xref{Code Gen Options,,Options for Code Generation Conventions}.
43b72ede
AA
722@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg}
723-ffixed-@var{reg} -fexceptions
724-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
725-fasynchronous-unwind-tables
726-fno-gnu-unique
727-finhibit-size-directive -fcommon -fno-ident
728-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt
729-fno-jump-tables -fno-bit-tests
730-frecord-gcc-switches
731-freg-struct-return -fshort-enums -fshort-wchar
732-fverbose-asm -fpack-struct[=@var{n}]
733-fleading-underscore -ftls-model=@var{model}
734-fstack-reuse=@var{reuse_level}
28d8c680
AB
735-ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
736-ftrapv -fwrapv
43b72ede 737-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
738-fstrict-volatile-bitfields -fsync-libcalls}
739
740@item Developer Options
741@xref{Developer Options,,GCC Developer Options}.
43b72ede 742@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion
d77de738 743-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
43b72ede
AA
744-fchecking -fchecking=@var{n}
745-fdbg-cnt-list -fdbg-cnt=@var{counter-value-list}
746-fdisable-ipa-@var{pass_name}
747-fdisable-rtl-@var{pass_name}
748-fdisable-rtl-@var{pass-name}=@var{range-list}
749-fdisable-tree-@var{pass_name}
750-fdisable-tree-@var{pass-name}=@var{range-list}
751-fdump-debug -fdump-earlydebug
752-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links
753-fdump-final-insns@r{[}=@var{file}@r{]}
754-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
755-fdump-lang-all
756-fdump-lang-@var{switch}
757-fdump-lang-@var{switch}-@var{options}
758-fdump-lang-@var{switch}-@var{options}=@var{filename}
759-fdump-passes
760-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename}
761-fdump-statistics
762-fdump-tree-all
763-fdump-tree-@var{switch}
764-fdump-tree-@var{switch}-@var{options}
765-fdump-tree-@var{switch}-@var{options}=@var{filename}
766-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second
767-fenable-@var{kind}-@var{pass}
768-fenable-@var{kind}-@var{pass}=@var{range-list}
769-fira-verbose=@var{n}
770-flto-report -flto-report-wpa -fmem-report-wpa
771-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report
772-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]}
773-fmultiflags -fprofile-report
774-frandom-seed=@var{string} -fsched-verbose=@var{n}
775-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
776-fstats -fstack-usage -ftime-report -ftime-report-details
777-fvar-tracking-assignments-toggle -gtoggle
778-print-file-name=@var{library} -print-libgcc-file-name
779-print-multi-directory -print-multi-lib -print-multi-os-directory
780-print-prog-name=@var{program} -print-search-dirs -Q
781-print-sysroot -print-sysroot-headers-suffix
d77de738
ML
782-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
783
784@item Machine-Dependent Options
785@xref{Submodel Options,,Machine-Dependent Options}.
786@c This list is ordered alphanumerically by subsection name.
787@c Try and put the significant identifier (CPU or system) first,
788@c so users have a clue at guessing where the ones they want will be.
789
790@emph{AArch64 Options}
43b72ede
AA
791@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian
792-mgeneral-regs-only
793-mcmodel=tiny -mcmodel=small -mcmodel=large
794-mstrict-align -mno-strict-align
795-momit-leaf-frame-pointer
796-mtls-dialect=desc -mtls-dialect=traditional
797-mtls-size=@var{size}
798-mfix-cortex-a53-835769 -mfix-cortex-a53-843419
799-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div
800-mpc-relative-literal-loads
801-msign-return-address=@var{scope}
d77de738 802-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
43b72ede
AA
803+@var{b-key}]|@var{bti}
804-mharden-sls=@var{opts}
805-march=@var{name} -mcpu=@var{name} -mtune=@var{name}
806-moverride=@var{string} -mverbose-cost-dump
807-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg}
808-mstack-protector-guard-offset=@var{offset} -mtrack-speculation
c0911c6b 809-moutline-atomics -mearly-ldp-fusion -mlate-ldp-fusion}
d77de738
ML
810
811@emph{Adapteva Epiphany Options}
43b72ede
AA
812@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs
813-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf
814-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num}
815-mround-nearest -mlong-calls -mshort-calls -msmall16
816-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num}
d77de738
ML
817-msplit-vecmove-early -m1reg-@var{reg}}
818
819@emph{AMD GCN Options}
820@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
821
822@emph{ARC Options}
43b72ede
AA
823@gccoptlist{-mbarrel-shifter -mjli-always
824-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700
825-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr
826-mea -mno-mpy -mmul32x16 -mmul64 -matomic
827-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap
828-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape
829-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof
830-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved
831-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num}
832-mvolatile-cache -mtp-regno=@var{regno}
833-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc
834-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi
835-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none
836-mlra-priority-compact -mlra-priority-noncompact -mmillicode
837-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level}
838-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame
839-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo}
d77de738
ML
840-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
841
842@emph{ARM Options}
43b72ede
AA
843@gccoptlist{-mapcs-frame -mno-apcs-frame
844-mabi=@var{name}
845-mapcs-stack-check -mno-apcs-stack-check
846-mapcs-reentrant -mno-apcs-reentrant
847-mgeneral-regs-only
848-msched-prolog -mno-sched-prolog
849-mlittle-endian -mbig-endian
850-mbe8 -mbe32
851-mfloat-abi=@var{name}
d77de738 852-mfp16-format=@var{name}
43b72ede
AA
853-mthumb-interwork -mno-thumb-interwork
854-mcpu=@var{name} -march=@var{name} -mfpu=@var{name}
855-mtune=@var{name} -mprint-tune-info
856-mstructure-size-boundary=@var{n}
857-mabort-on-noreturn
858-mlong-calls -mno-long-calls
859-msingle-pic-base -mno-single-pic-base
860-mpic-register=@var{reg}
861-mnop-fun-dllimport
862-mpoke-function-name
863-mthumb -marm -mflip-thumb
864-mtpcs-frame -mtpcs-leaf-frame
865-mcaller-super-interworking -mcallee-super-interworking
866-mtp=@var{name} -mtls-dialect=@var{dialect}
867-mword-relocations
868-mfix-cortex-m3-ldrd
869-mfix-cortex-a57-aes-1742098
870-mfix-cortex-a72-aes-1655431
871-munaligned-access
872-mneon-for-64bits
873-mslow-flash-data
874-masm-syntax-unified
875-mrestrict-it
876-mverbose-cost-dump
877-mpure-code
878-mcmse
879-mfix-cmse-cve-2021-35465
880-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset}
881-mfdpic
14fab5fb
AC
882-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
883[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
d77de738
ML
884
885@emph{AVR Options}
43b72ede 886@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args
cda38361 887-mbranch-cost=@var{cost} -mfuse-add=@var{level}
42503cc2
GJL
888-mcall-prologues -mgas-isr-prologues -mint8 -mflmap
889-mdouble=@var{bits} -mlong-double=@var{bits}
43b72ede
AA
890-mn_flash=@var{size} -mno-interrupts
891-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack
42503cc2
GJL
892-mrodata-in-ram -mfract-convert-truncate
893-mshort-calls -mskip-bug -nodevicelib -nodevicespecs
d77de738
ML
894-Waddr-space-convert -Wmisspelled-isr}
895
896@emph{Blackfin Options}
43b72ede
AA
897@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
898-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer
899-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly
900-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
901-mno-id-shared-library -mshared-library-id=@var{n}
902-mleaf-id-shared-library -mno-leaf-id-shared-library
903-msep-data -mno-sep-data -mlong-calls -mno-long-calls
904-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram
d77de738
ML
905-micplb}
906
907@emph{C6X Options}
43b72ede 908@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu}
d77de738
ML
909-msim -msdata=@var{sdata-type}}
910
911@emph{CRIS Options}
912@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
43b72ede
AA
913-mtune=@var{cpu} -mmax-stack-frame=@var{n}
914-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects
915-mstack-align -mdata-align -mconst-align
916-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
917-melf -maout -sim -sim2
d77de738
ML
918-mmul-bug-workaround -mno-mul-bug-workaround}
919
920@emph{C-SKY Options}
43b72ede
AA
921@gccoptlist{-march=@var{arch} -mcpu=@var{cpu}
922-mbig-endian -EB -mlittle-endian -EL
923-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu
924-mfloat-abi=@var{name}
925-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust
926-mdsp -medsp -mvdsp
927-mdiv -msmart -mhigh-registers -manchor
928-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt
d77de738
ML
929-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
930
931@emph{Darwin Options}
43b72ede
AA
932@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal
933-arch_only -bind_at_load -bundle -bundle_loader
934-client_name -compatibility_version -current_version
935-dead_strip
936-dependency-file -dylib_file -dylinker_install_name
937-dynamic -dynamiclib -exported_symbols_list
938-filelist -flat_namespace -force_cpusubtype_ALL
939-force_flat_namespace -headerpad_max_install_names
940-iframework
941-image_base -init -install_name -keep_private_externs
942-multi_module -multiply_defined -multiply_defined_unused
47b634a3 943-noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths
43b72ede
AA
944-nofixprebinding -nomultidefs -noprebind -noseglinkedit
945-pagezero_size -prebind -prebind_all_twolevel_modules
946-private_bundle -read_only_relocs -sectalign
947-sectobjectsymbols -whyload -seg1addr
948-sectcreate -sectobjectsymbols -sectorder
949-segaddr -segs_read_only_addr -segs_read_write_addr
950-seg_addr_table -seg_addr_table_filename -seglinkedit
951-segprot -segs_read_only_addr -segs_read_write_addr
952-single_module -static -sub_library -sub_umbrella
953-twolevel_namespace -umbrella -undefined
954-unexported_symbols_list -weak_reference_mismatches
955-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version}
d77de738
ML
956-mkernel -mone-byte-bool}
957
958@emph{DEC Alpha Options}
43b72ede
AA
959@gccoptlist{-mno-fp-regs -msoft-float
960-mieee -mieee-with-inexact -mieee-conformant
961-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
962-mtrap-precision=@var{mode} -mbuild-constants
963-mcpu=@var{cpu-type} -mtune=@var{cpu-type}
964-mbwx -mmax -mfix -mcix
965-mfloat-vax -mfloat-ieee
966-mexplicit-relocs -msmall-data -mlarge-data
967-msmall-text -mlarge-text
d77de738
ML
968-mmemory-latency=@var{time}}
969
970@emph{eBPF Options}
9cbf4286 971@gccoptlist{-mbig-endian -mlittle-endian
77d0f9ec 972-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext
14dab1a1 973-mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version}
0e850eff 974-masm=@var{dialect} -minline-memops-threshold=@var{bytes}}
d77de738
ML
975
976@emph{FR30 Options}
977@gccoptlist{-msmall-model -mno-lsim}
978
979@emph{FT32 Options}
980@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
981
982@emph{FRV Options}
43b72ede
AA
983@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64
984-mhard-float -msoft-float
985-malloc-cc -mfixed-cc -mdword -mno-dword
986-mdouble -mno-double
987-mmedia -mno-media -mmuladd -mno-muladd
988-mfdpic -minline-plt -mgprel-ro -multilib-library-pic
989-mlinked-fp -mlong-calls -malign-labels
990-mlibrary-pic -macc-4 -macc-8
991-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move
992-moptimize-membar -mno-optimize-membar
993-mscc -mno-scc -mcond-exec -mno-cond-exec
994-mvliw-branch -mno-vliw-branch
995-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec
996-mno-nested-cond-exec -mtomcat-stats
997-mTLS -mtls
d77de738
ML
998-mcpu=@var{cpu}}
999
1000@emph{GNU/Linux Options}
43b72ede 1001@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid
d77de738
ML
1002-tno-android-cc -tno-android-ld}
1003
1004@emph{H8/300 Options}
1005@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
1006
1007@emph{HPPA Options}
43b72ede
AA
1008@gccoptlist{-march=@var{architecture-type}
1009-matomic-libcalls -mbig-switch
1010-mcaller-copies -mdisable-fpregs -mdisable-indexing
1011-mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld
1012-mfixed-range=@var{register-range}
1013-mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls
1014-mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs
1015-mno-disable-indexing -mno-fast-indirect-calls -mno-gas
1016-mno-jump-in-delay -mno-long-load-store
1017-mno-portable-runtime -mno-soft-float
1018-mno-space-regs -msoft-float -mpa-risc-1-0
1019-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime
1020-mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio
d77de738
ML
1021-munix=@var{unix-std} -nolibdld -static -threads}
1022
1023@emph{IA-64 Options}
43b72ede
AA
1024@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic
1025-mvolatile-asm-stop -mregister-names -msdata -mno-sdata
1026-mconstant-gp -mauto-pic -mfused-madd
1027-minline-float-divide-min-latency
1028-minline-float-divide-max-throughput
1029-mno-inline-float-divide
1030-minline-int-divide-min-latency
1031-minline-int-divide-max-throughput
1032-mno-inline-int-divide
1033-minline-sqrt-min-latency -minline-sqrt-max-throughput
1034-mno-inline-sqrt
1035-mdwarf2-asm -mearly-stop-bits
1036-mfixed-range=@var{register-range} -mtls-size=@var{tls-size}
1037-mtune=@var{cpu-type} -milp32 -mlp64
1038-msched-br-data-spec -msched-ar-data-spec -msched-control-spec
1039-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec
1040-msched-spec-ldc -msched-spec-control-ldc
1041-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns
1042-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path
1043-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
d77de738
ML
1044-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1045
1046@emph{LM32 Options}
43b72ede 1047@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled
d77de738
ML
1048-msign-extend-enabled -muser-enabled}
1049
1050@emph{LoongArch Options}
43b72ede 1051@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type}
bb4a8198
YY
1052-mfpu=@var{fpu-type} -msimd=@var{simd-type}
1053-msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx
43b72ede
AA
1054-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division
1055-mcond-move-int -mno-cond-move-int
1056-mcond-move-float -mno-cond-move-float
1057-memcpy -mno-memcpy -mstrict-align -mno-strict-align
1058-mmax-inline-memcpy-size=@var{n}
e1b1cba1 1059-mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs
43b72ede 1060-mdirect-extern-access -mno-direct-extern-access
fe23a2ff 1061-mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as}
9a07bc47 1062-mrecip -mrecip=@var{opt}
d77de738
ML
1063
1064@emph{M32R/D Options}
43b72ede
AA
1065@gccoptlist{-m32r2 -m32rx -m32r
1066-mdebug
1067-malign-loops -mno-align-loops
1068-missue-rate=@var{number}
1069-mbranch-cost=@var{number}
1070-mmodel=@var{code-size-model-type}
1071-msdata=@var{sdata-type}
1072-mno-flush-func -mflush-func=@var{name}
1073-mno-flush-trap -mflush-trap=@var{number}
d77de738
ML
1074-G @var{num}}
1075
1076@emph{M32C Options}
1077@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1078
1079@emph{M680x0 Options}
43b72ede
AA
1080@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune}
1081-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
1082-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407
1083-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020
1084-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort
1085-mno-short -mhard-float -m68881 -msoft-float -mpcrel
1086-malign-int -mstrict-align -msep-data -mno-sep-data
1087-mshared-library-id=n -mid-shared-library -mno-id-shared-library
d77de738
ML
1088-mxgot -mno-xgot -mlong-jump-table-offsets}
1089
1090@emph{MCore Options}
43b72ede
AA
1091@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates
1092-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields
1093-m4byte-functions -mno-4byte-functions -mcallgraph-data
1094-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim
d77de738
ML
1095-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1096
d77de738 1097@emph{MicroBlaze Options}
43b72ede
AA
1098@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu}
1099-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift
1100-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss
1101-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt
1102-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model}
d77de738
ML
1103-mpic-data-is-text-relative}
1104
1105@emph{MIPS Options}
43b72ede
AA
1106@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch}
1107-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
1108-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6
1109-mips16 -mno-mips16 -mflip-mips16
1110-minterlink-compressed -mno-interlink-compressed
1111-minterlink-mips16 -mno-interlink-mips16
1112-mabi=@var{abi} -mabicalls -mno-abicalls
1113-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot
1114-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float
1115-mno-float -msingle-float -mdouble-float
1116-modd-spreg -mno-odd-spreg
1117-mabs=@var{mode} -mnan=@var{encoding}
1118-mdsp -mno-dsp -mdspr2 -mno-dspr2
1119-mmcu -mmno-mcu
1120-meva -mno-eva
1121-mvirt -mno-virt
1122-mxpa -mno-xpa
1123-mcrc -mno-crc
1124-mginv -mno-ginv
1125-mmicromips -mno-micromips
1126-mmsa -mno-msa
1127-mloongson-mmi -mno-loongson-mmi
1128-mloongson-ext -mno-loongson-ext
1129-mloongson-ext2 -mno-loongson-ext2
1130-mfpu=@var{fpu-type}
1131-msmartmips -mno-smartmips
1132-mpaired-single -mno-paired-single -mdmx -mno-mdmx
1133-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc
1134-mlong64 -mlong32 -msym32 -mno-sym32
1135-G@var{num} -mlocal-sdata -mno-local-sdata
1136-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt
1137-membedded-data -mno-embedded-data
1138-muninit-const-in-rodata -mno-uninit-const-in-rodata
1139-mcode-readable=@var{setting}
1140-msplit-addresses -mno-split-addresses
1141-mexplicit-relocs -mno-explicit-relocs
58af788d 1142-mexplicit-relocs=@var{release}
43b72ede
AA
1143-mcheck-zero-division -mno-check-zero-division
1144-mdivide-traps -mdivide-breaks
1145-mload-store-pairs -mno-load-store-pairs
acc38ff5
YS
1146-mstrict-align -mno-strict-align
1147-mno-unaligned-access -munaligned-access
43b72ede
AA
1148-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls
1149-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp
1150-mfix-24k -mno-fix-24k
1151-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400
1152-mfix-r5900 -mno-fix-r5900
1153-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000
1154-mfix-vr4120 -mno-fix-vr4120
1155-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1
1156-mflush-func=@var{func} -mno-flush-func
1157-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely
1158-mcompact-branches=@var{policy}
1159-mfp-exceptions -mno-fp-exceptions
1160-mvr4130-align -mno-vr4130-align -msynci -mno-synci
1161-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4
1162-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
d77de738
ML
1163-mframe-header-opt -mno-frame-header-opt}
1164
1165@emph{MMIX Options}
43b72ede
AA
1166@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu
1167-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols
1168-melf -mbranch-predict -mno-branch-predict -mbase-addresses
d77de738
ML
1169-mno-base-addresses -msingle-exit -mno-single-exit}
1170
1171@emph{MN10300 Options}
43b72ede
AA
1172@gccoptlist{-mmult-bug -mno-mult-bug
1173-mno-am33 -mam33 -mam33-2 -mam34
1174-mtune=@var{cpu-type}
1175-mreturn-pointer-on-d0
d77de738
ML
1176-mno-crt0 -mrelax -mliw -msetlb}
1177
1178@emph{Moxie Options}
1179@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1180
1181@emph{MSP430 Options}
43b72ede
AA
1182@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax
1183-mwarn-mcu
1184-mcode-region= -mdata-region=
1185-msilicon-errata= -msilicon-errata-warn=
d77de738
ML
1186-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1187
1188@emph{NDS32 Options}
43b72ede
AA
1189@gccoptlist{-mbig-endian -mlittle-endian
1190-mreduced-regs -mfull-regs
1191-mcmov -mno-cmov
1192-mext-perf -mno-ext-perf
1193-mext-perf2 -mno-ext-perf2
1194-mext-string -mno-ext-string
1195-mv3push -mno-v3push
1196-m16bit -mno-16bit
1197-misr-vector-size=@var{num}
1198-mcache-block-size=@var{num}
1199-march=@var{arch}
1200-mcmodel=@var{code-model}
d77de738
ML
1201-mctor-dtor -mrelax}
1202
1203@emph{Nios II Options}
43b72ede
AA
1204@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt
1205-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp}
1206-mel -meb
1207-mno-bypass-cache -mbypass-cache
1208-mno-cache-volatile -mcache-volatile
1209-mno-fast-sw-div -mfast-sw-div
1210-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div
1211-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn}
1212-mcustom-fpu-cfg=@var{name}
1213-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name}
d77de738
ML
1214-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1215
1216@emph{Nvidia PTX Options}
1217@gccoptlist{-m64 -mmainkernel -moptimize}
1218
1219@emph{OpenRISC Options}
43b72ede
AA
1220@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div
1221-msoft-mul -msoft-div
1222-msoft-float -mhard-float -mdouble-float -munordered-float
1223-mcmov -mror -mrori -msext -msfimm -mshftimm
d77de738
ML
1224-mcmodel=@var{code-model}}
1225
1226@emph{PDP-11 Options}
43b72ede
AA
1227@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10
1228-mint32 -mno-int16 -mint16 -mno-int32
d77de738
ML
1229-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1230
d77de738
ML
1231@emph{PowerPC Options}
1232See RS/6000 and PowerPC Options.
1233
1234@emph{PRU Options}
43b72ede 1235@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop
f58e6d42 1236-mabi=@var{variant}}
d77de738
ML
1237
1238@emph{RISC-V Options}
43b72ede
AA
1239@gccoptlist{-mbranch-cost=@var{N-instruction}
1240-mplt -mno-plt
1241-mabi=@var{ABI-string}
1242-mfdiv -mno-fdiv
1243-mdiv -mno-div
1244-misa-spec=@var{ISA-spec-string}
1245-march=@var{ISA-string}
1246-mtune=@var{processor-string}
1247-mpreferred-stack-boundary=@var{num}
1248-msmall-data-limit=@var{N-bytes}
1249-msave-restore -mno-save-restore
1250-mshorten-memrefs -mno-shorten-memrefs
1251-mstrict-align -mno-strict-align
1252-mcmodel=medlow -mcmodel=medany
1253-mexplicit-relocs -mno-explicit-relocs
1254-mrelax -mno-relax
1255-mriscv-attribute -mno-riscv-attribute
1256-malign-data=@var{type}
1257-mbig-endian -mlittle-endian
1258-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1259-mstack-protector-guard-offset=@var{offset}
f797260a 1260-mcsr-check -mno-csr-check
dc95b338 1261-mmovcc -mno-movcc
df48285b 1262-minline-atomics -mno-inline-atomics
949f1ccf
CM
1263-minline-strlen -mno-inline-strlen
1264-minline-strcmp -mno-inline-strcmp
1265-minline-strncmp -mno-inline-strncmp}
d77de738
ML
1266
1267@emph{RL78 Options}
43b72ede
AA
1268@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs
1269-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
d77de738
ML
1270-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1271
1272@emph{RS/6000 and PowerPC Options}
43b72ede
AA
1273@gccoptlist{-mcpu=@var{cpu-type}
1274-mtune=@var{cpu-type}
1275-mcmodel=@var{code-model}
1276-mpowerpc64
1277-maltivec -mno-altivec
1278-mpowerpc-gpopt -mno-powerpc-gpopt
1279-mpowerpc-gfxopt -mno-powerpc-gfxopt
1280-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd
1281-mfprnd -mno-fprnd
1282-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp
1283-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc
1284-m64 -m32 -mxl-compat -mno-xl-compat -mpe
1285-malign-power -malign-natural
1286-msoft-float -mhard-float -mmultiple -mno-multiple
1287-mupdate -mno-update
1288-mavoid-indexed-addresses -mno-avoid-indexed-addresses
1289-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
1290-mstrict-align -mno-strict-align -mrelocatable
1291-mno-relocatable -mrelocatable-lib -mno-relocatable-lib
1292-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
1293-mdynamic-no-pic -mswdiv -msingle-pic-base
1294-mprioritize-restricted-insns=@var{priority}
1295-msched-costly-dep=@var{dependence_type}
1296-minsert-sched-nops=@var{scheme}
1297-mcall-aixdesc -mcall-eabi -mcall-freebsd
1298-mcall-linux -mcall-netbsd -mcall-openbsd
1299-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi
1300-mtraceback=@var{traceback_type}
1301-maix-struct-return -msvr4-struct-return
1302-mabi=@var{abi-type} -msecure-plt -mbss-plt
1303-mlongcall -mno-longcall -mpltseq -mno-pltseq
1304-mblock-move-inline-limit=@var{num}
1305-mblock-compare-inline-limit=@var{num}
1306-mblock-compare-inline-loop-limit=@var{num}
1307-mno-block-ops-unaligned-vsx
1308-mstring-compare-inline-limit=@var{num}
1309-misel -mno-isel
1310-mvrsave -mno-vrsave
1311-mmulhw -mno-mulhw
1312-mdlmzb -mno-dlmzb
1313-mprototype -mno-prototype
1314-msim -mmvme -mads -myellowknife -memb -msdata
1315-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num}
1316-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision
1317-mno-recip-precision
1318-mveclibabi=@var{type} -mfriz -mno-friz
1319-mpointers-to-nested-functions -mno-pointers-to-nested-functions
1320-msave-toc-indirect -mno-save-toc-indirect
438ef143 1321-mpower8-fusion -mno-mpower8-fusion
43b72ede
AA
1322-mcrypto -mno-crypto -mhtm -mno-htm
1323-mquad-memory -mno-quad-memory
1324-mquad-memory-atomic -mno-quad-memory-atomic
1325-mcompat-align-parm -mno-compat-align-parm
1326-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware
1327-mgnu-attribute -mno-gnu-attribute
1328-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1329-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed
1330-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect
d77de738
ML
1331-mprivileged -mno-privileged}
1332
1333@emph{RX Options}
43b72ede
AA
1334@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu
1335-mcpu=
1336-mbig-endian-data -mlittle-endian-data
1337-msmall-data
1338-msim -mno-sim
1339-mas100-syntax -mno-as100-syntax
1340-mrelax
1341-mmax-constant-size=
1342-mint-register=
1343-mpid
1344-mallow-string-insns -mno-allow-string-insns
1345-mjsr
1346-mno-warn-multiple-fast-interrupts
d77de738
ML
1347-msave-acc-in-interrupts}
1348
1349@emph{S/390 and zSeries Options}
43b72ede
AA
1350@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1351-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp
1352-mlong-double-64 -mlong-double-128
1353-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack
1354-msmall-exec -mno-small-exec -mmvcle -mno-mvcle
1355-m64 -m31 -mdebug -mno-debug -mesa -mzarch
1356-mhtm -mvx -mzvector
1357-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip
1358-mfused-madd -mno-fused-madd
1359-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard
d77de738
ML
1360-mhotpatch=@var{halfwords},@var{halfwords}}
1361
d77de738 1362@emph{SH Options}
43b72ede
AA
1363@gccoptlist{-m1 -m2 -m2e
1364-m2a-nofpu -m2a-single-only -m2a-single -m2a
1365-m3 -m3e
1366-m4-nofpu -m4-single-only -m4-single -m4
1367-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al
1368-mb -ml -mdalign -mrelax
1369-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave
1370-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct
1371-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy}
1372-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range}
1373-maccumulate-outgoing-args
1374-matomic-model=@var{atomic-model}
1375-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch
1376-mcbranch-force-delay-slot
1377-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra
d77de738
ML
1378-mpretend-cmove -mtas}
1379
1380@emph{Solaris 2 Options}
43b72ede 1381@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text
d77de738
ML
1382-pthreads}
1383
1384@emph{SPARC Options}
43b72ede
AA
1385@gccoptlist{-mcpu=@var{cpu-type}
1386-mtune=@var{cpu-type}
1387-mcmodel=@var{code-model}
1388-mmemory-model=@var{mem-model}
1389-m32 -m64 -mapp-regs -mno-app-regs
1390-mfaster-structs -mno-faster-structs -mflat -mno-flat
1391-mfpu -mno-fpu -mhard-float -msoft-float
1392-mhard-quad-float -msoft-quad-float
1393-mstack-bias -mno-stack-bias
1394-mstd-struct-return -mno-std-struct-return
1395-munaligned-doubles -mno-unaligned-doubles
1396-muser-mode -mno-user-mode
1397-mv8plus -mno-v8plus -mvis -mno-vis
1398-mvis2 -mno-vis2 -mvis3 -mno-vis3
1399-mvis4 -mno-vis4 -mvis4b -mno-vis4b
1400-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld
1401-mpopc -mno-popc -msubxc -mno-subxc
1402-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc
d77de738
ML
1403-mlra -mno-lra}
1404
1405@emph{System V Options}
1406@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1407
1408@emph{V850 Options}
43b72ede
AA
1409@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep
1410-mprolog-function -mno-prolog-function -mspace
1411-mtda=@var{n} -msda=@var{n} -mzda=@var{n}
1412-mapp-regs -mno-app-regs
1413-mdisable-callt -mno-disable-callt
1414-mv850e2v3 -mv850e2 -mv850e1 -mv850es
1415-mv850e -mv850 -mv850e3v5
1416-mloop
1417-mrelax
1418-mlong-jumps
1419-msoft-float
1420-mhard-float
1421-mgcc-abi
1422-mrh850-abi
d77de738
ML
1423-mbig-switch}
1424
1425@emph{VAX Options}
1426@gccoptlist{-mg -mgnu -munix -mlra}
1427
1428@emph{Visium Options}
43b72ede 1429@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float
d77de738
ML
1430-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1431
1432@emph{VMS Options}
43b72ede 1433@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64
d77de738
ML
1434-mpointer-size=@var{size}}
1435
1436@emph{VxWorks Options}
b6f4b000 1437@gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic
d77de738
ML
1438-Xbind-lazy -Xbind-now}
1439
1440@emph{x86 Options}
43b72ede
AA
1441@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1442-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default
1443-mfpmath=@var{unit}
1444-masm=@var{dialect} -mno-fancy-math-387
1445-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float
1446-mno-wide-multiply -mrtd -malign-double
1447-mpreferred-stack-boundary=@var{num}
1448-mincoming-stack-boundary=@var{num}
1449-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait
1450-mrecip -mrecip=@var{opt}
1451-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt}
ad5b757d 1452-mpartial-vector-fp-math
43b72ede 1453-mmove-max=@var{bits} -mstore-max=@var{bits}
a307a26e 1454-mnoreturn-no-callee-saved-registers
43b72ede
AA
1455-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx
1456-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl
1457-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
1458-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd
1459-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves
1460-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop
1461-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp
1462-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg
1463-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call
1464-mavx512vbmi2 -mavx512bf16 -menqcmd
1465-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
1466-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid
1467-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk
1468-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni
1469-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16
e686416b 1470-mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf
49a14ee4 1471-musermsr -mavx10.1 -mavx10.1-256 -mavx10.1-512 -mevex512
43b72ede
AA
1472-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops
1473-minline-stringops-dynamically -mstringop-strategy=@var{alg}
1474-mkl -mwidekl
1475-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy}
1476-mpush-args -maccumulate-outgoing-args -m128bit-long-double
1477-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128
1478-mregparm=@var{num} -msseregparm
1479-mveclibabi=@var{type} -mvect8-ret-in-mem
1480-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign
1481-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
1482-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode}
1483-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num}
1484-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv
1485-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name}
1486-mavx256-split-unaligned-load -mavx256-split-unaligned-store
1487-malign-data=@var{type} -mstack-protector-guard=@var{guard}
1488-mstack-protector-guard-reg=@var{reg}
1489-mstack-protector-guard-offset=@var{offset}
1490-mstack-protector-guard-symbol=@var{symbol}
1491-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop
1492-mindirect-branch=@var{choice} -mfunction-return=@var{choice}
1493-mindirect-branch-register -mharden-sls=@var{choice}
1494-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access
bb576017 1495-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1496
1497@emph{x86 Windows Options}
b6c4fcda 1498@gccoptlist{-mconsole -mcrtdll=@var{library} -mdll
43b72ede 1499-mnop-fun-dllimport -mthread
d77de738
ML
1500-municode -mwin32 -mwindows -fno-set-stack-executable}
1501
1502@emph{Xstormy16 Options}
1503@gccoptlist{-msim}
1504
1505@emph{Xtensa Options}
43b72ede
AA
1506@gccoptlist{-mconst16 -mno-const16
1507-mfused-madd -mno-fused-madd
1508-mforce-no-pic
1509-mserialize-volatile -mno-serialize-volatile
1510-mtext-section-literals -mno-text-section-literals
1511-mauto-litpools -mno-auto-litpools
1512-mtarget-align -mno-target-align
1513-mlongcalls -mno-longcalls
1514-mabi=@var{abi-type}
675b390e
MF
1515-mextra-l32r-costs=@var{cycles}
1516-mstrict-align -mno-strict-align}
d77de738
ML
1517
1518@emph{zSeries Options}
1519See S/390 and zSeries Options.
1520@end table
1521
1522
1523@node Overall Options
1524@section Options Controlling the Kind of Output
1525
1526Compilation can involve up to four stages: preprocessing, compilation
1527proper, assembly and linking, always in that order. GCC is capable of
1528preprocessing and compiling several files either into several
1529assembler input files, or into one assembler input file; then each
1530assembler input file produces an object file, and linking combines all
1531the object files (those newly compiled, and those specified as input)
1532into an executable file.
1533
1534@cindex file name suffix
1535For any given input file, the file name suffix determines what kind of
1536compilation is done:
1537
1538@table @gcctabopt
1539@item @var{file}.c
1540C source code that must be preprocessed.
1541
1542@item @var{file}.i
1543C source code that should not be preprocessed.
1544
1545@item @var{file}.ii
1546C++ source code that should not be preprocessed.
1547
1548@item @var{file}.m
1549Objective-C source code. Note that you must link with the @file{libobjc}
1550library to make an Objective-C program work.
1551
1552@item @var{file}.mi
1553Objective-C source code that should not be preprocessed.
1554
1555@item @var{file}.mm
1556@itemx @var{file}.M
1557Objective-C++ source code. Note that you must link with the @file{libobjc}
1558library to make an Objective-C++ program work. Note that @samp{.M} refers
1559to a literal capital M@.
1560
1561@item @var{file}.mii
1562Objective-C++ source code that should not be preprocessed.
1563
1564@item @var{file}.h
1565C, C++, Objective-C or Objective-C++ header file to be turned into a
1566precompiled header (default), or C, C++ header file to be turned into an
1567Ada spec (via the @option{-fdump-ada-spec} switch).
1568
1569@item @var{file}.cc
1570@itemx @var{file}.cp
1571@itemx @var{file}.cxx
1572@itemx @var{file}.cpp
1573@itemx @var{file}.CPP
1574@itemx @var{file}.c++
1575@itemx @var{file}.C
1576C++ source code that must be preprocessed. Note that in @samp{.cxx},
1577the last two letters must both be literally @samp{x}. Likewise,
1578@samp{.C} refers to a literal capital C@.
1579
1580@item @var{file}.mm
1581@itemx @var{file}.M
1582Objective-C++ source code that must be preprocessed.
1583
1584@item @var{file}.mii
1585Objective-C++ source code that should not be preprocessed.
1586
1587@item @var{file}.hh
1588@itemx @var{file}.H
1589@itemx @var{file}.hp
1590@itemx @var{file}.hxx
1591@itemx @var{file}.hpp
1592@itemx @var{file}.HPP
1593@itemx @var{file}.h++
1594@itemx @var{file}.tcc
1595C++ header file to be turned into a precompiled header or Ada spec.
1596
1597@item @var{file}.f
1598@itemx @var{file}.for
1599@itemx @var{file}.ftn
ba615557 1600@itemx @var{file}.fi
d77de738
ML
1601Fixed form Fortran source code that should not be preprocessed.
1602
1603@item @var{file}.F
1604@itemx @var{file}.FOR
1605@itemx @var{file}.fpp
1606@itemx @var{file}.FPP
1607@itemx @var{file}.FTN
1608Fixed form Fortran source code that must be preprocessed (with the traditional
1609preprocessor).
1610
1611@item @var{file}.f90
1612@itemx @var{file}.f95
1613@itemx @var{file}.f03
1614@itemx @var{file}.f08
ba615557 1615@itemx @var{file}.fii
d77de738
ML
1616Free form Fortran source code that should not be preprocessed.
1617
1618@item @var{file}.F90
1619@itemx @var{file}.F95
1620@itemx @var{file}.F03
1621@itemx @var{file}.F08
1622Free form Fortran source code that must be preprocessed (with the
1623traditional preprocessor).
1624
1625@item @var{file}.go
1626Go source code.
1627
1628@item @var{file}.d
1629D source code.
1630
1631@item @var{file}.di
1632D interface file.
1633
1634@item @var{file}.dd
1635D documentation code (Ddoc).
1636
1637@item @var{file}.ads
1638Ada source code file that contains a library unit declaration (a
1639declaration of a package, subprogram, or generic, or a generic
1640instantiation), or a library unit renaming declaration (a package,
1641generic, or subprogram renaming declaration). Such files are also
1642called @dfn{specs}.
1643
1644@item @var{file}.adb
1645Ada source code file containing a library unit body (a subprogram or
1646package body). Such files are also called @dfn{bodies}.
1647
1648@c GCC also knows about some suffixes for languages not yet included:
1649@c Ratfor:
1650@c @var{file}.r
1651
1652@item @var{file}.s
1653Assembler code.
1654
1655@item @var{file}.S
1656@itemx @var{file}.sx
1657Assembler code that must be preprocessed.
1658
1659@item @var{other}
1660An object file to be fed straight into linking.
1661Any file name with no recognized suffix is treated this way.
1662@end table
1663
1664@opindex x
1665You can specify the input language explicitly with the @option{-x} option:
1666
1667@table @gcctabopt
1668@item -x @var{language}
1669Specify explicitly the @var{language} for the following input files
1670(rather than letting the compiler choose a default based on the file
1671name suffix). This option applies to all following input files until
1672the next @option{-x} option. Possible values for @var{language} are:
1673@smallexample
1674c c-header cpp-output
1675c++ c++-header c++-system-header c++-user-header c++-cpp-output
1676objective-c objective-c-header objective-c-cpp-output
1677objective-c++ objective-c++-header objective-c++-cpp-output
1678assembler assembler-with-cpp
1679ada
1680d
1681f77 f77-cpp-input f95 f95-cpp-input
1682go
1683@end smallexample
1684
1685@item -x none
1686Turn off any specification of a language, so that subsequent files are
1687handled according to their file name suffixes (as they are if @option{-x}
1688has not been used at all).
1689@end table
1690
1691If you only want some of the stages of compilation, you can use
1692@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1693one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1694@command{gcc} is to stop. Note that some combinations (for example,
1695@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1696
1697@table @gcctabopt
d77de738 1698@opindex c
ddf6fe37 1699@item -c
d77de738
ML
1700Compile or assemble the source files, but do not link. The linking
1701stage simply is not done. The ultimate output is in the form of an
1702object file for each source file.
1703
1704By default, the object file name for a source file is made by replacing
1705the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1706
1707Unrecognized input files, not requiring compilation or assembly, are
1708ignored.
1709
d77de738 1710@opindex S
ddf6fe37 1711@item -S
d77de738
ML
1712Stop after the stage of compilation proper; do not assemble. The output
1713is in the form of an assembler code file for each non-assembler input
1714file specified.
1715
1716By default, the assembler file name for a source file is made by
1717replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1718
1719Input files that don't require compilation are ignored.
1720
d77de738 1721@opindex E
ddf6fe37 1722@item -E
d77de738
ML
1723Stop after the preprocessing stage; do not run the compiler proper. The
1724output is in the form of preprocessed source code, which is sent to the
1725standard output.
1726
1727Input files that don't require preprocessing are ignored.
1728
1729@cindex output file option
d77de738 1730@opindex o
ddf6fe37 1731@item -o @var{file}
d77de738
ML
1732Place the primary output in file @var{file}. This applies to whatever
1733sort of output is being produced, whether it be an executable file, an
1734object file, an assembler file or preprocessed C code.
1735
1736If @option{-o} is not specified, the default is to put an executable
1737file in @file{a.out}, the object file for
1738@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1739assembler file in @file{@var{source}.s}, a precompiled header file in
1740@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1741standard output.
1742
1743Though @option{-o} names only the primary output, it also affects the
1744naming of auxiliary and dump outputs. See the examples below. Unless
1745overridden, both auxiliary outputs and dump outputs are placed in the
1746same directory as the primary output. In auxiliary outputs, the suffix
1747of the input file is replaced with that of the auxiliary output file
1748type; in dump outputs, the suffix of the dump file is appended to the
1749input file suffix. In compilation commands, the base name of both
1750auxiliary and dump outputs is that of the primary output; in compile and
1751link commands, the primary output name, minus the executable suffix, is
1752combined with the input file name. If both share the same base name,
1753disregarding the suffix, the result of the combination is that base
1754name, otherwise, they are concatenated, separated by a dash.
1755
1756@smallexample
1757gcc -c foo.c ...
1758@end smallexample
1759
1760will use @file{foo.o} as the primary output, and place aux outputs and
1761dumps next to it, e.g., aux file @file{foo.dwo} for
1762@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1763@option{-fdump-rtl-final}.
1764
1765If a non-linker output file is explicitly specified, aux and dump files
1766by default take the same base name:
1767
1768@smallexample
1769gcc -c foo.c -o dir/foobar.o ...
1770@end smallexample
1771
1772will name aux outputs @file{dir/foobar.*} and dump outputs
1773@file{dir/foobar.c.*}.
1774
1775A linker output will instead prefix aux and dump outputs:
1776
1777@smallexample
1778gcc foo.c bar.c -o dir/foobar ...
1779@end smallexample
1780
1781will generally name aux outputs @file{dir/foobar-foo.*} and
1782@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1783@file{dir/foobar-bar.c.*}.
1784
1785The one exception to the above is when the executable shares the base
1786name with the single input:
1787
1788@smallexample
1789gcc foo.c -o dir/foo ...
1790@end smallexample
1791
1792in which case aux outputs are named @file{dir/foo.*} and dump outputs
1793named @file{dir/foo.c.*}.
1794
1795The location and the names of auxiliary and dump outputs can be adjusted
1796by the options @option{-dumpbase}, @option{-dumpbase-ext},
1797@option{-dumpdir}, @option{-save-temps=cwd}, and
1798@option{-save-temps=obj}.
1799
1800
d77de738 1801@opindex dumpbase
ddf6fe37 1802@item -dumpbase @var{dumpbase}
d77de738
ML
1803This option sets the base name for auxiliary and dump output files. It
1804does not affect the name of the primary output file. Intermediate
1805outputs, when preserved, are not regarded as primary outputs, but as
1806auxiliary outputs:
1807
1808@smallexample
1809gcc -save-temps -S foo.c
1810@end smallexample
1811
1812saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1813then compiles to the (implied) output file @file{foo.s}, whereas:
1814
1815@smallexample
1816gcc -save-temps -dumpbase save-foo -c foo.c
1817@end smallexample
1818
1819preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1820an intermediate, thus auxiliary output), and then assembles to the
1821(implied) output file @file{foo.o}.
1822
1823Absent this option, dump and aux files take their names from the input
1824file, or from the (non-linker) output file, if one is explicitly
1825specified: dump output files (e.g. those requested by @option{-fdump-*}
1826options) with the input name suffix, and aux output files (those
1827requested by other non-dump options, e.g. @code{-save-temps},
1828@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1829
1830Similar suffix differentiation of dump and aux outputs can be attained
1831for explicitly-given @option{-dumpbase basename.suf} by also specifying
1832@option{-dumpbase-ext .suf}.
1833
1834If @var{dumpbase} is explicitly specified with any directory component,
1835any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1836@option{-save-temps=*}) is ignored, and instead of appending to it,
1837@var{dumpbase} fully overrides it:
1838
1839@smallexample
1840gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1841 -dumpdir pfx- -save-temps=cwd ...
1842@end smallexample
1843
1844creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1845@file{dir/} in @option{-o}, the @file{./} prefix implied by
1846@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1847
1848When @option{-dumpbase} is specified in a command that compiles multiple
1849inputs, or that compiles and then links, it may be combined with
1850@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1851file is compiled using the combined @var{dumppfx}, and default values
1852for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1853file:
1854
1855@smallexample
1856gcc foo.c bar.c -c -dumpbase main ...
1857@end smallexample
1858
1859creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1860overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1861as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1862and @file{main-bar.*}.
1863
1864An empty string specified as @var{dumpbase} avoids the influence of the
1865output basename in the naming of auxiliary and dump outputs during
1866compilation, computing default values :
1867
1868@smallexample
1869gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1870@end smallexample
1871
1872will name aux outputs @file{dir/foo.*} and dump outputs
1873@file{dir/foo.c.*}. Note how their basenames are taken from the input
1874name, but the directory still defaults to that of the output.
1875
1876The empty-string dumpbase does not prevent the use of the output
1877basename for outputs during linking:
1878
1879@smallexample
1880gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1881@end smallexample
1882
1883The compilation of the source files will name auxiliary outputs
1884@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1885@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1886linking will use @file{dir/foobar.} as the prefix for dumps and
1887auxiliary files.
1888
1889
d77de738 1890@opindex dumpbase-ext
ddf6fe37 1891@item -dumpbase-ext @var{auxdropsuf}
d77de738
ML
1892When forming the name of an auxiliary (but not a dump) output file, drop
1893trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1894suffixes. If not specified, this option defaults to the suffix of a
1895default @var{dumpbase}, i.e., the suffix of the input file when
1896@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1897is combined with @var{dumppfx}.
1898
1899@smallexample
1900gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1901@end smallexample
1902
1903creates @file{dir/foo.o} as the main output, and generates auxiliary
1904outputs in @file{dir/x-foo.*}, taking the location of the primary
1905output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1906outputs retain the suffix: @file{dir/x-foo.c.*}.
1907
1908This option is disregarded if it does not match the suffix of a
1909specified @var{dumpbase}, except as an alternative to the executable
1910suffix when appending the linker output base name to @var{dumppfx}, as
1911specified below:
1912
1913@smallexample
1914gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1915@end smallexample
1916
1917creates @file{main.out} as the primary output, and avoids overwriting
1918the auxiliary and dump outputs by using the executable name minus
1919@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1920@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1921@file{main-foo.c.*} and @file{main-bar.c.*}.
1922
1923
d77de738 1924@opindex dumpdir
ddf6fe37 1925@item -dumpdir @var{dumppfx}
d77de738
ML
1926When forming the name of an auxiliary or dump output file, use
1927@var{dumppfx} as a prefix:
1928
1929@smallexample
1930gcc -dumpdir pfx- -c foo.c ...
1931@end smallexample
1932
1933creates @file{foo.o} as the primary output, and auxiliary outputs named
1934@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1935@var{dumpbase} derived from the default primary output, derived in turn
1936from the input name. Dump outputs also take the input name suffix:
1937@file{pfx-foo.c.*}.
1938
1939If @var{dumppfx} is to be used as a directory name, it must end with a
1940directory separator:
1941
1942@smallexample
1943gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1944@end smallexample
1945
1946creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1947named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1948default @var{dumpbase} derived from the primary output name. Dump
1949outputs also take the input name suffix: @file{dir/bar.c.*}.
1950
1951It defaults to the location of the output file, unless the output
1952file is a special file like @code{/dev/null}. Options
1953@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1954default, just like an explicit @option{-dumpdir} option. In case
1955multiple such options are given, the last one prevails:
1956
1957@smallexample
1958gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1959@end smallexample
1960
1961outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1962@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1963@option{-dumpdir} option. It does not matter that @option{=obj} is the
1964default for @option{-save-temps}, nor that the output directory is
1965implicitly the current directory. Dump outputs are named
1966@file{foo.c.*}.
1967
1968When compiling from multiple input files, if @option{-dumpbase} is
1969specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1970are appended to (or override, if containing any directory components) an
1971explicit or defaulted @var{dumppfx}, so that each of the multiple
1972compilations gets differently-named aux and dump outputs.
1973
1974@smallexample
1975gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1976@end smallexample
1977
1978outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1979@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1980Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1981and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1982single-input compilation:
1983
1984@smallexample
1985gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1986@end smallexample
1987
1988that, applying @option{-dumpbase} to a single source, does not compute
1989and append a separate @var{dumpbase} per input file. Its auxiliary and
1990dump outputs go in @file{dir/pfx-main.*}.
1991
1992When compiling and then linking from multiple input files, a defaulted
1993or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1994transformation above (e.g. the compilation of @file{foo.c} and
1995@file{bar.c} above, but without @option{-c}). If neither
1996@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1997base name, minus @var{auxdropsuf}, if specified, or the executable
1998suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1999instead. Note, however, that unlike earlier cases of linking:
2000
2001@smallexample
2002gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
2003@end smallexample
2004
2005does not append the output name @file{main} to @var{dumppfx}, because
2006@option{-dumpdir} is explicitly specified. The goal is that the
2007explicitly-specified @var{dumppfx} may contain the specified output name
2008as part of the prefix, if desired; only an explicitly-specified
2009@option{-dumpbase} would be combined with it, in order to avoid simply
2010discarding a meaningful option.
2011
2012When compiling and then linking from a single input file, the linker
2013output base name will only be appended to the default @var{dumppfx} as
2014above if it does not share the base name with the single input file
2015name. This has been covered in single-input linking cases above, but
2016not with an explicit @option{-dumpdir} that inhibits the combination,
2017even if overridden by @option{-save-temps=*}:
2018
2019@smallexample
2020gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
2021@end smallexample
2022
2023Auxiliary outputs are named @file{foo.*}, and dump outputs
2024@file{foo.c.*}, in the current working directory as ultimately requested
2025by @option{-save-temps=cwd}.
2026
2027Summing it all up for an intuitive though slightly imprecise data flow:
2028the primary output name is broken into a directory part and a basename
2029part; @var{dumppfx} is set to the former, unless overridden by
2030@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
2031to the latter, unless overriden by @option{-dumpbase}. If there are
2032multiple inputs or linking, this @var{dumpbase} may be combined with
2033@var{dumppfx} and taken from each input file. Auxiliary output names
2034for each input are formed by combining @var{dumppfx}, @var{dumpbase}
2035minus suffix, and the auxiliary output suffix; dump output names are
2036only different in that the suffix from @var{dumpbase} is retained.
2037
2038When it comes to auxiliary and dump outputs created during LTO
2039recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
2040given or as derived from the linker output name but not from inputs,
2041even in cases in which this combination would not otherwise be used as
2042such, is passed down with a trailing period replacing the compiler-added
2043dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2044being involved in linking, this program does not normally get any
2045@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2046
2047When running sub-compilers, @command{lto-wrapper} appends LTO stage
2048names to the received @var{dumppfx}, ensures it contains a directory
2049component so that it overrides any @option{-dumpdir}, and passes that as
2050@option{-dumpbase} to sub-compilers.
2051
d77de738 2052@opindex v
ddf6fe37 2053@item -v
d77de738
ML
2054Print (on standard error output) the commands executed to run the stages
2055of compilation. Also print the version number of the compiler driver
2056program and of the preprocessor and the compiler proper.
2057
d77de738 2058@opindex ###
ddf6fe37 2059@item -###
d77de738
ML
2060Like @option{-v} except the commands are not executed and arguments
2061are quoted unless they contain only alphanumeric characters or @code{./-_}.
2062This is useful for shell scripts to capture the driver-generated command lines.
2063
d77de738 2064@opindex help
ddf6fe37 2065@item --help
d77de738
ML
2066Print (on the standard output) a description of the command-line options
2067understood by @command{gcc}. If the @option{-v} option is also specified
2068then @option{--help} is also passed on to the various processes
2069invoked by @command{gcc}, so that they can display the command-line options
2070they accept. If the @option{-Wextra} option has also been specified
2071(prior to the @option{--help} option), then command-line options that
2072have no documentation associated with them are also displayed.
2073
d77de738 2074@opindex target-help
ddf6fe37 2075@item --target-help
d77de738
ML
2076Print (on the standard output) a description of target-specific command-line
2077options for each tool. For some targets extra target-specific
2078information may also be printed.
2079
2080@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2081Print (on the standard output) a description of the command-line
2082options understood by the compiler that fit into all specified classes
2083and qualifiers. These are the supported classes:
2084
2085@table @asis
2086@item @samp{optimizers}
2087Display all of the optimization options supported by the
2088compiler.
2089
2090@item @samp{warnings}
2091Display all of the options controlling warning messages
2092produced by the compiler.
2093
2094@item @samp{target}
2095Display target-specific options. Unlike the
2096@option{--target-help} option however, target-specific options of the
2097linker and assembler are not displayed. This is because those
2098tools do not currently support the extended @option{--help=} syntax.
2099
2100@item @samp{params}
2101Display the values recognized by the @option{--param}
2102option.
2103
2104@item @var{language}
2105Display the options supported for @var{language}, where
2106@var{language} is the name of one of the languages supported in this
2107version of GCC@. If an option is supported by all languages, one needs
2108to select @samp{common} class.
2109
2110@item @samp{common}
2111Display the options that are common to all languages.
2112@end table
2113
2114These are the supported qualifiers:
2115
2116@table @asis
2117@item @samp{undocumented}
2118Display only those options that are undocumented.
2119
2120@item @samp{joined}
2121Display options taking an argument that appears after an equal
2122sign in the same continuous piece of text, such as:
2123@samp{--help=target}.
2124
2125@item @samp{separate}
2126Display options taking an argument that appears as a separate word
2127following the original option, such as: @samp{-o output-file}.
2128@end table
2129
2130Thus for example to display all the undocumented target-specific
2131switches supported by the compiler, use:
2132
2133@smallexample
2134--help=target,undocumented
2135@end smallexample
2136
2137The sense of a qualifier can be inverted by prefixing it with the
2138@samp{^} character, so for example to display all binary warning
2139options (i.e., ones that are either on or off and that do not take an
2140argument) that have a description, use:
2141
2142@smallexample
2143--help=warnings,^joined,^undocumented
2144@end smallexample
2145
2146The argument to @option{--help=} should not consist solely of inverted
2147qualifiers.
2148
2149Combining several classes is possible, although this usually
2150restricts the output so much that there is nothing to display. One
2151case where it does work, however, is when one of the classes is
2152@var{target}. For example, to display all the target-specific
2153optimization options, use:
2154
2155@smallexample
2156--help=target,optimizers
2157@end smallexample
2158
2159The @option{--help=} option can be repeated on the command line. Each
2160successive use displays its requested class of options, skipping
2161those that have already been displayed. If @option{--help} is also
2162specified anywhere on the command line then this takes precedence
2163over any @option{--help=} option.
2164
2165If the @option{-Q} option appears on the command line before the
2166@option{--help=} option, then the descriptive text displayed by
2167@option{--help=} is changed. Instead of describing the displayed
2168options, an indication is given as to whether the option is enabled,
2169disabled or set to a specific value (assuming that the compiler
2170knows this at the point where the @option{--help=} option is used).
2171
2172Here is a truncated example from the ARM port of @command{gcc}:
2173
2174@smallexample
2175 % gcc -Q -mabi=2 --help=target -c
2176 The following options are target specific:
2177 -mabi= 2
2178 -mabort-on-noreturn [disabled]
2179 -mapcs [disabled]
2180@end smallexample
2181
2182The output is sensitive to the effects of previous command-line
2183options, so for example it is possible to find out which optimizations
2184are enabled at @option{-O2} by using:
2185
2186@smallexample
2187-Q -O2 --help=optimizers
2188@end smallexample
2189
2190Alternatively you can discover which binary optimizations are enabled
2191by @option{-O3} by using:
2192
2193@smallexample
2194gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2195gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2196diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2197@end smallexample
2198
d77de738 2199@opindex version
ddf6fe37 2200@item --version
d77de738
ML
2201Display the version number and copyrights of the invoked GCC@.
2202
d77de738 2203@opindex pass-exit-codes
ddf6fe37 2204@item -pass-exit-codes
d77de738
ML
2205Normally the @command{gcc} program exits with the code of 1 if any
2206phase of the compiler returns a non-success return code. If you specify
2207@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2208the numerically highest error produced by any phase returning an error
2209indication. The C, C++, and Fortran front ends return 4 if an internal
2210compiler error is encountered.
2211
d77de738 2212@opindex pipe
ddf6fe37 2213@item -pipe
d77de738
ML
2214Use pipes rather than temporary files for communication between the
2215various stages of compilation. This fails to work on some systems where
2216the assembler is unable to read from a pipe; but the GNU assembler has
2217no trouble.
2218
d77de738 2219@opindex specs
ddf6fe37 2220@item -specs=@var{file}
d77de738
ML
2221Process @var{file} after the compiler reads in the standard @file{specs}
2222file, in order to override the defaults which the @command{gcc} driver
2223program uses when determining what switches to pass to @command{cc1},
2224@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2225@option{-specs=@var{file}} can be specified on the command line, and they
2226are processed in order, from left to right. @xref{Spec Files}, for
2227information about the format of the @var{file}.
2228
d77de738 2229@opindex wrapper
ddf6fe37 2230@item -wrapper
d77de738
ML
2231Invoke all subcommands under a wrapper program. The name of the
2232wrapper program and its parameters are passed as a comma separated
2233list.
2234
2235@smallexample
2236gcc -c t.c -wrapper gdb,--args
2237@end smallexample
2238
2239@noindent
2240This invokes all subprograms of @command{gcc} under
2241@samp{gdb --args}, thus the invocation of @command{cc1} is
2242@samp{gdb --args cc1 @dots{}}.
2243
d77de738 2244@opindex ffile-prefix-map
ddf6fe37 2245@item -ffile-prefix-map=@var{old}=@var{new}
d77de738
ML
2246When compiling files residing in directory @file{@var{old}}, record
2247any references to them in the result of the compilation as if the
2248files resided in directory @file{@var{new}} instead. Specifying this
2249option is equivalent to specifying all the individual
2250@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27 2251builds that are location independent. Directories referenced by
2eb0191a
JJ
2252directives are not affected by these options. See also
2253@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map},
2254@option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}.
2255
2eb0191a 2256@opindex fcanon-prefix-map
e54b01a1 2257@item -fcanon-prefix-map
2eb0191a
JJ
2258For the @option{-f*-prefix-map} options normally comparison
2259of @file{@var{old}} prefix against the filename that would be normally
2260referenced in the result of the compilation is done using textual
2261comparison of the prefixes, or ignoring character case for case insensitive
2262filesystems and considering slashes and backslashes as equal on DOS based
2263filesystems. The @option{-fcanon-prefix-map} causes such comparisons
2264to be done on canonicalized paths of @file{@var{old}}
2265and the referenced filename.
d77de738 2266
d77de738 2267@opindex fplugin
ddf6fe37 2268@item -fplugin=@var{name}.so
d77de738
ML
2269Load the plugin code in file @var{name}.so, assumed to be a
2270shared object to be dlopen'd by the compiler. The base name of
2271the shared object file is used to identify the plugin for the
2272purposes of argument parsing (See
2273@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2274Each plugin should define the callback functions specified in the
2275Plugins API.
2276
d77de738 2277@opindex fplugin-arg
ddf6fe37 2278@item -fplugin-arg-@var{name}-@var{key}=@var{value}
d77de738
ML
2279Define an argument called @var{key} with a value of @var{value}
2280for the plugin called @var{name}.
2281
d77de738 2282@opindex fdump-ada-spec
ddf6fe37 2283@item -fdump-ada-spec@r{[}-slim@r{]}
d77de738
ML
2284For C and C++ source and include files, generate corresponding Ada specs.
2285@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2286GNAT User's Guide}, which provides detailed documentation on this feature.
2287
d77de738 2288@opindex fada-spec-parent
ddf6fe37 2289@item -fada-spec-parent=@var{unit}
d77de738
ML
2290In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2291Ada specs as child units of parent @var{unit}.
2292
d77de738 2293@opindex fdump-go-spec
ddf6fe37 2294@item -fdump-go-spec=@var{file}
d77de738
ML
2295For input files in any language, generate corresponding Go
2296declarations in @var{file}. This generates Go @code{const},
2297@code{type}, @code{var}, and @code{func} declarations which may be a
2298useful way to start writing a Go interface to code written in some
2299other language.
2300
2301@include @value{srcdir}/../libiberty/at-file.texi
2302@end table
2303
2304@node Invoking G++
2305@section Compiling C++ Programs
2306
2307@cindex suffixes for C++ source
2308@cindex C++ source file suffixes
2309C++ source files conventionally use one of the suffixes @samp{.C},
2310@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2311@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2312@samp{.H}, or (for shared template code) @samp{.tcc}; and
2313preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2314files with these names and compiles them as C++ programs even if you
2315call the compiler the same way as for compiling C programs (usually
2316with the name @command{gcc}).
2317
2318@findex g++
2319@findex c++
2320However, the use of @command{gcc} does not add the C++ library.
2321@command{g++} is a program that calls GCC and automatically specifies linking
2322against the C++ library. It treats @samp{.c},
2323@samp{.h} and @samp{.i} files as C++ source files instead of C source
2324files unless @option{-x} is used. This program is also useful when
2325precompiling a C header file with a @samp{.h} extension for use in C++
2326compilations. On many systems, @command{g++} is also installed with
2327the name @command{c++}.
2328
2329@cindex invoking @command{g++}
2330When you compile C++ programs, you may specify many of the same
2331command-line options that you use for compiling programs in any
2332language; or command-line options meaningful for C and related
2333languages; or options that are meaningful only for C++ programs.
2334@xref{C Dialect Options,,Options Controlling C Dialect}, for
2335explanations of options for languages related to C@.
2336@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2337explanations of options that are meaningful only for C++ programs.
2338
2339@node C Dialect Options
2340@section Options Controlling C Dialect
2341@cindex dialect options
2342@cindex language dialect options
2343@cindex options, dialect
2344
2345The following options control the dialect of C (or languages derived
2346from C, such as C++, Objective-C and Objective-C++) that the compiler
2347accepts:
2348
2349@table @gcctabopt
2350@cindex ANSI support
2351@cindex ISO support
d77de738 2352@opindex ansi
ddf6fe37 2353@item -ansi
d77de738
ML
2354In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2355equivalent to @option{-std=c++98}.
2356
2357This turns off certain features of GCC that are incompatible with ISO
2358C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2359such as the @code{asm} and @code{typeof} keywords, and
2360predefined macros such as @code{unix} and @code{vax} that identify the
2361type of system you are using. It also enables the undesirable and
2362rarely used ISO trigraph feature. For the C compiler,
2363it disables recognition of C++ style @samp{//} comments as well as
2364the @code{inline} keyword.
2365
2366The alternate keywords @code{__asm__}, @code{__extension__},
2367@code{__inline__} and @code{__typeof__} continue to work despite
2368@option{-ansi}. You would not want to use them in an ISO C program, of
2369course, but it is useful to put them in header files that might be included
2370in compilations done with @option{-ansi}. Alternate predefined macros
2371such as @code{__unix__} and @code{__vax__} are also available, with or
2372without @option{-ansi}.
2373
2374The @option{-ansi} option does not cause non-ISO programs to be
2375rejected gratuitously. For that, @option{-Wpedantic} is required in
2376addition to @option{-ansi}. @xref{Warning Options}.
2377
2378The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2379option is used. Some header files may notice this macro and refrain
2380from declaring certain functions or defining certain macros that the
2381ISO standard doesn't call for; this is to avoid interfering with any
2382programs that might use these names for other things.
2383
2384Functions that are normally built in but do not have semantics
2385defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2386functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2387built-in functions provided by GCC}, for details of the functions
2388affected.
2389
d77de738 2390@opindex std
ddf6fe37 2391@item -std=
d77de738
ML
2392Determine the language standard. @xref{Standards,,Language Standards
2393Supported by GCC}, for details of these standard versions. This option
2394is currently only supported when compiling C or C++.
2395
2396The compiler can accept several base standards, such as @samp{c90} or
2397@samp{c++98}, and GNU dialects of those standards, such as
2398@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2399compiler accepts all programs following that standard plus those
2400using GNU extensions that do not contradict it. For example,
2401@option{-std=c90} turns off certain features of GCC that are
2402incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2403keywords, but not other GNU extensions that do not have a meaning in
2404ISO C90, such as omitting the middle term of a @code{?:}
2405expression. On the other hand, when a GNU dialect of a standard is
2406specified, all features supported by the compiler are enabled, even when
2407those features change the meaning of the base standard. As a result, some
2408strict-conforming programs may be rejected. The particular standard
2409is used by @option{-Wpedantic} to identify which features are GNU
2410extensions given that version of the standard. For example
2411@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2412comments, while @option{-std=gnu99 -Wpedantic} does not.
2413
2414A value for this option must be provided; possible values are
2415
2416@table @samp
2417@item c90
2418@itemx c89
2419@itemx iso9899:1990
2420Support all ISO C90 programs (certain GNU extensions that conflict
2421with ISO C90 are disabled). Same as @option{-ansi} for C code.
2422
2423@item iso9899:199409
2424ISO C90 as modified in amendment 1.
2425
2426@item c99
2427@itemx c9x
2428@itemx iso9899:1999
2429@itemx iso9899:199x
2430ISO C99. This standard is substantially completely supported, modulo
2431bugs and floating-point issues
2432(mainly but not entirely relating to optional C99 features from
2433Annexes F and G). See
2434@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2435names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2436
2437@item c11
2438@itemx c1x
2439@itemx iso9899:2011
2440ISO C11, the 2011 revision of the ISO C standard. This standard is
2441substantially completely supported, modulo bugs, floating-point issues
2442(mainly but not entirely relating to optional C11 features from
2443Annexes F and G) and the optional Annexes K (Bounds-checking
2444interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2445
2446@item c17
2447@itemx c18
2448@itemx iso9899:2017
2449@itemx iso9899:2018
2450ISO C17, the 2017 revision of the ISO C standard
2451(published in 2018). This standard is
2452same as C11 except for corrections of defects (all of which are also
2453applied with @option{-std=c11}) and a new value of
2454@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2455
fad61bf7
JM
2456@item c23
2457@itemx c2x
2458@itemx iso9899:2024
2459ISO C23, the 2023 revision of the ISO C standard (expected to be
2460published in 2024). The support for this version is experimental and
2461incomplete. The name @samp{c2x} is deprecated.
d77de738
ML
2462
2463@item gnu90
2464@itemx gnu89
2465GNU dialect of ISO C90 (including some C99 features).
2466
2467@item gnu99
2468@itemx gnu9x
2469GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2470
2471@item gnu11
2472@itemx gnu1x
2473GNU dialect of ISO C11.
2474The name @samp{gnu1x} is deprecated.
2475
2476@item gnu17
2477@itemx gnu18
2478GNU dialect of ISO C17. This is the default for C code.
2479
fad61bf7
JM
2480@item gnu23
2481@itemx gnu2x
d77de738
ML
2482The next version of the ISO C standard, still under development, plus
2483GNU extensions. The support for this version is experimental and
fad61bf7 2484incomplete. The name @samp{gnu2x} is deprecated.
d77de738
ML
2485
2486@item c++98
2487@itemx c++03
2488The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2489additional defect reports. Same as @option{-ansi} for C++ code.
2490
2491@item gnu++98
2492@itemx gnu++03
2493GNU dialect of @option{-std=c++98}.
2494
2495@item c++11
2496@itemx c++0x
2497The 2011 ISO C++ standard plus amendments.
2498The name @samp{c++0x} is deprecated.
2499
2500@item gnu++11
2501@itemx gnu++0x
2502GNU dialect of @option{-std=c++11}.
2503The name @samp{gnu++0x} is deprecated.
2504
2505@item c++14
2506@itemx c++1y
2507The 2014 ISO C++ standard plus amendments.
2508The name @samp{c++1y} is deprecated.
2509
2510@item gnu++14
2511@itemx gnu++1y
2512GNU dialect of @option{-std=c++14}.
2513The name @samp{gnu++1y} is deprecated.
2514
2515@item c++17
2516@itemx c++1z
2517The 2017 ISO C++ standard plus amendments.
2518The name @samp{c++1z} is deprecated.
2519
2520@item gnu++17
2521@itemx gnu++1z
2522GNU dialect of @option{-std=c++17}.
2523This is the default for C++ code.
2524The name @samp{gnu++1z} is deprecated.
2525
2526@item c++20
2527@itemx c++2a
2528The 2020 ISO C++ standard plus amendments.
2529Support is experimental, and could change in incompatible ways in
2530future releases.
2531The name @samp{c++2a} is deprecated.
2532
2533@item gnu++20
2534@itemx gnu++2a
2535GNU dialect of @option{-std=c++20}.
2536Support is experimental, and could change in incompatible ways in
2537future releases.
2538The name @samp{gnu++2a} is deprecated.
2539
2540@item c++2b
2541@itemx c++23
2542The next revision of the ISO C++ standard, planned for
25432023. Support is highly experimental, and will almost certainly
2544change in incompatible ways in future releases.
2545
2546@item gnu++2b
2547@itemx gnu++23
2548GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2549and will almost certainly change in incompatible ways in future
2550releases.
5388a43f
MP
2551
2552@item c++2c
2553@itemx c++26
2554The next revision of the ISO C++ standard, planned for
25552026. Support is highly experimental, and will almost certainly
2556change in incompatible ways in future releases.
2557
2558@item gnu++2c
2559@itemx gnu++26
2560GNU dialect of @option{-std=c++2c}. Support is highly experimental,
2561and will almost certainly change in incompatible ways in future
2562releases.
d77de738
ML
2563@end table
2564
d77de738 2565@opindex aux-info
ddf6fe37 2566@item -aux-info @var{filename}
d77de738
ML
2567Output to the given filename prototyped declarations for all functions
2568declared and/or defined in a translation unit, including those in header
2569files. This option is silently ignored in any language other than C@.
2570
2571Besides declarations, the file indicates, in comments, the origin of
2572each declaration (source file and line), whether the declaration was
2573implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2574@samp{O} for old, respectively, in the first character after the line
2575number and the colon), and whether it came from a declaration or a
2576definition (@samp{C} or @samp{F}, respectively, in the following
2577character). In the case of function definitions, a K&R-style list of
2578arguments followed by their declarations is also provided, inside
2579comments, after the declaration.
2580
d77de738
ML
2581@opindex fno-asm
2582@opindex fasm
ddf6fe37 2583@item -fno-asm
d77de738
ML
2584Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2585keyword, so that code can use these words as identifiers. You can use
2586the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2587instead. In C, @option{-ansi} implies @option{-fno-asm}.
2588
2589In C++, @code{inline} is a standard keyword and is not affected by
2590this switch. You may want to use the @option{-fno-gnu-keywords} flag
2591instead, which disables @code{typeof} but not @code{asm} and
2592@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2593this switch only affects the @code{asm} and @code{typeof} keywords,
fad61bf7
JM
2594since @code{inline} is a standard keyword in ISO C99. In C23 mode
2595(@option{-std=c23} or @option{-std=gnu23}), this switch only affects
d77de738 2596the @code{asm} keyword, since @code{typeof} is a standard keyword in
fad61bf7 2597ISO C23.
d77de738 2598
d77de738
ML
2599@opindex fno-builtin
2600@opindex fbuiltin
f33d7a88 2601@cindex built-in functions
ddf6fe37
AA
2602@item -fno-builtin
2603@itemx -fno-builtin-@var{function}
d77de738
ML
2604Don't recognize built-in functions that do not begin with
2605@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2606functions provided by GCC}, for details of the functions affected,
2607including those which are not built-in functions when @option{-ansi} or
2608@option{-std} options for strict ISO C conformance are used because they
2609do not have an ISO standard meaning.
2610
2611GCC normally generates special code to handle certain built-in functions
2612more efficiently; for instance, calls to @code{alloca} may become single
2613instructions which adjust the stack directly, and calls to @code{memcpy}
2614may become inline copy loops. The resulting code is often both smaller
2615and faster, but since the function calls no longer appear as such, you
2616cannot set a breakpoint on those calls, nor can you change the behavior
2617of the functions by linking with a different library. In addition,
2618when a function is recognized as a built-in function, GCC may use
2619information about that function to warn about problems with calls to
2620that function, or to generate more efficient code, even if the
2621resulting code still contains calls to that function. For example,
2622warnings are given with @option{-Wformat} for bad calls to
2623@code{printf} when @code{printf} is built in and @code{strlen} is
2624known not to modify global memory.
2625
2626With the @option{-fno-builtin-@var{function}} option
2627only the built-in function @var{function} is
2628disabled. @var{function} must not begin with @samp{__builtin_}. If a
2629function is named that is not built-in in this version of GCC, this
2630option is ignored. There is no corresponding
2631@option{-fbuiltin-@var{function}} option; if you wish to enable
2632built-in functions selectively when using @option{-fno-builtin} or
2633@option{-ffreestanding}, you may define macros such as:
2634
2635@smallexample
2636#define abs(n) __builtin_abs ((n))
2637#define strcpy(d, s) __builtin_strcpy ((d), (s))
2638@end smallexample
2639
d77de738 2640@opindex fcond-mismatch
ddf6fe37 2641@item -fcond-mismatch
d77de738
ML
2642Allow conditional expressions with mismatched types in the second and
2643third arguments. The value of such an expression is void. This option
2644is not supported for C++.
2645
d77de738
ML
2646@opindex ffreestanding
2647@cindex hosted environment
f33d7a88 2648@item -ffreestanding
d77de738
ML
2649
2650Assert that compilation targets a freestanding environment. This
2651implies @option{-fno-builtin}. A freestanding environment
2652is one in which the standard library may not exist, and program startup may
2653not necessarily be at @code{main}. The most obvious example is an OS kernel.
2654This is equivalent to @option{-fno-hosted}.
2655
2656@xref{Standards,,Language Standards Supported by GCC}, for details of
2657freestanding and hosted environments.
2658
d77de738 2659@opindex fgimple
ddf6fe37 2660@item -fgimple
d77de738
ML
2661
2662Enable parsing of function definitions marked with @code{__GIMPLE}.
2663This is an experimental feature that allows unit testing of GIMPLE
2664passes.
2665
d77de738 2666@opindex fgnu-tm
ddf6fe37 2667@item -fgnu-tm
d77de738
ML
2668When the option @option{-fgnu-tm} is specified, the compiler
2669generates code for the Linux variant of Intel's current Transactional
2670Memory ABI specification document (Revision 1.1, May 6 2009). This is
2671an experimental feature whose interface may change in future versions
2672of GCC, as the official specification changes. Please note that not
2673all architectures are supported for this feature.
2674
2675For more information on GCC's support for transactional memory,
2676@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2677Transactional Memory Library}.
2678
2679Note that the transactional memory feature is not supported with
2680non-call exceptions (@option{-fnon-call-exceptions}).
2681
d77de738 2682@opindex fgnu89-inline
ddf6fe37 2683@item -fgnu89-inline
d77de738
ML
2684The option @option{-fgnu89-inline} tells GCC to use the traditional
2685GNU semantics for @code{inline} functions when in C99 mode.
2686@xref{Inline,,An Inline Function is As Fast As a Macro}.
2687Using this option is roughly equivalent to adding the
2688@code{gnu_inline} function attribute to all inline functions
2689(@pxref{Function Attributes}).
2690
2691The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2692C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2693specifies the default behavior).
2694This option is not supported in @option{-std=c90} or
2695@option{-std=gnu90} mode.
2696
2697The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2698@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2699in effect for @code{inline} functions. @xref{Common Predefined
2700Macros,,,cpp,The C Preprocessor}.
2701
d77de738
ML
2702@opindex fhosted
2703@cindex hosted environment
f33d7a88 2704@item -fhosted
d77de738
ML
2705
2706Assert that compilation targets a hosted environment. This implies
2707@option{-fbuiltin}. A hosted environment is one in which the
2708entire standard library is available, and in which @code{main} has a return
2709type of @code{int}. Examples are nearly everything except a kernel.
2710This is equivalent to @option{-fno-freestanding}.
2711
d77de738 2712@opindex flax-vector-conversions
ddf6fe37 2713@item -flax-vector-conversions
d77de738
ML
2714Allow implicit conversions between vectors with differing numbers of
2715elements and/or incompatible element types. This option should not be
2716used for new code.
2717
d77de738 2718@opindex fms-extensions
ddf6fe37 2719@item -fms-extensions
d77de738
ML
2720Accept some non-standard constructs used in Microsoft header files.
2721
2722In C++ code, this allows member names in structures to be similar
2723to previous types declarations.
2724
2725@smallexample
2726typedef int UOW;
2727struct ABC @{
2728 UOW UOW;
2729@};
2730@end smallexample
2731
2732Some cases of unnamed fields in structures and unions are only
2733accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2734fields within structs/unions}, for details.
2735
2736Note that this option is off for all targets except for x86
2737targets using ms-abi.
2738
ddf6fe37 2739@opindex foffload
d77de738
ML
2740@cindex Offloading targets
2741@cindex OpenACC offloading targets
2742@cindex OpenMP offloading targets
f33d7a88
AA
2743@item -foffload=disable
2744@itemx -foffload=default
2745@itemx -foffload=@var{target-list}
d77de738
ML
2746Specify for which OpenMP and OpenACC offload targets code should be generated.
2747The default behavior, equivalent to @option{-foffload=default}, is to generate
2748code for all supported offload targets. The @option{-foffload=disable} form
2749generates code only for the host fallback, while
2750@option{-foffload=@var{target-list}} generates code only for the specified
2751comma-separated list of offload targets.
2752
2753Offload targets are specified in GCC's internal target-triplet format. You can
2754run the compiler with @option{-v} to show the list of configured offload targets
2755under @code{OFFLOAD_TARGET_NAMES}.
2756
ddf6fe37 2757@opindex foffload-options
d77de738
ML
2758@cindex Offloading options
2759@cindex OpenACC offloading options
2760@cindex OpenMP offloading options
f33d7a88
AA
2761@item -foffload-options=@var{options}
2762@itemx -foffload-options=@var{target-triplet-list}=@var{options}
d77de738
ML
2763
2764With @option{-foffload-options=@var{options}}, GCC passes the specified
2765@var{options} to the compilers for all enabled offloading targets. You can
2766specify options that apply only to a specific target or targets by using
2767the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2768@var{target-list} is a comma-separated list in the same format as for the
2769@option{-foffload=} option.
2770
2771Typical command lines are
2772
2773@smallexample
4bcb46b3 2774-foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic
e9c1679c 2775-foffload-options=amdgcn-amdhsa=-march=gfx906
d77de738
ML
2776@end smallexample
2777
d77de738
ML
2778@opindex fopenacc
2779@cindex OpenACC accelerator programming
f33d7a88 2780@item -fopenacc
643a5223
TB
2781Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and
2782@samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and
2783@samp{*$acc} in fixed-form Fortran. When @option{-fopenacc} is specified,
2784the compiler generates accelerated code according to the OpenACC Application
d77de738
ML
2785Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2786implies @option{-pthread}, and thus is only supported on targets that
2787have support for @option{-pthread}.
2788
d77de738
ML
2789@opindex fopenacc-dim
2790@cindex OpenACC accelerator programming
f33d7a88 2791@item -fopenacc-dim=@var{geom}
d77de738
ML
2792Specify default compute dimensions for parallel offload regions that do
2793not explicitly specify. The @var{geom} value is a triple of
2794':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2795can be omitted, to use a target-specific default value.
2796
d77de738
ML
2797@opindex fopenmp
2798@cindex OpenMP parallel
f33d7a88 2799@item -fopenmp
75e5a467 2800Enable handling of OpenMP directives @samp{#pragma omp},
643a5223 2801@samp{[[omp::directive(...)]]}, @samp{[[omp::sequence(...)]]} and
75e5a467 2802@samp{[[omp::decl(...)]]} in C/C++ and @samp{!$omp} in Fortran. It
643a5223
TB
2803additionally enables the conditional compilation sentinel @samp{!$} in
2804Fortran. In fixed source form Fortran, the sentinels can also start with
2805@samp{c} or @samp{*}. When @option{-fopenmp} is specified, the
d77de738
ML
2806compiler generates parallel code according to the OpenMP Application
2807Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2808implies @option{-pthread}, and thus is only supported on targets that
2809have support for @option{-pthread}. @option{-fopenmp} implies
2810@option{-fopenmp-simd}.
2811
d77de738
ML
2812@opindex fopenmp-simd
2813@cindex OpenMP SIMD
2814@cindex SIMD
f33d7a88 2815@item -fopenmp-simd
d77de738 2816Enable handling of OpenMP's @code{simd}, @code{declare simd},
1fab441d
TB
2817@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}
2818and @code{loop} directive, and of combined or composite directives with
75e5a467 2819@code{simd} as constituent with @code{#pragma omp},
1fab441d 2820@code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and
75e5a467 2821@code{[[omp::decl(...)]]} in C/C++ and @code{!$omp} in Fortran. It
643a5223
TB
2822additionally enables the conditional compilation sentinel @samp{!$} in
2823Fortran. In fixed source form Fortran, the sentinels can also start with
2824@samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless
2825@option{-fopenmp} is additionally specified, the @code{loop} region binds
2826to the current task region, independent of the specified @code{bind} clause.
d77de738 2827
ddf6fe37 2828@opindex fopenmp-target-simd-clone
f33d7a88 2829@cindex OpenMP target SIMD clone
309e2d95
SL
2830@item -fopenmp-target-simd-clone
2831@item -fopenmp-target-simd-clone=@var{device-type}
309e2d95
SL
2832In addition to generating SIMD clones for functions marked with the
2833@code{declare simd} directive, GCC also generates clones
2834for functions marked with the OpenMP @code{declare target} directive
2835that are suitable for vectorization when this option is in effect. The
2836@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2837and @code{any}, which correspond to keywords for the @code{device_type}
2838clause of the @code{declare target} directive; clones are generated for
2839the intersection of devices specified.
2840@option{-fopenmp-target-simd-clone} is equivalent to
2841@option{-fopenmp-target-simd-clone=any} and
2842@option{-fno-openmp-target-simd-clone} is equivalent to
2843@option{-fopenmp-target-simd-clone=none}.
2844
2845At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2846optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2847it is disabled by default.
2848
d77de738
ML
2849@opindex fpermitted-flt-eval-methods
2850@opindex fpermitted-flt-eval-methods=c11
2851@opindex fpermitted-flt-eval-methods=ts-18661-3
ddf6fe37 2852@item -fpermitted-flt-eval-methods=@var{style}
d77de738
ML
2853ISO/IEC TS 18661-3 defines new permissible values for
2854@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2855a semantic type that is an interchange or extended format should be
2856evaluated to the precision and range of that type. These new values are
2857a superset of those permitted under C99/C11, which does not specify the
2858meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2859conforming to C11 may not have been written expecting the possibility of
2860the new values.
2861
2862@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2863should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2864or the extended set of values specified in ISO/IEC TS 18661-3.
2865
2866@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2867
2868The default when in a standards compliant mode (@option{-std=c11} or similar)
2869is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2870dialect (@option{-std=gnu11} or similar) is
2871@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2872
024f135a
BB
2873@opindex fdeps-
2874The @samp{-fdeps-*} options are used to extract structured dependency
2875information for a source. This involves determining what resources provided by
2876other source files will be required to compile the source as well as what
2877resources are provided by the source. This information can be used to add
2878required dependencies between compilation rules of dependent sources based on
2879their contents rather than requiring such information be reflected within the
2880build tools as well.
2881
2882@opindex fdeps-file
2883@item -fdeps-file=@var{file}
2884Where to write structured dependency information.
2885
2886@opindex fdeps-format
2887@item -fdeps-format=@var{format}
2888The format to use for structured dependency information. @samp{p1689r5} is the
2889only supported format right now. Note that when this argument is specified, the
2890output of @samp{-MF} is stripped of some information (namely C++ modules) so
2891that it does not use extended makefile syntax not understood by most tools.
2892
2893@opindex fdeps-target
2894@item -fdeps-target=@var{file}
2895Analogous to @option{-MT} but for structured dependency information. This
2896indicates the target which will ultimately need any required resources and
2897provide any resources extracted from the source that may be required by other
2898sources.
2899
d77de738 2900@opindex fplan9-extensions
ddf6fe37 2901@item -fplan9-extensions
d77de738
ML
2902Accept some non-standard constructs used in Plan 9 code.
2903
2904This enables @option{-fms-extensions}, permits passing pointers to
2905structures with anonymous fields to functions that expect pointers to
2906elements of the type of the field, and permits referring to anonymous
2907fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2908struct/union fields within structs/unions}, for details. This is only
2909supported for C, not C++.
2910
d77de738
ML
2911@opindex fsigned-bitfields
2912@opindex funsigned-bitfields
2913@opindex fno-signed-bitfields
2914@opindex fno-unsigned-bitfields
ddf6fe37
AA
2915@item -fsigned-bitfields
2916@itemx -funsigned-bitfields
2917@itemx -fno-signed-bitfields
2918@itemx -fno-unsigned-bitfields
d77de738
ML
2919These options control whether a bit-field is signed or unsigned, when the
2920declaration does not use either @code{signed} or @code{unsigned}. By
2921default, such a bit-field is signed, because this is consistent: the
2922basic integer types such as @code{int} are signed types.
2923
d77de738 2924@opindex fsigned-char
ddf6fe37 2925@item -fsigned-char
d77de738
ML
2926Let the type @code{char} be signed, like @code{signed char}.
2927
2928Note that this is equivalent to @option{-fno-unsigned-char}, which is
2929the negative form of @option{-funsigned-char}. Likewise, the option
2930@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2931
d77de738 2932@opindex funsigned-char
ddf6fe37 2933@item -funsigned-char
d77de738
ML
2934Let the type @code{char} be unsigned, like @code{unsigned char}.
2935
2936Each kind of machine has a default for what @code{char} should
2937be. It is either like @code{unsigned char} by default or like
2938@code{signed char} by default.
2939
2940Ideally, a portable program should always use @code{signed char} or
2941@code{unsigned char} when it depends on the signedness of an object.
2942But many programs have been written to use plain @code{char} and
2943expect it to be signed, or expect it to be unsigned, depending on the
2944machines they were written for. This option, and its inverse, let you
2945make such a program work with the opposite default.
2946
2947The type @code{char} is always a distinct type from each of
2948@code{signed char} or @code{unsigned char}, even though its behavior
2949is always just like one of those two.
2950
d77de738
ML
2951@opindex fstrict-flex-arrays
2952@opindex fno-strict-flex-arrays
d77de738 2953@opindex fstrict-flex-arrays=@var{level}
eb71695f
SL
2954@item -fstrict-flex-arrays @r{(C and C++ only)}
2955@itemx -fstrict-flex-arrays=@var{level} @r{(C and C++ only)}
d77de738
ML
2956Control when to treat the trailing array of a structure as a flexible array
2957member for the purpose of accessing the elements of such an array. The value
2958of @var{level} controls the level of strictness.
2959
eb71695f
SL
2960@option{-fstrict-flex-arrays} is equivalent to
2961@option{-fstrict-flex-arrays=3}, which is the strictest; all
2962trailing arrays of structures are treated as flexible array members.
2963
2964The negative form @option{-fno-strict-flex-arrays} is equivalent to
2965@option{-fstrict-flex-arrays=0}, which is the least strict. In this
2966case a trailing array is treated as a flexible array member only when
2967it is declared as a flexible array member per C99 standard onwards.
2968
d77de738
ML
2969The possible values of @var{level} are the same as for the
2970@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2971
2972You can control this behavior for a specific trailing array field of a
2973structure by using the variable attribute @code{strict_flex_array} attribute
2974(@pxref{Variable Attributes}).
2975
eb71695f
SL
2976The @option{-fstrict_flex_arrays} option interacts with the
2977@option{-Wstrict-flex-arrays} option. @xref{Warning Options}, for more
2978information.
2979
d77de738 2980@opindex fsso-struct
ddf6fe37 2981@item -fsso-struct=@var{endianness}
d77de738
ML
2982Set the default scalar storage order of structures and unions to the
2983specified endianness. The accepted values are @samp{big-endian},
2984@samp{little-endian} and @samp{native} for the native endianness of
2985the target (the default). This option is not supported for C++.
2986
2987@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2988code that is not binary compatible with code generated without it if the
2989specified endianness is not the native endianness of the target.
2990@end table
2991
2992@node C++ Dialect Options
2993@section Options Controlling C++ Dialect
2994
2995@cindex compiler options, C++
2996@cindex C++ options, command-line
2997@cindex options, C++
2998This section describes the command-line options that are only meaningful
2999for C++ programs. You can also use most of the GNU compiler options
3000regardless of what language your program is in. For example, you
3001might compile a file @file{firstClass.C} like this:
3002
3003@smallexample
3004g++ -g -fstrict-enums -O -c firstClass.C
3005@end smallexample
3006
3007@noindent
3008In this example, only @option{-fstrict-enums} is an option meant
3009only for C++ programs; you can use the other options with any
3010language supported by GCC@.
3011
3012Some options for compiling C programs, such as @option{-std}, are also
3013relevant for C++ programs.
3014@xref{C Dialect Options,,Options Controlling C Dialect}.
3015
3016Here is a list of options that are @emph{only} for compiling C++ programs:
3017
3018@table @gcctabopt
3019
d77de738 3020@opindex fabi-version
ddf6fe37 3021@item -fabi-version=@var{n}
d77de738
ML
3022Use version @var{n} of the C++ ABI@. The default is version 0.
3023
3024Version 0 refers to the version conforming most closely to
3025the C++ ABI specification. Therefore, the ABI obtained using version 0
3026will change in different versions of G++ as ABI bugs are fixed.
3027
3028Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
3029
3030Version 2 is the version of the C++ ABI that first appeared in G++
30313.4, and was the default through G++ 4.9.
3032
3033Version 3 corrects an error in mangling a constant address as a
3034template argument.
3035
3036Version 4, which first appeared in G++ 4.5, implements a standard
3037mangling for vector types.
3038
3039Version 5, which first appeared in G++ 4.6, corrects the mangling of
3040attribute const/volatile on function pointer types, decltype of a
3041plain decl, and use of a function parameter in the declaration of
3042another parameter.
3043
3044Version 6, which first appeared in G++ 4.7, corrects the promotion
3045behavior of C++11 scoped enums and the mangling of template argument
3046packs, const/static_cast, prefix ++ and --, and a class scope function
3047used as a template argument.
3048
3049Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
3050builtin type and corrects the mangling of lambdas in default argument
3051scope.
3052
3053Version 8, which first appeared in G++ 4.9, corrects the substitution
3054behavior of function types with function-cv-qualifiers.
3055
3056Version 9, which first appeared in G++ 5.2, corrects the alignment of
3057@code{nullptr_t}.
3058
3059Version 10, which first appeared in G++ 6.1, adds mangling of
3060attributes that affect type identity, such as ia32 calling convention
3061attributes (e.g.@: @samp{stdcall}).
3062
3063Version 11, which first appeared in G++ 7, corrects the mangling of
3064sizeof... expressions and operator names. For multiple entities with
3065the same name within a function, that are declared in different scopes,
3066the mangling now changes starting with the twelfth occurrence. It also
3067implies @option{-fnew-inheriting-ctors}.
3068
3069Version 12, which first appeared in G++ 8, corrects the calling
3070conventions for empty classes on the x86_64 target and for classes
3071with only deleted copy/move constructors. It accidentally changes the
3072calling convention for classes with a deleted copy constructor and a
3073trivial move constructor.
3074
3075Version 13, which first appeared in G++ 8.2, fixes the accidental
3076change in version 12.
3077
3078Version 14, which first appeared in G++ 10, corrects the mangling of
3079the nullptr expression.
3080
3081Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
3082tag regression.
3083
3084Version 16, which first appeared in G++ 11, changes the mangling of
3085@code{__alignof__} to be distinct from that of @code{alignof}, and
3086dependent operator names.
3087
3088Version 17, which first appeared in G++ 12, fixes layout of classes
3089that inherit from aggregate classes with default member initializers
3090in C++14 and up.
3091
3092Version 18, which first appeard in G++ 13, fixes manglings of lambdas
3093that have additional context.
3094
cd37325b
JJ
3095Version 19, which first appeard in G++ 14, fixes manglings of structured
3096bindings to include ABI tags.
3097
d77de738
ML
3098See also @option{-Wabi}.
3099
d77de738 3100@opindex fabi-compat-version
ddf6fe37 3101@item -fabi-compat-version=@var{n}
d77de738
ML
3102On targets that support strong aliases, G++
3103works around mangling changes by creating an alias with the correct
3104mangled name when defining a symbol with an incorrect mangled name.
3105This switch specifies which ABI version to use for the alias.
3106
3107With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
3108compatibility). If another ABI version is explicitly selected, this
3109defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
3110use @option{-fabi-compat-version=2}.
3111
3112If this option is not provided but @option{-Wabi=@var{n}} is, that
3113version is used for compatibility aliases. If this option is provided
3114along with @option{-Wabi} (without the version), the version from this
3115option is used for the warning.
3116
d77de738
ML
3117@opindex fno-access-control
3118@opindex faccess-control
ddf6fe37 3119@item -fno-access-control
d77de738
ML
3120Turn off all access checking. This switch is mainly useful for working
3121around bugs in the access control code.
3122
d77de738 3123@opindex faligned-new
ddf6fe37 3124@item -faligned-new
d77de738
ML
3125Enable support for C++17 @code{new} of types that require more
3126alignment than @code{void* ::operator new(std::size_t)} provides. A
3127numeric argument such as @code{-faligned-new=32} can be used to
3128specify how much alignment (in bytes) is provided by that function,
3129but few users will need to override the default of
3130@code{alignof(std::max_align_t)}.
3131
3132This flag is enabled by default for @option{-std=c++17}.
3133
d77de738
ML
3134@opindex fchar8_t
3135@opindex fno-char8_t
ddf6fe37
AA
3136@item -fchar8_t
3137@itemx -fno-char8_t
d77de738
ML
3138Enable support for @code{char8_t} as adopted for C++20. This includes
3139the addition of a new @code{char8_t} fundamental type, changes to the
3140types of UTF-8 string and character literals, new signatures for
3141user-defined literals, associated standard library updates, and new
3142@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3143
3144This option enables functions to be overloaded for ordinary and UTF-8
3145strings:
3146
3147@smallexample
3148int f(const char *); // #1
3149int f(const char8_t *); // #2
3150int v1 = f("text"); // Calls #1
3151int v2 = f(u8"text"); // Calls #2
3152@end smallexample
3153
3154@noindent
3155and introduces new signatures for user-defined literals:
3156
3157@smallexample
3158int operator""_udl1(char8_t);
3159int v3 = u8'x'_udl1;
3160int operator""_udl2(const char8_t*, std::size_t);
3161int v4 = u8"text"_udl2;
3162template<typename T, T...> int operator""_udl3();
3163int v5 = u8"text"_udl3;
3164@end smallexample
3165
3166@noindent
3167The change to the types of UTF-8 string and character literals introduces
3168incompatibilities with ISO C++11 and later standards. For example, the
3169following code is well-formed under ISO C++11, but is ill-formed when
3170@option{-fchar8_t} is specified.
3171
3172@smallexample
d77de738
ML
3173const char *cp = u8"xx";// error: invalid conversion from
3174 // `const char8_t*' to `const char*'
3175int f(const char*);
3176auto v = f(u8"xx"); // error: invalid conversion from
3177 // `const char8_t*' to `const char*'
3178std::string s@{u8"xx"@}; // error: no matching function for call to
3179 // `std::basic_string<char>::basic_string()'
3180using namespace std::literals;
3181s = u8"xx"s; // error: conversion from
3182 // `basic_string<char8_t>' to non-scalar
3183 // type `basic_string<char>' requested
3184@end smallexample
3185
d77de738 3186@opindex fcheck-new
ddf6fe37 3187@item -fcheck-new
d77de738
ML
3188Check that the pointer returned by @code{operator new} is non-null
3189before attempting to modify the storage allocated. This check is
3190normally unnecessary because the C++ standard specifies that
3191@code{operator new} only returns @code{0} if it is declared
3192@code{throw()}, in which case the compiler always checks the
3193return value even without this option. In all other cases, when
3194@code{operator new} has a non-empty exception specification, memory
3195exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3196@samp{new (nothrow)}.
3197
d77de738
ML
3198@opindex fconcepts
3199@opindex fconcepts-ts
ddf6fe37
AA
3200@item -fconcepts
3201@itemx -fconcepts-ts
d77de738
ML
3202Enable support for the C++ Concepts feature for constraining template
3203arguments. With @option{-std=c++20} and above, Concepts are part of
3204the language standard, so @option{-fconcepts} defaults to on.
3205
3206Some constructs that were allowed by the earlier C++ Extensions for
3207Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3208into the standard, can additionally be enabled by
d836db14
MP
3209@option{-fconcepts-ts}. The option @option{-fconcepts-ts} was deprecated
3210in GCC 14 and may be removed in GCC 15; users are expected to convert
3211their code to C++20 concepts.
d77de738 3212
d77de738 3213@opindex fconstexpr-depth
ddf6fe37 3214@item -fconstexpr-depth=@var{n}
d77de738
ML
3215Set the maximum nested evaluation depth for C++11 constexpr functions
3216to @var{n}. A limit is needed to detect endless recursion during
3217constant expression evaluation. The minimum specified by the standard
3218is 512.
3219
d77de738 3220@opindex fconstexpr-cache-depth
ddf6fe37 3221@item -fconstexpr-cache-depth=@var{n}
d77de738
ML
3222Set the maximum level of nested evaluation depth for C++11 constexpr
3223functions that will be cached to @var{n}. This is a heuristic that
3224trades off compilation speed (when the cache avoids repeated
3225calculations) against memory consumption (when the cache grows very
3226large from highly recursive evaluations). The default is 8. Very few
3227users are likely to want to adjust it, but if your code does heavy
3228constexpr calculations you might want to experiment to find which
3229value works best for you.
3230
d77de738 3231@opindex fconstexpr-fp-except
ddf6fe37 3232@item -fconstexpr-fp-except
d77de738
ML
3233Annex F of the C standard specifies that IEC559 floating point
3234exceptions encountered at compile time should not stop compilation.
3235C++ compilers have historically not followed this guidance, instead
3236treating floating point division by zero as non-constant even though
3237it has a well defined value. This flag tells the compiler to give
3238Annex F priority over other rules saying that a particular operation
3239is undefined.
3240
3241@smallexample
3242constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3243@end smallexample
3244
d77de738 3245@opindex fconstexpr-loop-limit
ddf6fe37 3246@item -fconstexpr-loop-limit=@var{n}
d77de738
ML
3247Set the maximum number of iterations for a loop in C++14 constexpr functions
3248to @var{n}. A limit is needed to detect infinite loops during
3249constant expression evaluation. The default is 262144 (1<<18).
3250
d77de738 3251@opindex fconstexpr-ops-limit
ddf6fe37 3252@item -fconstexpr-ops-limit=@var{n}
d77de738
ML
3253Set the maximum number of operations during a single constexpr evaluation.
3254Even when number of iterations of a single loop is limited with the above limit,
3255if there are several nested loops and each of them has many iterations but still
3256smaller than the above limit, or if in a body of some loop or even outside
3257of a loop too many expressions need to be evaluated, the resulting constexpr
3258evaluation might take too long.
3259The default is 33554432 (1<<25).
3260
2efb237f 3261@opindex fcontracts
ddf6fe37 3262@item -fcontracts
2efb237f
JCI
3263Enable experimental support for the C++ Contracts feature, as briefly
3264added to and then removed from the C++20 working paper (N4820). The
3265implementation also includes proposed enhancements from papers P1290,
3266P1332, and P1429. This functionality is intended mostly for those
3267interested in experimentation towards refining the feature to get it
3268into shape for a future C++ standard.
3269
3270On violation of a checked contract, the violation handler is called.
3271Users can replace the violation handler by defining
3272@smallexample
4ace81b6
SL
3273void
3274handle_contract_violation (const std::experimental::contract_violation&);
2efb237f
JCI
3275@end smallexample
3276
3277There are different sets of additional flags that can be used together
3278to specify which contracts will be checked and how, for N4820
3279contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3280used together.
3281
3282@table @gcctabopt
2efb237f 3283@opindex fcontract-mode
ddf6fe37 3284@item -fcontract-mode=[on|off]
2efb237f
JCI
3285Control whether any contracts have any semantics at all. Defaults to on.
3286
2efb237f 3287@opindex fcontract-assumption-mode
ddf6fe37 3288@item -fcontract-assumption-mode=[on|off]
2efb237f
JCI
3289[N4820] Control whether contracts with level @samp{axiom}
3290should have the assume semantic. Defaults to on.
3291
2efb237f 3292@opindex fcontract-build-level
ddf6fe37 3293@item -fcontract-build-level=[off|default|audit]
2efb237f
JCI
3294[N4820] Specify which level of contracts to generate checks
3295for. Defaults to @samp{default}.
3296
2efb237f 3297@opindex fcontract-continuation-mode
ddf6fe37 3298@item -fcontract-continuation-mode=[on|off]
2efb237f
JCI
3299[N4820] Control whether to allow the program to continue executing
3300after a contract violation. That is, do checked contracts have the
3301@samp{maybe} semantic described below rather than the @samp{never}
3302semantic. Defaults to off.
3303
2efb237f 3304@opindex fcontract-role
ddf6fe37 3305@item -fcontract-role=<name>:<default>,<audit>,<axiom>
2efb237f
JCI
3306[P1332] Specify the concrete semantics for each contract level
3307of a particular contract role.
3308
3309@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3310[P1429] Specify the concrete semantic for a particular
3311contract level.
3312
2efb237f 3313@opindex fcontract-strict-declarations
ddf6fe37 3314@item -fcontract-strict-declarations=[on|off]
2efb237f
JCI
3315Control whether to reject adding contracts to a function after its
3316first declaration. Defaults to off.
3317@end table
3318
3319The possible concrete semantics for that can be specified with
3320@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3321
3322@table @code
3323@item ignore
3324This contract has no effect.
3325
3326@item assume
3327This contract is treated like C++23 @code{[[assume]]}.
3328
3329@item check_never_continue
3330@itemx never
3331@itemx abort
3332This contract is checked. If it fails, the violation handler is
3333called. If the handler returns, @code{std::terminate} is called.
3334
3335@item check_maybe_continue
3336@itemx maybe
3337This contract is checked. If it fails, the violation handler is
3338called. If the handler returns, execution continues normally.
3339@end table
3340
d77de738 3341@opindex fcoroutines
ddf6fe37 3342@item -fcoroutines
d77de738
ML
3343Enable support for the C++ coroutines extension (experimental).
3344
d6840b31
PP
3345@opindex fdiagnostics-all-candidates
3346@item -fdiagnostics-all-candidates
3347Permit the C++ front end to note all candidates during overload resolution
3348failure, including when a deleted function is selected.
3349
d77de738
ML
3350@opindex fno-elide-constructors
3351@opindex felide-constructors
ddf6fe37 3352@item -fno-elide-constructors
d77de738
ML
3353The C++ standard allows an implementation to omit creating a temporary
3354that is only used to initialize another object of the same type.
3355Specifying this option disables that optimization, and forces G++ to
3356call the copy constructor in all cases. This option also causes G++
3357to call trivial member functions which otherwise would be expanded inline.
3358
3359In C++17, the compiler is required to omit these temporaries, but this
3360option still affects trivial member functions.
3361
d77de738
ML
3362@opindex fno-enforce-eh-specs
3363@opindex fenforce-eh-specs
ddf6fe37 3364@item -fno-enforce-eh-specs
d77de738
ML
3365Don't generate code to check for violation of exception specifications
3366at run time. This option violates the C++ standard, but may be useful
3367for reducing code size in production builds, much like defining
3368@code{NDEBUG}. This does not give user code permission to throw
3369exceptions in violation of the exception specifications; the compiler
3370still optimizes based on the specifications, so throwing an
3371unexpected exception results in undefined behavior at run time.
3372
d77de738
ML
3373@opindex fextern-tls-init
3374@opindex fno-extern-tls-init
ddf6fe37
AA
3375@item -fextern-tls-init
3376@itemx -fno-extern-tls-init
d77de738
ML
3377The C++11 and OpenMP standards allow @code{thread_local} and
3378@code{threadprivate} variables to have dynamic (runtime)
3379initialization. To support this, any use of such a variable goes
3380through a wrapper function that performs any necessary initialization.
3381When the use and definition of the variable are in the same
3382translation unit, this overhead can be optimized away, but when the
3383use is in a different translation unit there is significant overhead
3384even if the variable doesn't actually need dynamic initialization. If
3385the programmer can be sure that no use of the variable in a
3386non-defining TU needs to trigger dynamic initialization (either
3387because the variable is statically initialized, or a use of the
3388variable in the defining TU will be executed before any uses in
3389another TU), they can avoid this overhead with the
3390@option{-fno-extern-tls-init} option.
3391
3392On targets that support symbol aliases, the default is
3393@option{-fextern-tls-init}. On targets that do not support symbol
3394aliases, the default is @option{-fno-extern-tls-init}.
3395
d77de738
ML
3396@opindex ffold-simple-inlines
3397@opindex fno-fold-simple-inlines
ddf6fe37
AA
3398@item -ffold-simple-inlines
3399@itemx -fno-fold-simple-inlines
d77de738
ML
3400Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3401@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3402means no debug information will be generated for such calls. Since these
3403functions are rarely interesting to debug, this flag is enabled by default
3404unless @option{-fno-inline} is active.
3405
d77de738
ML
3406@opindex fno-gnu-keywords
3407@opindex fgnu-keywords
ddf6fe37 3408@item -fno-gnu-keywords
d77de738
ML
3409Do not recognize @code{typeof} as a keyword, so that code can use this
3410word as an identifier. You can use the keyword @code{__typeof__} instead.
3411This option is implied by the strict ISO C++ dialects: @option{-ansi},
3412@option{-std=c++98}, @option{-std=c++11}, etc.
3413
1f1c4322
MP
3414@opindex fno-immediate-escalation
3415@opindex fimmediate-escalation
3416@item -fno-immediate-escalation
3417Do not enable immediate function escalation whereby certain functions
3418can be promoted to consteval, as specified in P2564R3. For example:
3419
3420@example
3421consteval int id(int i) @{ return i; @}
3422
3423constexpr int f(auto t)
3424@{
3425 return t + id(t); // id causes f<int> to be promoted to consteval
3426@}
3427
3428void g(int i)
3429@{
3430 f (3);
3431@}
3432@end example
3433
3434compiles in C++20: @code{f} is an immediate-escalating function (due to
3435the @code{auto} it is a function template and is declared @code{constexpr})
3436and @code{id(t)} is an immediate-escalating expression, so @code{f} is
3437promoted to @code{consteval}. Consequently, the call to @code{id(t)}
3438is in an immediate context, so doesn't have to produce a constant (that
3439is the mechanism allowing consteval function composition). However,
3440with @option{-fno-immediate-escalation}, @code{f} is not promoted to
3441@code{consteval}, and since the call to consteval function @code{id(t)}
3442is not a constant expression, the compiler rejects the code.
3443
3444This option is turned on by default; it is only effective in C++20 mode
3445or later.
3446
d77de738 3447@opindex fimplicit-constexpr
ddf6fe37 3448@item -fimplicit-constexpr
d77de738
ML
3449Make inline functions implicitly constexpr, if they satisfy the
3450requirements for a constexpr function. This option can be used in
3451C++14 mode or later. This can result in initialization changing from
3452dynamic to static and other optimizations.
3453
d77de738
ML
3454@opindex fno-implicit-templates
3455@opindex fimplicit-templates
ddf6fe37 3456@item -fno-implicit-templates
d77de738
ML
3457Never emit code for non-inline templates that are instantiated
3458implicitly (i.e.@: by use); only emit code for explicit instantiations.
3459If you use this option, you must take care to structure your code to
3460include all the necessary explicit instantiations to avoid getting
3461undefined symbols at link time.
3462@xref{Template Instantiation}, for more information.
3463
d77de738
ML
3464@opindex fno-implicit-inline-templates
3465@opindex fimplicit-inline-templates
ddf6fe37 3466@item -fno-implicit-inline-templates
d77de738
ML
3467Don't emit code for implicit instantiations of inline templates, either.
3468The default is to handle inlines differently so that compiles with and
3469without optimization need the same set of explicit instantiations.
3470
d77de738
ML
3471@opindex fno-implement-inlines
3472@opindex fimplement-inlines
ddf6fe37 3473@item -fno-implement-inlines
d77de738
ML
3474To save space, do not emit out-of-line copies of inline functions
3475controlled by @code{#pragma implementation}. This causes linker
3476errors if these functions are not inlined everywhere they are called.
3477
d77de738
ML
3478@opindex fmodules-ts
3479@opindex fno-modules-ts
ddf6fe37
AA
3480@item -fmodules-ts
3481@itemx -fno-modules-ts
d77de738
ML
3482Enable support for C++20 modules (@pxref{C++ Modules}). The
3483@option{-fno-modules-ts} is usually not needed, as that is the
3484default. Even though this is a C++20 feature, it is not currently
3485implicitly enabled by selecting that standard version.
3486
ddf6fe37 3487@opindex fmodule-header
d77de738
ML
3488@item -fmodule-header
3489@itemx -fmodule-header=user
3490@itemx -fmodule-header=system
d77de738
ML
3491Compile a header file to create an importable header unit.
3492
d77de738 3493@opindex fmodule-implicit-inline
ddf6fe37 3494@item -fmodule-implicit-inline
d77de738
ML
3495Member functions defined in their class definitions are not implicitly
3496inline for modular code. This is different to traditional C++
3497behavior, for good reasons. However, it may result in a difficulty
3498during code porting. This option makes such function definitions
3499implicitly inline. It does however generate an ABI incompatibility,
3500so you must use it everywhere or nowhere. (Such definitions outside
3501of a named module remain implicitly inline, regardless.)
3502
d77de738
ML
3503@opindex fno-module-lazy
3504@opindex fmodule-lazy
ddf6fe37 3505@item -fno-module-lazy
d77de738
ML
3506Disable lazy module importing and module mapper creation.
3507
f33d7a88
AA
3508@vindex CXX_MODULE_MAPPER @r{environment variable}
3509@opindex fmodule-mapper
d77de738
ML
3510@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3511@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3512@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3513@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3514@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3515@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
d77de738
ML
3516An oracle to query for module name to filename mappings. If
3517unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3518and if that is unset, an in-process default is provided.
3519
d77de738 3520@opindex fmodule-only
ddf6fe37 3521@item -fmodule-only
d77de738
ML
3522Only emit the Compiled Module Interface, inhibiting any object file.
3523
d77de738 3524@opindex fms-extensions
ddf6fe37 3525@item -fms-extensions
d77de738
ML
3526Disable Wpedantic warnings about constructs used in MFC, such as implicit
3527int and getting a pointer to member function via non-standard syntax.
3528
d77de738 3529@opindex fnew-inheriting-ctors
ddf6fe37 3530@item -fnew-inheriting-ctors
d77de738
ML
3531Enable the P0136 adjustment to the semantics of C++11 constructor
3532inheritance. This is part of C++17 but also considered to be a Defect
3533Report against C++11 and C++14. This flag is enabled by default
3534unless @option{-fabi-version=10} or lower is specified.
3535
d77de738 3536@opindex fnew-ttp-matching
ddf6fe37 3537@item -fnew-ttp-matching
d77de738
ML
3538Enable the P0522 resolution to Core issue 150, template template
3539parameters and default arguments: this allows a template with default
3540template arguments as an argument for a template template parameter
3541with fewer template parameters. This flag is enabled by default for
3542@option{-std=c++17}.
3543
d77de738
ML
3544@opindex fno-nonansi-builtins
3545@opindex fnonansi-builtins
ddf6fe37 3546@item -fno-nonansi-builtins
d77de738
ML
3547Disable built-in declarations of functions that are not mandated by
3548ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3549@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3550
d77de738 3551@opindex fnothrow-opt
ddf6fe37 3552@item -fnothrow-opt
d77de738
ML
3553Treat a @code{throw()} exception specification as if it were a
3554@code{noexcept} specification to reduce or eliminate the text size
3555overhead relative to a function with no exception specification. If
3556the function has local variables of types with non-trivial
3557destructors, the exception specification actually makes the
3558function smaller because the EH cleanups for those variables can be
3559optimized away. The semantic effect is that an exception thrown out of
3560a function with such an exception specification results in a call
3561to @code{terminate} rather than @code{unexpected}.
3562
d77de738
ML
3563@opindex fno-operator-names
3564@opindex foperator-names
ddf6fe37 3565@item -fno-operator-names
d77de738
ML
3566Do not treat the operator name keywords @code{and}, @code{bitand},
3567@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3568synonyms as keywords.
3569
d77de738
ML
3570@opindex fno-optional-diags
3571@opindex foptional-diags
ddf6fe37 3572@item -fno-optional-diags
d77de738
ML
3573Disable diagnostics that the standard says a compiler does not need to
3574issue. Currently, the only such diagnostic issued by G++ is the one for
3575a name having multiple meanings within a class.
3576
d77de738
ML
3577@opindex fno-pretty-templates
3578@opindex fpretty-templates
ddf6fe37 3579@item -fno-pretty-templates
d77de738
ML
3580When an error message refers to a specialization of a function
3581template, the compiler normally prints the signature of the
3582template followed by the template arguments and any typedefs or
3583typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3584rather than @code{void f(int)}) so that it's clear which template is
3585involved. When an error message refers to a specialization of a class
3586template, the compiler omits any template arguments that match
3587the default template arguments for that template. If either of these
3588behaviors make it harder to understand the error message rather than
3589easier, you can use @option{-fno-pretty-templates} to disable them.
3590
d77de738
ML
3591@opindex fno-rtti
3592@opindex frtti
ddf6fe37 3593@item -fno-rtti
d77de738
ML
3594Disable generation of information about every class with virtual
3595functions for use by the C++ run-time type identification features
3596(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3597of the language, you can save some space by using this flag. Note that
3598exception handling uses the same information, but G++ generates it as
3599needed. The @code{dynamic_cast} operator can still be used for casts that
3600do not require run-time type information, i.e.@: casts to @code{void *} or to
3601unambiguous base classes.
3602
3603Mixing code compiled with @option{-frtti} with that compiled with
3604@option{-fno-rtti} may not work. For example, programs may
3605fail to link if a class compiled with @option{-fno-rtti} is used as a base
3606for a class compiled with @option{-frtti}.
3607
d77de738 3608@opindex fsized-deallocation
ddf6fe37 3609@item -fsized-deallocation
d77de738
ML
3610Enable the built-in global declarations
3611@smallexample
3612void operator delete (void *, std::size_t) noexcept;
3613void operator delete[] (void *, std::size_t) noexcept;
3614@end smallexample
3615as introduced in C++14. This is useful for user-defined replacement
3616deallocation functions that, for example, use the size of the object
3617to make deallocation faster. Enabled by default under
3618@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3619warns about places that might want to add a definition.
3620
d77de738 3621@opindex fstrict-enums
ddf6fe37 3622@item -fstrict-enums
d77de738
ML
3623Allow the compiler to optimize using the assumption that a value of
3624enumerated type can only be one of the values of the enumeration (as
3625defined in the C++ standard; basically, a value that can be
3626represented in the minimum number of bits needed to represent all the
3627enumerators). This assumption may not be valid if the program uses a
3628cast to convert an arbitrary integer value to the enumerated type.
d8a656d5
JW
3629This option has no effect for an enumeration type with a fixed underlying
3630type.
d77de738 3631
d77de738 3632@opindex fstrong-eval-order
ddf6fe37 3633@item -fstrong-eval-order
d77de738
ML
3634Evaluate member access, array subscripting, and shift expressions in
3635left-to-right order, and evaluate assignment in right-to-left order,
3636as adopted for C++17. Enabled by default with @option{-std=c++17}.
3637@option{-fstrong-eval-order=some} enables just the ordering of member
3638access and shift expressions, and is the default without
3639@option{-std=c++17}.
3640
d77de738 3641@opindex ftemplate-backtrace-limit
ddf6fe37 3642@item -ftemplate-backtrace-limit=@var{n}
d77de738
ML
3643Set the maximum number of template instantiation notes for a single
3644warning or error to @var{n}. The default value is 10.
3645
d77de738 3646@opindex ftemplate-depth
ddf6fe37 3647@item -ftemplate-depth=@var{n}
d77de738
ML
3648Set the maximum instantiation depth for template classes to @var{n}.
3649A limit on the template instantiation depth is needed to detect
3650endless recursions during template class instantiation. ANSI/ISO C++
3651conforming programs must not rely on a maximum depth greater than 17
3652(changed to 1024 in C++11). The default value is 900, as the compiler
3653can run out of stack space before hitting 1024 in some situations.
3654
d77de738
ML
3655@opindex fno-threadsafe-statics
3656@opindex fthreadsafe-statics
ddf6fe37 3657@item -fno-threadsafe-statics
d77de738
ML
3658Do not emit the extra code to use the routines specified in the C++
3659ABI for thread-safe initialization of local statics. You can use this
3660option to reduce code size slightly in code that doesn't need to be
3661thread-safe.
3662
d77de738 3663@opindex fuse-cxa-atexit
ddf6fe37 3664@item -fuse-cxa-atexit
d77de738
ML
3665Register destructors for objects with static storage duration with the
3666@code{__cxa_atexit} function rather than the @code{atexit} function.
3667This option is required for fully standards-compliant handling of static
3668destructors, but only works if your C library supports
3669@code{__cxa_atexit}.
3670
d77de738
ML
3671@opindex fno-use-cxa-get-exception-ptr
3672@opindex fuse-cxa-get-exception-ptr
ddf6fe37 3673@item -fno-use-cxa-get-exception-ptr
d77de738
ML
3674Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3675causes @code{std::uncaught_exception} to be incorrect, but is necessary
3676if the runtime routine is not available.
3677
d77de738 3678@opindex fvisibility-inlines-hidden
ddf6fe37 3679@item -fvisibility-inlines-hidden
d77de738
ML
3680This switch declares that the user does not attempt to compare
3681pointers to inline functions or methods where the addresses of the two functions
3682are taken in different shared objects.
3683
3684The effect of this is that GCC may, effectively, mark inline methods with
3685@code{__attribute__ ((visibility ("hidden")))} so that they do not
3686appear in the export table of a DSO and do not require a PLT indirection
3687when used within the DSO@. Enabling this option can have a dramatic effect
3688on load and link times of a DSO as it massively reduces the size of the
3689dynamic export table when the library makes heavy use of templates.
3690
3691The behavior of this switch is not quite the same as marking the
3692methods as hidden directly, because it does not affect static variables
3693local to the function or cause the compiler to deduce that
3694the function is defined in only one shared object.
3695
3696You may mark a method as having a visibility explicitly to negate the
3697effect of the switch for that method. For example, if you do want to
3698compare pointers to a particular inline method, you might mark it as
3699having default visibility. Marking the enclosing class with explicit
3700visibility has no effect.
3701
3702Explicitly instantiated inline methods are unaffected by this option
3703as their linkage might otherwise cross a shared library boundary.
3704@xref{Template Instantiation}.
3705
d77de738 3706@opindex fvisibility-ms-compat
ddf6fe37 3707@item -fvisibility-ms-compat
d77de738
ML
3708This flag attempts to use visibility settings to make GCC's C++
3709linkage model compatible with that of Microsoft Visual Studio.
3710
3711The flag makes these changes to GCC's linkage model:
3712
3713@enumerate
3714@item
3715It sets the default visibility to @code{hidden}, like
3716@option{-fvisibility=hidden}.
3717
3718@item
3719Types, but not their members, are not hidden by default.
3720
3721@item
3722The One Definition Rule is relaxed for types without explicit
3723visibility specifications that are defined in more than one
3724shared object: those declarations are permitted if they are
3725permitted when this option is not used.
3726@end enumerate
3727
3728In new code it is better to use @option{-fvisibility=hidden} and
3729export those classes that are intended to be externally visible.
3730Unfortunately it is possible for code to rely, perhaps accidentally,
3731on the Visual Studio behavior.
3732
3733Among the consequences of these changes are that static data members
3734of the same type with the same name but defined in different shared
3735objects are different, so changing one does not change the other;
3736and that pointers to function members defined in different shared
3737objects may not compare equal. When this flag is given, it is a
3738violation of the ODR to define types with the same name differently.
3739
d77de738
ML
3740@opindex fno-weak
3741@opindex fweak
ddf6fe37 3742@item -fno-weak
d77de738
ML
3743Do not use weak symbol support, even if it is provided by the linker.
3744By default, G++ uses weak symbols if they are available. This
3745option exists only for testing, and should not be used by end-users;
3746it results in inferior code and has no benefits. This option may
3747be removed in a future release of G++.
3748
d77de738
ML
3749@opindex fext-numeric-literals
3750@opindex fno-ext-numeric-literals
ddf6fe37 3751@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
d77de738
ML
3752Accept imaginary, fixed-point, or machine-defined
3753literal number suffixes as GNU extensions.
3754When this option is turned off these suffixes are treated
3755as C++11 user-defined literal numeric suffixes.
3756This is on by default for all pre-C++11 dialects and all GNU dialects:
3757@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3758@option{-std=gnu++14}.
3759This option is off by default
3760for ISO C++11 onwards (@option{-std=c++11}, ...).
3761
d77de738 3762@opindex nostdinc++
ddf6fe37 3763@item -nostdinc++
d77de738
ML
3764Do not search for header files in the standard directories specific to
3765C++, but do still search the other standard directories. (This option
3766is used when building the C++ library.)
3767
ddf6fe37
AA
3768@opindex flang-info-include-translate
3769@opindex flang-info-include-translate-not
d77de738
ML
3770@item -flang-info-include-translate
3771@itemx -flang-info-include-translate-not
3772@itemx -flang-info-include-translate=@var{header}
d77de738
ML
3773Inform of include translation events. The first will note accepted
3774include translations, the second will note declined include
3775translations. The @var{header} form will inform of include
3776translations relating to that specific header. If @var{header} is of
3777the form @code{"user"} or @code{<system>} it will be resolved to a
3778specific user or system header using the include path.
3779
ddf6fe37 3780@opindex flang-info-module-cmi
d77de738
ML
3781@item -flang-info-module-cmi
3782@itemx -flang-info-module-cmi=@var{module}
d77de738
ML
3783Inform of Compiled Module Interface pathnames. The first will note
3784all read CMI pathnames. The @var{module} form will not reading a
3785specific module's CMI. @var{module} may be a named module or a
3786header-unit (the latter indicated by either being a pathname containing
3787directory separators or enclosed in @code{<>} or @code{""}).
3788
d77de738 3789@opindex stdlib
ddf6fe37 3790@item -stdlib=@var{libstdc++,libc++}
d77de738
ML
3791When G++ is configured to support this option, it allows specification of
3792alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3793(the default, native C++ runtime for G++) and @var{libc++} which is the
3794C++ runtime installed on some operating systems (e.g. Darwin versions from
3795Darwin11 onwards). The option switches G++ to use the headers from the
3796specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3797when a C++ runtime is required for linking.
3798@end table
3799
3800In addition, these warning options have meanings only for C++ programs:
3801
3802@table @gcctabopt
d77de738 3803@opindex Wabi-tag
ddf6fe37 3804@item -Wabi-tag @r{(C++ and Objective-C++ only)}
d77de738
ML
3805Warn when a type with an ABI tag is used in a context that does not
3806have that ABI tag. See @ref{C++ Attributes} for more information
3807about ABI tags.
3808
d77de738
ML
3809@opindex Wcomma-subscript
3810@opindex Wno-comma-subscript
ddf6fe37 3811@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
d77de738
ML
3812Warn about uses of a comma expression within a subscripting expression.
3813This usage was deprecated in C++20 and is going to be removed in C++23.
3814However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3815
3816@smallexample
3817@group
3818void f(int *a, int b, int c) @{
3819 a[b,c]; // deprecated in C++20, invalid in C++23
3820 a[(b,c)]; // OK
3821@}
3822@end group
3823@end smallexample
3824
3825In C++23 it is valid to have comma separated expressions in a subscript
3826when an overloaded subscript operator is found and supports the right
3827number and types of arguments. G++ will accept the formerly valid syntax
3828for code that is not valid in C++23 but used to be valid but deprecated
3829in C++20 with a pedantic warning that can be disabled with
3830@option{-Wno-comma-subscript}.
3831
3832Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3833and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3834
5fccebdb
JM
3835This warning is upgraded to an error by @option{-pedantic-errors} in
3836C++23 mode or later.
3837
d77de738
ML
3838@opindex Wctad-maybe-unsupported
3839@opindex Wno-ctad-maybe-unsupported
ddf6fe37 3840@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
d77de738
ML
3841Warn when performing class template argument deduction (CTAD) on a type with
3842no explicitly written deduction guides. This warning will point out cases
3843where CTAD succeeded only because the compiler synthesized the implicit
3844deduction guides, which might not be what the programmer intended. Certain
3845style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3846types that are designed to support CTAD. This warning can be suppressed with
3847the following pattern:
3848
3849@smallexample
3850struct allow_ctad_t; // any name works
3851template <typename T> struct S @{
3852 S(T) @{ @}
3853@};
4ace81b6
SL
3854// Guide with incomplete parameter type will never be considered.
3855S(allow_ctad_t) -> S<void>;
d77de738
ML
3856@end smallexample
3857
d77de738
ML
3858@opindex Wctor-dtor-privacy
3859@opindex Wno-ctor-dtor-privacy
ddf6fe37 3860@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
d77de738
ML
3861Warn when a class seems unusable because all the constructors or
3862destructors in that class are private, and it has neither friends nor
3863public static member functions. Also warn if there are no non-private
3864methods, and there's at least one private member function that isn't
3865a constructor or destructor.
3866
d77de738
ML
3867@opindex Wdangling-reference
3868@opindex Wno-dangling-reference
ddf6fe37 3869@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
d77de738
ML
3870Warn when a reference is bound to a temporary whose lifetime has ended.
3871For example:
3872
3873@smallexample
3874int n = 1;
3875const int& r = std::max(n - 1, n + 1); // r is dangling
3876@end smallexample
3877
3878In the example above, two temporaries are created, one for each
3879argument, and a reference to one of the temporaries is returned.
3880However, both temporaries are destroyed at the end of the full
3881expression, so the reference @code{r} is dangling. This warning
3882also detects dangling references in member initializer lists:
3883
3884@smallexample
3885const int& f(const int& i) @{ return i; @}
3886struct S @{
3887 const int &r; // r is dangling
3888 S() : r(f(10)) @{ @}
3889@};
3890@end smallexample
3891
3892Member functions are checked as well, but only their object argument:
3893
3894@smallexample
3895struct S @{
3896 const S& self () @{ return *this; @}
3897@};
3898const S& s = S().self(); // s is dangling
3899@end smallexample
3900
3901Certain functions are safe in this respect, for example @code{std::use_facet}:
3902they take and return a reference, but they don't return one of its arguments,
3903which can fool the warning. Such functions can be excluded from the warning
3904by wrapping them in a @code{#pragma}:
3905
3906@smallexample
3907#pragma GCC diagnostic push
3908#pragma GCC diagnostic ignored "-Wdangling-reference"
3909const T& foo (const T&) @{ @dots{} @}
3910#pragma GCC diagnostic pop
3911@end smallexample
3912
c7607c4c
MP
3913The @code{#pragma} can also surround the class; in that case, the warning
3914will be disabled for all the member functions.
3915
ce51e843
ML
3916@option{-Wdangling-reference} also warns about code like
3917
3918@smallexample
3919auto p = std::minmax(1, 2);
3920@end smallexample
3921
3922where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3923both references dangle after the end of the full expression that contains
3924the call to @code{std::minmax}.
3925
f2061b2a
MP
3926The warning does not warn for @code{std::span}-like classes. We consider
3927classes of the form:
3928
3929@smallexample
3930template<typename T>
3931struct Span @{
3932 T* data_;
3933 std::size len_;
3934@};
3935@end smallexample
3936
8efcdbf5 3937as @code{std::span}-like; that is, the class is a non-union class
f2061b2a
MP
3938that has a pointer data member and a trivial destructor.
3939
c7607c4c
MP
3940The warning can be disabled by using the @code{gnu::no_dangling} attribute
3941(@pxref{C++ Attributes}).
3942
d77de738
ML
3943This warning is enabled by @option{-Wall}.
3944
d77de738
ML
3945@opindex Wdelete-non-virtual-dtor
3946@opindex Wno-delete-non-virtual-dtor
ddf6fe37 3947@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
3948Warn when @code{delete} is used to destroy an instance of a class that
3949has virtual functions and non-virtual destructor. It is unsafe to delete
3950an instance of a derived class through a pointer to a base class if the
3951base class does not have a virtual destructor. This warning is enabled
3952by @option{-Wall}.
3953
d77de738
ML
3954@opindex Wdeprecated-copy
3955@opindex Wno-deprecated-copy
ddf6fe37 3956@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
d77de738
ML
3957Warn that the implicit declaration of a copy constructor or copy
3958assignment operator is deprecated if the class has a user-provided
3959copy constructor or copy assignment operator, in C++11 and up. This
3960warning is enabled by @option{-Wextra}. With
3961@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3962user-provided destructor.
3963
d77de738
ML
3964@opindex Wdeprecated-enum-enum-conversion
3965@opindex Wno-deprecated-enum-enum-conversion
ddf6fe37 3966@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3967Disable the warning about the case when the usual arithmetic conversions
3968are applied on operands where one is of enumeration type and the other is
3969of a different enumeration type. This conversion was deprecated in C++20.
3970For example:
3971
3972@smallexample
3973enum E1 @{ e @};
3974enum E2 @{ f @};
3975int k = f - e;
3976@end smallexample
3977
3978@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3979@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3980by @option{-Wenum-conversion}.
3981
d77de738
ML
3982@opindex Wdeprecated-enum-float-conversion
3983@opindex Wno-deprecated-enum-float-conversion
ddf6fe37 3984@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3985Disable the warning about the case when the usual arithmetic conversions
3986are applied on operands where one is of enumeration type and the other is
3987of a floating-point type. This conversion was deprecated in C++20. For
3988example:
3989
3990@smallexample
3991enum E1 @{ e @};
3992enum E2 @{ f @};
3993bool b = e <= 3.7;
3994@end smallexample
3995
3996@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3997@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3998by @option{-Wenum-conversion}.
3999
b106f11d
AC
4000@opindex Welaborated-enum-base
4001@opindex Wno-elaborated-enum-base
4002@item -Wno-elaborated-enum-base
4003For C++11 and above, warn if an (invalid) additional enum-base is used
4004in an elaborated-type-specifier. That is, if an enum with given
4005underlying type and no enumerator list is used in a declaration other
4006than just a standalone declaration of the enum. Enabled by default. This
4007warning is upgraded to an error with -pedantic-errors.
4008
d77de738
ML
4009@opindex Winit-list-lifetime
4010@opindex Wno-init-list-lifetime
ddf6fe37 4011@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
d77de738
ML
4012Do not warn about uses of @code{std::initializer_list} that are likely
4013to result in dangling pointers. Since the underlying array for an
4014@code{initializer_list} is handled like a normal C++ temporary object,
4015it is easy to inadvertently keep a pointer to the array past the end
4016of the array's lifetime. For example:
4017
4018@itemize @bullet
4019@item
4020If a function returns a temporary @code{initializer_list}, or a local
4021@code{initializer_list} variable, the array's lifetime ends at the end
4022of the return statement, so the value returned has a dangling pointer.
4023
4024@item
4025If a new-expression creates an @code{initializer_list}, the array only
4026lives until the end of the enclosing full-expression, so the
4027@code{initializer_list} in the heap has a dangling pointer.
4028
4029@item
4030When an @code{initializer_list} variable is assigned from a
4031brace-enclosed initializer list, the temporary array created for the
4032right side of the assignment only lives until the end of the
4033full-expression, so at the next statement the @code{initializer_list}
4034variable has a dangling pointer.
4035
4036@smallexample
4037// li's initial underlying array lives as long as li
4038std::initializer_list<int> li = @{ 1,2,3 @};
4039// assignment changes li to point to a temporary array
4040li = @{ 4, 5 @};
4041// now the temporary is gone and li has a dangling pointer
4042int i = li.begin()[0] // undefined behavior
4043@end smallexample
4044
4045@item
4046When a list constructor stores the @code{begin} pointer from the
4047@code{initializer_list} argument, this doesn't extend the lifetime of
4048the array, so if a class variable is constructed from a temporary
4049@code{initializer_list}, the pointer is left dangling by the end of
4050the variable declaration statement.
4051
4052@end itemize
4053
c85f8dbb
MP
4054@opindex Winvalid-constexpr
4055@opindex Wno-invalid-constexpr
ddf6fe37 4056@item -Winvalid-constexpr
c85f8dbb
MP
4057
4058Warn when a function never produces a constant expression. In C++20
4059and earlier, for every @code{constexpr} function and function template,
4060there must be at least one set of function arguments in at least one
4061instantiation such that an invocation of the function or constructor
4062could be an evaluated subexpression of a core constant expression.
4063C++23 removed this restriction, so it's possible to have a function
4064or a function template marked @code{constexpr} for which no invocation
4065satisfies the requirements of a core constant expression.
4066
4067This warning is enabled as a pedantic warning by default in C++20 and
4068earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
4069which case it will be an ordinary warning. For example:
4070
4071@smallexample
4072void f (int& i);
4073constexpr void
4074g (int& i)
4075@{
4ace81b6
SL
4076 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
4077 f(i);
c85f8dbb
MP
4078@}
4079@end smallexample
4080
d77de738
ML
4081@opindex Winvalid-imported-macros
4082@opindex Wno-invalid-imported-macros
ddf6fe37 4083@item -Winvalid-imported-macros
d77de738
ML
4084Verify all imported macro definitions are valid at the end of
4085compilation. This is not enabled by default, as it requires
4086additional processing to determine. It may be useful when preparing
4087sets of header-units to ensure consistent macros.
4088
d77de738
ML
4089@opindex Wliteral-suffix
4090@opindex Wno-literal-suffix
ddf6fe37 4091@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
d77de738
ML
4092Do not warn when a string or character literal is followed by a
4093ud-suffix which does not begin with an underscore. As a conforming
4094extension, GCC treats such suffixes as separate preprocessing tokens
4095in order to maintain backwards compatibility with code that uses
4096formatting macros from @code{<inttypes.h>}. For example:
4097
4098@smallexample
4099#define __STDC_FORMAT_MACROS
4100#include <inttypes.h>
4101#include <stdio.h>
4102
4103int main() @{
4104 int64_t i64 = 123;
4105 printf("My int64: %" PRId64"\n", i64);
4106@}
4107@end smallexample
4108
4109In this case, @code{PRId64} is treated as a separate preprocessing token.
4110
4111This option also controls warnings when a user-defined literal
4112operator is declared with a literal suffix identifier that doesn't
4113begin with an underscore. Literal suffix identifiers that don't begin
4114with an underscore are reserved for future standardization.
4115
4116These warnings are enabled by default.
4117
d77de738
ML
4118@opindex Wnarrowing
4119@opindex Wno-narrowing
ddf6fe37 4120@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
d77de738
ML
4121For C++11 and later standards, narrowing conversions are diagnosed by default,
4122as required by the standard. A narrowing conversion from a constant produces
4123an error, and a narrowing conversion from a non-constant produces a warning,
4124but @option{-Wno-narrowing} suppresses the diagnostic.
4125Note that this does not affect the meaning of well-formed code;
4126narrowing conversions are still considered ill-formed in SFINAE contexts.
4127
4128With @option{-Wnarrowing} in C++98, warn when a narrowing
4129conversion prohibited by C++11 occurs within
4130@samp{@{ @}}, e.g.
4131
4132@smallexample
4133int i = @{ 2.2 @}; // error: narrowing from double to int
4134@end smallexample
4135
4136This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
4137
d77de738
ML
4138@opindex Wnoexcept
4139@opindex Wno-noexcept
ddf6fe37 4140@item -Wnoexcept @r{(C++ and Objective-C++ only)}
d77de738
ML
4141Warn when a noexcept-expression evaluates to false because of a call
4142to a function that does not have a non-throwing exception
4143specification (i.e. @code{throw()} or @code{noexcept}) but is known by
4144the compiler to never throw an exception.
4145
d77de738
ML
4146@opindex Wnoexcept-type
4147@opindex Wno-noexcept-type
ddf6fe37 4148@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
d77de738
ML
4149Warn if the C++17 feature making @code{noexcept} part of a function
4150type changes the mangled name of a symbol relative to C++14. Enabled
4151by @option{-Wabi} and @option{-Wc++17-compat}.
4152
4153As an example:
4154
4155@smallexample
4156template <class T> void f(T t) @{ t(); @};
4157void g() noexcept;
4158void h() @{ f(g); @}
4159@end smallexample
4160
4161@noindent
4162In C++14, @code{f} calls @code{f<void(*)()>}, but in
4163C++17 it calls @code{f<void(*)()noexcept>}.
4164
d77de738
ML
4165@opindex Wclass-memaccess
4166@opindex Wno-class-memaccess
ddf6fe37 4167@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
d77de738
ML
4168Warn when the destination of a call to a raw memory function such as
4169@code{memset} or @code{memcpy} is an object of class type, and when writing
4170into such an object might bypass the class non-trivial or deleted constructor
4171or copy assignment, violate const-correctness or encapsulation, or corrupt
4172virtual table pointers. Modifying the representation of such objects may
4173violate invariants maintained by member functions of the class. For example,
4174the call to @code{memset} below is undefined because it modifies a non-trivial
4175class object and is, therefore, diagnosed. The safe way to either initialize
4176or clear the storage of objects of such types is by using the appropriate
4177constructor or assignment operator, if one is available.
4178@smallexample
4179std::string str = "abc";
4180memset (&str, 0, sizeof str);
4181@end smallexample
4182The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4183Explicitly casting the pointer to the class object to @code{void *} or
4184to a type that can be safely accessed by the raw memory function suppresses
4185the warning.
4186
d77de738
ML
4187@opindex Wnon-virtual-dtor
4188@opindex Wno-non-virtual-dtor
ddf6fe37 4189@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
4190Warn when a class has virtual functions and an accessible non-virtual
4191destructor itself or in an accessible polymorphic base class, in which
4192case it is possible but unsafe to delete an instance of a derived
4193class through a pointer to the class itself or base class. This
4194warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4195The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4196should be preferred because it warns about the unsafe cases without false
4197positives.
d77de738 4198
d77de738
ML
4199@opindex Wregister
4200@opindex Wno-register
ddf6fe37 4201@item -Wregister @r{(C++ and Objective-C++ only)}
d77de738
ML
4202Warn on uses of the @code{register} storage class specifier, except
4203when it is part of the GNU @ref{Explicit Register Variables} extension.
4204The use of the @code{register} keyword as storage class specifier has
4205been deprecated in C++11 and removed in C++17.
4206Enabled by default with @option{-std=c++17}.
4207
d77de738
ML
4208@opindex Wreorder
4209@opindex Wno-reorder
4210@cindex reordering, warning
4211@cindex warning for reordering of member initializers
f33d7a88 4212@item -Wreorder @r{(C++ and Objective-C++ only)}
d77de738
ML
4213Warn when the order of member initializers given in the code does not
4214match the order in which they must be executed. For instance:
4215
4216@smallexample
4217struct A @{
4218 int i;
4219 int j;
4220 A(): j (0), i (1) @{ @}
4221@};
4222@end smallexample
4223
4224@noindent
4225The compiler rearranges the member initializers for @code{i}
4226and @code{j} to match the declaration order of the members, emitting
4227a warning to that effect. This warning is enabled by @option{-Wall}.
4228
d77de738
ML
4229@opindex Wpessimizing-move
4230@opindex Wno-pessimizing-move
ddf6fe37 4231@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4232This warning warns when a call to @code{std::move} prevents copy
4233elision. A typical scenario when copy elision can occur is when returning in
4234a function with a class return type, when the expression being returned is the
4235name of a non-volatile automatic object, and is not a function parameter, and
4236has the same type as the function return type.
4237
4238@smallexample
4239struct T @{
4240@dots{}
4241@};
4242T fn()
4243@{
4244 T t;
4245 @dots{}
4246 return std::move (t);
4247@}
4248@end smallexample
4249
4250But in this example, the @code{std::move} call prevents copy elision.
4251
4252This warning is enabled by @option{-Wall}.
4253
d77de738
ML
4254@opindex Wredundant-move
4255@opindex Wno-redundant-move
ddf6fe37 4256@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4257This warning warns about redundant calls to @code{std::move}; that is, when
4258a move operation would have been performed even without the @code{std::move}
4259call. This happens because the compiler is forced to treat the object as if
4260it were an rvalue in certain situations such as returning a local variable,
4261where copy elision isn't applicable. Consider:
4262
4263@smallexample
4264struct T @{
4265@dots{}
4266@};
4267T fn(T t)
4268@{
4269 @dots{}
4270 return std::move (t);
4271@}
4272@end smallexample
4273
4274Here, the @code{std::move} call is redundant. Because G++ implements Core
4275Issue 1579, another example is:
4276
4277@smallexample
4278struct T @{ // convertible to U
4279@dots{}
4280@};
4281struct U @{
4282@dots{}
4283@};
4284U fn()
4285@{
4286 T t;
4287 @dots{}
4288 return std::move (t);
4289@}
4290@end smallexample
4291In this example, copy elision isn't applicable because the type of the
4292expression being returned and the function return type differ, yet G++
4293treats the return value as if it were designated by an rvalue.
4294
4295This warning is enabled by @option{-Wextra}.
4296
d77de738
ML
4297@opindex Wrange-loop-construct
4298@opindex Wno-range-loop-construct
ddf6fe37 4299@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
d77de738
ML
4300This warning warns when a C++ range-based for-loop is creating an unnecessary
4301copy. This can happen when the range declaration is not a reference, but
4302probably should be. For example:
4303
4304@smallexample
4305struct S @{ char arr[128]; @};
4306void fn () @{
4307 S arr[5];
4308 for (const auto x : arr) @{ @dots{} @}
4309@}
4310@end smallexample
4311
4312It does not warn when the type being copied is a trivially-copyable type whose
4313size is less than 64 bytes.
4314
4315This warning also warns when a loop variable in a range-based for-loop is
4316initialized with a value of a different type resulting in a copy. For example:
4317
4318@smallexample
4319void fn() @{
4320 int arr[10];
4321 for (const double &x : arr) @{ @dots{} @}
4322@}
4323@end smallexample
4324
4325In the example above, in every iteration of the loop a temporary value of
4326type @code{double} is created and destroyed, to which the reference
4327@code{const double &} is bound.
4328
4329This warning is enabled by @option{-Wall}.
4330
d77de738
ML
4331@opindex Wredundant-tags
4332@opindex Wno-redundant-tags
ddf6fe37 4333@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4334Warn about redundant class-key and enum-key in references to class types
4335and enumerated types in contexts where the key can be eliminated without
4336causing an ambiguity. For example:
4337
4338@smallexample
4339struct foo;
4340struct foo *p; // warn that keyword struct can be eliminated
4341@end smallexample
4342
4343@noindent
4344On the other hand, in this example there is no warning:
4345
4346@smallexample
4347struct foo;
4348void foo (); // "hides" struct foo
4349void bar (struct foo&); // no warning, keyword struct is necessary
4350@end smallexample
4351
d77de738
ML
4352@opindex Wsubobject-linkage
4353@opindex Wno-subobject-linkage
ddf6fe37 4354@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
d77de738
ML
4355Do not warn
4356if a class type has a base or a field whose type uses the anonymous
4357namespace or depends on a type with no linkage. If a type A depends on
4358a type B with no or internal linkage, defining it in multiple
4359translation units would be an ODR violation because the meaning of B
4360is different in each translation unit. If A only appears in a single
4361translation unit, the best way to silence the warning is to give it
4362internal linkage by putting it in an anonymous namespace as well. The
4363compiler doesn't give this warning for types defined in the main .C
4364file, as those are unlikely to have multiple definitions.
4365@option{-Wsubobject-linkage} is enabled by default.
4366
d77de738
ML
4367@opindex Weffc++
4368@opindex Wno-effc++
ddf6fe37 4369@item -Weffc++ @r{(C++ and Objective-C++ only)}
d77de738
ML
4370Warn about violations of the following style guidelines from Scott Meyers'
4371@cite{Effective C++} series of books:
4372
4373@itemize @bullet
4374@item
4375Define a copy constructor and an assignment operator for classes
4376with dynamically-allocated memory.
4377
4378@item
4379Prefer initialization to assignment in constructors.
4380
4381@item
4382Have @code{operator=} return a reference to @code{*this}.
4383
4384@item
4385Don't try to return a reference when you must return an object.
4386
4387@item
4388Distinguish between prefix and postfix forms of increment and
4389decrement operators.
4390
4391@item
4392Never overload @code{&&}, @code{||}, or @code{,}.
4393
4394@end itemize
4395
4396This option also enables @option{-Wnon-virtual-dtor}, which is also
4397one of the effective C++ recommendations. However, the check is
4398extended to warn about the lack of virtual destructor in accessible
4399non-polymorphic bases classes too.
4400
4401When selecting this option, be aware that the standard library
4402headers do not obey all of these guidelines; use @samp{grep -v}
4403to filter out those warnings.
4404
d77de738
ML
4405@opindex Wexceptions
4406@opindex Wno-exceptions
ddf6fe37 4407@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
d77de738
ML
4408Disable the warning about the case when an exception handler is shadowed by
4409another handler, which can point out a wrong ordering of exception handlers.
4410
d77de738
ML
4411@opindex Wstrict-null-sentinel
4412@opindex Wno-strict-null-sentinel
ddf6fe37 4413@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
d77de738
ML
4414Warn about the use of an uncasted @code{NULL} as sentinel. When
4415compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4416to @code{__null}. Although it is a null pointer constant rather than a
4417null pointer, it is guaranteed to be of the same size as a pointer.
4418But this use is not portable across different compilers.
4419
d77de738
ML
4420@opindex Wno-non-template-friend
4421@opindex Wnon-template-friend
ddf6fe37 4422@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
d77de738
ML
4423Disable warnings when non-template friend functions are declared
4424within a template. In very old versions of GCC that predate implementation
4425of the ISO standard, declarations such as
4426@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4427could be interpreted as a particular specialization of a template
4428function; the warning exists to diagnose compatibility problems,
4429and is enabled by default.
4430
d77de738
ML
4431@opindex Wold-style-cast
4432@opindex Wno-old-style-cast
ddf6fe37 4433@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4434Warn if an old-style (C-style) cast to a non-void type is used within
4435a C++ program. The new-style casts (@code{dynamic_cast},
4436@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4437less vulnerable to unintended effects and much easier to search for.
4438
d77de738
ML
4439@opindex Woverloaded-virtual
4440@opindex Wno-overloaded-virtual
4441@cindex overloaded virtual function, warning
4442@cindex warning for overloaded virtual function
f33d7a88
AA
4443@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4444@itemx -Woverloaded-virtual=@var{n}
d77de738
ML
4445Warn when a function declaration hides virtual functions from a
4446base class. For example, in:
4447
4448@smallexample
4449struct A @{
4450 virtual void f();
4451@};
4452
4453struct B: public A @{
4454 void f(int); // does not override
4455@};
4456@end smallexample
4457
4458the @code{A} class version of @code{f} is hidden in @code{B}, and code
4459like:
4460
4461@smallexample
4462B* b;
4463b->f();
4464@end smallexample
4465
4466@noindent
4467fails to compile.
4468
d82490d5
JW
4469In cases where the different signatures are not an accident, the
4470simplest solution is to add a using-declaration to the derived class
4471to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4472
d77de738
ML
4473The optional level suffix controls the behavior when all the
4474declarations in the derived class override virtual functions in the
4475base class, even if not all of the base functions are overridden:
4476
4477@smallexample
4478struct C @{
4479 virtual void f();
4480 virtual void f(int);
4481@};
4482
4483struct D: public C @{
4484 void f(int); // does override
4485@}
4486@end smallexample
4487
4488This pattern is less likely to be a mistake; if D is only used
4489virtually, the user might have decided that the base class semantics
4490for some of the overloads are fine.
4491
4492At level 1, this case does not warn; at level 2, it does.
4493@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4494included in @option{-Wall}.
4495
d77de738
ML
4496@opindex Wno-pmf-conversions
4497@opindex Wpmf-conversions
ddf6fe37 4498@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
d77de738
ML
4499Disable the diagnostic for converting a bound pointer to member function
4500to a plain pointer.
4501
d77de738
ML
4502@opindex Wsign-promo
4503@opindex Wno-sign-promo
ddf6fe37 4504@item -Wsign-promo @r{(C++ and Objective-C++ only)}
d77de738
ML
4505Warn when overload resolution chooses a promotion from unsigned or
4506enumerated type to a signed type, over a conversion to an unsigned type of
4507the same size. Previous versions of G++ tried to preserve
4508unsignedness, but the standard mandates the current behavior.
4509
d77de738
ML
4510@opindex Wtemplates
4511@opindex Wno-templates
ddf6fe37 4512@item -Wtemplates @r{(C++ and Objective-C++ only)}
d77de738
ML
4513Warn when a primary template declaration is encountered. Some coding
4514rules disallow templates, and this may be used to enforce that rule.
4515The warning is inactive inside a system header file, such as the STL, so
4516one can still use the STL. One may also instantiate or specialize
4517templates.
4518
d77de738
ML
4519@opindex Wmismatched-new-delete
4520@opindex Wno-mismatched-new-delete
ddf6fe37 4521@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
d77de738
ML
4522Warn for mismatches between calls to @code{operator new} or @code{operator
4523delete} and the corresponding call to the allocation or deallocation function.
4524This includes invocations of C++ @code{operator delete} with pointers
4525returned from either mismatched forms of @code{operator new}, or from other
4526functions that allocate objects for which the @code{operator delete} isn't
4527a suitable deallocator, as well as calls to other deallocation functions
4528with pointers returned from @code{operator new} for which the deallocation
4529function isn't suitable.
4530
4531For example, the @code{delete} expression in the function below is diagnosed
4532because it doesn't match the array form of the @code{new} expression
4533the pointer argument was returned from. Similarly, the call to @code{free}
4534is also diagnosed.
4535
4536@smallexample
4537void f ()
4538@{
4539 int *a = new int[n];
4540 delete a; // warning: mismatch in array forms of expressions
4541
4542 char *p = new char[n];
4543 free (p); // warning: mismatch between new and free
4544@}
4545@end smallexample
4546
4547The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4548involving allocation and deallocation functions other than @code{operator
4549new} and @code{operator delete}.
4550
4551@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4552
d77de738
ML
4553@opindex Wmismatched-tags
4554@opindex Wno-mismatched-tags
ddf6fe37 4555@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4556Warn for declarations of structs, classes, and class templates and their
4557specializations with a class-key that does not match either the definition
4558or the first declaration if no definition is provided.
4559
4560For example, the declaration of @code{struct Object} in the argument list
4561of @code{draw} triggers the warning. To avoid it, either remove the redundant
4562class-key @code{struct} or replace it with @code{class} to match its definition.
4563@smallexample
4564class Object @{
4565public:
4566 virtual ~Object () = 0;
4567@};
4568void draw (struct Object*);
4569@end smallexample
4570
4571It is not wrong to declare a class with the class-key @code{struct} as
4572the example above shows. The @option{-Wmismatched-tags} option is intended
4573to help achieve a consistent style of class declarations. In code that is
4574intended to be portable to Windows-based compilers the warning helps prevent
4575unresolved references due to the difference in the mangling of symbols
4576declared with different class-keys. The option can be used either on its
4577own or in conjunction with @option{-Wredundant-tags}.
4578
d77de738
ML
4579@opindex Wmultiple-inheritance
4580@opindex Wno-multiple-inheritance
ddf6fe37 4581@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
d77de738
ML
4582Warn when a class is defined with multiple direct base classes. Some
4583coding rules disallow multiple inheritance, and this may be used to
4584enforce that rule. The warning is inactive inside a system header file,
4585such as the STL, so one can still use the STL. One may also define
4586classes that indirectly use multiple inheritance.
4587
d77de738
ML
4588@opindex Wvirtual-inheritance
4589@opindex Wno-virtual-inheritance
ddf6fe37 4590@item -Wvirtual-inheritance
d77de738
ML
4591Warn when a class is defined with a virtual direct base class. Some
4592coding rules disallow multiple inheritance, and this may be used to
4593enforce that rule. The warning is inactive inside a system header file,
4594such as the STL, so one can still use the STL. One may also define
4595classes that indirectly use virtual inheritance.
4596
d77de738
ML
4597@opindex Wvirtual-move-assign
4598@opindex Wno-virtual-move-assign
ddf6fe37 4599@item -Wno-virtual-move-assign
d77de738
ML
4600Suppress warnings about inheriting from a virtual base with a
4601non-trivial C++11 move assignment operator. This is dangerous because
4602if the virtual base is reachable along more than one path, it is
4603moved multiple times, which can mean both objects end up in the
4604moved-from state. If the move assignment operator is written to avoid
4605moving from a moved-from object, this warning can be disabled.
4606
d77de738
ML
4607@opindex Wnamespaces
4608@opindex Wno-namespaces
ddf6fe37 4609@item -Wnamespaces
d77de738
ML
4610Warn when a namespace definition is opened. Some coding rules disallow
4611namespaces, and this may be used to enforce that rule. The warning is
4612inactive inside a system header file, such as the STL, so one can still
4613use the STL. One may also use using directives and qualified names.
4614
cff174fa
MP
4615@opindex Wtemplate-id-cdtor
4616@opindex Wno-template-id-cdtor
4617@item -Wno-template-id-cdtor @r{(C++ and Objective-C++ only)}
4618Disable the warning about the use of simple-template-id as the declarator-id
4619of a constructor or destructor, which became invalid in C++20 via DR 2237.
4620For example:
4621
4622@smallexample
4623template<typename T> struct S @{
4624 S<T>(); // should be S();
4625 ~S<T>(); // should be ~S();
4626@};
4627@end smallexample
4628
4629@option{-Wtemplate-id-cdtor} is enabled by default with
4630@option{-std=c++20}; it is also enabled by @option{-Wc++20-compat}.
4631
d77de738
ML
4632@opindex Wterminate
4633@opindex Wno-terminate
ddf6fe37 4634@item -Wno-terminate @r{(C++ and Objective-C++ only)}
d77de738
ML
4635Disable the warning about a throw-expression that will immediately
4636result in a call to @code{terminate}.
4637
d77de738
ML
4638@opindex Wvexing-parse
4639@opindex Wno-vexing-parse
ddf6fe37 4640@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
d77de738
ML
4641Warn about the most vexing parse syntactic ambiguity. This warns about
4642the cases when a declaration looks like a variable definition, but the
4643C++ language requires it to be interpreted as a function declaration.
4644For instance:
4645
4646@smallexample
4647void f(double a) @{
4648 int i(); // extern int i (void);
4649 int n(int(a)); // extern int n (int);
4650@}
4651@end smallexample
4652
4653Another example:
4654
4655@smallexample
4656struct S @{ S(int); @};
4657void f(double a) @{
4658 S x(int(a)); // extern struct S x (int);
4659 S y(int()); // extern struct S y (int (*) (void));
4660 S z(); // extern struct S z (void);
4661@}
4662@end smallexample
4663
4664The warning will suggest options how to deal with such an ambiguity; e.g.,
4665it can suggest removing the parentheses or using braces instead.
4666
4667This warning is enabled by default.
4668
d77de738
ML
4669@opindex Wno-class-conversion
4670@opindex Wclass-conversion
ddf6fe37 4671@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
4672Do not warn when a conversion function converts an
4673object to the same type, to a base class of that type, or to void; such
4674a conversion function will never be called.
4675
d77de738
ML
4676@opindex Wvolatile
4677@opindex Wno-volatile
ddf6fe37 4678@item -Wvolatile @r{(C++ and Objective-C++ only)}
d77de738
ML
4679Warn about deprecated uses of the @code{volatile} qualifier. This includes
4680postfix and prefix @code{++} and @code{--} expressions of
4681@code{volatile}-qualified types, using simple assignments where the left
4682operand is a @code{volatile}-qualified non-class type for their value,
4683compound assignments where the left operand is a @code{volatile}-qualified
4684non-class type, @code{volatile}-qualified function return type,
4685@code{volatile}-qualified parameter type, and structured bindings of a
4686@code{volatile}-qualified type. This usage was deprecated in C++20.
4687
4688Enabled by default with @option{-std=c++20}.
4689
d77de738
ML
4690@opindex Wzero-as-null-pointer-constant
4691@opindex Wno-zero-as-null-pointer-constant
ddf6fe37 4692@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
d77de738
ML
4693Warn when a literal @samp{0} is used as null pointer constant. This can
4694be useful to facilitate the conversion to @code{nullptr} in C++11.
4695
d77de738
ML
4696@opindex Waligned-new
4697@opindex Wno-aligned-new
ddf6fe37 4698@item -Waligned-new
d77de738
ML
4699Warn about a new-expression of a type that requires greater alignment
4700than the @code{alignof(std::max_align_t)} but uses an allocation
4701function without an explicit alignment parameter. This option is
4702enabled by @option{-Wall}.
4703
4704Normally this only warns about global allocation functions, but
4705@option{-Waligned-new=all} also warns about class member allocation
4706functions.
4707
d77de738
ML
4708@opindex Wplacement-new
4709@opindex Wno-placement-new
ddf6fe37
AA
4710@item -Wno-placement-new
4711@itemx -Wplacement-new=@var{n}
d77de738
ML
4712Warn about placement new expressions with undefined behavior, such as
4713constructing an object in a buffer that is smaller than the type of
4714the object. For example, the placement new expression below is diagnosed
4715because it attempts to construct an array of 64 integers in a buffer only
471664 bytes large.
4717@smallexample
4718char buf [64];
4719new (buf) int[64];
4720@end smallexample
4721This warning is enabled by default.
4722
4723@table @gcctabopt
4724@item -Wplacement-new=1
4725This is the default warning level of @option{-Wplacement-new}. At this
4726level the warning is not issued for some strictly undefined constructs that
4727GCC allows as extensions for compatibility with legacy code. For example,
4728the following @code{new} expression is not diagnosed at this level even
4729though it has undefined behavior according to the C++ standard because
4730it writes past the end of the one-element array.
4731@smallexample
4732struct S @{ int n, a[1]; @};
4733S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4734new (s->a)int [32]();
4735@end smallexample
4736
4737@item -Wplacement-new=2
4738At this level, in addition to diagnosing all the same constructs as at level
47391, a diagnostic is also issued for placement new expressions that construct
4740an object in the last member of structure whose type is an array of a single
4741element and whose size is less than the size of the object being constructed.
4742While the previous example would be diagnosed, the following construct makes
4743use of the flexible member array extension to avoid the warning at level 2.
4744@smallexample
4745struct S @{ int n, a[]; @};
4746S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4747new (s->a)int [32]();
4748@end smallexample
4749
4750@end table
4751
d77de738
ML
4752@opindex Wcatch-value
4753@opindex Wno-catch-value
ddf6fe37
AA
4754@item -Wcatch-value
4755@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
d77de738
ML
4756Warn about catch handlers that do not catch via reference.
4757With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4758warn about polymorphic class types that are caught by value.
4759With @option{-Wcatch-value=2} warn about all class types that are caught
4760by value. With @option{-Wcatch-value=3} warn about all types that are
4761not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4762
d77de738
ML
4763@opindex Wconditionally-supported
4764@opindex Wno-conditionally-supported
ddf6fe37 4765@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
d77de738
ML
4766Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4767
d77de738
ML
4768@opindex Wdelete-incomplete
4769@opindex Wno-delete-incomplete
ddf6fe37 4770@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
d77de738
ML
4771Do not warn when deleting a pointer to incomplete type, which may cause
4772undefined behavior at runtime. This warning is enabled by default.
4773
d77de738
ML
4774@opindex Wextra-semi
4775@opindex Wno-extra-semi
ddf6fe37 4776@item -Wextra-semi @r{(C++, Objective-C++ only)}
d77de738
ML
4777Warn about redundant semicolons after in-class function definitions.
4778
08edf85f
PP
4779@opindex Wno-global-module
4780@opindex Wglobal-module
4781@item -Wno-global-module @r{(C++ and Objective-C++ only)}
4782Disable the diagnostic for when the global module fragment of a module
4783unit does not consist only of preprocessor directives.
4784
d77de738
ML
4785@opindex Winaccessible-base
4786@opindex Wno-inaccessible-base
ddf6fe37 4787@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
d77de738
ML
4788This option controls warnings
4789when a base class is inaccessible in a class derived from it due to
4790ambiguity. The warning is enabled by default.
4791Note that the warning for ambiguous virtual
4792bases is enabled by the @option{-Wextra} option.
4793@smallexample
4794@group
4795struct A @{ int a; @};
4796
4797struct B : A @{ @};
4798
4799struct C : B, A @{ @};
4800@end group
4801@end smallexample
4802
d77de738
ML
4803@opindex Winherited-variadic-ctor
4804@opindex Wno-inherited-variadic-ctor
ddf6fe37 4805@item -Wno-inherited-variadic-ctor
d77de738
ML
4806Suppress warnings about use of C++11 inheriting constructors when the
4807base class inherited from has a C variadic constructor; the warning is
4808on by default because the ellipsis is not inherited.
4809
d77de738
ML
4810@opindex Wno-invalid-offsetof
4811@opindex Winvalid-offsetof
ddf6fe37 4812@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
d77de738
ML
4813Suppress warnings from applying the @code{offsetof} macro to a non-POD
4814type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4815to a non-standard-layout type is undefined. In existing C++ implementations,
4816however, @code{offsetof} typically gives meaningful results.
4817This flag is for users who are aware that they are
4818writing nonportable code and who have deliberately chosen to ignore the
4819warning about it.
4820
4821The restrictions on @code{offsetof} may be relaxed in a future version
4822of the C++ standard.
4823
d77de738
ML
4824@opindex Wsized-deallocation
4825@opindex Wno-sized-deallocation
ddf6fe37 4826@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
d77de738
ML
4827Warn about a definition of an unsized deallocation function
4828@smallexample
4829void operator delete (void *) noexcept;
4830void operator delete[] (void *) noexcept;
4831@end smallexample
4832without a definition of the corresponding sized deallocation function
4833@smallexample
4834void operator delete (void *, std::size_t) noexcept;
4835void operator delete[] (void *, std::size_t) noexcept;
4836@end smallexample
4837or vice versa. Enabled by @option{-Wextra} along with
4838@option{-fsized-deallocation}.
4839
d77de738
ML
4840@opindex Wno-suggest-final-types
4841@opindex Wsuggest-final-types
ddf6fe37 4842@item -Wsuggest-final-types
d77de738
ML
4843Warn about types with virtual methods where code quality would be improved
4844if the type were declared with the C++11 @code{final} specifier,
4845or, if possible,
4846declared in an anonymous namespace. This allows GCC to more aggressively
4847devirtualize the polymorphic calls. This warning is more effective with
4848link-time optimization,
4849where the information about the class hierarchy graph is
4850more complete.
4851
d77de738
ML
4852@opindex Wno-suggest-final-methods
4853@opindex Wsuggest-final-methods
ddf6fe37 4854@item -Wsuggest-final-methods
d77de738
ML
4855Warn about virtual methods where code quality would be improved if the method
4856were declared with the C++11 @code{final} specifier,
4857or, if possible, its type were
4858declared in an anonymous namespace or with the @code{final} specifier.
4859This warning is
4860more effective with link-time optimization, where the information about the
4861class hierarchy graph is more complete. It is recommended to first consider
4862suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4863annotations.
4864
d77de738
ML
4865@opindex Wsuggest-override
4866@opindex Wno-suggest-override
ddf6fe37 4867@item -Wsuggest-override
d77de738
ML
4868Warn about overriding virtual functions that are not marked with the
4869@code{override} keyword.
4870
d77de738
ML
4871@opindex Wconversion-null
4872@opindex Wno-conversion-null
ddf6fe37 4873@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
d77de738
ML
4874Do not warn for conversions between @code{NULL} and non-pointer
4875types. @option{-Wconversion-null} is enabled by default.
4876
4877@end table
4878
4879@node Objective-C and Objective-C++ Dialect Options
4880@section Options Controlling Objective-C and Objective-C++ Dialects
4881
4882@cindex compiler options, Objective-C and Objective-C++
4883@cindex Objective-C and Objective-C++ options, command-line
4884@cindex options, Objective-C and Objective-C++
4885(NOTE: This manual does not describe the Objective-C and Objective-C++
4886languages themselves. @xref{Standards,,Language Standards
4887Supported by GCC}, for references.)
4888
4889This section describes the command-line options that are only meaningful
4890for Objective-C and Objective-C++ programs. You can also use most of
4891the language-independent GNU compiler options.
4892For example, you might compile a file @file{some_class.m} like this:
4893
4894@smallexample
4895gcc -g -fgnu-runtime -O -c some_class.m
4896@end smallexample
4897
4898@noindent
4899In this example, @option{-fgnu-runtime} is an option meant only for
4900Objective-C and Objective-C++ programs; you can use the other options with
4901any language supported by GCC@.
4902
4903Note that since Objective-C is an extension of the C language, Objective-C
4904compilations may also use options specific to the C front-end (e.g.,
4905@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4906C++-specific options (e.g., @option{-Wabi}).
4907
4908Here is a list of options that are @emph{only} for compiling Objective-C
4909and Objective-C++ programs:
4910
4911@table @gcctabopt
d77de738 4912@opindex fconstant-string-class
ddf6fe37 4913@item -fconstant-string-class=@var{class-name}
d77de738
ML
4914Use @var{class-name} as the name of the class to instantiate for each
4915literal string specified with the syntax @code{@@"@dots{}"}. The default
4916class name is @code{NXConstantString} if the GNU runtime is being used, and
cdd4b3c0 4917@code{NSConstantString} if the NeXT runtime is being used (see below). On
a335cf24 4918Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if
cdd4b3c0
IS
4919also present, overrides the @option{-fconstant-string-class} setting and cause
4920@code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings.
4921Note that @option{-fconstant-cfstrings} is an alias for the target-specific
4922@option{-mconstant-cfstrings} equivalent.
d77de738 4923
d77de738 4924@opindex fgnu-runtime
ddf6fe37 4925@item -fgnu-runtime
d77de738
ML
4926Generate object code compatible with the standard GNU Objective-C
4927runtime. This is the default for most types of systems.
4928
d77de738 4929@opindex fnext-runtime
ddf6fe37 4930@item -fnext-runtime
d77de738 4931Generate output compatible with the NeXT runtime. This is the default
a335cf24 4932for NeXT-based systems, including Darwin / macOS. The macro
d77de738
ML
4933@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4934used.
4935
d77de738
ML
4936@opindex fno-nil-receivers
4937@opindex fnil-receivers
ddf6fe37 4938@item -fno-nil-receivers
d77de738
ML
4939Assume that all Objective-C message dispatches (@code{[receiver
4940message:arg]}) in this translation unit ensure that the receiver is
4941not @code{nil}. This allows for more efficient entry points in the
4942runtime to be used. This option is only available in conjunction with
4943the NeXT runtime and ABI version 0 or 1.
4944
d77de738 4945@opindex fobjc-abi-version
ddf6fe37 4946@item -fobjc-abi-version=@var{n}
d77de738
ML
4947Use version @var{n} of the Objective-C ABI for the selected runtime.
4948This option is currently supported only for the NeXT runtime. In that
4949case, Version 0 is the traditional (32-bit) ABI without support for
4950properties and other Objective-C 2.0 additions. Version 1 is the
4951traditional (32-bit) ABI with support for properties and other
4952Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4953nothing is specified, the default is Version 0 on 32-bit target
4954machines, and Version 2 on 64-bit target machines.
4955
d77de738 4956@opindex fobjc-call-cxx-cdtors
ddf6fe37 4957@item -fobjc-call-cxx-cdtors
d77de738
ML
4958For each Objective-C class, check if any of its instance variables is a
4959C++ object with a non-trivial default constructor. If so, synthesize a
4960special @code{- (id) .cxx_construct} instance method which runs
4961non-trivial default constructors on any such instance variables, in order,
4962and then return @code{self}. Similarly, check if any instance variable
4963is a C++ object with a non-trivial destructor, and if so, synthesize a
4964special @code{- (void) .cxx_destruct} method which runs
4965all such default destructors, in reverse order.
4966
4967The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4968methods thusly generated only operate on instance variables
4969declared in the current Objective-C class, and not those inherited
4970from superclasses. It is the responsibility of the Objective-C
4971runtime to invoke all such methods in an object's inheritance
4972hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4973by the runtime immediately after a new object instance is allocated;
4974the @code{- (void) .cxx_destruct} methods are invoked immediately
4975before the runtime deallocates an object instance.
4976
4977As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4978support for invoking the @code{- (id) .cxx_construct} and
4979@code{- (void) .cxx_destruct} methods.
4980
d77de738 4981@opindex fobjc-direct-dispatch
ddf6fe37 4982@item -fobjc-direct-dispatch
d77de738
ML
4983Allow fast jumps to the message dispatcher. On Darwin this is
4984accomplished via the comm page.
4985
d77de738 4986@opindex fobjc-exceptions
ddf6fe37 4987@item -fobjc-exceptions
d77de738
ML
4988Enable syntactic support for structured exception handling in
4989Objective-C, similar to what is offered by C++. This option
4990is required to use the Objective-C keywords @code{@@try},
4991@code{@@throw}, @code{@@catch}, @code{@@finally} and
4992@code{@@synchronized}. This option is available with both the GNU
4993runtime and the NeXT runtime (but not available in conjunction with
4994the NeXT runtime on Mac OS X 10.2 and earlier).
4995
d77de738 4996@opindex fobjc-gc
ddf6fe37 4997@item -fobjc-gc
d77de738
ML
4998Enable garbage collection (GC) in Objective-C and Objective-C++
4999programs. This option is only available with the NeXT runtime; the
5000GNU runtime has a different garbage collection implementation that
5001does not require special compiler flags.
5002
d77de738 5003@opindex fobjc-nilcheck
ddf6fe37 5004@item -fobjc-nilcheck
d77de738
ML
5005For the NeXT runtime with version 2 of the ABI, check for a nil
5006receiver in method invocations before doing the actual method call.
5007This is the default and can be disabled using
5008@option{-fno-objc-nilcheck}. Class methods and super calls are never
5009checked for nil in this way no matter what this flag is set to.
5010Currently this flag does nothing when the GNU runtime, or an older
5011version of the NeXT runtime ABI, is used.
5012
d77de738 5013@opindex fobjc-std
ddf6fe37 5014@item -fobjc-std=objc1
d77de738
ML
5015Conform to the language syntax of Objective-C 1.0, the language
5016recognized by GCC 4.0. This only affects the Objective-C additions to
5017the C/C++ language; it does not affect conformance to C/C++ standards,
5018which is controlled by the separate C/C++ dialect option flags. When
5019this option is used with the Objective-C or Objective-C++ compiler,
5020any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
5021This is useful if you need to make sure that your Objective-C code can
5022be compiled with older versions of GCC@.
5023
d77de738 5024@opindex freplace-objc-classes
ddf6fe37 5025@item -freplace-objc-classes
d77de738
ML
5026Emit a special marker instructing @command{ld(1)} not to statically link in
5027the resulting object file, and allow @command{dyld(1)} to load it in at
5028run time instead. This is used in conjunction with the Fix-and-Continue
5029debugging mode, where the object file in question may be recompiled and
5030dynamically reloaded in the course of program execution, without the need
5031to restart the program itself. Currently, Fix-and-Continue functionality
5032is only available in conjunction with the NeXT runtime on Mac OS X 10.3
5033and later.
5034
d77de738 5035@opindex fzero-link
ddf6fe37 5036@item -fzero-link
d77de738
ML
5037When compiling for the NeXT runtime, the compiler ordinarily replaces calls
5038to @code{objc_getClass("@dots{}")} (when the name of the class is known at
5039compile time) with static class references that get initialized at load time,
5040which improves run-time performance. Specifying the @option{-fzero-link} flag
5041suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
5042to be retained. This is useful in Zero-Link debugging mode, since it allows
5043for individual class implementations to be modified during program execution.
5044The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
5045regardless of command-line options.
5046
d77de738
ML
5047@opindex fno-local-ivars
5048@opindex flocal-ivars
ddf6fe37 5049@item -fno-local-ivars
d77de738
ML
5050By default instance variables in Objective-C can be accessed as if
5051they were local variables from within the methods of the class they're
5052declared in. This can lead to shadowing between instance variables
5053and other variables declared either locally inside a class method or
5054globally with the same name. Specifying the @option{-fno-local-ivars}
5055flag disables this behavior thus avoiding variable shadowing issues.
5056
d77de738 5057@opindex fivar-visibility
ddf6fe37 5058@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
d77de738
ML
5059Set the default instance variable visibility to the specified option
5060so that instance variables declared outside the scope of any access
5061modifier directives default to the specified visibility.
5062
d77de738 5063@opindex gen-decls
ddf6fe37 5064@item -gen-decls
d77de738
ML
5065Dump interface declarations for all classes seen in the source file to a
5066file named @file{@var{sourcename}.decl}.
5067
d77de738
ML
5068@opindex Wassign-intercept
5069@opindex Wno-assign-intercept
ddf6fe37 5070@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5071Warn whenever an Objective-C assignment is being intercepted by the
5072garbage collector.
5073
d77de738
ML
5074@opindex Wproperty-assign-default
5075@opindex Wno-property-assign-default
ddf6fe37 5076@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5077Do not warn if a property for an Objective-C object has no assign
5078semantics specified.
5079
d77de738
ML
5080@opindex Wno-protocol
5081@opindex Wprotocol
ddf6fe37 5082@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5083If a class is declared to implement a protocol, a warning is issued for
5084every method in the protocol that is not implemented by the class. The
5085default behavior is to issue a warning for every method not explicitly
5086implemented in the class, even if a method implementation is inherited
5087from the superclass. If you use the @option{-Wno-protocol} option, then
5088methods inherited from the superclass are considered to be implemented,
5089and no warning is issued for them.
5090
d77de738 5091@opindex Wobjc-root-class
ddf6fe37 5092@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5093Warn if a class interface lacks a superclass. Most classes will inherit
5094from @code{NSObject} (or @code{Object}) for example. When declaring
5095classes intended to be root classes, the warning can be suppressed by
5096marking their interfaces with @code{__attribute__((objc_root_class))}.
5097
d77de738
ML
5098@opindex Wselector
5099@opindex Wno-selector
ddf6fe37 5100@item -Wselector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5101Warn if multiple methods of different types for the same selector are
5102found during compilation. The check is performed on the list of methods
5103in the final stage of compilation. Additionally, a check is performed
5104for each selector appearing in a @code{@@selector(@dots{})}
5105expression, and a corresponding method for that selector has been found
5106during compilation. Because these checks scan the method table only at
5107the end of compilation, these warnings are not produced if the final
5108stage of compilation is not reached, for example because an error is
5109found during compilation, or because the @option{-fsyntax-only} option is
5110being used.
5111
d77de738
ML
5112@opindex Wstrict-selector-match
5113@opindex Wno-strict-selector-match
ddf6fe37 5114@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5115Warn if multiple methods with differing argument and/or return types are
5116found for a given selector when attempting to send a message using this
5117selector to a receiver of type @code{id} or @code{Class}. When this flag
5118is off (which is the default behavior), the compiler omits such warnings
5119if any differences found are confined to types that share the same size
5120and alignment.
5121
d77de738
ML
5122@opindex Wundeclared-selector
5123@opindex Wno-undeclared-selector
ddf6fe37 5124@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5125Warn if a @code{@@selector(@dots{})} expression referring to an
5126undeclared selector is found. A selector is considered undeclared if no
5127method with that name has been declared before the
5128@code{@@selector(@dots{})} expression, either explicitly in an
5129@code{@@interface} or @code{@@protocol} declaration, or implicitly in
5130an @code{@@implementation} section. This option always performs its
5131checks as soon as a @code{@@selector(@dots{})} expression is found,
5132while @option{-Wselector} only performs its checks in the final stage of
5133compilation. This also enforces the coding style convention
5134that methods and selectors must be declared before being used.
5135
d77de738 5136@opindex print-objc-runtime-info
ddf6fe37 5137@item -print-objc-runtime-info
d77de738
ML
5138Generate C header describing the largest structure that is passed by
5139value, if any.
5140
5141@end table
5142
5143@node Diagnostic Message Formatting Options
5144@section Options to Control Diagnostic Messages Formatting
5145@cindex options to control diagnostics formatting
5146@cindex diagnostic messages
5147@cindex message formatting
5148
5149Traditionally, diagnostic messages have been formatted irrespective of
5150the output device's aspect (e.g.@: its width, @dots{}). You can use the
5151options described below
5152to control the formatting algorithm for diagnostic messages,
5153e.g.@: how many characters per line, how often source location
5154information should be reported. Note that some language front ends may not
5155honor these options.
5156
5157@table @gcctabopt
d77de738 5158@opindex fmessage-length
ddf6fe37 5159@item -fmessage-length=@var{n}
d77de738
ML
5160Try to format error messages so that they fit on lines of about
5161@var{n} characters. If @var{n} is zero, then no line-wrapping is
5162done; each error message appears on a single line. This is the
5163default for all front ends.
5164
5165Note - this option also affects the display of the @samp{#error} and
5166@samp{#warning} pre-processor directives, and the @samp{deprecated}
5167function/type/variable attribute. It does not however affect the
5168@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5169
5170@item -fdiagnostics-plain-output
5171This option requests that diagnostic output look as plain as possible, which
5172may be useful when running @command{dejagnu} or other utilities that need to
5173parse diagnostics output and prefer that it remain more stable over time.
5174@option{-fdiagnostics-plain-output} is currently equivalent to the following
5175options:
43b72ede
AA
5176@gccoptlist{-fno-diagnostics-show-caret
5177-fno-diagnostics-show-line-numbers
5178-fdiagnostics-color=never
5179-fdiagnostics-urls=never
4f01ae37
DM
5180-fdiagnostics-path-format=separate-events
5181-fdiagnostics-text-art-charset=none}
d77de738
ML
5182In the future, if GCC changes the default appearance of its diagnostics, the
5183corresponding option to disable the new behavior will be added to this list.
5184
d77de738 5185@opindex fdiagnostics-show-location
ddf6fe37 5186@item -fdiagnostics-show-location=once
d77de738
ML
5187Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5188reporter to emit source location information @emph{once}; that is, in
5189case the message is too long to fit on a single physical line and has to
5190be wrapped, the source location won't be emitted (as prefix) again,
5191over and over, in subsequent continuation lines. This is the default
5192behavior.
5193
5194@item -fdiagnostics-show-location=every-line
5195Only meaningful in line-wrapping mode. Instructs the diagnostic
5196messages reporter to emit the same source location information (as
5197prefix) for physical lines that result from the process of breaking
5198a message which is too long to fit on a single line.
5199
ddf6fe37 5200@opindex fdiagnostics-color
d77de738
ML
5201@cindex highlight, color
5202@vindex GCC_COLORS @r{environment variable}
f33d7a88
AA
5203@item -fdiagnostics-color[=@var{WHEN}]
5204@itemx -fno-diagnostics-color
d77de738
ML
5205Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5206or @samp{auto}. The default depends on how the compiler has been configured,
5207it can be any of the above @var{WHEN} options or also @samp{never}
5208if @env{GCC_COLORS} environment variable isn't present in the environment,
5209and @samp{auto} otherwise.
5210@samp{auto} makes GCC use color only when the standard error is a terminal,
5211and when not executing in an emacs shell.
5212The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5213aliases for @option{-fdiagnostics-color=always} and
5214@option{-fdiagnostics-color=never}, respectively.
5215
5216The colors are defined by the environment variable @env{GCC_COLORS}.
5217Its value is a colon-separated list of capabilities and Select Graphic
5218Rendition (SGR) substrings. SGR commands are interpreted by the
5219terminal or terminal emulator. (See the section in the documentation
5220of your text terminal for permitted values and their meanings as
5221character attributes.) These substring values are integers in decimal
5222representation and can be concatenated with semicolons.
5223Common values to concatenate include
5224@samp{1} for bold,
5225@samp{4} for underline,
5226@samp{5} for blink,
5227@samp{7} for inverse,
5228@samp{39} for default foreground color,
5229@samp{30} to @samp{37} for foreground colors,
5230@samp{90} to @samp{97} for 16-color mode foreground colors,
5231@samp{38;5;0} to @samp{38;5;255}
5232for 88-color and 256-color modes foreground colors,
5233@samp{49} for default background color,
5234@samp{40} to @samp{47} for background colors,
5235@samp{100} to @samp{107} for 16-color mode background colors,
5236and @samp{48;5;0} to @samp{48;5;255}
5237for 88-color and 256-color modes background colors.
5238
5239The default @env{GCC_COLORS} is
5240@smallexample
5241error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5242quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5243diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5244type-diff=01;32:fnname=01;32:targs=35
5245@end smallexample
5246@noindent
5247where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5248@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5249@samp{01} is bold, and @samp{31} is red.
5250Setting @env{GCC_COLORS} to the empty string disables colors.
5251Supported capabilities are as follows.
5252
5253@table @code
d77de738 5254@vindex error GCC_COLORS @r{capability}
f33d7a88 5255@item error=
d77de738
ML
5256SGR substring for error: markers.
5257
d77de738 5258@vindex warning GCC_COLORS @r{capability}
f33d7a88 5259@item warning=
d77de738
ML
5260SGR substring for warning: markers.
5261
d77de738 5262@vindex note GCC_COLORS @r{capability}
f33d7a88 5263@item note=
d77de738
ML
5264SGR substring for note: markers.
5265
d77de738 5266@vindex path GCC_COLORS @r{capability}
f33d7a88 5267@item path=
d77de738
ML
5268SGR substring for colorizing paths of control-flow events as printed
5269via @option{-fdiagnostics-path-format=}, such as the identifiers of
5270individual events and lines indicating interprocedural calls and returns.
5271
d77de738 5272@vindex range1 GCC_COLORS @r{capability}
f33d7a88 5273@item range1=
d77de738
ML
5274SGR substring for first additional range.
5275
d77de738 5276@vindex range2 GCC_COLORS @r{capability}
f33d7a88 5277@item range2=
d77de738
ML
5278SGR substring for second additional range.
5279
d77de738 5280@vindex locus GCC_COLORS @r{capability}
f33d7a88 5281@item locus=
d77de738
ML
5282SGR substring for location information, @samp{file:line} or
5283@samp{file:line:column} etc.
5284
d77de738 5285@vindex quote GCC_COLORS @r{capability}
f33d7a88 5286@item quote=
d77de738
ML
5287SGR substring for information printed within quotes.
5288
d77de738 5289@vindex fnname GCC_COLORS @r{capability}
f33d7a88 5290@item fnname=
d77de738
ML
5291SGR substring for names of C++ functions.
5292
d77de738 5293@vindex targs GCC_COLORS @r{capability}
f33d7a88 5294@item targs=
d77de738
ML
5295SGR substring for C++ function template parameter bindings.
5296
d77de738 5297@vindex fixit-insert GCC_COLORS @r{capability}
f33d7a88 5298@item fixit-insert=
d77de738
ML
5299SGR substring for fix-it hints suggesting text to
5300be inserted or replaced.
5301
d77de738 5302@vindex fixit-delete GCC_COLORS @r{capability}
f33d7a88 5303@item fixit-delete=
d77de738
ML
5304SGR substring for fix-it hints suggesting text to
5305be deleted.
5306
d77de738 5307@vindex diff-filename GCC_COLORS @r{capability}
f33d7a88 5308@item diff-filename=
d77de738
ML
5309SGR substring for filename headers within generated patches.
5310
d77de738 5311@vindex diff-hunk GCC_COLORS @r{capability}
f33d7a88 5312@item diff-hunk=
d77de738
ML
5313SGR substring for the starts of hunks within generated patches.
5314
d77de738 5315@vindex diff-delete GCC_COLORS @r{capability}
f33d7a88 5316@item diff-delete=
d77de738
ML
5317SGR substring for deleted lines within generated patches.
5318
d77de738 5319@vindex diff-insert GCC_COLORS @r{capability}
f33d7a88 5320@item diff-insert=
d77de738
ML
5321SGR substring for inserted lines within generated patches.
5322
d77de738 5323@vindex type-diff GCC_COLORS @r{capability}
f33d7a88 5324@item type-diff=
d77de738
ML
5325SGR substring for highlighting mismatching types within template
5326arguments in the C++ frontend.
5327@end table
5328
d77de738
ML
5329@opindex fdiagnostics-urls
5330@cindex urls
5331@vindex GCC_URLS @r{environment variable}
5332@vindex TERM_URLS @r{environment variable}
f33d7a88 5333@item -fdiagnostics-urls[=@var{WHEN}]
d77de738
ML
5334Use escape sequences to embed URLs in diagnostics. For example, when
5335@option{-fdiagnostics-show-option} emits text showing the command-line
5336option controlling a diagnostic, embed a URL for documentation of that
5337option.
5338
5339@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5340@samp{auto} makes GCC use URL escape sequences only when the standard error
5341is a terminal, and when not executing in an emacs shell or any graphical
5342terminal which is known to be incompatible with this feature, see below.
5343
5344The default depends on how the compiler has been configured.
5345It can be any of the above @var{WHEN} options.
5346
5347GCC can also be configured (via the
5348@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5349so that the default is affected by environment variables.
5350Under such a configuration, GCC defaults to using @samp{auto}
5351if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5352present and non-empty in the environment of the compiler, or @samp{never}
5353if neither are.
5354
5355However, even with @option{-fdiagnostics-urls=always} the behavior is
5356dependent on those environment variables:
5357If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5358diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5359If set to @samp{bel}, the default, URLs use BEL escape sequences.
5360Any other non-empty value enables the feature.
5361If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5362Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5363BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5364
5365At this time GCC tries to detect also a few terminals that are known to
5366not implement the URL feature, and have bugs or at least had bugs in
5367some versions that are still in use, where the URL escapes are likely
5368to misbehave, i.e. print garbage on the screen.
5369That list is currently xfce4-terminal, certain known to be buggy
5370gnome-terminal versions, the linux console, and mingw.
5371This check can be skipped with the @option{-fdiagnostics-urls=always}.
5372
d77de738
ML
5373@opindex fno-diagnostics-show-option
5374@opindex fdiagnostics-show-option
ddf6fe37 5375@item -fno-diagnostics-show-option
d77de738
ML
5376By default, each diagnostic emitted includes text indicating the
5377command-line option that directly controls the diagnostic (if such an
5378option is known to the diagnostic machinery). Specifying the
5379@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5380
d77de738
ML
5381@opindex fno-diagnostics-show-caret
5382@opindex fdiagnostics-show-caret
ddf6fe37 5383@item -fno-diagnostics-show-caret
d77de738
ML
5384By default, each diagnostic emitted includes the original source line
5385and a caret @samp{^} indicating the column. This option suppresses this
5386information. The source line is truncated to @var{n} characters, if
5387the @option{-fmessage-length=n} option is given. When the output is done
5388to the terminal, the width is limited to the width given by the
5389@env{COLUMNS} environment variable or, if not set, to the terminal width.
5390
d77de738
ML
5391@opindex fno-diagnostics-show-labels
5392@opindex fdiagnostics-show-labels
ddf6fe37 5393@item -fno-diagnostics-show-labels
d77de738
ML
5394By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5395diagnostics can label ranges of source code with pertinent information, such
5396as the types of expressions:
5397
5398@smallexample
5399 printf ("foo %s bar", long_i + long_j);
5400 ~^ ~~~~~~~~~~~~~~~
5401 | |
5402 char * long int
5403@end smallexample
5404
5405This option suppresses the printing of these labels (in the example above,
5406the vertical bars and the ``char *'' and ``long int'' text).
5407
d77de738
ML
5408@opindex fno-diagnostics-show-cwe
5409@opindex fdiagnostics-show-cwe
ddf6fe37 5410@item -fno-diagnostics-show-cwe
d77de738
ML
5411Diagnostic messages can optionally have an associated
5412@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5413GCC itself only provides such metadata for some of the @option{-fanalyzer}
5414diagnostics. GCC plugins may also provide diagnostics with such metadata.
5415By default, if this information is present, it will be printed with
5416the diagnostic. This option suppresses the printing of this metadata.
5417
d77de738
ML
5418@opindex fno-diagnostics-show-rules
5419@opindex fdiagnostics-show-rules
ddf6fe37 5420@item -fno-diagnostics-show-rules
d77de738
ML
5421Diagnostic messages can optionally have rules associated with them, such
5422as from a coding standard, or a specification.
5423GCC itself does not do this for any of its diagnostics, but plugins may do so.
5424By default, if this information is present, it will be printed with
5425the diagnostic. This option suppresses the printing of this metadata.
5426
d77de738
ML
5427@opindex fno-diagnostics-show-line-numbers
5428@opindex fdiagnostics-show-line-numbers
ddf6fe37 5429@item -fno-diagnostics-show-line-numbers
d77de738
ML
5430By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5431a left margin is printed, showing line numbers. This option suppresses this
5432left margin.
5433
d77de738 5434@opindex fdiagnostics-minimum-margin-width
ddf6fe37 5435@item -fdiagnostics-minimum-margin-width=@var{width}
d77de738
ML
5436This option controls the minimum width of the left margin printed by
5437@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5438
d77de738 5439@opindex fdiagnostics-parseable-fixits
ddf6fe37 5440@item -fdiagnostics-parseable-fixits
d77de738
ML
5441Emit fix-it hints in a machine-parseable format, suitable for consumption
5442by IDEs. For each fix-it, a line will be printed after the relevant
5443diagnostic, starting with the string ``fix-it:''. For example:
5444
5445@smallexample
5446fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5447@end smallexample
5448
5449The location is expressed as a half-open range, expressed as a count of
5450bytes, starting at byte 1 for the initial column. In the above example,
5451bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5452given string:
5453
5454@smallexample
545500000000011111111112222222222
545612345678901234567890123456789
5457 gtk_widget_showall (dlg);
5458 ^^^^^^^^^^^^^^^^^^
5459 gtk_widget_show_all
5460@end smallexample
5461
5462The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5463newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5464(e.g. vertical tab as ``\013'').
5465
5466An empty replacement string indicates that the given range is to be removed.
5467An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5468be inserted at the given position.
5469
d77de738 5470@opindex fdiagnostics-generate-patch
ddf6fe37 5471@item -fdiagnostics-generate-patch
d77de738
ML
5472Print fix-it hints to stderr in unified diff format, after any diagnostics
5473are printed. For example:
5474
5475@smallexample
5476--- test.c
5477+++ test.c
5478@@ -42,5 +42,5 @@
5479
5480 void show_cb(GtkDialog *dlg)
5481 @{
5482- gtk_widget_showall(dlg);
5483+ gtk_widget_show_all(dlg);
5484 @}
5485
5486@end smallexample
5487
5488The diff may or may not be colorized, following the same rules
5489as for diagnostics (see @option{-fdiagnostics-color}).
5490
d77de738 5491@opindex fdiagnostics-show-template-tree
ddf6fe37 5492@item -fdiagnostics-show-template-tree
d77de738
ML
5493
5494In the C++ frontend, when printing diagnostics showing mismatching
5495template types, such as:
5496
5497@smallexample
5498 could not convert 'std::map<int, std::vector<double> >()'
5499 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5500@end smallexample
5501
5502the @option{-fdiagnostics-show-template-tree} flag enables printing a
5503tree-like structure showing the common and differing parts of the types,
5504such as:
5505
5506@smallexample
5507 map<
5508 [...],
5509 vector<
5510 [double != float]>>
5511@end smallexample
5512
5513The parts that differ are highlighted with color (``double'' and
5514``float'' in this case).
5515
d77de738
ML
5516@opindex fno-elide-type
5517@opindex felide-type
ddf6fe37 5518@item -fno-elide-type
d77de738
ML
5519By default when the C++ frontend prints diagnostics showing mismatching
5520template types, common parts of the types are printed as ``[...]'' to
5521simplify the error message. For example:
5522
5523@smallexample
5524 could not convert 'std::map<int, std::vector<double> >()'
5525 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5526@end smallexample
5527
5528Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5529This flag also affects the output of the
5530@option{-fdiagnostics-show-template-tree} flag.
5531
d77de738 5532@opindex fdiagnostics-path-format
ddf6fe37 5533@item -fdiagnostics-path-format=@var{KIND}
d77de738
ML
5534Specify how to print paths of control-flow events for diagnostics that
5535have such a path associated with them.
5536
5537@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5538the default.
5539
5540@samp{none} means to not print diagnostic paths.
5541
5542@samp{separate-events} means to print a separate ``note'' diagnostic for
5543each event within the diagnostic. For example:
5544
5545@smallexample
5546test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5547test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5548test.c:27:3: note: (2) when 'i < count'
5549test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5550@end smallexample
5551
5552@samp{inline-events} means to print the events ``inline'' within the source
5553code. This view attempts to consolidate the events into runs of
5554sufficiently-close events, printing them as labelled ranges within the source.
5555
5556For example, the same events as above might be printed as:
5557
5558@smallexample
5559 'test': events 1-3
5560 |
5561 | 25 | list = PyList_New(0);
5562 | | ^~~~~~~~~~~~~
5563 | | |
5564 | | (1) when 'PyList_New' fails, returning NULL
5565 | 26 |
5566 | 27 | for (i = 0; i < count; i++) @{
5567 | | ~~~
5568 | | |
5569 | | (2) when 'i < count'
5570 | 28 | item = PyLong_FromLong(random());
5571 | 29 | PyList_Append(list, item);
5572 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5573 | | |
5574 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5575 |
5576@end smallexample
5577
5578Interprocedural control flow is shown by grouping the events by stack frame,
5579and using indentation to show how stack frames are nested, pushed, and popped.
5580
5581For example:
5582
5583@smallexample
5584 'test': events 1-2
5585 |
5586 | 133 | @{
5587 | | ^
5588 | | |
5589 | | (1) entering 'test'
5590 | 134 | boxed_int *obj = make_boxed_int (i);
5591 | | ~~~~~~~~~~~~~~~~~~
5592 | | |
5593 | | (2) calling 'make_boxed_int'
5594 |
5595 +--> 'make_boxed_int': events 3-4
5596 |
5597 | 120 | @{
5598 | | ^
5599 | | |
5600 | | (3) entering 'make_boxed_int'
5601 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5602 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5603 | | |
5604 | | (4) calling 'wrapped_malloc'
5605 |
5606 +--> 'wrapped_malloc': events 5-6
5607 |
5608 | 7 | @{
5609 | | ^
5610 | | |
5611 | | (5) entering 'wrapped_malloc'
5612 | 8 | return malloc (size);
5613 | | ~~~~~~~~~~~~~
5614 | | |
5615 | | (6) calling 'malloc'
5616 |
5617 <-------------+
5618 |
5619 'test': event 7
5620 |
5621 | 138 | free_boxed_int (obj);
5622 | | ^~~~~~~~~~~~~~~~~~~~
5623 | | |
5624 | | (7) calling 'free_boxed_int'
5625 |
5626(etc)
5627@end smallexample
5628
d77de738 5629@opindex fdiagnostics-show-path-depths
ddf6fe37 5630@item -fdiagnostics-show-path-depths
d77de738
ML
5631This option provides additional information when printing control-flow paths
5632associated with a diagnostic.
5633
5634If this is option is provided then the stack depth will be printed for
5635each run of events within @option{-fdiagnostics-path-format=inline-events}.
5636If provided with @option{-fdiagnostics-path-format=separate-events}, then
5637the stack depth and function declaration will be appended when printing
5638each event.
5639
5640This is intended for use by GCC developers and plugin developers when
5641debugging diagnostics that report interprocedural control flow.
5642
d77de738
ML
5643@opindex fno-show-column
5644@opindex fshow-column
ddf6fe37 5645@item -fno-show-column
d77de738
ML
5646Do not print column numbers in diagnostics. This may be necessary if
5647diagnostics are being scanned by a program that does not understand the
5648column numbers, such as @command{dejagnu}.
5649
d77de738 5650@opindex fdiagnostics-column-unit
ddf6fe37 5651@item -fdiagnostics-column-unit=@var{UNIT}
d77de738
ML
5652Select the units for the column number. This affects traditional diagnostics
5653(in the absence of @option{-fno-show-column}), as well as JSON format
5654diagnostics if requested.
5655
5656The default @var{UNIT}, @samp{display}, considers the number of display
5657columns occupied by each character. This may be larger than the number
5658of bytes required to encode the character, in the case of tab
5659characters, or it may be smaller, in the case of multibyte characters.
5660For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5661display column, and its UTF-8 encoding requires two bytes; the character
5662``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5663its UTF-8 encoding requires four bytes.
5664
5665Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5666count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5667
d77de738 5668@opindex fdiagnostics-column-origin
ddf6fe37 5669@item -fdiagnostics-column-origin=@var{ORIGIN}
d77de738
ML
5670Select the origin for column numbers, i.e. the column number assigned to the
5671first column. The default value of 1 corresponds to traditional GCC
5672behavior and to the GNU style guide. Some utilities may perform better with an
5673origin of 0; any non-negative value may be specified.
5674
d77de738 5675@opindex fdiagnostics-escape-format
ddf6fe37 5676@item -fdiagnostics-escape-format=@var{FORMAT}
d77de738
ML
5677When GCC prints pertinent source lines for a diagnostic it normally attempts
5678to print the source bytes directly. However, some diagnostics relate to encoding
5679issues in the source file, such as malformed UTF-8, or issues with Unicode
5680normalization. These diagnostics are flagged so that GCC will escape bytes
5681that are not printable ASCII when printing their pertinent source lines.
5682
5683This option controls how such bytes should be escaped.
5684
5685The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5686are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5687correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5688displayed as hexadecimal in the form @samp{<XX>}.
5689
5690For example, a source line containing the string @samp{before} followed by the
5691Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
56920xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5693the string @samp{after} will be printed for such a diagnostic as:
5694
5695@smallexample
5696 before<U+03C0><BF>after
5697@end smallexample
5698
5699Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5700in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5701Unicode characters. For the example above, the following will be printed:
5702
5703@smallexample
5704 before<CF><80><BF>after
5705@end smallexample
5706
4f01ae37
DM
5707@opindex fdiagnostics-text-art-charset
5708@item -fdiagnostics-text-art-charset=@var{CHARSET}
5709Some diagnostics can contain ``text art'' diagrams: visualizations created
5710from text, intended to be viewed in a monospaced font.
5711
5712This option selects which characters should be used for printing such
5713diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode},
5714or @samp{emoji}.
5715
5716The @samp{none} value suppresses the printing of such diagrams.
5717The @samp{ascii} value will ensure that such diagrams are pure ASCII
5718(``ASCII art''). The @samp{unicode} value will allow for conservative use of
5719unicode drawing characters (such as box-drawing characters). The @samp{emoji}
5720value further adds the possibility of emoji in the output (such as emitting
5721U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the
5722emoji variant of the character).
5723
04013e44
DM
5724The default is @samp{emoji}, except when the environment variable @env{LANG}
5725is set to @samp{C}, in which case the default is @samp{ascii}.
4f01ae37 5726
d77de738 5727@opindex fdiagnostics-format
ddf6fe37 5728@item -fdiagnostics-format=@var{FORMAT}
d77de738
ML
5729Select a different format for printing diagnostics.
5730@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5731@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5732
5733The default is @samp{text}.
5734
5735The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5736diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5737named @file{@var{source}.sarif}, respectively.
5738
5739The @samp{json} format is a synonym for @samp{json-stderr}.
5740The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5741where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5742whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5743
5744The emitted JSON consists of a top-level JSON array containing JSON objects
3bd8241a 5745representing the diagnostics.
d77de738
ML
5746
5747Diagnostics can have child diagnostics. For example, this error and note:
5748
5749@smallexample
5750misleading-indentation.c:15:3: warning: this 'if' clause does not
5751 guard... [-Wmisleading-indentation]
5752 15 | if (flag)
5753 | ^~
5754misleading-indentation.c:17:5: note: ...this statement, but the latter
5755 is misleadingly indented as if it were guarded by the 'if'
5756 17 | y = 2;
5757 | ^
5758@end smallexample
5759
5760@noindent
5761might be printed in JSON form (after formatting) like this:
5762
5763@smallexample
5764[
5765 @{
5766 "kind": "warning",
5767 "locations": [
5768 @{
5769 "caret": @{
5770 "display-column": 3,
5771 "byte-column": 3,
5772 "column": 3,
5773 "file": "misleading-indentation.c",
5774 "line": 15
5775 @},
5776 "finish": @{
5777 "display-column": 4,
5778 "byte-column": 4,
5779 "column": 4,
5780 "file": "misleading-indentation.c",
5781 "line": 15
5782 @}
5783 @}
5784 ],
5785 "message": "this \u2018if\u2019 clause does not guard...",
5786 "option": "-Wmisleading-indentation",
5787 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5788 "children": [
5789 @{
5790 "kind": "note",
5791 "locations": [
5792 @{
5793 "caret": @{
5794 "display-column": 5,
5795 "byte-column": 5,
5796 "column": 5,
5797 "file": "misleading-indentation.c",
5798 "line": 17
5799 @}
5800 @}
5801 ],
5802 "escape-source": false,
5803 "message": "...this statement, but the latter is @dots{}"
5804 @}
5805 ]
5806 "escape-source": false,
5807 "column-origin": 1,
5808 @}
5809]
5810@end smallexample
5811
5812@noindent
5813where the @code{note} is a child of the @code{warning}.
5814
5815A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5816an @code{option} key describing the command-line option controlling the
5817warning.
5818
5819A diagnostic can contain zero or more locations. Each location has an
5820optional @code{label} string and up to three positions within it: a
5821@code{caret} position and optional @code{start} and @code{finish} positions.
5822A position is described by a @code{file} name, a @code{line} number, and
5823three numbers indicating a column position:
5824@itemize @bullet
5825
5826@item
5827@code{display-column} counts display columns, accounting for tabs and
5828multibyte characters.
5829
5830@item
5831@code{byte-column} counts raw bytes.
5832
5833@item
5834@code{column} is equal to one of
5835the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5836option.
5837
5838@end itemize
5839All three columns are relative to the origin specified by
5840@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5841be set, for instance, to 0 for compatibility with other utilities that
5842number columns from 0. The column origin is recorded in the JSON output in
5843the @code{column-origin} tag. In the remaining examples below, the extra
5844column number outputs have been omitted for brevity.
5845
5846For example, this error:
5847
5848@smallexample
5849bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5850 'struct s'@} and 'T' @{aka 'struct t'@})
5851 64 | return callee_4a () + callee_4b ();
5852 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5853 | | |
5854 | | T @{aka struct t@}
5855 | S @{aka struct s@}
5856@end smallexample
5857
5858@noindent
5859has three locations. Its primary location is at the ``+'' token at column
586023. It has two secondary locations, describing the left and right-hand sides
5861of the expression, which have labels. It might be printed in JSON form as:
5862
5863@smallexample
5864 @{
5865 "children": [],
5866 "kind": "error",
5867 "locations": [
5868 @{
5869 "caret": @{
5870 "column": 23, "file": "bad-binary-ops.c", "line": 64
5871 @}
5872 @},
5873 @{
5874 "caret": @{
5875 "column": 10, "file": "bad-binary-ops.c", "line": 64
5876 @},
5877 "finish": @{
5878 "column": 21, "file": "bad-binary-ops.c", "line": 64
5879 @},
5880 "label": "S @{aka struct s@}"
5881 @},
5882 @{
5883 "caret": @{
5884 "column": 25, "file": "bad-binary-ops.c", "line": 64
5885 @},
5886 "finish": @{
5887 "column": 36, "file": "bad-binary-ops.c", "line": 64
5888 @},
5889 "label": "T @{aka struct t@}"
5890 @}
5891 ],
5892 "escape-source": false,
5893 "message": "invalid operands to binary + @dots{}"
5894 @}
5895@end smallexample
5896
5897If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5898consisting of half-open intervals, similar to the output of
5899@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5900with a replacement fix-it hint:
5901
5902@smallexample
5903demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5904 mean 'color'?
5905 8 | return ptr->colour;
5906 | ^~~~~~
5907 | color
5908@end smallexample
5909
5910@noindent
5911might be printed in JSON form as:
5912
5913@smallexample
5914 @{
5915 "children": [],
5916 "fixits": [
5917 @{
5918 "next": @{
5919 "column": 21,
5920 "file": "demo.c",
5921 "line": 8
5922 @},
5923 "start": @{
5924 "column": 15,
5925 "file": "demo.c",
5926 "line": 8
5927 @},
5928 "string": "color"
5929 @}
5930 ],
5931 "kind": "error",
5932 "locations": [
5933 @{
5934 "caret": @{
5935 "column": 15,
5936 "file": "demo.c",
5937 "line": 8
5938 @},
5939 "finish": @{
5940 "column": 20,
5941 "file": "demo.c",
5942 "line": 8
5943 @}
5944 @}
5945 ],
5946 "escape-source": false,
5947 "message": "\u2018struct s\u2019 has no member named @dots{}"
5948 @}
5949@end smallexample
5950
5951@noindent
5952where the fix-it hint suggests replacing the text from @code{start} up
5953to but not including @code{next} with @code{string}'s value. Deletions
5954are expressed via an empty value for @code{string}, insertions by
5955having @code{start} equal @code{next}.
5956
5957If the diagnostic has a path of control-flow events associated with it,
5958it has a @code{path} array of objects representing the events. Each
5959event object has a @code{description} string, a @code{location} object,
5960along with a @code{function} string and a @code{depth} number for
5961representing interprocedural paths. The @code{function} represents the
5962current function at that event, and the @code{depth} represents the
5963stack depth relative to some baseline: the higher, the more frames are
5964within the stack.
5965
5966For example, the intraprocedural example shown for
5967@option{-fdiagnostics-path-format=} might have this JSON for its path:
5968
5969@smallexample
5970 "path": [
5971 @{
5972 "depth": 0,
5973 "description": "when 'PyList_New' fails, returning NULL",
5974 "function": "test",
5975 "location": @{
5976 "column": 10,
5977 "file": "test.c",
5978 "line": 25
5979 @}
5980 @},
5981 @{
5982 "depth": 0,
5983 "description": "when 'i < count'",
5984 "function": "test",
5985 "location": @{
5986 "column": 3,
5987 "file": "test.c",
5988 "line": 27
5989 @}
5990 @},
5991 @{
5992 "depth": 0,
5993 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5994 "function": "test",
5995 "location": @{
5996 "column": 5,
5997 "file": "test.c",
5998 "line": 29
5999 @}
6000 @}
6001 ]
6002@end smallexample
6003
6004Diagnostics have a boolean attribute @code{escape-source}, hinting whether
6005non-ASCII bytes should be escaped when printing the pertinent lines of
6006source code (@code{true} for diagnostics involving source encoding issues).
6007
3bd8241a
DM
6008@opindex fno-diagnostics-json-formatting
6009@opindex fdiagnostics-json-formatting
6010@item -fno-diagnostics-json-formatting
6011By default, when JSON is emitted for diagnostics (via
6012@option{-fdiagnostics-format=sarif-stderr},
6013@option{-fdiagnostics-format=sarif-file},
6014@option{-fdiagnostics-format=json},
6015@option{-fdiagnostics-format=json-stderr},
6016@option{-fdiagnostics-format=json-file}),
6017GCC will add newlines and indentation to visually emphasize the
6018hierarchical structure of the JSON.
6019
6020Use @option{-fno-diagnostics-json-formatting} to suppress this whitespace.
6021It must be passed before the option it is to affect.
6022
6023This is intended for compatibility with tools that do not expect the output
6024to contain newlines, such as that emitted by older GCC releases.
6025
d77de738
ML
6026@end table
6027
6028@node Warning Options
6029@section Options to Request or Suppress Warnings
6030@cindex options to control warnings
6031@cindex warning messages
6032@cindex messages, warning
6033@cindex suppressing warnings
6034
6035Warnings are diagnostic messages that report constructions that
6036are not inherently erroneous but that are risky or suggest there
6037may have been an error.
6038
6039The following language-independent options do not enable specific
6040warnings but control the kinds of diagnostics produced by GCC@.
6041
6042@table @gcctabopt
6043@cindex syntax checking
d77de738 6044@opindex fsyntax-only
ddf6fe37 6045@item -fsyntax-only
d77de738
ML
6046Check the code for syntax errors, but don't do anything beyond that.
6047
d77de738 6048@opindex fmax-errors
ddf6fe37 6049@item -fmax-errors=@var{n}
d77de738
ML
6050Limits the maximum number of error messages to @var{n}, at which point
6051GCC bails out rather than attempting to continue processing the source
6052code. If @var{n} is 0 (the default), there is no limit on the number
6053of error messages produced. If @option{-Wfatal-errors} is also
6054specified, then @option{-Wfatal-errors} takes precedence over this
6055option.
6056
d77de738 6057@opindex w
ddf6fe37 6058@item -w
d77de738
ML
6059Inhibit all warning messages.
6060
d77de738
ML
6061@opindex Werror
6062@opindex Wno-error
ddf6fe37 6063@item -Werror
d77de738
ML
6064Make all warnings into errors.
6065
d77de738
ML
6066@opindex Werror=
6067@opindex Wno-error=
ddf6fe37 6068@item -Werror=
d77de738
ML
6069Make the specified warning into an error. The specifier for a warning
6070is appended; for example @option{-Werror=switch} turns the warnings
6071controlled by @option{-Wswitch} into errors. This switch takes a
6072negative form, to be used to negate @option{-Werror} for specific
6073warnings; for example @option{-Wno-error=switch} makes
6074@option{-Wswitch} warnings not be errors, even when @option{-Werror}
6075is in effect.
6076
6077The warning message for each controllable warning includes the
6078option that controls the warning. That option can then be used with
6079@option{-Werror=} and @option{-Wno-error=} as described above.
6080(Printing of the option in the warning message can be disabled using the
6081@option{-fno-diagnostics-show-option} flag.)
6082
6083Note that specifying @option{-Werror=}@var{foo} automatically implies
6084@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
6085imply anything.
6086
d77de738
ML
6087@opindex Wfatal-errors
6088@opindex Wno-fatal-errors
ddf6fe37 6089@item -Wfatal-errors
d77de738
ML
6090This option causes the compiler to abort compilation on the first error
6091occurred rather than trying to keep going and printing further error
6092messages.
6093
6094@end table
6095
6096You can request many specific warnings with options beginning with
6097@samp{-W}, for example @option{-Wimplicit} to request warnings on
6098implicit declarations. Each of these specific warning options also
6099has a negative form beginning @samp{-Wno-} to turn off warnings; for
6100example, @option{-Wno-implicit}. This manual lists only one of the
6101two forms, whichever is not the default. For further
6102language-specific options also refer to @ref{C++ Dialect Options} and
6103@ref{Objective-C and Objective-C++ Dialect Options}.
6104Additional warnings can be produced by enabling the static analyzer;
6105@xref{Static Analyzer Options}.
6106
6107Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
6108options, such as @option{-Wunused}, which may turn on further options,
6109such as @option{-Wunused-value}. The combined effect of positive and
6110negative forms is that more specific options have priority over less
6111specific ones, independently of their position in the command-line. For
6112options of the same specificity, the last one takes effect. Options
6113enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
6114as if they appeared at the end of the command-line.
6115
6116When an unrecognized warning option is requested (e.g.,
6117@option{-Wunknown-warning}), GCC emits a diagnostic stating
6118that the option is not recognized. However, if the @option{-Wno-} form
6119is used, the behavior is slightly different: no diagnostic is
6120produced for @option{-Wno-unknown-warning} unless other diagnostics
6121are being produced. This allows the use of new @option{-Wno-} options
6122with old compilers, but if something goes wrong, the compiler
6123warns that an unrecognized option is present.
6124
6125The effectiveness of some warnings depends on optimizations also being
6126enabled. For example @option{-Wsuggest-final-types} is more effective
6127with link-time optimization and some instances of other warnings may
6128not be issued at all unless optimization is enabled. While optimization
6129in general improves the efficacy of control and data flow sensitive
6130warnings, in some cases it may also cause false positives.
6131
6132@table @gcctabopt
d77de738
ML
6133@opindex pedantic
6134@opindex Wpedantic
6135@opindex Wno-pedantic
ddf6fe37
AA
6136@item -Wpedantic
6137@itemx -pedantic
d77de738 6138Issue all the warnings demanded by strict ISO C and ISO C++;
5fccebdb
JM
6139diagnose all programs that use forbidden extensions, and some other
6140programs that do not follow ISO C and ISO C++. This follows the version
6141of the ISO C or C++ standard specified by any @option{-std} option used.
d77de738
ML
6142
6143Valid ISO C and ISO C++ programs should compile properly with or without
6144this option (though a rare few require @option{-ansi} or a
5fccebdb 6145@option{-std} option specifying the version of the standard)@. However,
d77de738 6146without this option, certain GNU extensions and traditional C and C++
5fccebdb
JM
6147features are supported as well. With this option, they are diagnosed
6148(or rejected with @option{-pedantic-errors}).
d77de738
ML
6149
6150@option{-Wpedantic} does not cause warning messages for use of the
6151alternate keywords whose names begin and end with @samp{__}. This alternate
6152format can also be used to disable warnings for non-ISO @samp{__intN} types,
6153i.e. @samp{__intN__}.
6154Pedantic warnings are also disabled in the expression that follows
6155@code{__extension__}. However, only system header files should use
6156these escape routes; application programs should avoid them.
6157@xref{Alternate Keywords}.
6158
5fccebdb
JM
6159Some warnings about non-conforming programs are controlled by options
6160other than @option{-Wpedantic}; in many cases they are implied by
6161@option{-Wpedantic} but can be disabled separately by their specific
6162option, e.g. @option{-Wpedantic -Wno-pointer-sign}.
d77de738
ML
6163
6164Where the standard specified with @option{-std} represents a GNU
6165extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6166corresponding @dfn{base standard}, the version of ISO C on which the GNU
6167extended dialect is based. Warnings from @option{-Wpedantic} are given
6168where they are required by the base standard. (It does not make sense
6169for such warnings to be given only for features not in the specified GNU
6170C dialect, since by definition the GNU dialects of C include all
6171features the compiler supports with the given option, and there would be
6172nothing to warn about.)
6173
d77de738 6174@opindex pedantic-errors
ddf6fe37 6175@item -pedantic-errors
d77de738
ML
6176Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6177requires a diagnostic, in some cases where there is undefined behavior
6178at compile-time and in some other cases that do not prevent compilation
6179of programs that are valid according to the standard. This is not
5fccebdb
JM
6180equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be
6181useful, as it only makes errors of the diagnostics that are controlled by
6182@option{-Wpedantic}, whereas this option also affects required diagnostics that
6183are always enabled or controlled by options other than @option{-Wpedantic}.
6184
6185If you want the required diagnostics that are warnings by default to
6186be errors instead, but don't also want to enable the @option{-Wpedantic}
6187diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic}
6188(or @option{-pedantic-errors -Wno-error=pedantic} to enable them but
6189only as warnings).
6190
6191Some required diagnostics are errors by default, but can be reduced to
6192warnings using @option{-fpermissive} or their specific warning option,
6193e.g. @option{-Wno-error=narrowing}.
6194
6195Some diagnostics for non-ISO practices are controlled by specific
6196warning options other than @option{-Wpedantic}, but are also made
6197errors by @option{-pedantic-errors}. For instance:
6198
6199@gccoptlist{
6200-Wattributes @r{(for standard attributes)}
6201-Wchanges-meaning @r{(C++)}
6202-Wcomma-subscript @r{(C++23 or later)}
6203-Wdeclaration-after-statement @r{(C90 or earlier)}
b106f11d 6204-Welaborated-enum-base @r{(C++11 or later)}
5fccebdb
JM
6205-Wimplicit-int @r{(C99 or later)}
6206-Wimplicit-function-declaration @r{(C99 or later)}
6207-Wincompatible-pointer-types
6208-Wint-conversion
6209-Wlong-long @r{(C90 or earlier)}
6210-Wmain
6211-Wnarrowing @r{(C++11 or later)}
6212-Wpointer-arith
6213-Wpointer-sign
6214-Wincompatible-pointer-types
6215-Wregister @r{(C++17 or later)}
6216-Wvla @r{(C90 or earlier)}
6217-Wwrite-strings @r{(C++11 or later)}
6218}
d77de738 6219
ef10cb86
JM
6220@opindex fpermissive
6221@item -fpermissive
6222Downgrade some required diagnostics about nonconformant code from
6223errors to warnings. Thus, using @option{-fpermissive} allows some
6224nonconforming code to compile. Some C++ diagnostics are controlled
da4315f5
FW
6225only by this flag, but it also downgrades some C and C++ diagnostics
6226that have their own flag:
ef10cb86
JM
6227
6228@gccoptlist{
ff9efa3f 6229-Wdeclaration-missing-parameter-type @r{(C and Objective-C only)}
55e94561 6230-Wimplicit-function-declaration @r{(C and Objective-C only)}
4ee2aca7 6231-Wimplicit-int @r{(C and Objective-C only)}
9715c545 6232-Wincompatible-pointer-types @r{(C and Objective-C only)}
2c3db94d 6233-Wint-conversion @r{(C and Objective-C only)}
fa99f7d1 6234-Wnarrowing @r{(C++ and Objective-C++ only)}
4ecfa6c4 6235-Wreturn-mismatch @r{(C and Objective-C only)}
ef10cb86
JM
6236}
6237
da4315f5
FW
6238The @option{-fpermissive} option is the default for historic C language
6239modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90},
6240@option{-std=gnu90}).
6241
d77de738
ML
6242@opindex Wall
6243@opindex Wno-all
ddf6fe37 6244@item -Wall
d77de738
ML
6245This enables all the warnings about constructions that some users
6246consider questionable, and that are easy to avoid (or modify to
6247prevent the warning), even in conjunction with macros. This also
6248enables some language-specific warnings described in @ref{C++ Dialect
6249Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6250
6251@option{-Wall} turns on the following warning flags:
6252
43b72ede 6253@gccoptlist{-Waddress
7e758890 6254-Waligned-new @r{(C++ and Objective-C++ only)}
43b72ede
AA
6255-Warray-bounds=1 @r{(only with} @option{-O2}@r{)}
6256-Warray-compare
7e758890 6257-Warray-parameter=2
43b72ede
AA
6258-Wbool-compare
6259-Wbool-operation
7e758890 6260-Wc++11-compat -Wc++14-compat -Wc++17compat -Wc++20compat
43b72ede
AA
6261-Wcatch-value @r{(C++ and Objective-C++ only)}
6262-Wchar-subscripts
7e758890 6263-Wclass-memaccess @r{(C++ and Objective-C++ only)}
43b72ede 6264-Wcomment
7e758890 6265-Wdangling-else
43b72ede 6266-Wdangling-pointer=2
7e758890 6267-Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
43b72ede
AA
6268-Wduplicate-decl-specifier @r{(C and Objective-C only)}
6269-Wenum-compare @r{(in C/ObjC; this is on by default in C++)}
6270-Wenum-int-mismatch @r{(C and Objective-C only)}
7e758890
SL
6271-Wformat=1
6272-Wformat-contains-nul
6273-Wformat-diag
6274-Wformat-extra-args
6275-Wformat-overflow=1
6276-Wformat-truncation=1
6277-Wformat-zero-length
6278-Wframe-address
43b72ede 6279-Wimplicit @r{(C and Objective-C only)}
43b72ede 6280-Wimplicit-function-declaration @r{(C and Objective-C only)}
7e758890
SL
6281-Wimplicit-int @r{(C and Objective-C only)}
6282-Winfinite-recursion
6283-Winit-self @r{(C++ and Objective-C++ only)}
6284-Wint-in-bool-context
43b72ede
AA
6285-Wlogical-not-parentheses
6286-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}
6287-Wmaybe-uninitialized
6288-Wmemset-elt-size
6289-Wmemset-transposed-args
6290-Wmisleading-indentation @r{(only for C/C++)}
6291-Wmismatched-dealloc
7e758890 6292-Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
43b72ede
AA
6293-Wmissing-attributes
6294-Wmissing-braces @r{(only for C/ObjC)}
6295-Wmultistatement-macros
7e758890 6296-Wnarrowing @r{(C++ and Objective-C++ only)}
43b72ede
AA
6297-Wnonnull
6298-Wnonnull-compare
7e758890
SL
6299-Wopenmp-simd @r{(C and C++ only)}
6300-Woverloaded-virtual=1 @r{(C++ and Objective-C++ only)}
6301-Wpacked-not-aligned
43b72ede 6302-Wparentheses
7e758890
SL
6303-Wpessimizing-move @r{(C++ and Objective-C++ only)}
6304-Wpointer-sign @r{(only for C/ObjC)}
6305-Wrange-loop-construct @r{(C++ and Objective-C++ only)}
6306-Wreorder @r{(C++ and Objective-C++ only)}
43b72ede
AA
6307-Wrestrict
6308-Wreturn-type
7e758890 6309-Wself-move @r{(C++ and Objective-C++ only)}
43b72ede 6310-Wsequence-point
7e758890 6311-Wsign-compare @r{(C++ and Objective-C++ only)}
43b72ede
AA
6312-Wsizeof-array-div
6313-Wsizeof-pointer-div
6314-Wsizeof-pointer-memaccess
6315-Wstrict-aliasing
6316-Wstrict-overflow=1
6317-Wswitch
6318-Wtautological-compare
6319-Wtrigraphs
6320-Wuninitialized
6321-Wunknown-pragmas
7e758890
SL
6322-Wunused
6323-Wunused-but-set-variable
6324-Wunused-const-variable=1 @r{(only for C/ObjC)}
43b72ede
AA
6325-Wunused-function
6326-Wunused-label
7e758890 6327-Wunused-local-typedefs
43b72ede
AA
6328-Wunused-value
6329-Wunused-variable
6330-Wuse-after-free=2
7e758890 6331-Wvla-parameter
43b72ede 6332-Wvolatile-register-var
d77de738
ML
6333-Wzero-length-bounds}
6334
6335Note that some warning flags are not implied by @option{-Wall}. Some of
6336them warn about constructions that users generally do not consider
6337questionable, but which occasionally you might wish to check for;
6338others warn about constructions that are necessary or hard to avoid in
6339some cases, and there is no simple way to modify the code to suppress
6340the warning. Some of them are enabled by @option{-Wextra} but many of
6341them must be enabled individually.
6342
d77de738
ML
6343@opindex W
6344@opindex Wextra
6345@opindex Wno-extra
ddf6fe37 6346@item -Wextra
d77de738
ML
6347This enables some extra warning flags that are not enabled by
6348@option{-Wall}. (This option used to be called @option{-W}. The older
6349name is still supported, but the newer name is more descriptive.)
6350
7e758890
SL
6351@gccoptlist{-Wabsolute-value @r{(only for C/ObjC)}
6352-Walloc-size
6353-Wcalloc-transposed-args
43b72ede 6354-Wcast-function-type
7e758890
SL
6355-Wclobbered
6356-Wdeprecated-copy @r{(C++ and Objective-C++ only)}
43b72ede 6357-Wempty-body
7e758890
SL
6358-Wenum-conversion @r{(only for C/ObjC)}
6359-Wexpansion-to-defined
6360-Wignored-qualifiers @r{(only for C/C++)}
43b72ede 6361-Wimplicit-fallthrough=3
7e758890 6362-Wmaybe-uninitialized
43b72ede 6363-Wmissing-field-initializers
7e758890
SL
6364-Wmissing-parameter-type @r{(C/ObjC only)}
6365-Wold-style-declaration @r{(C/ObjC only)}
6366-Woverride-init @r{(C/ObjC only)}
6367-Wredundant-move @r{(C++ and Objective-C++ only)}
6368-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
6369-Wsign-compare @r{(C++ and Objective-C++ only)}
6370-Wsized-deallocation @r{(C++ and Objective-C++ only)}
43b72ede 6371-Wstring-compare
43b72ede
AA
6372-Wtype-limits
6373-Wuninitialized
43b72ede 6374-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
d77de738
ML
6375-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6376
d77de738
ML
6377The option @option{-Wextra} also prints warning messages for the
6378following cases:
6379
6380@itemize @bullet
6381
6382@item
6383A pointer is compared against integer zero with @code{<}, @code{<=},
6384@code{>}, or @code{>=}.
6385
6386@item
6387(C++ only) An enumerator and a non-enumerator both appear in a
6388conditional expression.
6389
6390@item
6391(C++ only) Ambiguous virtual bases.
6392
6393@item
6394(C++ only) Subscripting an array that has been declared @code{register}.
6395
6396@item
6397(C++ only) Taking the address of a variable that has been declared
6398@code{register}.
6399
6400@item
6401(C++ only) A base class is not initialized in the copy constructor
6402of a derived class.
6403
6404@end itemize
6405
d77de738
ML
6406@opindex Wabi
6407@opindex Wno-abi
ddf6fe37 6408@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
6409
6410Warn about code affected by ABI changes. This includes code that may
6411not be compatible with the vendor-neutral C++ ABI as well as the psABI
6412for the particular target.
6413
6414Since G++ now defaults to updating the ABI with each major release,
6415normally @option{-Wabi} warns only about C++ ABI compatibility
6416problems if there is a check added later in a release series for an
6417ABI issue discovered since the initial release. @option{-Wabi} warns
6418about more things if an older ABI version is selected (with
6419@option{-fabi-version=@var{n}}).
6420
6421@option{-Wabi} can also be used with an explicit version number to
6422warn about C++ ABI compatibility with a particular @option{-fabi-version}
6423level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6424@option{-fabi-version=2}.
6425
6426If an explicit version number is provided and
6427@option{-fabi-compat-version} is not specified, the version number
6428from this option is used for compatibility aliases. If no explicit
6429version number is provided with this option, but
6430@option{-fabi-compat-version} is specified, that version number is
6431used for C++ ABI warnings.
6432
6433Although an effort has been made to warn about
6434all such cases, there are probably some cases that are not warned about,
6435even though G++ is generating incompatible code. There may also be
6436cases where warnings are emitted even though the code that is generated
6437is compatible.
6438
6439You should rewrite your code to avoid these warnings if you are
6440concerned about the fact that code generated by G++ may not be binary
6441compatible with code generated by other compilers.
6442
6443Known incompatibilities in @option{-fabi-version=2} (which was the
6444default from GCC 3.4 to 4.9) include:
6445
6446@itemize @bullet
6447
6448@item
6449A template with a non-type template parameter of reference type was
6450mangled incorrectly:
6451@smallexample
6452extern int N;
6453template <int &> struct S @{@};
6454void n (S<N>) @{2@}
6455@end smallexample
6456
6457This was fixed in @option{-fabi-version=3}.
6458
6459@item
6460SIMD vector types declared using @code{__attribute ((vector_size))} were
6461mangled in a non-standard way that does not allow for overloading of
6462functions taking vectors of different sizes.
6463
6464The mangling was changed in @option{-fabi-version=4}.
6465
6466@item
6467@code{__attribute ((const))} and @code{noreturn} were mangled as type
6468qualifiers, and @code{decltype} of a plain declaration was folded away.
6469
6470These mangling issues were fixed in @option{-fabi-version=5}.
6471
6472@item
6473Scoped enumerators passed as arguments to a variadic function are
6474promoted like unscoped enumerators, causing @code{va_arg} to complain.
6475On most targets this does not actually affect the parameter passing
6476ABI, as there is no way to pass an argument smaller than @code{int}.
6477
6478Also, the ABI changed the mangling of template argument packs,
6479@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6480a class scope function used as a template argument.
6481
6482These issues were corrected in @option{-fabi-version=6}.
6483
6484@item
6485Lambdas in default argument scope were mangled incorrectly, and the
6486ABI changed the mangling of @code{nullptr_t}.
6487
6488These issues were corrected in @option{-fabi-version=7}.
6489
6490@item
6491When mangling a function type with function-cv-qualifiers, the
6492un-qualified function type was incorrectly treated as a substitution
6493candidate.
6494
6495This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6496
6497@item
6498@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6499unaligned accesses. Note that this did not affect the ABI of a
6500function with a @code{nullptr_t} parameter, as parameters have a
6501minimum alignment.
6502
6503This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6504
6505@item
6506Target-specific attributes that affect the identity of a type, such as
6507ia32 calling conventions on a function type (stdcall, regparm, etc.),
6508did not affect the mangled name, leading to name collisions when
6509function pointers were used as template arguments.
6510
6511This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6512
6513@end itemize
6514
6515This option also enables warnings about psABI-related changes.
6516The known psABI changes at this point include:
6517
6518@itemize @bullet
6519
6520@item
6521For SysV/x86-64, unions with @code{long double} members are
6522passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6523the case. For example:
6524
6525@smallexample
6526union U @{
6527 long double ld;
6528 int i;
6529@};
6530@end smallexample
6531
6532@noindent
6533@code{union U} is now always passed in memory.
6534
6535@end itemize
6536
e2f939d3
JM
6537@item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6538C++ requires that unqualified uses of a name within a class have the
6539same meaning in the complete scope of the class, so declaring the name
6540after using it is ill-formed:
6541@smallexample
6542struct A;
6543struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6544struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6545@end smallexample
6546By default, the B1 case is only a warning because the two declarations
6547have the same type, while the B2 case is an error. Both diagnostics
6548can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6549error case can be reduced to a warning with
6550@option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6551
6552Both diagnostics are also suppressed by @option{-fms-extensions}.
6553
d77de738
ML
6554@opindex Wchar-subscripts
6555@opindex Wno-char-subscripts
ddf6fe37 6556@item -Wchar-subscripts
d77de738
ML
6557Warn if an array subscript has type @code{char}. This is a common cause
6558of error, as programmers often forget that this type is signed on some
6559machines.
6560This warning is enabled by @option{-Wall}.
6561
d77de738
ML
6562@opindex Wno-coverage-mismatch
6563@opindex Wcoverage-mismatch
ddf6fe37 6564@item -Wno-coverage-mismatch
d77de738
ML
6565Warn if feedback profiles do not match when using the
6566@option{-fprofile-use} option.
6567If a source file is changed between compiling with @option{-fprofile-generate}
6568and with @option{-fprofile-use}, the files with the profile feedback can fail
6569to match the source file and GCC cannot use the profile feedback
6570information. By default, this warning is enabled and is treated as an
6571error. @option{-Wno-coverage-mismatch} can be used to disable the
6572warning or @option{-Wno-error=coverage-mismatch} can be used to
6573disable the error. Disabling the error for this warning can result in
6574poorly optimized code and is useful only in the
6575case of very minor changes such as bug fixes to an existing code-base.
6576Completely disabling the warning is not recommended.
6577
d77de738
ML
6578@opindex Wno-coverage-invalid-line-number
6579@opindex Wcoverage-invalid-line-number
ddf6fe37 6580@item -Wno-coverage-invalid-line-number
d77de738
ML
6581Warn in case a function ends earlier than it begins due
6582to an invalid linenum macros. The warning is emitted only
6583with @option{--coverage} enabled.
6584
6585By default, this warning is enabled and is treated as an
6586error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6587warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6588disable the error.
6589
d77de738
ML
6590@opindex Wno-cpp
6591@opindex Wcpp
ddf6fe37 6592@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
d77de738
ML
6593Suppress warning messages emitted by @code{#warning} directives.
6594
d77de738
ML
6595@opindex Wdouble-promotion
6596@opindex Wno-double-promotion
ddf6fe37 6597@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6598Give a warning when a value of type @code{float} is implicitly
6599promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6600floating-point unit implement @code{float} in hardware, but emulate
6601@code{double} in software. On such a machine, doing computations
6602using @code{double} values is much more expensive because of the
6603overhead required for software emulation.
6604
6605It is easy to accidentally do computations with @code{double} because
6606floating-point literals are implicitly of type @code{double}. For
6607example, in:
6608@smallexample
6609@group
6610float area(float radius)
6611@{
6612 return 3.14159 * radius * radius;
6613@}
6614@end group
6615@end smallexample
6616the compiler performs the entire computation with @code{double}
6617because the floating-point literal is a @code{double}.
6618
d77de738
ML
6619@opindex Wduplicate-decl-specifier
6620@opindex Wno-duplicate-decl-specifier
ddf6fe37 6621@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
d77de738
ML
6622Warn if a declaration has duplicate @code{const}, @code{volatile},
6623@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6624@option{-Wall}.
6625
d77de738
ML
6626@opindex Wformat
6627@opindex Wno-format
6628@opindex ffreestanding
6629@opindex fno-builtin
6630@opindex Wformat=
ddf6fe37
AA
6631@item -Wformat
6632@itemx -Wformat=@var{n}
d77de738
ML
6633Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6634the arguments supplied have types appropriate to the format string
6635specified, and that the conversions specified in the format string make
6636sense. This includes standard functions, and others specified by format
6637attributes (@pxref{Function Attributes}), in the @code{printf},
6638@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6639not in the C standard) families (or other target-specific families).
6640Which functions are checked without format attributes having been
6641specified depends on the standard version selected, and such checks of
6642functions without the attribute specified are disabled by
6643@option{-ffreestanding} or @option{-fno-builtin}.
6644
6645The formats are checked against the format features supported by GNU
6646libc version 2.2. These include all ISO C90 and C99 features, as well
6647as features from the Single Unix Specification and some BSD and GNU
6648extensions. Other library implementations may not support all these
6649features; GCC does not support warning about features that go beyond a
6650particular library's limitations. However, if @option{-Wpedantic} is used
6651with @option{-Wformat}, warnings are given about format features not
6652in the selected standard version (but not for @code{strfmon} formats,
6653since those are not in any version of the C standard). @xref{C Dialect
6654Options,,Options Controlling C Dialect}.
6655
6656@table @gcctabopt
d77de738
ML
6657@opindex Wformat
6658@opindex Wformat=1
ddf6fe37
AA
6659@item -Wformat=1
6660@itemx -Wformat
d77de738
ML
6661Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6662@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6663@option{-Wformat} also checks for null format arguments for several
6664functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6665aspects of this level of format checking can be disabled by the
6666options: @option{-Wno-format-contains-nul},
6667@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6668@option{-Wformat} is enabled by @option{-Wall}.
6669
d77de738 6670@opindex Wformat=2
ddf6fe37 6671@item -Wformat=2
d77de738
ML
6672Enable @option{-Wformat} plus additional format checks. Currently
6673equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6674-Wformat-y2k}.
6675@end table
6676
d77de738
ML
6677@opindex Wno-format-contains-nul
6678@opindex Wformat-contains-nul
ddf6fe37 6679@item -Wno-format-contains-nul
d77de738
ML
6680If @option{-Wformat} is specified, do not warn about format strings that
6681contain NUL bytes.
6682
d77de738
ML
6683@opindex Wno-format-extra-args
6684@opindex Wformat-extra-args
ddf6fe37 6685@item -Wno-format-extra-args
d77de738
ML
6686If @option{-Wformat} is specified, do not warn about excess arguments to a
6687@code{printf} or @code{scanf} format function. The C standard specifies
6688that such arguments are ignored.
6689
6690Where the unused arguments lie between used arguments that are
6691specified with @samp{$} operand number specifications, normally
6692warnings are still given, since the implementation could not know what
6693type to pass to @code{va_arg} to skip the unused arguments. However,
6694in the case of @code{scanf} formats, this option suppresses the
6695warning if the unused arguments are all pointers, since the Single
6696Unix Specification says that such unused arguments are allowed.
6697
d77de738
ML
6698@opindex Wformat-overflow
6699@opindex Wno-format-overflow
ddf6fe37
AA
6700@item -Wformat-overflow
6701@itemx -Wformat-overflow=@var{level}
d77de738
ML
6702Warn about calls to formatted input/output functions such as @code{sprintf}
6703and @code{vsprintf} that might overflow the destination buffer. When the
6704exact number of bytes written by a format directive cannot be determined
6705at compile-time it is estimated based on heuristics that depend on the
6706@var{level} argument and on optimization. While enabling optimization
6707will in most cases improve the accuracy of the warning, it may also
6708result in false positives.
6709
6710@table @gcctabopt
d77de738
ML
6711@opindex Wformat-overflow
6712@opindex Wno-format-overflow
ddf6fe37
AA
6713@item -Wformat-overflow
6714@itemx -Wformat-overflow=1
d77de738
ML
6715Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6716employs a conservative approach that warns only about calls that most
6717likely overflow the buffer. At this level, numeric arguments to format
6718directives with unknown values are assumed to have the value of one, and
6719strings of unknown length to be empty. Numeric arguments that are known
6720to be bounded to a subrange of their type, or string arguments whose output
6721is bounded either by their directive's precision or by a finite set of
6722string literals, are assumed to take on the value within the range that
6723results in the most bytes on output. For example, the call to @code{sprintf}
6724below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6725the terminating NUL character (@code{'\0'}) appended by the function
6726to the destination buffer will be written past its end. Increasing
6727the size of the buffer by a single byte is sufficient to avoid the
6728warning, though it may not be sufficient to avoid the overflow.
6729
6730@smallexample
6731void f (int a, int b)
6732@{
6733 char buf [13];
6734 sprintf (buf, "a = %i, b = %i\n", a, b);
6735@}
6736@end smallexample
6737
6738@item -Wformat-overflow=2
6739Level @var{2} warns also about calls that might overflow the destination
6740buffer given an argument of sufficient length or magnitude. At level
6741@var{2}, unknown numeric arguments are assumed to have the minimum
6742representable value for signed types with a precision greater than 1, and
6743the maximum representable value otherwise. Unknown string arguments whose
6744length cannot be assumed to be bounded either by the directive's precision,
6745or by a finite set of string literals they may evaluate to, or the character
6746array they may point to, are assumed to be 1 character long.
6747
6748At level @var{2}, the call in the example above is again diagnosed, but
6749this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6750@code{%i} directive will write some of its digits beyond the end of
6751the destination buffer. To make the call safe regardless of the values
6752of the two variables, the size of the destination buffer must be increased
6753to at least 34 bytes. GCC includes the minimum size of the buffer in
6754an informational note following the warning.
6755
6756An alternative to increasing the size of the destination buffer is to
6757constrain the range of formatted values. The maximum length of string
6758arguments can be bounded by specifying the precision in the format
6759directive. When numeric arguments of format directives can be assumed
6760to be bounded by less than the precision of their type, choosing
6761an appropriate length modifier to the format specifier will reduce
6762the required buffer size. For example, if @var{a} and @var{b} in the
6763example above can be assumed to be within the precision of
6764the @code{short int} type then using either the @code{%hi} format
6765directive or casting the argument to @code{short} reduces the maximum
6766required size of the buffer to 24 bytes.
6767
6768@smallexample
6769void f (int a, int b)
6770@{
6771 char buf [23];
6772 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6773@}
6774@end smallexample
6775@end table
6776
d77de738
ML
6777@opindex Wno-format-zero-length
6778@opindex Wformat-zero-length
ddf6fe37 6779@item -Wno-format-zero-length
d77de738
ML
6780If @option{-Wformat} is specified, do not warn about zero-length formats.
6781The C standard specifies that zero-length formats are allowed.
6782
d77de738
ML
6783@opindex Wformat-nonliteral
6784@opindex Wno-format-nonliteral
ddf6fe37 6785@item -Wformat-nonliteral
d77de738
ML
6786If @option{-Wformat} is specified, also warn if the format string is not a
6787string literal and so cannot be checked, unless the format function
6788takes its format arguments as a @code{va_list}.
6789
d77de738
ML
6790@opindex Wformat-security
6791@opindex Wno-format-security
ddf6fe37 6792@item -Wformat-security
d77de738
ML
6793If @option{-Wformat} is specified, also warn about uses of format
6794functions that represent possible security problems. At present, this
6795warns about calls to @code{printf} and @code{scanf} functions where the
6796format string is not a string literal and there are no format arguments,
6797as in @code{printf (foo);}. This may be a security hole if the format
6798string came from untrusted input and contains @samp{%n}. (This is
6799currently a subset of what @option{-Wformat-nonliteral} warns about, but
6800in future warnings may be added to @option{-Wformat-security} that are not
6801included in @option{-Wformat-nonliteral}.)
6802
d77de738
ML
6803@opindex Wformat-signedness
6804@opindex Wno-format-signedness
ddf6fe37 6805@item -Wformat-signedness
d77de738
ML
6806If @option{-Wformat} is specified, also warn if the format string
6807requires an unsigned argument and the argument is signed and vice versa.
6808
d77de738
ML
6809@opindex Wformat-truncation
6810@opindex Wno-format-truncation
ddf6fe37
AA
6811@item -Wformat-truncation
6812@itemx -Wformat-truncation=@var{level}
d77de738
ML
6813Warn about calls to formatted input/output functions such as @code{snprintf}
6814and @code{vsnprintf} that might result in output truncation. When the exact
6815number of bytes written by a format directive cannot be determined at
6816compile-time it is estimated based on heuristics that depend on
6817the @var{level} argument and on optimization. While enabling optimization
6818will in most cases improve the accuracy of the warning, it may also result
6819in false positives. Except as noted otherwise, the option uses the same
6820logic @option{-Wformat-overflow}.
6821
6822@table @gcctabopt
d77de738
ML
6823@opindex Wformat-truncation
6824@opindex Wno-format-truncation
ddf6fe37
AA
6825@item -Wformat-truncation
6826@itemx -Wformat-truncation=1
d77de738
ML
6827Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6828employs a conservative approach that warns only about calls to bounded
6829functions whose return value is unused and that will most likely result
6830in output truncation.
6831
6832@item -Wformat-truncation=2
6833Level @var{2} warns also about calls to bounded functions whose return
6834value is used and that might result in truncation given an argument of
6835sufficient length or magnitude.
6836@end table
6837
d77de738
ML
6838@opindex Wformat-y2k
6839@opindex Wno-format-y2k
ddf6fe37 6840@item -Wformat-y2k
d77de738
ML
6841If @option{-Wformat} is specified, also warn about @code{strftime}
6842formats that may yield only a two-digit year.
6843
d77de738
ML
6844@opindex Wnonnull
6845@opindex Wno-nonnull
ddf6fe37 6846@item -Wnonnull
d77de738
ML
6847Warn about passing a null pointer for arguments marked as
6848requiring a non-null value by the @code{nonnull} function attribute.
6849
6850@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6851can be disabled with the @option{-Wno-nonnull} option.
6852
d77de738
ML
6853@opindex Wnonnull-compare
6854@opindex Wno-nonnull-compare
ddf6fe37 6855@item -Wnonnull-compare
d77de738
ML
6856Warn when comparing an argument marked with the @code{nonnull}
6857function attribute against null inside the function.
6858
6859@option{-Wnonnull-compare} is included in @option{-Wall}. It
6860can be disabled with the @option{-Wno-nonnull-compare} option.
6861
d77de738
ML
6862@opindex Wnull-dereference
6863@opindex Wno-null-dereference
ddf6fe37 6864@item -Wnull-dereference
d77de738
ML
6865Warn if the compiler detects paths that trigger erroneous or
6866undefined behavior due to dereferencing a null pointer. This option
6867is only active when @option{-fdelete-null-pointer-checks} is active,
6868which is enabled by optimizations in most targets. The precision of
6869the warnings depends on the optimization options used.
6870
2ae5384d
JM
6871@opindex Wnrvo
6872@opindex Wno-nrvo
6873@item -Wnrvo @r{(C++ and Objective-C++ only)}
6874Warn if the compiler does not elide the copy from a local variable to
6875the return value of a function in a context where it is allowed by
6876[class.copy.elision]. This elision is commonly known as the Named
6877Return Value Optimization. For instance, in the example below the
72cfa0f7 6878compiler cannot elide copies from both v1 and v2, so it elides neither.
2ae5384d
JM
6879
6880@smallexample
6881std::vector<int> f()
6882@{
6883 std::vector<int> v1, v2;
6884 // ...
6885 if (cond) return v1;
6886 else return v2; // warning: not eliding copy
6887@}
6888@end smallexample
6889
d77de738
ML
6890@opindex Winfinite-recursion
6891@opindex Wno-infinite-recursion
ddf6fe37 6892@item -Winfinite-recursion
d77de738
ML
6893Warn about infinitely recursive calls. The warning is effective at all
6894optimization levels but requires optimization in order to detect infinite
6895recursion in calls between two or more functions.
6896@option{-Winfinite-recursion} is included in @option{-Wall}.
6897
ce51e843
ML
6898Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6899similar diagnostic, but is implemented in a different way (as part of
6900@option{-fanalyzer}).
6901
d77de738
ML
6902@opindex Winit-self
6903@opindex Wno-init-self
ddf6fe37 6904@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6905Warn about uninitialized variables that are initialized with themselves.
6906Note this option can only be used with the @option{-Wuninitialized} option.
6907
6908For example, GCC warns about @code{i} being uninitialized in the
6909following snippet only when @option{-Winit-self} has been specified:
6910@smallexample
6911@group
6912int f()
6913@{
6914 int i = i;
6915 return i;
6916@}
6917@end group
6918@end smallexample
6919
6920This warning is enabled by @option{-Wall} in C++.
6921
d77de738
ML
6922@opindex Wimplicit-int
6923@opindex Wno-implicit-int
ddf6fe37 6924@item -Wno-implicit-int @r{(C and Objective-C only)}
d77de738 6925This option controls warnings when a declaration does not specify a type.
4ee2aca7
FW
6926This warning is enabled by default, as an error, in C99 and later
6927dialects of C, and also by @option{-Wall}. The error can be downgraded
6928to a warning using @option{-fpermissive} (along with certain other
6929errors), or for this error alone, with @option{-Wno-error=implicit-int}.
d77de738 6930
5fccebdb
JM
6931This warning is upgraded to an error by @option{-pedantic-errors}.
6932
d77de738
ML
6933@opindex Wimplicit-function-declaration
6934@opindex Wno-implicit-function-declaration
ddf6fe37 6935@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
d77de738 6936This option controls warnings when a function is used before being declared.
55e94561
FW
6937This warning is enabled by default, as an error, in C99 and later
6938dialects of C, and also by @option{-Wall}. The error can be downgraded
6939to a warning using @option{-fpermissive} (along with certain other
6940errors), or for this error alone, with
6941@option{-Wno-error=implicit-function-declaration}.
5fccebdb
JM
6942
6943This warning is upgraded to an error by @option{-pedantic-errors}.
d77de738 6944
d77de738
ML
6945@opindex Wimplicit
6946@opindex Wno-implicit
ddf6fe37 6947@item -Wimplicit @r{(C and Objective-C only)}
d77de738
ML
6948Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6949This warning is enabled by @option{-Wall}.
6950
24592abd
MP
6951@opindex Whardened
6952@opindex Wno-hardened
6953@item -Whardened
6954Warn when @option{-fhardened} did not enable an option from its set (for
6955which see @option{-fhardened}). For instance, using @option{-fhardened}
6956and @option{-fstack-protector} at the same time on the command line causes
6957@option{-Whardened} to warn because @option{-fstack-protector-strong} is
6958not enabled by @option{-fhardened}.
6959
6960This warning is enabled by default and has effect only when @option{-fhardened}
6961is enabled.
6962
d77de738
ML
6963@opindex Wimplicit-fallthrough
6964@opindex Wno-implicit-fallthrough
ddf6fe37 6965@item -Wimplicit-fallthrough
d77de738
ML
6966@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6967and @option{-Wno-implicit-fallthrough} is the same as
6968@option{-Wimplicit-fallthrough=0}.
6969
d77de738 6970@opindex Wimplicit-fallthrough=
ddf6fe37 6971@item -Wimplicit-fallthrough=@var{n}
d77de738
ML
6972Warn when a switch case falls through. For example:
6973
6974@smallexample
6975@group
6976switch (cond)
6977 @{
6978 case 1:
6979 a = 1;
6980 break;
6981 case 2:
6982 a = 2;
6983 case 3:
6984 a = 3;
6985 break;
6986 @}
6987@end group
6988@end smallexample
6989
6990This warning does not warn when the last statement of a case cannot
6991fall through, e.g. when there is a return statement or a call to function
6992declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6993also takes into account control flow statements, such as ifs, and only
6994warns when appropriate. E.g.@:
6995
6996@smallexample
6997@group
6998switch (cond)
6999 @{
7000 case 1:
7001 if (i > 3) @{
7002 bar (5);
7003 break;
7004 @} else if (i < 1) @{
7005 bar (0);
7006 @} else
7007 return;
7008 default:
7009 @dots{}
7010 @}
7011@end group
7012@end smallexample
7013
7014Since there are occasions where a switch case fall through is desirable,
7015GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
7016to be used along with a null statement to suppress this warning that
7017would normally occur:
7018
7019@smallexample
7020@group
7021switch (cond)
7022 @{
7023 case 1:
7024 bar (0);
7025 __attribute__ ((fallthrough));
7026 default:
7027 @dots{}
7028 @}
7029@end group
7030@end smallexample
7031
7032C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
7033warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
7034or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
7035Instead of these attributes, it is also possible to add a fallthrough comment
7036to silence the warning. The whole body of the C or C++ style comment should
7037match the given regular expressions listed below. The option argument @var{n}
7038specifies what kind of comments are accepted:
7039
7040@itemize @bullet
7041
7042@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
7043
7044@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
7045expression, any comment is used as fallthrough comment.
7046
7047@item @option{-Wimplicit-fallthrough=2} case insensitively matches
7048@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
7049
7050@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
7051following regular expressions:
7052
7053@itemize @bullet
7054
7055@item @code{-fallthrough}
7056
7057@item @code{@@fallthrough@@}
7058
7059@item @code{lint -fallthrough[ \t]*}
7060
7061@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
7062
7063@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
7064
7065@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
7066
7067@end itemize
7068
7069@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
7070following regular expressions:
7071
7072@itemize @bullet
7073
7074@item @code{-fallthrough}
7075
7076@item @code{@@fallthrough@@}
7077
7078@item @code{lint -fallthrough[ \t]*}
7079
7080@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
7081
7082@end itemize
7083
7084@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
7085fallthrough comments, only attributes disable the warning.
7086
7087@end itemize
7088
7089The comment needs to be followed after optional whitespace and other comments
7090by @code{case} or @code{default} keywords or by a user label that precedes some
7091@code{case} or @code{default} label.
7092
7093@smallexample
7094@group
7095switch (cond)
7096 @{
7097 case 1:
7098 bar (0);
7099 /* FALLTHRU */
7100 default:
7101 @dots{}
7102 @}
7103@end group
7104@end smallexample
7105
7106The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
7107
d77de738
ML
7108@opindex Wif-not-aligned
7109@opindex Wno-if-not-aligned
ddf6fe37 7110@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
7111Control if warnings triggered by the @code{warn_if_not_aligned} attribute
7112should be issued. These warnings are enabled by default.
7113
d77de738
ML
7114@opindex Wignored-qualifiers
7115@opindex Wno-ignored-qualifiers
ddf6fe37 7116@item -Wignored-qualifiers @r{(C and C++ only)}
d77de738
ML
7117Warn if the return type of a function has a type qualifier
7118such as @code{const}. For ISO C such a type qualifier has no effect,
7119since the value returned by a function is not an lvalue.
7120For C++, the warning is only emitted for scalar types or @code{void}.
7121ISO C prohibits qualified @code{void} return types on function
7122definitions, so such return types always receive a warning
7123even without this option.
7124
7125This warning is also enabled by @option{-Wextra}.
7126
d77de738
ML
7127@opindex Wignored-attributes
7128@opindex Wno-ignored-attributes
ddf6fe37 7129@item -Wno-ignored-attributes @r{(C and C++ only)}
d77de738
ML
7130This option controls warnings when an attribute is ignored.
7131This is different from the
7132@option{-Wattributes} option in that it warns whenever the compiler decides
7133to drop an attribute, not that the attribute is either unknown, used in a
7134wrong place, etc. This warning is enabled by default.
7135
d77de738
ML
7136@opindex Wmain
7137@opindex Wno-main
ddf6fe37 7138@item -Wmain
d77de738
ML
7139Warn if the type of @code{main} is suspicious. @code{main} should be
7140a function with external linkage, returning int, taking either zero
7141arguments, two, or three arguments of appropriate types. This warning
7142is enabled by default in C++ and is enabled by either @option{-Wall}
7143or @option{-Wpedantic}.
7144
5fccebdb
JM
7145This warning is upgraded to an error by @option{-pedantic-errors}.
7146
d77de738
ML
7147@opindex Wmisleading-indentation
7148@opindex Wno-misleading-indentation
ddf6fe37 7149@item -Wmisleading-indentation @r{(C and C++ only)}
d77de738
ML
7150Warn when the indentation of the code does not reflect the block structure.
7151Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
7152@code{for} clauses with a guarded statement that does not use braces,
7153followed by an unguarded statement with the same indentation.
7154
7155In the following example, the call to ``bar'' is misleadingly indented as
7156if it were guarded by the ``if'' conditional.
7157
7158@smallexample
7159 if (some_condition ())
7160 foo ();
7161 bar (); /* Gotcha: this is not guarded by the "if". */
7162@end smallexample
7163
7164In the case of mixed tabs and spaces, the warning uses the
7165@option{-ftabstop=} option to determine if the statements line up
7166(defaulting to 8).
7167
7168The warning is not issued for code involving multiline preprocessor logic
7169such as the following example.
7170
7171@smallexample
7172 if (flagA)
7173 foo (0);
7174#if SOME_CONDITION_THAT_DOES_NOT_HOLD
7175 if (flagB)
7176#endif
7177 foo (1);
7178@end smallexample
7179
7180The warning is not issued after a @code{#line} directive, since this
7181typically indicates autogenerated code, and no assumptions can be made
7182about the layout of the file that the directive references.
7183
7184This warning is enabled by @option{-Wall} in C and C++.
7185
d77de738
ML
7186@opindex Wmissing-attributes
7187@opindex Wno-missing-attributes
ddf6fe37 7188@item -Wmissing-attributes
d77de738
ML
7189Warn when a declaration of a function is missing one or more attributes
7190that a related function is declared with and whose absence may adversely
7191affect the correctness or efficiency of generated code. For example,
7192the warning is issued for declarations of aliases that use attributes
7193to specify less restrictive requirements than those of their targets.
7194This typically represents a potential optimization opportunity.
7195By contrast, the @option{-Wattribute-alias=2} option controls warnings
7196issued when the alias is more restrictive than the target, which could
7197lead to incorrect code generation.
7198Attributes considered include @code{alloc_align}, @code{alloc_size},
7199@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
7200@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
7201@code{returns_nonnull}, and @code{returns_twice}.
7202
7203In C++, the warning is issued when an explicit specialization of a primary
7204template declared with attribute @code{alloc_align}, @code{alloc_size},
7205@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
7206or @code{nonnull} is declared without it. Attributes @code{deprecated},
7207@code{error}, and @code{warning} suppress the warning.
7208(@pxref{Function Attributes}).
7209
7210You can use the @code{copy} attribute to apply the same
7211set of attributes to a declaration as that on another declaration without
7212explicitly enumerating the attributes. This attribute can be applied
7213to declarations of functions (@pxref{Common Function Attributes}),
7214variables (@pxref{Common Variable Attributes}), or types
7215(@pxref{Common Type Attributes}).
7216
7217@option{-Wmissing-attributes} is enabled by @option{-Wall}.
7218
7219For example, since the declaration of the primary function template
7220below makes use of both attribute @code{malloc} and @code{alloc_size}
7221the declaration of the explicit specialization of the template is
7222diagnosed because it is missing one of the attributes.
7223
7224@smallexample
7225template <class T>
7226T* __attribute__ ((malloc, alloc_size (1)))
7227allocate (size_t);
7228
7229template <>
7230void* __attribute__ ((malloc)) // missing alloc_size
7231allocate<void> (size_t);
7232@end smallexample
7233
d77de738
ML
7234@opindex Wmissing-braces
7235@opindex Wno-missing-braces
ddf6fe37 7236@item -Wmissing-braces
d77de738
ML
7237Warn if an aggregate or union initializer is not fully bracketed. In
7238the following example, the initializer for @code{a} is not fully
7239bracketed, but that for @code{b} is fully bracketed.
7240
7241@smallexample
7242int a[2][2] = @{ 0, 1, 2, 3 @};
7243int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
7244@end smallexample
7245
7246This warning is enabled by @option{-Wall}.
7247
d77de738
ML
7248@opindex Wmissing-include-dirs
7249@opindex Wno-missing-include-dirs
ddf6fe37 7250@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
72cfa0f7 7251Warn if a user-supplied include directory does not exist. This option is disabled
d77de738
ML
7252by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
7253enabled by default by warning for -I and -J, only.
7254
d77de738
ML
7255@opindex Wmissing-profile
7256@opindex Wno-missing-profile
ddf6fe37 7257@item -Wno-missing-profile
d77de738
ML
7258This option controls warnings if feedback profiles are missing when using the
7259@option{-fprofile-use} option.
7260This option diagnoses those cases where a new function or a new file is added
7261between compiling with @option{-fprofile-generate} and with
7262@option{-fprofile-use}, without regenerating the profiles.
7263In these cases, the profile feedback data files do not contain any
7264profile feedback information for
7265the newly added function or file respectively. Also, in the case when profile
7266count data (.gcda) files are removed, GCC cannot use any profile feedback
7267information. In all these cases, warnings are issued to inform you that a
7268profile generation step is due.
7269Ignoring the warning can result in poorly optimized code.
7270@option{-Wno-missing-profile} can be used to
7271disable the warning, but this is not recommended and should be done only
7272when non-existent profile data is justified.
7273
d77de738
ML
7274@opindex Wmismatched-dealloc
7275@opindex Wno-mismatched-dealloc
ddf6fe37 7276@item -Wmismatched-dealloc
d77de738
ML
7277
7278Warn for calls to deallocation functions with pointer arguments returned
f5964f1a 7279from allocation functions for which the former isn't a suitable
d77de738
ML
7280deallocator. A pair of functions can be associated as matching allocators
7281and deallocators by use of attribute @code{malloc}. Unless disabled by
7282the @option{-fno-builtin} option the standard functions @code{calloc},
7283@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7284forms of C++ @code{operator new} and @code{operator delete} are implicitly
7285associated as matching allocators and deallocators. In the following
7286example @code{mydealloc} is the deallocator for pointers returned from
7287@code{myalloc}.
7288
7289@smallexample
7290void mydealloc (void*);
7291
7292__attribute__ ((malloc (mydealloc, 1))) void*
7293myalloc (size_t);
7294
7295void f (void)
7296@{
7297 void *p = myalloc (32);
7298 // @dots{}use p@dots{}
7299 free (p); // warning: not a matching deallocator for myalloc
7300 mydealloc (p); // ok
7301@}
7302@end smallexample
7303
7304In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7305mismatches involving either @code{operator new} or @code{operator delete}.
7306
7307Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7308
d77de738
ML
7309@opindex Wmultistatement-macros
7310@opindex Wno-multistatement-macros
ddf6fe37 7311@item -Wmultistatement-macros
d77de738
ML
7312Warn about unsafe multiple statement macros that appear to be guarded
7313by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7314@code{while}, in which only the first statement is actually guarded after
7315the macro is expanded.
7316
7317For example:
7318
7319@smallexample
7320#define DOIT x++; y++
7321if (c)
7322 DOIT;
7323@end smallexample
7324
7325will increment @code{y} unconditionally, not just when @code{c} holds.
7326The can usually be fixed by wrapping the macro in a do-while loop:
7327@smallexample
7328#define DOIT do @{ x++; y++; @} while (0)
7329if (c)
7330 DOIT;
7331@end smallexample
7332
7333This warning is enabled by @option{-Wall} in C and C++.
7334
d77de738
ML
7335@opindex Wparentheses
7336@opindex Wno-parentheses
ddf6fe37 7337@item -Wparentheses
d77de738
ML
7338Warn if parentheses are omitted in certain contexts, such
7339as when there is an assignment in a context where a truth value
7340is expected, or when operators are nested whose precedence people
7341often get confused about.
7342
7343Also warn if a comparison like @code{x<=y<=z} appears; this is
7344equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7345interpretation from that of ordinary mathematical notation.
7346
7347Also warn for dangerous uses of the GNU extension to
7348@code{?:} with omitted middle operand. When the condition
7349in the @code{?}: operator is a boolean expression, the omitted value is
7350always 1. Often programmers expect it to be a value computed
7351inside the conditional expression instead.
7352
7353For C++ this also warns for some cases of unnecessary parentheses in
7354declarations, which can indicate an attempt at a function call instead
7355of a declaration:
7356@smallexample
7357@{
7358 // Declares a local variable called mymutex.
7359 std::unique_lock<std::mutex> (mymutex);
7360 // User meant std::unique_lock<std::mutex> lock (mymutex);
7361@}
7362@end smallexample
7363
7364This warning is enabled by @option{-Wall}.
7365
d77de738
ML
7366@opindex Wself-move
7367@opindex Wno-self-move
ddf6fe37 7368@item -Wno-self-move @r{(C++ and Objective-C++ only)}
d77de738
ML
7369This warning warns when a value is moved to itself with @code{std::move}.
7370Such a @code{std::move} typically has no effect.
7371
7372@smallexample
7373struct T @{
7374@dots{}
7375@};
7376void fn()
7377@{
7378 T t;
7379 @dots{}
7380 t = std::move (t);
7381@}
7382@end smallexample
7383
7384This warning is enabled by @option{-Wall}.
7385
d77de738
ML
7386@opindex Wsequence-point
7387@opindex Wno-sequence-point
ddf6fe37 7388@item -Wsequence-point
d77de738
ML
7389Warn about code that may have undefined semantics because of violations
7390of sequence point rules in the C and C++ standards.
7391
7392The C and C++ standards define the order in which expressions in a C/C++
7393program are evaluated in terms of @dfn{sequence points}, which represent
7394a partial ordering between the execution of parts of the program: those
7395executed before the sequence point, and those executed after it. These
7396occur after the evaluation of a full expression (one which is not part
7397of a larger expression), after the evaluation of the first operand of a
7398@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7399function is called (but after the evaluation of its arguments and the
7400expression denoting the called function), and in certain other places.
7401Other than as expressed by the sequence point rules, the order of
7402evaluation of subexpressions of an expression is not specified. All
7403these rules describe only a partial order rather than a total order,
7404since, for example, if two functions are called within one expression
7405with no sequence point between them, the order in which the functions
7406are called is not specified. However, the standards committee have
7407ruled that function calls do not overlap.
7408
7409It is not specified when between sequence points modifications to the
7410values of objects take effect. Programs whose behavior depends on this
7411have undefined behavior; the C and C++ standards specify that ``Between
7412the previous and next sequence point an object shall have its stored
7413value modified at most once by the evaluation of an expression.
7414Furthermore, the prior value shall be read only to determine the value
7415to be stored.''. If a program breaks these rules, the results on any
7416particular implementation are entirely unpredictable.
7417
7418Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7419= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7420diagnosed by this option, and it may give an occasional false positive
7421result, but in general it has been found fairly effective at detecting
7422this sort of problem in programs.
7423
7424The C++17 standard will define the order of evaluation of operands in
7425more cases: in particular it requires that the right-hand side of an
7426assignment be evaluated before the left-hand side, so the above
7427examples are no longer undefined. But this option will still warn
7428about them, to help people avoid writing code that is undefined in C
7429and earlier revisions of C++.
7430
7431The standard is worded confusingly, therefore there is some debate
7432over the precise meaning of the sequence point rules in subtle cases.
7433Links to discussions of the problem, including proposed formal
7434definitions, may be found on the GCC readings page, at
7435@uref{https://gcc.gnu.org/@/readings.html}.
7436
7437This warning is enabled by @option{-Wall} for C and C++.
7438
d77de738
ML
7439@opindex Wno-return-local-addr
7440@opindex Wreturn-local-addr
ddf6fe37 7441@item -Wno-return-local-addr
d77de738
ML
7442Do not warn about returning a pointer (or in C++, a reference) to a
7443variable that goes out of scope after the function returns.
7444
6e312b2b
FW
7445@opindex Wreturn-mismatch
7446@opindex Wno-return-mismatch
7447@item -Wreturn-mismatch
7448Warn about return statements without an expressions in functions which
7449do not return @code{void}. Also warn about a @code{return} statement
7450with an expression in a function whose return type is @code{void},
7451unless the expression type is also @code{void}. As a GNU extension, the
7452latter case is accepted without a warning unless @option{-Wpedantic} is
7453used.
7454
7455Attempting to use the return value of a non-@code{void} function other
7456than @code{main} that flows off the end by reaching the closing curly
7457brace that terminates the function is undefined.
7458
4ecfa6c4
FW
7459This warning is specific to C and enabled by default. In C99 and later
7460language dialects, it is treated as an error. It can be downgraded
7461to a warning using @option{-fpermissive} (along with other warnings),
7462or for just this warning, with @option{-Wno-error=return-mismatch}.
6e312b2b 7463
d77de738
ML
7464@opindex Wreturn-type
7465@opindex Wno-return-type
ddf6fe37 7466@item -Wreturn-type
6e312b2b
FW
7467Warn whenever a function is defined with a return type that defaults to
7468@code{int} (unless @option{-Wimplicit-int} is active, which takes
7469precedence). Also warn if execution may reach the end of the function
7470body, or if the function does not contain any return statement at all.
7471
7472Attempting to use the return value of a non-@code{void} function other
7473than @code{main} that flows off the end by reaching the closing curly
7474brace that terminates the function is undefined.
d77de738
ML
7475
7476Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7477than @code{main} results in undefined behavior even when the value of
7478the function is not used.
7479
7480This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7481
d77de738
ML
7482@opindex Wshift-count-negative
7483@opindex Wno-shift-count-negative
ddf6fe37 7484@item -Wno-shift-count-negative
d77de738
ML
7485Controls warnings if a shift count is negative.
7486This warning is enabled by default.
7487
d77de738
ML
7488@opindex Wshift-count-overflow
7489@opindex Wno-shift-count-overflow
ddf6fe37 7490@item -Wno-shift-count-overflow
d77de738
ML
7491Controls warnings if a shift count is greater than or equal to the bit width
7492of the type. This warning is enabled by default.
7493
d77de738
ML
7494@opindex Wshift-negative-value
7495@opindex Wno-shift-negative-value
ddf6fe37 7496@item -Wshift-negative-value
d77de738
ML
7497Warn if left shifting a negative value. This warning is enabled by
7498@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7499
d77de738
ML
7500@opindex Wshift-overflow
7501@opindex Wno-shift-overflow
ddf6fe37
AA
7502@item -Wno-shift-overflow
7503@itemx -Wshift-overflow=@var{n}
d77de738
ML
7504These options control warnings about left shift overflows.
7505
7506@table @gcctabopt
7507@item -Wshift-overflow=1
7508This is the warning level of @option{-Wshift-overflow} and is enabled
7509by default in C99 and C++11 modes (and newer). This warning level does
7510not warn about left-shifting 1 into the sign bit. (However, in C, such
7511an overflow is still rejected in contexts where an integer constant expression
7512is required.) No warning is emitted in C++20 mode (and newer), as signed left
7513shifts always wrap.
7514
7515@item -Wshift-overflow=2
7516This warning level also warns about left-shifting 1 into the sign bit,
7517unless C++14 mode (or newer) is active.
7518@end table
7519
d77de738
ML
7520@opindex Wswitch
7521@opindex Wno-switch
ddf6fe37 7522@item -Wswitch
d77de738
ML
7523Warn whenever a @code{switch} statement has an index of enumerated type
7524and lacks a @code{case} for one or more of the named codes of that
7525enumeration. (The presence of a @code{default} label prevents this
7526warning.) @code{case} labels outside the enumeration range also
7527provoke warnings when this option is used (even if there is a
7528@code{default} label).
7529This warning is enabled by @option{-Wall}.
7530
d77de738
ML
7531@opindex Wswitch-default
7532@opindex Wno-switch-default
ddf6fe37 7533@item -Wswitch-default
d77de738
ML
7534Warn whenever a @code{switch} statement does not have a @code{default}
7535case.
7536
d77de738
ML
7537@opindex Wswitch-enum
7538@opindex Wno-switch-enum
ddf6fe37 7539@item -Wswitch-enum
d77de738
ML
7540Warn whenever a @code{switch} statement has an index of enumerated type
7541and lacks a @code{case} for one or more of the named codes of that
7542enumeration. @code{case} labels outside the enumeration range also
7543provoke warnings when this option is used. The only difference
7544between @option{-Wswitch} and this option is that this option gives a
7545warning about an omitted enumeration code even if there is a
7546@code{default} label.
7547
d77de738
ML
7548@opindex Wswitch-bool
7549@opindex Wno-switch-bool
ddf6fe37 7550@item -Wno-switch-bool
d77de738
ML
7551Do not warn when a @code{switch} statement has an index of boolean type
7552and the case values are outside the range of a boolean type.
7553It is possible to suppress this warning by casting the controlling
7554expression to a type other than @code{bool}. For example:
7555@smallexample
7556@group
7557switch ((int) (a == 4))
7558 @{
7559 @dots{}
7560 @}
7561@end group
7562@end smallexample
7563This warning is enabled by default for C and C++ programs.
7564
d77de738
ML
7565@opindex Wswitch-outside-range
7566@opindex Wno-switch-outside-range
ddf6fe37 7567@item -Wno-switch-outside-range
d77de738
ML
7568This option controls warnings when a @code{switch} case has a value
7569that is outside of its
7570respective type range. This warning is enabled by default for
7571C and C++ programs.
7572
d77de738
ML
7573@opindex Wswitch-unreachable
7574@opindex Wno-switch-unreachable
ddf6fe37 7575@item -Wno-switch-unreachable
d77de738
ML
7576Do not warn when a @code{switch} statement contains statements between the
7577controlling expression and the first case label, which will never be
7578executed. For example:
7579@smallexample
7580@group
7581switch (cond)
7582 @{
7583 i = 15;
7584 @dots{}
7585 case 5:
7586 @dots{}
7587 @}
7588@end group
7589@end smallexample
7590@option{-Wswitch-unreachable} does not warn if the statement between the
7591controlling expression and the first case label is just a declaration:
7592@smallexample
7593@group
7594switch (cond)
7595 @{
7596 int i;
7597 @dots{}
7598 case 5:
7599 i = 5;
7600 @dots{}
7601 @}
7602@end group
7603@end smallexample
7604This warning is enabled by default for C and C++ programs.
7605
d77de738
ML
7606@opindex Wsync-nand
7607@opindex Wno-sync-nand
ddf6fe37 7608@item -Wsync-nand @r{(C and C++ only)}
d77de738
ML
7609Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7610built-in functions are used. These functions changed semantics in GCC 4.4.
7611
d77de738
ML
7612@opindex Wtrivial-auto-var-init
7613@opindex Wno-trivial-auto-var-init
ddf6fe37 7614@item -Wtrivial-auto-var-init
d77de738
ML
7615Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7616variable. A common situation is an automatic variable that is declared
7617between the controlling expression and the first case label of a @code{switch}
7618statement.
7619
d77de738
ML
7620@opindex Wunused-but-set-parameter
7621@opindex Wno-unused-but-set-parameter
ddf6fe37 7622@item -Wunused-but-set-parameter
d77de738
ML
7623Warn whenever a function parameter is assigned to, but otherwise unused
7624(aside from its declaration).
7625
7626To suppress this warning use the @code{unused} attribute
7627(@pxref{Variable Attributes}).
7628
7629This warning is also enabled by @option{-Wunused} together with
7630@option{-Wextra}.
7631
d77de738
ML
7632@opindex Wunused-but-set-variable
7633@opindex Wno-unused-but-set-variable
ddf6fe37 7634@item -Wunused-but-set-variable
d77de738
ML
7635Warn whenever a local variable is assigned to, but otherwise unused
7636(aside from its declaration).
7637This warning is enabled by @option{-Wall}.
7638
7639To suppress this warning use the @code{unused} attribute
7640(@pxref{Variable Attributes}).
7641
7642This warning is also enabled by @option{-Wunused}, which is enabled
7643by @option{-Wall}.
7644
d77de738
ML
7645@opindex Wunused-function
7646@opindex Wno-unused-function
ddf6fe37 7647@item -Wunused-function
d77de738
ML
7648Warn whenever a static function is declared but not defined or a
7649non-inline static function is unused.
7650This warning is enabled by @option{-Wall}.
7651
d77de738
ML
7652@opindex Wunused-label
7653@opindex Wno-unused-label
ddf6fe37 7654@item -Wunused-label
d77de738
ML
7655Warn whenever a label is declared but not used.
7656This warning is enabled by @option{-Wall}.
7657
7658To suppress this warning use the @code{unused} attribute
7659(@pxref{Variable Attributes}).
7660
d77de738
ML
7661@opindex Wunused-local-typedefs
7662@opindex Wno-unused-local-typedefs
ddf6fe37 7663@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
7664Warn when a typedef locally defined in a function is not used.
7665This warning is enabled by @option{-Wall}.
7666
d77de738
ML
7667@opindex Wunused-parameter
7668@opindex Wno-unused-parameter
ddf6fe37 7669@item -Wunused-parameter
d77de738 7670Warn whenever a function parameter is unused aside from its declaration.
5c3e2e13
SL
7671This option is not enabled by @code{-Wunused} unless @code{-Wextra} is also
7672specified.
d77de738
ML
7673
7674To suppress this warning use the @code{unused} attribute
7675(@pxref{Variable Attributes}).
7676
d77de738
ML
7677@opindex Wunused-result
7678@opindex Wno-unused-result
ddf6fe37 7679@item -Wno-unused-result
d77de738
ML
7680Do not warn if a caller of a function marked with attribute
7681@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7682its return value. The default is @option{-Wunused-result}.
7683
d77de738
ML
7684@opindex Wunused-variable
7685@opindex Wno-unused-variable
ddf6fe37 7686@item -Wunused-variable
d77de738
ML
7687Warn whenever a local or static variable is unused aside from its
7688declaration. This option implies @option{-Wunused-const-variable=1} for C,
7689but not for C++. This warning is enabled by @option{-Wall}.
7690
7691To suppress this warning use the @code{unused} attribute
7692(@pxref{Variable Attributes}).
7693
d77de738
ML
7694@opindex Wunused-const-variable
7695@opindex Wno-unused-const-variable
ddf6fe37
AA
7696@item -Wunused-const-variable
7697@itemx -Wunused-const-variable=@var{n}
d77de738 7698Warn whenever a constant static variable is unused aside from its declaration.
d77de738
ML
7699
7700To suppress this warning use the @code{unused} attribute
7701(@pxref{Variable Attributes}).
7702
7703@table @gcctabopt
7704@item -Wunused-const-variable=1
5c3e2e13 7705Warn about unused static const variables defined in the main
d77de738
ML
7706compilation unit, but not about static const variables declared in any
7707header included.
7708
5c3e2e13
SL
7709@option{-Wunused-const-variable=1} is enabled by either
7710@option{-Wunused-variable} or @option{-Wunused} for C, but not for
7711C++. In C this declares variable storage, but in C++ this is not an
7712error since const variables take the place of @code{#define}s.
7713
d77de738
ML
7714@item -Wunused-const-variable=2
7715This warning level also warns for unused constant static variables in
5c3e2e13
SL
7716headers (excluding system headers). It is equivalent to the short form
7717@option{-Wunused-const-variable}. This level must be explicitly
7718requested in both C and C++ because it might be hard to clean up all
d77de738
ML
7719headers included.
7720@end table
7721
d77de738
ML
7722@opindex Wunused-value
7723@opindex Wno-unused-value
ddf6fe37 7724@item -Wunused-value
d77de738
ML
7725Warn whenever a statement computes a result that is explicitly not
7726used. To suppress this warning cast the unused expression to
7727@code{void}. This includes an expression-statement or the left-hand
7728side of a comma expression that contains no side effects. For example,
7729an expression such as @code{x[i,j]} causes a warning, while
7730@code{x[(void)i,j]} does not.
7731
7732This warning is enabled by @option{-Wall}.
7733
d77de738
ML
7734@opindex Wunused
7735@opindex Wno-unused
ddf6fe37 7736@item -Wunused
5c3e2e13
SL
7737All the above @option{-Wunused} options combined, except those documented
7738as needing to be specified explicitly.
d77de738
ML
7739
7740In order to get a warning about an unused function parameter, you must
7741either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
5c3e2e13
SL
7742@option{-Wunused}), or separately specify @option{-Wunused-parameter} and/or
7743@option{-Wunused-but-set-parameter}.
7744
7745@option{-Wunused} enables only @option{-Wunused-const-variable=1} rather than
7746@option{-Wunused-const-variable}, and only for C, not C++.
d77de738 7747
25bb8a40
SL
7748@opindex Wuse-after-free
7749@opindex Wno-use-after-free
7750@item -Wuse-after-free @r{(C, Objective-C, C++ and Objective-C++ only)}
7751@itemx -Wuse-after-free=@var{n}
7752Warn about uses of pointers to dynamically allocated objects that have
7753been rendered indeterminate by a call to a deallocation function.
7754The warning is enabled at all optimization levels but may yield different
7755results with optimization than without.
7756
7757@table @gcctabopt
7758@item -Wuse-after-free=1
7759At level 1 the warning attempts to diagnose only unconditional uses
7760of pointers made indeterminate by a deallocation call or a successful
7761call to @code{realloc}, regardless of whether or not the call resulted
7762in an actual reallocation of memory. This includes double-@code{free}
7763calls as well as uses in arithmetic and relational expressions. Although
7764undefined, uses of indeterminate pointers in equality (or inequality)
7765expressions are not diagnosed at this level.
7766@item -Wuse-after-free=2
7767At level 2, in addition to unconditional uses, the warning also diagnoses
7768conditional uses of pointers made indeterminate by a deallocation call.
7769As at level 2, uses in equality (or inequality) expressions are not
7770diagnosed. For example, the second call to @code{free} in the following
7771function is diagnosed at this level:
7772@smallexample
7773struct A @{ int refcount; void *data; @};
7774
7775void release (struct A *p)
7776@{
7777 int refcount = --p->refcount;
7778 free (p);
7779 if (refcount == 0)
7780 free (p->data); // warning: p may be used after free
7781@}
7782@end smallexample
7783@item -Wuse-after-free=3
7784At level 3, the warning also diagnoses uses of indeterminate pointers in
7785equality expressions. All uses of indeterminate pointers are undefined
7786but equality tests sometimes appear after calls to @code{realloc} as
7787an attempt to determine whether the call resulted in relocating the object
7788to a different address. They are diagnosed at a separate level to aid
7789gradually transitioning legacy code to safe alternatives. For example,
7790the equality test in the function below is diagnosed at this level:
7791@smallexample
7792void adjust_pointers (int**, int);
7793
7794void grow (int **p, int n)
7795@{
7796 int **q = (int**)realloc (p, n *= 2);
7797 if (q == p)
7798 return;
7799 adjust_pointers ((int**)q, n);
7800@}
7801@end smallexample
7802To avoid the warning at this level, store offsets into allocated memory
7803instead of pointers. This approach obviates needing to adjust the stored
7804pointers after reallocation.
7805@end table
7806
7807@option{-Wuse-after-free=2} is included in @option{-Wall}.
7808
7809@opindex Wuseless-cast
7810@opindex Wno-useless-cast
7811@item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)}
7812Warn when an expression is cast to its own type. This warning does not
7813occur when a class object is converted to a non-reference type as that
7814is a way to create a temporary:
7815
7816@smallexample
7817struct S @{ @};
7818void g (S&&);
7819void f (S&& arg)
7820@{
7821 g (S(arg)); // make arg prvalue so that it can bind to S&&
7822@}
7823@end smallexample
7824
d77de738
ML
7825@opindex Wuninitialized
7826@opindex Wno-uninitialized
ddf6fe37 7827@item -Wuninitialized
d77de738
ML
7828Warn if an object with automatic or allocated storage duration is used
7829without having been initialized. In C++, also warn if a non-static
7830reference or non-static @code{const} member appears in a class without
7831constructors.
7832
7833In addition, passing a pointer (or in C++, a reference) to an uninitialized
7834object to a @code{const}-qualified argument of a built-in function known to
7835read the object is also diagnosed by this warning.
7836(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7837
7838If you want to warn about code that uses the uninitialized value of the
7839variable in its own initializer, use the @option{-Winit-self} option.
7840
7841These warnings occur for individual uninitialized elements of
7842structure, union or array variables as well as for variables that are
7843uninitialized as a whole. They do not occur for variables or elements
7844declared @code{volatile}. Because these warnings depend on
7845optimization, the exact variables or elements for which there are
7846warnings depend on the precise optimization options and version of GCC
7847used.
7848
7849Note that there may be no warning about a variable that is used only
7850to compute a value that itself is never used, because such
7851computations may be deleted by data flow analysis before the warnings
7852are printed.
7853
7854In C++, this warning also warns about using uninitialized objects in
7855member-initializer-lists. For example, GCC warns about @code{b} being
7856uninitialized in the following snippet:
7857
7858@smallexample
7859struct A @{
7860 int a;
7861 int b;
7862 A() : a(b) @{ @}
7863@};
7864@end smallexample
7865
d77de738
ML
7866@opindex Winvalid-memory-model
7867@opindex Wno-invalid-memory-model
ddf6fe37 7868@item -Wno-invalid-memory-model
d77de738
ML
7869This option controls warnings
7870for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7871and the C11 atomic generic functions with a memory consistency argument
7872that is either invalid for the operation or outside the range of values
7873of the @code{memory_order} enumeration. For example, since the
7874@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7875defined for the relaxed, release, and sequentially consistent memory
7876orders the following code is diagnosed:
7877
7878@smallexample
7879void store (int *i)
7880@{
7881 __atomic_store_n (i, 0, memory_order_consume);
7882@}
7883@end smallexample
7884
7885@option{-Winvalid-memory-model} is enabled by default.
7886
d77de738
ML
7887@opindex Wmaybe-uninitialized
7888@opindex Wno-maybe-uninitialized
ddf6fe37 7889@item -Wmaybe-uninitialized
d77de738
ML
7890For an object with automatic or allocated storage duration, if there exists
7891a path from the function entry to a use of the object that is initialized,
7892but there exist some other paths for which the object is not initialized,
7893the compiler emits a warning if it cannot prove the uninitialized paths
7894are not executed at run time.
7895
7896In addition, passing a pointer (or in C++, a reference) to an uninitialized
7897object to a @code{const}-qualified function argument is also diagnosed by
7898this warning. (@option{-Wuninitialized} is issued for built-in functions
7899known to read the object.) Annotating the function with attribute
7900@code{access (none)} indicates that the argument isn't used to access
7901the object and avoids the warning (@pxref{Common Function Attributes}).
7902
7903These warnings are only possible in optimizing compilation, because otherwise
7904GCC does not keep track of the state of variables.
7905
7906These warnings are made optional because GCC may not be able to determine when
7907the code is correct in spite of appearing to have an error. Here is one
7908example of how this can happen:
7909
7910@smallexample
7911@group
7912@{
7913 int x;
7914 switch (y)
7915 @{
7916 case 1: x = 1;
7917 break;
7918 case 2: x = 4;
7919 break;
7920 case 3: x = 5;
7921 @}
7922 foo (x);
7923@}
7924@end group
7925@end smallexample
7926
7927@noindent
7928If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7929always initialized, but GCC doesn't know this. To suppress the
7930warning, you need to provide a default case with assert(0) or
7931similar code.
7932
7933@cindex @code{longjmp} warnings
7934This option also warns when a non-volatile automatic variable might be
7935changed by a call to @code{longjmp}.
7936The compiler sees only the calls to @code{setjmp}. It cannot know
7937where @code{longjmp} will be called; in fact, a signal handler could
7938call it at any point in the code. As a result, you may get a warning
7939even when there is in fact no problem because @code{longjmp} cannot
7940in fact be called at the place that would cause a problem.
7941
7942Some spurious warnings can be avoided if you declare all the functions
7943you use that never return as @code{noreturn}. @xref{Function
7944Attributes}.
7945
7946This warning is enabled by @option{-Wall} or @option{-Wextra}.
7947
d77de738
ML
7948@opindex Wunknown-pragmas
7949@opindex Wno-unknown-pragmas
7950@cindex warning for unknown pragmas
7951@cindex unknown pragmas, warning
7952@cindex pragmas, warning of unknown
f33d7a88 7953@item -Wunknown-pragmas
d77de738
ML
7954Warn when a @code{#pragma} directive is encountered that is not understood by
7955GCC@. If this command-line option is used, warnings are even issued
7956for unknown pragmas in system header files. This is not the case if
7957the warnings are only enabled by the @option{-Wall} command-line option.
7958
d77de738
ML
7959@opindex Wno-pragmas
7960@opindex Wpragmas
ddf6fe37 7961@item -Wno-pragmas
d77de738
ML
7962Do not warn about misuses of pragmas, such as incorrect parameters,
7963invalid syntax, or conflicts between pragmas. See also
7964@option{-Wunknown-pragmas}.
7965
d77de738
ML
7966@opindex Wno-prio-ctor-dtor
7967@opindex Wprio-ctor-dtor
ddf6fe37 7968@item -Wno-prio-ctor-dtor
d77de738
ML
7969Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7970The use of constructor and destructor attributes allow you to assign a
7971priority to the constructor/destructor to control its order of execution
7972before @code{main} is called or after it returns. The priority values must be
7973greater than 100 as the compiler reserves priority values between 0--100 for
7974the implementation.
7975
d77de738
ML
7976@opindex Wstrict-aliasing
7977@opindex Wno-strict-aliasing
ddf6fe37 7978@item -Wstrict-aliasing
d77de738
ML
7979This option is only active when @option{-fstrict-aliasing} is active.
7980It warns about code that might break the strict aliasing rules that the
7981compiler is using for optimization. The warning does not catch all
7982cases, but does attempt to catch the more common pitfalls. It is
7983included in @option{-Wall}.
7984It is equivalent to @option{-Wstrict-aliasing=3}
7985
d77de738 7986@opindex Wstrict-aliasing=n
ddf6fe37 7987@item -Wstrict-aliasing=n
d77de738
ML
7988This option is only active when @option{-fstrict-aliasing} is active.
7989It warns about code that might break the strict aliasing rules that the
7990compiler is using for optimization.
7991Higher levels correspond to higher accuracy (fewer false positives).
7992Higher levels also correspond to more effort, similar to the way @option{-O}
7993works.
7994@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7995
7996Level 1: Most aggressive, quick, least accurate.
7997Possibly useful when higher levels
7998do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7999false negatives. However, it has many false positives.
8000Warns for all pointer conversions between possibly incompatible types,
8001even if never dereferenced. Runs in the front end only.
8002
8003Level 2: Aggressive, quick, not too precise.
8004May still have many false positives (not as many as level 1 though),
8005and few false negatives (but possibly more than level 1).
8006Unlike level 1, it only warns when an address is taken. Warns about
8007incomplete types. Runs in the front end only.
8008
8009Level 3 (default for @option{-Wstrict-aliasing}):
8010Should have very few false positives and few false
8011negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
8012Takes care of the common pun+dereference pattern in the front end:
8013@code{*(int*)&some_float}.
8014If optimization is enabled, it also runs in the back end, where it deals
8015with multiple statement cases using flow-sensitive points-to information.
8016Only warns when the converted pointer is dereferenced.
8017Does not warn about incomplete types.
8018
d77de738
ML
8019@opindex Wstrict-overflow
8020@opindex Wno-strict-overflow
ddf6fe37
AA
8021@item -Wstrict-overflow
8022@itemx -Wstrict-overflow=@var{n}
d77de738
ML
8023This option is only active when signed overflow is undefined.
8024It warns about cases where the compiler optimizes based on the
8025assumption that signed overflow does not occur. Note that it does not
8026warn about all cases where the code might overflow: it only warns
8027about cases where the compiler implements some optimization. Thus
8028this warning depends on the optimization level.
8029
8030An optimization that assumes that signed overflow does not occur is
8031perfectly safe if the values of the variables involved are such that
8032overflow never does, in fact, occur. Therefore this warning can
8033easily give a false positive: a warning about code that is not
8034actually a problem. To help focus on important issues, several
8035warning levels are defined. No warnings are issued for the use of
8036undefined signed overflow when estimating how many iterations a loop
8037requires, in particular when determining whether a loop will be
8038executed at all.
8039
8040@table @gcctabopt
8041@item -Wstrict-overflow=1
8042Warn about cases that are both questionable and easy to avoid. For
8043example the compiler simplifies
8044@code{x + 1 > x} to @code{1}. This level of
8045@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
8046are not, and must be explicitly requested.
8047
8048@item -Wstrict-overflow=2
8049Also warn about other cases where a comparison is simplified to a
8050constant. For example: @code{abs (x) >= 0}. This can only be
8051simplified when signed integer overflow is undefined, because
8052@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
8053zero. @option{-Wstrict-overflow} (with no level) is the same as
8054@option{-Wstrict-overflow=2}.
8055
8056@item -Wstrict-overflow=3
8057Also warn about other cases where a comparison is simplified. For
8058example: @code{x + 1 > 1} is simplified to @code{x > 0}.
8059
8060@item -Wstrict-overflow=4
8061Also warn about other simplifications not covered by the above cases.
8062For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
8063
8064@item -Wstrict-overflow=5
8065Also warn about cases where the compiler reduces the magnitude of a
8066constant involved in a comparison. For example: @code{x + 2 > y} is
8067simplified to @code{x + 1 >= y}. This is reported only at the
8068highest warning level because this simplification applies to many
8069comparisons, so this warning level gives a very large number of
8070false positives.
8071@end table
8072
d77de738
ML
8073@opindex Wstring-compare
8074@opindex Wno-string-compare
ddf6fe37 8075@item -Wstring-compare
d77de738
ML
8076Warn for calls to @code{strcmp} and @code{strncmp} whose result is
8077determined to be either zero or non-zero in tests for such equality
8078owing to the length of one argument being greater than the size of
8079the array the other argument is stored in (or the bound in the case
8080of @code{strncmp}). Such calls could be mistakes. For example,
8081the call to @code{strcmp} below is diagnosed because its result is
8082necessarily non-zero irrespective of the contents of the array @code{a}.
8083
8084@smallexample
8085extern char a[4];
8086void f (char *d)
8087@{
8088 strcpy (d, "string");
8089 @dots{}
8090 if (0 == strcmp (a, d)) // cannot be true
8091 puts ("a and d are the same");
8092@}
8093@end smallexample
8094
8095@option{-Wstring-compare} is enabled by @option{-Wextra}.
8096
ddf6fe37
AA
8097@opindex Wstringop-overflow
8098@opindex Wno-stringop-overflow
d77de738
ML
8099@item -Wno-stringop-overflow
8100@item -Wstringop-overflow
8101@itemx -Wstringop-overflow=@var{type}
d77de738
ML
8102Warn for calls to string manipulation functions such as @code{memcpy} and
8103@code{strcpy} that are determined to overflow the destination buffer. The
8104optional argument is one greater than the type of Object Size Checking to
8105perform to determine the size of the destination. @xref{Object Size Checking}.
8106The argument is meaningful only for functions that operate on character arrays
8107but not for raw memory functions like @code{memcpy} which always make use
8108of Object Size type-0. The option also warns for calls that specify a size
8109in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
8110The option produces the best results with optimization enabled but can detect
8111a small subset of simple buffer overflows even without optimization in
8112calls to the GCC built-in functions like @code{__builtin_memcpy} that
8113correspond to the standard functions. In any case, the option warns about
8114just a subset of buffer overflows detected by the corresponding overflow
8115checking built-ins. For example, the option issues a warning for
8116the @code{strcpy} call below because it copies at least 5 characters
8117(the string @code{"blue"} including the terminating NUL) into the buffer
8118of size 4.
8119
8120@smallexample
8121enum Color @{ blue, purple, yellow @};
8122const char* f (enum Color clr)
8123@{
8124 static char buf [4];
8125 const char *str;
8126 switch (clr)
8127 @{
8128 case blue: str = "blue"; break;
8129 case purple: str = "purple"; break;
8130 case yellow: str = "yellow"; break;
8131 @}
8132
8133 return strcpy (buf, str); // warning here
8134@}
8135@end smallexample
8136
8137Option @option{-Wstringop-overflow=2} is enabled by default.
8138
8139@table @gcctabopt
d77de738
ML
8140@opindex Wstringop-overflow
8141@opindex Wno-stringop-overflow
ddf6fe37
AA
8142@item -Wstringop-overflow
8143@itemx -Wstringop-overflow=1
d77de738
ML
8144The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
8145to determine the sizes of destination objects. At this setting the option
8146does not warn for writes past the end of subobjects of larger objects accessed
8147by pointers unless the size of the largest surrounding object is known. When
8148the destination may be one of several objects it is assumed to be the largest
8149one of them. On Linux systems, when optimization is enabled at this setting
8150the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
8151is defined to a non-zero value.
8152
8153@item -Wstringop-overflow=2
8154The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
8155to determine the sizes of destination objects. At this setting the option
8156warns about overflows when writing to members of the largest complete
8157objects whose exact size is known. However, it does not warn for excessive
8158writes to the same members of unknown objects referenced by pointers since
8159they may point to arrays containing unknown numbers of elements. This is
8160the default setting of the option.
8161
8162@item -Wstringop-overflow=3
8163The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
8164to determine the sizes of destination objects. At this setting the option
8165warns about overflowing the smallest object or data member. This is the
8166most restrictive setting of the option that may result in warnings for safe
8167code.
8168
8169@item -Wstringop-overflow=4
8170The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
8171to determine the sizes of destination objects. At this setting the option
8172warns about overflowing any data members, and when the destination is
8173one of several objects it uses the size of the largest of them to decide
8174whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
8175setting of the option may result in warnings for benign code.
8176@end table
8177
d77de738
ML
8178@opindex Wstringop-overread
8179@opindex Wno-stringop-overread
ddf6fe37 8180@item -Wno-stringop-overread
d77de738
ML
8181Warn for calls to string manipulation functions such as @code{memchr}, or
8182@code{strcpy} that are determined to read past the end of the source
8183sequence.
8184
8185Option @option{-Wstringop-overread} is enabled by default.
8186
d77de738
ML
8187@opindex Wstringop-truncation
8188@opindex Wno-stringop-truncation
ddf6fe37 8189@item -Wno-stringop-truncation
d77de738
ML
8190Do not warn for calls to bounded string manipulation functions
8191such as @code{strncat},
8192@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
8193or leave the destination unchanged.
8194
8195In the following example, the call to @code{strncat} specifies a bound that
8196is less than the length of the source string. As a result, the copy of
8197the source will be truncated and so the call is diagnosed. To avoid the
8198warning use @code{bufsize - strlen (buf) - 1)} as the bound.
8199
8200@smallexample
8201void append (char *buf, size_t bufsize)
8202@{
8203 strncat (buf, ".txt", 3);
8204@}
8205@end smallexample
8206
8207As another example, the following call to @code{strncpy} results in copying
8208to @code{d} just the characters preceding the terminating NUL, without
8209appending the NUL to the end. Assuming the result of @code{strncpy} is
8210necessarily a NUL-terminated string is a common mistake, and so the call
8211is diagnosed. To avoid the warning when the result is not expected to be
8212NUL-terminated, call @code{memcpy} instead.
8213
8214@smallexample
8215void copy (char *d, const char *s)
8216@{
8217 strncpy (d, s, strlen (s));
8218@}
8219@end smallexample
8220
8221In the following example, the call to @code{strncpy} specifies the size
8222of the destination buffer as the bound. If the length of the source
8223string is equal to or greater than this size the result of the copy will
8224not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
8225the warning, specify @code{sizeof buf - 1} as the bound and set the last
8226element of the buffer to @code{NUL}.
8227
8228@smallexample
8229void copy (const char *s)
8230@{
8231 char buf[80];
8232 strncpy (buf, s, sizeof buf);
8233 @dots{}
8234@}
8235@end smallexample
8236
8237In situations where a character array is intended to store a sequence
8238of bytes with no terminating @code{NUL} such an array may be annotated
8239with attribute @code{nonstring} to avoid this warning. Such arrays,
8240however, are not suitable arguments to functions that expect
8241@code{NUL}-terminated strings. To help detect accidental misuses of
8242such arrays GCC issues warnings unless it can prove that the use is
8243safe. @xref{Common Variable Attributes}.
8244
2a27ae32
QZ
8245@opindex Wstrict-flex-arrays
8246@opindex Wno-strict-flex-arrays
eb71695f
SL
8247@item -Wstrict-flex-arrays @r{(C and C++ only)}
8248Warn about improper usages of flexible array members
2a27ae32
QZ
8249according to the @var{level} of the @code{strict_flex_array (@var{level})}
8250attribute attached to the trailing array field of a structure if it's
8251available, otherwise according to the @var{level} of the option
eb71695f
SL
8252@option{-fstrict-flex-arrays=@var{level}}. @xref{Common Variable Attributes},
8253for more information about the attribute, and @ref{C Dialect Options} for
8254more information about the option. @code{-Wstrict-flex-arrays}
8255is effective only when @var{level} is greater than 0.
2a27ae32 8256
eb71695f 8257When @var{level}=1, warnings are issued for a trailing array reference
2a27ae32
QZ
8258of a structure that have 2 or more elements if the trailing array is referenced
8259as a flexible array member.
8260
eb71695f 8261When @var{level}=2, in addition to @var{level}=1, additional warnings are
2a27ae32
QZ
8262issued for a trailing one-element array reference of a structure
8263if the array is referenced as a flexible array member.
8264
eb71695f 8265When @var{level}=3, in addition to @var{level}=2, additional warnings are
2a27ae32
QZ
8266issued for a trailing zero-length array reference of a structure
8267if the array is referenced as a flexible array member.
8268
eb71695f
SL
8269This option is more effective when @option{-ftree-vrp} is active (the
8270default for @option{-O2} and above) but some warnings may be diagnosed
8271even without optimization.
2a27ae32 8272
d77de738
ML
8273@opindex Wsuggest-attribute=
8274@opindex Wno-suggest-attribute=
53ba8d66 8275@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}returns_nonnull@r{|}
d77de738
ML
8276Warn for cases where adding an attribute may be beneficial. The
8277attributes currently supported are listed below.
8278
8279@table @gcctabopt
d77de738
ML
8280@opindex Wsuggest-attribute=pure
8281@opindex Wno-suggest-attribute=pure
8282@opindex Wsuggest-attribute=const
8283@opindex Wno-suggest-attribute=const
8284@opindex Wsuggest-attribute=noreturn
8285@opindex Wno-suggest-attribute=noreturn
8286@opindex Wmissing-noreturn
8287@opindex Wno-missing-noreturn
8288@opindex Wsuggest-attribute=malloc
8289@opindex Wno-suggest-attribute=malloc
ddf6fe37
AA
8290@item -Wsuggest-attribute=pure
8291@itemx -Wsuggest-attribute=const
8292@itemx -Wsuggest-attribute=noreturn
8293@itemx -Wmissing-noreturn
8294@itemx -Wsuggest-attribute=malloc
53ba8d66
JH
8295@itemx -Wsuggest-attribute=returns_nonnull
8296@itemx -Wno-suggest-attribute=returns_nonnull
d77de738
ML
8297
8298Warn about functions that might be candidates for attributes
53ba8d66 8299@code{pure}, @code{const}, @code{noreturn}, @code{malloc} or @code{returns_nonnull}. The compiler
d77de738
ML
8300only warns for functions visible in other compilation units or (in the case of
8301@code{pure} and @code{const}) if it cannot prove that the function returns
8302normally. A function returns normally if it doesn't contain an infinite loop or
8303return abnormally by throwing, calling @code{abort} or trapping. This analysis
8304requires option @option{-fipa-pure-const}, which is enabled by default at
8305@option{-O} and higher. Higher optimization levels improve the accuracy
8306of the analysis.
8307
d77de738
ML
8308@opindex Wsuggest-attribute=format
8309@opindex Wmissing-format-attribute
8310@opindex Wno-suggest-attribute=format
8311@opindex Wno-missing-format-attribute
8312@opindex Wformat
8313@opindex Wno-format
ddf6fe37
AA
8314@item -Wsuggest-attribute=format
8315@itemx -Wmissing-format-attribute
d77de738
ML
8316
8317Warn about function pointers that might be candidates for @code{format}
8318attributes. Note these are only possible candidates, not absolute ones.
8319GCC guesses that function pointers with @code{format} attributes that
8320are used in assignment, initialization, parameter passing or return
8321statements should have a corresponding @code{format} attribute in the
8322resulting type. I.e.@: the left-hand side of the assignment or
8323initialization, the type of the parameter variable, or the return type
8324of the containing function respectively should also have a @code{format}
8325attribute to avoid the warning.
8326
8327GCC also warns about function definitions that might be
8328candidates for @code{format} attributes. Again, these are only
8329possible candidates. GCC guesses that @code{format} attributes
8330might be appropriate for any function that calls a function like
8331@code{vprintf} or @code{vscanf}, but this might not always be the
8332case, and some functions for which @code{format} attributes are
8333appropriate may not be detected.
8334
d77de738
ML
8335@opindex Wsuggest-attribute=cold
8336@opindex Wno-suggest-attribute=cold
ddf6fe37 8337@item -Wsuggest-attribute=cold
d77de738
ML
8338
8339Warn about functions that might be candidates for @code{cold} attribute. This
8340is based on static detection and generally only warns about functions which
8341always leads to a call to another @code{cold} function such as wrappers of
8342C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
8343@end table
8344
d880e093
MU
8345@opindex Wno-alloc-size
8346@opindex Walloc-size
8347@item -Walloc-size
8348Warn about calls to allocation functions decorated with attribute
8349@code{alloc_size} that specify insufficient size for the target type of
8350the pointer the result is assigned to, including those to the built-in
8351forms of the functions @code{aligned_alloc}, @code{alloca},
e7dd72ae 8352@code{calloc}, @code{malloc}, and @code{realloc}.
d880e093 8353
d77de738
ML
8354@opindex Wno-alloc-zero
8355@opindex Walloc-zero
ddf6fe37 8356@item -Walloc-zero
d77de738
ML
8357Warn about calls to allocation functions decorated with attribute
8358@code{alloc_size} that specify zero bytes, including those to the built-in
8359forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
8360@code{malloc}, and @code{realloc}. Because the behavior of these functions
8361when called with a zero size differs among implementations (and in the case
8362of @code{realloc} has been deprecated) relying on it may result in subtle
8363portability bugs and should be avoided.
8364
e7dd72ae
JJ
8365@opindex Wcalloc-transposed-args
8366@opindex Wno-calloc-transposed-args
8367@item -Wcalloc-transposed-args
8368Warn about calls to allocation functions decorated with attribute
8369@code{alloc_size} with two arguments, which use @code{sizeof} operator
8370as the earlier size argument and don't use it as the later size argument.
8371This is a coding style warning. The first argument to @code{calloc} is
8372documented to be number of elements in array, while the second argument
8373is size of each element, so @code{calloc (@var{n}, sizeof (int))} is preferred
8374over @code{calloc (sizeof (int), @var{n})}. If @code{sizeof} in the earlier
8375argument and not the latter is intentional, the warning can be suppressed
8376by using @code{calloc (sizeof (struct @var{S}) + 0, n)} or
8377@code{calloc (1 * sizeof (struct @var{S}), 4)} or using @code{sizeof} in the
8378later argument as well.
8379
d77de738
ML
8380@opindex Walloc-size-larger-than=
8381@opindex Wno-alloc-size-larger-than
ddf6fe37 8382@item -Walloc-size-larger-than=@var{byte-size}
d77de738
ML
8383Warn about calls to functions decorated with attribute @code{alloc_size}
8384that attempt to allocate objects larger than the specified number of bytes,
8385or where the result of the size computation in an integer type with infinite
8386precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
8387@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8388Warnings controlled by the option can be disabled either by specifying
8389@var{byte-size} of @samp{SIZE_MAX} or more or by
8390@option{-Wno-alloc-size-larger-than}.
8391@xref{Function Attributes}.
8392
d77de738 8393@opindex Wno-alloc-size-larger-than
ddf6fe37 8394@item -Wno-alloc-size-larger-than
d77de738
ML
8395Disable @option{-Walloc-size-larger-than=} warnings. The option is
8396equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
8397larger.
8398
d77de738
ML
8399@opindex Wno-alloca
8400@opindex Walloca
ddf6fe37 8401@item -Walloca
d77de738
ML
8402This option warns on all uses of @code{alloca} in the source.
8403
d77de738
ML
8404@opindex Walloca-larger-than=
8405@opindex Wno-alloca-larger-than
ddf6fe37 8406@item -Walloca-larger-than=@var{byte-size}
d77de738
ML
8407This option warns on calls to @code{alloca} with an integer argument whose
8408value is either zero, or that is not bounded by a controlling predicate
8409that limits its value to at most @var{byte-size}. It also warns for calls
8410to @code{alloca} where the bound value is unknown. Arguments of non-integer
8411types are considered unbounded even if they appear to be constrained to
8412the expected range.
8413
8414For example, a bounded case of @code{alloca} could be:
8415
8416@smallexample
8417void func (size_t n)
8418@{
8419 void *p;
8420 if (n <= 1000)
8421 p = alloca (n);
8422 else
8423 p = malloc (n);
8424 f (p);
8425@}
8426@end smallexample
8427
8428In the above example, passing @code{-Walloca-larger-than=1000} would not
8429issue a warning because the call to @code{alloca} is known to be at most
84301000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8431the compiler would emit a warning.
8432
8433Unbounded uses, on the other hand, are uses of @code{alloca} with no
8434controlling predicate constraining its integer argument. For example:
8435
8436@smallexample
8437void func ()
8438@{
8439 void *p = alloca (n);
8440 f (p);
8441@}
8442@end smallexample
8443
8444If @code{-Walloca-larger-than=500} were passed, the above would trigger
8445a warning, but this time because of the lack of bounds checking.
8446
8447Note, that even seemingly correct code involving signed integers could
8448cause a warning:
8449
8450@smallexample
8451void func (signed int n)
8452@{
8453 if (n < 500)
8454 @{
8455 p = alloca (n);
8456 f (p);
8457 @}
8458@}
8459@end smallexample
8460
8461In the above example, @var{n} could be negative, causing a larger than
8462expected argument to be implicitly cast into the @code{alloca} call.
8463
8464This option also warns when @code{alloca} is used in a loop.
8465
8466@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8467but is usually only effective when @option{-ftree-vrp} is active (default
8468for @option{-O2} and above).
8469
8470See also @option{-Wvla-larger-than=}@samp{byte-size}.
8471
d77de738 8472@opindex Wno-alloca-larger-than
ddf6fe37 8473@item -Wno-alloca-larger-than
d77de738
ML
8474Disable @option{-Walloca-larger-than=} warnings. The option is
8475equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8476
d77de738
ML
8477@opindex Warith-conversion
8478@opindex Wno-arith-conversion
ddf6fe37 8479@item -Warith-conversion
d77de738
ML
8480Do warn about implicit conversions from arithmetic operations even
8481when conversion of the operands to the same type cannot change their
8482values. This affects warnings from @option{-Wconversion},
8483@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8484
8485@smallexample
8486@group
8487void f (char c, int i)
8488@{
8489 c = c + i; // warns with @option{-Wconversion}
8490 c = c + 1; // only warns with @option{-Warith-conversion}
8491@}
8492@end group
8493@end smallexample
8494
d77de738
ML
8495@opindex Wno-array-bounds
8496@opindex Warray-bounds
ddf6fe37
AA
8497@item -Warray-bounds
8498@itemx -Warray-bounds=@var{n}
d77de738
ML
8499Warn about out of bounds subscripts or offsets into arrays. This warning
8500is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8501is active (the default for @option{-O2} and above) but a subset of instances
8502are issued even without optimization.
8503
710c9676
QZ
8504By default, the trailing array of a structure will be treated as a flexible
8505array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8506if it is declared as either a flexible array member per C99 standard onwards
8507(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8508array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8509zero-length arrays or one-element arrays are not warned by default.
8510
8511You can add the option @option{-fstrict-flex-arrays} or
8512@option{-fstrict-flex-arrays=@var{level}} to control how this
8513option treat trailing array of a structure as a flexible array member:
8514
8515when @var{level}<=1, no change to the default behavior.
8516
8517when @var{level}=2, additional warnings will be issued for out of bounds
8518subscripts or offsets into one-element arrays;
8519
8520when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8521issued for out of bounds subscripts or offsets into zero-length arrays.
8522
d77de738
ML
8523@table @gcctabopt
8524@item -Warray-bounds=1
8525This is the default warning level of @option{-Warray-bounds} and is enabled
8526by @option{-Wall}; higher levels are not, and must be explicitly requested.
8527
8528@item -Warray-bounds=2
710c9676
QZ
8529This warning level also warns about the intermediate results of pointer
8530arithmetic that may yield out of bounds values. This warning level may
8531give a larger number of false positives and is deactivated by default.
d77de738
ML
8532@end table
8533
d77de738
ML
8534@opindex Warray-compare
8535@opindex Wno-array-compare
ddf6fe37 8536@item -Warray-compare
d77de738
ML
8537Warn about equality and relational comparisons between two operands of array
8538type. This comparison was deprecated in C++20. For example:
8539
8540@smallexample
8541int arr1[5];
8542int arr2[5];
8543bool same = arr1 == arr2;
8544@end smallexample
8545
8546@option{-Warray-compare} is enabled by @option{-Wall}.
8547
ddf6fe37 8548@opindex Wno-array-parameter
8fd992a3 8549@opindex Warray-parameter
d77de738
ML
8550@item -Warray-parameter
8551@itemx -Warray-parameter=@var{n}
8fd992a3 8552Warn about redeclarations of functions involving parameters of array or
d77de738
ML
8553pointer types of inconsistent kinds or forms, and enable the detection
8554of out-of-bounds accesses to such parameters by warnings such as
8555@option{-Warray-bounds}.
8556
8fd992a3
SL
8557If the first function declaration uses the array form for a parameter
8558declaration, the bound specified
d77de738
ML
8559in the array is assumed to be the minimum number of elements expected to
8560be provided in calls to the function and the maximum number of elements
8561accessed by it. Failing to provide arguments of sufficient size or accessing
8562more than the maximum number of elements may be diagnosed by warnings such
8fd992a3
SL
8563as @option{-Warray-bounds} or @option{-Wstringop-overflow}.
8564At level 1, the warning diagnoses inconsistencies
d77de738
ML
8565involving array parameters declared using the @code{T[static N]} form.
8566
8fd992a3
SL
8567For example, the warning triggers for the second declaration of @code{f}
8568because the first one with the keyword @code{static} specifies that
8569the array argument must have at least four elements, while the second
8570allows an array of any size to be passed to @code{f}.
d77de738
ML
8571
8572@smallexample
8573void f (int[static 4]);
8574void f (int[]); // warning (inconsistent array form)
8575
8576void g (void)
8577@{
8fd992a3 8578 int *p = (int *)malloc (1 * sizeof (int));
d77de738
ML
8579 f (p); // warning (array too small)
8580 @dots{}
8581@}
8582@end smallexample
8583
8584At level 2 the warning also triggers for redeclarations involving any other
8585inconsistency in array or pointer argument forms denoting array sizes.
8586Pointers and arrays of unspecified bound are considered equivalent and do
8587not trigger a warning.
8588
8589@smallexample
8590void g (int*);
8591void g (int[]); // no warning
8592void g (int[8]); // warning (inconsistent array bound)
8593@end smallexample
8594
8595@option{-Warray-parameter=2} is included in @option{-Wall}. The
8596@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8597involving Variable Length Array arguments.
8598
8fd992a3
SL
8599The short form of the option @option{-Warray-parameter} is equivalent to
8600@option{-Warray-parameter=2}. The negative form @option{-Wno-array-parameter}
8601is equivalent to @option{-Warray-parameter=0}.
8602
d77de738
ML
8603@opindex Wattribute-alias
8604@opindex Wno-attribute-alias
ddf6fe37
AA
8605@item -Wattribute-alias=@var{n}
8606@itemx -Wno-attribute-alias
d77de738
ML
8607Warn about declarations using the @code{alias} and similar attributes whose
8608target is incompatible with the type of the alias.
8609@xref{Function Attributes,,Declaring Attributes of Functions}.
8610
8611@table @gcctabopt
8612@item -Wattribute-alias=1
8613The default warning level of the @option{-Wattribute-alias} option diagnoses
8614incompatibilities between the type of the alias declaration and that of its
8615target. Such incompatibilities are typically indicative of bugs.
8616
8617@item -Wattribute-alias=2
8618
8619At this level @option{-Wattribute-alias} also diagnoses cases where
8620the attributes of the alias declaration are more restrictive than the
8621attributes applied to its target. These mismatches can potentially
8622result in incorrect code generation. In other cases they may be
8623benign and could be resolved simply by adding the missing attribute to
8624the target. For comparison, see the @option{-Wmissing-attributes}
8625option, which controls diagnostics when the alias declaration is less
8626restrictive than the target, rather than more restrictive.
8627
8628Attributes considered include @code{alloc_align}, @code{alloc_size},
8629@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8630@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8631@code{returns_nonnull}, and @code{returns_twice}.
8632@end table
8633
8634@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8635This is the default. You can disable these warnings with either
8636@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8637
d77de738
ML
8638@opindex Wbidi-chars=
8639@opindex Wbidi-chars
8640@opindex Wno-bidi-chars
ddf6fe37 8641@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
d77de738
ML
8642Warn about possibly misleading UTF-8 bidirectional control characters in
8643comments, string literals, character constants, and identifiers. Such
8644characters can change left-to-right writing direction into right-to-left
8645(and vice versa), which can cause confusion between the logical order and
8646visual order. This may be dangerous; for instance, it may seem that a piece
8647of code is not commented out, whereas it in fact is.
8648
8649There are three levels of warning supported by GCC@. The default is
8650@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8651bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8652@option{-Wbidi-chars=any} warns about any use of bidirectional control
8653characters.
8654
8655By default, this warning does not warn about UCNs. It is, however, possible
8656to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8657@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8658and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8659@option{-Wbidi-chars=any} was specified.
8660
d77de738
ML
8661@opindex Wno-bool-compare
8662@opindex Wbool-compare
ddf6fe37 8663@item -Wbool-compare
d77de738
ML
8664Warn about boolean expression compared with an integer value different from
8665@code{true}/@code{false}. For instance, the following comparison is
8666always false:
8667@smallexample
8668int n = 5;
8669@dots{}
8670if ((n > 1) == 2) @{ @dots{} @}
8671@end smallexample
8672This warning is enabled by @option{-Wall}.
8673
d77de738
ML
8674@opindex Wno-bool-operation
8675@opindex Wbool-operation
ddf6fe37 8676@item -Wbool-operation
d77de738
ML
8677Warn about suspicious operations on expressions of a boolean type. For
8678instance, bitwise negation of a boolean is very likely a bug in the program.
8679For C, this warning also warns about incrementing or decrementing a boolean,
8680which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8681Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8682
8683This warning is enabled by @option{-Wall}.
8684
d77de738
ML
8685@opindex Wno-duplicated-branches
8686@opindex Wduplicated-branches
ddf6fe37 8687@item -Wduplicated-branches
d77de738
ML
8688Warn when an if-else has identical branches. This warning detects cases like
8689@smallexample
8690if (p != NULL)
8691 return 0;
8692else
8693 return 0;
8694@end smallexample
8695It doesn't warn when both branches contain just a null statement. This warning
8696also warn for conditional operators:
8697@smallexample
8698 int i = x ? *p : *p;
8699@end smallexample
8700
d77de738
ML
8701@opindex Wno-duplicated-cond
8702@opindex Wduplicated-cond
ddf6fe37 8703@item -Wduplicated-cond
d77de738
ML
8704Warn about duplicated conditions in an if-else-if chain. For instance,
8705warn for the following code:
8706@smallexample
8707if (p->q != NULL) @{ @dots{} @}
8708else if (p->q != NULL) @{ @dots{} @}
8709@end smallexample
8710
d77de738
ML
8711@opindex Wno-frame-address
8712@opindex Wframe-address
ddf6fe37 8713@item -Wframe-address
d77de738
ML
8714Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8715is called with an argument greater than 0. Such calls may return indeterminate
8716values or crash the program. The warning is included in @option{-Wall}.
8717
d77de738
ML
8718@opindex Wno-discarded-qualifiers
8719@opindex Wdiscarded-qualifiers
ddf6fe37 8720@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8721Do not warn if type qualifiers on pointers are being discarded.
8722Typically, the compiler warns if a @code{const char *} variable is
8723passed to a function that takes a @code{char *} parameter. This option
8724can be used to suppress such a warning.
8725
d77de738
ML
8726@opindex Wno-discarded-array-qualifiers
8727@opindex Wdiscarded-array-qualifiers
ddf6fe37 8728@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8729Do not warn if type qualifiers on arrays which are pointer targets
8730are being discarded. Typically, the compiler warns if a
8731@code{const int (*)[]} variable is passed to a function that
8732takes a @code{int (*)[]} parameter. This option can be used to
8733suppress such a warning.
8734
d77de738
ML
8735@opindex Wno-incompatible-pointer-types
8736@opindex Wincompatible-pointer-types
ddf6fe37 8737@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
d77de738
ML
8738Do not warn when there is a conversion between pointers that have incompatible
8739types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8740which warns for pointer argument passing or assignment with different
8741signedness.
8742
9715c545
FW
8743By default, in C99 and later dialects of C, GCC treats this issue as an
8744error. The error can be downgraded to a warning using
8745@option{-fpermissive} (along with certain other errors), or for this
8746error alone, with @option{-Wno-error=incompatible-pointer-types}.
8747
5fccebdb
JM
8748This warning is upgraded to an error by @option{-pedantic-errors}.
8749
d77de738
ML
8750@opindex Wno-int-conversion
8751@opindex Wint-conversion
ddf6fe37 8752@item -Wno-int-conversion @r{(C and Objective-C only)}
d77de738
ML
8753Do not warn about incompatible integer to pointer and pointer to integer
8754conversions. This warning is about implicit conversions; for explicit
8755conversions the warnings @option{-Wno-int-to-pointer-cast} and
8756@option{-Wno-pointer-to-int-cast} may be used.
8757
2c3db94d
FW
8758By default, in C99 and later dialects of C, GCC treats this issue as an
8759error. The error can be downgraded to a warning using
8760@option{-fpermissive} (along with certain other errors), or for this
8761error alone, with @option{-Wno-error=int-conversion}.
8762
5fccebdb
JM
8763This warning is upgraded to an error by @option{-pedantic-errors}.
8764
d77de738
ML
8765@opindex Wzero-length-bounds
8766@opindex Wzero-length-bounds
ddf6fe37 8767@item -Wzero-length-bounds
d77de738
ML
8768Warn about accesses to elements of zero-length array members that might
8769overlap other members of the same object. Declaring interior zero-length
8e9c65d3 8770arrays is discouraged because accesses to them are undefined.
d77de738
ML
8771@xref{Zero Length}.
8772
8773For example, the first two stores in function @code{bad} are diagnosed
8774because the array elements overlap the subsequent members @code{b} and
8775@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8776because it is beyond the bounds of the enclosing object.
8777
8778@smallexample
8779struct X @{ int a[0]; int b, c; @};
8780struct X x;
8781
8782void bad (void)
8783@{
8784 x.a[0] = 0; // -Wzero-length-bounds
8785 x.a[1] = 1; // -Wzero-length-bounds
8786 x.a[2] = 2; // -Warray-bounds
8787@}
8788@end smallexample
8789
8790Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8791
d77de738
ML
8792@opindex Wno-div-by-zero
8793@opindex Wdiv-by-zero
ddf6fe37 8794@item -Wno-div-by-zero
d77de738
ML
8795Do not warn about compile-time integer division by zero. Floating-point
8796division by zero is not warned about, as it can be a legitimate way of
8797obtaining infinities and NaNs.
8798
d77de738
ML
8799@opindex Wsystem-headers
8800@opindex Wno-system-headers
8801@cindex warnings from system headers
8802@cindex system headers, warnings from
f33d7a88 8803@item -Wsystem-headers
d77de738
ML
8804Print warning messages for constructs found in system header files.
8805Warnings from system headers are normally suppressed, on the assumption
8806that they usually do not indicate real problems and would only make the
8807compiler output harder to read. Using this command-line option tells
8808GCC to emit warnings from system headers as if they occurred in user
8809code. However, note that using @option{-Wall} in conjunction with this
8810option does @emph{not} warn about unknown pragmas in system
8811headers---for that, @option{-Wunknown-pragmas} must also be used.
8812
d77de738
ML
8813@opindex Wtautological-compare
8814@opindex Wno-tautological-compare
ddf6fe37 8815@item -Wtautological-compare
d77de738
ML
8816Warn if a self-comparison always evaluates to true or false. This
8817warning detects various mistakes such as:
8818@smallexample
8819int i = 1;
8820@dots{}
8821if (i > i) @{ @dots{} @}
8822@end smallexample
8823
8824This warning also warns about bitwise comparisons that always evaluate
8825to true or false, for instance:
8826@smallexample
8827if ((a & 16) == 10) @{ @dots{} @}
8828@end smallexample
8829will always be false.
8830
8831This warning is enabled by @option{-Wall}.
8832
d77de738
ML
8833@opindex Wtrampolines
8834@opindex Wno-trampolines
ddf6fe37 8835@item -Wtrampolines
d77de738
ML
8836Warn about trampolines generated for pointers to nested functions.
8837A trampoline is a small piece of data or code that is created at run
8838time on the stack when the address of a nested function is taken, and is
8839used to call the nested function indirectly. For some targets, it is
8840made up of data only and thus requires no special treatment. But, for
8841most targets, it is made up of code and thus requires the stack to be
8842made executable in order for the program to work properly.
8843
d77de738
ML
8844@opindex Wfloat-equal
8845@opindex Wno-float-equal
ddf6fe37 8846@item -Wfloat-equal
d77de738
ML
8847Warn if floating-point values are used in equality comparisons.
8848
8849The idea behind this is that sometimes it is convenient (for the
8850programmer) to consider floating-point values as approximations to
8851infinitely precise real numbers. If you are doing this, then you need
8852to compute (by analyzing the code, or in some other way) the maximum or
8853likely maximum error that the computation introduces, and allow for it
8854when performing comparisons (and when producing output, but that's a
8855different problem). In particular, instead of testing for equality, you
8856should check to see whether the two values have ranges that overlap; and
8857this is done with the relational operators, so equality comparisons are
8858probably mistaken.
8859
d77de738
ML
8860@opindex Wtraditional
8861@opindex Wno-traditional
ddf6fe37 8862@item -Wtraditional @r{(C and Objective-C only)}
d77de738
ML
8863Warn about certain constructs that behave differently in traditional and
8864ISO C@. Also warn about ISO C constructs that have no traditional C
8865equivalent, and/or problematic constructs that should be avoided.
8866
8867@itemize @bullet
8868@item
8869Macro parameters that appear within string literals in the macro body.
8870In traditional C macro replacement takes place within string literals,
8871but in ISO C it does not.
8872
8873@item
8874In traditional C, some preprocessor directives did not exist.
8875Traditional preprocessors only considered a line to be a directive
8876if the @samp{#} appeared in column 1 on the line. Therefore
8877@option{-Wtraditional} warns about directives that traditional C
8878understands but ignores because the @samp{#} does not appear as the
8879first character on the line. It also suggests you hide directives like
8880@code{#pragma} not understood by traditional C by indenting them. Some
8881traditional implementations do not recognize @code{#elif}, so this option
8882suggests avoiding it altogether.
8883
8884@item
8885A function-like macro that appears without arguments.
8886
8887@item
8888The unary plus operator.
8889
8890@item
8891The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8892constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8893constants.) Note, these suffixes appear in macros defined in the system
8894headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8895Use of these macros in user code might normally lead to spurious
8896warnings, however GCC's integrated preprocessor has enough context to
8897avoid warning in these cases.
8898
8899@item
8900A function declared external in one block and then used after the end of
8901the block.
8902
8903@item
8904A @code{switch} statement has an operand of type @code{long}.
8905
8906@item
8907A non-@code{static} function declaration follows a @code{static} one.
8908This construct is not accepted by some traditional C compilers.
8909
8910@item
8911The ISO type of an integer constant has a different width or
8912signedness from its traditional type. This warning is only issued if
8913the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8914typically represent bit patterns, are not warned about.
8915
8916@item
8917Usage of ISO string concatenation is detected.
8918
8919@item
8920Initialization of automatic aggregates.
8921
8922@item
8923Identifier conflicts with labels. Traditional C lacks a separate
8924namespace for labels.
8925
8926@item
8927Initialization of unions. If the initializer is zero, the warning is
8928omitted. This is done under the assumption that the zero initializer in
8929user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8930initializer warnings and relies on default initialization to zero in the
8931traditional C case.
8932
8933@item
8934Conversions by prototypes between fixed/floating-point values and vice
8935versa. The absence of these prototypes when compiling with traditional
8936C causes serious problems. This is a subset of the possible
8937conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8938
8939@item
8940Use of ISO C style function definitions. This warning intentionally is
8941@emph{not} issued for prototype declarations or variadic functions
8942because these ISO C features appear in your code when using
8943libiberty's traditional C compatibility macros, @code{PARAMS} and
8944@code{VPARAMS}. This warning is also bypassed for nested functions
8945because that feature is already a GCC extension and thus not relevant to
8946traditional C compatibility.
8947@end itemize
8948
d77de738
ML
8949@opindex Wtraditional-conversion
8950@opindex Wno-traditional-conversion
ddf6fe37 8951@item -Wtraditional-conversion @r{(C and Objective-C only)}
d77de738
ML
8952Warn if a prototype causes a type conversion that is different from what
8953would happen to the same argument in the absence of a prototype. This
8954includes conversions of fixed point to floating and vice versa, and
8955conversions changing the width or signedness of a fixed-point argument
8956except when the same as the default promotion.
8957
d77de738
ML
8958@opindex Wdeclaration-after-statement
8959@opindex Wno-declaration-after-statement
ddf6fe37 8960@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
d77de738
ML
8961Warn when a declaration is found after a statement in a block. This
8962construct, known from C++, was introduced with ISO C99 and is by default
8963allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8964
5fccebdb
JM
8965This warning is upgraded to an error by @option{-pedantic-errors}.
8966
d77de738
ML
8967@opindex Wshadow
8968@opindex Wno-shadow
ddf6fe37 8969@item -Wshadow
d77de738
ML
8970Warn whenever a local variable or type declaration shadows another
8971variable, parameter, type, class member (in C++), or instance variable
8972(in Objective-C) or whenever a built-in function is shadowed. Note
8973that in C++, the compiler warns if a local variable shadows an
8974explicit typedef, but not if it shadows a struct/class/enum.
8975If this warning is enabled, it includes also all instances of
8976local shadowing. This means that @option{-Wno-shadow=local}
8977and @option{-Wno-shadow=compatible-local} are ignored when
8978@option{-Wshadow} is used.
8979Same as @option{-Wshadow=global}.
8980
d77de738
ML
8981@opindex Wno-shadow-ivar
8982@opindex Wshadow-ivar
ddf6fe37 8983@item -Wno-shadow-ivar @r{(Objective-C only)}
d77de738
ML
8984Do not warn whenever a local variable shadows an instance variable in an
8985Objective-C method.
8986
d77de738 8987@opindex Wshadow=global
ddf6fe37 8988@item -Wshadow=global
d77de738
ML
8989Warn for any shadowing.
8990Same as @option{-Wshadow}.
8991
d77de738 8992@opindex Wshadow=local
ddf6fe37 8993@item -Wshadow=local
d77de738
ML
8994Warn when a local variable shadows another local variable or parameter.
8995
d77de738 8996@opindex Wshadow=compatible-local
ddf6fe37 8997@item -Wshadow=compatible-local
d77de738
ML
8998Warn when a local variable shadows another local variable or parameter
8999whose type is compatible with that of the shadowing variable. In C++,
9000type compatibility here means the type of the shadowing variable can be
9001converted to that of the shadowed variable. The creation of this flag
9002(in addition to @option{-Wshadow=local}) is based on the idea that when
9003a local variable shadows another one of incompatible type, it is most
9004likely intentional, not a bug or typo, as shown in the following example:
9005
9006@smallexample
9007@group
9008for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
9009@{
9010 for (int i = 0; i < N; ++i)
9011 @{
9012 ...
9013 @}
9014 ...
9015@}
9016@end group
9017@end smallexample
9018
9019Since the two variable @code{i} in the example above have incompatible types,
9020enabling only @option{-Wshadow=compatible-local} does not emit a warning.
9021Because their types are incompatible, if a programmer accidentally uses one
9022in place of the other, type checking is expected to catch that and emit an
9023error or warning. Use of this flag instead of @option{-Wshadow=local} can
9024possibly reduce the number of warnings triggered by intentional shadowing.
9025Note that this also means that shadowing @code{const char *i} by
9026@code{char *i} does not emit a warning.
9027
9028This warning is also enabled by @option{-Wshadow=local}.
9029
d77de738
ML
9030@opindex Wlarger-than=
9031@opindex Wlarger-than-@var{byte-size}
ddf6fe37 9032@item -Wlarger-than=@var{byte-size}
d77de738
ML
9033Warn whenever an object is defined whose size exceeds @var{byte-size}.
9034@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
9035Warnings controlled by the option can be disabled either by specifying
9036@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
9037
9038Also warn for calls to bounded functions such as @code{memchr} or
9039@code{strnlen} that specify a bound greater than the largest possible
9040object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
9041can only be disabled by @option{-Wno-larger-than}.
9042
d77de738 9043@opindex Wno-larger-than
ddf6fe37 9044@item -Wno-larger-than
d77de738
ML
9045Disable @option{-Wlarger-than=} warnings. The option is equivalent
9046to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
9047
d77de738
ML
9048@opindex Wframe-larger-than=
9049@opindex Wno-frame-larger-than
ddf6fe37 9050@item -Wframe-larger-than=@var{byte-size}
d77de738
ML
9051Warn if the size of a function frame exceeds @var{byte-size}.
9052The computation done to determine the stack frame size is approximate
9053and not conservative.
9054The actual requirements may be somewhat greater than @var{byte-size}
9055even if you do not get a warning. In addition, any space allocated
9056via @code{alloca}, variable-length arrays, or related constructs
9057is not included by the compiler when determining
9058whether or not to issue a warning.
9059@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
9060Warnings controlled by the option can be disabled either by specifying
9061@var{byte-size} of @samp{SIZE_MAX} or more or by
9062@option{-Wno-frame-larger-than}.
9063
d77de738 9064@opindex Wno-frame-larger-than
ddf6fe37 9065@item -Wno-frame-larger-than
d77de738
ML
9066Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
9067to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
9068
d77de738
ML
9069@opindex Wfree-nonheap-object
9070@opindex Wno-free-nonheap-object
ddf6fe37 9071@item -Wfree-nonheap-object
d77de738
ML
9072Warn when attempting to deallocate an object that was either not allocated
9073on the heap, or by using a pointer that was not returned from a prior call
9074to the corresponding allocation function. For example, because the call
9075to @code{stpcpy} returns a pointer to the terminating nul character and
9076not to the beginning of the object, the call to @code{free} below is
9077diagnosed.
9078
9079@smallexample
9080void f (char *p)
9081@{
9082 p = stpcpy (p, "abc");
9083 // ...
9084 free (p); // warning
9085@}
9086@end smallexample
9087
9088@option{-Wfree-nonheap-object} is included in @option{-Wall}.
9089
d77de738
ML
9090@opindex Wstack-usage
9091@opindex Wno-stack-usage
ddf6fe37 9092@item -Wstack-usage=@var{byte-size}
d77de738
ML
9093Warn if the stack usage of a function might exceed @var{byte-size}.
9094The computation done to determine the stack usage is conservative.
9095Any space allocated via @code{alloca}, variable-length arrays, or related
9096constructs is included by the compiler when determining whether or not to
9097issue a warning.
9098
9099The message is in keeping with the output of @option{-fstack-usage}.
9100
9101@itemize
9102@item
9103If the stack usage is fully static but exceeds the specified amount, it's:
9104
9105@smallexample
9106 warning: stack usage is 1120 bytes
9107@end smallexample
9108@item
9109If the stack usage is (partly) dynamic but bounded, it's:
9110
9111@smallexample
9112 warning: stack usage might be 1648 bytes
9113@end smallexample
9114@item
9115If the stack usage is (partly) dynamic and not bounded, it's:
9116
9117@smallexample
9118 warning: stack usage might be unbounded
9119@end smallexample
9120@end itemize
9121
9122@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
9123Warnings controlled by the option can be disabled either by specifying
9124@var{byte-size} of @samp{SIZE_MAX} or more or by
9125@option{-Wno-stack-usage}.
9126
d77de738 9127@opindex Wno-stack-usage
ddf6fe37 9128@item -Wno-stack-usage
d77de738
ML
9129Disable @option{-Wstack-usage=} warnings. The option is equivalent
9130to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
9131
d77de738
ML
9132@opindex Wunsafe-loop-optimizations
9133@opindex Wno-unsafe-loop-optimizations
ddf6fe37 9134@item -Wunsafe-loop-optimizations
d77de738
ML
9135Warn if the loop cannot be optimized because the compiler cannot
9136assume anything on the bounds of the loop indices. With
9137@option{-funsafe-loop-optimizations} warn if the compiler makes
9138such assumptions.
9139
d77de738
ML
9140@opindex Wno-pedantic-ms-format
9141@opindex Wpedantic-ms-format
ddf6fe37 9142@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
d77de738
ML
9143When used in combination with @option{-Wformat}
9144and @option{-pedantic} without GNU extensions, this option
9145disables the warnings about non-ISO @code{printf} / @code{scanf} format
9146width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
9147which depend on the MS runtime.
9148
d77de738
ML
9149@opindex Wpointer-arith
9150@opindex Wno-pointer-arith
ddf6fe37 9151@item -Wpointer-arith
d77de738
ML
9152Warn about anything that depends on the ``size of'' a function type or
9153of @code{void}. GNU C assigns these types a size of 1, for
9154convenience in calculations with @code{void *} pointers and pointers
9155to functions. In C++, warn also when an arithmetic operation involves
9156@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
9157
5fccebdb
JM
9158This warning is upgraded to an error by @option{-pedantic-errors}.
9159
d77de738
ML
9160@opindex Wpointer-compare
9161@opindex Wno-pointer-compare
ddf6fe37 9162@item -Wno-pointer-compare
d77de738
ML
9163Do not warn if a pointer is compared with a zero character constant.
9164This usually
9165means that the pointer was meant to be dereferenced. For example:
9166
9167@smallexample
9168const char *p = foo ();
9169if (p == '\0')
9170 return 42;
9171@end smallexample
9172
9173Note that the code above is invalid in C++11.
9174
9175This warning is enabled by default.
9176
d77de738
ML
9177@opindex Wtsan
9178@opindex Wno-tsan
9a5e8f9d
SL
9179@item -Wno-tsan
9180
9181Disable warnings about unsupported features in ThreadSanitizer.
d77de738
ML
9182
9183ThreadSanitizer does not support @code{std::atomic_thread_fence} and
9184can report false positives.
9185
d77de738
ML
9186@opindex Wtype-limits
9187@opindex Wno-type-limits
ddf6fe37 9188@item -Wtype-limits
d77de738
ML
9189Warn if a comparison is always true or always false due to the limited
9190range of the data type, but do not warn for constant expressions. For
9191example, warn if an unsigned variable is compared against zero with
9192@code{<} or @code{>=}. This warning is also enabled by
9193@option{-Wextra}.
9194
d77de738
ML
9195@opindex Wabsolute-value
9196@opindex Wno-absolute-value
ddf6fe37 9197@item -Wabsolute-value @r{(C and Objective-C only)}
d77de738
ML
9198Warn for calls to standard functions that compute the absolute value
9199of an argument when a more appropriate standard function is available.
9200For example, calling @code{abs(3.14)} triggers the warning because the
9201appropriate function to call to compute the absolute value of a double
9202argument is @code{fabs}. The option also triggers warnings when the
9203argument in a call to such a function has an unsigned type. This
9204warning can be suppressed with an explicit type cast and it is also
9205enabled by @option{-Wextra}.
9206
9207@include cppwarnopts.texi
9208
d77de738
ML
9209@opindex Wbad-function-cast
9210@opindex Wno-bad-function-cast
ddf6fe37 9211@item -Wbad-function-cast @r{(C and Objective-C only)}
d77de738
ML
9212Warn when a function call is cast to a non-matching type.
9213For example, warn if a call to a function returning an integer type
9214is cast to a pointer type.
9215
d77de738
ML
9216@opindex Wc90-c99-compat
9217@opindex Wno-c90-c99-compat
ddf6fe37 9218@item -Wc90-c99-compat @r{(C and Objective-C only)}
d77de738
ML
9219Warn about features not present in ISO C90, but present in ISO C99.
9220For instance, warn about use of variable length arrays, @code{long long}
9221type, @code{bool} type, compound literals, designated initializers, and so
9222on. This option is independent of the standards mode. Warnings are disabled
9223in the expression that follows @code{__extension__}.
9224
d77de738
ML
9225@opindex Wc99-c11-compat
9226@opindex Wno-c99-c11-compat
ddf6fe37 9227@item -Wc99-c11-compat @r{(C and Objective-C only)}
d77de738
ML
9228Warn about features not present in ISO C99, but present in ISO C11.
9229For instance, warn about use of anonymous structures and unions,
9230@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
9231@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
9232and so on. This option is independent of the standards mode. Warnings are
9233disabled in the expression that follows @code{__extension__}.
9234
fad61bf7
JM
9235@opindex Wc11-c23-compat
9236@opindex Wno-c11-c23-compat
9237@item -Wc11-c23-compat @r{(C and Objective-C only)}
9238@itemx -Wc11-c2x-compat @r{(C and Objective-C only)}
9239Warn about features not present in ISO C11, but present in ISO C23.
d77de738
ML
9240For instance, warn about omitting the string in @code{_Static_assert},
9241use of @samp{[[]]} syntax for attributes, use of decimal
9242floating-point types, and so on. This option is independent of the
9243standards mode. Warnings are disabled in the expression that follows
fad61bf7
JM
9244@code{__extension__}. The name @option{-Wc11-c2x-compat} is
9245deprecated.
d77de738 9246
fad61bf7 9247When not compiling in C23 mode, these warnings are upgraded to errors
5fccebdb
JM
9248by @option{-pedantic-errors}.
9249
d77de738
ML
9250@opindex Wc++-compat
9251@opindex Wno-c++-compat
ddf6fe37 9252@item -Wc++-compat @r{(C and Objective-C only)}
d77de738
ML
9253Warn about ISO C constructs that are outside of the common subset of
9254ISO C and ISO C++, e.g.@: request for implicit conversion from
9255@code{void *} to a pointer to non-@code{void} type.
9256
d77de738
ML
9257@opindex Wc++11-compat
9258@opindex Wno-c++11-compat
ddf6fe37 9259@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9260Warn about C++ constructs whose meaning differs between ISO C++ 1998
9261and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
9262in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
9263enabled by @option{-Wall}.
9264
d77de738
ML
9265@opindex Wc++14-compat
9266@opindex Wno-c++14-compat
ddf6fe37 9267@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9268Warn about C++ constructs whose meaning differs between ISO C++ 2011
9269and ISO C++ 2014. This warning is enabled by @option{-Wall}.
9270
d77de738
ML
9271@opindex Wc++17-compat
9272@opindex Wno-c++17-compat
ddf6fe37 9273@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9274Warn about C++ constructs whose meaning differs between ISO C++ 2014
9275and ISO C++ 2017. This warning is enabled by @option{-Wall}.
9276
d77de738
ML
9277@opindex Wc++20-compat
9278@opindex Wno-c++20-compat
ddf6fe37 9279@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
9280Warn about C++ constructs whose meaning differs between ISO C++ 2017
9281and ISO C++ 2020. This warning is enabled by @option{-Wall}.
9282
d77de738
ML
9283@opindex Wc++11-extensions
9284@opindex Wno-c++11-extensions
ddf6fe37 9285@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9286Do not warn about C++11 constructs in code being compiled using
9287an older C++ standard. Even without this option, some C++11 constructs
9288will only be diagnosed if @option{-Wpedantic} is used.
9289
d77de738
ML
9290@opindex Wc++14-extensions
9291@opindex Wno-c++14-extensions
ddf6fe37 9292@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9293Do not warn about C++14 constructs in code being compiled using
9294an older C++ standard. Even without this option, some C++14 constructs
9295will only be diagnosed if @option{-Wpedantic} is used.
9296
d77de738
ML
9297@opindex Wc++17-extensions
9298@opindex Wno-c++17-extensions
ddf6fe37 9299@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9300Do not warn about C++17 constructs in code being compiled using
9301an older C++ standard. Even without this option, some C++17 constructs
9302will only be diagnosed if @option{-Wpedantic} is used.
9303
d77de738
ML
9304@opindex Wc++20-extensions
9305@opindex Wno-c++20-extensions
ddf6fe37 9306@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9307Do not warn about C++20 constructs in code being compiled using
9308an older C++ standard. Even without this option, some C++20 constructs
9309will only be diagnosed if @option{-Wpedantic} is used.
9310
d77de738
ML
9311@opindex Wc++23-extensions
9312@opindex Wno-c++23-extensions
ddf6fe37 9313@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
9314Do not warn about C++23 constructs in code being compiled using
9315an older C++ standard. Even without this option, some C++23 constructs
9316will only be diagnosed if @option{-Wpedantic} is used.
9317
6ce95218
JJ
9318@opindex Wc++26-extensions
9319@opindex Wno-c++26-extensions
9320@item -Wno-c++26-extensions @r{(C++ and Objective-C++ only)}
9321Do not warn about C++26 constructs in code being compiled using
9322an older C++ standard. Even without this option, some C++26 constructs
9323will only be diagnosed if @option{-Wpedantic} is used.
9324
d77de738
ML
9325@opindex Wcast-qual
9326@opindex Wno-cast-qual
ddf6fe37 9327@item -Wcast-qual
d77de738
ML
9328Warn whenever a pointer is cast so as to remove a type qualifier from
9329the target type. For example, warn if a @code{const char *} is cast
9330to an ordinary @code{char *}.
9331
9332Also warn when making a cast that introduces a type qualifier in an
9333unsafe way. For example, casting @code{char **} to @code{const char **}
9334is unsafe, as in this example:
9335
9336@smallexample
9337 /* p is char ** value. */
9338 const char **q = (const char **) p;
9339 /* Assignment of readonly string to const char * is OK. */
9340 *q = "string";
9341 /* Now char** pointer points to read-only memory. */
9342 **p = 'b';
9343@end smallexample
9344
d77de738
ML
9345@opindex Wcast-align
9346@opindex Wno-cast-align
ddf6fe37 9347@item -Wcast-align
d77de738
ML
9348Warn whenever a pointer is cast such that the required alignment of the
9349target is increased. For example, warn if a @code{char *} is cast to
9350an @code{int *} on machines where integers can only be accessed at
9351two- or four-byte boundaries.
9352
d77de738 9353@opindex Wcast-align=strict
ddf6fe37 9354@item -Wcast-align=strict
d77de738
ML
9355Warn whenever a pointer is cast such that the required alignment of the
9356target is increased. For example, warn if a @code{char *} is cast to
9357an @code{int *} regardless of the target machine.
9358
d77de738
ML
9359@opindex Wcast-function-type
9360@opindex Wno-cast-function-type
ddf6fe37 9361@item -Wcast-function-type
d77de738
ML
9362Warn when a function pointer is cast to an incompatible function pointer.
9363In a cast involving function types with a variable argument list only
9364the types of initial arguments that are provided are considered.
9365Any parameter of pointer-type matches any other pointer-type. Any benign
9366differences in integral types are ignored, like @code{int} vs.@: @code{long}
9367on ILP32 targets. Likewise type qualifiers are ignored. The function
9368type @code{void (*) (void)} is special and matches everything, which can
9369be used to suppress this warning.
9370In a cast involving pointer to member types this warning warns whenever
9371the type cast is changing the pointer to member type.
9372This warning is enabled by @option{-Wextra}.
9373
d77de738
ML
9374@opindex Wwrite-strings
9375@opindex Wno-write-strings
ddf6fe37 9376@item -Wwrite-strings
d77de738
ML
9377When compiling C, give string constants the type @code{const
9378char[@var{length}]} so that copying the address of one into a
9379non-@code{const} @code{char *} pointer produces a warning. These
9380warnings help you find at compile time code that can try to write
9381into a string constant, but only if you have been very careful about
9382using @code{const} in declarations and prototypes. Otherwise, it is
9383just a nuisance. This is why we did not make @option{-Wall} request
9384these warnings.
9385
9386When compiling C++, warn about the deprecated conversion from string
9387literals to @code{char *}. This warning is enabled by default for C++
9388programs.
9389
5fccebdb
JM
9390This warning is upgraded to an error by @option{-pedantic-errors} in
9391C++11 mode or later.
9392
d77de738
ML
9393@opindex Wclobbered
9394@opindex Wno-clobbered
f33d7a88 9395@item -Wclobbered
d77de738
ML
9396Warn for variables that might be changed by @code{longjmp} or
9397@code{vfork}. This warning is also enabled by @option{-Wextra}.
9398
320dc51c
TS
9399@opindex Wcomplain-wrong-lang
9400@opindex Wno-complain-wrong-lang
f33d7a88 9401@item -Wno-complain-wrong-lang
320dc51c
TS
9402By default, language front ends complain when a command-line option is
9403valid, but not applicable to that front end.
9404This may be disabled with @option{-Wno-complain-wrong-lang},
9405which is mostly useful when invoking a single compiler driver for
9406multiple source files written in different languages, for example:
9407
9408@smallexample
9409$ g++ -fno-rtti a.cc b.f90
9410@end smallexample
9411
9412The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
9413and the Fortran front end to compile @file{b.f90}.
9414The latter front end diagnoses
9415@samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
9416which may be disabled with @option{-Wno-complain-wrong-lang}.
9417
e1f45bea
JM
9418@opindex Wcompare-distinct-pointer-types
9419@item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)}
9420Warn if pointers of distinct types are compared without a cast. This
9421warning is enabled by default.
9422
d77de738
ML
9423@opindex Wconversion
9424@opindex Wno-conversion
f33d7a88 9425@item -Wconversion
d77de738
ML
9426Warn for implicit conversions that may alter a value. This includes
9427conversions between real and integer, like @code{abs (x)} when
9428@code{x} is @code{double}; conversions between signed and unsigned,
9429like @code{unsigned ui = -1}; and conversions to smaller types, like
9430@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
9431((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
9432changed by the conversion like in @code{abs (2.0)}. Warnings about
9433conversions between signed and unsigned integers can be disabled by
9434using @option{-Wno-sign-conversion}.
9435
9436For C++, also warn for confusing overload resolution for user-defined
9437conversions; and conversions that never use a type conversion
9438operator: conversions to @code{void}, the same type, a base class or a
9439reference to them. Warnings about conversions between signed and
9440unsigned integers are disabled by default in C++ unless
9441@option{-Wsign-conversion} is explicitly enabled.
9442
9443Warnings about conversion from arithmetic on a small type back to that
9444type are only given with @option{-Warith-conversion}.
9445
d77de738
ML
9446@opindex Wdangling-else
9447@opindex Wno-dangling-else
ddf6fe37 9448@item -Wdangling-else
d77de738
ML
9449Warn about constructions where there may be confusion to which
9450@code{if} statement an @code{else} branch belongs. Here is an example of
9451such a case:
9452
9453@smallexample
9454@group
9455@{
9456 if (a)
9457 if (b)
9458 foo ();
9459 else
9460 bar ();
9461@}
9462@end group
9463@end smallexample
9464
9465In C/C++, every @code{else} branch belongs to the innermost possible
9466@code{if} statement, which in this example is @code{if (b)}. This is
9467often not what the programmer expected, as illustrated in the above
9468example by indentation the programmer chose. When there is the
9469potential for this confusion, GCC issues a warning when this flag
9470is specified. To eliminate the warning, add explicit braces around
9471the innermost @code{if} statement so there is no way the @code{else}
9472can belong to the enclosing @code{if}. The resulting code
9473looks like this:
9474
9475@smallexample
9476@group
9477@{
9478 if (a)
9479 @{
9480 if (b)
9481 foo ();
9482 else
9483 bar ();
9484 @}
9485@}
9486@end group
9487@end smallexample
9488
9489This warning is enabled by @option{-Wparentheses}.
9490
d77de738
ML
9491@opindex Wdangling-pointer
9492@opindex Wno-dangling-pointer
ddf6fe37
AA
9493@item -Wdangling-pointer
9494@itemx -Wdangling-pointer=@var{n}
d77de738
ML
9495Warn about uses of pointers (or C++ references) to objects with automatic
9496storage duration after their lifetime has ended. This includes local
9497variables declared in nested blocks, compound literals and other unnamed
9498temporary objects. In addition, warn about storing the address of such
9499objects in escaped pointers. The warning is enabled at all optimization
9500levels but may yield different results with optimization than without.
9501
9502@table @gcctabopt
9503@item -Wdangling-pointer=1
29f931e3
SL
9504At level 1, the warning diagnoses only unconditional uses of dangling pointers.
9505
9506@item -Wdangling-pointer=2
9507At level 2, in addition to unconditional uses the warning also diagnoses
9508conditional uses of dangling pointers.
9509@end table
9510
9511The short form @option{-Wdangling-pointer} is equivalent to
9512@option{-Wdangling-pointer=2}, while @option{-Wno-dangling-pointer} and
9513@option{-Wdangling-pointer=0} have the same effect of disabling the warnings.
9514@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9515
9516This example triggers the warning at level 1; the address of the unnamed
9517temporary is unconditionally referenced outside of its scope.
9518
d77de738 9519@smallexample
29f931e3 9520char f (char c1, char c2, char c3)
d77de738 9521@{
29f931e3
SL
9522 char *p;
9523 @{
9524 p = (char[]) @{ c1, c2, c3 @};
9525 @}
9526 // warning: using dangling pointer 'p' to an unnamed temporary
9527 return *p;
d77de738
ML
9528@}
9529@end smallexample
29f931e3 9530
d77de738 9531In the following function the store of the address of the local variable
29f931e3
SL
9532@code{x} in the escaped pointer @code{*p} triggers the warning at
9533level 1.
9534
d77de738
ML
9535@smallexample
9536void g (int **p)
9537@{
9538 int x = 7;
29f931e3 9539 // warning: storing the address of local variable 'x' in '*p'
4ace81b6 9540 *p = &x;
d77de738
ML
9541@}
9542@end smallexample
9543
29f931e3
SL
9544In this example, the array @var{a} is out of
9545scope when the pointer @var{s} is used. Since the code that sets @code{s}
9546is conditional, the warning triggers at level 2.
d77de738
ML
9547
9548@smallexample
29f931e3
SL
9549extern void frob (const char *);
9550void h (char *s)
d77de738
ML
9551@{
9552 if (!s)
9553 @{
9554 char a[12] = "tmpname";
9555 s = a;
9556 @}
29f931e3
SL
9557 // warning: dangling pointer 's' to 'a' may be used
9558 frob (s);
d77de738
ML
9559@}
9560@end smallexample
d77de738 9561
d77de738
ML
9562@opindex Wdate-time
9563@opindex Wno-date-time
ddf6fe37 9564@item -Wdate-time
d77de738
ML
9565Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9566are encountered as they might prevent bit-wise-identical reproducible
9567compilations.
9568
d77de738
ML
9569@opindex Wempty-body
9570@opindex Wno-empty-body
ddf6fe37 9571@item -Wempty-body
d77de738
ML
9572Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9573while} statement. This warning is also enabled by @option{-Wextra}.
9574
d77de738
ML
9575@opindex Wendif-labels
9576@opindex Wno-endif-labels
ddf6fe37 9577@item -Wno-endif-labels
d77de738
ML
9578Do not warn about stray tokens after @code{#else} and @code{#endif}.
9579
d77de738
ML
9580@opindex Wenum-compare
9581@opindex Wno-enum-compare
ddf6fe37 9582@item -Wenum-compare
d77de738
ML
9583Warn about a comparison between values of different enumerated types.
9584In C++ enumerated type mismatches in conditional expressions are also
9585diagnosed and the warning is enabled by default. In C this warning is
9586enabled by @option{-Wall}.
9587
d77de738
ML
9588@opindex Wenum-conversion
9589@opindex Wno-enum-conversion
ddf6fe37 9590@item -Wenum-conversion
d77de738
ML
9591Warn when a value of enumerated type is implicitly converted to a
9592different enumerated type. This warning is enabled by @option{-Wextra}
9593in C@.
9594
d77de738
ML
9595@opindex Wenum-int-mismatch
9596@opindex Wno-enum-int-mismatch
ddf6fe37 9597@item -Wenum-int-mismatch @r{(C and Objective-C only)}
d77de738
ML
9598Warn about mismatches between an enumerated type and an integer type in
9599declarations. For example:
9600
9601@smallexample
9602enum E @{ l = -1, z = 0, g = 1 @};
9603int foo(void);
9604enum E foo(void);
9605@end smallexample
9606
9607In C, an enumerated type is compatible with @code{char}, a signed
9608integer type, or an unsigned integer type. However, since the choice
9609of the underlying type of an enumerated type is implementation-defined,
9610such mismatches may cause portability issues. In C++, such mismatches
9611are an error. In C, this warning is enabled by @option{-Wall} and
9612@option{-Wc++-compat}.
9613
d77de738
ML
9614@opindex Wjump-misses-init
9615@opindex Wno-jump-misses-init
ddf6fe37 9616@item -Wjump-misses-init @r{(C, Objective-C only)}
d77de738
ML
9617Warn if a @code{goto} statement or a @code{switch} statement jumps
9618forward across the initialization of a variable, or jumps backward to a
9619label after the variable has been initialized. This only warns about
9620variables that are initialized when they are declared. This warning is
9621only supported for C and Objective-C; in C++ this sort of branch is an
9622error in any case.
9623
9624@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9625can be disabled with the @option{-Wno-jump-misses-init} option.
9626
d77de738
ML
9627@opindex Wsign-compare
9628@opindex Wno-sign-compare
9629@cindex warning for comparison of signed and unsigned values
9630@cindex comparison of signed and unsigned values, warning
9631@cindex signed and unsigned values, comparison warning
f33d7a88 9632@item -Wsign-compare
d77de738
ML
9633Warn when a comparison between signed and unsigned values could produce
9634an incorrect result when the signed value is converted to unsigned.
9635In C++, this warning is also enabled by @option{-Wall}. In C, it is
9636also enabled by @option{-Wextra}.
9637
d77de738
ML
9638@opindex Wsign-conversion
9639@opindex Wno-sign-conversion
ddf6fe37 9640@item -Wsign-conversion
d77de738
ML
9641Warn for implicit conversions that may change the sign of an integer
9642value, like assigning a signed integer expression to an unsigned
9643integer variable. An explicit cast silences the warning. In C, this
9644option is enabled also by @option{-Wconversion}.
9645
44e3f39a
QZ
9646@opindex Wflex-array-member-not-at-end
9647@opindex Wno-flex-array-member-not-at-end
9648@item -Wflex-array-member-not-at-end @r{(C and C++ only)}
9649Warn when a structure containing a C99 flexible array member as the last
9650field is not at the end of another structure.
9651This warning warns e.g. about
9652
9653@smallexample
9654struct flex @{ int length; char data[]; @};
9655struct mid_flex @{ int m; struct flex flex_data; int n; @};
9656@end smallexample
9657
d77de738
ML
9658@opindex Wfloat-conversion
9659@opindex Wno-float-conversion
ddf6fe37 9660@item -Wfloat-conversion
d77de738
ML
9661Warn for implicit conversions that reduce the precision of a real value.
9662This includes conversions from real to integer, and from higher precision
9663real to lower precision real values. This option is also enabled by
9664@option{-Wconversion}.
9665
d77de738
ML
9666@opindex Wno-scalar-storage-order
9667@opindex Wscalar-storage-order
ddf6fe37 9668@item -Wno-scalar-storage-order
d77de738
ML
9669Do not warn on suspicious constructs involving reverse scalar storage order.
9670
d77de738
ML
9671@opindex Wsizeof-array-div
9672@opindex Wno-sizeof-array-div
ddf6fe37 9673@item -Wsizeof-array-div
d77de738
ML
9674Warn about divisions of two sizeof operators when the first one is applied
9675to an array and the divisor does not equal the size of the array element.
9676In such a case, the computation will not yield the number of elements in the
9677array, which is likely what the user intended. This warning warns e.g. about
9678@smallexample
9679int fn ()
9680@{
9681 int arr[10];
9682 return sizeof (arr) / sizeof (short);
9683@}
9684@end smallexample
9685
9686This warning is enabled by @option{-Wall}.
9687
d77de738
ML
9688@opindex Wsizeof-pointer-div
9689@opindex Wno-sizeof-pointer-div
ddf6fe37 9690@item -Wsizeof-pointer-div
d77de738
ML
9691Warn for suspicious divisions of two sizeof expressions that divide
9692the pointer size by the element size, which is the usual way to compute
9693the array size but won't work out correctly with pointers. This warning
9694warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9695not an array, but a pointer. This warning is enabled by @option{-Wall}.
9696
d77de738
ML
9697@opindex Wsizeof-pointer-memaccess
9698@opindex Wno-sizeof-pointer-memaccess
ddf6fe37 9699@item -Wsizeof-pointer-memaccess
d77de738
ML
9700Warn for suspicious length parameters to certain string and memory built-in
9701functions if the argument uses @code{sizeof}. This warning triggers for
9702example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9703an array, but a pointer, and suggests a possible fix, or about
9704@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9705also warns about calls to bounded string copy functions like @code{strncat}
9706or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9707the source array. For example, in the following function the call to
9708@code{strncat} specifies the size of the source string as the bound. That
9709is almost certainly a mistake and so the call is diagnosed.
9710@smallexample
9711void make_file (const char *name)
9712@{
9713 char path[PATH_MAX];
9714 strncpy (path, name, sizeof path - 1);
9715 strncat (path, ".text", sizeof ".text");
9716 @dots{}
9717@}
9718@end smallexample
9719
9720The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9721
d77de738
ML
9722@opindex Wsizeof-array-argument
9723@opindex Wno-sizeof-array-argument
ddf6fe37 9724@item -Wno-sizeof-array-argument
d77de738
ML
9725Do not warn when the @code{sizeof} operator is applied to a parameter that is
9726declared as an array in a function definition. This warning is enabled by
9727default for C and C++ programs.
9728
d77de738
ML
9729@opindex Wmemset-elt-size
9730@opindex Wno-memset-elt-size
ddf6fe37 9731@item -Wmemset-elt-size
d77de738
ML
9732Warn for suspicious calls to the @code{memset} built-in function, if the
9733first argument references an array, and the third argument is a number
9734equal to the number of elements, but not equal to the size of the array
9735in memory. This indicates that the user has omitted a multiplication by
9736the element size. This warning is enabled by @option{-Wall}.
9737
d77de738
ML
9738@opindex Wmemset-transposed-args
9739@opindex Wno-memset-transposed-args
ddf6fe37 9740@item -Wmemset-transposed-args
d77de738
ML
9741Warn for suspicious calls to the @code{memset} built-in function where
9742the second argument is not zero and the third argument is zero. For
9743example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9744@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9745is only emitted if the third argument is a literal zero. Otherwise, if
9746it is an expression that is folded to zero, or a cast of zero to some
9747type, it is far less likely that the arguments have been mistakenly
9748transposed and no warning is emitted. This warning is enabled
9749by @option{-Wall}.
9750
d77de738
ML
9751@opindex Waddress
9752@opindex Wno-address
ddf6fe37 9753@item -Waddress
d77de738
ML
9754Warn about suspicious uses of address expressions. These include comparing
9755the address of a function or a declared object to the null pointer constant
9756such as in
9757@smallexample
9758void f (void);
9759void g (void)
9760@{
9761 if (!f) // warning: expression evaluates to false
9762 abort ();
9763@}
9764@end smallexample
9765comparisons of a pointer to a string literal, such as in
9766@smallexample
9767void f (const char *x)
9768@{
9769 if (x == "abc") // warning: expression evaluates to false
9770 puts ("equal");
9771@}
9772@end smallexample
9773and tests of the results of pointer addition or subtraction for equality
9774to null, such as in
9775@smallexample
9776void f (const int *p, int i)
9777@{
9778 return p + i == NULL;
9779@}
9780@end smallexample
9781Such uses typically indicate a programmer error: the address of most
9782functions and objects necessarily evaluates to true (the exception are
9783weak symbols), so their use in a conditional might indicate missing
9784parentheses in a function call or a missing dereference in an array
9785expression. The subset of the warning for object pointers can be
9786suppressed by casting the pointer operand to an integer type such
9787as @code{intptr_t} or @code{uintptr_t}.
9788Comparisons against string literals result in unspecified behavior
9789and are not portable, and suggest the intent was to call @code{strcmp}.
9790The warning is suppressed if the suspicious expression is the result
9791of macro expansion.
9792@option{-Waddress} warning is enabled by @option{-Wall}.
9793
d77de738
ML
9794@opindex Waddress-of-packed-member
9795@opindex Wno-address-of-packed-member
ddf6fe37 9796@item -Wno-address-of-packed-member
d77de738
ML
9797Do not warn when the address of packed member of struct or union is taken,
9798which usually results in an unaligned pointer value. This is
9799enabled by default.
9800
d77de738
ML
9801@opindex Wlogical-op
9802@opindex Wno-logical-op
ddf6fe37 9803@item -Wlogical-op
d77de738
ML
9804Warn about suspicious uses of logical operators in expressions.
9805This includes using logical operators in contexts where a
9806bit-wise operator is likely to be expected. Also warns when
9807the operands of a logical operator are the same:
9808@smallexample
9809extern int a;
9810if (a < 0 && a < 0) @{ @dots{} @}
9811@end smallexample
9812
d77de738
ML
9813@opindex Wlogical-not-parentheses
9814@opindex Wno-logical-not-parentheses
ddf6fe37 9815@item -Wlogical-not-parentheses
d77de738
ML
9816Warn about logical not used on the left hand side operand of a comparison.
9817This option does not warn if the right operand is considered to be a boolean
9818expression. Its purpose is to detect suspicious code like the following:
9819@smallexample
9820int a;
9821@dots{}
9822if (!a > 1) @{ @dots{} @}
9823@end smallexample
9824
9825It is possible to suppress the warning by wrapping the LHS into
9826parentheses:
9827@smallexample
9828if ((!a) > 1) @{ @dots{} @}
9829@end smallexample
9830
9831This warning is enabled by @option{-Wall}.
9832
d77de738
ML
9833@opindex Waggregate-return
9834@opindex Wno-aggregate-return
ddf6fe37 9835@item -Waggregate-return
d77de738
ML
9836Warn if any functions that return structures or unions are defined or
9837called. (In languages where you can return an array, this also elicits
9838a warning.)
9839
d77de738
ML
9840@opindex Wno-aggressive-loop-optimizations
9841@opindex Waggressive-loop-optimizations
ddf6fe37 9842@item -Wno-aggressive-loop-optimizations
d77de738
ML
9843Warn if in a loop with constant number of iterations the compiler detects
9844undefined behavior in some statement during one or more of the iterations.
9845
d77de738
ML
9846@opindex Wno-attributes
9847@opindex Wattributes
ddf6fe37 9848@item -Wno-attributes
d77de738
ML
9849Do not warn if an unexpected @code{__attribute__} is used, such as
9850unrecognized attributes, function attributes applied to variables,
9851etc. This does not stop errors for incorrect use of supported
9852attributes.
9853
5fccebdb
JM
9854Warnings about ill-formed uses of standard attributes are upgraded to
9855errors by @option{-pedantic-errors}.
9856
d77de738 9857Additionally, using @option{-Wno-attributes=}, it is possible to suppress
094a609c 9858warnings about unknown scoped attributes (in C++11 and C23). For example,
d77de738
ML
9859@option{-Wno-attributes=vendor::attr} disables warning about the following
9860declaration:
9861
9862@smallexample
9863[[vendor::attr]] void f();
9864@end smallexample
9865
9866It is also possible to disable warning about all attributes in a namespace
9867using @option{-Wno-attributes=vendor::} which prevents warning about both
9868of these declarations:
9869
9870@smallexample
9871[[vendor::safe]] void f();
9872[[vendor::unsafe]] void f2();
9873@end smallexample
9874
9875Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9876
d77de738
ML
9877@opindex Wno-builtin-declaration-mismatch
9878@opindex Wbuiltin-declaration-mismatch
ddf6fe37 9879@item -Wno-builtin-declaration-mismatch
d77de738
ML
9880Warn if a built-in function is declared with an incompatible signature
9881or as a non-function, or when a built-in function declared with a type
9882that does not include a prototype is called with arguments whose promoted
9883types do not match those expected by the function. When @option{-Wextra}
9884is specified, also warn when a built-in function that takes arguments is
9885declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9886warning is enabled by default. To avoid the warning include the appropriate
9887header to bring the prototypes of built-in functions into scope.
9888
9889For example, the call to @code{memset} below is diagnosed by the warning
9890because the function expects a value of type @code{size_t} as its argument
9891but the type of @code{32} is @code{int}. With @option{-Wextra},
9892the declaration of the function is diagnosed as well.
9893@smallexample
9894extern void* memset ();
9895void f (void *d)
9896@{
9897 memset (d, '\0', 32);
9898@}
9899@end smallexample
9900
d77de738
ML
9901@opindex Wno-builtin-macro-redefined
9902@opindex Wbuiltin-macro-redefined
ddf6fe37 9903@item -Wno-builtin-macro-redefined
d77de738
ML
9904Do not warn if certain built-in macros are redefined. This suppresses
9905warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9906@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9907
d77de738
ML
9908@opindex Wstrict-prototypes
9909@opindex Wno-strict-prototypes
ddf6fe37 9910@item -Wstrict-prototypes @r{(C and Objective-C only)}
d77de738
ML
9911Warn if a function is declared or defined without specifying the
9912argument types. (An old-style function definition is permitted without
9913a warning if preceded by a declaration that specifies the argument
9914types.)
9915
d77de738
ML
9916@opindex Wold-style-declaration
9917@opindex Wno-old-style-declaration
ddf6fe37 9918@item -Wold-style-declaration @r{(C and Objective-C only)}
d77de738
ML
9919Warn for obsolescent usages, according to the C Standard, in a
9920declaration. For example, warn if storage-class specifiers like
9921@code{static} are not the first things in a declaration. This warning
9922is also enabled by @option{-Wextra}.
9923
d77de738
ML
9924@opindex Wold-style-definition
9925@opindex Wno-old-style-definition
ddf6fe37 9926@item -Wold-style-definition @r{(C and Objective-C only)}
d77de738
ML
9927Warn if an old-style function definition is used. A warning is given
9928even if there is a previous prototype. A definition using @samp{()}
094a609c 9929is not considered an old-style definition in C23 mode, because it is
d77de738
ML
9930equivalent to @samp{(void)} in that case, but is considered an
9931old-style definition for older standards.
9932
d77de738
ML
9933@opindex Wmissing-parameter-type
9934@opindex Wno-missing-parameter-type
ddf6fe37 9935@item -Wmissing-parameter-type @r{(C and Objective-C only)}
d77de738
ML
9936A function parameter is declared without a type specifier in K&R-style
9937functions:
9938
9939@smallexample
9940void foo(bar) @{ @}
9941@end smallexample
9942
9943This warning is also enabled by @option{-Wextra}.
9944
ff9efa3f
FW
9945@opindex Wno-declaration-missing-parameter-type
9946@opindex Wdeclaration-missing-parameter-type
9947@item -Wno-declaration-missing-parameter-type @r{(C and Objective-C only)}
9948Do not warn if a function declaration contains a parameter name without
9949a type. Such function declarations do not provide a function prototype
9950and prevent most type checking in function calls.
9951
9952This warning is enabled by default. In C99 and later dialects of C, it
9953is treated as an error. The error can be downgraded to a warning using
9954@option{-fpermissive} (along with certain other errors), or for this
9955error alone, with @option{-Wno-error=declaration-missing-parameter-type}.
9956
9957This warning is upgraded to an error by @option{-pedantic-errors}.
9958
d77de738
ML
9959@opindex Wmissing-prototypes
9960@opindex Wno-missing-prototypes
ddf6fe37 9961@item -Wmissing-prototypes @r{(C and Objective-C only)}
d77de738
ML
9962Warn if a global function is defined without a previous prototype
9963declaration. This warning is issued even if the definition itself
9964provides a prototype. Use this option to detect global functions
9965that do not have a matching prototype declaration in a header file.
9966This option is not valid for C++ because all function declarations
9967provide prototypes and a non-matching declaration declares an
9968overload rather than conflict with an earlier declaration.
9969Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9970
ffc74822
HM
9971@opindex Wmissing-variable-declarations
9972@opindex Wno-missing-variable-declarations
9973@item -Wmissing-variable-declarations @r{(C and Objective-C only)}
9974Warn if a global variable is defined without a previous declaration.
9975Use this option to detect global variables that do not have a matching
9976extern declaration in a header file.
9977
d77de738
ML
9978@opindex Wmissing-declarations
9979@opindex Wno-missing-declarations
ddf6fe37 9980@item -Wmissing-declarations
d77de738
ML
9981Warn if a global function is defined without a previous declaration.
9982Do so even if the definition itself provides a prototype.
9983Use this option to detect global functions that are not declared in
9984header files. In C, no warnings are issued for functions with previous
9985non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9986missing prototypes. In C++, no warnings are issued for function templates,
9987or for inline functions, or for functions in anonymous namespaces.
9988
d77de738
ML
9989@opindex Wmissing-field-initializers
9990@opindex Wno-missing-field-initializers
9991@opindex W
9992@opindex Wextra
9993@opindex Wno-extra
ddf6fe37 9994@item -Wmissing-field-initializers
d77de738
ML
9995Warn if a structure's initializer has some fields missing. For
9996example, the following code causes such a warning, because
9997@code{x.h} is implicitly zero:
9998
9999@smallexample
10000struct s @{ int f, g, h; @};
10001struct s x = @{ 3, 4 @};
10002@end smallexample
10003
0f8f1dee
MP
10004@c It's unclear if this behavior is desirable. See PR39589 and PR96868.
10005In C this option does not warn about designated initializers, so the
10006following modification does not trigger a warning:
d77de738
ML
10007
10008@smallexample
10009struct s @{ int f, g, h; @};
10010struct s x = @{ .f = 3, .g = 4 @};
10011@end smallexample
10012
10013In C this option does not warn about the universal zero initializer
10014@samp{@{ 0 @}}:
10015
10016@smallexample
10017struct s @{ int f, g, h; @};
10018struct s x = @{ 0 @};
10019@end smallexample
10020
10021Likewise, in C++ this option does not warn about the empty @{ @}
10022initializer, for example:
10023
10024@smallexample
10025struct s @{ int f, g, h; @};
10026s x = @{ @};
10027@end smallexample
10028
10029This warning is included in @option{-Wextra}. To get other @option{-Wextra}
10030warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
10031
d77de738
ML
10032@opindex Wmissing-requires
10033@opindex Wno-missing-requires
ddf6fe37 10034@item -Wno-missing-requires
d77de738
ML
10035
10036By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
10037
10038@smallexample
10039bool satisfied = requires @{ C<T> @};
10040@end smallexample
10041
10042Here @samp{satisfied} will be true if @samp{C<T>} is a valid
10043expression, which it is for all T. Presumably the user meant to write
10044
10045@smallexample
10046bool satisfied = requires @{ requires C<T> @};
10047@end smallexample
10048
10049so @samp{satisfied} is only true if concept @samp{C} is satisfied for
10050type @samp{T}.
10051
10052This warning can be disabled with @option{-Wno-missing-requires}.
10053
d77de738
ML
10054@opindex Wmissing-template-keyword
10055@opindex Wno-missing-template-keyword
ddf6fe37 10056@item -Wno-missing-template-keyword
d77de738
ML
10057
10058The member access tokens ., -> and :: must be followed by the @code{template}
10059keyword if the parent object is dependent and the member being named is a
10060template.
10061
10062@smallexample
10063template <class X>
10064void DoStuff (X x)
10065@{
10066 x.template DoSomeOtherStuff<X>(); // Good.
10067 x.DoMoreStuff<X>(); // Warning, x is dependent.
10068@}
10069@end smallexample
10070
10071In rare cases it is possible to get false positives. To silence this, wrap
10072the expression in parentheses. For example, the following is treated as a
10073template, even where m and N are integers:
10074
10075@smallexample
10076void NotATemplate (my_class t)
10077@{
10078 int N = 5;
10079
10080 bool test = t.m < N > (0); // Treated as a template.
10081 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
10082@}
10083@end smallexample
10084
10085This warning can be disabled with @option{-Wno-missing-template-keyword}.
10086
d77de738
ML
10087@opindex Wno-multichar
10088@opindex Wmultichar
ddf6fe37 10089@item -Wno-multichar
d77de738
ML
10090Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
10091Usually they indicate a typo in the user's code, as they have
10092implementation-defined values, and should not be used in portable code.
10093
d77de738
ML
10094@opindex Wnormalized=
10095@opindex Wnormalized
10096@opindex Wno-normalized
10097@cindex NFC
10098@cindex NFKC
10099@cindex character set, input normalization
f33d7a88 10100@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
d77de738
ML
10101In ISO C and ISO C++, two identifiers are different if they are
10102different sequences of characters. However, sometimes when characters
10103outside the basic ASCII character set are used, you can have two
10104different character sequences that look the same. To avoid confusion,
10105the ISO 10646 standard sets out some @dfn{normalization rules} which
10106when applied ensure that two sequences that look the same are turned into
10107the same sequence. GCC can warn you if you are using identifiers that
10108have not been normalized; this option controls that warning.
10109
10110There are four levels of warning supported by GCC@. The default is
10111@option{-Wnormalized=nfc}, which warns about any identifier that is
10112not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
10113recommended form for most uses. It is equivalent to
10114@option{-Wnormalized}.
10115
10116Unfortunately, there are some characters allowed in identifiers by
10117ISO C and ISO C++ that, when turned into NFC, are not allowed in
10118identifiers. That is, there's no way to use these symbols in portable
10119ISO C or C++ and have all your identifiers in NFC@.
10120@option{-Wnormalized=id} suppresses the warning for these characters.
10121It is hoped that future versions of the standards involved will correct
10122this, which is why this option is not the default.
10123
10124You can switch the warning off for all characters by writing
10125@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
10126only do this if you are using some other normalization scheme (like
10127``D''), because otherwise you can easily create bugs that are
10128literally impossible to see.
10129
10130Some characters in ISO 10646 have distinct meanings but look identical
10131in some fonts or display methodologies, especially once formatting has
10132been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
10133LETTER N'', displays just like a regular @code{n} that has been
10134placed in a superscript. ISO 10646 defines the @dfn{NFKC}
10135normalization scheme to convert all these into a standard form as
10136well, and GCC warns if your code is not in NFKC if you use
10137@option{-Wnormalized=nfkc}. This warning is comparable to warning
10138about every identifier that contains the letter O because it might be
10139confused with the digit 0, and so is not the default, but may be
10140useful as a local coding convention if the programming environment
10141cannot be fixed to display these characters distinctly.
10142
d77de738
ML
10143@opindex Wno-attribute-warning
10144@opindex Wattribute-warning
ddf6fe37 10145@item -Wno-attribute-warning
d77de738
ML
10146Do not warn about usage of functions (@pxref{Function Attributes})
10147declared with @code{warning} attribute. By default, this warning is
10148enabled. @option{-Wno-attribute-warning} can be used to disable the
10149warning or @option{-Wno-error=attribute-warning} can be used to
10150disable the error when compiled with @option{-Werror} flag.
10151
d77de738
ML
10152@opindex Wno-deprecated
10153@opindex Wdeprecated
ddf6fe37 10154@item -Wno-deprecated
d77de738
ML
10155Do not warn about usage of deprecated features. @xref{Deprecated Features}.
10156
d77de738
ML
10157@opindex Wno-deprecated-declarations
10158@opindex Wdeprecated-declarations
ddf6fe37 10159@item -Wno-deprecated-declarations
d77de738
ML
10160Do not warn about uses of functions (@pxref{Function Attributes}),
10161variables (@pxref{Variable Attributes}), and types (@pxref{Type
10162Attributes}) marked as deprecated by using the @code{deprecated}
10163attribute.
10164
d77de738
ML
10165@opindex Wno-overflow
10166@opindex Woverflow
ddf6fe37 10167@item -Wno-overflow
d77de738
ML
10168Do not warn about compile-time overflow in constant expressions.
10169
d77de738
ML
10170@opindex Wno-odr
10171@opindex Wodr
ddf6fe37 10172@item -Wno-odr
d77de738
ML
10173Warn about One Definition Rule violations during link-time optimization.
10174Enabled by default.
10175
d77de738
ML
10176@opindex Wopenacc-parallelism
10177@opindex Wno-openacc-parallelism
10178@cindex OpenACC accelerator programming
f33d7a88 10179@item -Wopenacc-parallelism
d77de738
ML
10180Warn about potentially suboptimal choices related to OpenACC parallelism.
10181
449b6b81
TB
10182@opindex Wopenmp
10183@opindex Wno-openmp
10184@item -Wno-openmp
10185Warn about suspicious OpenMP code.
10186
d77de738
ML
10187@opindex Wopenmp-simd
10188@opindex Wno-openmp-simd
ddf6fe37 10189@item -Wopenmp-simd
d77de738
ML
10190Warn if the vectorizer cost model overrides the OpenMP
10191simd directive set by user. The @option{-fsimd-cost-model=unlimited}
10192option can be used to relax the cost model.
10193
d77de738
ML
10194@opindex Woverride-init
10195@opindex Wno-override-init
10196@opindex W
10197@opindex Wextra
10198@opindex Wno-extra
ddf6fe37 10199@item -Woverride-init @r{(C and Objective-C only)}
d77de738
ML
10200Warn if an initialized field without side effects is overridden when
10201using designated initializers (@pxref{Designated Inits, , Designated
10202Initializers}).
10203
10204This warning is included in @option{-Wextra}. To get other
10205@option{-Wextra} warnings without this one, use @option{-Wextra
10206-Wno-override-init}.
10207
d77de738
ML
10208@opindex Woverride-init-side-effects
10209@opindex Wno-override-init-side-effects
ddf6fe37 10210@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
d77de738
ML
10211Do not warn if an initialized field with side effects is overridden when
10212using designated initializers (@pxref{Designated Inits, , Designated
10213Initializers}). This warning is enabled by default.
10214
d77de738
ML
10215@opindex Wpacked
10216@opindex Wno-packed
ddf6fe37 10217@item -Wpacked
d77de738
ML
10218Warn if a structure is given the packed attribute, but the packed
10219attribute has no effect on the layout or size of the structure.
10220Such structures may be mis-aligned for little benefit. For
10221instance, in this code, the variable @code{f.x} in @code{struct bar}
10222is misaligned even though @code{struct bar} does not itself
10223have the packed attribute:
10224
10225@smallexample
10226@group
10227struct foo @{
10228 int x;
10229 char a, b, c, d;
10230@} __attribute__((packed));
10231struct bar @{
10232 char z;
10233 struct foo f;
10234@};
10235@end group
10236@end smallexample
10237
d77de738
ML
10238@opindex Wpacked-bitfield-compat
10239@opindex Wno-packed-bitfield-compat
ddf6fe37 10240@item -Wnopacked-bitfield-compat
d77de738
ML
10241The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
10242on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
10243the change can lead to differences in the structure layout. GCC
10244informs you when the offset of such a field has changed in GCC 4.4.
10245For example there is no longer a 4-bit padding between field @code{a}
10246and @code{b} in this structure:
10247
10248@smallexample
10249struct foo
10250@{
10251 char a:4;
10252 char b:8;
10253@} __attribute__ ((packed));
10254@end smallexample
10255
10256This warning is enabled by default. Use
10257@option{-Wno-packed-bitfield-compat} to disable this warning.
10258
d77de738
ML
10259@opindex Wpacked-not-aligned
10260@opindex Wno-packed-not-aligned
ddf6fe37 10261@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
10262Warn if a structure field with explicitly specified alignment in a
10263packed struct or union is misaligned. For example, a warning will
10264be issued on @code{struct S}, like, @code{warning: alignment 1 of
10265'struct S' is less than 8}, in this code:
10266
10267@smallexample
10268@group
10269struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
10270struct __attribute__ ((packed)) S @{
10271 struct S8 s8;
10272@};
10273@end group
10274@end smallexample
10275
10276This warning is enabled by @option{-Wall}.
10277
d77de738
ML
10278@opindex Wpadded
10279@opindex Wno-padded
ddf6fe37 10280@item -Wpadded
d77de738
ML
10281Warn if padding is included in a structure, either to align an element
10282of the structure or to align the whole structure. Sometimes when this
10283happens it is possible to rearrange the fields of the structure to
10284reduce the padding and so make the structure smaller.
10285
d77de738
ML
10286@opindex Wredundant-decls
10287@opindex Wno-redundant-decls
ddf6fe37 10288@item -Wredundant-decls
d77de738
ML
10289Warn if anything is declared more than once in the same scope, even in
10290cases where multiple declaration is valid and changes nothing.
10291
d77de738
ML
10292@opindex Wrestrict
10293@opindex Wno-restrict
ddf6fe37 10294@item -Wrestrict
d77de738
ML
10295Warn when an object referenced by a @code{restrict}-qualified parameter
10296(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
10297argument, or when copies between such objects overlap. For example,
10298the call to the @code{strcpy} function below attempts to truncate the string
10299by replacing its initial characters with the last four. However, because
10300the call writes the terminating NUL into @code{a[4]}, the copies overlap and
10301the call is diagnosed.
10302
10303@smallexample
10304void foo (void)
10305@{
10306 char a[] = "abcd1234";
10307 strcpy (a, a + 4);
10308 @dots{}
10309@}
10310@end smallexample
10311The @option{-Wrestrict} option detects some instances of simple overlap
10312even without optimization but works best at @option{-O2} and above. It
10313is included in @option{-Wall}.
10314
d77de738
ML
10315@opindex Wnested-externs
10316@opindex Wno-nested-externs
ddf6fe37 10317@item -Wnested-externs @r{(C and Objective-C only)}
d77de738
ML
10318Warn if an @code{extern} declaration is encountered within a function.
10319
d77de738
ML
10320@opindex Winline
10321@opindex Wno-inline
ddf6fe37 10322@item -Winline
d77de738
ML
10323Warn if a function that is declared as inline cannot be inlined.
10324Even with this option, the compiler does not warn about failures to
10325inline functions declared in system headers.
10326
10327The compiler uses a variety of heuristics to determine whether or not
10328to inline a function. For example, the compiler takes into account
10329the size of the function being inlined and the amount of inlining
10330that has already been done in the current function. Therefore,
10331seemingly insignificant changes in the source program can cause the
10332warnings produced by @option{-Winline} to appear or disappear.
10333
d77de738 10334@opindex Winterference-size
ddf6fe37 10335@item -Winterference-size
d77de738
ML
10336Warn about use of C++17 @code{std::hardware_destructive_interference_size}
10337without specifying its value with @option{--param destructive-interference-size}.
10338Also warn about questionable values for that option.
10339
10340This variable is intended to be used for controlling class layout, to
10341avoid false sharing in concurrent code:
10342
10343@smallexample
10344struct independent_fields @{
4ace81b6
SL
10345 alignas(std::hardware_destructive_interference_size)
10346 std::atomic<int> one;
10347 alignas(std::hardware_destructive_interference_size)
10348 std::atomic<int> two;
d77de738
ML
10349@};
10350@end smallexample
10351
10352Here @samp{one} and @samp{two} are intended to be far enough apart
10353that stores to one won't require accesses to the other to reload the
10354cache line.
10355
10356By default, @option{--param destructive-interference-size} and
10357@option{--param constructive-interference-size} are set based on the
10358current @option{-mtune} option, typically to the L1 cache line size
10359for the particular target CPU, sometimes to a range if tuning for a
10360generic target. So all translation units that depend on ABI
10361compatibility for the use of these variables must be compiled with
10362the same @option{-mtune} (or @option{-mcpu}).
10363
10364If ABI stability is important, such as if the use is in a header for a
10365library, you should probably not use the hardware interference size
10366variables at all. Alternatively, you can force a particular value
10367with @option{--param}.
10368
10369If you are confident that your use of the variable does not affect ABI
10370outside a single build of your project, you can turn off the warning
10371with @option{-Wno-interference-size}.
10372
d77de738
ML
10373@opindex Wint-in-bool-context
10374@opindex Wno-int-in-bool-context
ddf6fe37 10375@item -Wint-in-bool-context
d77de738
ML
10376Warn for suspicious use of integer values where boolean values are expected,
10377such as conditional expressions (?:) using non-boolean integer constants in
10378boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
10379integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
10380for all kinds of multiplications regardless of the data type.
10381This warning is enabled by @option{-Wall}.
10382
d77de738
ML
10383@opindex Wno-int-to-pointer-cast
10384@opindex Wint-to-pointer-cast
ddf6fe37 10385@item -Wno-int-to-pointer-cast
d77de738
ML
10386Suppress warnings from casts to pointer type of an integer of a
10387different size. In C++, casting to a pointer type of smaller size is
10388an error. @option{Wint-to-pointer-cast} is enabled by default.
10389
10390
d77de738
ML
10391@opindex Wno-pointer-to-int-cast
10392@opindex Wpointer-to-int-cast
ddf6fe37 10393@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
d77de738
ML
10394Suppress warnings from casts from a pointer to an integer type of a
10395different size.
10396
d77de738
ML
10397@opindex Winvalid-pch
10398@opindex Wno-invalid-pch
ddf6fe37 10399@item -Winvalid-pch
d77de738
ML
10400Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
10401the search path but cannot be used.
10402
d77de738
ML
10403@opindex Winvalid-utf8
10404@opindex Wno-invalid-utf8
ddf6fe37 10405@item -Winvalid-utf8
d77de738
ML
10406Warn if an invalid UTF-8 character is found.
10407This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
10408is used and turned into error with @option{-pedantic-errors}.
10409
d77de738
ML
10410@opindex Wunicode
10411@opindex Wno-unicode
ddf6fe37 10412@item -Wno-unicode
d77de738
ML
10413Don't diagnose invalid forms of delimited or named escape sequences which are
10414treated as separate tokens. @option{Wunicode} is enabled by default.
10415
d77de738
ML
10416@opindex Wlong-long
10417@opindex Wno-long-long
ddf6fe37 10418@item -Wlong-long
d77de738
ML
10419Warn if @code{long long} type is used. This is enabled by either
10420@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
10421modes. To inhibit the warning messages, use @option{-Wno-long-long}.
10422
5fccebdb
JM
10423This warning is upgraded to an error by @option{-pedantic-errors}.
10424
d77de738
ML
10425@opindex Wvariadic-macros
10426@opindex Wno-variadic-macros
ddf6fe37 10427@item -Wvariadic-macros
d77de738
ML
10428Warn if variadic macros are used in ISO C90 mode, or if the GNU
10429alternate syntax is used in ISO C99 mode. This is enabled by either
10430@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
10431messages, use @option{-Wno-variadic-macros}.
10432
d77de738
ML
10433@opindex Wvarargs
10434@opindex Wno-varargs
ddf6fe37 10435@item -Wno-varargs
d77de738
ML
10436Do not warn upon questionable usage of the macros used to handle variable
10437arguments like @code{va_start}. These warnings are enabled by default.
10438
d77de738
ML
10439@opindex Wvector-operation-performance
10440@opindex Wno-vector-operation-performance
ddf6fe37 10441@item -Wvector-operation-performance
d77de738
ML
10442Warn if vector operation is not implemented via SIMD capabilities of the
10443architecture. Mainly useful for the performance tuning.
10444Vector operation can be implemented @code{piecewise}, which means that the
10445scalar operation is performed on every vector element;
10446@code{in parallel}, which means that the vector operation is implemented
10447using scalars of wider type, which normally is more performance efficient;
10448and @code{as a single scalar}, which means that vector fits into a
10449scalar type.
10450
d77de738
ML
10451@opindex Wvla
10452@opindex Wno-vla
ddf6fe37 10453@item -Wvla
d77de738
ML
10454Warn if a variable-length array is used in the code.
10455@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
10456the variable-length array.
10457
5fccebdb
JM
10458This warning is upgraded to an error by @option{-pedantic-errors}.
10459
d77de738
ML
10460@opindex Wvla-larger-than=
10461@opindex Wno-vla-larger-than
ddf6fe37 10462@item -Wvla-larger-than=@var{byte-size}
d77de738
ML
10463If this option is used, the compiler warns for declarations of
10464variable-length arrays whose size is either unbounded, or bounded
10465by an argument that allows the array size to exceed @var{byte-size}
10466bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
10467works, but with variable-length arrays.
10468
10469Note that GCC may optimize small variable-length arrays of a known
10470value into plain arrays, so this warning may not get triggered for
10471such arrays.
10472
10473@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
10474is typically only effective when @option{-ftree-vrp} is active (default
10475for @option{-O2} and above).
10476
10477See also @option{-Walloca-larger-than=@var{byte-size}}.
10478
d77de738 10479@opindex Wno-vla-larger-than
ddf6fe37 10480@item -Wno-vla-larger-than
d77de738
ML
10481Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
10482to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
10483
d77de738 10484@opindex Wno-vla-parameter
ddf6fe37 10485@item -Wvla-parameter
d77de738
ML
10486Warn about redeclarations of functions involving arguments of Variable
10487Length Array types of inconsistent kinds or forms, and enable the detection
10488of out-of-bounds accesses to such parameters by warnings such as
10489@option{-Warray-bounds}.
10490
10491If the first function declaration uses the VLA form the bound specified
10492in the array is assumed to be the minimum number of elements expected to
10493be provided in calls to the function and the maximum number of elements
10494accessed by it. Failing to provide arguments of sufficient size or
10495accessing more than the maximum number of elements may be diagnosed.
10496
10497For example, the warning triggers for the following redeclarations because
10498the first one allows an array of any size to be passed to @code{f} while
10499the second one specifies that the array argument must have at least @code{n}
10500elements. In addition, calling @code{f} with the associated VLA bound
10501parameter in excess of the actual VLA bound triggers a warning as well.
10502
10503@smallexample
10504void f (int n, int[n]);
4ace81b6
SL
10505// warning: argument 2 previously declared as a VLA
10506void f (int, int[]);
d77de738
ML
10507
10508void g (int n)
10509@{
10510 if (n > 4)
10511 return;
10512 int a[n];
4ace81b6
SL
10513 // warning: access to a by f may be out of bounds
10514 f (sizeof a, a);
d77de738
ML
10515 @dots{}
10516@}
10517
10518@end smallexample
10519
10520@option{-Wvla-parameter} is included in @option{-Wall}. The
10521@option{-Warray-parameter} option triggers warnings for similar problems
10522involving ordinary array arguments.
10523
d77de738
ML
10524@opindex Wvolatile-register-var
10525@opindex Wno-volatile-register-var
ddf6fe37 10526@item -Wvolatile-register-var
d77de738
ML
10527Warn if a register variable is declared volatile. The volatile
10528modifier does not inhibit all optimizations that may eliminate reads
10529and/or writes to register variables. This warning is enabled by
10530@option{-Wall}.
10531
d77de738
ML
10532@opindex Wxor-used-as-pow
10533@opindex Wno-xor-used-as-pow
9a5e8f9d
SL
10534@item -Wno-xor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
10535Disable warnings about uses of @code{^}, the exclusive or operator,
10536where it appears the code meant exponentiation.
10537Specifically, the warning occurs when the
d77de738
ML
10538left-hand side is the decimal constant 2 or 10 and the right-hand side
10539is also a decimal constant.
10540
10541In C and C++, @code{^} means exclusive or, whereas in some other languages
10542(e.g. TeX and some versions of BASIC) it means exponentiation.
10543
9a5e8f9d
SL
10544This warning can be silenced by converting one of the operands to
10545hexadecimal as well as by compiling with @option{-Wno-xor-used-as-pow}.
d77de738 10546
d77de738
ML
10547@opindex Wdisabled-optimization
10548@opindex Wno-disabled-optimization
ddf6fe37 10549@item -Wdisabled-optimization
d77de738
ML
10550Warn if a requested optimization pass is disabled. This warning does
10551not generally indicate that there is anything wrong with your code; it
10552merely indicates that GCC's optimizers are unable to handle the code
10553effectively. Often, the problem is that your code is too big or too
10554complex; GCC refuses to optimize programs when the optimization
10555itself is likely to take inordinate amounts of time.
10556
d77de738
ML
10557@opindex Wpointer-sign
10558@opindex Wno-pointer-sign
ddf6fe37 10559@item -Wpointer-sign @r{(C and Objective-C only)}
d77de738
ML
10560Warn for pointer argument passing or assignment with different signedness.
10561This option is only supported for C and Objective-C@. It is implied by
10562@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10563@option{-Wno-pointer-sign}.
10564
5fccebdb
JM
10565This warning is upgraded to an error by @option{-pedantic-errors}.
10566
d77de738
ML
10567@opindex Wstack-protector
10568@opindex Wno-stack-protector
ddf6fe37 10569@item -Wstack-protector
d77de738
ML
10570This option is only active when @option{-fstack-protector} is active. It
10571warns about functions that are not protected against stack smashing.
10572
d77de738
ML
10573@opindex Woverlength-strings
10574@opindex Wno-overlength-strings
ddf6fe37 10575@item -Woverlength-strings
d77de738
ML
10576Warn about string constants that are longer than the ``minimum
10577maximum'' length specified in the C standard. Modern compilers
10578generally allow string constants that are much longer than the
10579standard's minimum limit, but very portable programs should avoid
10580using longer strings.
10581
10582The limit applies @emph{after} string constant concatenation, and does
10583not count the trailing NUL@. In C90, the limit was 509 characters; in
10584C99, it was raised to 4095. C++98 does not specify a normative
10585minimum maximum, so we do not diagnose overlength strings in C++@.
10586
10587This option is implied by @option{-Wpedantic}, and can be disabled with
10588@option{-Wno-overlength-strings}.
10589
d77de738
ML
10590@opindex Wunsuffixed-float-constants
10591@opindex Wno-unsuffixed-float-constants
ddf6fe37 10592@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
d77de738
ML
10593
10594Issue a warning for any floating constant that does not have
10595a suffix. When used together with @option{-Wsystem-headers} it
10596warns about such constants in system header files. This can be useful
10597when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10598from the decimal floating-point extension to C99.
10599
d77de738
ML
10600@opindex Wlto-type-mismatch
10601@opindex Wno-lto-type-mismatch
ddf6fe37 10602@item -Wno-lto-type-mismatch
d77de738
ML
10603
10604During the link-time optimization, do not warn about type mismatches in
10605global declarations from different compilation units.
10606Requires @option{-flto} to be enabled. Enabled by default.
10607
d77de738
ML
10608@opindex Wdesignated-init
10609@opindex Wno-designated-init
ddf6fe37 10610@item -Wno-designated-init @r{(C and Objective-C only)}
d77de738
ML
10611Suppress warnings when a positional initializer is used to initialize
10612a structure that has been marked with the @code{designated_init}
10613attribute.
10614
10615@end table
10616
10617@node Static Analyzer Options
10618@section Options That Control Static Analysis
10619
10620@table @gcctabopt
d77de738
ML
10621@opindex analyzer
10622@opindex fanalyzer
10623@opindex fno-analyzer
ddf6fe37 10624@item -fanalyzer
d77de738
ML
10625This option enables an static analysis of program flow which looks
10626for ``interesting'' interprocedural paths through the
10627code, and issues warnings for problems found on them.
10628
10629This analysis is much more expensive than other GCC warnings.
10630
a90316c6
DM
10631In technical terms, it performs coverage-guided symbolic execution of
10632the code being compiled. It is neither sound nor complete: it can
10633have false positives and false negatives. It is a bug-finding tool,
10634rather than a tool for proving program correctness.
10635
10636The analyzer is only suitable for use on C code in this release.
10637
d77de738
ML
10638Enabling this option effectively enables the following warnings:
10639
43b72ede
AA
10640@gccoptlist{
10641-Wanalyzer-allocation-size
10642-Wanalyzer-deref-before-check
10643-Wanalyzer-double-fclose
10644-Wanalyzer-double-free
10645-Wanalyzer-exposure-through-output-file
10646-Wanalyzer-exposure-through-uninit-copy
10647-Wanalyzer-fd-access-mode-mismatch
10648-Wanalyzer-fd-double-close
10649-Wanalyzer-fd-leak
10650-Wanalyzer-fd-phase-mismatch
10651-Wanalyzer-fd-type-mismatch
10652-Wanalyzer-fd-use-after-close
10653-Wanalyzer-fd-use-without-check
10654-Wanalyzer-file-leak
10655-Wanalyzer-free-of-non-heap
10656-Wanalyzer-imprecise-fp-arithmetic
841008d3 10657-Wanalyzer-infinite-loop
43b72ede
AA
10658-Wanalyzer-infinite-recursion
10659-Wanalyzer-jump-through-null
10660-Wanalyzer-malloc-leak
10661-Wanalyzer-mismatching-deallocation
10662-Wanalyzer-null-argument
10663-Wanalyzer-null-dereference
10664-Wanalyzer-out-of-bounds
034d99e8 10665-Wanalyzer-overlapping-buffers
43b72ede
AA
10666-Wanalyzer-possible-null-argument
10667-Wanalyzer-possible-null-dereference
10668-Wanalyzer-putenv-of-auto-var
10669-Wanalyzer-shift-count-negative
10670-Wanalyzer-shift-count-overflow
10671-Wanalyzer-stale-setjmp-buffer
cfaaa8b1
DM
10672-Wanalyzer-tainted-allocation-size
10673-Wanalyzer-tainted-array-index
10674-Wanalyzer-tainted-assertion
10675-Wanalyzer-tainted-divisor
10676-Wanalyzer-tainted-offset
10677-Wanalyzer-tainted-size
f65f63c4 10678-Wanalyzer-undefined-behavior-strtok
43b72ede
AA
10679-Wanalyzer-unsafe-call-within-signal-handler
10680-Wanalyzer-use-after-free
10681-Wanalyzer-use-of-pointer-in-stale-stack-frame
10682-Wanalyzer-use-of-uninitialized-value
10683-Wanalyzer-va-arg-type-mismatch
10684-Wanalyzer-va-list-exhausted
10685-Wanalyzer-va-list-leak
10686-Wanalyzer-va-list-use-after-va-end
10687-Wanalyzer-write-to-const
10688-Wanalyzer-write-to-string-literal
d77de738 10689}
d77de738
ML
10690
10691This option is only available if GCC was configured with analyzer
10692support enabled.
10693
08b7462d
DM
10694@opindex Wanalyzer-symbol-too-complex
10695@opindex Wno-analyzer-symbol-too-complex
10696@item -Wanalyzer-symbol-too-complex
10697If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10698to attempt to track the state of memory, but these can be defeated by
10699sufficiently complicated code.
10700
10701By default, the analysis silently stops tracking values of expressions
10702if they exceed the threshold defined by
10703@option{--param analyzer-max-svalue-depth=@var{value}}, and falls back
10704to an imprecise representation for such expressions.
10705The @option{-Wanalyzer-symbol-too-complex} option warns if this occurs.
10706
d77de738
ML
10707@opindex Wanalyzer-too-complex
10708@opindex Wno-analyzer-too-complex
ddf6fe37 10709@item -Wanalyzer-too-complex
d77de738
ML
10710If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10711to attempt to explore the control flow and data flow in the program,
10712but these can be defeated by sufficiently complicated code.
10713
10714By default, the analysis silently stops if the code is too
10715complicated for the analyzer to fully explore and it reaches an internal
10716limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10717
d77de738
ML
10718@opindex Wanalyzer-allocation-size
10719@opindex Wno-analyzer-allocation-size
ddf6fe37 10720@item -Wno-analyzer-allocation-size
4ace81b6
SL
10721This warning requires @option{-fanalyzer}, which enables it;
10722to disable it, use @option{-Wno-analyzer-allocation-size}.
d77de738
ML
10723
10724This diagnostic warns for paths through the code in which a pointer to
10725a buffer is assigned to point at a buffer with a size that is not a
10726multiple of @code{sizeof (*pointer)}.
10727
10728See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10729
ce51e843
ML
10730@opindex Wanalyzer-deref-before-check
10731@opindex Wno-analyzer-deref-before-check
ddf6fe37 10732@item -Wno-analyzer-deref-before-check
ce51e843
ML
10733This warning requires @option{-fanalyzer}, which enables it; use
10734@option{-Wno-analyzer-deref-before-check}
10735to disable it.
10736
10737This diagnostic warns for paths through the code in which a pointer
10738is checked for @code{NULL} *after* it has already been
10739dereferenced, suggesting that the pointer could have been NULL.
10740Such cases suggest that the check for NULL is either redundant,
10741or that it needs to be moved to before the pointer is dereferenced.
10742
10743This diagnostic also considers values passed to a function argument
10744marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10745value, and thus will complain if such values are checked for @code{NULL}
10746after returning from such a function call.
10747
10748This diagnostic is unlikely to be reported when any level of optimization
10749is enabled, as GCC's optimization logic will typically consider such
10750checks for NULL as being redundant, and optimize them away before the
10751analyzer "sees" them. Hence optimization should be disabled when
10752attempting to trigger this diagnostic.
10753
d77de738
ML
10754@opindex Wanalyzer-double-fclose
10755@opindex Wno-analyzer-double-fclose
ddf6fe37 10756@item -Wno-analyzer-double-fclose
d77de738
ML
10757This warning requires @option{-fanalyzer}, which enables it; use
10758@option{-Wno-analyzer-double-fclose} to disable it.
10759
10760This diagnostic warns for paths through the code in which a @code{FILE *}
10761can have @code{fclose} called on it more than once.
10762
10763See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10764
d77de738
ML
10765@opindex Wanalyzer-double-free
10766@opindex Wno-analyzer-double-free
ddf6fe37 10767@item -Wno-analyzer-double-free
d77de738
ML
10768This warning requires @option{-fanalyzer}, which enables it; use
10769@option{-Wno-analyzer-double-free} to disable it.
10770
10771This diagnostic warns for paths through the code in which a pointer
10772can have a deallocator called on it more than once, either @code{free},
10773or a deallocator referenced by attribute @code{malloc}.
10774
10775See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10776
d77de738
ML
10777@opindex Wanalyzer-exposure-through-output-file
10778@opindex Wno-analyzer-exposure-through-output-file
ddf6fe37 10779@item -Wno-analyzer-exposure-through-output-file
d77de738
ML
10780This warning requires @option{-fanalyzer}, which enables it; use
10781@option{-Wno-analyzer-exposure-through-output-file}
10782to disable it.
10783
10784This diagnostic warns for paths through the code in which a
10785security-sensitive value is written to an output file
10786(such as writing a password to a log file).
10787
10788See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10789
d77de738
ML
10790@opindex Wanalyzer-exposure-through-uninit-copy
10791@opindex Wno-analyzer-exposure-through-uninit-copy
ddf6fe37 10792@item -Wanalyzer-exposure-through-uninit-copy
d77de738
ML
10793This warning requires both @option{-fanalyzer} and the use of a plugin
10794to specify a function that copies across a ``trust boundary''. Use
10795@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10796
10797This diagnostic warns for ``infoleaks'' - paths through the code in which
10798uninitialized values are copied across a security boundary
10799(such as code within an OS kernel that copies a partially-initialized
10800struct on the stack to user space).
10801
10802See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10803
d77de738
ML
10804@opindex Wanalyzer-fd-access-mode-mismatch
10805@opindex Wno-analyzer-fd-access-mode-mismatch
ddf6fe37 10806@item -Wno-analyzer-fd-access-mode-mismatch
d77de738
ML
10807This warning requires @option{-fanalyzer}, which enables it; use
10808@option{-Wno-analyzer-fd-access-mode-mismatch}
10809to disable it.
10810
10811This diagnostic warns for paths through code in which a
10812@code{read} on a write-only file descriptor is attempted, or vice versa.
10813
10814This diagnostic also warns for code paths in a which a function with attribute
10815@code{fd_arg_read (N)} is called with a file descriptor opened with
10816@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10817@code{fd_arg_write (N)} is called with a file descriptor opened with
10818@code{O_RDONLY} at referenced argument @var{N}.
10819
d77de738
ML
10820@opindex Wanalyzer-fd-double-close
10821@opindex Wno-analyzer-fd-double-close
ddf6fe37 10822@item -Wno-analyzer-fd-double-close
d77de738
ML
10823This warning requires @option{-fanalyzer}, which enables it; use
10824@option{-Wno-analyzer-fd-double-close}
10825to disable it.
10826
10827This diagnostic warns for paths through code in which a
10828file descriptor can be closed more than once.
10829
10830See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10831
d77de738
ML
10832@opindex Wanalyzer-fd-leak
10833@opindex Wno-analyzer-fd-leak
ddf6fe37 10834@item -Wno-analyzer-fd-leak
d77de738
ML
10835This warning requires @option{-fanalyzer}, which enables it; use
10836@option{-Wno-analyzer-fd-leak}
10837to disable it.
10838
10839This diagnostic warns for paths through code in which an
10840open file descriptor is leaked.
10841
10842See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10843
86a90006
DM
10844@opindex Wanalyzer-fd-phase-mismatch
10845@opindex Wno-analyzer-fd-phase-mismatch
ddf6fe37 10846@item -Wno-analyzer-fd-phase-mismatch
86a90006
DM
10847This warning requires @option{-fanalyzer}, which enables it; use
10848@option{-Wno-analyzer-fd-phase-mismatch}
10849to disable it.
10850
10851This diagnostic warns for paths through code in which an operation is
10852attempted in the wrong phase of a file descriptor's lifetime.
10853For example, it will warn on attempts to call @code{accept} on a stream
10854socket that has not yet had @code{listen} successfully called on it.
10855
10856See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10857
86a90006
DM
10858@opindex Wanalyzer-fd-type-mismatch
10859@opindex Wno-analyzer-fd-type-mismatch
ddf6fe37 10860@item -Wno-analyzer-fd-type-mismatch
86a90006
DM
10861This warning requires @option{-fanalyzer}, which enables it; use
10862@option{-Wno-analyzer-fd-type-mismatch}
10863to disable it.
10864
10865This diagnostic warns for paths through code in which an
10866operation is attempted on the wrong type of file descriptor.
10867For example, it will warn on attempts to use socket operations
10868on a file descriptor obtained via @code{open}, or when attempting
10869to use a stream socket operation on a datagram socket.
10870
d77de738
ML
10871@opindex Wanalyzer-fd-use-after-close
10872@opindex Wno-analyzer-fd-use-after-close
ddf6fe37 10873@item -Wno-analyzer-fd-use-after-close
d77de738
ML
10874This warning requires @option{-fanalyzer}, which enables it; use
10875@option{-Wno-analyzer-fd-use-after-close}
10876to disable it.
10877
10878This diagnostic warns for paths through code in which a
10879read or write is called on a closed file descriptor.
10880
10881This diagnostic also warns for paths through code in which
10882a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10883or @code{fd_arg_write (N)} is called with a closed file descriptor at
10884referenced argument @code{N}.
10885
d77de738
ML
10886@opindex Wanalyzer-fd-use-without-check
10887@opindex Wno-analyzer-fd-use-without-check
ddf6fe37 10888@item -Wno-analyzer-fd-use-without-check
d77de738
ML
10889This warning requires @option{-fanalyzer}, which enables it; use
10890@option{-Wno-analyzer-fd-use-without-check}
10891to disable it.
10892
10893This diagnostic warns for paths through code in which a
10894file descriptor is used without being checked for validity.
10895
10896This diagnostic also warns for paths through code in which
10897a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10898or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10899argument @code{N}, without being checked for validity.
10900
d77de738
ML
10901@opindex Wanalyzer-file-leak
10902@opindex Wno-analyzer-file-leak
ddf6fe37 10903@item -Wno-analyzer-file-leak
d77de738
ML
10904This warning requires @option{-fanalyzer}, which enables it; use
10905@option{-Wno-analyzer-file-leak}
10906to disable it.
10907
10908This diagnostic warns for paths through the code in which a
10909@code{<stdio.h>} @code{FILE *} stream object is leaked.
10910
10911See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10912
d77de738
ML
10913@opindex Wanalyzer-free-of-non-heap
10914@opindex Wno-analyzer-free-of-non-heap
ddf6fe37 10915@item -Wno-analyzer-free-of-non-heap
d77de738
ML
10916This warning requires @option{-fanalyzer}, which enables it; use
10917@option{-Wno-analyzer-free-of-non-heap}
10918to disable it.
10919
10920This diagnostic warns for paths through the code in which @code{free}
10921is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10922
10923See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10924
d77de738
ML
10925@opindex Wanalyzer-imprecise-fp-arithmetic
10926@opindex Wno-analyzer-imprecise-fp-arithmetic
ddf6fe37 10927@item -Wno-analyzer-imprecise-fp-arithmetic
d77de738
ML
10928This warning requires @option{-fanalyzer}, which enables it; use
10929@option{-Wno-analyzer-imprecise-fp-arithmetic}
10930to disable it.
10931
10932This diagnostic warns for paths through the code in which floating-point
10933arithmetic is used in locations where precise computation is needed. This
10934diagnostic only warns on use of floating-point operands inside the
10935calculation of an allocation size at the moment.
10936
841008d3
DM
10937@opindex Wanalyzer-infinite-loop
10938@opindex Wno-analyzer-infinite-loop
10939@item -Wno-analyzer-infinite-loop
10940This warning requires @option{-fanalyzer}, which enables it; use
10941@option{-Wno-analyzer-infinite-loop} to disable it.
10942
10943This diagnostics warns for paths through the code which appear to
10944lead to an infinite loop.
10945
10946Specifically, the analyzer will issue this warning when it "sees" a loop
10947in which:
10948@itemize @bullet
10949@item
10950no externally-visible work could be being done within the loop
10951@item
10952there is no way to escape from the loop
10953@item
10954the analyzer is sufficiently confident about the program state
10955throughout the loop to know that the above are true
10956@end itemize
10957
10958One way for this warning to be emitted is when there is an execution
10959path through a loop for which taking the path on one iteration implies
10960that the same path will be taken on all subsequent iterations.
10961
10962For example, consider:
10963
10964@smallexample
10965 while (1)
10966 @{
10967 char opcode = *cpu_state.pc;
10968 switch (opcode)
10969 @{
10970 case OPCODE_FOO:
10971 handle_opcode_foo (&cpu_state);
10972 break;
10973 case OPCODE_BAR:
10974 handle_opcode_bar (&cpu_state);
10975 break;
10976 @}
10977 @}
10978@end smallexample
10979
10980The analyzer will complain for the above case because if @code{opcode}
10981ever matches none of the cases, the @code{switch} will follow the
10982implicit @code{default} case, making the body of the loop be a ``no-op''
10983with @code{cpu_state.pc} unchanged, and thus using the same value of
10984@code{opcode} on all subseqent iterations, leading to an infinite loop.
10985
10986See @uref{https://cwe.mitre.org/data/definitions/835.html, CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')}.
10987
ce51e843
ML
10988@opindex Wanalyzer-infinite-recursion
10989@opindex Wno-analyzer-infinite-recursion
ddf6fe37 10990@item -Wno-analyzer-infinite-recursion
ce51e843
ML
10991This warning requires @option{-fanalyzer}, which enables it; use
10992@option{-Wno-analyzer-infinite-recursion} to disable it.
10993
10994This diagnostics warns for paths through the code which appear to
10995lead to infinite recursion.
10996
10997Specifically, when the analyzer "sees" a recursive call, it will compare
10998the state of memory at the entry to the new frame with that at the entry
10999to the previous frame of that function on the stack. The warning is
11000issued if nothing in memory appears to be changing; any changes observed
11001to parameters or globals are assumed to lead to termination of the
11002recursion and thus suppress the warning.
11003
11004This diagnostic is likely to miss cases of infinite recursion that
11005are convered to iteration by the optimizer before the analyzer "sees"
11006them. Hence optimization should be disabled when attempting to trigger
11007this diagnostic.
11008
11009Compare with @option{-Winfinite-recursion}, which provides a similar
11010diagnostic, but is implemented in a different way.
11011
841008d3
DM
11012See @uref{https://cwe.mitre.org/data/definitions/674.html, CWE-674: Uncontrolled Recursion}.
11013
d77de738
ML
11014@opindex Wanalyzer-jump-through-null
11015@opindex Wno-analyzer-jump-through-null
ddf6fe37 11016@item -Wno-analyzer-jump-through-null
d77de738
ML
11017This warning requires @option{-fanalyzer}, which enables it; use
11018@option{-Wno-analyzer-jump-through-null}
11019to disable it.
11020
11021This diagnostic warns for paths through the code in which a @code{NULL}
11022function pointer is called.
11023
d77de738
ML
11024@opindex Wanalyzer-malloc-leak
11025@opindex Wno-analyzer-malloc-leak
ddf6fe37 11026@item -Wno-analyzer-malloc-leak
d77de738
ML
11027This warning requires @option{-fanalyzer}, which enables it; use
11028@option{-Wno-analyzer-malloc-leak}
11029to disable it.
11030
11031This diagnostic warns for paths through the code in which a
11032pointer allocated via an allocator is leaked: either @code{malloc},
11033or a function marked with attribute @code{malloc}.
11034
11035See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
11036
d77de738
ML
11037@opindex Wanalyzer-mismatching-deallocation
11038@opindex Wno-analyzer-mismatching-deallocation
ddf6fe37 11039@item -Wno-analyzer-mismatching-deallocation
d77de738
ML
11040This warning requires @option{-fanalyzer}, which enables it; use
11041@option{-Wno-analyzer-mismatching-deallocation}
11042to disable it.
11043
11044This diagnostic warns for paths through the code in which the
11045wrong deallocation function is called on a pointer value, based on
11046which function was used to allocate the pointer value. The diagnostic
11047will warn about mismatches between @code{free}, scalar @code{delete}
11048and vector @code{delete[]}, and those marked as allocator/deallocator
11049pairs using attribute @code{malloc}.
11050
11051See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
11052
d77de738
ML
11053@opindex Wanalyzer-out-of-bounds
11054@opindex Wno-analyzer-out-of-bounds
ddf6fe37 11055@item -Wno-analyzer-out-of-bounds
4ace81b6 11056This warning requires @option{-fanalyzer}, which enables it; use
d77de738
ML
11057@option{-Wno-analyzer-out-of-bounds} to disable it.
11058
4ace81b6 11059This diagnostic warns for paths through the code in which a buffer is
d77de738
ML
11060definitely read or written out-of-bounds. The diagnostic applies for
11061cases where the analyzer is able to determine a constant offset and for
11062accesses past the end of a buffer, also a constant capacity. Further,
11063the diagnostic does limited checking for accesses past the end when the
11064offset as well as the capacity is symbolic.
11065
11066See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
11067
0e466e97
DM
11068For cases where the analyzer is able, it will emit a text art diagram
11069visualizing the spatial relationship between the memory region that the
11070analyzer predicts would be accessed, versus the range of memory that is
11071valid to access: whether they overlap, are touching, are close or far
11072apart; which one is before or after in memory, the relative sizes
11073involved, the direction of the access (read vs write), and, in some
11074cases, the values of data involved. This diagram can be suppressed
11075using @option{-fdiagnostics-text-art-charset=none}.
11076
034d99e8
DM
11077@opindex Wanalyzer-overlapping-buffers
11078@opindex Wno-analyzer-overlapping-buffers
11079@item -Wno-analyzer-overlapping-buffers
11080This warning requires @option{-fanalyzer}, which enables it; use
11081@option{-Wno-analyzer-overlapping-buffers} to disable it.
11082
11083This diagnostic warns for paths through the code in which overlapping
11084buffers are passed to an API for which the behavior on such buffers
11085is undefined.
11086
11087Specifically, the diagnostic occurs on calls to the following functions
11088@itemize @bullet
11089@item @code{memcpy}
11090@item @code{strcat}
11091@item @code{strcpy}
11092@end itemize
11093for cases where the buffers are known to overlap.
11094
d77de738
ML
11095@opindex Wanalyzer-possible-null-argument
11096@opindex Wno-analyzer-possible-null-argument
ddf6fe37 11097@item -Wno-analyzer-possible-null-argument
d77de738
ML
11098This warning requires @option{-fanalyzer}, which enables it; use
11099@option{-Wno-analyzer-possible-null-argument} to disable it.
11100
11101This diagnostic warns for paths through the code in which a
11102possibly-NULL value is passed to a function argument marked
11103with @code{__attribute__((nonnull))} as requiring a non-NULL
11104value.
11105
11106See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
11107
d77de738
ML
11108@opindex Wanalyzer-possible-null-dereference
11109@opindex Wno-analyzer-possible-null-dereference
ddf6fe37 11110@item -Wno-analyzer-possible-null-dereference
d77de738
ML
11111This warning requires @option{-fanalyzer}, which enables it; use
11112@option{-Wno-analyzer-possible-null-dereference} to disable it.
11113
11114This diagnostic warns for paths through the code in which a
11115possibly-NULL value is dereferenced.
11116
11117See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
11118
d77de738
ML
11119@opindex Wanalyzer-null-argument
11120@opindex Wno-analyzer-null-argument
ddf6fe37 11121@item -Wno-analyzer-null-argument
d77de738
ML
11122This warning requires @option{-fanalyzer}, which enables it; use
11123@option{-Wno-analyzer-null-argument} to disable it.
11124
11125This diagnostic warns for paths through the code in which a
11126value known to be NULL is passed to a function argument marked
11127with @code{__attribute__((nonnull))} as requiring a non-NULL
11128value.
11129
11130See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
11131
d77de738
ML
11132@opindex Wanalyzer-null-dereference
11133@opindex Wno-analyzer-null-dereference
ddf6fe37 11134@item -Wno-analyzer-null-dereference
d77de738
ML
11135This warning requires @option{-fanalyzer}, which enables it; use
11136@option{-Wno-analyzer-null-dereference} to disable it.
11137
11138This diagnostic warns for paths through the code in which a
11139value known to be NULL is dereferenced.
11140
11141See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
11142
d77de738
ML
11143@opindex Wanalyzer-putenv-of-auto-var
11144@opindex Wno-analyzer-putenv-of-auto-var
ddf6fe37 11145@item -Wno-analyzer-putenv-of-auto-var
d77de738
ML
11146This warning requires @option{-fanalyzer}, which enables it; use
11147@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
11148
11149This diagnostic warns for paths through the code in which a
11150call to @code{putenv} is passed a pointer to an automatic variable
11151or an on-stack buffer.
11152
11153See @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}.
11154
d77de738
ML
11155@opindex Wanalyzer-shift-count-negative
11156@opindex Wno-analyzer-shift-count-negative
ddf6fe37 11157@item -Wno-analyzer-shift-count-negative
d77de738
ML
11158This warning requires @option{-fanalyzer}, which enables it; use
11159@option{-Wno-analyzer-shift-count-negative} to disable it.
11160
11161This diagnostic warns for paths through the code in which a
11162shift is attempted with a negative count. It is analogous to
11163the @option{-Wshift-count-negative} diagnostic implemented in
11164the C/C++ front ends, but is implemented based on analyzing
11165interprocedural paths, rather than merely parsing the syntax tree.
11166However, the analyzer does not prioritize detection of such paths, so
11167false negatives are more likely relative to other warnings.
11168
d77de738
ML
11169@opindex Wanalyzer-shift-count-overflow
11170@opindex Wno-analyzer-shift-count-overflow
ddf6fe37 11171@item -Wno-analyzer-shift-count-overflow
d77de738
ML
11172This warning requires @option{-fanalyzer}, which enables it; use
11173@option{-Wno-analyzer-shift-count-overflow} to disable it.
11174
11175This diagnostic warns for paths through the code in which a
11176shift is attempted with a count greater than or equal to the
11177precision of the operand's type. It is analogous to
11178the @option{-Wshift-count-overflow} diagnostic implemented in
11179the C/C++ front ends, but is implemented based on analyzing
11180interprocedural paths, rather than merely parsing the syntax tree.
11181However, the analyzer does not prioritize detection of such paths, so
11182false negatives are more likely relative to other warnings.
11183
d77de738
ML
11184@opindex Wanalyzer-stale-setjmp-buffer
11185@opindex Wno-analyzer-stale-setjmp-buffer
ddf6fe37 11186@item -Wno-analyzer-stale-setjmp-buffer
d77de738
ML
11187This warning requires @option{-fanalyzer}, which enables it; use
11188@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
11189
11190This diagnostic warns for paths through the code in which
11191@code{longjmp} is called to rewind to a @code{jmp_buf} relating
11192to a @code{setjmp} call in a function that has returned.
11193
11194When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
11195location, it records the stack frame. The stack frame becomes invalid
11196when the function containing the @code{setjmp} call returns. Attempting
11197to rewind to it via @code{longjmp} would reference a stack frame that
11198no longer exists, and likely lead to a crash (or worse).
11199
d77de738
ML
11200@opindex Wanalyzer-tainted-allocation-size
11201@opindex Wno-analyzer-tainted-allocation-size
ddf6fe37 11202@item -Wno-analyzer-tainted-allocation-size
cfaaa8b1 11203This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11204use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
11205
11206This diagnostic warns for paths through the code in which a value
11207that could be under an attacker's control is used as the size
11208of an allocation without being sanitized, so that an attacker could
11209inject an excessively large allocation and potentially cause a denial
11210of service attack.
11211
11212See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
11213
ce51e843
ML
11214@opindex Wanalyzer-tainted-assertion
11215@opindex Wno-analyzer-tainted-assertion
ddf6fe37 11216@item -Wno-analyzer-tainted-assertion
ce51e843 11217
cfaaa8b1 11218This warning requires @option{-fanalyzer} which enables it;
ce51e843
ML
11219use @option{-Wno-analyzer-tainted-assertion} to disable it.
11220
11221This diagnostic warns for paths through the code in which a value
11222that could be under an attacker's control is used as part of a
11223condition without being first sanitized, and that condition guards a
11224call to a function marked with attribute @code{noreturn}
11225(such as the function @code{__builtin_unreachable}). Such functions
11226typically indicate abnormal termination of the program, such as for
11227assertion failure handlers. For example:
11228
11229@smallexample
11230assert (some_tainted_value < SOME_LIMIT);
11231@end smallexample
11232
11233In such cases:
11234
11235@itemize
11236@item
11237when assertion-checking is enabled: an attacker could trigger
11238a denial of service by injecting an assertion failure
11239
11240@item
11241when assertion-checking is disabled, such as by defining @code{NDEBUG},
11242an attacker could inject data that subverts the process, since it
11243presumably violates a precondition that is being assumed by the code.
11244
11245@end itemize
11246
11247Note that when assertion-checking is disabled, the assertions are
11248typically removed by the preprocessor before the analyzer has a chance
11249to "see" them, so this diagnostic can only generate warnings on builds
11250in which assertion-checking is enabled.
11251
11252For the purpose of this warning, any function marked with attribute
11253@code{noreturn} is considered as a possible assertion failure
11254handler, including @code{__builtin_unreachable}. Note that these functions
11255are sometimes removed by the optimizer before the analyzer "sees" them.
11256Hence optimization should be disabled when attempting to trigger this
11257diagnostic.
11258
11259See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
11260
11261The warning can also report problematic constructions such as
11262
11263@smallexample
11264switch (some_tainted_value) @{
11265case 0:
11266 /* [...etc; various valid cases omitted...] */
11267 break;
11268
11269default:
11270 __builtin_unreachable (); /* BUG: attacker can trigger this */
11271@}
11272@end smallexample
11273
11274despite the above not being an assertion failure, strictly speaking.
11275
d77de738
ML
11276@opindex Wanalyzer-tainted-array-index
11277@opindex Wno-analyzer-tainted-array-index
ddf6fe37 11278@item -Wno-analyzer-tainted-array-index
cfaaa8b1 11279This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11280use @option{-Wno-analyzer-tainted-array-index} to disable it.
11281
11282This diagnostic warns for paths through the code in which a value
11283that could be under an attacker's control is used as the index
11284of an array access without being sanitized, so that an attacker
11285could inject an out-of-bounds access.
11286
11287See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11288
d77de738
ML
11289@opindex Wanalyzer-tainted-divisor
11290@opindex Wno-analyzer-tainted-divisor
ddf6fe37 11291@item -Wno-analyzer-tainted-divisor
cfaaa8b1 11292This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11293use @option{-Wno-analyzer-tainted-divisor} to disable it.
11294
11295This diagnostic warns for paths through the code in which a value
11296that could be under an attacker's control is used as the divisor
11297in a division or modulus operation without being sanitized, so that
11298an attacker could inject a division-by-zero.
11299
11300See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
11301
d77de738
ML
11302@opindex Wanalyzer-tainted-offset
11303@opindex Wno-analyzer-tainted-offset
ddf6fe37 11304@item -Wno-analyzer-tainted-offset
cfaaa8b1 11305This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11306use @option{-Wno-analyzer-tainted-offset} to disable it.
11307
11308This diagnostic warns for paths through the code in which a value
11309that could be under an attacker's control is used as a pointer offset
11310without being sanitized, so that an attacker could inject an out-of-bounds
11311access.
11312
11313See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
11314
d77de738
ML
11315@opindex Wanalyzer-tainted-size
11316@opindex Wno-analyzer-tainted-size
ddf6fe37 11317@item -Wno-analyzer-tainted-size
cfaaa8b1 11318This warning requires @option{-fanalyzer} which enables it;
d77de738
ML
11319use @option{-Wno-analyzer-tainted-size} to disable it.
11320
11321This diagnostic warns for paths through the code in which a value
11322that could be under an attacker's control is used as the size of
11323an operation such as @code{memset} without being sanitized, so that an
11324attacker could inject an out-of-bounds access.
11325
11326See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
11327
f65f63c4
DM
11328@opindex Wanalyzer-undefined-behavior-strtok
11329@opindex Wno-analyzer-undefined-behavior-strtok
11330@item -Wno-analyzer-undefined-behavior-strtok
11331This warning requires @option{-fanalyzer}, which enables it; use
11332@option{-Wno-analyzer-undefined-behavior-strtok} to disable it.
11333
11334This diagnostic warns for paths through the code in which a
11335call is made to @code{strtok} with undefined behavior.
11336
11337Specifically, passing NULL as the first parameter for the initial
11338call to @code{strtok} within a process has undefined behavior.
11339
d77de738
ML
11340@opindex Wanalyzer-unsafe-call-within-signal-handler
11341@opindex Wno-analyzer-unsafe-call-within-signal-handler
ddf6fe37 11342@item -Wno-analyzer-unsafe-call-within-signal-handler
d77de738
ML
11343This warning requires @option{-fanalyzer}, which enables it; use
11344@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
11345
11346This diagnostic warns for paths through the code in which a
11347function known to be async-signal-unsafe (such as @code{fprintf}) is
11348called from a signal handler.
11349
11350See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
11351
d77de738
ML
11352@opindex Wanalyzer-use-after-free
11353@opindex Wno-analyzer-use-after-free
ddf6fe37 11354@item -Wno-analyzer-use-after-free
d77de738
ML
11355This warning requires @option{-fanalyzer}, which enables it; use
11356@option{-Wno-analyzer-use-after-free} to disable it.
11357
11358This diagnostic warns for paths through the code in which a
11359pointer is used after a deallocator is called on it: either @code{free},
11360or a deallocator referenced by attribute @code{malloc}.
11361
11362See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
11363
d77de738
ML
11364@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
11365@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
ddf6fe37 11366@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
d77de738
ML
11367This warning requires @option{-fanalyzer}, which enables it; use
11368@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
11369to disable it.
11370
11371This diagnostic warns for paths through the code in which a pointer
11372is dereferenced that points to a variable in a stale stack frame.
11373
d77de738
ML
11374@opindex Wanalyzer-va-arg-type-mismatch
11375@opindex Wno-analyzer-va-arg-type-mismatch
ddf6fe37 11376@item -Wno-analyzer-va-arg-type-mismatch
d77de738
ML
11377This warning requires @option{-fanalyzer}, which enables it; use
11378@option{-Wno-analyzer-va-arg-type-mismatch}
11379to disable it.
11380
11381This diagnostic warns for interprocedural paths through the code for which
11382the analyzer detects an attempt to use @code{va_arg} to extract a value
11383passed to a variadic call, but uses a type that does not match that of
11384the expression passed to the call.
11385
11386See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
11387
d77de738
ML
11388@opindex Wanalyzer-va-list-exhausted
11389@opindex Wno-analyzer-va-list-exhausted
ddf6fe37 11390@item -Wno-analyzer-va-list-exhausted
d77de738
ML
11391This warning requires @option{-fanalyzer}, which enables it; use
11392@option{-Wno-analyzer-va-list-exhausted}
11393to disable it.
11394
11395This diagnostic warns for interprocedural paths through the code for which
11396the analyzer detects an attempt to use @code{va_arg} to access the next
11397value passed to a variadic call, but all of the values in the
11398@code{va_list} have already been consumed.
11399
11400See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
11401
d77de738
ML
11402@opindex Wanalyzer-va-list-leak
11403@opindex Wno-analyzer-va-list-leak
ddf6fe37 11404@item -Wno-analyzer-va-list-leak
d77de738
ML
11405This warning requires @option{-fanalyzer}, which enables it; use
11406@option{-Wno-analyzer-va-list-leak}
11407to disable it.
11408
11409This diagnostic warns for interprocedural paths through the code for which
11410the analyzer detects that @code{va_start} or @code{va_copy} has been called
11411on a @code{va_list} without a corresponding call to @code{va_end}.
11412
d77de738
ML
11413@opindex Wanalyzer-va-list-use-after-va-end
11414@opindex Wno-analyzer-va-list-use-after-va-end
ddf6fe37 11415@item -Wno-analyzer-va-list-use-after-va-end
d77de738
ML
11416This warning requires @option{-fanalyzer}, which enables it; use
11417@option{-Wno-analyzer-va-list-use-after-va-end}
11418to disable it.
11419
11420This diagnostic warns for interprocedural paths through the code for which
11421the analyzer detects an attempt to use a @code{va_list} after
11422@code{va_end} has been called on it.
11423@code{va_list}.
11424
d77de738
ML
11425@opindex Wanalyzer-write-to-const
11426@opindex Wno-analyzer-write-to-const
ddf6fe37 11427@item -Wno-analyzer-write-to-const
d77de738
ML
11428This warning requires @option{-fanalyzer}, which enables it; use
11429@option{-Wno-analyzer-write-to-const}
11430to disable it.
11431
11432This diagnostic warns for paths through the code in which the analyzer
11433detects an attempt to write through a pointer to a @code{const} object.
11434However, the analyzer does not prioritize detection of such paths, so
11435false negatives are more likely relative to other warnings.
11436
d77de738
ML
11437@opindex Wanalyzer-write-to-string-literal
11438@opindex Wno-analyzer-write-to-string-literal
ddf6fe37 11439@item -Wno-analyzer-write-to-string-literal
d77de738
ML
11440This warning requires @option{-fanalyzer}, which enables it; use
11441@option{-Wno-analyzer-write-to-string-literal}
11442to disable it.
11443
11444This diagnostic warns for paths through the code in which the analyzer
11445detects an attempt to write through a pointer to a string literal.
11446However, the analyzer does not prioritize detection of such paths, so
11447false negatives are more likely relative to other warnings.
11448
d77de738
ML
11449@opindex Wanalyzer-use-of-uninitialized-value
11450@opindex Wno-analyzer-use-of-uninitialized-value
ddf6fe37 11451@item -Wno-analyzer-use-of-uninitialized-value
d77de738
ML
11452This warning requires @option{-fanalyzer}, which enables it; use
11453@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
11454
11455This diagnostic warns for paths through the code in which an uninitialized
11456value is used.
11457
11458See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
11459
11460@end table
11461
11462The analyzer has hardcoded knowledge about the behavior of the following
11463memory-management functions:
11464
11465@itemize @bullet
11466@item @code{alloca}
11467@item The built-in functions @code{__builtin_alloc},
11468@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
11469@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
11470@code{__builtin_memcpy_chk}, @code{__builtin_memset},
11471@code{__builtin_memset_chk}, @code{__builtin_realloc},
11472@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
11473@item @code{calloc}
11474@item @code{free}
11475@item @code{malloc}
11476@item @code{memset}
11477@item @code{operator delete}
11478@item @code{operator delete []}
11479@item @code{operator new}
11480@item @code{operator new []}
11481@item @code{realloc}
11482@item @code{strdup}
11483@item @code{strndup}
11484@end itemize
11485
4ace81b6 11486@noindent
d77de738
ML
11487of the following functions for working with file descriptors:
11488
11489@itemize @bullet
11490@item @code{open}
11491@item @code{close}
11492@item @code{creat}
11493@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 11494@item @code{isatty}
d77de738
ML
11495@item @code{pipe}, and @code{pipe2}
11496@item @code{read}
11497@item @code{write}
86a90006 11498@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
11499@end itemize
11500
4ace81b6 11501@noindent
d77de738
ML
11502of the following functions for working with @code{<stdio.h>} streams:
11503@itemize @bullet
11504@item The built-in functions @code{__builtin_fprintf},
11505@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
11506@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
11507@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
11508@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
11509@code{__builtin_printf_unlocked}, @code{__builtin_putc},
11510@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
11511@code{__builtin_putc_unlocked}, @code{__builtin_puts},
11512@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
11513@code{__builtin_vprintf}
11514@item @code{fopen}
11515@item @code{fclose}
78a17f44 11516@item @code{ferror}
d77de738
ML
11517@item @code{fgets}
11518@item @code{fgets_unlocked}
78a17f44 11519@item @code{fileno}
d77de738 11520@item @code{fread}
78a17f44 11521@item @code{getc}
d77de738
ML
11522@item @code{getchar}
11523@item @code{fprintf}
11524@item @code{printf}
11525@item @code{fwrite}
11526@end itemize
11527
4ace81b6 11528@noindent
d77de738
ML
11529and of the following functions:
11530
11531@itemize @bullet
11532@item The built-in functions @code{__builtin_expect},
11533@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
11534@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
11535@code{__builtin_strlen}, @code{__builtin_va_copy}, and
11536@code{__builtin_va_start}
11537@item The GNU extensions @code{error} and @code{error_at_line}
11538@item @code{getpass}
11539@item @code{longjmp}
11540@item @code{putenv}
11541@item @code{setjmp}
11542@item @code{siglongjmp}
11543@item @code{signal}
11544@item @code{sigsetjmp}
bbdc0e0d 11545@item @code{strcat}
d77de738
ML
11546@item @code{strchr}
11547@item @code{strlen}
11548@end itemize
11549
11550In addition, various functions with an @code{__analyzer_} prefix have
11551special meaning to the analyzer, described in the GCC Internals manual.
11552
11553Pertinent parameters for controlling the exploration are:
4ace81b6
SL
11554@itemize @bullet
11555@item @option{--param analyzer-bb-explosion-factor=@var{value}}
11556@item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
11557@item @option{--param analyzer-max-recursion-depth=@var{value}}
11558@item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
11559@end itemize
d77de738
ML
11560
11561The following options control the analyzer.
11562
11563@table @gcctabopt
11564
d77de738
ML
11565@opindex fanalyzer-call-summaries
11566@opindex fno-analyzer-call-summaries
ddf6fe37 11567@item -fanalyzer-call-summaries
d77de738
ML
11568Simplify interprocedural analysis by computing the effect of certain calls,
11569rather than exploring all paths through the function from callsite to each
11570possible return.
11571
11572If enabled, call summaries are only used for functions with more than one
11573call site, and that are sufficiently complicated (as per
11574@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
11575
d77de738 11576@opindex fanalyzer-checker
ddf6fe37 11577@item -fanalyzer-checker=@var{name}
d77de738
ML
11578Restrict the analyzer to run just the named checker, and enable it.
11579
0e466e97
DM
11580@opindex fanalyzer-debug-text-art
11581@opindex fno-analyzer-debug-text-art
11582@item -fanalyzer-debug-text-art-headings
11583This option is intended for analyzer developers. If enabled,
11584the analyzer will add extra annotations to any diagrams it generates.
11585
d77de738
ML
11586@opindex fanalyzer-feasibility
11587@opindex fno-analyzer-feasibility
ddf6fe37 11588@item -fno-analyzer-feasibility
d77de738
ML
11589This option is intended for analyzer developers.
11590
11591By default the analyzer verifies that there is a feasible control flow path
11592for each diagnostic it emits: that the conditions that hold are not mutually
11593exclusive. Diagnostics for which no feasible path can be found are rejected.
11594This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
11595debugging issues in this code.
11596
d77de738
ML
11597@opindex fanalyzer-fine-grained
11598@opindex fno-analyzer-fine-grained
ddf6fe37 11599@item -fanalyzer-fine-grained
d77de738
ML
11600This option is intended for analyzer developers.
11601
11602Internally the analyzer builds an ``exploded graph'' that combines
11603control flow graphs with data flow information.
11604
11605By default, an edge in this graph can contain the effects of a run
11606of multiple statements within a basic block. With
11607@option{-fanalyzer-fine-grained}, each statement gets its own edge.
11608
d77de738
ML
11609@opindex fanalyzer-show-duplicate-count
11610@opindex fno-analyzer-show-duplicate-count
ddf6fe37 11611@item -fanalyzer-show-duplicate-count
d77de738
ML
11612This option is intended for analyzer developers: if multiple diagnostics
11613have been detected as being duplicates of each other, it emits a note when
11614reporting the best diagnostic, giving the number of additional diagnostics
11615that were suppressed by the deduplication logic.
11616
ce8cdf5b 11617@opindex fanalyzer-show-events-in-system-headers
11618@opindex fno-analyzer-show-events-in-system-headers
11619@item -fanalyzer-show-events-in-system-headers
11620By default the analyzer emits simplified diagnostics paths by hiding
11621events fully located within a system header.
11622With @option{-fanalyzer-show-events-in-system-headers} such
11623events are no longer suppressed.
11624
d77de738
ML
11625@opindex fanalyzer-state-merge
11626@opindex fno-analyzer-state-merge
ddf6fe37 11627@item -fno-analyzer-state-merge
d77de738
ML
11628This option is intended for analyzer developers.
11629
11630By default the analyzer attempts to simplify analysis by merging
11631sufficiently similar states at each program point as it builds its
11632``exploded graph''. With @option{-fno-analyzer-state-merge} this
11633merging can be suppressed, for debugging state-handling issues.
11634
d77de738
ML
11635@opindex fanalyzer-state-purge
11636@opindex fno-analyzer-state-purge
ddf6fe37 11637@item -fno-analyzer-state-purge
d77de738
ML
11638This option is intended for analyzer developers.
11639
11640By default the analyzer attempts to simplify analysis by purging
11641aspects of state at a program point that appear to no longer be relevant
11642e.g. the values of locals that aren't accessed later in the function
11643and which aren't relevant to leak analysis.
11644
11645With @option{-fno-analyzer-state-purge} this purging of state can
11646be suppressed, for debugging state-handling issues.
11647
8f636915
DM
11648@opindex fanalyzer-suppress-followups
11649@opindex fno-analyzer-suppress-followups
f33d7a88 11650@item -fno-analyzer-suppress-followups
8f636915
DM
11651This option is intended for analyzer developers.
11652
11653By default the analyzer will stop exploring an execution path after
11654encountering certain diagnostics, in order to avoid potentially issuing a
11655cascade of follow-up diagnostics.
11656
11657The diagnostics that terminate analysis along a path are:
11658
11659@itemize
11660@item @option{-Wanalyzer-null-argument}
11661@item @option{-Wanalyzer-null-dereference}
11662@item @option{-Wanalyzer-use-after-free}
11663@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
11664@item @option{-Wanalyzer-use-of-uninitialized-value}
11665@end itemize
11666
11667With @option{-fno-analyzer-suppress-followups} the analyzer will
11668continue to explore such paths even after such diagnostics, which may
11669be helpful for debugging issues in the analyzer, or for microbenchmarks
11670for detecting undefined behavior.
11671
d77de738
ML
11672@opindex fanalyzer-transitivity
11673@opindex fno-analyzer-transitivity
ddf6fe37 11674@item -fanalyzer-transitivity
d77de738
ML
11675This option enables transitivity of constraints within the analyzer.
11676
d77de738
ML
11677@opindex fanalyzer-undo-inlining
11678@opindex fno-analyzer-undo-inlining
ddf6fe37 11679@item -fno-analyzer-undo-inlining
d77de738
ML
11680This option is intended for analyzer developers.
11681
11682@option{-fanalyzer} runs relatively late compared to other code analysis
11683tools, and some optimizations have already been applied to the code. In
11684particular function inlining may have occurred, leading to the
11685interprocedural execution paths emitted by the analyzer containing
11686function frames that don't correspond to those in the original source
11687code.
11688
11689By default the analyzer attempts to reconstruct the original function
11690frames, and to emit events showing the inlined calls.
11691
11692With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11693the original frame information can be be disabled, which may be of help
11694when debugging issues in the analyzer.
11695
11696@item -fanalyzer-verbose-edges
11697This option is intended for analyzer developers. It enables more
11698verbose, lower-level detail in the descriptions of control flow
11699within diagnostic paths.
11700
11701@item -fanalyzer-verbose-state-changes
11702This option is intended for analyzer developers. It enables more
11703verbose, lower-level detail in the descriptions of events relating
11704to state machines within diagnostic paths.
11705
11706@item -fanalyzer-verbosity=@var{level}
11707This option controls the complexity of the control flow paths that are
11708emitted for analyzer diagnostics.
11709
11710The @var{level} can be one of:
11711
11712@table @samp
11713@item 0
11714At this level, interprocedural call and return events are displayed,
11715along with the most pertinent state-change events relating to
11716a diagnostic. For example, for a double-@code{free} diagnostic,
11717both calls to @code{free} will be shown.
11718
11719@item 1
11720As per the previous level, but also show events for the entry
11721to each function.
11722
11723@item 2
11724As per the previous level, but also show events relating to
11725control flow that are significant to triggering the issue
11726(e.g. ``true path taken'' at a conditional).
11727
11728This level is the default.
11729
11730@item 3
11731As per the previous level, but show all control flow events, not
11732just significant ones.
11733
11734@item 4
11735This level is intended for analyzer developers; it adds various
11736other events intended for debugging the analyzer.
11737
11738@end table
11739
d77de738 11740@opindex fdump-analyzer
ddf6fe37 11741@item -fdump-analyzer
d77de738
ML
11742Dump internal details about what the analyzer is doing to
11743@file{@var{file}.analyzer.txt}.
4ace81b6 11744@option{-fdump-analyzer-stderr} overrides this option.
d77de738 11745
d77de738 11746@opindex fdump-analyzer-stderr
ddf6fe37 11747@item -fdump-analyzer-stderr
d77de738
ML
11748Dump internal details about what the analyzer is doing to stderr.
11749This option overrides @option{-fdump-analyzer}.
11750
d77de738 11751@opindex fdump-analyzer-callgraph
ddf6fe37 11752@item -fdump-analyzer-callgraph
d77de738
ML
11753Dump a representation of the call graph suitable for viewing with
11754GraphViz to @file{@var{file}.callgraph.dot}.
11755
d77de738 11756@opindex fdump-analyzer-exploded-graph
ddf6fe37 11757@item -fdump-analyzer-exploded-graph
d77de738
ML
11758Dump a representation of the ``exploded graph'' suitable for viewing with
11759GraphViz to @file{@var{file}.eg.dot}.
11760Nodes are color-coded based on state-machine states to emphasize
11761state changes.
11762
d77de738 11763@opindex dump-analyzer-exploded-nodes
ddf6fe37 11764@item -fdump-analyzer-exploded-nodes
d77de738
ML
11765Emit diagnostics showing where nodes in the ``exploded graph'' are
11766in relation to the program source.
11767
d77de738 11768@opindex dump-analyzer-exploded-nodes-2
ddf6fe37 11769@item -fdump-analyzer-exploded-nodes-2
d77de738
ML
11770Dump a textual representation of the ``exploded graph'' to
11771@file{@var{file}.eg.txt}.
11772
d77de738 11773@opindex dump-analyzer-exploded-nodes-3
ddf6fe37 11774@item -fdump-analyzer-exploded-nodes-3
d77de738
ML
11775Dump a textual representation of the ``exploded graph'' to
11776one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11777This is typically a large number of dump files.
11778
d77de738 11779@opindex fdump-analyzer-exploded-paths
ddf6fe37 11780@item -fdump-analyzer-exploded-paths
d77de738
ML
11781Dump a textual representation of the ``exploded path'' for each
11782diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11783
d77de738 11784@opindex dump-analyzer-feasibility
ddf6fe37 11785@item -fdump-analyzer-feasibility
d77de738
ML
11786Dump internal details about the analyzer's search for feasible paths.
11787The details are written in a form suitable for viewing with GraphViz
11788to filenames of the form @file{@var{file}.*.fg.dot},
11789@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11790
841008d3
DM
11791@opindex dump-analyzer-infinite-loop
11792@item -fdump-analyzer-infinite-loop
11793Dump internal details about the analyzer's search for infinite loops.
11794The details are written in a form suitable for viewing with GraphViz
11795to filenames of the form @file{@var{file}.*.infinite-loop.dot}.
11796
d77de738 11797@opindex fdump-analyzer-json
ddf6fe37 11798@item -fdump-analyzer-json
d77de738
ML
11799Dump a compressed JSON representation of analyzer internals to
11800@file{@var{file}.analyzer.json.gz}. The precise format is subject
11801to change.
11802
d77de738 11803@opindex fdump-analyzer-state-purge
ddf6fe37 11804@item -fdump-analyzer-state-purge
d77de738
ML
11805As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11806``supergraph'' suitable for viewing with GraphViz, but annotate the
11807graph with information on what state will be purged at each node.
11808The graph is written to @file{@var{file}.state-purge.dot}.
11809
d77de738 11810@opindex fdump-analyzer-supergraph
ddf6fe37 11811@item -fdump-analyzer-supergraph
d77de738
ML
11812Dump representations of the ``supergraph'' suitable for viewing with
11813GraphViz to @file{@var{file}.supergraph.dot} and to
11814@file{@var{file}.supergraph-eg.dot}. These show all of the
11815control flow graphs in the program, with interprocedural edges for
11816calls and returns. The second dump contains annotations showing nodes
11817in the ``exploded graph'' and diagnostics associated with them.
11818
d77de738 11819@opindex fdump-analyzer-untracked
ddf6fe37 11820@item -fdump-analyzer-untracked
d77de738
ML
11821Emit custom warnings with internal details intended for analyzer developers.
11822
11823@end table
11824
11825@node Debugging Options
11826@section Options for Debugging Your Program
11827@cindex options, debugging
11828@cindex debugging information options
11829
11830To tell GCC to emit extra information for use by a debugger, in almost
11831all cases you need only to add @option{-g} to your other options. Some debug
11832formats can co-exist (like DWARF with CTF) when each of them is enabled
11833explicitly by adding the respective command line option to your other options.
11834
11835GCC allows you to use @option{-g} with
11836@option{-O}. The shortcuts taken by optimized code may occasionally
11837be surprising: some variables you declared may not exist
11838at all; flow of control may briefly move where you did not expect it;
11839some statements may not be executed because they compute constant
11840results or their values are already at hand; some statements may
11841execute in different places because they have been moved out of loops.
11842Nevertheless it is possible to debug optimized output. This makes
11843it reasonable to use the optimizer for programs that might have bugs.
11844
11845If you are not using some other optimization option, consider
11846using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11847With no @option{-O} option at all, some compiler passes that collect
11848information useful for debugging do not run at all, so that
11849@option{-Og} may result in a better debugging experience.
11850
11851@table @gcctabopt
d77de738 11852@opindex g
ddf6fe37 11853@item -g
d77de738
ML
11854Produce debugging information in the operating system's native format
11855(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11856information.
11857
11858On most systems that use stabs format, @option{-g} enables use of extra
11859debugging information that only GDB can use; this extra information
11860makes debugging work better in GDB but probably makes other debuggers
11861crash or refuse to read the program. If you want to control for certain whether
11862to generate the extra information, use @option{-gvms} (see below).
11863
d77de738 11864@opindex ggdb
ddf6fe37 11865@item -ggdb
d77de738
ML
11866Produce debugging information for use by GDB@. This means to use the
11867most expressive format available (DWARF, stabs, or the native format
11868if neither of those are supported), including GDB extensions if at all
11869possible.
11870
ddf6fe37 11871@opindex gdwarf
d77de738
ML
11872@item -gdwarf
11873@itemx -gdwarf-@var{version}
d77de738
ML
11874Produce debugging information in DWARF format (if that is supported).
11875The value of @var{version} may be either 2, 3, 4 or 5; the default
11876version for most targets is 5 (with the exception of VxWorks, TPF and
a335cf24 11877Darwin / macOS, which default to version 2, and AIX, which defaults
d77de738
ML
11878to version 4).
11879
11880Note that with DWARF Version 2, some ports require and always
11881use some non-conflicting DWARF 3 extensions in the unwind tables.
11882
11883Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11884for maximum benefit. Version 5 requires GDB 8.0 or higher.
11885
11886GCC no longer supports DWARF Version 1, which is substantially
11887different than Version 2 and later. For historical reasons, some
11888other DWARF-related options such as
11889@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11890in their names, but apply to all currently-supported versions of DWARF.
11891
d77de738 11892@opindex gbtf
ddf6fe37 11893@item -gbtf
d77de738
ML
11894Request BTF debug information. BTF is the default debugging format for the
11895eBPF target. On other targets, like x86, BTF debug information can be
11896generated along with DWARF debug information when both of the debug formats are
11897enabled explicitly via their respective command line options.
11898
ddf6fe37 11899@opindex gctf
d77de738
ML
11900@item -gctf
11901@itemx -gctf@var{level}
d77de738
ML
11902Request CTF debug information and use level to specify how much CTF debug
11903information should be produced. If @option{-gctf} is specified
11904without a value for level, the default level of CTF debug information is 2.
11905
11906CTF debug information can be generated along with DWARF debug information when
11907both of the debug formats are enabled explicitly via their respective command
11908line options.
11909
11910Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11911negates @option{-gctf}.
11912
11913Level 1 produces CTF information for tracebacks only. This includes callsite
11914information, but does not include type information.
11915
11916Level 2 produces type information for entities (functions, data objects etc.)
11917at file-scope or global-scope only.
11918
d77de738 11919@opindex gvms
ddf6fe37 11920@item -gvms
d77de738
ML
11921Produce debugging information in Alpha/VMS debug format (if that is
11922supported). This is the format used by DEBUG on Alpha/VMS systems.
11923
2f7e7bfa
MH
11924@item -gcodeview
11925@opindex gcodeview
11926Produce debugging information in CodeView debug format (if that is
11927supported). This is the format used by Microsoft Visual C++ on
11928Windows.
11929
d77de738
ML
11930@item -g@var{level}
11931@itemx -ggdb@var{level}
11932@itemx -gvms@var{level}
11933Request debugging information and also use @var{level} to specify how
11934much information. The default level is 2.
11935
11936Level 0 produces no debug information at all. Thus, @option{-g0} negates
11937@option{-g}.
11938
11939Level 1 produces minimal information, enough for making backtraces in
11940parts of the program that you don't plan to debug. This includes
11941descriptions of functions and external variables, and line number
11942tables, but no information about local variables.
11943
11944Level 3 includes extra information, such as all the macro definitions
11945present in the program. Some debuggers support macro expansion when
11946you use @option{-g3}.
11947
11948If you use multiple @option{-g} options, with or without level numbers,
11949the last such option is the one that is effective.
11950
11951@option{-gdwarf} does not accept a concatenated debug level, to avoid
11952confusion with @option{-gdwarf-@var{level}}.
11953Instead use an additional @option{-g@var{level}} option to change the
11954debug level for DWARF.
11955
d77de738
ML
11956@opindex feliminate-unused-debug-symbols
11957@opindex fno-eliminate-unused-debug-symbols
ddf6fe37 11958@item -fno-eliminate-unused-debug-symbols
d77de738
ML
11959By default, no debug information is produced for symbols that are not actually
11960used. Use this option if you want debug information for all symbols.
11961
d77de738 11962@opindex femit-class-debug-always
ddf6fe37 11963@item -femit-class-debug-always
d77de738
ML
11964Instead of emitting debugging information for a C++ class in only one
11965object file, emit it in all object files using the class. This option
11966should be used only with debuggers that are unable to handle the way GCC
11967normally emits debugging information for classes because using this
11968option increases the size of debugging information by as much as a
11969factor of two.
11970
d77de738
ML
11971@opindex fmerge-debug-strings
11972@opindex fno-merge-debug-strings
ddf6fe37 11973@item -fno-merge-debug-strings
d77de738
ML
11974Direct the linker to not merge together strings in the debugging
11975information that are identical in different object files. Merging is
11976not supported by all assemblers or linkers. Merging decreases the size
11977of the debug information in the output file at the cost of increasing
11978link processing time. Merging is enabled by default.
11979
d77de738 11980@opindex fdebug-prefix-map
ddf6fe37 11981@item -fdebug-prefix-map=@var{old}=@var{new}
d77de738
ML
11982When compiling files residing in directory @file{@var{old}}, record
11983debugging information describing them as if the files resided in
11984directory @file{@var{new}} instead. This can be used to replace a
11985build-time path with an install-time path in the debug info. It can
11986also be used to change an absolute path to a relative path by using
11987@file{.} for @var{new}. This can give more reproducible builds, which
11988are location independent, but may require an extra command to tell GDB
2eb0191a
JJ
11989where to find the source files. See also @option{-ffile-prefix-map}
11990and @option{-fcanon-prefix-map}.
d77de738 11991
d77de738 11992@opindex fvar-tracking
ddf6fe37 11993@item -fvar-tracking
d77de738
ML
11994Run variable tracking pass. It computes where variables are stored at each
11995position in code. Better debugging information is then generated
11996(if the debugging information format supports this information).
11997
11998It is enabled by default when compiling with optimization (@option{-Os},
11999@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
12000the debug info format supports it.
12001
d77de738
ML
12002@opindex fvar-tracking-assignments
12003@opindex fno-var-tracking-assignments
ddf6fe37 12004@item -fvar-tracking-assignments
d77de738
ML
12005Annotate assignments to user variables early in the compilation and
12006attempt to carry the annotations over throughout the compilation all the
12007way to the end, in an attempt to improve debug information while
12008optimizing. Use of @option{-gdwarf-4} is recommended along with it.
12009
12010It can be enabled even if var-tracking is disabled, in which case
12011annotations are created and maintained, but discarded at the end.
12012By default, this flag is enabled together with @option{-fvar-tracking},
12013except when selective scheduling is enabled.
12014
d77de738 12015@opindex gsplit-dwarf
ddf6fe37 12016@item -gsplit-dwarf
d77de738
ML
12017If DWARF debugging information is enabled, separate as much debugging
12018information as possible into a separate output file with the extension
12019@file{.dwo}. This option allows the build system to avoid linking files with
12020debug information. To be useful, this option requires a debugger capable of
12021reading @file{.dwo} files.
12022
d77de738
ML
12023@opindex gdwarf32
12024@opindex gdwarf64
ddf6fe37
AA
12025@item -gdwarf32
12026@itemx -gdwarf64
d77de738
ML
12027If DWARF debugging information is enabled, the @option{-gdwarf32} selects
12028the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
12029DWARF format. The default is target specific, on most targets it is
12030@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
12031can't support more than 2GiB of debug information in any of the DWARF
12032debug information sections. The 64-bit DWARF format allows larger debug
12033information and might not be well supported by all consumers yet.
12034
d77de738 12035@opindex gdescribe-dies
ddf6fe37 12036@item -gdescribe-dies
d77de738
ML
12037Add description attributes to some DWARF DIEs that have no name attribute,
12038such as artificial variables, external references and call site
12039parameter DIEs.
12040
d77de738 12041@opindex gpubnames
ddf6fe37 12042@item -gpubnames
d77de738
ML
12043Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
12044
d77de738 12045@opindex ggnu-pubnames
ddf6fe37 12046@item -ggnu-pubnames
d77de738
ML
12047Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
12048suitable for conversion into a GDB@ index. This option is only useful
12049with a linker that can produce GDB@ index version 7.
12050
d77de738
ML
12051@opindex fdebug-types-section
12052@opindex fno-debug-types-section
ddf6fe37 12053@item -fdebug-types-section
d77de738
ML
12054When using DWARF Version 4 or higher, type DIEs can be put into
12055their own @code{.debug_types} section instead of making them part of the
12056@code{.debug_info} section. It is more efficient to put them in a separate
12057comdat section since the linker can then remove duplicates.
12058But not all DWARF consumers support @code{.debug_types} sections yet
12059and on some objects @code{.debug_types} produces larger instead of smaller
12060debugging information.
12061
d77de738
ML
12062@opindex grecord-gcc-switches
12063@opindex gno-record-gcc-switches
ddf6fe37
AA
12064@item -grecord-gcc-switches
12065@itemx -gno-record-gcc-switches
d77de738
ML
12066This switch causes the command-line options used to invoke the
12067compiler that may affect code generation to be appended to the
12068DW_AT_producer attribute in DWARF debugging information. The options
12069are concatenated with spaces separating them from each other and from
12070the compiler version.
12071It is enabled by default.
12072See also @option{-frecord-gcc-switches} for another
12073way of storing compiler options into the object file.
12074
d77de738 12075@opindex gstrict-dwarf
ddf6fe37 12076@item -gstrict-dwarf
d77de738
ML
12077Disallow using extensions of later DWARF standard version than selected
12078with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
12079DWARF extensions from later standard versions is allowed.
12080
d77de738 12081@opindex gno-strict-dwarf
ddf6fe37 12082@item -gno-strict-dwarf
d77de738
ML
12083Allow using extensions of later DWARF standard version than selected with
12084@option{-gdwarf-@var{version}}.
12085
d77de738 12086@opindex gas-loc-support
ddf6fe37 12087@item -gas-loc-support
d77de738
ML
12088Inform the compiler that the assembler supports @code{.loc} directives.
12089It may then use them for the assembler to generate DWARF2+ line number
12090tables.
12091
12092This is generally desirable, because assembler-generated line-number
12093tables are a lot more compact than those the compiler can generate
12094itself.
12095
12096This option will be enabled by default if, at GCC configure time, the
12097assembler was found to support such directives.
12098
d77de738 12099@opindex gno-as-loc-support
ddf6fe37 12100@item -gno-as-loc-support
d77de738
ML
12101Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
12102line number tables are to be generated.
12103
d77de738 12104@opindex gas-locview-support
ddf6fe37 12105@item -gas-locview-support
d77de738
ML
12106Inform the compiler that the assembler supports @code{view} assignment
12107and reset assertion checking in @code{.loc} directives.
12108
12109This option will be enabled by default if, at GCC configure time, the
12110assembler was found to support them.
12111
12112@item -gno-as-locview-support
12113Force GCC to assign view numbers internally, if
12114@option{-gvariable-location-views} are explicitly requested.
12115
d77de738
ML
12116@opindex gcolumn-info
12117@opindex gno-column-info
ddf6fe37
AA
12118@item -gcolumn-info
12119@itemx -gno-column-info
d77de738
ML
12120Emit location column information into DWARF debugging information, rather
12121than just file and line.
12122This option is enabled by default.
12123
d77de738
ML
12124@opindex gstatement-frontiers
12125@opindex gno-statement-frontiers
ddf6fe37
AA
12126@item -gstatement-frontiers
12127@itemx -gno-statement-frontiers
d77de738
ML
12128This option causes GCC to create markers in the internal representation
12129at the beginning of statements, and to keep them roughly in place
12130throughout compilation, using them to guide the output of @code{is_stmt}
12131markers in the line number table. This is enabled by default when
12132compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
12133@dots{}), and outputting DWARF 2 debug information at the normal level.
12134
d77de738
ML
12135@opindex gvariable-location-views
12136@opindex gvariable-location-views=incompat5
12137@opindex gno-variable-location-views
ddf6fe37
AA
12138@item -gvariable-location-views
12139@itemx -gvariable-location-views=incompat5
12140@itemx -gno-variable-location-views
d77de738
ML
12141Augment variable location lists with progressive view numbers implied
12142from the line number table. This enables debug information consumers to
12143inspect state at certain points of the program, even if no instructions
12144associated with the corresponding source locations are present at that
12145point. If the assembler lacks support for view numbers in line number
12146tables, this will cause the compiler to emit the line number table,
12147which generally makes them somewhat less compact. The augmented line
12148number tables and location lists are fully backward-compatible, so they
12149can be consumed by debug information consumers that are not aware of
12150these augmentations, but they won't derive any benefit from them either.
12151
12152This is enabled by default when outputting DWARF 2 debug information at
12153the normal level, as long as there is assembler support,
12154@option{-fvar-tracking-assignments} is enabled and
12155@option{-gstrict-dwarf} is not. When assembler support is not
12156available, this may still be enabled, but it will force GCC to output
12157internal line number tables, and if
12158@option{-ginternal-reset-location-views} is not enabled, that will most
12159certainly lead to silently mismatching location views.
12160
12161There is a proposed representation for view numbers that is not backward
12162compatible with the location list format introduced in DWARF 5, that can
12163be enabled with @option{-gvariable-location-views=incompat5}. This
12164option may be removed in the future, is only provided as a reference
12165implementation of the proposed representation. Debug information
12166consumers are not expected to support this extended format, and they
12167would be rendered unable to decode location lists using it.
12168
d77de738
ML
12169@opindex ginternal-reset-location-views
12170@opindex gno-internal-reset-location-views
ddf6fe37
AA
12171@item -ginternal-reset-location-views
12172@itemx -gno-internal-reset-location-views
d77de738
ML
12173Attempt to determine location views that can be omitted from location
12174view lists. This requires the compiler to have very accurate insn
12175length estimates, which isn't always the case, and it may cause
12176incorrect view lists to be generated silently when using an assembler
12177that does not support location view lists. The GNU assembler will flag
12178any such error as a @code{view number mismatch}. This is only enabled
12179on ports that define a reliable estimation function.
12180
d77de738
ML
12181@opindex ginline-points
12182@opindex gno-inline-points
ddf6fe37
AA
12183@item -ginline-points
12184@itemx -gno-inline-points
d77de738
ML
12185Generate extended debug information for inlined functions. Location
12186view tracking markers are inserted at inlined entry points, so that
12187address and view numbers can be computed and output in debug
12188information. This can be enabled independently of location views, in
12189which case the view numbers won't be output, but it can only be enabled
12190along with statement frontiers, and it is only enabled by default if
12191location views are enabled.
12192
d77de738 12193@opindex gz
ddf6fe37 12194@item -gz@r{[}=@var{type}@r{]}
d77de738
ML
12195Produce compressed debug sections in DWARF format, if that is supported.
12196If @var{type} is not given, the default type depends on the capabilities
12197of the assembler and linker used. @var{type} may be one of
12198@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
12199compression in ELF gABI format). If the linker doesn't support writing
12200compressed debug sections, the option is rejected. Otherwise, if the
12201assembler does not support them, @option{-gz} is silently ignored when
12202producing object files.
12203
d77de738 12204@opindex femit-struct-debug-baseonly
ddf6fe37 12205@item -femit-struct-debug-baseonly
d77de738
ML
12206Emit debug information for struct-like types
12207only when the base name of the compilation source file
12208matches the base name of file in which the struct is defined.
12209
12210This option substantially reduces the size of debugging information,
12211but at significant potential loss in type information to the debugger.
12212See @option{-femit-struct-debug-reduced} for a less aggressive option.
12213See @option{-femit-struct-debug-detailed} for more detailed control.
12214
12215This option works only with DWARF debug output.
12216
d77de738 12217@opindex femit-struct-debug-reduced
ddf6fe37 12218@item -femit-struct-debug-reduced
d77de738
ML
12219Emit debug information for struct-like types
12220only when the base name of the compilation source file
12221matches the base name of file in which the type is defined,
12222unless the struct is a template or defined in a system header.
12223
12224This option significantly reduces the size of debugging information,
12225with some potential loss in type information to the debugger.
12226See @option{-femit-struct-debug-baseonly} for a more aggressive option.
12227See @option{-femit-struct-debug-detailed} for more detailed control.
12228
12229This option works only with DWARF debug output.
12230
d77de738 12231@opindex femit-struct-debug-detailed
ddf6fe37 12232@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
d77de738
ML
12233Specify the struct-like types
12234for which the compiler generates debug information.
12235The intent is to reduce duplicate struct debug information
12236between different object files within the same program.
12237
12238This option is a detailed version of
12239@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
12240which serves for most needs.
12241
12242A specification has the syntax@*
12243[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
12244
12245The optional first word limits the specification to
12246structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
12247A struct type is used directly when it is the type of a variable, member.
12248Indirect uses arise through pointers to structs.
12249That is, when use of an incomplete struct is valid, the use is indirect.
12250An example is
12251@samp{struct one direct; struct two * indirect;}.
12252
12253The optional second word limits the specification to
12254ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
12255Generic structs are a bit complicated to explain.
12256For C++, these are non-explicit specializations of template classes,
12257or non-template classes within the above.
12258Other programming languages have generics,
12259but @option{-femit-struct-debug-detailed} does not yet implement them.
12260
12261The third word specifies the source files for those
12262structs for which the compiler should emit debug information.
12263The values @samp{none} and @samp{any} have the normal meaning.
12264The value @samp{base} means that
12265the base of name of the file in which the type declaration appears
12266must match the base of the name of the main compilation file.
12267In practice, this means that when compiling @file{foo.c}, debug information
12268is generated for types declared in that file and @file{foo.h},
12269but not other header files.
12270The value @samp{sys} means those types satisfying @samp{base}
12271or declared in system or compiler headers.
12272
12273You may need to experiment to determine the best settings for your application.
12274
12275The default is @option{-femit-struct-debug-detailed=all}.
12276
12277This option works only with DWARF debug output.
12278
d77de738
ML
12279@opindex fdwarf2-cfi-asm
12280@opindex fno-dwarf2-cfi-asm
ddf6fe37 12281@item -fno-dwarf2-cfi-asm
d77de738
ML
12282Emit DWARF unwind info as compiler generated @code{.eh_frame} section
12283instead of using GAS @code{.cfi_*} directives.
12284
d77de738
ML
12285@opindex feliminate-unused-debug-types
12286@opindex fno-eliminate-unused-debug-types
ddf6fe37 12287@item -fno-eliminate-unused-debug-types
d77de738
ML
12288Normally, when producing DWARF output, GCC avoids producing debug symbol
12289output for types that are nowhere used in the source file being compiled.
12290Sometimes it is useful to have GCC emit debugging
12291information for all types declared in a compilation
12292unit, regardless of whether or not they are actually used
12293in that compilation unit, for example
12294if, in the debugger, you want to cast a value to a type that is
12295not actually used in your program (but is declared). More often,
12296however, this results in a significant amount of wasted space.
12297@end table
12298
12299@node Optimize Options
12300@section Options That Control Optimization
12301@cindex optimize options
12302@cindex options, optimization
12303
12304These options control various sorts of optimizations.
12305
12306Without any optimization option, the compiler's goal is to reduce the
12307cost of compilation and to make debugging produce the expected
12308results. Statements are independent: if you stop the program with a
12309breakpoint between statements, you can then assign a new value to any
12310variable or change the program counter to any other statement in the
12311function and get exactly the results you expect from the source
12312code.
12313
12314Turning on optimization flags makes the compiler attempt to improve
12315the performance and/or code size at the expense of compilation time
12316and possibly the ability to debug the program.
12317
12318The compiler performs optimization based on the knowledge it has of the
12319program. Compiling multiple files at once to a single output file mode allows
12320the compiler to use information gained from all of the files when compiling
12321each of them.
12322
12323Not all optimizations are controlled directly by a flag. Only
12324optimizations that have a flag are listed in this section.
12325
12326Most optimizations are completely disabled at @option{-O0} or if an
12327@option{-O} level is not set on the command line, even if individual
12328optimization flags are specified. Similarly, @option{-Og} suppresses
12329many optimization passes.
12330
12331Depending on the target and how GCC was configured, a slightly different
12332set of optimizations may be enabled at each @option{-O} level than
12333those listed here. You can invoke GCC with @option{-Q --help=optimizers}
12334to find out the exact set of optimizations that are enabled at each level.
12335@xref{Overall Options}, for examples.
12336
12337@table @gcctabopt
d77de738
ML
12338@opindex O
12339@opindex O1
ddf6fe37
AA
12340@item -O
12341@itemx -O1
d77de738
ML
12342Optimize. Optimizing compilation takes somewhat more time, and a lot
12343more memory for a large function.
12344
12345With @option{-O}, the compiler tries to reduce code size and execution
12346time, without performing any optimizations that take a great deal of
12347compilation time.
12348
12349@c Note that in addition to the default_options_table list in opts.cc,
12350@c several optimization flags default to true but control optimization
12351@c passes that are explicitly disabled at -O0.
12352
12353@option{-O} turns on the following optimization flags:
12354
12355@c Please keep the following list alphabetized.
43b72ede
AA
12356@gccoptlist{-fauto-inc-dec
12357-fbranch-count-reg
12358-fcombine-stack-adjustments
12359-fcompare-elim
12360-fcprop-registers
12361-fdce
12362-fdefer-pop
12363-fdelayed-branch
12364-fdse
12365-fforward-propagate
12366-fguess-branch-probability
12367-fif-conversion
12368-fif-conversion2
12369-finline-functions-called-once
12370-fipa-modref
12371-fipa-profile
12372-fipa-pure-const
12373-fipa-reference
12374-fipa-reference-addressable
12375-fmerge-constants
12376-fmove-loop-invariants
12377-fmove-loop-stores
12378-fomit-frame-pointer
12379-freorder-blocks
12380-fshrink-wrap
12381-fshrink-wrap-separate
12382-fsplit-wide-types
12383-fssa-backprop
12384-fssa-phiopt
12385-ftree-bit-ccp
12386-ftree-ccp
12387-ftree-ch
12388-ftree-coalesce-vars
12389-ftree-copy-prop
12390-ftree-dce
12391-ftree-dominator-opts
12392-ftree-dse
12393-ftree-forwprop
12394-ftree-fre
12395-ftree-phiprop
12396-ftree-pta
12397-ftree-scev-cprop
12398-ftree-sink
12399-ftree-slsr
12400-ftree-sra
12401-ftree-ter
d77de738
ML
12402-funit-at-a-time}
12403
d77de738 12404@opindex O2
ddf6fe37 12405@item -O2
d77de738
ML
12406Optimize even more. GCC performs nearly all supported optimizations
12407that do not involve a space-speed tradeoff.
12408As compared to @option{-O}, this option increases both compilation time
12409and the performance of the generated code.
12410
12411@option{-O2} turns on all optimization flags specified by @option{-O1}. It
12412also turns on the following optimization flags:
12413
12414@c Please keep the following list alphabetized!
43b72ede
AA
12415@gccoptlist{-falign-functions -falign-jumps
12416-falign-labels -falign-loops
12417-fcaller-saves
12418-fcode-hoisting
12419-fcrossjumping
12420-fcse-follow-jumps -fcse-skip-blocks
12421-fdelete-null-pointer-checks
12422-fdevirtualize -fdevirtualize-speculatively
12423-fexpensive-optimizations
12424-ffinite-loops
12425-fgcse -fgcse-lm
12426-fhoist-adjacent-loads
12427-finline-functions
12428-finline-small-functions
12429-findirect-inlining
12430-fipa-bit-cp -fipa-cp -fipa-icf
12431-fipa-ra -fipa-sra -fipa-vrp
12432-fisolate-erroneous-paths-dereference
12433-flra-remat
12434-foptimize-sibling-calls
12435-foptimize-strlen
12436-fpartial-inlining
12437-fpeephole2
12438-freorder-blocks-algorithm=stc
12439-freorder-blocks-and-partition -freorder-functions
12440-frerun-cse-after-loop
12441-fschedule-insns -fschedule-insns2
12442-fsched-interblock -fsched-spec
12443-fstore-merging
12444-fstrict-aliasing
12445-fthread-jumps
12446-ftree-builtin-call-dce
12447-ftree-loop-vectorize
12448-ftree-pre
12449-ftree-slp-vectorize
12450-ftree-switch-conversion -ftree-tail-merge
12451-ftree-vrp
d77de738
ML
12452-fvect-cost-model=very-cheap}
12453
12454Please note the warning under @option{-fgcse} about
12455invoking @option{-O2} on programs that use computed gotos.
12456
d77de738 12457@opindex O3
ddf6fe37 12458@item -O3
d77de738
ML
12459Optimize yet more. @option{-O3} turns on all optimizations specified
12460by @option{-O2} and also turns on the following optimization flags:
12461
12462@c Please keep the following list alphabetized!
43b72ede 12463@gccoptlist{-fgcse-after-reload
d77de738 12464-fipa-cp-clone
43b72ede
AA
12465-floop-interchange
12466-floop-unroll-and-jam
12467-fpeel-loops
12468-fpredictive-commoning
12469-fsplit-loops
12470-fsplit-paths
12471-ftree-loop-distribution
12472-ftree-partial-pre
12473-funswitch-loops
12474-fvect-cost-model=dynamic
d77de738
ML
12475-fversion-loops-for-strides}
12476
d77de738 12477@opindex O0
ddf6fe37 12478@item -O0
d77de738
ML
12479Reduce compilation time and make debugging produce the expected
12480results. This is the default.
12481
d77de738 12482@opindex Os
ddf6fe37 12483@item -Os
d77de738
ML
12484Optimize for size. @option{-Os} enables all @option{-O2} optimizations
12485except those that often increase code size:
12486
43b72ede
AA
12487@gccoptlist{-falign-functions -falign-jumps
12488-falign-labels -falign-loops
d77de738
ML
12489-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
12490
12491It also enables @option{-finline-functions}, causes the compiler to tune for
12492code size rather than execution speed, and performs further optimizations
12493designed to reduce code size.
12494
d77de738 12495@opindex Ofast
ddf6fe37 12496@item -Ofast
d77de738
ML
12497Disregard strict standards compliance. @option{-Ofast} enables all
12498@option{-O3} optimizations. It also enables optimizations that are not
12499valid for all standard-compliant programs.
12500It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
12501and the Fortran-specific @option{-fstack-arrays}, unless
12502@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
12503It turns off @option{-fsemantic-interposition}.
12504
d77de738 12505@opindex Og
ddf6fe37 12506@item -Og
d77de738
ML
12507Optimize debugging experience. @option{-Og} should be the optimization
12508level of choice for the standard edit-compile-debug cycle, offering
12509a reasonable level of optimization while maintaining fast compilation
12510and a good debugging experience. It is a better choice than @option{-O0}
12511for producing debuggable code because some compiler passes
12512that collect debug information are disabled at @option{-O0}.
12513
12514Like @option{-O0}, @option{-Og} completely disables a number of
12515optimization passes so that individual options controlling them have
12516no effect. Otherwise @option{-Og} enables all @option{-O1}
12517optimization flags except for those that may interfere with debugging:
12518
43b72ede
AA
12519@gccoptlist{-fbranch-count-reg -fdelayed-branch
12520-fdse -fif-conversion -fif-conversion2
12521-finline-functions-called-once
12522-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt
d77de738
ML
12523-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
12524
d77de738 12525@opindex Oz
ddf6fe37 12526@item -Oz
d77de738
ML
12527Optimize aggressively for size rather than speed. This may increase
12528the number of instructions executed if those instructions require
12529fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
12530including enabling most @option{-O2} optimizations.
12531
12532@end table
12533
12534If you use multiple @option{-O} options, with or without level numbers,
12535the last such option is the one that is effective.
12536
12537Options of the form @option{-f@var{flag}} specify machine-independent
12538flags. Most flags have both positive and negative forms; the negative
12539form of @option{-ffoo} is @option{-fno-foo}. In the table
12540below, only one of the forms is listed---the one you typically
12541use. You can figure out the other form by either removing @samp{no-}
12542or adding it.
12543
12544The following options control specific optimizations. They are either
12545activated by @option{-O} options or are related to ones that are. You
12546can use the following flags in the rare cases when ``fine-tuning'' of
12547optimizations to be performed is desired.
12548
12549@table @gcctabopt
d77de738
ML
12550@opindex fno-defer-pop
12551@opindex fdefer-pop
ddf6fe37 12552@item -fno-defer-pop
d77de738
ML
12553For machines that must pop arguments after a function call, always pop
12554the arguments as soon as each function returns.
12555At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
12556this allows the compiler to let arguments accumulate on the stack for several
12557function calls and pop them all at once.
12558
d77de738 12559@opindex fforward-propagate
ddf6fe37 12560@item -fforward-propagate
d77de738
ML
12561Perform a forward propagation pass on RTL@. The pass tries to combine two
12562instructions and checks if the result can be simplified. If loop unrolling
12563is active, two passes are performed and the second is scheduled after
12564loop unrolling.
12565
12566This option is enabled by default at optimization levels @option{-O1},
12567@option{-O2}, @option{-O3}, @option{-Os}.
12568
d77de738 12569@opindex ffp-contract
ddf6fe37 12570@item -ffp-contract=@var{style}
d77de738
ML
12571@option{-ffp-contract=off} disables floating-point expression contraction.
12572@option{-ffp-contract=fast} enables floating-point expression contraction
12573such as forming of fused multiply-add operations if the target has
12574native support for them.
12575@option{-ffp-contract=on} enables floating-point expression contraction
1c1dd396
AM
12576if allowed by the language standard. This is implemented for C and C++,
12577where it enables contraction within one expression, but not across
12578different statements.
d77de738 12579
1c1dd396
AM
12580The default is @option{-ffp-contract=off} for C in a standards compliant mode
12581(@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise.
d77de738 12582
d77de738 12583@opindex fomit-frame-pointer
ddf6fe37 12584@item -fomit-frame-pointer
d77de738
ML
12585Omit the frame pointer in functions that don't need one. This avoids the
12586instructions to save, set up and restore the frame pointer; on many targets
12587it also makes an extra register available.
12588
12589On some targets this flag has no effect because the standard calling sequence
12590always uses a frame pointer, so it cannot be omitted.
12591
12592Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
12593is used in all functions. Several targets always omit the frame pointer in
12594leaf functions.
12595
12596Enabled by default at @option{-O1} and higher.
12597
d77de738 12598@opindex foptimize-sibling-calls
ddf6fe37 12599@item -foptimize-sibling-calls
d77de738
ML
12600Optimize sibling and tail recursive calls.
12601
12602Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12603
d77de738 12604@opindex foptimize-strlen
ddf6fe37 12605@item -foptimize-strlen
d77de738
ML
12606Optimize various standard C string functions (e.g.@: @code{strlen},
12607@code{strchr} or @code{strcpy}) and
12608their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
12609
12610Enabled at levels @option{-O2}, @option{-O3}.
12611
1ff6d9f7
AO
12612@opindex finline-stringops
12613@item -finline-stringops[=@var{fn}]
12614Expand memory and string operations (for now, only @code{memset})
12615inline, even when the length is variable or big enough as to require
12616looping. This is most useful along with @option{-ffreestanding} and
12617@option{-fno-builtin}.
12618
12619In some circumstances, it enables the compiler to generate code that
12620takes advantage of known alignment and length multipliers, but even then
12621it may be less efficient than optimized runtime implementations, and
12622grow code size so much that even a less performant but shared
12623implementation runs faster due to better use of code caches. This
12624option is disabled by default.
12625
d77de738
ML
12626@opindex fno-inline
12627@opindex finline
ddf6fe37 12628@item -fno-inline
d77de738
ML
12629Do not expand any functions inline apart from those marked with
12630the @code{always_inline} attribute. This is the default when not
12631optimizing.
12632
12633Single functions can be exempted from inlining by marking them
12634with the @code{noinline} attribute.
12635
d77de738 12636@opindex finline-small-functions
ddf6fe37 12637@item -finline-small-functions
d77de738
ML
12638Integrate functions into their callers when their body is smaller than expected
12639function call code (so overall size of program gets smaller). The compiler
12640heuristically decides which functions are simple enough to be worth integrating
12641in this way. This inlining applies to all functions, even those not declared
12642inline.
12643
12644Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12645
d77de738 12646@opindex findirect-inlining
ddf6fe37 12647@item -findirect-inlining
d77de738
ML
12648Inline also indirect calls that are discovered to be known at compile
12649time thanks to previous inlining. This option has any effect only
12650when inlining itself is turned on by the @option{-finline-functions}
12651or @option{-finline-small-functions} options.
12652
12653Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12654
d77de738 12655@opindex finline-functions
ddf6fe37 12656@item -finline-functions
d77de738
ML
12657Consider all functions for inlining, even if they are not declared inline.
12658The compiler heuristically decides which functions are worth integrating
12659in this way.
12660
12661If all calls to a given function are integrated, and the function is
12662declared @code{static}, then the function is normally not output as
12663assembler code in its own right.
12664
12665Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
12666by @option{-fprofile-use} and @option{-fauto-profile}.
12667
d77de738 12668@opindex finline-functions-called-once
ddf6fe37 12669@item -finline-functions-called-once
d77de738
ML
12670Consider all @code{static} functions called once for inlining into their
12671caller even if they are not marked @code{inline}. If a call to a given
12672function is integrated, then the function is not output as assembler code
12673in its own right.
12674
12675Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
12676but not @option{-Og}.
12677
d77de738 12678@opindex fearly-inlining
ddf6fe37 12679@item -fearly-inlining
d77de738
ML
12680Inline functions marked by @code{always_inline} and functions whose body seems
12681smaller than the function call overhead early before doing
12682@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
12683makes profiling significantly cheaper and usually inlining faster on programs
12684having large chains of nested wrapper functions.
12685
12686Enabled by default.
12687
d77de738 12688@opindex fipa-sra
ddf6fe37 12689@item -fipa-sra
d77de738
ML
12690Perform interprocedural scalar replacement of aggregates, removal of
12691unused parameters and replacement of parameters passed by reference
12692by parameters passed by value.
12693
12694Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12695
d77de738 12696@opindex finline-limit
ddf6fe37 12697@item -finline-limit=@var{n}
d77de738
ML
12698By default, GCC limits the size of functions that can be inlined. This flag
12699allows coarse control of this limit. @var{n} is the size of functions that
12700can be inlined in number of pseudo instructions.
12701
12702Inlining is actually controlled by a number of parameters, which may be
12703specified individually by using @option{--param @var{name}=@var{value}}.
12704The @option{-finline-limit=@var{n}} option sets some of these parameters
12705as follows:
12706
12707@table @gcctabopt
12708@item max-inline-insns-single
12709is set to @var{n}/2.
12710@item max-inline-insns-auto
12711is set to @var{n}/2.
12712@end table
12713
12714See below for a documentation of the individual
12715parameters controlling inlining and for the defaults of these parameters.
12716
12717@emph{Note:} there may be no value to @option{-finline-limit} that results
12718in default behavior.
12719
12720@emph{Note:} pseudo instruction represents, in this particular context, an
12721abstract measurement of function's size. In no way does it represent a count
12722of assembly instructions and as such its exact meaning might change from one
12723release to an another.
12724
d77de738
ML
12725@opindex fno-keep-inline-dllexport
12726@opindex fkeep-inline-dllexport
ddf6fe37 12727@item -fno-keep-inline-dllexport
d77de738
ML
12728This is a more fine-grained version of @option{-fkeep-inline-functions},
12729which applies only to functions that are declared using the @code{dllexport}
12730attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12731Functions}.
12732
d77de738 12733@opindex fkeep-inline-functions
ddf6fe37 12734@item -fkeep-inline-functions
d77de738
ML
12735In C, emit @code{static} functions that are declared @code{inline}
12736into the object file, even if the function has been inlined into all
12737of its callers. This switch does not affect functions using the
12738@code{extern inline} extension in GNU C90@. In C++, emit any and all
12739inline functions into the object file.
12740
d77de738 12741@opindex fkeep-static-functions
ddf6fe37 12742@item -fkeep-static-functions
d77de738
ML
12743Emit @code{static} functions into the object file, even if the function
12744is never used.
12745
d77de738 12746@opindex fkeep-static-consts
ddf6fe37 12747@item -fkeep-static-consts
d77de738
ML
12748Emit variables declared @code{static const} when optimization isn't turned
12749on, even if the variables aren't referenced.
12750
12751GCC enables this option by default. If you want to force the compiler to
12752check if a variable is referenced, regardless of whether or not
12753optimization is turned on, use the @option{-fno-keep-static-consts} option.
12754
d77de738 12755@opindex fmerge-constants
ddf6fe37 12756@item -fmerge-constants
d77de738
ML
12757Attempt to merge identical constants (string constants and floating-point
12758constants) across compilation units.
12759
12760This option is the default for optimized compilation if the assembler and
12761linker support it. Use @option{-fno-merge-constants} to inhibit this
12762behavior.
12763
12764Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12765
d77de738 12766@opindex fmerge-all-constants
ddf6fe37 12767@item -fmerge-all-constants
d77de738
ML
12768Attempt to merge identical constants and identical variables.
12769
12770This option implies @option{-fmerge-constants}. In addition to
12771@option{-fmerge-constants} this considers e.g.@: even constant initialized
12772arrays or initialized constant variables with integral or floating-point
12773types. Languages like C or C++ require each variable, including multiple
12774instances of the same variable in recursive calls, to have distinct locations,
12775so using this option results in non-conforming
12776behavior.
12777
d77de738 12778@opindex fmodulo-sched
ddf6fe37 12779@item -fmodulo-sched
d77de738
ML
12780Perform swing modulo scheduling immediately before the first scheduling
12781pass. This pass looks at innermost loops and reorders their
12782instructions by overlapping different iterations.
12783
d77de738 12784@opindex fmodulo-sched-allow-regmoves
ddf6fe37 12785@item -fmodulo-sched-allow-regmoves
d77de738
ML
12786Perform more aggressive SMS-based modulo scheduling with register moves
12787allowed. By setting this flag certain anti-dependences edges are
12788deleted, which triggers the generation of reg-moves based on the
12789life-range analysis. This option is effective only with
12790@option{-fmodulo-sched} enabled.
12791
d77de738
ML
12792@opindex fno-branch-count-reg
12793@opindex fbranch-count-reg
ddf6fe37 12794@item -fno-branch-count-reg
d77de738
ML
12795Disable the optimization pass that scans for opportunities to use
12796``decrement and branch'' instructions on a count register instead of
12797instruction sequences that decrement a register, compare it against zero, and
12798then branch based upon the result. This option is only meaningful on
12799architectures that support such instructions, which include x86, PowerPC,
12800IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12801doesn't remove the decrement and branch instructions from the generated
12802instruction stream introduced by other optimization passes.
12803
12804The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12805except for @option{-Og}.
12806
d77de738
ML
12807@opindex fno-function-cse
12808@opindex ffunction-cse
ddf6fe37 12809@item -fno-function-cse
d77de738
ML
12810Do not put function addresses in registers; make each instruction that
12811calls a constant function contain the function's address explicitly.
12812
12813This option results in less efficient code, but some strange hacks
12814that alter the assembler output may be confused by the optimizations
12815performed when this option is not used.
12816
12817The default is @option{-ffunction-cse}
12818
d77de738
ML
12819@opindex fno-zero-initialized-in-bss
12820@opindex fzero-initialized-in-bss
ddf6fe37 12821@item -fno-zero-initialized-in-bss
d77de738
ML
12822If the target supports a BSS section, GCC by default puts variables that
12823are initialized to zero into BSS@. This can save space in the resulting
12824code.
12825
12826This option turns off this behavior because some programs explicitly
12827rely on variables going to the data section---e.g., so that the
12828resulting executable can find the beginning of that section and/or make
12829assumptions based on that.
12830
12831The default is @option{-fzero-initialized-in-bss}.
12832
d77de738 12833@opindex fthread-jumps
ddf6fe37 12834@item -fthread-jumps
d77de738
ML
12835Perform optimizations that check to see if a jump branches to a
12836location where another comparison subsumed by the first is found. If
12837so, the first branch is redirected to either the destination of the
12838second branch or a point immediately following it, depending on whether
12839the condition is known to be true or false.
12840
12841Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12842
d77de738 12843@opindex fsplit-wide-types
ddf6fe37 12844@item -fsplit-wide-types
d77de738
ML
12845When using a type that occupies multiple registers, such as @code{long
12846long} on a 32-bit system, split the registers apart and allocate them
12847independently. This normally generates better code for those types,
12848but may make debugging more difficult.
12849
12850Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12851@option{-Os}.
12852
d77de738 12853@opindex fsplit-wide-types-early
ddf6fe37 12854@item -fsplit-wide-types-early
d77de738
ML
12855Fully split wide types early, instead of very late.
12856This option has no effect unless @option{-fsplit-wide-types} is turned on.
12857
12858This is the default on some targets.
12859
d77de738 12860@opindex fcse-follow-jumps
ddf6fe37 12861@item -fcse-follow-jumps
d77de738
ML
12862In common subexpression elimination (CSE), scan through jump instructions
12863when the target of the jump is not reached by any other path. For
12864example, when CSE encounters an @code{if} statement with an
12865@code{else} clause, CSE follows the jump when the condition
12866tested is false.
12867
12868Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12869
d77de738 12870@opindex fcse-skip-blocks
ddf6fe37 12871@item -fcse-skip-blocks
d77de738
ML
12872This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12873follow jumps that conditionally skip over blocks. When CSE
12874encounters a simple @code{if} statement with no else clause,
12875@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12876body of the @code{if}.
12877
12878Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12879
d77de738 12880@opindex frerun-cse-after-loop
ddf6fe37 12881@item -frerun-cse-after-loop
d77de738
ML
12882Re-run common subexpression elimination after loop optimizations are
12883performed.
12884
12885Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12886
d77de738 12887@opindex fgcse
ddf6fe37 12888@item -fgcse
d77de738
ML
12889Perform a global common subexpression elimination pass.
12890This pass also performs global constant and copy propagation.
12891
12892@emph{Note:} When compiling a program using computed gotos, a GCC
12893extension, you may get better run-time performance if you disable
12894the global common subexpression elimination pass by adding
12895@option{-fno-gcse} to the command line.
12896
12897Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12898
d77de738 12899@opindex fgcse-lm
ddf6fe37 12900@item -fgcse-lm
d77de738
ML
12901When @option{-fgcse-lm} is enabled, global common subexpression elimination
12902attempts to move loads that are only killed by stores into themselves. This
12903allows a loop containing a load/store sequence to be changed to a load outside
12904the loop, and a copy/store within the loop.
12905
12906Enabled by default when @option{-fgcse} is enabled.
12907
d77de738 12908@opindex fgcse-sm
ddf6fe37 12909@item -fgcse-sm
d77de738
ML
12910When @option{-fgcse-sm} is enabled, a store motion pass is run after
12911global common subexpression elimination. This pass attempts to move
12912stores out of loops. When used in conjunction with @option{-fgcse-lm},
12913loops containing a load/store sequence can be changed to a load before
12914the loop and a store after the loop.
12915
12916Not enabled at any optimization level.
12917
d77de738 12918@opindex fgcse-las
ddf6fe37 12919@item -fgcse-las
d77de738
ML
12920When @option{-fgcse-las} is enabled, the global common subexpression
12921elimination pass eliminates redundant loads that come after stores to the
12922same memory location (both partial and full redundancies).
12923
12924Not enabled at any optimization level.
12925
d77de738 12926@opindex fgcse-after-reload
ddf6fe37 12927@item -fgcse-after-reload
d77de738
ML
12928When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12929pass is performed after reload. The purpose of this pass is to clean up
12930redundant spilling.
12931
12932Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12933
d77de738 12934@opindex faggressive-loop-optimizations
ddf6fe37 12935@item -faggressive-loop-optimizations
d77de738
ML
12936This option tells the loop optimizer to use language constraints to
12937derive bounds for the number of iterations of a loop. This assumes that
12938loop code does not invoke undefined behavior by for example causing signed
12939integer overflows or out-of-bound array accesses. The bounds for the
12940number of iterations of a loop are used to guide loop unrolling and peeling
12941and loop exit test optimizations.
12942This option is enabled by default.
12943
d77de738 12944@opindex funconstrained-commons
ddf6fe37 12945@item -funconstrained-commons
d77de738
ML
12946This option tells the compiler that variables declared in common blocks
12947(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12948prevents certain optimizations that depend on knowing the array bounds.
12949
d77de738 12950@opindex fcrossjumping
ddf6fe37 12951@item -fcrossjumping
d77de738
ML
12952Perform cross-jumping transformation.
12953This transformation unifies equivalent code and saves code size. The
12954resulting code may or may not perform better than without cross-jumping.
12955
12956Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12957
d77de738 12958@opindex fauto-inc-dec
ddf6fe37 12959@item -fauto-inc-dec
d77de738
ML
12960Combine increments or decrements of addresses with memory accesses.
12961This pass is always skipped on architectures that do not have
12962instructions to support this. Enabled by default at @option{-O1} and
12963higher on architectures that support this.
12964
d77de738 12965@opindex fdce
ddf6fe37 12966@item -fdce
d77de738
ML
12967Perform dead code elimination (DCE) on RTL@.
12968Enabled by default at @option{-O1} and higher.
12969
d77de738 12970@opindex fdse
ddf6fe37 12971@item -fdse
d77de738
ML
12972Perform dead store elimination (DSE) on RTL@.
12973Enabled by default at @option{-O1} and higher.
12974
d77de738 12975@opindex fif-conversion
ddf6fe37 12976@item -fif-conversion
d77de738
ML
12977Attempt to transform conditional jumps into branch-less equivalents. This
12978includes use of conditional moves, min, max, set flags and abs instructions, and
12979some tricks doable by standard arithmetics. The use of conditional execution
12980on chips where it is available is controlled by @option{-fif-conversion2}.
12981
12982Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12983not with @option{-Og}.
12984
d77de738 12985@opindex fif-conversion2
ddf6fe37 12986@item -fif-conversion2
d77de738
ML
12987Use conditional execution (where available) to transform conditional jumps into
12988branch-less equivalents.
12989
12990Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12991not with @option{-Og}.
12992
d77de738 12993@opindex fdeclone-ctor-dtor
ddf6fe37 12994@item -fdeclone-ctor-dtor
d77de738
ML
12995The C++ ABI requires multiple entry points for constructors and
12996destructors: one for a base subobject, one for a complete object, and
12997one for a virtual destructor that calls operator delete afterwards.
12998For a hierarchy with virtual bases, the base and complete variants are
12999clones, which means two copies of the function. With this option, the
13000base and complete variants are changed to be thunks that call a common
13001implementation.
13002
13003Enabled by @option{-Os}.
13004
d77de738 13005@opindex fdelete-null-pointer-checks
ddf6fe37 13006@item -fdelete-null-pointer-checks
d77de738
ML
13007Assume that programs cannot safely dereference null pointers, and that
13008no code or data element resides at address zero.
13009This option enables simple constant
13010folding optimizations at all optimization levels. In addition, other
13011optimization passes in GCC use this flag to control global dataflow
13012analyses that eliminate useless checks for null pointers; these assume
13013that a memory access to address zero always results in a trap, so
13014that if a pointer is checked after it has already been dereferenced,
13015it cannot be null.
13016
13017Note however that in some environments this assumption is not true.
13018Use @option{-fno-delete-null-pointer-checks} to disable this optimization
13019for programs that depend on that behavior.
13020
13021This option is enabled by default on most targets. On Nios II ELF, it
13022defaults to off. On AVR and MSP430, this option is completely disabled.
13023
13024Passes that use the dataflow information
13025are enabled independently at different optimization levels.
13026
d77de738 13027@opindex fdevirtualize
ddf6fe37 13028@item -fdevirtualize
d77de738
ML
13029Attempt to convert calls to virtual functions to direct calls. This
13030is done both within a procedure and interprocedurally as part of
13031indirect inlining (@option{-findirect-inlining}) and interprocedural constant
13032propagation (@option{-fipa-cp}).
13033Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13034
d77de738 13035@opindex fdevirtualize-speculatively
ddf6fe37 13036@item -fdevirtualize-speculatively
d77de738
ML
13037Attempt to convert calls to virtual functions to speculative direct calls.
13038Based on the analysis of the type inheritance graph, determine for a given call
13039the set of likely targets. If the set is small, preferably of size 1, change
13040the call into a conditional deciding between direct and indirect calls. The
13041speculative calls enable more optimizations, such as inlining. When they seem
13042useless after further optimization, they are converted back into original form.
13043
d77de738 13044@opindex fdevirtualize-at-ltrans
ddf6fe37 13045@item -fdevirtualize-at-ltrans
d77de738
ML
13046Stream extra information needed for aggressive devirtualization when running
13047the link-time optimizer in local transformation mode.
13048This option enables more devirtualization but
13049significantly increases the size of streamed data. For this reason it is
13050disabled by default.
13051
d77de738 13052@opindex fexpensive-optimizations
ddf6fe37 13053@item -fexpensive-optimizations
d77de738
ML
13054Perform a number of minor optimizations that are relatively expensive.
13055
13056Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13057
d77de738 13058@opindex free
ddf6fe37 13059@item -free
d77de738
ML
13060Attempt to remove redundant extension instructions. This is especially
13061helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
13062registers after writing to their lower 32-bit half.
13063
88ae53a3
LC
13064Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at
13065levels @option{-O2}, @option{-O3}, @option{-Os}.
d77de738 13066
d77de738
ML
13067@opindex fno-lifetime-dse
13068@opindex flifetime-dse
ddf6fe37 13069@item -fno-lifetime-dse
d77de738
ML
13070In C++ the value of an object is only affected by changes within its
13071lifetime: when the constructor begins, the object has an indeterminate
13072value, and any changes during the lifetime of the object are dead when
13073the object is destroyed. Normally dead store elimination will take
13074advantage of this; if your code relies on the value of the object
13075storage persisting beyond the lifetime of the object, you can use this
13076flag to disable this optimization. To preserve stores before the
13077constructor starts (e.g.@: because your operator new clears the object
13078storage) but still treat the object as dead after the destructor, you
13079can use @option{-flifetime-dse=1}. The default behavior can be
13080explicitly selected with @option{-flifetime-dse=2}.
13081@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
13082
d77de738 13083@opindex flive-range-shrinkage
ddf6fe37 13084@item -flive-range-shrinkage
d77de738
ML
13085Attempt to decrease register pressure through register live range
13086shrinkage. This is helpful for fast processors with small or moderate
13087size register sets.
13088
d77de738 13089@opindex fira-algorithm
ddf6fe37 13090@item -fira-algorithm=@var{algorithm}
d77de738
ML
13091Use the specified coloring algorithm for the integrated register
13092allocator. The @var{algorithm} argument can be @samp{priority}, which
13093specifies Chow's priority coloring, or @samp{CB}, which specifies
13094Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
13095for all architectures, but for those targets that do support it, it is
13096the default because it generates better code.
13097
d77de738 13098@opindex fira-region
ddf6fe37 13099@item -fira-region=@var{region}
d77de738
ML
13100Use specified regions for the integrated register allocator. The
13101@var{region} argument should be one of the following:
13102
13103@table @samp
13104
13105@item all
13106Use all loops as register allocation regions.
13107This can give the best results for machines with a small and/or
13108irregular register set.
13109
13110@item mixed
13111Use all loops except for loops with small register pressure
13112as the regions. This value usually gives
13113the best results in most cases and for most architectures,
13114and is enabled by default when compiling with optimization for speed
13115(@option{-O}, @option{-O2}, @dots{}).
13116
13117@item one
13118Use all functions as a single region.
13119This typically results in the smallest code size, and is enabled by default for
13120@option{-Os} or @option{-O0}.
13121
13122@end table
13123
d77de738 13124@opindex fira-hoist-pressure
ddf6fe37 13125@item -fira-hoist-pressure
d77de738
ML
13126Use IRA to evaluate register pressure in the code hoisting pass for
13127decisions to hoist expressions. This option usually results in smaller
13128code, but it can slow the compiler down.
13129
13130This option is enabled at level @option{-Os} for all targets.
13131
d77de738 13132@opindex fira-loop-pressure
ddf6fe37 13133@item -fira-loop-pressure
d77de738
ML
13134Use IRA to evaluate register pressure in loops for decisions to move
13135loop invariants. This option usually results in generation
13136of faster and smaller code on machines with large register files (>= 32
13137registers), but it can slow the compiler down.
13138
13139This option is enabled at level @option{-O3} for some targets.
13140
d77de738
ML
13141@opindex fno-ira-share-save-slots
13142@opindex fira-share-save-slots
ddf6fe37 13143@item -fno-ira-share-save-slots
d77de738
ML
13144Disable sharing of stack slots used for saving call-used hard
13145registers living through a call. Each hard register gets a
13146separate stack slot, and as a result function stack frames are
13147larger.
13148
d77de738
ML
13149@opindex fno-ira-share-spill-slots
13150@opindex fira-share-spill-slots
ddf6fe37 13151@item -fno-ira-share-spill-slots
d77de738
ML
13152Disable sharing of stack slots allocated for pseudo-registers. Each
13153pseudo-register that does not get a hard register gets a separate
13154stack slot, and as a result function stack frames are larger.
13155
d77de738 13156@opindex flra-remat
ddf6fe37 13157@item -flra-remat
d77de738
ML
13158Enable CFG-sensitive rematerialization in LRA. Instead of loading
13159values of spilled pseudos, LRA tries to rematerialize (recalculate)
13160values if it is profitable.
13161
13162Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13163
d77de738 13164@opindex fdelayed-branch
ddf6fe37 13165@item -fdelayed-branch
d77de738
ML
13166If supported for the target machine, attempt to reorder instructions
13167to exploit instruction slots available after delayed branch
13168instructions.
13169
13170Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
13171but not at @option{-Og}.
13172
d77de738 13173@opindex fschedule-insns
ddf6fe37 13174@item -fschedule-insns
d77de738
ML
13175If supported for the target machine, attempt to reorder instructions to
13176eliminate execution stalls due to required data being unavailable. This
13177helps machines that have slow floating point or memory load instructions
13178by allowing other instructions to be issued until the result of the load
13179or floating-point instruction is required.
13180
13181Enabled at levels @option{-O2}, @option{-O3}.
13182
d77de738 13183@opindex fschedule-insns2
ddf6fe37 13184@item -fschedule-insns2
d77de738
ML
13185Similar to @option{-fschedule-insns}, but requests an additional pass of
13186instruction scheduling after register allocation has been done. This is
13187especially useful on machines with a relatively small number of
13188registers and where memory load instructions take more than one cycle.
13189
13190Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13191
d77de738
ML
13192@opindex fno-sched-interblock
13193@opindex fsched-interblock
ddf6fe37 13194@item -fno-sched-interblock
d77de738
ML
13195Disable instruction scheduling across basic blocks, which
13196is normally enabled when scheduling before register allocation, i.e.@:
13197with @option{-fschedule-insns} or at @option{-O2} or higher.
13198
d77de738
ML
13199@opindex fno-sched-spec
13200@opindex fsched-spec
ddf6fe37 13201@item -fno-sched-spec
d77de738
ML
13202Disable speculative motion of non-load instructions, which
13203is normally enabled when scheduling before register allocation, i.e.@:
13204with @option{-fschedule-insns} or at @option{-O2} or higher.
13205
d77de738 13206@opindex fsched-pressure
ddf6fe37 13207@item -fsched-pressure
d77de738
ML
13208Enable register pressure sensitive insn scheduling before register
13209allocation. This only makes sense when scheduling before register
13210allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
13211@option{-O2} or higher. Usage of this option can improve the
13212generated code and decrease its size by preventing register pressure
13213increase above the number of available hard registers and subsequent
13214spills in register allocation.
13215
d77de738 13216@opindex fsched-spec-load
ddf6fe37 13217@item -fsched-spec-load
d77de738
ML
13218Allow speculative motion of some load instructions. This only makes
13219sense when scheduling before register allocation, i.e.@: with
13220@option{-fschedule-insns} or at @option{-O2} or higher.
13221
d77de738 13222@opindex fsched-spec-load-dangerous
ddf6fe37 13223@item -fsched-spec-load-dangerous
d77de738
ML
13224Allow speculative motion of more load instructions. This only makes
13225sense when scheduling before register allocation, i.e.@: with
13226@option{-fschedule-insns} or at @option{-O2} or higher.
13227
ddf6fe37 13228@opindex fsched-stalled-insns
d77de738
ML
13229@item -fsched-stalled-insns
13230@itemx -fsched-stalled-insns=@var{n}
d77de738
ML
13231Define how many insns (if any) can be moved prematurely from the queue
13232of stalled insns into the ready list during the second scheduling pass.
13233@option{-fno-sched-stalled-insns} means that no insns are moved
13234prematurely, @option{-fsched-stalled-insns=0} means there is no limit
13235on how many queued insns can be moved prematurely.
13236@option{-fsched-stalled-insns} without a value is equivalent to
13237@option{-fsched-stalled-insns=1}.
13238
ddf6fe37 13239@opindex fsched-stalled-insns-dep
d77de738
ML
13240@item -fsched-stalled-insns-dep
13241@itemx -fsched-stalled-insns-dep=@var{n}
d77de738
ML
13242Define how many insn groups (cycles) are examined for a dependency
13243on a stalled insn that is a candidate for premature removal from the queue
13244of stalled insns. This has an effect only during the second scheduling pass,
13245and only if @option{-fsched-stalled-insns} is used.
13246@option{-fno-sched-stalled-insns-dep} is equivalent to
13247@option{-fsched-stalled-insns-dep=0}.
13248@option{-fsched-stalled-insns-dep} without a value is equivalent to
13249@option{-fsched-stalled-insns-dep=1}.
13250
d77de738 13251@opindex fsched2-use-superblocks
ddf6fe37 13252@item -fsched2-use-superblocks
d77de738
ML
13253When scheduling after register allocation, use superblock scheduling.
13254This allows motion across basic block boundaries,
13255resulting in faster schedules. This option is experimental, as not all machine
13256descriptions used by GCC model the CPU closely enough to avoid unreliable
13257results from the algorithm.
13258
13259This only makes sense when scheduling after register allocation, i.e.@: with
13260@option{-fschedule-insns2} or at @option{-O2} or higher.
13261
d77de738 13262@opindex fsched-group-heuristic
ddf6fe37 13263@item -fsched-group-heuristic
d77de738
ML
13264Enable the group heuristic in the scheduler. This heuristic favors
13265the instruction that belongs to a schedule group. This is enabled
13266by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
13267or @option{-fschedule-insns2} or at @option{-O2} or higher.
13268
d77de738 13269@opindex fsched-critical-path-heuristic
ddf6fe37 13270@item -fsched-critical-path-heuristic
d77de738
ML
13271Enable the critical-path heuristic in the scheduler. This heuristic favors
13272instructions on the critical path. This is enabled by default when
13273scheduling is enabled, i.e.@: with @option{-fschedule-insns}
13274or @option{-fschedule-insns2} or at @option{-O2} or higher.
13275
d77de738 13276@opindex fsched-spec-insn-heuristic
ddf6fe37 13277@item -fsched-spec-insn-heuristic
d77de738
ML
13278Enable the speculative instruction heuristic in the scheduler. This
13279heuristic favors speculative instructions with greater dependency weakness.
13280This is enabled by default when scheduling is enabled, i.e.@:
13281with @option{-fschedule-insns} or @option{-fschedule-insns2}
13282or at @option{-O2} or higher.
13283
d77de738 13284@opindex fsched-rank-heuristic
ddf6fe37 13285@item -fsched-rank-heuristic
d77de738
ML
13286Enable the rank heuristic in the scheduler. This heuristic favors
13287the instruction belonging to a basic block with greater size or frequency.
13288This is enabled by default when scheduling is enabled, i.e.@:
13289with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13290at @option{-O2} or higher.
13291
d77de738 13292@opindex fsched-last-insn-heuristic
ddf6fe37 13293@item -fsched-last-insn-heuristic
d77de738
ML
13294Enable the last-instruction heuristic in the scheduler. This heuristic
13295favors the instruction that is less dependent on the last instruction
13296scheduled. This is enabled by default when scheduling is enabled,
13297i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13298at @option{-O2} or higher.
13299
d77de738 13300@opindex fsched-dep-count-heuristic
ddf6fe37 13301@item -fsched-dep-count-heuristic
d77de738
ML
13302Enable the dependent-count heuristic in the scheduler. This heuristic
13303favors the instruction that has more instructions depending on it.
13304This is enabled by default when scheduling is enabled, i.e.@:
13305with @option{-fschedule-insns} or @option{-fschedule-insns2} or
13306at @option{-O2} or higher.
13307
d77de738 13308@opindex freschedule-modulo-scheduled-loops
ddf6fe37 13309@item -freschedule-modulo-scheduled-loops
d77de738
ML
13310Modulo scheduling is performed before traditional scheduling. If a loop
13311is modulo scheduled, later scheduling passes may change its schedule.
13312Use this option to control that behavior.
13313
d77de738 13314@opindex fselective-scheduling
ddf6fe37 13315@item -fselective-scheduling
d77de738
ML
13316Schedule instructions using selective scheduling algorithm. Selective
13317scheduling runs instead of the first scheduler pass.
13318
d77de738 13319@opindex fselective-scheduling2
ddf6fe37 13320@item -fselective-scheduling2
d77de738
ML
13321Schedule instructions using selective scheduling algorithm. Selective
13322scheduling runs instead of the second scheduler pass.
13323
d77de738 13324@opindex fsel-sched-pipelining
ddf6fe37 13325@item -fsel-sched-pipelining
d77de738
ML
13326Enable software pipelining of innermost loops during selective scheduling.
13327This option has no effect unless one of @option{-fselective-scheduling} or
13328@option{-fselective-scheduling2} is turned on.
13329
d77de738 13330@opindex fsel-sched-pipelining-outer-loops
ddf6fe37 13331@item -fsel-sched-pipelining-outer-loops
d77de738
ML
13332When pipelining loops during selective scheduling, also pipeline outer loops.
13333This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
13334
d77de738 13335@opindex fsemantic-interposition
ddf6fe37 13336@item -fsemantic-interposition
d77de738
ML
13337Some object formats, like ELF, allow interposing of symbols by the
13338dynamic linker.
13339This means that for symbols exported from the DSO, the compiler cannot perform
13340interprocedural propagation, inlining and other optimizations in anticipation
13341that the function or variable in question may change. While this feature is
13342useful, for example, to rewrite memory allocation functions by a debugging
13343implementation, it is expensive in the terms of code quality.
13344With @option{-fno-semantic-interposition} the compiler assumes that
13345if interposition happens for functions the overwriting function will have
13346precisely the same semantics (and side effects).
13347Similarly if interposition happens
13348for variables, the constructor of the variable will be the same. The flag
13349has no effect for functions explicitly declared inline
13350(where it is never allowed for interposition to change semantics)
13351and for symbols explicitly declared weak.
13352
d77de738 13353@opindex fshrink-wrap
ddf6fe37 13354@item -fshrink-wrap
d77de738
ML
13355Emit function prologues only before parts of the function that need it,
13356rather than at the top of the function. This flag is enabled by default at
13357@option{-O} and higher.
13358
d77de738 13359@opindex fshrink-wrap-separate
ddf6fe37 13360@item -fshrink-wrap-separate
d77de738
ML
13361Shrink-wrap separate parts of the prologue and epilogue separately, so that
13362those parts are only executed when needed.
13363This option is on by default, but has no effect unless @option{-fshrink-wrap}
13364is also turned on and the target supports this.
13365
d77de738 13366@opindex fcaller-saves
ddf6fe37 13367@item -fcaller-saves
d77de738
ML
13368Enable allocation of values to registers that are clobbered by
13369function calls, by emitting extra instructions to save and restore the
13370registers around such calls. Such allocation is done only when it
13371seems to result in better code.
13372
13373This option is always enabled by default on certain machines, usually
13374those which have no call-preserved registers to use instead.
13375
13376Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13377
d77de738 13378@opindex fcombine-stack-adjustments
ddf6fe37 13379@item -fcombine-stack-adjustments
d77de738
ML
13380Tracks stack adjustments (pushes and pops) and stack memory references
13381and then tries to find ways to combine them.
13382
13383Enabled by default at @option{-O1} and higher.
13384
d77de738 13385@opindex fipa-ra
ddf6fe37 13386@item -fipa-ra
d77de738
ML
13387Use caller save registers for allocation if those registers are not used by
13388any called function. In that case it is not necessary to save and restore
13389them around calls. This is only possible if called functions are part of
13390same compilation unit as current function and they are compiled before it.
13391
13392Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
13393is disabled if generated code will be instrumented for profiling
13394(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
13395exactly (this happens on targets that do not expose prologues
13396and epilogues in RTL).
13397
d77de738 13398@opindex fconserve-stack
ddf6fe37 13399@item -fconserve-stack
d77de738
ML
13400Attempt to minimize stack usage. The compiler attempts to use less
13401stack space, even if that makes the program slower. This option
13402implies setting the @option{large-stack-frame} parameter to 100
13403and the @option{large-stack-frame-growth} parameter to 400.
13404
d77de738 13405@opindex ftree-reassoc
ddf6fe37 13406@item -ftree-reassoc
d77de738
ML
13407Perform reassociation on trees. This flag is enabled by default
13408at @option{-O1} and higher.
13409
d77de738 13410@opindex fcode-hoisting
ddf6fe37 13411@item -fcode-hoisting
d77de738
ML
13412Perform code hoisting. Code hoisting tries to move the
13413evaluation of expressions executed on all paths to the function exit
13414as early as possible. This is especially useful as a code size
13415optimization, but it often helps for code speed as well.
13416This flag is enabled by default at @option{-O2} and higher.
13417
d77de738 13418@opindex ftree-pre
ddf6fe37 13419@item -ftree-pre
d77de738
ML
13420Perform partial redundancy elimination (PRE) on trees. This flag is
13421enabled by default at @option{-O2} and @option{-O3}.
13422
d77de738 13423@opindex ftree-partial-pre
ddf6fe37 13424@item -ftree-partial-pre
d77de738
ML
13425Make partial redundancy elimination (PRE) more aggressive. This flag is
13426enabled by default at @option{-O3}.
13427
d77de738 13428@opindex ftree-forwprop
ddf6fe37 13429@item -ftree-forwprop
d77de738
ML
13430Perform forward propagation on trees. This flag is enabled by default
13431at @option{-O1} and higher.
13432
d77de738 13433@opindex ftree-fre
ddf6fe37 13434@item -ftree-fre
d77de738
ML
13435Perform full redundancy elimination (FRE) on trees. The difference
13436between FRE and PRE is that FRE only considers expressions
13437that are computed on all paths leading to the redundant computation.
13438This analysis is faster than PRE, though it exposes fewer redundancies.
13439This flag is enabled by default at @option{-O1} and higher.
13440
d77de738 13441@opindex ftree-phiprop
ddf6fe37 13442@item -ftree-phiprop
d77de738
ML
13443Perform hoisting of loads from conditional pointers on trees. This
13444pass is enabled by default at @option{-O1} and higher.
13445
d77de738 13446@opindex fhoist-adjacent-loads
ddf6fe37 13447@item -fhoist-adjacent-loads
d77de738
ML
13448Speculatively hoist loads from both branches of an if-then-else if the
13449loads are from adjacent locations in the same structure and the target
13450architecture has a conditional move instruction. This flag is enabled
13451by default at @option{-O2} and higher.
13452
d77de738 13453@opindex ftree-copy-prop
ddf6fe37 13454@item -ftree-copy-prop
d77de738
ML
13455Perform copy propagation on trees. This pass eliminates unnecessary
13456copy operations. This flag is enabled by default at @option{-O1} and
13457higher.
13458
d77de738 13459@opindex fipa-pure-const
ddf6fe37 13460@item -fipa-pure-const
d77de738
ML
13461Discover which functions are pure or constant.
13462Enabled by default at @option{-O1} and higher.
13463
d77de738 13464@opindex fipa-reference
ddf6fe37 13465@item -fipa-reference
d77de738
ML
13466Discover which static variables do not escape the
13467compilation unit.
13468Enabled by default at @option{-O1} and higher.
13469
d77de738 13470@opindex fipa-reference-addressable
ddf6fe37 13471@item -fipa-reference-addressable
d77de738
ML
13472Discover read-only, write-only and non-addressable static variables.
13473Enabled by default at @option{-O1} and higher.
13474
d77de738 13475@opindex fipa-stack-alignment
ddf6fe37 13476@item -fipa-stack-alignment
d77de738
ML
13477Reduce stack alignment on call sites if possible.
13478Enabled by default.
13479
d77de738 13480@opindex fipa-pta
ddf6fe37 13481@item -fipa-pta
d77de738
ML
13482Perform interprocedural pointer analysis and interprocedural modification
13483and reference analysis. This option can cause excessive memory and
13484compile-time usage on large compilation units. It is not enabled by
13485default at any optimization level.
13486
d77de738 13487@opindex fipa-profile
ddf6fe37 13488@item -fipa-profile
d77de738
ML
13489Perform interprocedural profile propagation. The functions called only from
13490cold functions are marked as cold. Also functions executed once (such as
13491@code{cold}, @code{noreturn}, static constructors or destructors) are
13492identified. Cold functions and loop less parts of functions executed once are
13493then optimized for size.
13494Enabled by default at @option{-O1} and higher.
13495
d77de738 13496@opindex fipa-modref
ddf6fe37 13497@item -fipa-modref
d77de738
ML
13498Perform interprocedural mod/ref analysis. This optimization analyzes the side
13499effects of functions (memory locations that are modified or referenced) and
13500enables better optimization across the function call boundary. This flag is
13501enabled by default at @option{-O1} and higher.
13502
d77de738 13503@opindex fipa-cp
ddf6fe37 13504@item -fipa-cp
d77de738
ML
13505Perform interprocedural constant propagation.
13506This optimization analyzes the program to determine when values passed
13507to functions are constants and then optimizes accordingly.
13508This optimization can substantially increase performance
13509if the application has constants passed to functions.
13510This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
13511It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13512
d77de738 13513@opindex fipa-cp-clone
ddf6fe37 13514@item -fipa-cp-clone
d77de738
ML
13515Perform function cloning to make interprocedural constant propagation stronger.
13516When enabled, interprocedural constant propagation performs function cloning
13517when externally visible function can be called with constant arguments.
13518Because this optimization can create multiple copies of functions,
13519it may significantly increase code size
13520(see @option{--param ipa-cp-unit-growth=@var{value}}).
13521This flag is enabled by default at @option{-O3}.
13522It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13523
d77de738 13524@opindex fipa-bit-cp
ddf6fe37 13525@item -fipa-bit-cp
d77de738
ML
13526When enabled, perform interprocedural bitwise constant
13527propagation. This flag is enabled by default at @option{-O2} and
13528by @option{-fprofile-use} and @option{-fauto-profile}.
13529It requires that @option{-fipa-cp} is enabled.
13530
d77de738 13531@opindex fipa-vrp
ddf6fe37 13532@item -fipa-vrp
d77de738
ML
13533When enabled, perform interprocedural propagation of value
13534ranges. This flag is enabled by default at @option{-O2}. It requires
13535that @option{-fipa-cp} is enabled.
13536
d77de738 13537@opindex fipa-icf
ddf6fe37 13538@item -fipa-icf
d77de738
ML
13539Perform Identical Code Folding for functions and read-only variables.
13540The optimization reduces code size and may disturb unwind stacks by replacing
13541a function by equivalent one with a different name. The optimization works
13542more effectively with link-time optimization enabled.
13543
13544Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
13545works on different levels and thus the optimizations are not same - there are
13546equivalences that are found only by GCC and equivalences found only by Gold.
13547
13548This flag is enabled by default at @option{-O2} and @option{-Os}.
13549
d77de738 13550@opindex flive-patching
ddf6fe37 13551@item -flive-patching=@var{level}
d77de738
ML
13552Control GCC's optimizations to produce output suitable for live-patching.
13553
13554If the compiler's optimization uses a function's body or information extracted
13555from its body to optimize/change another function, the latter is called an
13556impacted function of the former. If a function is patched, its impacted
13557functions should be patched too.
13558
13559The impacted functions are determined by the compiler's interprocedural
13560optimizations. For example, a caller is impacted when inlining a function
13561into its caller,
13562cloning a function and changing its caller to call this new clone,
13563or extracting a function's pureness/constness information to optimize
13564its direct or indirect callers, etc.
13565
13566Usually, the more IPA optimizations enabled, the larger the number of
13567impacted functions for each function. In order to control the number of
13568impacted functions and more easily compute the list of impacted function,
13569IPA optimizations can be partially enabled at two different levels.
13570
13571The @var{level} argument should be one of the following:
13572
13573@table @samp
13574
13575@item inline-clone
13576
13577Only enable inlining and cloning optimizations, which includes inlining,
13578cloning, interprocedural scalar replacement of aggregates and partial inlining.
13579As a result, when patching a function, all its callers and its clones'
13580callers are impacted, therefore need to be patched as well.
13581
13582@option{-flive-patching=inline-clone} disables the following optimization flags:
43b72ede
AA
13583@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra
13584-fipa-icf -fipa-icf-functions -fipa-icf-variables
13585-fipa-bit-cp -fipa-vrp -fipa-pure-const
13586-fipa-reference-addressable
d77de738
ML
13587-fipa-stack-alignment -fipa-modref}
13588
13589@item inline-only-static
13590
13591Only enable inlining of static functions.
13592As a result, when patching a static function, all its callers are impacted
13593and so need to be patched as well.
13594
13595In addition to all the flags that @option{-flive-patching=inline-clone}
13596disables,
13597@option{-flive-patching=inline-only-static} disables the following additional
13598optimization flags:
13599@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
13600
13601@end table
13602
13603When @option{-flive-patching} is specified without any value, the default value
13604is @var{inline-clone}.
13605
13606This flag is disabled by default.
13607
13608Note that @option{-flive-patching} is not supported with link-time optimization
13609(@option{-flto}).
13610
d77de738 13611@opindex fisolate-erroneous-paths-dereference
ddf6fe37 13612@item -fisolate-erroneous-paths-dereference
d77de738
ML
13613Detect paths that trigger erroneous or undefined behavior due to
13614dereferencing a null pointer. Isolate those paths from the main control
13615flow and turn the statement with erroneous or undefined behavior into a trap.
13616This flag is enabled by default at @option{-O2} and higher and depends on
13617@option{-fdelete-null-pointer-checks} also being enabled.
13618
d77de738 13619@opindex fisolate-erroneous-paths-attribute
ddf6fe37 13620@item -fisolate-erroneous-paths-attribute
d77de738
ML
13621Detect paths that trigger erroneous or undefined behavior due to a null value
13622being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
13623attribute. Isolate those paths from the main control flow and turn the
13624statement with erroneous or undefined behavior into a trap. This is not
13625currently enabled, but may be enabled by @option{-O2} in the future.
13626
d77de738 13627@opindex ftree-sink
ddf6fe37 13628@item -ftree-sink
d77de738
ML
13629Perform forward store motion on trees. This flag is
13630enabled by default at @option{-O1} and higher.
13631
d77de738 13632@opindex ftree-bit-ccp
ddf6fe37 13633@item -ftree-bit-ccp
d77de738
ML
13634Perform sparse conditional bit constant propagation on trees and propagate
13635pointer alignment information.
13636This pass only operates on local scalar variables and is enabled by default
13637at @option{-O1} and higher, except for @option{-Og}.
13638It requires that @option{-ftree-ccp} is enabled.
13639
d77de738 13640@opindex ftree-ccp
ddf6fe37 13641@item -ftree-ccp
d77de738
ML
13642Perform sparse conditional constant propagation (CCP) on trees. This
13643pass only operates on local scalar variables and is enabled by default
13644at @option{-O1} and higher.
13645
d77de738 13646@opindex fssa-backprop
ddf6fe37 13647@item -fssa-backprop
d77de738
ML
13648Propagate information about uses of a value up the definition chain
13649in order to simplify the definitions. For example, this pass strips
13650sign operations if the sign of a value never matters. The flag is
13651enabled by default at @option{-O1} and higher.
13652
d77de738 13653@opindex fssa-phiopt
ddf6fe37 13654@item -fssa-phiopt
d77de738
ML
13655Perform pattern matching on SSA PHI nodes to optimize conditional
13656code. This pass is enabled by default at @option{-O1} and higher,
13657except for @option{-Og}.
13658
d77de738 13659@opindex ftree-switch-conversion
ddf6fe37 13660@item -ftree-switch-conversion
d77de738
ML
13661Perform conversion of simple initializations in a switch to
13662initializations from a scalar array. This flag is enabled by default
13663at @option{-O2} and higher.
13664
d77de738 13665@opindex ftree-tail-merge
ddf6fe37 13666@item -ftree-tail-merge
d77de738
ML
13667Look for identical code sequences. When found, replace one with a jump to the
13668other. This optimization is known as tail merging or cross jumping. This flag
13669is enabled by default at @option{-O2} and higher. The compilation time
13670in this pass can
13671be limited using @option{max-tail-merge-comparisons} parameter and
13672@option{max-tail-merge-iterations} parameter.
13673
d77de738 13674@opindex ftree-dce
ddf6fe37 13675@item -ftree-dce
d77de738
ML
13676Perform dead code elimination (DCE) on trees. This flag is enabled by
13677default at @option{-O1} and higher.
13678
d77de738 13679@opindex ftree-builtin-call-dce
ddf6fe37 13680@item -ftree-builtin-call-dce
d77de738
ML
13681Perform conditional dead code elimination (DCE) for calls to built-in functions
13682that may set @code{errno} but are otherwise free of side effects. This flag is
13683enabled by default at @option{-O2} and higher if @option{-Os} is not also
13684specified.
13685
d77de738
ML
13686@opindex ffinite-loops
13687@opindex fno-finite-loops
ddf6fe37 13688@item -ffinite-loops
d77de738
ML
13689Assume that a loop with an exit will eventually take the exit and not loop
13690indefinitely. This allows the compiler to remove loops that otherwise have
13691no side-effects, not considering eventual endless looping as such.
13692
13693This option is enabled by default at @option{-O2} for C++ with -std=c++11
13694or higher.
13695
d77de738 13696@opindex ftree-dominator-opts
ddf6fe37 13697@item -ftree-dominator-opts
d77de738
ML
13698Perform a variety of simple scalar cleanups (constant/copy
13699propagation, redundancy elimination, range propagation and expression
13700simplification) based on a dominator tree traversal. This also
13701performs jump threading (to reduce jumps to jumps). This flag is
13702enabled by default at @option{-O1} and higher.
13703
d77de738 13704@opindex ftree-dse
ddf6fe37 13705@item -ftree-dse
d77de738
ML
13706Perform dead store elimination (DSE) on trees. A dead store is a store into
13707a memory location that is later overwritten by another store without
13708any intervening loads. In this case the earlier store can be deleted. This
13709flag is enabled by default at @option{-O1} and higher.
13710
d77de738 13711@opindex ftree-ch
ddf6fe37 13712@item -ftree-ch
d77de738
ML
13713Perform loop header copying on trees. This is beneficial since it increases
13714effectiveness of code motion optimizations. It also saves one jump. This flag
13715is enabled by default at @option{-O1} and higher. It is not enabled
13716for @option{-Os}, since it usually increases code size.
13717
d77de738 13718@opindex ftree-loop-optimize
ddf6fe37 13719@item -ftree-loop-optimize
d77de738
ML
13720Perform loop optimizations on trees. This flag is enabled by default
13721at @option{-O1} and higher.
13722
d77de738
ML
13723@opindex ftree-loop-linear
13724@opindex floop-strip-mine
13725@opindex floop-block
ddf6fe37
AA
13726@item -ftree-loop-linear
13727@itemx -floop-strip-mine
13728@itemx -floop-block
d77de738
ML
13729Perform loop nest optimizations. Same as
13730@option{-floop-nest-optimize}. To use this code transformation, GCC has
13731to be configured with @option{--with-isl} to enable the Graphite loop
13732transformation infrastructure.
13733
d77de738 13734@opindex fgraphite-identity
ddf6fe37 13735@item -fgraphite-identity
d77de738
ML
13736Enable the identity transformation for graphite. For every SCoP we generate
13737the polyhedral representation and transform it back to gimple. Using
13738@option{-fgraphite-identity} we can check the costs or benefits of the
13739GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13740are also performed by the code generator isl, like index splitting and
13741dead code elimination in loops.
13742
d77de738 13743@opindex floop-nest-optimize
ddf6fe37 13744@item -floop-nest-optimize
d77de738
ML
13745Enable the isl based loop nest optimizer. This is a generic loop nest
13746optimizer based on the Pluto optimization algorithms. It calculates a loop
13747structure optimized for data-locality and parallelism. This option
13748is experimental.
13749
d77de738 13750@opindex floop-parallelize-all
ddf6fe37 13751@item -floop-parallelize-all
d77de738
ML
13752Use the Graphite data dependence analysis to identify loops that can
13753be parallelized. Parallelize all the loops that can be analyzed to
13754not contain loop carried dependences without checking that it is
13755profitable to parallelize the loops.
13756
d77de738 13757@opindex ftree-coalesce-vars
ddf6fe37 13758@item -ftree-coalesce-vars
d77de738
ML
13759While transforming the program out of the SSA representation, attempt to
13760reduce copying by coalescing versions of different user-defined
13761variables, instead of just compiler temporaries. This may severely
13762limit the ability to debug an optimized program compiled with
13763@option{-fno-var-tracking-assignments}. In the negated form, this flag
13764prevents SSA coalescing of user variables. This option is enabled by
13765default if optimization is enabled, and it does very little otherwise.
13766
d77de738 13767@opindex ftree-loop-if-convert
ddf6fe37 13768@item -ftree-loop-if-convert
d77de738
ML
13769Attempt to transform conditional jumps in the innermost loops to
13770branch-less equivalents. The intent is to remove control-flow from
13771the innermost loops in order to improve the ability of the
13772vectorization pass to handle these loops. This is enabled by default
13773if vectorization is enabled.
13774
d77de738 13775@opindex ftree-loop-distribution
ddf6fe37 13776@item -ftree-loop-distribution
d77de738
ML
13777Perform loop distribution. This flag can improve cache performance on
13778big loop bodies and allow further loop optimizations, like
13779parallelization or vectorization, to take place. For example, the loop
13780@smallexample
13781DO I = 1, N
13782 A(I) = B(I) + C
13783 D(I) = E(I) * F
13784ENDDO
13785@end smallexample
13786is transformed to
13787@smallexample
13788DO I = 1, N
13789 A(I) = B(I) + C
13790ENDDO
13791DO I = 1, N
13792 D(I) = E(I) * F
13793ENDDO
13794@end smallexample
13795This flag is enabled by default at @option{-O3}.
13796It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13797
d77de738 13798@opindex ftree-loop-distribute-patterns
ddf6fe37 13799@item -ftree-loop-distribute-patterns
d77de738
ML
13800Perform loop distribution of patterns that can be code generated with
13801calls to a library. This flag is enabled by default at @option{-O2} and
13802higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13803
13804This pass distributes the initialization loops and generates a call to
13805memset zero. For example, the loop
13806@smallexample
13807DO I = 1, N
13808 A(I) = 0
13809 B(I) = A(I) + I
13810ENDDO
13811@end smallexample
13812is transformed to
13813@smallexample
13814DO I = 1, N
13815 A(I) = 0
13816ENDDO
13817DO I = 1, N
13818 B(I) = A(I) + I
13819ENDDO
13820@end smallexample
13821and the initialization loop is transformed into a call to memset zero.
13822This flag is enabled by default at @option{-O3}.
13823It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13824
d77de738 13825@opindex floop-interchange
ddf6fe37 13826@item -floop-interchange
d77de738
ML
13827Perform loop interchange outside of graphite. This flag can improve cache
13828performance on loop nest and allow further loop optimizations, like
13829vectorization, to take place. For example, the loop
13830@smallexample
13831for (int i = 0; i < N; i++)
13832 for (int j = 0; j < N; j++)
13833 for (int k = 0; k < N; k++)
13834 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13835@end smallexample
13836is transformed to
13837@smallexample
13838for (int i = 0; i < N; i++)
13839 for (int k = 0; k < N; k++)
13840 for (int j = 0; j < N; j++)
13841 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13842@end smallexample
13843This flag is enabled by default at @option{-O3}.
13844It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13845
d77de738 13846@opindex floop-unroll-and-jam
ddf6fe37 13847@item -floop-unroll-and-jam
d77de738
ML
13848Apply unroll and jam transformations on feasible loops. In a loop
13849nest this unrolls the outer loop by some factor and fuses the resulting
13850multiple inner loops. This flag is enabled by default at @option{-O3}.
13851It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13852
d77de738 13853@opindex ftree-loop-im
ddf6fe37 13854@item -ftree-loop-im
d77de738
ML
13855Perform loop invariant motion on trees. This pass moves only invariants that
13856are hard to handle at RTL level (function calls, operations that expand to
13857nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13858operands of conditions that are invariant out of the loop, so that we can use
13859just trivial invariantness analysis in loop unswitching. The pass also includes
13860store motion.
13861
d77de738 13862@opindex ftree-loop-ivcanon
ddf6fe37 13863@item -ftree-loop-ivcanon
d77de738
ML
13864Create a canonical counter for number of iterations in loops for which
13865determining number of iterations requires complicated analysis. Later
13866optimizations then may determine the number easily. Useful especially
13867in connection with unrolling.
13868
d77de738 13869@opindex ftree-scev-cprop
ddf6fe37 13870@item -ftree-scev-cprop
d77de738
ML
13871Perform final value replacement. If a variable is modified in a loop
13872in such a way that its value when exiting the loop can be determined using
13873only its initial value and the number of loop iterations, replace uses of
13874the final value by such a computation, provided it is sufficiently cheap.
13875This reduces data dependencies and may allow further simplifications.
13876Enabled by default at @option{-O1} and higher.
13877
d77de738 13878@opindex fivopts
ddf6fe37 13879@item -fivopts
d77de738
ML
13880Perform induction variable optimizations (strength reduction, induction
13881variable merging and induction variable elimination) on trees.
13882
d77de738 13883@opindex ftree-parallelize-loops
ddf6fe37 13884@item -ftree-parallelize-loops=n
d77de738
ML
13885Parallelize loops, i.e., split their iteration space to run in n threads.
13886This is only possible for loops whose iterations are independent
13887and can be arbitrarily reordered. The optimization is only
13888profitable on multiprocessor machines, for loops that are CPU-intensive,
13889rather than constrained e.g.@: by memory bandwidth. This option
13890implies @option{-pthread}, and thus is only supported on targets
13891that have support for @option{-pthread}.
13892
d77de738 13893@opindex ftree-pta
ddf6fe37 13894@item -ftree-pta
d77de738
ML
13895Perform function-local points-to analysis on trees. This flag is
13896enabled by default at @option{-O1} and higher, except for @option{-Og}.
13897
d77de738 13898@opindex ftree-sra
ddf6fe37 13899@item -ftree-sra
d77de738
ML
13900Perform scalar replacement of aggregates. This pass replaces structure
13901references with scalars to prevent committing structures to memory too
13902early. This flag is enabled by default at @option{-O1} and higher,
13903except for @option{-Og}.
13904
d77de738 13905@opindex fstore-merging
ddf6fe37 13906@item -fstore-merging
d77de738
ML
13907Perform merging of narrow stores to consecutive memory addresses. This pass
13908merges contiguous stores of immediate values narrower than a word into fewer
13909wider stores to reduce the number of instructions. This is enabled by default
13910at @option{-O2} and higher as well as @option{-Os}.
13911
d77de738 13912@opindex ftree-ter
ddf6fe37 13913@item -ftree-ter
d77de738
ML
13914Perform temporary expression replacement during the SSA->normal phase. Single
13915use/single def temporaries are replaced at their use location with their
13916defining expression. This results in non-GIMPLE code, but gives the expanders
13917much more complex trees to work on resulting in better RTL generation. This is
13918enabled by default at @option{-O1} and higher.
13919
d77de738 13920@opindex ftree-slsr
ddf6fe37 13921@item -ftree-slsr
d77de738
ML
13922Perform straight-line strength reduction on trees. This recognizes related
13923expressions involving multiplications and replaces them by less expensive
13924calculations when possible. This is enabled by default at @option{-O1} and
13925higher.
13926
d77de738 13927@opindex ftree-vectorize
ddf6fe37 13928@item -ftree-vectorize
d77de738
ML
13929Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13930and @option{-ftree-slp-vectorize} if not explicitly specified.
13931
d77de738 13932@opindex ftree-loop-vectorize
ddf6fe37 13933@item -ftree-loop-vectorize
d77de738
ML
13934Perform loop vectorization on trees. This flag is enabled by default at
13935@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13936and @option{-fauto-profile}.
13937
d77de738 13938@opindex ftree-slp-vectorize
ddf6fe37 13939@item -ftree-slp-vectorize
d77de738
ML
13940Perform basic block vectorization on trees. This flag is enabled by default at
13941@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13942and @option{-fauto-profile}.
13943
d77de738 13944@opindex ftrivial-auto-var-init
ddf6fe37 13945@item -ftrivial-auto-var-init=@var{choice}
d77de738
ML
13946Initialize automatic variables with either a pattern or with zeroes to increase
13947the security and predictability of a program by preventing uninitialized memory
13948disclosure and use.
13949GCC still considers an automatic variable that doesn't have an explicit
13950initializer as uninitialized, @option{-Wuninitialized} and
13951@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13952warning messages on such automatic variables and the compiler will
13953perform optimization as if the variable were uninitialized.
d77de738
ML
13954With this option, GCC will also initialize any padding of automatic variables
13955that have structure or union types to zeroes.
13956However, the current implementation cannot initialize automatic variables that
13957are declared between the controlling expression and the first case of a
13958@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13959such cases.
13960
13961The three values of @var{choice} are:
13962
13963@itemize @bullet
13964@item
13965@samp{uninitialized} doesn't initialize any automatic variables.
13966This is C and C++'s default.
13967
13968@item
13969@samp{pattern} Initialize automatic variables with values which will likely
13970transform logic bugs into crashes down the line, are easily recognized in a
13971crash dump and without being values that programmers can rely on for useful
13972program semantics.
13973The current value is byte-repeatable pattern with byte "0xFE".
13974The values used for pattern initialization might be changed in the future.
13975
13976@item
13977@samp{zero} Initialize automatic variables with zeroes.
13978@end itemize
13979
13980The default is @samp{uninitialized}.
13981
862867ea
AO
13982Note that the initializer values, whether @samp{zero} or @samp{pattern},
13983refer to data representation (in memory or machine registers), rather
13984than to their interpretation as numerical values. This distinction may
13985be important in languages that support types with biases or implicit
13986multipliers, and with such extensions as @samp{hardbool} (@pxref{Type
13987Attributes}). For example, a variable that uses 8 bits to represent
13988(biased) quantities in the @code{range 160..400} will be initialized
13989with the bit patterns @code{0x00} or @code{0xFE}, depending on
13990@var{choice}, whether or not these representations stand for values in
13991that range, and even if they do, the interpretation of the value held by
13992the variable will depend on the bias. A @samp{hardbool} variable that
13993uses say @code{0X5A} and @code{0xA5} for @code{false} and @code{true},
13994respectively, will trap with either @samp{choice} of trivial
13995initializer, i.e., @samp{zero} initialization will not convert to the
13996representation for @code{false}, even if it would for a @code{static}
13997variable of the same type. This means the initializer pattern doesn't
13998generally depend on the type of the initialized variable. One notable
13999exception is that (non-hardened) boolean variables that fit in registers
14000are initialized with @code{false} (zero), even when @samp{pattern} is
14001requested.
14002
d77de738
ML
14003You can control this behavior for a specific variable by using the variable
14004attribute @code{uninitialized} (@pxref{Variable Attributes}).
14005
d77de738 14006@opindex fvect-cost-model
ddf6fe37 14007@item -fvect-cost-model=@var{model}
d77de738
ML
14008Alter the cost model used for vectorization. The @var{model} argument
14009should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
14010@samp{very-cheap}.
14011With the @samp{unlimited} model the vectorized code-path is assumed
14012to be profitable while with the @samp{dynamic} model a runtime check
14013guards the vectorized code-path to enable it only for iteration
14014counts that will likely execute faster than when executing the original
14015scalar loop. The @samp{cheap} model disables vectorization of
14016loops where doing so would be cost prohibitive for example due to
14017required runtime checks for data dependence or alignment but otherwise
14018is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
14019allows vectorization if the vector code would entirely replace the
14020scalar code that is being vectorized. For example, if each iteration
14021of a vectorized loop would only be able to handle exactly four iterations
14022of the scalar loop, the @samp{very-cheap} model would only allow
14023vectorization if the scalar iteration count is known to be a multiple
14024of four.
14025
14026The default cost model depends on other optimization flags and is
14027either @samp{dynamic} or @samp{cheap}.
14028
d77de738 14029@opindex fsimd-cost-model
ddf6fe37 14030@item -fsimd-cost-model=@var{model}
d77de738
ML
14031Alter the cost model used for vectorization of loops marked with the OpenMP
14032simd directive. The @var{model} argument should be one of
14033@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
14034have the same meaning as described in @option{-fvect-cost-model} and by
14035default a cost model defined with @option{-fvect-cost-model} is used.
14036
d77de738 14037@opindex ftree-vrp
ddf6fe37 14038@item -ftree-vrp
d77de738
ML
14039Perform Value Range Propagation on trees. This is similar to the
14040constant propagation pass, but instead of values, ranges of values are
14041propagated. This allows the optimizers to remove unnecessary range
14042checks like array bound checks and null pointer checks. This is
14043enabled by default at @option{-O2} and higher. Null pointer check
14044elimination is only done if @option{-fdelete-null-pointer-checks} is
14045enabled.
14046
d77de738 14047@opindex fsplit-paths
ddf6fe37 14048@item -fsplit-paths
d77de738
ML
14049Split paths leading to loop backedges. This can improve dead code
14050elimination and common subexpression elimination. This is enabled by
14051default at @option{-O3} and above.
14052
d77de738 14053@opindex fsplit-ivs-in-unroller
ddf6fe37 14054@item -fsplit-ivs-in-unroller
d77de738
ML
14055Enables expression of values of induction variables in later iterations
14056of the unrolled loop using the value in the first iteration. This breaks
14057long dependency chains, thus improving efficiency of the scheduling passes.
14058
14059A combination of @option{-fweb} and CSE is often sufficient to obtain the
14060same effect. However, that is not reliable in cases where the loop body
14061is more complicated than a single basic block. It also does not work at all
14062on some architectures due to restrictions in the CSE pass.
14063
14064This optimization is enabled by default.
14065
d77de738 14066@opindex fvariable-expansion-in-unroller
ddf6fe37 14067@item -fvariable-expansion-in-unroller
d77de738
ML
14068With this option, the compiler creates multiple copies of some
14069local variables when unrolling a loop, which can result in superior code.
14070
14071This optimization is enabled by default for PowerPC targets, but disabled
14072by default otherwise.
14073
d77de738 14074@opindex fpartial-inlining
ddf6fe37 14075@item -fpartial-inlining
d77de738
ML
14076Inline parts of functions. This option has any effect only
14077when inlining itself is turned on by the @option{-finline-functions}
14078or @option{-finline-small-functions} options.
14079
14080Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14081
d77de738 14082@opindex fpredictive-commoning
ddf6fe37 14083@item -fpredictive-commoning
d77de738
ML
14084Perform predictive commoning optimization, i.e., reusing computations
14085(especially memory loads and stores) performed in previous
14086iterations of loops.
14087
14088This option is enabled at level @option{-O3}.
14089It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14090
d77de738 14091@opindex fprefetch-loop-arrays
ddf6fe37 14092@item -fprefetch-loop-arrays
d77de738
ML
14093If supported by the target machine, generate instructions to prefetch
14094memory to improve the performance of loops that access large arrays.
14095
14096This option may generate better or worse code; results are highly
14097dependent on the structure of loops within the source code.
14098
14099Disabled at level @option{-Os}.
14100
d77de738
ML
14101@opindex fno-printf-return-value
14102@opindex fprintf-return-value
ddf6fe37 14103@item -fno-printf-return-value
d77de738
ML
14104Do not substitute constants for known return value of formatted output
14105functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
14106@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
14107transformation allows GCC to optimize or even eliminate branches based
14108on the known return value of these functions called with arguments that
14109are either constant, or whose values are known to be in a range that
14110makes determining the exact return value possible. For example, when
14111@option{-fprintf-return-value} is in effect, both the branch and the
14112body of the @code{if} statement (but not the call to @code{snprint})
14113can be optimized away when @code{i} is a 32-bit or smaller integer
14114because the return value is guaranteed to be at most 8.
14115
14116@smallexample
14117char buf[9];
14118if (snprintf (buf, "%08x", i) >= sizeof buf)
14119 @dots{}
14120@end smallexample
14121
14122The @option{-fprintf-return-value} option relies on other optimizations
14123and yields best results with @option{-O2} and above. It works in tandem
14124with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
14125options. The @option{-fprintf-return-value} option is enabled by default.
14126
d77de738
ML
14127@opindex fno-peephole
14128@opindex fpeephole
14129@opindex fno-peephole2
14130@opindex fpeephole2
ddf6fe37
AA
14131@item -fno-peephole
14132@itemx -fno-peephole2
d77de738
ML
14133Disable any machine-specific peephole optimizations. The difference
14134between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
14135are implemented in the compiler; some targets use one, some use the
14136other, a few use both.
14137
14138@option{-fpeephole} is enabled by default.
14139@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14140
d77de738
ML
14141@opindex fno-guess-branch-probability
14142@opindex fguess-branch-probability
ddf6fe37 14143@item -fno-guess-branch-probability
d77de738
ML
14144Do not guess branch probabilities using heuristics.
14145
14146GCC uses heuristics to guess branch probabilities if they are
14147not provided by profiling feedback (@option{-fprofile-arcs}). These
14148heuristics are based on the control flow graph. If some branch probabilities
14149are specified by @code{__builtin_expect}, then the heuristics are
14150used to guess branch probabilities for the rest of the control flow graph,
14151taking the @code{__builtin_expect} info into account. The interactions
14152between the heuristics and @code{__builtin_expect} can be complex, and in
14153some cases, it may be useful to disable the heuristics so that the effects
14154of @code{__builtin_expect} are easier to understand.
14155
14156It is also possible to specify expected probability of the expression
14157with @code{__builtin_expect_with_probability} built-in function.
14158
14159The default is @option{-fguess-branch-probability} at levels
14160@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
14161
d77de738 14162@opindex freorder-blocks
ddf6fe37 14163@item -freorder-blocks
d77de738
ML
14164Reorder basic blocks in the compiled function in order to reduce number of
14165taken branches and improve code locality.
14166
14167Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14168
d77de738 14169@opindex freorder-blocks-algorithm
ddf6fe37 14170@item -freorder-blocks-algorithm=@var{algorithm}
d77de738
ML
14171Use the specified algorithm for basic block reordering. The
14172@var{algorithm} argument can be @samp{simple}, which does not increase
14173code size (except sometimes due to secondary effects like alignment),
14174or @samp{stc}, the ``software trace cache'' algorithm, which tries to
14175put all often executed code together, minimizing the number of branches
14176executed by making extra copies of code.
14177
14178The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
14179@samp{stc} at levels @option{-O2}, @option{-O3}.
14180
d77de738 14181@opindex freorder-blocks-and-partition
ddf6fe37 14182@item -freorder-blocks-and-partition
d77de738
ML
14183In addition to reordering basic blocks in the compiled function, in order
14184to reduce number of taken branches, partitions hot and cold basic blocks
14185into separate sections of the assembly and @file{.o} files, to improve
14186paging and cache locality performance.
14187
14188This optimization is automatically turned off in the presence of
14189exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
14190section attribute and on any architecture that does not support named
14191sections. When @option{-fsplit-stack} is used this option is not
14192enabled by default (to avoid linker errors), but may be enabled
14193explicitly (if using a working linker).
14194
14195Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
14196
d77de738 14197@opindex freorder-functions
ddf6fe37 14198@item -freorder-functions
d77de738
ML
14199Reorder functions in the object file in order to
14200improve code locality. This is implemented by using special
14201subsections @code{.text.hot} for most frequently executed functions and
14202@code{.text.unlikely} for unlikely executed functions. Reordering is done by
14203the linker so object file format must support named sections and linker must
14204place them in a reasonable way.
14205
14206This option isn't effective unless you either provide profile feedback
14207(see @option{-fprofile-arcs} for details) or manually annotate functions with
14208@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
14209
14210Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14211
d77de738 14212@opindex fstrict-aliasing
ddf6fe37 14213@item -fstrict-aliasing
d77de738
ML
14214Allow the compiler to assume the strictest aliasing rules applicable to
14215the language being compiled. For C (and C++), this activates
14216optimizations based on the type of expressions. In particular, an
14217object of one type is assumed never to reside at the same address as an
14218object of a different type, unless the types are almost the same. For
14219example, an @code{unsigned int} can alias an @code{int}, but not a
14220@code{void*} or a @code{double}. A character type may alias any other
14221type.
14222
14223@anchor{Type-punning}Pay special attention to code like this:
14224@smallexample
14225union a_union @{
14226 int i;
14227 double d;
14228@};
14229
14230int f() @{
14231 union a_union t;
14232 t.d = 3.0;
14233 return t.i;
14234@}
14235@end smallexample
14236The practice of reading from a different union member than the one most
14237recently written to (called ``type-punning'') is common. Even with
14238@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
14239is accessed through the union type. So, the code above works as
14240expected. @xref{Structures unions enumerations and bit-fields
14241implementation}. However, this code might not:
14242@smallexample
14243int f() @{
14244 union a_union t;
14245 int* ip;
14246 t.d = 3.0;
14247 ip = &t.i;
14248 return *ip;
14249@}
14250@end smallexample
14251
14252Similarly, access by taking the address, casting the resulting pointer
14253and dereferencing the result has undefined behavior, even if the cast
14254uses a union type, e.g.:
14255@smallexample
14256int f() @{
14257 double d = 3.0;
14258 return ((union a_union *) &d)->i;
14259@}
14260@end smallexample
14261
14262The @option{-fstrict-aliasing} option is enabled at levels
14263@option{-O2}, @option{-O3}, @option{-Os}.
14264
d77de738 14265@opindex fipa-strict-aliasing
ddf6fe37 14266@item -fipa-strict-aliasing
d77de738
ML
14267Controls whether rules of @option{-fstrict-aliasing} are applied across
14268function boundaries. Note that if multiple functions gets inlined into a
14269single function the memory accesses are no longer considered to be crossing a
14270function boundary.
14271
14272The @option{-fipa-strict-aliasing} option is enabled by default and is
14273effective only in combination with @option{-fstrict-aliasing}.
14274
ddf6fe37 14275@opindex falign-functions
d77de738
ML
14276@item -falign-functions
14277@itemx -falign-functions=@var{n}
14278@itemx -falign-functions=@var{n}:@var{m}
14279@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
14280@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14281Align the start of functions to the next power-of-two greater than or
14282equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
14283least the first @var{m} bytes of the function can be fetched by the CPU
14284without crossing an @var{n}-byte alignment boundary.
0f5a9a00
JH
14285This is an optimization of code performance and alignment is ignored for
14286functions considered cold. If alignment is required for all functions,
14287use @option{-fmin-function-alignment}.
d77de738
ML
14288
14289If @var{m} is not specified, it defaults to @var{n}.
14290
14291Examples: @option{-falign-functions=32} aligns functions to the next
1429232-byte boundary, @option{-falign-functions=24} aligns to the next
1429332-byte boundary only if this can be done by skipping 23 bytes or less,
14294@option{-falign-functions=32:7} aligns to the next
1429532-byte boundary only if this can be done by skipping 6 bytes or less.
14296
14297The second pair of @var{n2}:@var{m2} values allows you to specify
14298a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
14299the next 64-byte boundary if this can be done by skipping 6 bytes or less,
14300otherwise aligns to the next 32-byte boundary if this can be done
14301by skipping 2 bytes or less.
14302If @var{m2} is not specified, it defaults to @var{n2}.
14303
14304Some assemblers only support this flag when @var{n} is a power of two;
14305in that case, it is rounded up.
14306
14307@option{-fno-align-functions} and @option{-falign-functions=1} are
14308equivalent and mean that functions are not aligned.
14309
14310If @var{n} is not specified or is zero, use a machine-dependent default.
14311The maximum allowed @var{n} option value is 65536.
14312
14313Enabled at levels @option{-O2}, @option{-O3}.
14314
14315@item -flimit-function-alignment
14316If this option is enabled, the compiler tries to avoid unnecessarily
14317overaligning functions. It attempts to instruct the assembler to align
14318by the amount specified by @option{-falign-functions}, but not to
14319skip more bytes than the size of the function.
14320
ddf6fe37 14321@opindex falign-labels
d77de738
ML
14322@item -falign-labels
14323@itemx -falign-labels=@var{n}
14324@itemx -falign-labels=@var{n}:@var{m}
14325@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
14326@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14327Align all branch targets to a power-of-two boundary.
14328
14329Parameters of this option are analogous to the @option{-falign-functions} option.
14330@option{-fno-align-labels} and @option{-falign-labels=1} are
14331equivalent and mean that labels are not aligned.
14332
14333If @option{-falign-loops} or @option{-falign-jumps} are applicable and
14334are greater than this value, then their values are used instead.
14335
14336If @var{n} is not specified or is zero, use a machine-dependent default
14337which is very likely to be @samp{1}, meaning no alignment.
14338The maximum allowed @var{n} option value is 65536.
14339
14340Enabled at levels @option{-O2}, @option{-O3}.
14341
ddf6fe37 14342@opindex falign-loops
d77de738
ML
14343@item -falign-loops
14344@itemx -falign-loops=@var{n}
14345@itemx -falign-loops=@var{n}:@var{m}
14346@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
14347@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14348Align loops to a power-of-two boundary. If the loops are executed
14349many times, this makes up for any execution of the dummy padding
14350instructions.
0f5a9a00
JH
14351This is an optimization of code performance and alignment is ignored for
14352loops considered cold.
d77de738
ML
14353
14354If @option{-falign-labels} is greater than this value, then its value
14355is used instead.
14356
14357Parameters of this option are analogous to the @option{-falign-functions} option.
14358@option{-fno-align-loops} and @option{-falign-loops=1} are
14359equivalent and mean that loops are not aligned.
14360The maximum allowed @var{n} option value is 65536.
14361
14362If @var{n} is not specified or is zero, use a machine-dependent default.
14363
14364Enabled at levels @option{-O2}, @option{-O3}.
14365
ddf6fe37 14366@opindex falign-jumps
d77de738
ML
14367@item -falign-jumps
14368@itemx -falign-jumps=@var{n}
14369@itemx -falign-jumps=@var{n}:@var{m}
14370@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
14371@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
14372Align branch targets to a power-of-two boundary, for branch targets
14373where the targets can only be reached by jumping. In this case,
14374no dummy operations need be executed.
0f5a9a00
JH
14375This is an optimization of code performance and alignment is ignored for
14376jumps considered cold.
d77de738
ML
14377
14378If @option{-falign-labels} is greater than this value, then its value
14379is used instead.
14380
14381Parameters of this option are analogous to the @option{-falign-functions} option.
14382@option{-fno-align-jumps} and @option{-falign-jumps=1} are
14383equivalent and mean that loops are not aligned.
14384
14385If @var{n} is not specified or is zero, use a machine-dependent default.
14386The maximum allowed @var{n} option value is 65536.
14387
14388Enabled at levels @option{-O2}, @option{-O3}.
14389
0f5a9a00
JH
14390@opindex fmin-function-alignment=@var{n}
14391@item -fmin-function-alignment
14392Specify minimal alignment of functions to the next power-of-two greater than or
14393equal to @var{n}. Unlike @option{-falign-functions} this alignment is applied
14394also to all functions (even those considered cold). The alignment is also not
14395affected by @option{-flimit-function-alignment}
14396
14397
d77de738 14398@opindex fno-allocation-dce
ddf6fe37 14399@item -fno-allocation-dce
d77de738
ML
14400Do not remove unused C++ allocations in dead code elimination.
14401
d77de738 14402@opindex fallow-store-data-races
ddf6fe37 14403@item -fallow-store-data-races
d77de738
ML
14404Allow the compiler to perform optimizations that may introduce new data races
14405on stores, without proving that the variable cannot be concurrently accessed
14406by other threads. Does not affect optimization of local data. It is safe to
14407use this option if it is known that global data will not be accessed by
14408multiple threads.
14409
14410Examples of optimizations enabled by @option{-fallow-store-data-races} include
14411hoisting or if-conversions that may cause a value that was already in memory
14412to be re-written with that same value. Such re-writing is safe in a single
14413threaded context but may be unsafe in a multi-threaded context. Note that on
14414some processors, if-conversions may be required in order to enable
14415vectorization.
14416
14417Enabled at level @option{-Ofast}.
14418
d77de738 14419@opindex funit-at-a-time
ddf6fe37 14420@item -funit-at-a-time
d77de738
ML
14421This option is left for compatibility reasons. @option{-funit-at-a-time}
14422has no effect, while @option{-fno-unit-at-a-time} implies
14423@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
14424
14425Enabled by default.
14426
d77de738
ML
14427@opindex fno-toplevel-reorder
14428@opindex ftoplevel-reorder
ddf6fe37 14429@item -fno-toplevel-reorder
d77de738
ML
14430Do not reorder top-level functions, variables, and @code{asm}
14431statements. Output them in the same order that they appear in the
14432input file. When this option is used, unreferenced static variables
14433are not removed. This option is intended to support existing code
14434that relies on a particular ordering. For new code, it is better to
14435use attributes when possible.
14436
14437@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
14438also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
14439Additionally @option{-fno-toplevel-reorder} implies
14440@option{-fno-section-anchors}.
14441
d77de738 14442@opindex funreachable-traps
ddf6fe37 14443@item -funreachable-traps
d77de738
ML
14444With this option, the compiler turns calls to
14445@code{__builtin_unreachable} into traps, instead of using them for
14446optimization. This also affects any such calls implicitly generated
14447by the compiler.
14448
14449This option has the same effect as @option{-fsanitize=unreachable
14450-fsanitize-trap=unreachable}, but does not affect the values of those
14451options. If @option{-fsanitize=unreachable} is enabled, that option
14452takes priority over this one.
14453
14454This option is enabled by default at @option{-O0} and @option{-Og}.
14455
d77de738 14456@opindex fweb
ddf6fe37 14457@item -fweb
d77de738
ML
14458Constructs webs as commonly used for register allocation purposes and assign
14459each web individual pseudo register. This allows the register allocation pass
14460to operate on pseudos directly, but also strengthens several other optimization
14461passes, such as CSE, loop optimizer and trivial dead code remover. It can,
14462however, make debugging impossible, since variables no longer stay in a
14463``home register''.
14464
14465Enabled by default with @option{-funroll-loops}.
14466
d77de738 14467@opindex fwhole-program
ddf6fe37 14468@item -fwhole-program
d77de738
ML
14469Assume that the current compilation unit represents the whole program being
14470compiled. All public functions and variables with the exception of @code{main}
14471and those merged by attribute @code{externally_visible} become static functions
14472and in effect are optimized more aggressively by interprocedural optimizers.
14473
39ebd3a9
JH
14474With @option{-flto} this option has a limited use. In most cases the
14475precise list of symbols used or exported from the binary is known the
14476resolution info passed to the link-time optimizer by the linker plugin. It is
14477still useful if no linker plugin is used or during incremental link step when
14478final code is produced (with @option{-flto}
14479@option{-flinker-output=nolto-rel}).
d77de738 14480
d77de738 14481@opindex flto
ddf6fe37 14482@item -flto[=@var{n}]
d77de738
ML
14483This option runs the standard link-time optimizer. When invoked
14484with source code, it generates GIMPLE (one of GCC's internal
14485representations) and writes it to special ELF sections in the object
14486file. When the object files are linked together, all the function
14487bodies are read from these ELF sections and instantiated as if they
14488had been part of the same translation unit.
14489
14490To use the link-time optimizer, @option{-flto} and optimization
14491options should be specified at compile time and during the final link.
14492It is recommended that you compile all the files participating in the
14493same link with the same options and also specify those options at
0f5a9a00 14494link time.
d77de738
ML
14495For example:
14496
14497@smallexample
14498gcc -c -O2 -flto foo.c
14499gcc -c -O2 -flto bar.c
14500gcc -o myprog -flto -O2 foo.o bar.o
14501@end smallexample
14502
14503The first two invocations to GCC save a bytecode representation
14504of GIMPLE into special ELF sections inside @file{foo.o} and
14505@file{bar.o}. The final invocation reads the GIMPLE bytecode from
14506@file{foo.o} and @file{bar.o}, merges the two files into a single
14507internal image, and compiles the result as usual. Since both
14508@file{foo.o} and @file{bar.o} are merged into a single image, this
14509causes all the interprocedural analyses and optimizations in GCC to
14510work across the two files as if they were a single one. This means,
14511for example, that the inliner is able to inline functions in
14512@file{bar.o} into functions in @file{foo.o} and vice-versa.
14513
14514Another (simpler) way to enable link-time optimization is:
14515
14516@smallexample
14517gcc -o myprog -flto -O2 foo.c bar.c
14518@end smallexample
14519
14520The above generates bytecode for @file{foo.c} and @file{bar.c},
14521merges them together into a single GIMPLE representation and optimizes
14522them as usual to produce @file{myprog}.
14523
14524The important thing to keep in mind is that to enable link-time
14525optimizations you need to use the GCC driver to perform the link step.
14526GCC automatically performs link-time optimization if any of the
14527objects involved were compiled with the @option{-flto} command-line option.
14528You can always override
14529the automatic decision to do link-time optimization
14530by passing @option{-fno-lto} to the link command.
14531
14532To make whole program optimization effective, it is necessary to make
14533certain whole program assumptions. The compiler needs to know
14534what functions and variables can be accessed by libraries and runtime
14535outside of the link-time optimized unit. When supported by the linker,
14536the linker plugin (see @option{-fuse-linker-plugin}) passes information
14537to the compiler about used and externally visible symbols. When
14538the linker plugin is not available, @option{-fwhole-program} should be
14539used to allow the compiler to make these assumptions, which leads
14540to more aggressive optimization decisions.
14541
14542When a file is compiled with @option{-flto} without
14543@option{-fuse-linker-plugin}, the generated object file is larger than
14544a regular object file because it contains GIMPLE bytecodes and the usual
14545final code (see @option{-ffat-lto-objects}). This means that
14546object files with LTO information can be linked as normal object
14547files; if @option{-fno-lto} is passed to the linker, no
14548interprocedural optimizations are applied. Note that when
14549@option{-fno-fat-lto-objects} is enabled the compile stage is faster
14550but you cannot perform a regular, non-LTO link on them.
14551
14552When producing the final binary, GCC only
14553applies link-time optimizations to those files that contain bytecode.
14554Therefore, you can mix and match object files and libraries with
14555GIMPLE bytecodes and final object code. GCC automatically selects
14556which files to optimize in LTO mode and which files to link without
14557further processing.
14558
14559Generally, options specified at link time override those
14560specified at compile time, although in some cases GCC attempts to infer
14561link-time options from the settings used to compile the input files.
14562
14563If you do not specify an optimization level option @option{-O} at
14564link time, then GCC uses the highest optimization level
14565used when compiling the object files. Note that it is generally
14566ineffective to specify an optimization level option only at link time and
14567not at compile time, for two reasons. First, compiling without
14568optimization suppresses compiler passes that gather information
14569needed for effective optimization at link time. Second, some early
14570optimization passes can be performed only at compile time and
14571not at link time.
14572
14573There are some code generation flags preserved by GCC when
14574generating bytecodes, as they need to be used during the final link.
14575Currently, the following options and their settings are taken from
14576the first object file that explicitly specifies them:
14577@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
14578@option{-fgnu-tm} and all the @option{-m} target flags.
14579
14580The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
14581@option{-fPIE} are combined based on the following scheme:
14582
14583@smallexample
14584@option{-fPIC} + @option{-fpic} = @option{-fpic}
14585@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
14586@option{-fpic/-fPIC} + (no option) = (no option)
14587@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
14588@option{-fpic} + @option{-fPIE} = @option{-fpie}
14589@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
14590@end smallexample
14591
14592Certain ABI-changing flags are required to match in all compilation units,
14593and trying to override this at link time with a conflicting value
14594is ignored. This includes options such as @option{-freg-struct-return}
14595and @option{-fpcc-struct-return}.
14596
14597Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
14598@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
14599are passed through to the link stage and merged conservatively for
14600conflicting translation units. Specifically
14601@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
14602precedence; and for example @option{-ffp-contract=off} takes precedence
14603over @option{-ffp-contract=fast}. You can override them at link time.
14604
14605Diagnostic options such as @option{-Wstringop-overflow} are passed
14606through to the link stage and their setting matches that of the
14607compile-step at function granularity. Note that this matters only
14608for diagnostics emitted during optimization. Note that code
14609transforms such as inlining can lead to warnings being enabled
14610or disabled for regions if code not consistent with the setting
14611at compile time.
14612
14613When you need to pass options to the assembler via @option{-Wa} or
14614@option{-Xassembler} make sure to either compile such translation
14615units with @option{-fno-lto} or consistently use the same assembler
14616options on all translation units. You can alternatively also
14617specify assembler options at LTO link time.
14618
14619To enable debug info generation you need to supply @option{-g} at
14620compile time. If any of the input files at link time were built
14621with debug info generation enabled the link will enable debug info
14622generation as well. Any elaborate debug info settings
14623like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
14624at the linker command line and mixing different settings in different
14625translation units is discouraged.
14626
14627If LTO encounters objects with C linkage declared with incompatible
14628types in separate translation units to be linked together (undefined
14629behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
14630issued. The behavior is still undefined at run time. Similar
14631diagnostics may be raised for other languages.
14632
14633Another feature of LTO is that it is possible to apply interprocedural
14634optimizations on files written in different languages:
14635
14636@smallexample
14637gcc -c -flto foo.c
14638g++ -c -flto bar.cc
14639gfortran -c -flto baz.f90
14640g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
14641@end smallexample
14642
14643Notice that the final link is done with @command{g++} to get the C++
14644runtime libraries and @option{-lgfortran} is added to get the Fortran
14645runtime libraries. In general, when mixing languages in LTO mode, you
14646should use the same link command options as when mixing languages in a
14647regular (non-LTO) compilation.
14648
14649If object files containing GIMPLE bytecode are stored in a library archive, say
14650@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
14651are using a linker with plugin support. To create static libraries suitable
14652for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
14653and @command{ranlib};
14654to show the symbols of object files with GIMPLE bytecode, use
14655@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
14656and @command{nm} have been compiled with plugin support. At link time, use the
14657flag @option{-fuse-linker-plugin} to ensure that the library participates in
14658the LTO optimization process:
14659
14660@smallexample
14661gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
14662@end smallexample
14663
14664With the linker plugin enabled, the linker extracts the needed
14665GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
14666to make them part of the aggregated GIMPLE image to be optimized.
14667
14668If you are not using a linker with plugin support and/or do not
14669enable the linker plugin, then the objects inside @file{libfoo.a}
14670are extracted and linked as usual, but they do not participate
14671in the LTO optimization process. In order to make a static library suitable
14672for both LTO optimization and usual linkage, compile its object files with
14673@option{-flto} @option{-ffat-lto-objects}.
14674
14675Link-time optimizations do not require the presence of the whole program to
14676operate. If the program does not require any symbols to be exported, it is
14677possible to combine @option{-flto} and @option{-fwhole-program} to allow
14678the interprocedural optimizers to use more aggressive assumptions which may
14679lead to improved optimization opportunities.
14680Use of @option{-fwhole-program} is not needed when linker plugin is
14681active (see @option{-fuse-linker-plugin}).
14682
14683The current implementation of LTO makes no
14684attempt to generate bytecode that is portable between different
14685types of hosts. The bytecode files are versioned and there is a
14686strict version check, so bytecode files generated in one version of
14687GCC do not work with an older or newer version of GCC.
14688
14689Link-time optimization does not work well with generation of debugging
14690information on systems other than those using a combination of ELF and
14691DWARF.
14692
14693If you specify the optional @var{n}, the optimization and code
14694generation done at link time is executed in parallel using @var{n}
14695parallel jobs by utilizing an installed @command{make} program. The
14696environment variable @env{MAKE} may be used to override the program
14697used.
14698
14699You can also specify @option{-flto=jobserver} to use GNU make's
14700job server mode to determine the number of parallel jobs. This
14701is useful when the Makefile calling GCC is already executing in parallel.
14702You must prepend a @samp{+} to the command recipe in the parent Makefile
14703for this to work. This option likely only works if @env{MAKE} is
14704GNU make. Even without the option value, GCC tries to automatically
14705detect a running GNU make's job server.
14706
14707Use @option{-flto=auto} to use GNU make's job server, if available,
14708or otherwise fall back to autodetection of the number of CPU threads
14709present in your system.
14710
d77de738 14711@opindex flto-partition
ddf6fe37 14712@item -flto-partition=@var{alg}
d77de738
ML
14713Specify the partitioning algorithm used by the link-time optimizer.
14714The value is either @samp{1to1} to specify a partitioning mirroring
14715the original source files or @samp{balanced} to specify partitioning
14716into equally sized chunks (whenever possible) or @samp{max} to create
14717new partition for every symbol where possible. Specifying @samp{none}
14718as an algorithm disables partitioning and streaming completely.
14719The default value is @samp{balanced}. While @samp{1to1} can be used
14720as an workaround for various code ordering issues, the @samp{max}
14721partitioning is intended for internal testing only.
14722The value @samp{one} specifies that exactly one partition should be
14723used while the value @samp{none} bypasses partitioning and executes
14724the link-time optimization step directly from the WPA phase.
14725
d77de738 14726@opindex flto-compression-level
ddf6fe37 14727@item -flto-compression-level=@var{n}
d77de738
ML
14728This option specifies the level of compression used for intermediate
14729language written to LTO object files, and is only meaningful in
14730conjunction with LTO mode (@option{-flto}). GCC currently supports two
14731LTO compression algorithms. For zstd, valid values are 0 (no compression)
14732to 19 (maximum compression), while zlib supports values from 0 to 9.
14733Values outside this range are clamped to either minimum or maximum
14734of the supported values. If the option is not given,
14735a default balanced compression setting is used.
14736
d77de738 14737@opindex fuse-linker-plugin
ddf6fe37 14738@item -fuse-linker-plugin
d77de738
ML
14739Enables the use of a linker plugin during link-time optimization. This
14740option relies on plugin support in the linker, which is available in gold
14741or in GNU ld 2.21 or newer.
14742
14743This option enables the extraction of object files with GIMPLE bytecode out
14744of library archives. This improves the quality of optimization by exposing
14745more code to the link-time optimizer. This information specifies what
14746symbols can be accessed externally (by non-LTO object or during dynamic
14747linking). Resulting code quality improvements on binaries (and shared
14748libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14749See @option{-flto} for a description of the effect of this flag and how to
14750use it.
14751
14752This option is enabled by default when LTO support in GCC is enabled
14753and GCC was configured for use with
14754a linker supporting plugins (GNU ld 2.21 or newer or gold).
14755
d77de738 14756@opindex ffat-lto-objects
ddf6fe37 14757@item -ffat-lto-objects
d77de738
ML
14758Fat LTO objects are object files that contain both the intermediate language
14759and the object code. This makes them usable for both LTO linking and normal
14760linking. This option is effective only when compiling with @option{-flto}
14761and is ignored at link time.
14762
14763@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14764requires the complete toolchain to be aware of LTO. It requires a linker with
14765linker plugin support for basic functionality. Additionally,
14766@command{nm}, @command{ar} and @command{ranlib}
14767need to support linker plugins to allow a full-featured build environment
14768(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14769@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14770to these tools. With non fat LTO makefiles need to be modified to use them.
14771
14772Note that modern binutils provide plugin auto-load mechanism.
14773Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14774effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14775@command{gcc-ranlib}).
14776
14777The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14778support.
14779
d77de738 14780@opindex fcompare-elim
ddf6fe37 14781@item -fcompare-elim
d77de738
ML
14782After register allocation and post-register allocation instruction splitting,
14783identify arithmetic instructions that compute processor flags similar to a
14784comparison operation based on that arithmetic. If possible, eliminate the
14785explicit comparison operation.
14786
14787This pass only applies to certain targets that cannot explicitly represent
14788the comparison operation before register allocation is complete.
14789
14790Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14791
04c9cf5c
MT
14792@opindex ffold-mem-offsets
14793@item -ffold-mem-offsets
14794@itemx -fno-fold-mem-offsets
14795Try to eliminate add instructions by folding them in memory loads/stores.
14796
14797Enabled at levels @option{-O2}, @option{-O3}.
14798
d77de738 14799@opindex fcprop-registers
ddf6fe37 14800@item -fcprop-registers
d77de738
ML
14801After register allocation and post-register allocation instruction splitting,
14802perform a copy-propagation pass to try to reduce scheduling dependencies
14803and occasionally eliminate the copy.
14804
14805Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14806
d77de738 14807@opindex fprofile-correction
ddf6fe37 14808@item -fprofile-correction
d77de738
ML
14809Profiles collected using an instrumented binary for multi-threaded programs may
14810be inconsistent due to missed counter updates. When this option is specified,
14811GCC uses heuristics to correct or smooth out such inconsistencies. By
14812default, GCC emits an error message when an inconsistent profile is detected.
14813
14814This option is enabled by @option{-fauto-profile}.
14815
d77de738 14816@opindex fprofile-partial-training
ddf6fe37 14817@item -fprofile-partial-training
d77de738
ML
14818With @code{-fprofile-use} all portions of programs not executed during train
14819run are optimized agressively for size rather than speed. In some cases it is
14820not practical to train all possible hot paths in the program. (For
14821example, program may contain functions specific for a given hardware and
14822trianing may not cover all hardware configurations program is run on.) With
14823@code{-fprofile-partial-training} profile feedback will be ignored for all
14824functions not executed during the train run leading them to be optimized as if
14825they were compiled without profile feedback. This leads to better performance
14826when train run is not representative but also leads to significantly bigger
14827code.
14828
ddf6fe37 14829@opindex fprofile-use
d77de738
ML
14830@item -fprofile-use
14831@itemx -fprofile-use=@var{path}
d77de738
ML
14832Enable profile feedback-directed optimizations,
14833and the following optimizations, many of which
14834are generally profitable only with profile feedback available:
14835
43b72ede
AA
14836@gccoptlist{-fbranch-probabilities -fprofile-values
14837-funroll-loops -fpeel-loops -ftracer -fvpt
14838-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14839-fpredictive-commoning -fsplit-loops -funswitch-loops
14840-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14841-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14842-fprofile-reorder-functions}
14843
14844Before you can use this option, you must first generate profiling information.
14845@xref{Instrumentation Options}, for information about the
14846@option{-fprofile-generate} option.
14847
14848By default, GCC emits an error message if the feedback profiles do not
14849match the source code. This error can be turned into a warning by using
14850@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14851optimized code. Additionally, by default, GCC also emits a warning message if
14852the feedback profiles do not exist (see @option{-Wmissing-profile}).
14853
14854If @var{path} is specified, GCC looks at the @var{path} to find
14855the profile feedback data files. See @option{-fprofile-dir}.
14856
ddf6fe37 14857@opindex fauto-profile
d77de738
ML
14858@item -fauto-profile
14859@itemx -fauto-profile=@var{path}
d77de738
ML
14860Enable sampling-based feedback-directed optimizations,
14861and the following optimizations,
14862many of which are generally profitable only with profile feedback available:
14863
43b72ede
AA
14864@gccoptlist{-fbranch-probabilities -fprofile-values
14865-funroll-loops -fpeel-loops -ftracer -fvpt
14866-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14867-fpredictive-commoning -fsplit-loops -funswitch-loops
14868-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14869-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14870-fprofile-correction}
14871
14872@var{path} is the name of a file containing AutoFDO profile information.
14873If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14874
14875Producing an AutoFDO profile data file requires running your program
14876with the @command{perf} utility on a supported GNU/Linux target system.
14877For more information, see @uref{https://perf.wiki.kernel.org/}.
14878
14879E.g.
14880@smallexample
14881perf record -e br_inst_retired:near_taken -b -o perf.data \
14882 -- your_program
14883@end smallexample
14884
14885Then use the @command{create_gcov} tool to convert the raw profile data
14886to a format that can be used by GCC.@ You must also supply the
14887unstripped binary for your program to this tool.
14888See @uref{https://github.com/google/autofdo}.
14889
14890E.g.
14891@smallexample
14892create_gcov --binary=your_program.unstripped --profile=perf.data \
14893 --gcov=profile.afdo
14894@end smallexample
14895@end table
14896
14897The following options control compiler behavior regarding floating-point
14898arithmetic. These options trade off between speed and
14899correctness. All must be specifically enabled.
14900
14901@table @gcctabopt
d77de738 14902@opindex ffloat-store
ddf6fe37 14903@item -ffloat-store
d77de738
ML
14904Do not store floating-point variables in registers, and inhibit other
14905options that might change whether a floating-point value is taken from a
14906register or memory.
14907
14908@cindex floating-point precision
14909This option prevents undesirable excess precision on machines such as
14910the 68000 where the floating registers (of the 68881) keep more
14911precision than a @code{double} is supposed to have. Similarly for the
14912x86 architecture. For most programs, the excess precision does only
14913good, but a few programs rely on the precise definition of IEEE floating
14914point. Use @option{-ffloat-store} for such programs, after modifying
14915them to store all pertinent intermediate computations into variables.
14916
d77de738 14917@opindex fexcess-precision
ddf6fe37 14918@item -fexcess-precision=@var{style}
d77de738
ML
14919This option allows further control over excess precision on machines
14920where floating-point operations occur in a format with more precision or
14921range than the IEEE standard and interchange floating-point types. By
14922default, @option{-fexcess-precision=fast} is in effect; this means that
14923operations may be carried out in a wider precision than the types specified
14924in the source if that would result in faster code, and it is unpredictable
14925when rounding to the types specified in the source code takes place.
14926When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14927then excess precision follows the rules specified in ISO C99 or C++; in particular,
14928both casts and assignments cause values to be rounded to their
14929semantic types (whereas @option{-ffloat-store} only affects
14930assignments). This option is enabled by default for C or C++ if a strict
14931conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14932@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14933regardless of whether a strict conformance option is used.
14934
14935@opindex mfpmath
14936@option{-fexcess-precision=standard} is not implemented for languages
14937other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14938or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14939semantics apply without excess precision, and in the latter, rounding
14940is unpredictable.
14941
d77de738 14942@opindex ffast-math
ddf6fe37 14943@item -ffast-math
d77de738
ML
14944Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14945@option{-ffinite-math-only}, @option{-fno-rounding-math},
14946@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14947@option{-fexcess-precision=fast}.
14948
14949This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14950
14951This option is not turned on by any @option{-O} option besides
14952@option{-Ofast} since it can result in incorrect output for programs
14953that depend on an exact implementation of IEEE or ISO rules/specifications
14954for math functions. It may, however, yield faster code for programs
14955that do not require the guarantees of these specifications.
14956
d77de738
ML
14957@opindex fno-math-errno
14958@opindex fmath-errno
ddf6fe37 14959@item -fno-math-errno
d77de738
ML
14960Do not set @code{errno} after calling math functions that are executed
14961with a single instruction, e.g., @code{sqrt}. A program that relies on
14962IEEE exceptions for math error handling may want to use this flag
14963for speed while maintaining IEEE arithmetic compatibility.
14964
14965This option is not turned on by any @option{-O} option since
14966it can result in incorrect output for programs that depend on
14967an exact implementation of IEEE or ISO rules/specifications for
14968math functions. It may, however, yield faster code for programs
14969that do not require the guarantees of these specifications.
14970
14971The default is @option{-fmath-errno}.
14972
14973On Darwin systems, the math library never sets @code{errno}. There is
14974therefore no reason for the compiler to consider the possibility that
14975it might, and @option{-fno-math-errno} is the default.
14976
d77de738 14977@opindex funsafe-math-optimizations
ddf6fe37 14978@item -funsafe-math-optimizations
d77de738
ML
14979
14980Allow optimizations for floating-point arithmetic that (a) assume
14981that arguments and results are valid and (b) may violate IEEE or
14982ANSI standards. When used at link time, it may include libraries
14983or startup files that change the default FPU control word or other
14984similar optimizations.
14985
14986This option is not turned on by any @option{-O} option since
14987it can result in incorrect output for programs that depend on
14988an exact implementation of IEEE or ISO rules/specifications for
14989math functions. It may, however, yield faster code for programs
14990that do not require the guarantees of these specifications.
14991Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14992@option{-fassociative-math} and @option{-freciprocal-math}.
14993
14994The default is @option{-fno-unsafe-math-optimizations}.
14995
d77de738 14996@opindex fassociative-math
ddf6fe37 14997@item -fassociative-math
d77de738
ML
14998
14999Allow re-association of operands in series of floating-point operations.
15000This violates the ISO C and C++ language standard by possibly changing
15001computation result. NOTE: re-ordering may change the sign of zero as
15002well as ignore NaNs and inhibit or create underflow or overflow (and
15003thus cannot be used on code that relies on rounding behavior like
15004@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
15005and thus may not be used when ordered comparisons are required.
15006This option requires that both @option{-fno-signed-zeros} and
15007@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
15008much sense with @option{-frounding-math}. For Fortran the option
15009is automatically enabled when both @option{-fno-signed-zeros} and
15010@option{-fno-trapping-math} are in effect.
15011
15012The default is @option{-fno-associative-math}.
15013
d77de738 15014@opindex freciprocal-math
ddf6fe37 15015@item -freciprocal-math
d77de738
ML
15016
15017Allow the reciprocal of a value to be used instead of dividing by
15018the value if this enables optimizations. For example @code{x / y}
15019can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
15020is subject to common subexpression elimination. Note that this loses
15021precision and increases the number of flops operating on the value.
15022
15023The default is @option{-fno-reciprocal-math}.
15024
d77de738 15025@opindex ffinite-math-only
ddf6fe37 15026@item -ffinite-math-only
d77de738
ML
15027Allow optimizations for floating-point arithmetic that assume
15028that arguments and results are not NaNs or +-Infs.
15029
15030This option is not turned on by any @option{-O} option since
15031it can result in incorrect output for programs that depend on
15032an exact implementation of IEEE or ISO rules/specifications for
15033math functions. It may, however, yield faster code for programs
15034that do not require the guarantees of these specifications.
15035
15036The default is @option{-fno-finite-math-only}.
15037
d77de738
ML
15038@opindex fno-signed-zeros
15039@opindex fsigned-zeros
ddf6fe37 15040@item -fno-signed-zeros
d77de738
ML
15041Allow optimizations for floating-point arithmetic that ignore the
15042signedness of zero. IEEE arithmetic specifies the behavior of
15043distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
15044of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
15045This option implies that the sign of a zero result isn't significant.
15046
15047The default is @option{-fsigned-zeros}.
15048
d77de738
ML
15049@opindex fno-trapping-math
15050@opindex ftrapping-math
ddf6fe37 15051@item -fno-trapping-math
d77de738
ML
15052Compile code assuming that floating-point operations cannot generate
15053user-visible traps. These traps include division by zero, overflow,
15054underflow, inexact result and invalid operation. This option requires
15055that @option{-fno-signaling-nans} be in effect. Setting this option may
15056allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
15057
15058This option should never be turned on by any @option{-O} option since
15059it can result in incorrect output for programs that depend on
15060an exact implementation of IEEE or ISO rules/specifications for
15061math functions.
15062
15063The default is @option{-ftrapping-math}.
15064
15065Future versions of GCC may provide finer control of this setting
15066using C99's @code{FENV_ACCESS} pragma. This command-line option
15067will be used along with @option{-frounding-math} to specify the
15068default state for @code{FENV_ACCESS}.
15069
d77de738 15070@opindex frounding-math
ddf6fe37 15071@item -frounding-math
d77de738
ML
15072Disable transformations and optimizations that assume default floating-point
15073rounding behavior. This is round-to-zero for all floating point
15074to integer conversions, and round-to-nearest for all other arithmetic
15075truncations. This option should be specified for programs that change
15076the FP rounding mode dynamically, or that may be executed with a
15077non-default rounding mode. This option disables constant folding of
15078floating-point expressions at compile time (which may be affected by
15079rounding mode) and arithmetic transformations that are unsafe in the
15080presence of sign-dependent rounding modes.
15081
15082The default is @option{-fno-rounding-math}.
15083
15084This option is experimental and does not currently guarantee to
15085disable all GCC optimizations that are affected by rounding mode.
15086Future versions of GCC may provide finer control of this setting
15087using C99's @code{FENV_ACCESS} pragma. This command-line option
15088will be used along with @option{-ftrapping-math} to specify the
15089default state for @code{FENV_ACCESS}.
15090
d77de738 15091@opindex fsignaling-nans
ddf6fe37 15092@item -fsignaling-nans
d77de738
ML
15093Compile code assuming that IEEE signaling NaNs may generate user-visible
15094traps during floating-point operations. Setting this option disables
15095optimizations that may change the number of exceptions visible with
15096signaling NaNs. This option implies @option{-ftrapping-math}.
15097
15098This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
15099be defined.
15100
15101The default is @option{-fno-signaling-nans}.
15102
15103This option is experimental and does not currently guarantee to
15104disable all GCC optimizations that affect signaling NaN behavior.
15105
d77de738
ML
15106@opindex fno-fp-int-builtin-inexact
15107@opindex ffp-int-builtin-inexact
ddf6fe37 15108@item -fno-fp-int-builtin-inexact
d77de738
ML
15109Do not allow the built-in functions @code{ceil}, @code{floor},
15110@code{round} and @code{trunc}, and their @code{float} and @code{long
15111double} variants, to generate code that raises the ``inexact''
15112floating-point exception for noninteger arguments. ISO C99 and C11
15113allow these functions to raise the ``inexact'' exception, but ISO/IEC
15114TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
094a609c 15115ISO C23, does not allow these functions to do so.
d77de738
ML
15116
15117The default is @option{-ffp-int-builtin-inexact}, allowing the
094a609c 15118exception to be raised, unless C23 or a later C standard is selected.
d77de738
ML
15119This option does nothing unless @option{-ftrapping-math} is in effect.
15120
15121Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
15122generate a call to a library function then the ``inexact'' exception
15123may be raised if the library implementation does not follow TS 18661.
15124
d77de738 15125@opindex fsingle-precision-constant
ddf6fe37 15126@item -fsingle-precision-constant
d77de738
ML
15127Treat floating-point constants as single precision instead of
15128implicitly converting them to double-precision constants.
15129
d77de738 15130@opindex fcx-limited-range
ddf6fe37 15131@item -fcx-limited-range
d77de738
ML
15132When enabled, this option states that a range reduction step is not
15133needed when performing complex division. Also, there is no checking
15134whether the result of a complex multiplication or division is @code{NaN
15135+ I*NaN}, with an attempt to rescue the situation in that case. The
15136default is @option{-fno-cx-limited-range}, but is enabled by
15137@option{-ffast-math}.
15138
15139This option controls the default setting of the ISO C99
15140@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
15141all languages.
15142
d77de738 15143@opindex fcx-fortran-rules
ddf6fe37 15144@item -fcx-fortran-rules
d77de738
ML
15145Complex multiplication and division follow Fortran rules. Range
15146reduction is done as part of complex division, but there is no checking
15147whether the result of a complex multiplication or division is @code{NaN
15148+ I*NaN}, with an attempt to rescue the situation in that case.
15149
15150The default is @option{-fno-cx-fortran-rules}.
15151
15152@end table
15153
15154The following options control optimizations that may improve
15155performance, but are not enabled by any @option{-O} options. This
15156section includes experimental options that may produce broken code.
15157
15158@table @gcctabopt
d77de738 15159@opindex fbranch-probabilities
ddf6fe37 15160@item -fbranch-probabilities
d77de738
ML
15161After running a program compiled with @option{-fprofile-arcs}
15162(@pxref{Instrumentation Options}),
15163you can compile it a second time using
15164@option{-fbranch-probabilities}, to improve optimizations based on
15165the number of times each branch was taken. When a program
15166compiled with @option{-fprofile-arcs} exits, it saves arc execution
15167counts to a file called @file{@var{sourcename}.gcda} for each source
15168file. The information in this data file is very dependent on the
15169structure of the generated code, so you must use the same source code
15170and the same optimization options for both compilations.
15171See details about the file naming in @option{-fprofile-arcs}.
15172
15173With @option{-fbranch-probabilities}, GCC puts a
15174@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
15175These can be used to improve optimization. Currently, they are only
15176used in one place: in @file{reorg.cc}, instead of guessing which path a
15177branch is most likely to take, the @samp{REG_BR_PROB} values are used to
15178exactly determine which path is taken more often.
15179
15180Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15181
d77de738 15182@opindex fprofile-values
ddf6fe37 15183@item -fprofile-values
d77de738
ML
15184If combined with @option{-fprofile-arcs}, it adds code so that some
15185data about values of expressions in the program is gathered.
15186
15187With @option{-fbranch-probabilities}, it reads back the data gathered
15188from profiling values of expressions for usage in optimizations.
15189
15190Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
15191@option{-fauto-profile}.
15192
d77de738 15193@opindex fprofile-reorder-functions
ddf6fe37 15194@item -fprofile-reorder-functions
d77de738
ML
15195Function reordering based on profile instrumentation collects
15196first time of execution of a function and orders these functions
15197in ascending order.
15198
15199Enabled with @option{-fprofile-use}.
15200
d77de738 15201@opindex fvpt
ddf6fe37 15202@item -fvpt
d77de738
ML
15203If combined with @option{-fprofile-arcs}, this option instructs the compiler
15204to add code to gather information about values of expressions.
15205
15206With @option{-fbranch-probabilities}, it reads back the data gathered
15207and actually performs the optimizations based on them.
15208Currently the optimizations include specialization of division operations
15209using the knowledge about the value of the denominator.
15210
15211Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
15212
d77de738 15213@opindex frename-registers
ddf6fe37 15214@item -frename-registers
d77de738
ML
15215Attempt to avoid false dependencies in scheduled code by making use
15216of registers left over after register allocation. This optimization
15217most benefits processors with lots of registers. Depending on the
15218debug information format adopted by the target, however, it can
15219make debugging impossible, since variables no longer stay in
15220a ``home register''.
15221
15222Enabled by default with @option{-funroll-loops}.
15223
d77de738 15224@opindex fschedule-fusion
ddf6fe37 15225@item -fschedule-fusion
d77de738
ML
15226Performs a target dependent pass over the instruction stream to schedule
15227instructions of same type together because target machine can execute them
15228more efficiently if they are adjacent to each other in the instruction flow.
15229
15230Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
15231
d77de738 15232@opindex ftracer
ddf6fe37 15233@item -ftracer
d77de738
ML
15234Perform tail duplication to enlarge superblock size. This transformation
15235simplifies the control flow of the function allowing other optimizations to do
15236a better job.
15237
15238Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15239
d77de738 15240@opindex funroll-loops
ddf6fe37 15241@item -funroll-loops
d77de738
ML
15242Unroll loops whose number of iterations can be determined at compile time or
15243upon entry to the loop. @option{-funroll-loops} implies
15244@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
15245It also turns on complete loop peeling (i.e.@: complete removal of loops with
15246a small constant number of iterations). This option makes code larger, and may
15247or may not make it run faster.
15248
15249Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15250
d77de738 15251@opindex funroll-all-loops
ddf6fe37 15252@item -funroll-all-loops
d77de738
ML
15253Unroll all loops, even if their number of iterations is uncertain when
15254the loop is entered. This usually makes programs run more slowly.
15255@option{-funroll-all-loops} implies the same options as
15256@option{-funroll-loops}.
15257
d77de738 15258@opindex fpeel-loops
ddf6fe37 15259@item -fpeel-loops
d77de738
ML
15260Peels loops for which there is enough information that they do not
15261roll much (from profile feedback or static analysis). It also turns on
15262complete loop peeling (i.e.@: complete removal of loops with small constant
15263number of iterations).
15264
15265Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
15266
d77de738 15267@opindex fmove-loop-invariants
ddf6fe37 15268@item -fmove-loop-invariants
d77de738
ML
15269Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
15270at level @option{-O1} and higher, except for @option{-Og}.
15271
d77de738 15272@opindex fmove-loop-stores
ddf6fe37 15273@item -fmove-loop-stores
d77de738
ML
15274Enables the loop store motion pass in the GIMPLE loop optimizer. This
15275moves invariant stores to after the end of the loop in exchange for
15276carrying the stored value in a register across the iteration.
15277Note for this option to have an effect @option{-ftree-loop-im} has to
15278be enabled as well. Enabled at level @option{-O1} and higher, except
15279for @option{-Og}.
15280
d77de738 15281@opindex fsplit-loops
ddf6fe37 15282@item -fsplit-loops
d77de738
ML
15283Split a loop into two if it contains a condition that's always true
15284for one side of the iteration space and false for the other.
15285
15286Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15287
d77de738 15288@opindex funswitch-loops
ddf6fe37 15289@item -funswitch-loops
d77de738
ML
15290Move branches with loop invariant conditions out of the loop, with duplicates
15291of the loop on both branches (modified according to result of the condition).
15292
15293Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15294
d77de738 15295@opindex fversion-loops-for-strides
ddf6fe37 15296@item -fversion-loops-for-strides
d77de738
ML
15297If a loop iterates over an array with a variable stride, create another
15298version of the loop that assumes the stride is always one. For example:
15299
15300@smallexample
15301for (int i = 0; i < n; ++i)
15302 x[i * stride] = @dots{};
15303@end smallexample
15304
15305becomes:
15306
15307@smallexample
15308if (stride == 1)
15309 for (int i = 0; i < n; ++i)
15310 x[i] = @dots{};
15311else
15312 for (int i = 0; i < n; ++i)
15313 x[i * stride] = @dots{};
15314@end smallexample
15315
15316This is particularly useful for assumed-shape arrays in Fortran where
15317(for example) it allows better vectorization assuming contiguous accesses.
15318This flag is enabled by default at @option{-O3}.
15319It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
15320
d77de738
ML
15321@opindex ffunction-sections
15322@opindex fdata-sections
ddf6fe37
AA
15323@item -ffunction-sections
15324@itemx -fdata-sections
d77de738
ML
15325Place each function or data item into its own section in the output
15326file if the target supports arbitrary sections. The name of the
15327function or the name of the data item determines the section's name
15328in the output file.
15329
15330Use these options on systems where the linker can perform optimizations to
15331improve locality of reference in the instruction space. Most systems using the
15332ELF object format have linkers with such optimizations. On AIX, the linker
15333rearranges sections (CSECTs) based on the call graph. The performance impact
15334varies.
15335
15336Together with a linker garbage collection (linker @option{--gc-sections}
15337option) these options may lead to smaller statically-linked executables (after
15338stripping).
15339
15340On ELF/DWARF systems these options do not degenerate the quality of the debug
15341information. There could be issues with other object files/debug info formats.
15342
15343Only use these options when there are significant benefits from doing so. When
15344you specify these options, the assembler and linker create larger object and
15345executable files and are also slower. These options affect code generation.
15346They prevent optimizations by the compiler and assembler using relative
15347locations inside a translation unit since the locations are unknown until
15348link time. An example of such an optimization is relaxing calls to short call
15349instructions.
15350
d77de738 15351@opindex fstdarg-opt
ddf6fe37 15352@item -fstdarg-opt
d77de738
ML
15353Optimize the prologue of variadic argument functions with respect to usage of
15354those arguments.
15355
d77de738 15356@opindex fsection-anchors
ddf6fe37 15357@item -fsection-anchors
d77de738
ML
15358Try to reduce the number of symbolic address calculations by using
15359shared ``anchor'' symbols to address nearby objects. This transformation
15360can help to reduce the number of GOT entries and GOT accesses on some
15361targets.
15362
15363For example, the implementation of the following function @code{foo}:
15364
15365@smallexample
15366static int a, b, c;
15367int foo (void) @{ return a + b + c; @}
15368@end smallexample
15369
15370@noindent
15371usually calculates the addresses of all three variables, but if you
15372compile it with @option{-fsection-anchors}, it accesses the variables
15373from a common anchor point instead. The effect is similar to the
15374following pseudocode (which isn't valid C):
15375
15376@smallexample
15377int foo (void)
15378@{
15379 register int *xr = &x;
15380 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
15381@}
15382@end smallexample
15383
15384Not all targets support this option.
15385
d77de738 15386@opindex fzero-call-used-regs
ddf6fe37 15387@item -fzero-call-used-regs=@var{choice}
d77de738
ML
15388Zero call-used registers at function return to increase program
15389security by either mitigating Return-Oriented Programming (ROP)
15390attacks or preventing information leakage through registers.
15391
15392The possible values of @var{choice} are the same as for the
15393@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
15394The default is @samp{skip}.
15395
15396You can control this behavior for a specific function by using the function
15397attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
15398
d77de738 15399@opindex param
ddf6fe37 15400@item --param @var{name}=@var{value}
d77de738
ML
15401In some places, GCC uses various constants to control the amount of
15402optimization that is done. For example, GCC does not inline functions
15403that contain more than a certain number of instructions. You can
15404control some of these constants on the command line using the
15405@option{--param} option.
15406
15407The names of specific parameters, and the meaning of the values, are
15408tied to the internals of the compiler, and are subject to change
15409without notice in future releases.
15410
c381327d
GP
15411In order to get the minimal, maximal and default values of a parameter,
15412use the @option{--help=param -Q} options.
d77de738
ML
15413
15414In each case, the @var{value} is an integer. The following choices
15415of @var{name} are recognized for all targets:
15416
15417@table @gcctabopt
15418@item predictable-branch-outcome
15419When branch is predicted to be taken with probability lower than this threshold
15420(in percent), then it is considered well predictable.
15421
15422@item max-rtl-if-conversion-insns
15423RTL if-conversion tries to remove conditional branches around a block and
15424replace them with conditionally executed instructions. This parameter
15425gives the maximum number of instructions in a block which should be
15426considered for if-conversion. The compiler will
15427also use other heuristics to decide whether if-conversion is likely to be
15428profitable.
15429
15430@item max-rtl-if-conversion-predictable-cost
15431RTL if-conversion will try to remove conditional branches around a block
15432and replace them with conditionally executed instructions. These parameters
15433give the maximum permissible cost for the sequence that would be generated
15434by if-conversion depending on whether the branch is statically determined
15435to be predictable or not. The units for this parameter are the same as
15436those for the GCC internal seq_cost metric. The compiler will try to
15437provide a reasonable default for this parameter using the BRANCH_COST
15438target macro.
15439
15440@item max-crossjump-edges
15441The maximum number of incoming edges to consider for cross-jumping.
15442The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
15443the number of edges incoming to each block. Increasing values mean
15444more aggressive optimization, making the compilation time increase with
15445probably small improvement in executable size.
15446
15447@item min-crossjump-insns
15448The minimum number of instructions that must be matched at the end
15449of two blocks before cross-jumping is performed on them. This
15450value is ignored in the case where all instructions in the block being
15451cross-jumped from are matched.
15452
15453@item max-grow-copy-bb-insns
15454The maximum code size expansion factor when copying basic blocks
15455instead of jumping. The expansion is relative to a jump instruction.
15456
15457@item max-goto-duplication-insns
15458The maximum number of instructions to duplicate to a block that jumps
15459to a computed goto. To avoid @math{O(N^2)} behavior in a number of
15460passes, GCC factors computed gotos early in the compilation process,
15461and unfactors them as late as possible. Only computed jumps at the
15462end of a basic blocks with no more than max-goto-duplication-insns are
15463unfactored.
15464
15465@item max-delay-slot-insn-search
15466The maximum number of instructions to consider when looking for an
15467instruction to fill a delay slot. If more than this arbitrary number of
15468instructions are searched, the time savings from filling the delay slot
15469are minimal, so stop searching. Increasing values mean more
15470aggressive optimization, making the compilation time increase with probably
15471small improvement in execution time.
15472
15473@item max-delay-slot-live-search
15474When trying to fill delay slots, the maximum number of instructions to
15475consider when searching for a block with valid live register
15476information. Increasing this arbitrarily chosen value means more
15477aggressive optimization, increasing the compilation time. This parameter
15478should be removed when the delay slot code is rewritten to maintain the
15479control-flow graph.
15480
15481@item max-gcse-memory
15482The approximate maximum amount of memory in @code{kB} that can be allocated in
15483order to perform the global common subexpression elimination
15484optimization. If more memory than specified is required, the
15485optimization is not done.
15486
15487@item max-gcse-insertion-ratio
15488If the ratio of expression insertions to deletions is larger than this value
15489for any expression, then RTL PRE inserts or removes the expression and thus
15490leaves partially redundant computations in the instruction stream.
15491
15492@item max-pending-list-length
15493The maximum number of pending dependencies scheduling allows
15494before flushing the current state and starting over. Large functions
15495with few branches or calls can create excessively large lists which
15496needlessly consume memory and resources.
15497
15498@item max-modulo-backtrack-attempts
15499The maximum number of backtrack attempts the scheduler should make
15500when modulo scheduling a loop. Larger values can exponentially increase
15501compilation time.
15502
15503@item max-inline-functions-called-once-loop-depth
15504Maximal loop depth of a call considered by inline heuristics that tries to
15505inline all functions called once.
15506
15507@item max-inline-functions-called-once-insns
15508Maximal estimated size of functions produced while inlining functions called
15509once.
15510
15511@item max-inline-insns-single
15512Several parameters control the tree inliner used in GCC@. This number sets the
15513maximum number of instructions (counted in GCC's internal representation) in a
15514single function that the tree inliner considers for inlining. This only
15515affects functions declared inline and methods implemented in a class
15516declaration (C++).
15517
15518
15519@item max-inline-insns-auto
15520When you use @option{-finline-functions} (included in @option{-O3}),
15521a lot of functions that would otherwise not be considered for inlining
15522by the compiler are investigated. To those functions, a different
15523(more restrictive) limit compared to functions declared inline can
15524be applied (@option{--param max-inline-insns-auto}).
15525
15526@item max-inline-insns-small
15527This is bound applied to calls which are considered relevant with
15528@option{-finline-small-functions}.
15529
15530@item max-inline-insns-size
15531This is bound applied to calls which are optimized for size. Small growth
15532may be desirable to anticipate optimization oppurtunities exposed by inlining.
15533
15534@item uninlined-function-insns
15535Number of instructions accounted by inliner for function overhead such as
15536function prologue and epilogue.
15537
15538@item uninlined-function-time
15539Extra time accounted by inliner for function overhead such as time needed to
15540execute function prologue and epilogue.
15541
15542@item inline-heuristics-hint-percent
15543The scale (in percents) applied to @option{inline-insns-single},
15544@option{inline-insns-single-O2}, @option{inline-insns-auto}
15545when inline heuristics hints that inlining is
15546very profitable (will enable later optimizations).
15547
15548@item uninlined-thunk-insns
15549@item uninlined-thunk-time
15550Same as @option{--param uninlined-function-insns} and
15551@option{--param uninlined-function-time} but applied to function thunks.
15552
15553@item inline-min-speedup
15554When estimated performance improvement of caller + callee runtime exceeds this
15555threshold (in percent), the function can be inlined regardless of the limit on
15556@option{--param max-inline-insns-single} and @option{--param
15557max-inline-insns-auto}.
15558
15559@item large-function-insns
15560The limit specifying really large functions. For functions larger than this
15561limit after inlining, inlining is constrained by
15562@option{--param large-function-growth}. This parameter is useful primarily
15563to avoid extreme compilation time caused by non-linear algorithms used by the
15564back end.
15565
15566@item large-function-growth
15567Specifies maximal growth of large function caused by inlining in percents.
15568For example, parameter value 100 limits large function growth to 2.0 times
15569the original size.
15570
15571@item large-unit-insns
15572The limit specifying large translation unit. Growth caused by inlining of
15573units larger than this limit is limited by @option{--param inline-unit-growth}.
15574For small units this might be too tight.
15575For example, consider a unit consisting of function A
15576that is inline and B that just calls A three times. If B is small relative to
15577A, the growth of unit is 300\% and yet such inlining is very sane. For very
15578large units consisting of small inlineable functions, however, the overall unit
15579growth limit is needed to avoid exponential explosion of code size. Thus for
15580smaller units, the size is increased to @option{--param large-unit-insns}
15581before applying @option{--param inline-unit-growth}.
15582
15583@item lazy-modules
15584Maximum number of concurrently open C++ module files when lazy loading.
15585
15586@item inline-unit-growth
15587Specifies maximal overall growth of the compilation unit caused by inlining.
15588For example, parameter value 20 limits unit growth to 1.2 times the original
15589size. Cold functions (either marked cold via an attribute or by profile
15590feedback) are not accounted into the unit size.
15591
15592@item ipa-cp-unit-growth
15593Specifies maximal overall growth of the compilation unit caused by
15594interprocedural constant propagation. For example, parameter value 10 limits
15595unit growth to 1.1 times the original size.
15596
15597@item ipa-cp-large-unit-insns
15598The size of translation unit that IPA-CP pass considers large.
15599
15600@item large-stack-frame
15601The limit specifying large stack frames. While inlining the algorithm is trying
15602to not grow past this limit too much.
15603
15604@item large-stack-frame-growth
15605Specifies maximal growth of large stack frames caused by inlining in percents.
15606For example, parameter value 1000 limits large stack frame growth to 11 times
15607the original size.
15608
15609@item max-inline-insns-recursive
15610@itemx max-inline-insns-recursive-auto
15611Specifies the maximum number of instructions an out-of-line copy of a
15612self-recursive inline
15613function can grow into by performing recursive inlining.
15614
15615@option{--param max-inline-insns-recursive} applies to functions
15616declared inline.
15617For functions not declared inline, recursive inlining
15618happens only when @option{-finline-functions} (included in @option{-O3}) is
15619enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
15620
15621@item max-inline-recursive-depth
15622@itemx max-inline-recursive-depth-auto
15623Specifies the maximum recursion depth used for recursive inlining.
15624
15625@option{--param max-inline-recursive-depth} applies to functions
15626declared inline. For functions not declared inline, recursive inlining
15627happens only when @option{-finline-functions} (included in @option{-O3}) is
15628enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
15629
15630@item min-inline-recursive-probability
15631Recursive inlining is profitable only for function having deep recursion
15632in average and can hurt for function having little recursion depth by
15633increasing the prologue size or complexity of function body to other
15634optimizers.
15635
15636When profile feedback is available (see @option{-fprofile-generate}) the actual
15637recursion depth can be guessed from the probability that function recurses
15638via a given call expression. This parameter limits inlining only to call
15639expressions whose probability exceeds the given threshold (in percents).
15640
15641@item early-inlining-insns
15642Specify growth that the early inliner can make. In effect it increases
15643the amount of inlining for code having a large abstraction penalty.
15644
15645@item max-early-inliner-iterations
15646Limit of iterations of the early inliner. This basically bounds
15647the number of nested indirect calls the early inliner can resolve.
15648Deeper chains are still handled by late inlining.
15649
15650@item comdat-sharing-probability
15651Probability (in percent) that C++ inline function with comdat visibility
15652are shared across multiple compilation units.
15653
15654@item modref-max-bases
15655@item modref-max-refs
15656@item modref-max-accesses
15657Specifies the maximal number of base pointers, references and accesses stored
15658for a single function by mod/ref analysis.
15659
15660@item modref-max-tests
15661Specifies the maxmal number of tests alias oracle can perform to disambiguate
15662memory locations using the mod/ref information. This parameter ought to be
15663bigger than @option{--param modref-max-bases} and @option{--param
15664modref-max-refs}.
15665
15666@item modref-max-depth
15667Specifies the maximum depth of DFS walk used by modref escape analysis.
15668Setting to 0 disables the analysis completely.
15669
15670@item modref-max-escape-points
15671Specifies the maximum number of escape points tracked by modref per SSA-name.
15672
15673@item modref-max-adjustments
15674Specifies the maximum number the access range is enlarged during modref dataflow
15675analysis.
15676
15677@item profile-func-internal-id
15678A parameter to control whether to use function internal id in profile
15679database lookup. If the value is 0, the compiler uses an id that
15680is based on function assembler name and filename, which makes old profile
15681data more tolerant to source changes such as function reordering etc.
15682
15683@item min-vect-loop-bound
15684The minimum number of iterations under which loops are not vectorized
15685when @option{-ftree-vectorize} is used. The number of iterations after
15686vectorization needs to be greater than the value specified by this option
15687to allow vectorization.
15688
15689@item gcse-cost-distance-ratio
15690Scaling factor in calculation of maximum distance an expression
15691can be moved by GCSE optimizations. This is currently supported only in the
15692code hoisting pass. The bigger the ratio, the more aggressive code hoisting
15693is with simple expressions, i.e., the expressions that have cost
15694less than @option{gcse-unrestricted-cost}. Specifying 0 disables
15695hoisting of simple expressions.
15696
15697@item gcse-unrestricted-cost
15698Cost, roughly measured as the cost of a single typical machine
15699instruction, at which GCSE optimizations do not constrain
15700the distance an expression can travel. This is currently
15701supported only in the code hoisting pass. The lesser the cost,
15702the more aggressive code hoisting is. Specifying 0
15703allows all expressions to travel unrestricted distances.
15704
15705@item max-hoist-depth
15706The depth of search in the dominator tree for expressions to hoist.
15707This is used to avoid quadratic behavior in hoisting algorithm.
15708The value of 0 does not limit on the search, but may slow down compilation
15709of huge functions.
15710
15711@item max-tail-merge-comparisons
15712The maximum amount of similar bbs to compare a bb with. This is used to
15713avoid quadratic behavior in tree tail merging.
15714
15715@item max-tail-merge-iterations
15716The maximum amount of iterations of the pass over the function. This is used to
15717limit compilation time in tree tail merging.
15718
15719@item store-merging-allow-unaligned
15720Allow the store merging pass to introduce unaligned stores if it is legal to
15721do so.
15722
15723@item max-stores-to-merge
15724The maximum number of stores to attempt to merge into wider stores in the store
15725merging pass.
15726
15727@item max-store-chains-to-track
15728The maximum number of store chains to track at the same time in the attempt
15729to merge them into wider stores in the store merging pass.
15730
15731@item max-stores-to-track
15732The maximum number of stores to track at the same time in the attemt to
15733to merge them into wider stores in the store merging pass.
15734
15735@item max-unrolled-insns
15736The maximum number of instructions that a loop may have to be unrolled.
15737If a loop is unrolled, this parameter also determines how many times
15738the loop code is unrolled.
15739
15740@item max-average-unrolled-insns
15741The maximum number of instructions biased by probabilities of their execution
15742that a loop may have to be unrolled. If a loop is unrolled,
15743this parameter also determines how many times the loop code is unrolled.
15744
15745@item max-unroll-times
15746The maximum number of unrollings of a single loop.
15747
15748@item max-peeled-insns
15749The maximum number of instructions that a loop may have to be peeled.
15750If a loop is peeled, this parameter also determines how many times
15751the loop code is peeled.
15752
15753@item max-peel-times
15754The maximum number of peelings of a single loop.
15755
15756@item max-peel-branches
15757The maximum number of branches on the hot path through the peeled sequence.
15758
15759@item max-completely-peeled-insns
15760The maximum number of insns of a completely peeled loop.
15761
15762@item max-completely-peel-times
15763The maximum number of iterations of a loop to be suitable for complete peeling.
15764
15765@item max-completely-peel-loop-nest-depth
15766The maximum depth of a loop nest suitable for complete peeling.
15767
15768@item max-unswitch-insns
15769The maximum number of insns of an unswitched loop.
15770
5b50850c
RB
15771@item max-unswitch-depth
15772The maximum depth of a loop nest to be unswitched.
15773
d77de738
ML
15774@item lim-expensive
15775The minimum cost of an expensive expression in the loop invariant motion.
15776
15777@item min-loop-cond-split-prob
15778When FDO profile information is available, @option{min-loop-cond-split-prob}
15779specifies minimum threshold for probability of semi-invariant condition
15780statement to trigger loop split.
15781
15782@item iv-consider-all-candidates-bound
15783Bound on number of candidates for induction variables, below which
15784all candidates are considered for each use in induction variable
15785optimizations. If there are more candidates than this,
15786only the most relevant ones are considered to avoid quadratic time complexity.
15787
15788@item iv-max-considered-uses
15789The induction variable optimizations give up on loops that contain more
15790induction variable uses.
15791
15792@item iv-always-prune-cand-set-bound
15793If the number of candidates in the set is smaller than this value,
15794always try to remove unnecessary ivs from the set
15795when adding a new one.
15796
15797@item avg-loop-niter
15798Average number of iterations of a loop.
15799
15800@item dse-max-object-size
15801Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15802Larger values may result in larger compilation times.
15803
15804@item dse-max-alias-queries-per-store
15805Maximum number of queries into the alias oracle per store.
15806Larger values result in larger compilation times and may result in more
15807removed dead stores.
15808
15809@item scev-max-expr-size
15810Bound on size of expressions used in the scalar evolutions analyzer.
15811Large expressions slow the analyzer.
15812
15813@item scev-max-expr-complexity
15814Bound on the complexity of the expressions in the scalar evolutions analyzer.
15815Complex expressions slow the analyzer.
15816
15817@item max-tree-if-conversion-phi-args
15818Maximum number of arguments in a PHI supported by TREE if conversion
15819unless the loop is marked with simd pragma.
15820
15821@item vect-max-layout-candidates
15822The maximum number of possible vector layouts (such as permutations)
15823to consider when optimizing to-be-vectorized code.
15824
15825@item vect-max-version-for-alignment-checks
15826The maximum number of run-time checks that can be performed when
15827doing loop versioning for alignment in the vectorizer.
15828
15829@item vect-max-version-for-alias-checks
15830The maximum number of run-time checks that can be performed when
15831doing loop versioning for alias in the vectorizer.
15832
15833@item vect-max-peeling-for-alignment
15834The maximum number of loop peels to enhance access alignment
15835for vectorizer. Value -1 means no limit.
15836
15837@item max-iterations-to-track
15838The maximum number of iterations of a loop the brute-force algorithm
15839for analysis of the number of iterations of the loop tries to evaluate.
15840
15841@item hot-bb-count-fraction
15842The denominator n of fraction 1/n of the maximal execution count of a
15843basic block in the entire program that a basic block needs to at least
15844have in order to be considered hot. The default is 10000, which means
15845that a basic block is considered hot if its execution count is greater
15846than 1/10000 of the maximal execution count. 0 means that it is never
15847considered hot. Used in non-LTO mode.
15848
15849@item hot-bb-count-ws-permille
15850The number of most executed permilles, ranging from 0 to 1000, of the
15851profiled execution of the entire program to which the execution count
15852of a basic block must be part of in order to be considered hot. The
15853default is 990, which means that a basic block is considered hot if
15854its execution count contributes to the upper 990 permilles, or 99.0%,
15855of the profiled execution of the entire program. 0 means that it is
15856never considered hot. Used in LTO mode.
15857
15858@item hot-bb-frequency-fraction
15859The denominator n of fraction 1/n of the execution frequency of the
15860entry block of a function that a basic block of this function needs
15861to at least have in order to be considered hot. The default is 1000,
15862which means that a basic block is considered hot in a function if it
15863is executed more frequently than 1/1000 of the frequency of the entry
15864block of the function. 0 means that it is never considered hot.
15865
15866@item unlikely-bb-count-fraction
15867The denominator n of fraction 1/n of the number of profiled runs of
15868the entire program below which the execution count of a basic block
15869must be in order for the basic block to be considered unlikely executed.
15870The default is 20, which means that a basic block is considered unlikely
15871executed if it is executed in fewer than 1/20, or 5%, of the runs of
15872the program. 0 means that it is always considered unlikely executed.
15873
15874@item max-predicted-iterations
15875The maximum number of loop iterations we predict statically. This is useful
15876in cases where a function contains a single loop with known bound and
15877another loop with unknown bound.
15878The known number of iterations is predicted correctly, while
15879the unknown number of iterations average to roughly 10. This means that the
15880loop without bounds appears artificially cold relative to the other one.
15881
15882@item builtin-expect-probability
15883Control the probability of the expression having the specified value. This
15884parameter takes a percentage (i.e.@: 0 ... 100) as input.
15885
15886@item builtin-string-cmp-inline-length
15887The maximum length of a constant string for a builtin string cmp call
15888eligible for inlining.
15889
15890@item align-threshold
15891
15892Select fraction of the maximal frequency of executions of a basic block in
15893a function to align the basic block.
15894
15895@item align-loop-iterations
15896
15897A loop expected to iterate at least the selected number of iterations is
15898aligned.
15899
15900@item tracer-dynamic-coverage
15901@itemx tracer-dynamic-coverage-feedback
15902
15903This value is used to limit superblock formation once the given percentage of
15904executed instructions is covered. This limits unnecessary code size
15905expansion.
15906
15907The @option{tracer-dynamic-coverage-feedback} parameter
15908is used only when profile
15909feedback is available. The real profiles (as opposed to statically estimated
15910ones) are much less balanced allowing the threshold to be larger value.
15911
15912@item tracer-max-code-growth
15913Stop tail duplication once code growth has reached given percentage. This is
15914a rather artificial limit, as most of the duplicates are eliminated later in
15915cross jumping, so it may be set to much higher values than is the desired code
15916growth.
15917
15918@item tracer-min-branch-ratio
15919
15920Stop reverse growth when the reverse probability of best edge is less than this
15921threshold (in percent).
15922
15923@item tracer-min-branch-probability
15924@itemx tracer-min-branch-probability-feedback
15925
15926Stop forward growth if the best edge has probability lower than this
15927threshold.
15928
15929Similarly to @option{tracer-dynamic-coverage} two parameters are
15930provided. @option{tracer-min-branch-probability-feedback} is used for
15931compilation with profile feedback and @option{tracer-min-branch-probability}
15932compilation without. The value for compilation with profile feedback
15933needs to be more conservative (higher) in order to make tracer
15934effective.
15935
15936@item stack-clash-protection-guard-size
15937Specify the size of the operating system provided stack guard as
159382 raised to @var{num} bytes. Higher values may reduce the
15939number of explicit probes, but a value larger than the operating system
15940provided guard will leave code vulnerable to stack clash style attacks.
15941
15942@item stack-clash-protection-probe-interval
15943Stack clash protection involves probing stack space as it is allocated. This
15944param controls the maximum distance between probes into the stack as 2 raised
15945to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15946larger than the operating system provided guard will leave code vulnerable to
15947stack clash style attacks.
15948
15949@item max-cse-path-length
15950
15951The maximum number of basic blocks on path that CSE considers.
15952
15953@item max-cse-insns
15954The maximum number of instructions CSE processes before flushing.
15955
15956@item ggc-min-expand
15957
15958GCC uses a garbage collector to manage its own memory allocation. This
15959parameter specifies the minimum percentage by which the garbage
15960collector's heap should be allowed to expand between collections.
15961Tuning this may improve compilation speed; it has no effect on code
15962generation.
15963
15964The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15965RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15966the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15967GCC is not able to calculate RAM on a particular platform, the lower
15968bound of 30% is used. Setting this parameter and
15969@option{ggc-min-heapsize} to zero causes a full collection to occur at
15970every opportunity. This is extremely slow, but can be useful for
15971debugging.
15972
15973@item ggc-min-heapsize
15974
15975Minimum size of the garbage collector's heap before it begins bothering
15976to collect garbage. The first collection occurs after the heap expands
15977by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15978tuning this may improve compilation speed, and has no effect on code
15979generation.
15980
15981The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15982tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15983with a lower bound of 4096 (four megabytes) and an upper bound of
15984131072 (128 megabytes). If GCC is not able to calculate RAM on a
15985particular platform, the lower bound is used. Setting this parameter
15986very large effectively disables garbage collection. Setting this
15987parameter and @option{ggc-min-expand} to zero causes a full collection
15988to occur at every opportunity.
15989
15990@item max-reload-search-insns
15991The maximum number of instruction reload should look backward for equivalent
15992register. Increasing values mean more aggressive optimization, making the
15993compilation time increase with probably slightly better performance.
15994
15995@item max-cselib-memory-locations
15996The maximum number of memory locations cselib should take into account.
15997Increasing values mean more aggressive optimization, making the compilation time
15998increase with probably slightly better performance.
15999
16000@item max-sched-ready-insns
16001The maximum number of instructions ready to be issued the scheduler should
16002consider at any given time during the first scheduling pass. Increasing
16003values mean more thorough searches, making the compilation time increase
16004with probably little benefit.
16005
16006@item max-sched-region-blocks
16007The maximum number of blocks in a region to be considered for
16008interblock scheduling.
16009
16010@item max-pipeline-region-blocks
16011The maximum number of blocks in a region to be considered for
16012pipelining in the selective scheduler.
16013
16014@item max-sched-region-insns
16015The maximum number of insns in a region to be considered for
16016interblock scheduling.
16017
16018@item max-pipeline-region-insns
16019The maximum number of insns in a region to be considered for
16020pipelining in the selective scheduler.
16021
16022@item min-spec-prob
16023The minimum probability (in percents) of reaching a source block
16024for interblock speculative scheduling.
16025
16026@item max-sched-extend-regions-iters
16027The maximum number of iterations through CFG to extend regions.
16028A value of 0 disables region extensions.
16029
16030@item max-sched-insn-conflict-delay
16031The maximum conflict delay for an insn to be considered for speculative motion.
16032
16033@item sched-spec-prob-cutoff
16034The minimal probability of speculation success (in percents), so that
16035speculative insns are scheduled.
16036
16037@item sched-state-edge-prob-cutoff
16038The minimum probability an edge must have for the scheduler to save its
16039state across it.
16040
16041@item sched-mem-true-dep-cost
16042Minimal distance (in CPU cycles) between store and load targeting same
16043memory locations.
16044
16045@item selsched-max-lookahead
16046The maximum size of the lookahead window of selective scheduling. It is a
16047depth of search for available instructions.
16048
16049@item selsched-max-sched-times
16050The maximum number of times that an instruction is scheduled during
16051selective scheduling. This is the limit on the number of iterations
16052through which the instruction may be pipelined.
16053
16054@item selsched-insns-to-rename
16055The maximum number of best instructions in the ready list that are considered
16056for renaming in the selective scheduler.
16057
16058@item sms-min-sc
16059The minimum value of stage count that swing modulo scheduler
16060generates.
16061
16062@item max-last-value-rtl
16063The maximum size measured as number of RTLs that can be recorded in an expression
16064in combiner for a pseudo register as last known value of that register.
16065
16066@item max-combine-insns
16067The maximum number of instructions the RTL combiner tries to combine.
16068
16069@item integer-share-limit
16070Small integer constants can use a shared data structure, reducing the
16071compiler's memory usage and increasing its speed. This sets the maximum
16072value of a shared integer constant.
16073
16074@item ssp-buffer-size
16075The minimum size of buffers (i.e.@: arrays) that receive stack smashing
16076protection when @option{-fstack-protector} is used.
16077
16078@item min-size-for-stack-sharing
16079The minimum size of variables taking part in stack slot sharing when not
16080optimizing.
16081
16082@item max-jump-thread-duplication-stmts
16083Maximum number of statements allowed in a block that needs to be
16084duplicated when threading jumps.
16085
16086@item max-jump-thread-paths
16087The maximum number of paths to consider when searching for jump threading
16088opportunities. When arriving at a block, incoming edges are only considered
16089if the number of paths to be searched so far multiplied by the number of
16090incoming edges does not exhaust the specified maximum number of paths to
16091consider.
16092
16093@item max-fields-for-field-sensitive
16094Maximum number of fields in a structure treated in
16095a field sensitive manner during pointer analysis.
16096
16097@item prefetch-latency
16098Estimate on average number of instructions that are executed before
16099prefetch finishes. The distance prefetched ahead is proportional
16100to this constant. Increasing this number may also lead to less
16101streams being prefetched (see @option{simultaneous-prefetches}).
16102
16103@item simultaneous-prefetches
16104Maximum number of prefetches that can run at the same time.
16105
16106@item l1-cache-line-size
16107The size of cache line in L1 data cache, in bytes.
16108
16109@item l1-cache-size
16110The size of L1 data cache, in kilobytes.
16111
16112@item l2-cache-size
16113The size of L2 data cache, in kilobytes.
16114
16115@item prefetch-dynamic-strides
16116Whether the loop array prefetch pass should issue software prefetch hints
16117for strides that are non-constant. In some cases this may be
16118beneficial, though the fact the stride is non-constant may make it
16119hard to predict when there is clear benefit to issuing these hints.
16120
16121Set to 1 if the prefetch hints should be issued for non-constant
16122strides. Set to 0 if prefetch hints should be issued only for strides that
16123are known to be constant and below @option{prefetch-minimum-stride}.
16124
16125@item prefetch-minimum-stride
16126Minimum constant stride, in bytes, to start using prefetch hints for. If
16127the stride is less than this threshold, prefetch hints will not be issued.
16128
16129This setting is useful for processors that have hardware prefetchers, in
16130which case there may be conflicts between the hardware prefetchers and
16131the software prefetchers. If the hardware prefetchers have a maximum
16132stride they can handle, it should be used here to improve the use of
16133software prefetchers.
16134
16135A value of -1 means we don't have a threshold and therefore
16136prefetch hints can be issued for any constant stride.
16137
16138This setting is only useful for strides that are known and constant.
16139
16140@item destructive-interference-size
16141@item constructive-interference-size
16142The values for the C++17 variables
16143@code{std::hardware_destructive_interference_size} and
16144@code{std::hardware_constructive_interference_size}. The destructive
16145interference size is the minimum recommended offset between two
16146independent concurrently-accessed objects; the constructive
16147interference size is the maximum recommended size of contiguous memory
16148accessed together. Typically both will be the size of an L1 cache
16149line for the target, in bytes. For a generic target covering a range of L1
16150cache line sizes, typically the constructive interference size will be
16151the small end of the range and the destructive size will be the large
16152end.
16153
16154The destructive interference size is intended to be used for layout,
16155and thus has ABI impact. The default value is not expected to be
16156stable, and on some targets varies with @option{-mtune}, so use of
16157this variable in a context where ABI stability is important, such as
16158the public interface of a library, is strongly discouraged; if it is
16159used in that context, users can stabilize the value using this
16160option.
16161
16162The constructive interference size is less sensitive, as it is
16163typically only used in a @samp{static_assert} to make sure that a type
16164fits within a cache line.
16165
16166See also @option{-Winterference-size}.
16167
16168@item loop-interchange-max-num-stmts
16169The maximum number of stmts in a loop to be interchanged.
16170
16171@item loop-interchange-stride-ratio
16172The minimum ratio between stride of two loops for interchange to be profitable.
16173
16174@item min-insn-to-prefetch-ratio
16175The minimum ratio between the number of instructions and the
16176number of prefetches to enable prefetching in a loop.
16177
16178@item prefetch-min-insn-to-mem-ratio
16179The minimum ratio between the number of instructions and the
16180number of memory references to enable prefetching in a loop.
16181
16182@item use-canonical-types
16183Whether the compiler should use the ``canonical'' type system.
16184Should always be 1, which uses a more efficient internal
16185mechanism for comparing types in C++ and Objective-C++. However, if
16186bugs in the canonical type system are causing compilation failures,
16187set this value to 0 to disable canonical types.
16188
16189@item switch-conversion-max-branch-ratio
16190Switch initialization conversion refuses to create arrays that are
16191bigger than @option{switch-conversion-max-branch-ratio} times the number of
16192branches in the switch.
16193
16194@item max-partial-antic-length
16195Maximum length of the partial antic set computed during the tree
16196partial redundancy elimination optimization (@option{-ftree-pre}) when
16197optimizing at @option{-O3} and above. For some sorts of source code
16198the enhanced partial redundancy elimination optimization can run away,
16199consuming all of the memory available on the host machine. This
16200parameter sets a limit on the length of the sets that are computed,
16201which prevents the runaway behavior. Setting a value of 0 for
16202this parameter allows an unlimited set length.
16203
16204@item rpo-vn-max-loop-depth
16205Maximum loop depth that is value-numbered optimistically.
16206When the limit hits the innermost
16207@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
16208loop nest are value-numbered optimistically and the remaining ones not.
16209
16210@item sccvn-max-alias-queries-per-access
16211Maximum number of alias-oracle queries we perform when looking for
16212redundancies for loads and stores. If this limit is hit the search
16213is aborted and the load or store is not considered redundant. The
16214number of queries is algorithmically limited to the number of
16215stores on all paths from the load to the function entry.
16216
16217@item ira-max-loops-num
16218IRA uses regional register allocation by default. If a function
16219contains more loops than the number given by this parameter, only at most
16220the given number of the most frequently-executed loops form regions
16221for regional register allocation.
16222
16223@item ira-max-conflict-table-size
16224Although IRA uses a sophisticated algorithm to compress the conflict
16225table, the table can still require excessive amounts of memory for
16226huge functions. If the conflict table for a function could be more
16227than the size in MB given by this parameter, the register allocator
16228instead uses a faster, simpler, and lower-quality
16229algorithm that does not require building a pseudo-register conflict table.
16230
16231@item ira-loop-reserved-regs
16232IRA can be used to evaluate more accurate register pressure in loops
16233for decisions to move loop invariants (see @option{-O3}). The number
16234of available registers reserved for some other purposes is given
16235by this parameter. Default of the parameter
16236is the best found from numerous experiments.
16237
16238@item ira-consider-dup-in-all-alts
16239Make IRA to consider matching constraint (duplicated operand number)
16240heavily in all available alternatives for preferred register class.
16241If it is set as zero, it means IRA only respects the matching
16242constraint when it's in the only available alternative with an
16243appropriate register class. Otherwise, it means IRA will check all
16244available alternatives for preferred register class even if it has
16245found some choice with an appropriate register class and respect the
16246found qualified matching constraint.
16247
9847c753
ML
16248@item ira-simple-lra-insn-threshold
16249Approximate function insn number in 1K units triggering simple local RA.
16250
d77de738
ML
16251@item lra-inheritance-ebb-probability-cutoff
16252LRA tries to reuse values reloaded in registers in subsequent insns.
16253This optimization is called inheritance. EBB is used as a region to
16254do this optimization. The parameter defines a minimal fall-through
16255edge probability in percentage used to add BB to inheritance EBB in
16256LRA. The default value was chosen
16257from numerous runs of SPEC2000 on x86-64.
16258
16259@item loop-invariant-max-bbs-in-loop
16260Loop invariant motion can be very expensive, both in compilation time and
16261in amount of needed compile-time memory, with very large loops. Loops
16262with more basic blocks than this parameter won't have loop invariant
16263motion optimization performed on them.
16264
16265@item loop-max-datarefs-for-datadeps
16266Building data dependencies is expensive for very large loops. This
16267parameter limits the number of data references in loops that are
16268considered for data dependence analysis. These large loops are no
16269handled by the optimizations using loop data dependencies.
16270
16271@item max-vartrack-size
16272Sets a maximum number of hash table slots to use during variable
16273tracking dataflow analysis of any function. If this limit is exceeded
16274with variable tracking at assignments enabled, analysis for that
16275function is retried without it, after removing all debug insns from
16276the function. If the limit is exceeded even without debug insns, var
16277tracking analysis is completely disabled for the function. Setting
16278the parameter to zero makes it unlimited.
16279
16280@item max-vartrack-expr-depth
16281Sets a maximum number of recursion levels when attempting to map
16282variable names or debug temporaries to value expressions. This trades
16283compilation time for more complete debug information. If this is set too
16284low, value expressions that are available and could be represented in
16285debug information may end up not being used; setting this higher may
16286enable the compiler to find more complex debug expressions, but compile
16287time and memory use may grow.
16288
16289@item max-debug-marker-count
16290Sets a threshold on the number of debug markers (e.g.@: begin stmt
16291markers) to avoid complexity explosion at inlining or expanding to RTL.
16292If a function has more such gimple stmts than the set limit, such stmts
16293will be dropped from the inlined copy of a function, and from its RTL
16294expansion.
16295
16296@item min-nondebug-insn-uid
16297Use uids starting at this parameter for nondebug insns. The range below
16298the parameter is reserved exclusively for debug insns created by
16299@option{-fvar-tracking-assignments}, but debug insns may get
16300(non-overlapping) uids above it if the reserved range is exhausted.
16301
10478270
MJ
16302@item ipa-sra-deref-prob-threshold
16303IPA-SRA replaces a pointer which is known not be NULL with one or more
16304new parameters only when the probability (in percent, relative to
16305function entry) of it being dereferenced is higher than this parameter.
16306
d77de738
ML
16307@item ipa-sra-ptr-growth-factor
16308IPA-SRA replaces a pointer to an aggregate with one or more new
16309parameters only when their cumulative size is less or equal to
16310@option{ipa-sra-ptr-growth-factor} times the size of the original
16311pointer parameter.
16312
69363825
ML
16313@item ipa-sra-ptrwrap-growth-factor
16314Additional maximum allowed growth of total size of new parameters
16315that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
16316if it points to a local variable that the caller only writes to and
16317passes it as an argument to other functions.
69363825 16318
d77de738
ML
16319@item ipa-sra-max-replacements
16320Maximum pieces of an aggregate that IPA-SRA tracks. As a
16321consequence, it is also the maximum number of replacements of a formal
16322parameter.
16323
16324@item sra-max-scalarization-size-Ospeed
16325@itemx sra-max-scalarization-size-Osize
16326The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
16327replace scalar parts of aggregates with uses of independent scalar
16328variables. These parameters control the maximum size, in storage units,
16329of aggregate which is considered for replacement when compiling for
16330speed
16331(@option{sra-max-scalarization-size-Ospeed}) or size
16332(@option{sra-max-scalarization-size-Osize}) respectively.
16333
16334@item sra-max-propagations
16335The maximum number of artificial accesses that Scalar Replacement of
16336Aggregates (SRA) will track, per one local variable, in order to
16337facilitate copy propagation.
16338
16339@item tm-max-aggregate-size
16340When making copies of thread-local variables in a transaction, this
16341parameter specifies the size in bytes after which variables are
16342saved with the logging functions as opposed to save/restore code
16343sequence pairs. This option only applies when using
16344@option{-fgnu-tm}.
16345
16346@item graphite-max-nb-scop-params
16347To avoid exponential effects in the Graphite loop transforms, the
16348number of parameters in a Static Control Part (SCoP) is bounded.
16349A value of zero can be used to lift
16350the bound. A variable whose value is unknown at compilation time and
16351defined outside a SCoP is a parameter of the SCoP.
16352
551935d1
AO
16353@item hardcfr-max-blocks
16354Disable @option{-fharden-control-flow-redundancy} for functions with a
16355larger number of blocks than the specified value. Zero removes any
16356limit.
16357
16358@item hardcfr-max-inline-blocks
16359Force @option{-fharden-control-flow-redundancy} to use out-of-line
16360checking for functions with a larger number of basic blocks than the
16361specified value.
16362
d77de738
ML
16363@item loop-block-tile-size
16364Loop blocking or strip mining transforms, enabled with
16365@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
16366loop in the loop nest by a given number of iterations. The strip
16367length can be changed using the @option{loop-block-tile-size}
16368parameter.
16369
16370@item ipa-jump-function-lookups
16371Specifies number of statements visited during jump function offset discovery.
16372
16373@item ipa-cp-value-list-size
16374IPA-CP attempts to track all possible values and types passed to a function's
16375parameter in order to propagate them and perform devirtualization.
16376@option{ipa-cp-value-list-size} is the maximum number of values and types it
16377stores per one formal parameter of a function.
16378
16379@item ipa-cp-eval-threshold
16380IPA-CP calculates its own score of cloning profitability heuristics
16381and performs those cloning opportunities with scores that exceed
16382@option{ipa-cp-eval-threshold}.
16383
16384@item ipa-cp-max-recursive-depth
16385Maximum depth of recursive cloning for self-recursive function.
16386
16387@item ipa-cp-min-recursive-probability
16388Recursive cloning only when the probability of call being executed exceeds
16389the parameter.
16390
16391@item ipa-cp-profile-count-base
16392When using @option{-fprofile-use} option, IPA-CP will consider the measured
16393execution count of a call graph edge at this percentage position in their
16394histogram as the basis for its heuristics calculation.
16395
16396@item ipa-cp-recursive-freq-factor
16397The number of times interprocedural copy propagation expects recursive
16398functions to call themselves.
16399
16400@item ipa-cp-recursion-penalty
16401Percentage penalty the recursive functions will receive when they
16402are evaluated for cloning.
16403
16404@item ipa-cp-single-call-penalty
16405Percentage penalty functions containing a single call to another
16406function will receive when they are evaluated for cloning.
16407
16408@item ipa-max-agg-items
16409IPA-CP is also capable to propagate a number of scalar values passed
16410in an aggregate. @option{ipa-max-agg-items} controls the maximum
16411number of such values per one parameter.
16412
16413@item ipa-cp-loop-hint-bonus
16414When IPA-CP determines that a cloning candidate would make the number
16415of iterations of a loop known, it adds a bonus of
16416@option{ipa-cp-loop-hint-bonus} to the profitability score of
16417the candidate.
16418
16419@item ipa-max-loop-predicates
16420The maximum number of different predicates IPA will use to describe when
16421loops in a function have known properties.
16422
16423@item ipa-max-aa-steps
16424During its analysis of function bodies, IPA-CP employs alias analysis
16425in order to track values pointed to by function parameters. In order
16426not spend too much time analyzing huge functions, it gives up and
16427consider all memory clobbered after examining
16428@option{ipa-max-aa-steps} statements modifying memory.
16429
16430@item ipa-max-switch-predicate-bounds
16431Maximal number of boundary endpoints of case ranges of switch statement.
16432For switch exceeding this limit, IPA-CP will not construct cloning cost
16433predicate, which is used to estimate cloning benefit, for default case
16434of the switch statement.
16435
16436@item ipa-max-param-expr-ops
16437IPA-CP will analyze conditional statement that references some function
16438parameter to estimate benefit for cloning upon certain constant value.
16439But if number of operations in a parameter expression exceeds
16440@option{ipa-max-param-expr-ops}, the expression is treated as complicated
16441one, and is not handled by IPA analysis.
16442
16443@item lto-partitions
16444Specify desired number of partitions produced during WHOPR compilation.
16445The number of partitions should exceed the number of CPUs used for compilation.
16446
16447@item lto-min-partition
16448Size of minimal partition for WHOPR (in estimated instructions).
16449This prevents expenses of splitting very small programs into too many
16450partitions.
16451
16452@item lto-max-partition
16453Size of max partition for WHOPR (in estimated instructions).
16454to provide an upper bound for individual size of partition.
16455Meant to be used only with balanced partitioning.
16456
16457@item lto-max-streaming-parallelism
16458Maximal number of parallel processes used for LTO streaming.
16459
16460@item cxx-max-namespaces-for-diagnostic-help
16461The maximum number of namespaces to consult for suggestions when C++
16462name lookup fails for an identifier.
16463
16464@item sink-frequency-threshold
16465The maximum relative execution frequency (in percents) of the target block
16466relative to a statement's original block to allow statement sinking of a
16467statement. Larger numbers result in more aggressive statement sinking.
16468A small positive adjustment is applied for
16469statements with memory operands as those are even more profitable so sink.
16470
16471@item max-stores-to-sink
16472The maximum number of conditional store pairs that can be sunk. Set to 0
16473if either vectorization (@option{-ftree-vectorize}) or if-conversion
16474(@option{-ftree-loop-if-convert}) is disabled.
16475
16476@item case-values-threshold
16477The smallest number of different values for which it is best to use a
16478jump-table instead of a tree of conditional branches. If the value is
164790, use the default for the machine.
16480
16481@item jump-table-max-growth-ratio-for-size
16482The maximum code size growth ratio when expanding
16483into a jump table (in percent). The parameter is used when
16484optimizing for size.
16485
16486@item jump-table-max-growth-ratio-for-speed
16487The maximum code size growth ratio when expanding
16488into a jump table (in percent). The parameter is used when
16489optimizing for speed.
16490
16491@item tree-reassoc-width
16492Set the maximum number of instructions executed in parallel in
16493reassociated tree. This parameter overrides target dependent
16494heuristics used by default if has non zero value.
16495
16496@item sched-pressure-algorithm
16497Choose between the two available implementations of
16498@option{-fsched-pressure}. Algorithm 1 is the original implementation
16499and is the more likely to prevent instructions from being reordered.
16500Algorithm 2 was designed to be a compromise between the relatively
16501conservative approach taken by algorithm 1 and the rather aggressive
16502approach taken by the default scheduler. It relies more heavily on
16503having a regular register file and accurate register pressure classes.
16504See @file{haifa-sched.cc} in the GCC sources for more details.
16505
16506The default choice depends on the target.
16507
16508@item max-slsr-cand-scan
16509Set the maximum number of existing candidates that are considered when
16510seeking a basis for a new straight-line strength reduction candidate.
16511
16512@item asan-globals
16513Enable buffer overflow detection for global objects. This kind
16514of protection is enabled by default if you are using
16515@option{-fsanitize=address} option.
16516To disable global objects protection use @option{--param asan-globals=0}.
16517
16518@item asan-stack
16519Enable buffer overflow detection for stack objects. This kind of
16520protection is enabled by default when using @option{-fsanitize=address}.
16521To disable stack protection use @option{--param asan-stack=0} option.
16522
16523@item asan-instrument-reads
16524Enable buffer overflow detection for memory reads. This kind of
16525protection is enabled by default when using @option{-fsanitize=address}.
16526To disable memory reads protection use
16527@option{--param asan-instrument-reads=0}.
16528
16529@item asan-instrument-writes
16530Enable buffer overflow detection for memory writes. This kind of
16531protection is enabled by default when using @option{-fsanitize=address}.
16532To disable memory writes protection use
16533@option{--param asan-instrument-writes=0} option.
16534
16535@item asan-memintrin
16536Enable detection for built-in functions. This kind of protection
16537is enabled by default when using @option{-fsanitize=address}.
16538To disable built-in functions protection use
16539@option{--param asan-memintrin=0}.
16540
16541@item asan-use-after-return
16542Enable detection of use-after-return. This kind of protection
16543is enabled by default when using the @option{-fsanitize=address} option.
16544To disable it use @option{--param asan-use-after-return=0}.
16545
16546Note: By default the check is disabled at run time. To enable it,
16547add @code{detect_stack_use_after_return=1} to the environment variable
16548@env{ASAN_OPTIONS}.
16549
16550@item asan-instrumentation-with-call-threshold
16551If number of memory accesses in function being instrumented
16552is greater or equal to this number, use callbacks instead of inline checks.
16553E.g. to disable inline code use
16554@option{--param asan-instrumentation-with-call-threshold=0}.
16555
545c9f8b 16556@item asan-kernel-mem-intrinsic-prefix
f56ed5b3
SL
16557If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
16558with @samp{__asan_} or @samp{__hwasan_}
16559for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
16560respectively.
545c9f8b 16561
d77de738
ML
16562@item hwasan-instrument-stack
16563Enable hwasan instrumentation of statically sized stack-allocated variables.
16564This kind of instrumentation is enabled by default when using
16565@option{-fsanitize=hwaddress} and disabled by default when using
16566@option{-fsanitize=kernel-hwaddress}.
16567To disable stack instrumentation use
16568@option{--param hwasan-instrument-stack=0}, and to enable it use
16569@option{--param hwasan-instrument-stack=1}.
16570
16571@item hwasan-random-frame-tag
16572When using stack instrumentation, decide tags for stack variables using a
16573deterministic sequence beginning at a random tag for each frame. With this
16574parameter unset tags are chosen using the same sequence but beginning from 1.
16575This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
16576for @option{-fsanitize=kernel-hwaddress}.
16577To disable it use @option{--param hwasan-random-frame-tag=0}.
16578
16579@item hwasan-instrument-allocas
16580Enable hwasan instrumentation of dynamically sized stack-allocated variables.
16581This kind of instrumentation is enabled by default when using
16582@option{-fsanitize=hwaddress} and disabled by default when using
16583@option{-fsanitize=kernel-hwaddress}.
16584To disable instrumentation of such variables use
16585@option{--param hwasan-instrument-allocas=0}, and to enable it use
16586@option{--param hwasan-instrument-allocas=1}.
16587
16588@item hwasan-instrument-reads
16589Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
16590default for both @option{-fsanitize=hwaddress} and
16591@option{-fsanitize=kernel-hwaddress}.
16592To disable checking memory reads use
16593@option{--param hwasan-instrument-reads=0}.
16594
16595@item hwasan-instrument-writes
16596Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
16597default for both @option{-fsanitize=hwaddress} and
16598@option{-fsanitize=kernel-hwaddress}.
16599To disable checking memory writes use
16600@option{--param hwasan-instrument-writes=0}.
16601
16602@item hwasan-instrument-mem-intrinsics
16603Enable hwasan instrumentation of builtin functions. Instrumentation of these
16604builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
16605and @option{-fsanitize=kernel-hwaddress}.
16606To disable instrumentation of builtin functions use
16607@option{--param hwasan-instrument-mem-intrinsics=0}.
16608
16609@item use-after-scope-direct-emission-threshold
16610If the size of a local variable in bytes is smaller or equal to this
16611number, directly poison (or unpoison) shadow memory instead of using
16612run-time callbacks.
16613
16614@item tsan-distinguish-volatile
16615Emit special instrumentation for accesses to volatiles.
16616
16617@item tsan-instrument-func-entry-exit
16618Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
16619
16620@item max-fsm-thread-path-insns
16621Maximum number of instructions to copy when duplicating blocks on a
16622finite state automaton jump thread path.
16623
16624@item threader-debug
16625threader-debug=[none|all] Enables verbose dumping of the threader solver.
16626
16627@item parloops-chunk-size
16628Chunk size of omp schedule for loops parallelized by parloops.
16629
16630@item parloops-schedule
16631Schedule type of omp schedule for loops parallelized by parloops (static,
16632dynamic, guided, auto, runtime).
16633
16634@item parloops-min-per-thread
16635The minimum number of iterations per thread of an innermost parallelized
16636loop for which the parallelized variant is preferred over the single threaded
16637one. Note that for a parallelized loop nest the
16638minimum number of iterations of the outermost loop per thread is two.
16639
16640@item max-ssa-name-query-depth
16641Maximum depth of recursion when querying properties of SSA names in things
16642like fold routines. One level of recursion corresponds to following a
16643use-def chain.
16644
16645@item max-speculative-devirt-maydefs
16646The maximum number of may-defs we analyze when looking for a must-def
16647specifying the dynamic type of an object that invokes a virtual call
16648we may be able to devirtualize speculatively.
16649
d77de738
ML
16650@item ranger-debug
16651Specifies the type of debug output to be issued for ranges.
16652
d77de738
ML
16653@item unroll-jam-min-percent
16654The minimum percentage of memory references that must be optimized
16655away for the unroll-and-jam transformation to be considered profitable.
16656
16657@item unroll-jam-max-unroll
16658The maximum number of times the outer loop should be unrolled by
16659the unroll-and-jam transformation.
16660
16661@item max-rtl-if-conversion-unpredictable-cost
16662Maximum permissible cost for the sequence that would be generated
16663by the RTL if-conversion pass for a branch that is considered unpredictable.
16664
16665@item max-variable-expansions-in-unroller
16666If @option{-fvariable-expansion-in-unroller} is used, the maximum number
16667of times that an individual variable will be expanded during loop unrolling.
16668
16669@item partial-inlining-entry-probability
16670Maximum probability of the entry BB of split region
16671(in percent relative to entry BB of the function)
16672to make partial inlining happen.
16673
16674@item max-tracked-strlens
16675Maximum number of strings for which strlen optimization pass will
16676track string lengths.
16677
16678@item gcse-after-reload-partial-fraction
16679The threshold ratio for performing partial redundancy
16680elimination after reload.
16681
16682@item gcse-after-reload-critical-fraction
16683The threshold ratio of critical edges execution count that
16684permit performing redundancy elimination after reload.
16685
16686@item max-loop-header-insns
16687The maximum number of insns in loop header duplicated
16688by the copy loop headers pass.
16689
16690@item vect-epilogues-nomask
16691Enable loop epilogue vectorization using smaller vector size.
16692
16693@item vect-partial-vector-usage
16694Controls when the loop vectorizer considers using partial vector loads
16695and stores as an alternative to falling back to scalar code. 0 stops
16696the vectorizer from ever using partial vector loads and stores. 1 allows
16697partial vector loads and stores if vectorization removes the need for the
16698code to iterate. 2 allows partial vector loads and stores in all loops.
16699The parameter only has an effect on targets that support partial
16700vector loads and stores.
16701
16702@item vect-inner-loop-cost-factor
16703The maximum factor which the loop vectorizer applies to the cost of statements
16704in an inner loop relative to the loop being vectorized. The factor applied
16705is the maximum of the estimated number of iterations of the inner loop and
16706this parameter. The default value of this parameter is 50.
16707
16708@item vect-induction-float
16709Enable loop vectorization of floating point inductions.
16710
cbe32d38
ML
16711@item vrp-sparse-threshold
16712Maximum number of basic blocks before VRP uses a sparse bitmap cache.
16713
16714@item vrp-switch-limit
16715Maximum number of outgoing edges in a switch before VRP will not process it.
16716
16717@item vrp-vector-threshold
16718Maximum number of basic blocks for VRP to use a basic cache vector.
16719
d77de738
ML
16720@item avoid-fma-max-bits
16721Maximum number of bits for which we avoid creating FMAs.
16722
8afdbcdd
DZ
16723@item fully-pipelined-fma
16724Whether the target fully pipelines FMA instructions. If non-zero,
16725reassociation considers the benefit of parallelizing FMA's multiplication
16726part and addition part, assuming FMUL and FMA use the same units that can
16727also do FADD.
16728
d77de738
ML
16729@item sms-loop-average-count-threshold
16730A threshold on the average loop count considered by the swing modulo scheduler.
16731
16732@item sms-dfa-history
16733The number of cycles the swing modulo scheduler considers when checking
16734conflicts using DFA.
16735
16736@item graphite-allow-codegen-errors
16737Whether codegen errors should be ICEs when @option{-fchecking}.
16738
16739@item sms-max-ii-factor
16740A factor for tuning the upper bound that swing modulo scheduler
16741uses for scheduling a loop.
16742
16743@item lra-max-considered-reload-pseudos
16744The max number of reload pseudos which are considered during
16745spilling a non-reload pseudo.
16746
16747@item max-pow-sqrt-depth
16748Maximum depth of sqrt chains to use when synthesizing exponentiation
16749by a real constant.
16750
16751@item max-dse-active-local-stores
16752Maximum number of active local stores in RTL dead store elimination.
16753
16754@item asan-instrument-allocas
16755Enable asan allocas/VLAs protection.
16756
16757@item max-iterations-computation-cost
16758Bound on the cost of an expression to compute the number of iterations.
16759
16760@item max-isl-operations
16761Maximum number of isl operations, 0 means unlimited.
16762
16763@item graphite-max-arrays-per-scop
16764Maximum number of arrays per scop.
16765
16766@item max-vartrack-reverse-op-size
16767Max. size of loc list for which reverse ops should be added.
16768
16769@item fsm-scale-path-stmts
16770Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
16771crossing a loop backedge when comparing to
16772@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
16773
16774@item uninit-control-dep-attempts
16775Maximum number of nested calls to search for control dependencies
16776during uninitialized variable analysis.
16777
b8a2a124
RB
16778@item uninit-max-chain-len
16779Maximum number of predicates anded for each predicate ored in the normalized
16780predicate chain.
16781
16782@item uninit-max-num-chains
16783Maximum number of predicates ored in the normalized predicate chain.
16784
d77de738
ML
16785@item sched-autopref-queue-depth
16786Hardware autoprefetcher scheduler model control flag.
16787Number of lookahead cycles the model looks into; at '
16788' only enable instruction sorting heuristic.
16789
16790@item loop-versioning-max-inner-insns
16791The maximum number of instructions that an inner loop can have
16792before the loop versioning pass considers it too big to copy.
16793
16794@item loop-versioning-max-outer-insns
16795The maximum number of instructions that an outer loop can have
16796before the loop versioning pass considers it too big to copy,
16797discounting any instructions in inner loops that directly benefit
16798from versioning.
16799
16800@item ssa-name-def-chain-limit
16801The maximum number of SSA_NAME assignments to follow in determining
16802a property of a variable such as its value. This limits the number
16803of iterations or recursive calls GCC performs when optimizing certain
16804statements or when determining their validity prior to issuing
16805diagnostics.
16806
16807@item store-merging-max-size
16808Maximum size of a single store merging region in bytes.
16809
16810@item hash-table-verification-limit
16811The number of elements for which hash table verification is done
16812for each searched element.
16813
16814@item max-find-base-term-values
16815Maximum number of VALUEs handled during a single find_base_term call.
16816
16817@item analyzer-max-enodes-per-program-point
16818The maximum number of exploded nodes per program point within
16819the analyzer, before terminating analysis of that point.
16820
16821@item analyzer-max-constraints
16822The maximum number of constraints per state.
16823
16824@item analyzer-min-snodes-for-call-summary
16825The minimum number of supernodes within a function for the
16826analyzer to consider summarizing its effects at call sites.
16827
16828@item analyzer-max-enodes-for-full-dump
16829The maximum depth of exploded nodes that should appear in a dot dump
16830before switching to a less verbose format.
16831
16832@item analyzer-max-recursion-depth
16833The maximum number of times a callsite can appear in a call stack
16834within the analyzer, before terminating analysis of a call that would
16835recurse deeper.
16836
16837@item analyzer-max-svalue-depth
16838The maximum depth of a symbolic value, before approximating
16839the value as unknown.
16840
16841@item analyzer-max-infeasible-edges
16842The maximum number of infeasible edges to reject before declaring
16843a diagnostic as infeasible.
16844
16845@item gimple-fe-computed-hot-bb-threshold
16846The number of executions of a basic block which is considered hot.
16847The parameter is used only in GIMPLE FE.
16848
16849@item analyzer-bb-explosion-factor
16850The maximum number of 'after supernode' exploded nodes within the analyzer
16851per supernode, before terminating analysis.
16852
c0c5a57b
MJ
16853@item analyzer-text-art-string-ellipsis-threshold
16854The number of bytes at which to ellipsize string literals in analyzer text art diagrams.
16855
16856@item analyzer-text-art-ideal-canvas-width
16857The ideal width in characters of text art diagrams generated by the analyzer.
16858
16859@item analyzer-text-art-string-ellipsis-head-len
16860The number of literal bytes to show at the head of a string literal in text art when ellipsizing it.
16861
16862@item analyzer-text-art-string-ellipsis-tail-len
16863The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it.
16864
d77de738
ML
16865@item ranger-logical-depth
16866Maximum depth of logical expression evaluation ranger will look through
16867when evaluating outgoing edge ranges.
16868
9fd6d83a
ML
16869@item ranger-recompute-depth
16870Maximum depth of instruction chains to consider for recomputation
16871in the outgoing range calculator.
16872
d77de738
ML
16873@item relation-block-limit
16874Maximum number of relations the oracle will register in a basic block.
16875
16876@item min-pagesize
16877Minimum page size for warning purposes.
16878
16879@item openacc-kernels
16880Specify mode of OpenACC `kernels' constructs handling.
16881With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16882constructs are decomposed into parts, a sequence of compute
16883constructs, each then handled individually.
16884This is work in progress.
16885With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16886constructs are handled by the @samp{parloops} pass, en bloc.
16887This is the current default.
16888
16889@item openacc-privatization
4ace81b6
SL
16890Control whether the @option{-fopt-info-omp-note} and applicable
16891@option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
d77de738
ML
16892With @option{--param=openacc-privatization=quiet}, don't diagnose.
16893This is the current default.
16894With @option{--param=openacc-privatization=noisy}, do diagnose.
16895
16896@end table
16897
16898The following choices of @var{name} are available on AArch64 targets:
16899
16900@table @gcctabopt
7328faf8
RS
16901@item aarch64-vect-compare-costs
16902When vectorizing, consider using multiple different approaches and use
16903the cost model to choose the cheapest one. This includes:
16904
16905@itemize
16906@item
16907Trying both SVE and Advanced SIMD, when SVE is available.
16908
16909@item
16910Trying to use 64-bit Advanced SIMD vectors for the smallest data elements,
16911rather than using 128-bit vectors for everything.
16912
16913@item
16914Trying to use ``unpacked'' SVE vectors for smaller elements. This includes
16915storing smaller elements in larger containers and accessing elements with
16916extending loads and truncating stores.
16917@end itemize
d77de738
ML
16918
16919@item aarch64-float-recp-precision
16920The number of Newton iterations for calculating the reciprocal for float type.
16921The precision of division is proportional to this param when division
16922approximation is enabled. The default value is 1.
16923
16924@item aarch64-double-recp-precision
16925The number of Newton iterations for calculating the reciprocal for double type.
16926The precision of division is propotional to this param when division
16927approximation is enabled. The default value is 2.
16928
16929@item aarch64-autovec-preference
16930Force an ISA selection strategy for auto-vectorization. Accepts values from
169310 to 4, inclusive.
16932@table @samp
16933@item 0
16934Use the default heuristics.
16935@item 1
16936Use only Advanced SIMD for auto-vectorization.
16937@item 2
16938Use only SVE for auto-vectorization.
16939@item 3
16940Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16941deemed equal.
16942@item 4
16943Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16944@end table
16945The default value is 0.
16946
834fc2bf
MA
16947@item aarch64-ldp-policy
16948Fine-grained policy for load pairs.
16949With @option{--param=aarch64-ldp-policy=default}, use the policy of the
16950tuning structure. This is the current default.
16951With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless
16952of alignment.
16953With @option{--param=aarch64-ldp-policy=never}, do not emit ldp.
16954With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the
16955source pointer is aligned to at least double the alignment of the type.
16956
16957@item aarch64-stp-policy
16958Fine-grained policy for store pairs.
16959With @option{--param=aarch64-stp-policy=default}, use the policy of the
16960tuning structure. This is the current default.
16961With @option{--param=aarch64-stp-policy=always}, emit stp regardless
16962of alignment.
16963With @option{--param=aarch64-stp-policy=never}, do not emit stp.
16964With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the
16965source pointer is aligned to at least double the alignment of the type.
16966
c0911c6b
AC
16967@item aarch64-ldp-alias-check-limit
16968Limit on the number of alias checks performed by the AArch64 load/store pair
16969fusion pass when attempting to form an ldp/stp. Higher values make the pass
16970more aggressive at re-ordering loads over stores, at the expense of increased
16971compile time.
16972
16973@item aarch64-ldp-writeback
16974Param to control which writeback opportunities we try to handle in the AArch64
16975load/store pair fusion pass. A value of zero disables writeback handling. One
16976means we try to form pairs involving one or more existing individual writeback
16977accesses where possible. A value of two means we also try to opportunistically
16978form writeback opportunities by folding in trailing destructive updates of the
16979base register used by a pair.
16980
d77de738
ML
16981@item aarch64-loop-vect-issue-rate-niters
16982The tuning for some AArch64 CPUs tries to take both latencies and issue
16983rates into account when deciding whether a loop should be vectorized
16984using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16985If this parameter is set to @var{n}, GCC will not use this heuristic
16986for loops that are known to execute in fewer than @var{n} Advanced
16987SIMD iterations.
16988
16989@item aarch64-vect-unroll-limit
16990The vectorizer will use available tuning information to determine whether it
16991would be beneficial to unroll the main vectorized loop and by how much. This
16992parameter set's the upper bound of how much the vectorizer will unroll the main
16993loop. The default value is four.
16994
16995@end table
16996
16997The following choices of @var{name} are available on i386 and x86_64 targets:
16998
16999@table @gcctabopt
17000@item x86-stlf-window-ninsns
17001Instructions number above which STFL stall penalty can be compensated.
17002
60101899
RB
17003@item x86-stv-max-visits
17004The maximum number of use and def visits when discovering a STV chain before
17005the discovery is aborted.
17006
d77de738
ML
17007@end table
17008
17009@end table
17010
17011@node Instrumentation Options
17012@section Program Instrumentation Options
17013@cindex instrumentation options
17014@cindex program instrumentation options
17015@cindex run-time error checking options
17016@cindex profiling options
17017@cindex options, program instrumentation
17018@cindex options, run-time error checking
17019@cindex options, profiling
17020
17021GCC supports a number of command-line options that control adding
17022run-time instrumentation to the code it normally generates.
17023For example, one purpose of instrumentation is collect profiling
17024statistics for use in finding program hot spots, code coverage
17025analysis, or profile-guided optimizations.
17026Another class of program instrumentation is adding run-time checking
17027to detect programming errors like invalid pointer
17028dereferences or out-of-bounds array accesses, as well as deliberately
17029hostile attacks such as stack smashing or C++ vtable hijacking.
17030There is also a general hook which can be used to implement other
17031forms of tracing or function-level instrumentation for debug or
17032program analysis purposes.
17033
17034@table @gcctabopt
17035@cindex @command{prof}
17036@cindex @command{gprof}
d77de738
ML
17037@opindex p
17038@opindex pg
ddf6fe37
AA
17039@item -p
17040@itemx -pg
d77de738
ML
17041Generate extra code to write profile information suitable for the
17042analysis program @command{prof} (for @option{-p}) or @command{gprof}
17043(for @option{-pg}). You must use this option when compiling
17044the source files you want data about, and you must also use it when
17045linking.
17046
17047You can use the function attribute @code{no_instrument_function} to
17048suppress profiling of individual functions when compiling with these options.
17049@xref{Common Function Attributes}.
17050
d77de738 17051@opindex fprofile-arcs
ddf6fe37 17052@item -fprofile-arcs
d77de738
ML
17053Add code so that program flow @dfn{arcs} are instrumented. During
17054execution the program records how many times each branch and call is
17055executed and how many times it is taken or returns. On targets that support
17056constructors with priority support, profiling properly handles constructors,
17057destructors and C++ constructors (and destructors) of classes which are used
17058as a type of a global variable.
17059
17060When the compiled
17061program exits it saves this data to a file called
17062@file{@var{auxname}.gcda} for each source file. The data may be used for
17063profile-directed optimizations (@option{-fbranch-probabilities}), or for
17064test coverage analysis (@option{-ftest-coverage}). Each object file's
17065@var{auxname} is generated from the name of the output file, if
17066explicitly specified and it is not the final executable, otherwise it is
17067the basename of the source file. In both cases any suffix is removed
17068(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
17069@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
17070
17071Note that if a command line directly links source files, the corresponding
17072@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
17073E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
17074@file{binary-b.gcda} files.
17075
17076@xref{Cross-profiling}.
17077
17078@cindex @command{gcov}
d77de738 17079@opindex coverage
ddf6fe37 17080@item --coverage
d77de738
ML
17081
17082This option is used to compile and link code instrumented for coverage
17083analysis. The option is a synonym for @option{-fprofile-arcs}
17084@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
17085linking). See the documentation for those options for more details.
17086
17087@itemize
17088
17089@item
17090Compile the source files with @option{-fprofile-arcs} plus optimization
17091and code generation options. For test coverage analysis, use the
17092additional @option{-ftest-coverage} option. You do not need to profile
17093every source file in a program.
17094
17095@item
17096Compile the source files additionally with @option{-fprofile-abs-path}
17097to create absolute path names in the @file{.gcno} files. This allows
17098@command{gcov} to find the correct sources in projects where compilations
17099occur with different working directories.
17100
17101@item
17102Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
17103(the latter implies the former).
17104
17105@item
17106Run the program on a representative workload to generate the arc profile
17107information. This may be repeated any number of times. You can run
17108concurrent instances of your program, and provided that the file system
17109supports locking, the data files will be correctly updated. Unless
17110a strict ISO C dialect option is in effect, @code{fork} calls are
17111detected and correctly handled without double counting.
17112
17113Moreover, an object file can be recompiled multiple times
17114and the corresponding @file{.gcda} file merges as long as
17115the source file and the compiler options are unchanged.
17116
17117@item
17118For profile-directed optimizations, compile the source files again with
17119the same optimization and code generation options plus
17120@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
17121Control Optimization}).
17122
17123@item
17124For test coverage analysis, use @command{gcov} to produce human readable
17125information from the @file{.gcno} and @file{.gcda} files. Refer to the
17126@command{gcov} documentation for further information.
17127
17128@end itemize
17129
17130With @option{-fprofile-arcs}, for each function of your program GCC
17131creates a program flow graph, then finds a spanning tree for the graph.
17132Only arcs that are not on the spanning tree have to be instrumented: the
17133compiler adds code to count the number of times that these arcs are
17134executed. When an arc is the only exit or only entrance to a block, the
17135instrumentation code can be added to the block; otherwise, a new basic
17136block must be created to hold the instrumentation code.
17137
17138@need 2000
d77de738 17139@opindex ftest-coverage
ddf6fe37 17140@item -ftest-coverage
d77de738
ML
17141Produce a notes file that the @command{gcov} code-coverage utility
17142(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
17143show program coverage. Each source file's note file is called
17144@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
17145above for a description of @var{auxname} and instructions on how to
17146generate test coverage data. Coverage data matches the source files
17147more closely if you do not optimize.
17148
d77de738 17149@opindex fprofile-abs-path
ddf6fe37 17150@item -fprofile-abs-path
d77de738
ML
17151Automatically convert relative source file names to absolute path names
17152in the @file{.gcno} files. This allows @command{gcov} to find the correct
17153sources in projects where compilations occur with different working
17154directories.
17155
d77de738 17156@opindex fprofile-dir
ddf6fe37 17157@item -fprofile-dir=@var{path}
d77de738
ML
17158
17159Set the directory to search for the profile data files in to @var{path}.
17160This option affects only the profile data generated by
17161@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
17162and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
17163and its related options. Both absolute and relative paths can be used.
17164By default, GCC uses the current directory as @var{path}, thus the
17165profile data file appears in the same directory as the object file.
17166In order to prevent the file name clashing, if the object file name is
17167not an absolute path, we mangle the absolute path of the
17168@file{@var{sourcename}.gcda} file and use it as the file name of a
17169@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
17170See similar option @option{-fprofile-note}.
17171
17172When an executable is run in a massive parallel environment, it is recommended
17173to save profile to different folders. That can be done with variables
17174in @var{path} that are exported during run-time:
17175
17176@table @gcctabopt
17177
17178@item %p
17179process ID.
17180
17181@item %q@{VAR@}
17182value of environment variable @var{VAR}
17183
17184@end table
17185
ddf6fe37 17186@opindex fprofile-generate
d77de738
ML
17187@item -fprofile-generate
17188@itemx -fprofile-generate=@var{path}
d77de738
ML
17189
17190Enable options usually used for instrumenting application to produce
17191profile useful for later recompilation with profile feedback based
17192optimization. You must use @option{-fprofile-generate} both when
17193compiling and when linking your program.
17194
17195The following options are enabled:
17196@option{-fprofile-arcs}, @option{-fprofile-values},
17197@option{-finline-functions}, and @option{-fipa-bit-cp}.
17198
17199If @var{path} is specified, GCC looks at the @var{path} to find
17200the profile feedback data files. See @option{-fprofile-dir}.
17201
17202To optimize the program based on the collected profile information, use
17203@option{-fprofile-use}. @xref{Optimize Options}, for more information.
17204
ddf6fe37 17205@opindex fprofile-info-section
d77de738
ML
17206@item -fprofile-info-section
17207@itemx -fprofile-info-section=@var{name}
d77de738
ML
17208
17209Register the profile information in the specified section instead of using a
17210constructor/destructor. The section name is @var{name} if it is specified,
17211otherwise the section name defaults to @code{.gcov_info}. A pointer to the
17212profile information generated by @option{-fprofile-arcs} is placed in the
17213specified section for each translation unit. This option disables the profile
17214information registration through a constructor and it disables the profile
17215information processing through a destructor. This option is not intended to be
17216used in hosted environments such as GNU/Linux. It targets freestanding
17217environments (for example embedded systems) with limited resources which do not
17218support constructors/destructors or the C library file I/O.
17219
17220The linker could collect the input sections in a continuous memory block and
17221define start and end symbols. A GNU linker script example which defines a
17222linker output section follows:
17223
17224@smallexample
17225 .gcov_info :
17226 @{
17227 PROVIDE (__gcov_info_start = .);
17228 KEEP (*(.gcov_info))
17229 PROVIDE (__gcov_info_end = .);
17230 @}
17231@end smallexample
17232
17233The program could dump the profiling information registered in this linker set
17234for example like this:
17235
17236@smallexample
17237#include <gcov.h>
17238#include <stdio.h>
17239#include <stdlib.h>
17240
17241extern const struct gcov_info *const __gcov_info_start[];
17242extern const struct gcov_info *const __gcov_info_end[];
17243
17244static void
17245dump (const void *d, unsigned n, void *arg)
17246@{
17247 const unsigned char *c = d;
17248
17249 for (unsigned i = 0; i < n; ++i)
17250 printf ("%02x", c[i]);
17251@}
17252
17253static void
17254filename (const char *f, void *arg)
17255@{
17256 __gcov_filename_to_gcfn (f, dump, arg );
17257@}
17258
17259static void *
17260allocate (unsigned length, void *arg)
17261@{
17262 return malloc (length);
17263@}
17264
17265static void
17266dump_gcov_info (void)
17267@{
17268 const struct gcov_info *const *info = __gcov_info_start;
17269 const struct gcov_info *const *end = __gcov_info_end;
17270
17271 /* Obfuscate variable to prevent compiler optimizations. */
17272 __asm__ ("" : "+r" (info));
17273
17274 while (info != end)
17275 @{
17276 void *arg = NULL;
17277 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
17278 putchar ('\n');
17279 ++info;
17280 @}
17281@}
17282
17283int
17284main (void)
17285@{
17286 dump_gcov_info ();
17287 return 0;
17288@}
17289@end smallexample
17290
17291The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
17292deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
17293@code{__gcov_info_to_gcda} functions and merge the profile information into
17294@file{.gcda} files on the host filesystem.
17295
d77de738 17296@opindex fprofile-note
ddf6fe37 17297@item -fprofile-note=@var{path}
d77de738
ML
17298
17299If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
17300location. If you combine the option with multiple source files,
17301the @file{.gcno} file will be overwritten.
17302
d77de738 17303@opindex fprofile-prefix-path
ddf6fe37 17304@item -fprofile-prefix-path=@var{path}
d77de738
ML
17305
17306This option can be used in combination with
17307@option{profile-generate=}@var{profile_dir} and
17308@option{profile-use=}@var{profile_dir} to inform GCC where is the base
17309directory of built source tree. By default @var{profile_dir} will contain
17310files with mangled absolute paths of all object files in the built project.
17311This is not desirable when directory used to build the instrumented binary
17312differs from the directory used to build the binary optimized with profile
17313feedback because the profile data will not be found during the optimized build.
17314In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
17315pointing to the base directory of the build can be used to strip the irrelevant
17316part of the path and keep all file names relative to the main build directory.
17317
d77de738 17318@opindex fprofile-prefix-map
ddf6fe37 17319@item -fprofile-prefix-map=@var{old}=@var{new}
d77de738
ML
17320When compiling files residing in directory @file{@var{old}}, record
17321profiling information (with @option{--coverage})
17322describing them as if the files resided in
17323directory @file{@var{new}} instead.
2eb0191a 17324See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
d77de738 17325
d77de738 17326@opindex fprofile-update
ddf6fe37 17327@item -fprofile-update=@var{method}
d77de738
ML
17328
17329Alter the update method for an application instrumented for profile
17330feedback based optimization. The @var{method} argument should be one of
17331@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
17332The first one is useful for single-threaded applications,
17333while the second one prevents profile corruption by emitting thread-safe code.
17334
17335@strong{Warning:} When an application does not properly join all threads
17336(or creates an detached thread), a profile file can be still corrupted.
17337
17338Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
17339when supported by a target, or to @samp{single} otherwise. The GCC driver
17340automatically selects @samp{prefer-atomic} when @option{-pthread}
20a3c74c
SH
17341is present in the command line, otherwise the default method is @samp{single}.
17342
17343If @samp{atomic} is selected, then the profile information is updated using
17344atomic operations on a best-effort basis. Ideally, the profile information is
17345updated through atomic operations in hardware. If the target platform does not
17346support the required atomic operations in hardware, however, @file{libatomic}
17347is available, then the profile information is updated through calls to
17348@file{libatomic}. If the target platform neither supports the required atomic
17349operations in hardware nor @file{libatomic}, then the profile information is
17350not atomically updated and a warning is issued. In this case, the obtained
17351profiling information may be corrupt for multi-threaded applications.
17352
17353For performance reasons, if 64-bit counters are used for the profiling
17354information and the target platform only supports 32-bit atomic operations in
17355hardware, then the performance critical profiling updates are done using two
1735632-bit atomic operations for each counter update. If a signal interrupts these
17357two operations updating a counter, then the profiling information may be in an
17358inconsistent state.
d77de738 17359
d77de738 17360@opindex fprofile-filter-files
ddf6fe37 17361@item -fprofile-filter-files=@var{regex}
d77de738
ML
17362
17363Instrument only functions from files whose name matches
17364any of the regular expressions (separated by semi-colons).
17365
17366For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
17367only @file{main.c} and all C files starting with 'module'.
17368
d77de738 17369@opindex fprofile-exclude-files
ddf6fe37 17370@item -fprofile-exclude-files=@var{regex}
d77de738
ML
17371
17372Instrument only functions from files whose name does not match
17373any of the regular expressions (separated by semi-colons).
17374
17375For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
17376of all files that are located in the @file{/usr/} folder.
17377
d77de738 17378@opindex fprofile-reproducible
ddf6fe37 17379@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
d77de738
ML
17380Control level of reproducibility of profile gathered by
17381@code{-fprofile-generate}. This makes it possible to rebuild program
17382with same outcome which is useful, for example, for distribution
17383packages.
17384
17385With @option{-fprofile-reproducible=serial} the profile gathered by
17386@option{-fprofile-generate} is reproducible provided the trained program
17387behaves the same at each invocation of the train run, it is not
17388multi-threaded and profile data streaming is always done in the same
17389order. Note that profile streaming happens at the end of program run but
17390also before @code{fork} function is invoked.
17391
17392Note that it is quite common that execution counts of some part of
17393programs depends, for example, on length of temporary file names or
17394memory space randomization (that may affect hash-table collision rate).
17395Such non-reproducible part of programs may be annotated by
17396@code{no_instrument_function} function attribute. @command{gcov-dump} with
17397@option{-l} can be used to dump gathered data and verify that they are
17398indeed reproducible.
17399
17400With @option{-fprofile-reproducible=parallel-runs} collected profile
17401stays reproducible regardless the order of streaming of the data into
17402gcda files. This setting makes it possible to run multiple instances of
17403instrumented program in parallel (such as with @code{make -j}). This
17404reduces quality of gathered data, in particular of indirect call
17405profiling.
17406
d77de738 17407@opindex fsanitize=address
ddf6fe37 17408@item -fsanitize=address
d77de738
ML
17409Enable AddressSanitizer, a fast memory error detector.
17410Memory access instructions are instrumented to detect
17411out-of-bounds and use-after-free bugs.
17412The option enables @option{-fsanitize-address-use-after-scope}.
17413See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
17414more details. The run-time behavior can be influenced using the
17415@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
17416the available options are shown at startup of the instrumented program. See
17417@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
17418for a list of supported options.
17419The option cannot be combined with @option{-fsanitize=thread} or
17420@option{-fsanitize=hwaddress}. Note that the only target
17421@option{-fsanitize=hwaddress} is currently supported on is AArch64.
17422
6a07798c
MP
17423To get more accurate stack traces, it is possible to use options such as
17424@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
17425most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
17426optimizing sibling and tail recursive calls; this option is implicit for
17427@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
17428disables Identical Code Folding for functions). Since multiple runs of the
17429program may yield backtraces with different addresses due to ASLR (Address
17430Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
17431this can be achieved with @samp{setarch `uname -m` -R ./prog}.
17432
d77de738 17433@opindex fsanitize=kernel-address
f33d7a88 17434@item -fsanitize=kernel-address
d77de738 17435Enable AddressSanitizer for Linux kernel.
a0bf71be 17436See @uref{https://github.com/google/kernel-sanitizers} for more details.
d77de738 17437
d77de738 17438@opindex fsanitize=hwaddress
f33d7a88 17439@item -fsanitize=hwaddress
d77de738
ML
17440Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
17441ignore the top byte of a pointer to allow the detection of memory errors with
17442a low memory overhead.
17443Memory access instructions are instrumented to detect out-of-bounds and
17444use-after-free bugs.
17445The option enables @option{-fsanitize-address-use-after-scope}.
17446See
17447@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
17448for more details. The run-time behavior can be influenced using the
17449@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
17450the available options are shown at startup of the instrumented program.
17451The option cannot be combined with @option{-fsanitize=thread} or
17452@option{-fsanitize=address}, and is currently only available on AArch64.
17453
d77de738 17454@opindex fsanitize=kernel-hwaddress
ddf6fe37 17455@item -fsanitize=kernel-hwaddress
d77de738
ML
17456Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
17457Similar to @option{-fsanitize=kernel-address} but using an alternate
17458instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
17459instrumentation differences necessary for compiling the Linux kernel.
17460These differences are to avoid hwasan library initialization calls and to
17461account for the stack pointer having a different value in its top byte.
17462
17463@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
17464Instrumenting the stack and alloca calls are not on by default but are still
17465possible by specifying the command-line options
17466@option{--param hwasan-instrument-stack=1} and
17467@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
17468tag is not implemented for kernel instrumentation.
17469
d77de738 17470@opindex fsanitize=pointer-compare
ddf6fe37 17471@item -fsanitize=pointer-compare
d77de738
ML
17472Instrument comparison operation (<, <=, >, >=) with pointer operands.
17473The option must be combined with either @option{-fsanitize=kernel-address} or
17474@option{-fsanitize=address}
17475The option cannot be combined with @option{-fsanitize=thread}.
17476Note: By default the check is disabled at run time. To enable it,
17477add @code{detect_invalid_pointer_pairs=2} to the environment variable
17478@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17479invalid operation only when both pointers are non-null.
17480
d77de738 17481@opindex fsanitize=pointer-subtract
ddf6fe37 17482@item -fsanitize=pointer-subtract
d77de738
ML
17483Instrument subtraction with pointer operands.
17484The option must be combined with either @option{-fsanitize=kernel-address} or
17485@option{-fsanitize=address}
17486The option cannot be combined with @option{-fsanitize=thread}.
17487Note: By default the check is disabled at run time. To enable it,
17488add @code{detect_invalid_pointer_pairs=2} to the environment variable
17489@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
17490invalid operation only when both pointers are non-null.
17491
d77de738 17492@opindex fsanitize=shadow-call-stack
ddf6fe37 17493@item -fsanitize=shadow-call-stack
d77de738
ML
17494Enable ShadowCallStack, a security enhancement mechanism used to protect
17495programs against return address overwrites (e.g. stack buffer overflows.)
17496It works by saving a function's return address to a separately allocated
17497shadow call stack in the function prologue and restoring the return address
17498from the shadow call stack in the function epilogue. Instrumentation only
17499occurs in functions that need to save the return address to the stack.
17500
17501Currently it only supports the aarch64 platform. It is specifically
17502designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
17503For the user space programs, runtime support is not currently provided
17504in libc and libgcc. Users who want to use this feature in user space need
17505to provide their own support for the runtime. It should be noted that
17506this may cause the ABI rules to be broken.
17507
17508On aarch64, the instrumentation makes use of the platform register @code{x18}.
17509This generally means that any code that may run on the same thread as code
17510compiled with ShadowCallStack must be compiled with the flag
17511@option{-ffixed-x18}, otherwise functions compiled without
17512@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
17513stack pointer.
17514
17515Also, because there is no userspace runtime support, code compiled with
17516ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
17517to turn off exceptions.
17518
17519See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
17520details.
17521
d77de738 17522@opindex fsanitize=thread
ddf6fe37 17523@item -fsanitize=thread
d77de738
ML
17524Enable ThreadSanitizer, a fast data race detector.
17525Memory access instructions are instrumented to detect
17526data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
17527details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
17528environment variable; see
17529@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
17530supported options.
17531The option cannot be combined with @option{-fsanitize=address},
17532@option{-fsanitize=leak}.
17533
17534Note that sanitized atomic builtins cannot throw exceptions when
17535operating on invalid memory addresses with non-call exceptions
17536(@option{-fnon-call-exceptions}).
17537
d77de738 17538@opindex fsanitize=leak
ddf6fe37 17539@item -fsanitize=leak
d77de738 17540Enable LeakSanitizer, a memory leak detector.
c5c4fdac
JG
17541This option only matters for linking of executables.
17542The executable is linked against a library that overrides @code{malloc}
d77de738
ML
17543and other allocator functions. See
17544@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
17545details. The run-time behavior can be influenced using the
17546@env{LSAN_OPTIONS} environment variable.
17547The option cannot be combined with @option{-fsanitize=thread}.
17548
d77de738 17549@opindex fsanitize=undefined
ddf6fe37 17550@item -fsanitize=undefined
d77de738
ML
17551Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
17552Various computations are instrumented to detect undefined behavior
17553at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
17554@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
17555
17556@table @gcctabopt
17557
d77de738 17558@opindex fsanitize=shift
ddf6fe37 17559@item -fsanitize=shift
d77de738
ML
17560This option enables checking that the result of a shift operation is
17561not undefined. Note that what exactly is considered undefined differs
17562slightly between C and C++, as well as between ISO C90 and C99, etc.
17563This option has two suboptions, @option{-fsanitize=shift-base} and
17564@option{-fsanitize=shift-exponent}.
17565
d77de738 17566@opindex fsanitize=shift-exponent
ddf6fe37 17567@item -fsanitize=shift-exponent
d77de738
ML
17568This option enables checking that the second argument of a shift operation
17569is not negative and is smaller than the precision of the promoted first
17570argument.
17571
d77de738 17572@opindex fsanitize=shift-base
ddf6fe37 17573@item -fsanitize=shift-base
d77de738
ML
17574If the second argument of a shift operation is within range, check that the
17575result of a shift operation is not undefined. Note that what exactly is
17576considered undefined differs slightly between C and C++, as well as between
17577ISO C90 and C99, etc.
17578
d77de738 17579@opindex fsanitize=integer-divide-by-zero
ddf6fe37 17580@item -fsanitize=integer-divide-by-zero
d77de738
ML
17581Detect integer division by zero.
17582
d77de738 17583@opindex fsanitize=unreachable
ddf6fe37 17584@item -fsanitize=unreachable
d77de738
ML
17585With this option, the compiler turns the @code{__builtin_unreachable}
17586call into a diagnostics message call instead. When reaching the
17587@code{__builtin_unreachable} call, the behavior is undefined.
17588
d77de738 17589@opindex fsanitize=vla-bound
ddf6fe37 17590@item -fsanitize=vla-bound
d77de738
ML
17591This option instructs the compiler to check that the size of a variable
17592length array is positive.
17593
d77de738 17594@opindex fsanitize=null
ddf6fe37 17595@item -fsanitize=null
d77de738
ML
17596This option enables pointer checking. Particularly, the application
17597built with this option turned on will issue an error message when it
17598tries to dereference a NULL pointer, or if a reference (possibly an
17599rvalue reference) is bound to a NULL pointer, or if a method is invoked
17600on an object pointed by a NULL pointer.
17601
d77de738 17602@opindex fsanitize=return
ddf6fe37 17603@item -fsanitize=return
d77de738
ML
17604This option enables return statement checking. Programs
17605built with this option turned on will issue an error message
17606when the end of a non-void function is reached without actually
17607returning a value. This option works in C++ only.
17608
d77de738 17609@opindex fsanitize=signed-integer-overflow
ddf6fe37 17610@item -fsanitize=signed-integer-overflow
d77de738
ML
17611This option enables signed integer overflow checking. We check that
17612the result of @code{+}, @code{*}, and both unary and binary @code{-}
17613does not overflow in the signed arithmetics. This also detects
17614@code{INT_MIN / -1} signed division. Note, integer promotion
17615rules must be taken into account. That is, the following is not an
17616overflow:
17617@smallexample
17618signed char a = SCHAR_MAX;
17619a++;
17620@end smallexample
17621
d77de738 17622@opindex fsanitize=bounds
ddf6fe37 17623@item -fsanitize=bounds
d77de738
ML
17624This option enables instrumentation of array bounds. Various out of bounds
17625accesses are detected. Flexible array members, flexible array member-like
c7728805
JJ
17626arrays, and initializers of variables with static storage are not
17627instrumented, with the exception of flexible array member-like arrays
17628for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
17629options or @code{strict_flex_array} attributes say they shouldn't be treated
17630like flexible array member-like arrays.
d77de738 17631
d77de738 17632@opindex fsanitize=bounds-strict
ddf6fe37 17633@item -fsanitize=bounds-strict
d77de738 17634This option enables strict instrumentation of array bounds. Most out of bounds
c7728805
JJ
17635accesses are detected, including flexible array member-like arrays.
17636Initializers of variables with static storage are not instrumented.
d77de738 17637
d77de738 17638@opindex fsanitize=alignment
ddf6fe37 17639@item -fsanitize=alignment
d77de738
ML
17640
17641This option enables checking of alignment of pointers when they are
17642dereferenced, or when a reference is bound to insufficiently aligned target,
17643or when a method or constructor is invoked on insufficiently aligned object.
17644
d77de738 17645@opindex fsanitize=object-size
ddf6fe37 17646@item -fsanitize=object-size
d77de738 17647This option enables instrumentation of memory references using the
7283380a
SP
17648@code{__builtin_dynamic_object_size} function. Various out of bounds
17649pointer accesses are detected.
d77de738 17650
d77de738 17651@opindex fsanitize=float-divide-by-zero
ddf6fe37 17652@item -fsanitize=float-divide-by-zero
d77de738
ML
17653Detect floating-point division by zero. Unlike other similar options,
17654@option{-fsanitize=float-divide-by-zero} is not enabled by
17655@option{-fsanitize=undefined}, since floating-point division by zero can
17656be a legitimate way of obtaining infinities and NaNs.
17657
d77de738 17658@opindex fsanitize=float-cast-overflow
ddf6fe37 17659@item -fsanitize=float-cast-overflow
d77de738
ML
17660This option enables floating-point type to integer conversion checking.
17661We check that the result of the conversion does not overflow.
17662Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
17663not enabled by @option{-fsanitize=undefined}.
17664This option does not work well with @code{FE_INVALID} exceptions enabled.
17665
d77de738 17666@opindex fsanitize=nonnull-attribute
ddf6fe37 17667@item -fsanitize=nonnull-attribute
d77de738
ML
17668
17669This option enables instrumentation of calls, checking whether null values
17670are not passed to arguments marked as requiring a non-null value by the
17671@code{nonnull} function attribute.
17672
d77de738 17673@opindex fsanitize=returns-nonnull-attribute
ddf6fe37 17674@item -fsanitize=returns-nonnull-attribute
d77de738
ML
17675
17676This option enables instrumentation of return statements in functions
17677marked with @code{returns_nonnull} function attribute, to detect returning
17678of null values from such functions.
17679
d77de738 17680@opindex fsanitize=bool
ddf6fe37 17681@item -fsanitize=bool
d77de738
ML
17682
17683This option enables instrumentation of loads from bool. If a value other
17684than 0/1 is loaded, a run-time error is issued.
17685
d77de738 17686@opindex fsanitize=enum
ddf6fe37 17687@item -fsanitize=enum
d77de738
ML
17688
17689This option enables instrumentation of loads from an enum type. If
17690a value outside the range of values for the enum type is loaded,
17691a run-time error is issued.
17692
d77de738 17693@opindex fsanitize=vptr
ddf6fe37 17694@item -fsanitize=vptr
d77de738
ML
17695
17696This option enables instrumentation of C++ member function calls, member
17697accesses and some conversions between pointers to base and derived classes,
17698to verify the referenced object has the correct dynamic type.
17699
d77de738 17700@opindex fsanitize=pointer-overflow
ddf6fe37 17701@item -fsanitize=pointer-overflow
d77de738
ML
17702
17703This option enables instrumentation of pointer arithmetics. If the pointer
17704arithmetics overflows, a run-time error is issued.
17705
d77de738 17706@opindex fsanitize=builtin
ddf6fe37 17707@item -fsanitize=builtin
d77de738
ML
17708
17709This option enables instrumentation of arguments to selected builtin
17710functions. If an invalid value is passed to such arguments, a run-time
17711error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
17712or @code{__builtin_clz} invokes undefined behavior and is diagnosed
17713by this option.
17714
17715@end table
17716
17717Note that sanitizers tend to increase the rate of false positive
17718warnings, most notably those around @option{-Wmaybe-uninitialized}.
17719We recommend against combining @option{-Werror} and [the use of]
17720sanitizers.
17721
17722While @option{-ftrapv} causes traps for signed overflows to be emitted,
17723@option{-fsanitize=undefined} gives a diagnostic message.
17724This currently works only for the C family of languages.
17725
d77de738 17726@opindex fno-sanitize=all
ddf6fe37 17727@item -fno-sanitize=all
d77de738
ML
17728
17729This option disables all previously enabled sanitizers.
17730@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
17731together.
17732
d77de738 17733@opindex fasan-shadow-offset
ddf6fe37 17734@item -fasan-shadow-offset=@var{number}
d77de738
ML
17735This option forces GCC to use custom shadow offset in AddressSanitizer checks.
17736It is useful for experimenting with different shadow memory layouts in
17737Kernel AddressSanitizer.
17738
d77de738 17739@opindex fsanitize-sections
ddf6fe37 17740@item -fsanitize-sections=@var{s1},@var{s2},...
d77de738
ML
17741Sanitize global variables in selected user-defined sections. @var{si} may
17742contain wildcards.
17743
d77de738
ML
17744@opindex fsanitize-recover
17745@opindex fno-sanitize-recover
ddf6fe37 17746@item -fsanitize-recover@r{[}=@var{opts}@r{]}
d77de738
ML
17747@option{-fsanitize-recover=} controls error recovery mode for sanitizers
17748mentioned in comma-separated list of @var{opts}. Enabling this option
17749for a sanitizer component causes it to attempt to continue
17750running the program as if no error happened. This means multiple
17751runtime errors can be reported in a single program run, and the exit
17752code of the program may indicate success even when errors
17753have been reported. The @option{-fno-sanitize-recover=} option
17754can be used to alter
17755this behavior: only the first detected error is reported
17756and program then exits with a non-zero exit code.
17757
17758Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
17759except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
17760@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
17761@option{-fsanitize=bounds-strict},
17762@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
17763For these sanitizers error recovery is turned on by default,
17764except @option{-fsanitize=address}, for which this feature is experimental.
17765@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
17766accepted, the former enables recovery for all sanitizers that support it,
17767the latter disables recovery for all sanitizers that support it.
17768
17769Even if a recovery mode is turned on the compiler side, it needs to be also
17770enabled on the runtime library side, otherwise the failures are still fatal.
17771The runtime library defaults to @code{halt_on_error=0} for
17772ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
17773AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
17774setting the @code{halt_on_error} flag in the corresponding environment variable.
17775
17776Syntax without an explicit @var{opts} parameter is deprecated. It is
17777equivalent to specifying an @var{opts} list of:
17778
17779@smallexample
17780undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
17781@end smallexample
17782
d77de738 17783@opindex fsanitize-address-use-after-scope
ddf6fe37 17784@item -fsanitize-address-use-after-scope
d77de738
ML
17785Enable sanitization of local variables to detect use-after-scope bugs.
17786The option sets @option{-fstack-reuse} to @samp{none}.
17787
d77de738
ML
17788@opindex fsanitize-trap
17789@opindex fno-sanitize-trap
ddf6fe37 17790@item -fsanitize-trap@r{[}=@var{opts}@r{]}
d77de738
ML
17791The @option{-fsanitize-trap=} option instructs the compiler to
17792report for sanitizers mentioned in comma-separated list of @var{opts}
17793undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
17794library routine. If this option is enabled for certain sanitizer,
17795it takes precedence over the @option{-fsanitizer-recover=} for that
17796sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
17797of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
17798
17799The advantage of this is that the @code{libubsan} library is not needed
17800and is not linked in, so this is usable even in freestanding environments.
17801
17802Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
17803except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
17804@option{-fsanitize=float-divide-by-zero} and
17805@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
17806specified, which enables it for @code{undefined} suboptions,
17807@option{-fsanitize=float-cast-overflow},
17808@option{-fsanitize=float-divide-by-zero} and
17809@option{-fsanitize=bounds-strict}.
17810If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
17811and @code{-fsanitize=vptr} is enabled on the command line, the
17812instrumentation is silently ignored as the instrumentation always needs
17813@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
17814
d77de738 17815@opindex fsanitize-undefined-trap-on-error
ddf6fe37 17816@item -fsanitize-undefined-trap-on-error
d77de738
ML
17817The @option{-fsanitize-undefined-trap-on-error} option is deprecated
17818equivalent of @option{-fsanitize-trap=all}.
17819
d77de738 17820@opindex fsanitize-coverage=trace-pc
ddf6fe37 17821@item -fsanitize-coverage=trace-pc
d77de738
ML
17822Enable coverage-guided fuzzing code instrumentation.
17823Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
17824
d77de738 17825@opindex fsanitize-coverage=trace-cmp
ddf6fe37 17826@item -fsanitize-coverage=trace-cmp
d77de738
ML
17827Enable dataflow guided fuzzing code instrumentation.
17828Inserts a call to @code{__sanitizer_cov_trace_cmp1},
17829@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
17830@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
17831variable or @code{__sanitizer_cov_trace_const_cmp1},
17832@code{__sanitizer_cov_trace_const_cmp2},
17833@code{__sanitizer_cov_trace_const_cmp4} or
17834@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
17835operand constant, @code{__sanitizer_cov_trace_cmpf} or
17836@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
17837@code{__sanitizer_cov_trace_switch} for switch statements.
17838
d77de738 17839@opindex fcf-protection
ddf6fe37 17840@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
d77de738
ML
17841Enable code instrumentation of control-flow transfers to increase
17842program security by checking that target addresses of control-flow
17843transfer instructions (such as indirect function call, function return,
17844indirect jump) are valid. This prevents diverting the flow of control
17845to an unexpected target. This is intended to protect against such
17846threats as Return-oriented Programming (ROP), and similarly
17847call/jmp-oriented programming (COP/JOP).
17848
17849The value @code{branch} tells the compiler to implement checking of
17850validity of control-flow transfer at the point of indirect branch
17851instructions, i.e.@: call/jmp instructions. The value @code{return}
17852implements checking of validity at the point of returning from a
17853function. The value @code{full} is an alias for specifying both
17854@code{branch} and @code{return}. The value @code{none} turns off
17855instrumentation.
17856
75ed4655 17857To override @option{-fcf-protection}, @option{-fcf-protection=none}
17858needs to be added and then with @option{-fcf-protection=xxx}.
17859
d77de738
ML
17860The value @code{check} is used for the final link with link-time
17861optimization (LTO). An error is issued if LTO object files are
17862compiled with different @option{-fcf-protection} values. The
17863value @code{check} is ignored at the compile time.
17864
17865The macro @code{__CET__} is defined when @option{-fcf-protection} is
17866used. The first bit of @code{__CET__} is set to 1 for the value
17867@code{branch} and the second bit of @code{__CET__} is set to 1 for
17868the @code{return}.
17869
17870You can also use the @code{nocf_check} attribute to identify
17871which functions and calls should be skipped from instrumentation
17872(@pxref{Function Attributes}).
17873
17874Currently the x86 GNU/Linux target provides an implementation based
17875on Intel Control-flow Enforcement Technology (CET) which works for
17876i686 processor or newer.
17877
d77de738 17878@opindex fharden-compares
ddf6fe37 17879@item -fharden-compares
d77de738
ML
17880For every logical test that survives gimple optimizations and is
17881@emph{not} the condition in a conditional branch (for example,
17882conditions tested for conditional moves, or to store in boolean
17883variables), emit extra code to compute and verify the reversed
17884condition, and to call @code{__builtin_trap} if the results do not
17885match. Use with @samp{-fharden-conditional-branches} to cover all
17886conditionals.
17887
d77de738 17888@opindex fharden-conditional-branches
ddf6fe37 17889@item -fharden-conditional-branches
d77de738
ML
17890For every non-vectorized conditional branch that survives gimple
17891optimizations, emit extra code to compute and verify the reversed
17892condition, and to call @code{__builtin_trap} if the result is
17893unexpected. Use with @samp{-fharden-compares} to cover all
17894conditionals.
17895
551935d1
AO
17896@opindex fharden-control-flow-redundancy
17897@item -fharden-control-flow-redundancy
17898Emit extra code to set booleans when entering basic blocks, and to
17899verify and trap, at function exits, when the booleans do not form an
17900execution path that is compatible with the control flow graph.
17901
17902Verification takes place before returns, before mandatory tail calls
17903(see below) and, optionally, before escaping exceptions with
17904@option{-fhardcfr-check-exceptions}, before returning calls with
17905@option{-fhardcfr-check-returning-calls}, and before noreturn calls with
17906@option{-fhardcfr-check-noreturn-calls}). Tuning options
17907@option{--param hardcfr-max-blocks} and @option{--param
17908hardcfr-max-inline-blocks} are available.
17909
17910Tail call optimization takes place too late to affect control flow
17911redundancy, but calls annotated as mandatory tail calls by language
17912front-ends, and any calls marked early enough as potential tail calls
17913would also have verification issued before the call, but these
17914possibilities are merely theoretical, as these conditions can only be
17915met when using custom compiler plugins.
17916
17917@opindex fhardcfr-skip-leaf
17918@item -fhardcfr-skip-leaf
17919Disable @option{-fharden-control-flow-redundancy} in leaf functions.
17920
17921@opindex fhardcfr-check-exceptions
17922@opindex fno-hardcfr-check-exceptions
17923@item -fhardcfr-check-exceptions
17924When @option{-fharden-control-flow-redundancy} is active, check the
17925recorded execution path against the control flow graph at exception
17926escape points, as if the function body was wrapped with a cleanup
17927handler that performed the check and reraised. This option is enabled
17928by default; use @option{-fno-hardcfr-check-exceptions} to disable it.
17929
17930@opindex fhardcfr-check-returning-calls
17931@opindex fno-hardcfr-check-returning-calls
17932@item -fhardcfr-check-returning-calls
17933When @option{-fharden-control-flow-redundancy} is active, check the
17934recorded execution path against the control flow graph before any
17935function call immediately followed by a return of its result, if any, so
17936as to not prevent tail-call optimization, whether or not it is
17937ultimately optimized to a tail call.
17938
17939This option is enabled by default whenever sibling call optimizations
17940are enabled (see @option{-foptimize-sibling-calls}), but it can be
17941enabled (or disabled, using its negated form) explicitly, regardless of
17942the optimizations.
17943
17944@opindex fhardcfr-check-noreturn-calls
17945@item -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]}
17946When @option{-fharden-control-flow-redundancy} is active, check the
17947recorded execution path against the control flow graph before
17948@code{noreturn} calls, either all of them (@option{always}), those that
17949aren't expected to return control to the caller through an exception
17950(@option{no-xthrow}, the default), those that may not return control to
17951the caller through an exception either (@option{nothrow}), or none of
17952them (@option{never}).
17953
17954Checking before a @code{noreturn} function that may return control to
17955the caller through an exception may cause checking to be performed more
17956than once, if the exception is caught in the caller, whether by a
17957handler or a cleanup. When @option{-fhardcfr-check-exceptions} is also
17958enabled, the compiler will avoid associating a @code{noreturn} call with
17959the implicitly-added cleanup handler, since it would be redundant with
17960the check performed before the call, but other handlers or cleanups in
17961the function, if activated, will modify the recorded execution path and
17962check it again when another checkpoint is hit. The checkpoint may even
17963be another @code{noreturn} call, so checking may end up performed
17964multiple times.
17965
17966Various optimizers may cause calls to be marked as @code{noreturn}
17967and/or @code{nothrow}, even in the absence of the corresponding
17968attributes, which may affect the placement of checks before calls, as
17969well as the addition of implicit cleanup handlers for them. This
17970unpredictability, and the fact that raising and reraising exceptions
17971frequently amounts to implicitly calling @code{noreturn} functions, have
17972made @option{no-xthrow} the default setting for this option: it excludes
17973from the @code{noreturn} treatment only internal functions used to
17974(re)raise exceptions, that are not affected by these optimizations.
17975
24592abd
MP
17976@opindex fhardened
17977@item -fhardened
17978Enable a set of flags for C and C++ that improve the security of the
17979generated code without affecting its ABI. The precise flags enabled
17980may change between major releases of GCC, but are currently:
17981
17982@c Keep this in sync with print_help_hardened!
17983@gccoptlist{
17984-D_FORTIFY_SOURCE=3
17985-D_GLIBCXX_ASSERTIONS
17986-ftrivial-auto-var-init=zero
17987-fPIE -pie -Wl,-z,relro,-z,now
17988-fstack-protector-strong
17989-fstack-clash-protection
17990-fcf-protection=full @r{(x86 GNU/Linux only)}
17991}
17992
17993The list of options enabled by @option{-fhardened} can be generated using
17994the @option{--help=hardened} option.
17995
17996When the system glibc is older than 2.35, @option{-D_FORTIFY_SOURCE=2}
17997is used instead.
17998
17999This option is intended to be used in production builds, not merely
18000in debug builds.
18001
18002Currently, @option{-fhardened} is only supported on GNU/Linux targets.
18003
18004@option{-fhardened} only enables a particular option if it wasn't
18005already specified anywhere on the command line. For instance,
18006@option{-fhardened} @option{-fstack-protector} will only enable
18007@option{-fstack-protector}, but not @option{-fstack-protector-strong}.
18008
d77de738 18009@opindex fstack-protector
ddf6fe37 18010@item -fstack-protector
d77de738
ML
18011Emit extra code to check for buffer overflows, such as stack smashing
18012attacks. This is done by adding a guard variable to functions with
18013vulnerable objects. This includes functions that call @code{alloca}, and
18014functions with buffers larger than or equal to 8 bytes. The guards are
18015initialized when a function is entered and then checked when the function
18016exits. If a guard check fails, an error message is printed and the program
18017exits. Only variables that are actually allocated on the stack are
18018considered, optimized away variables or variables allocated in registers
18019don't count.
18020
d77de738 18021@opindex fstack-protector-all
ddf6fe37 18022@item -fstack-protector-all
d77de738
ML
18023Like @option{-fstack-protector} except that all functions are protected.
18024
d77de738 18025@opindex fstack-protector-strong
ddf6fe37 18026@item -fstack-protector-strong
d77de738
ML
18027Like @option{-fstack-protector} but includes additional functions to
18028be protected --- those that have local array definitions, or have
18029references to local frame addresses. Only variables that are actually
18030allocated on the stack are considered, optimized away variables or variables
18031allocated in registers don't count.
18032
d77de738 18033@opindex fstack-protector-explicit
ddf6fe37 18034@item -fstack-protector-explicit
d77de738
ML
18035Like @option{-fstack-protector} but only protects those functions which
18036have the @code{stack_protect} attribute.
18037
d77de738 18038@opindex fstack-check
ddf6fe37 18039@item -fstack-check
d77de738
ML
18040Generate code to verify that you do not go beyond the boundary of the
18041stack. You should specify this flag if you are running in an
18042environment with multiple threads, but you only rarely need to specify it in
18043a single-threaded environment since stack overflow is automatically
18044detected on nearly all systems if there is only one stack.
18045
18046Note that this switch does not actually cause checking to be done; the
18047operating system or the language runtime must do that. The switch causes
18048generation of code to ensure that they see the stack being extended.
18049
18050You can additionally specify a string parameter: @samp{no} means no
18051checking, @samp{generic} means force the use of old-style checking,
18052@samp{specific} means use the best checking method and is equivalent
18053to bare @option{-fstack-check}.
18054
18055Old-style checking is a generic mechanism that requires no specific
18056target support in the compiler but comes with the following drawbacks:
18057
18058@enumerate
18059@item
18060Modified allocation strategy for large objects: they are always
18061allocated dynamically if their size exceeds a fixed threshold. Note this
18062may change the semantics of some code.
18063
18064@item
18065Fixed limit on the size of the static frame of functions: when it is
18066topped by a particular function, stack checking is not reliable and
18067a warning is issued by the compiler.
18068
18069@item
18070Inefficiency: because of both the modified allocation strategy and the
18071generic implementation, code performance is hampered.
18072@end enumerate
18073
18074Note that old-style stack checking is also the fallback method for
18075@samp{specific} if no target support has been added in the compiler.
18076
18077@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
18078and stack overflows. @samp{specific} is an excellent choice when compiling
18079Ada code. It is not generally sufficient to protect against stack-clash
18080attacks. To protect against those you want @samp{-fstack-clash-protection}.
18081
d77de738 18082@opindex fstack-clash-protection
ddf6fe37 18083@item -fstack-clash-protection
d77de738
ML
18084Generate code to prevent stack clash style attacks. When this option is
18085enabled, the compiler will only allocate one page of stack space at a time
18086and each page is accessed immediately after allocation. Thus, it prevents
18087allocations from jumping over any stack guard page provided by the
18088operating system.
18089
18090Most targets do not fully support stack clash protection. However, on
18091those targets @option{-fstack-clash-protection} will protect dynamic stack
18092allocations. @option{-fstack-clash-protection} may also provide limited
18093protection for static stack allocations if the target supports
18094@option{-fstack-check=specific}.
18095
d77de738
ML
18096@opindex fstack-limit-register
18097@opindex fstack-limit-symbol
18098@opindex fno-stack-limit
ddf6fe37
AA
18099@item -fstack-limit-register=@var{reg}
18100@itemx -fstack-limit-symbol=@var{sym}
18101@itemx -fno-stack-limit
d77de738
ML
18102Generate code to ensure that the stack does not grow beyond a certain value,
18103either the value of a register or the address of a symbol. If a larger
18104stack is required, a signal is raised at run time. For most targets,
18105the signal is raised before the stack overruns the boundary, so
18106it is possible to catch the signal without taking special precautions.
18107
18108For instance, if the stack starts at absolute address @samp{0x80000000}
18109and grows downwards, you can use the flags
18110@option{-fstack-limit-symbol=__stack_limit} and
18111@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
18112of 128KB@. Note that this may only work with the GNU linker.
18113
18114You can locally override stack limit checking by using the
18115@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
18116
d77de738 18117@opindex fsplit-stack
ddf6fe37 18118@item -fsplit-stack
d77de738
ML
18119Generate code to automatically split the stack before it overflows.
18120The resulting program has a discontiguous stack which can only
18121overflow if the program is unable to allocate any more memory. This
18122is most useful when running threaded programs, as it is no longer
18123necessary to calculate a good stack size to use for each thread. This
18124is currently only implemented for the x86 targets running
18125GNU/Linux.
18126
18127When code compiled with @option{-fsplit-stack} calls code compiled
18128without @option{-fsplit-stack}, there may not be much stack space
18129available for the latter code to run. If compiling all code,
18130including library code, with @option{-fsplit-stack} is not an option,
18131then the linker can fix up these calls so that the code compiled
18132without @option{-fsplit-stack} always has a large stack. Support for
18133this is implemented in the gold linker in GNU binutils release 2.21
18134and later.
18135
f0a90c7d
AO
18136@opindex -fstrub=disable
18137@item -fstrub=disable
18138Disable stack scrubbing entirely, ignoring any @code{strub} attributes.
18139See @xref{Common Type Attributes}.
18140
18141@opindex fstrub=strict
18142@item -fstrub=strict
18143Functions default to @code{strub} mode @code{disabled}, and apply
18144@option{strict}ly the restriction that only functions associated with
18145@code{strub}-@code{callable} modes (@code{at-calls}, @code{callable} and
18146@code{always_inline} @code{internal}) are @code{callable} by functions
18147with @code{strub}-enabled modes (@code{at-calls} and @code{internal}).
18148
18149@opindex fstrub=relaxed
18150@item -fstrub=relaxed
18151Restore the default stack scrub (@code{strub}) setting, namely,
18152@code{strub} is only enabled as required by @code{strub} attributes
18153associated with function and data types. @code{Relaxed} means that
18154strub contexts are only prevented from calling functions explicitly
18155associated with @code{strub} mode @code{disabled}. This option is only
18156useful to override other @option{-fstrub=*} options that precede it in
18157the command line.
18158
18159@opindex fstrub=at-calls
18160@item -fstrub=at-calls
18161Enable @code{at-calls} @code{strub} mode where viable. The primary use
18162of this option is for testing. It exercises the @code{strub} machinery
18163in scenarios strictly local to a translation unit. This @code{strub}
18164mode modifies function interfaces, so any function that is visible to
18165other translation units, or that has its address taken, will @emph{not}
18166be affected by this option. Optimization options may also affect
18167viability. See the @code{strub} attribute documentation for details on
18168viability and eligibility requirements.
18169
18170@opindex fstrub=internal
18171@item -fstrub=internal
18172Enable @code{internal} @code{strub} mode where viable. The primary use
18173of this option is for testing. This option is intended to exercise
18174thoroughly parts of the @code{strub} machinery that implement the less
18175efficient, but interface-preserving @code{strub} mode. Functions that
18176would not be affected by this option are quite uncommon.
18177
18178@opindex fstrub=all
18179@item -fstrub=all
18180Enable some @code{strub} mode where viable. When both strub modes are
18181viable, @code{at-calls} is preferred. @option{-fdump-ipa-strubm} adds
18182function attributes that tell which mode was selected for each function.
18183The primary use of this option is for testing, to exercise thoroughly
18184the @code{strub} machinery.
18185
d77de738 18186@opindex fvtable-verify
ddf6fe37 18187@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
d77de738
ML
18188This option is only available when compiling C++ code.
18189It turns on (or off, if using @option{-fvtable-verify=none}) the security
18190feature that verifies at run time, for every virtual call, that
18191the vtable pointer through which the call is made is valid for the type of
18192the object, and has not been corrupted or overwritten. If an invalid vtable
18193pointer is detected at run time, an error is reported and execution of the
18194program is immediately halted.
18195
18196This option causes run-time data structures to be built at program startup,
18197which are used for verifying the vtable pointers.
18198The options @samp{std} and @samp{preinit}
18199control the timing of when these data structures are built. In both cases the
18200data structures are built before execution reaches @code{main}. Using
18201@option{-fvtable-verify=std} causes the data structures to be built after
18202shared libraries have been loaded and initialized.
18203@option{-fvtable-verify=preinit} causes them to be built before shared
18204libraries have been loaded and initialized.
18205
18206If this option appears multiple times in the command line with different
18207values specified, @samp{none} takes highest priority over both @samp{std} and
18208@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
18209
d77de738 18210@opindex fvtv-debug
ddf6fe37 18211@item -fvtv-debug
d77de738
ML
18212When used in conjunction with @option{-fvtable-verify=std} or
18213@option{-fvtable-verify=preinit}, causes debug versions of the
18214runtime functions for the vtable verification feature to be called.
18215This flag also causes the compiler to log information about which
18216vtable pointers it finds for each class.
18217This information is written to a file named @file{vtv_set_ptr_data.log}
18218in the directory named by the environment variable @env{VTV_LOGS_DIR}
18219if that is defined or the current working directory otherwise.
18220
18221Note: This feature @emph{appends} data to the log file. If you want a fresh log
18222file, be sure to delete any existing one.
18223
d77de738 18224@opindex fvtv-counts
ddf6fe37 18225@item -fvtv-counts
d77de738
ML
18226This is a debugging flag. When used in conjunction with
18227@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
18228causes the compiler to keep track of the total number of virtual calls
18229it encounters and the number of verifications it inserts. It also
18230counts the number of calls to certain run-time library functions
18231that it inserts and logs this information for each compilation unit.
18232The compiler writes this information to a file named
18233@file{vtv_count_data.log} in the directory named by the environment
18234variable @env{VTV_LOGS_DIR} if that is defined or the current working
18235directory otherwise. It also counts the size of the vtable pointer sets
18236for each class, and writes this information to @file{vtv_class_set_sizes.log}
18237in the same directory.
18238
18239Note: This feature @emph{appends} data to the log files. To get fresh log
18240files, be sure to delete any existing ones.
18241
d77de738 18242@opindex finstrument-functions
ddf6fe37 18243@item -finstrument-functions
d77de738
ML
18244Generate instrumentation calls for entry and exit to functions. Just
18245after function entry and just before function exit, the following
18246profiling functions are called with the address of the current
18247function and its call site. (On some platforms,
18248@code{__builtin_return_address} does not work beyond the current
18249function, so the call site information may not be available to the
18250profiling functions otherwise.)
18251
18252@smallexample
18253void __cyg_profile_func_enter (void *this_fn,
18254 void *call_site);
18255void __cyg_profile_func_exit (void *this_fn,
18256 void *call_site);
18257@end smallexample
18258
18259The first argument is the address of the start of the current function,
18260which may be looked up exactly in the symbol table.
18261
18262This instrumentation is also done for functions expanded inline in other
18263functions. The profiling calls indicate where, conceptually, the
18264inline function is entered and exited. This means that addressable
18265versions of such functions must be available. If all your uses of a
18266function are expanded inline, this may mean an additional expansion of
18267code size. If you use @code{extern inline} in your C code, an
18268addressable version of such functions must be provided. (This is
18269normally the case anyway, but if you get lucky and the optimizer always
18270expands the functions inline, you might have gotten away without
18271providing static copies.)
18272
18273A function may be given the attribute @code{no_instrument_function}, in
18274which case this instrumentation is not done. This can be used, for
18275example, for the profiling functions listed above, high-priority
18276interrupt routines, and any functions from which the profiling functions
18277cannot safely be called (perhaps signal handlers, if the profiling
18278routines generate output or allocate memory).
18279@xref{Common Function Attributes}.
18280
9c19597c 18281@opindex finstrument-functions-once
ddf6fe37 18282@item -finstrument-functions-once
d77de738
ML
18283This is similar to @option{-finstrument-functions}, but the profiling
18284functions are called only once per instrumented function, i.e. the first
18285profiling function is called after the first entry into the instrumented
18286function and the second profiling function is called before the exit
18287corresponding to this first entry.
18288
18289The definition of @code{once} for the purpose of this option is a little
18290vague because the implementation is not protected against data races.
18291As a result, the implementation only guarantees that the profiling
18292functions are called at @emph{least} once per process and at @emph{most}
18293once per thread, but the calls are always paired, that is to say, if a
18294thread calls the first function, then it will call the second function,
18295unless it never reaches the exit of the instrumented function.
18296
d77de738 18297@opindex finstrument-functions-exclude-file-list
ddf6fe37 18298@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
d77de738
ML
18299
18300Set the list of functions that are excluded from instrumentation (see
18301the description of @option{-finstrument-functions}). If the file that
18302contains a function definition matches with one of @var{file}, then
18303that function is not instrumented. The match is done on substrings:
18304if the @var{file} parameter is a substring of the file name, it is
18305considered to be a match.
18306
18307For example:
18308
18309@smallexample
18310-finstrument-functions-exclude-file-list=/bits/stl,include/sys
18311@end smallexample
18312
18313@noindent
18314excludes any inline function defined in files whose pathnames
18315contain @file{/bits/stl} or @file{include/sys}.
18316
18317If, for some reason, you want to include letter @samp{,} in one of
18318@var{sym}, write @samp{\,}. For example,
18319@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
18320(note the single quote surrounding the option).
18321
d77de738 18322@opindex finstrument-functions-exclude-function-list
ddf6fe37 18323@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
d77de738
ML
18324
18325This is similar to @option{-finstrument-functions-exclude-file-list},
18326but this option sets the list of function names to be excluded from
18327instrumentation. The function name to be matched is its user-visible
18328name, such as @code{vector<int> blah(const vector<int> &)}, not the
18329internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
18330match is done on substrings: if the @var{sym} parameter is a substring
18331of the function name, it is considered to be a match. For C99 and C++
18332extended identifiers, the function name must be given in UTF-8, not
18333using universal character names.
18334
d77de738 18335@opindex fpatchable-function-entry
ddf6fe37 18336@item -fpatchable-function-entry=@var{N}[,@var{M}]
d77de738
ML
18337Generate @var{N} NOPs right at the beginning
18338of each function, with the function entry point before the @var{M}th NOP.
18339If @var{M} is omitted, it defaults to @code{0} so the
18340function entry points to the address just at the first NOP.
18341The NOP instructions reserve extra space which can be used to patch in
18342any desired instrumentation at run time, provided that the code segment
18343is writable. The amount of space is controllable indirectly via
18344the number of NOPs; the NOP instruction used corresponds to the instruction
18345emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
18346is target-specific and may also depend on the architecture variant and/or
18347other compilation options.
18348
18349For run-time identification, the starting addresses of these areas,
18350which correspond to their respective function entries minus @var{M},
18351are additionally collected in the @code{__patchable_function_entries}
18352section of the resulting binary.
18353
18354Note that the value of @code{__attribute__ ((patchable_function_entry
18355(N,M)))} takes precedence over command-line option
18356@option{-fpatchable-function-entry=N,M}. This can be used to increase
18357the area size or to remove it completely on a single function.
18358If @code{N=0}, no pad location is recorded.
18359
18360The NOP instructions are inserted at---and maybe before, depending on
18361@var{M}---the function entry address, even before the prologue. On
18362PowerPC with the ELFv2 ABI, for a function with dual entry points,
18363the local entry point is this function entry address.
18364
18365The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
18366ELFv2 ABI, for a function with dual entry points, the supported values
18367for @var{M} are 0, 2, 6 and 14.
18368@end table
18369
18370
18371@node Preprocessor Options
18372@section Options Controlling the Preprocessor
18373@cindex preprocessor options
18374@cindex options, preprocessor
18375
18376These options control the C preprocessor, which is run on each C source
18377file before actual compilation.
18378
18379If you use the @option{-E} option, nothing is done except preprocessing.
18380Some of these options make sense only together with @option{-E} because
18381they cause the preprocessor output to be unsuitable for actual
18382compilation.
18383
18384In addition to the options listed here, there are a number of options
18385to control search paths for include files documented in
18386@ref{Directory Options}.
18387Options to control preprocessor diagnostics are listed in
18388@ref{Warning Options}.
18389
18390@table @gcctabopt
18391@include cppopts.texi
18392
d77de738 18393@opindex Wp
ddf6fe37 18394@item -Wp,@var{option}
d77de738
ML
18395You can use @option{-Wp,@var{option}} to bypass the compiler driver
18396and pass @var{option} directly through to the preprocessor. If
18397@var{option} contains commas, it is split into multiple options at the
18398commas. However, many options are modified, translated or interpreted
18399by the compiler driver before being passed to the preprocessor, and
18400@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
18401interface is undocumented and subject to change, so whenever possible
18402you should avoid using @option{-Wp} and let the driver handle the
18403options instead.
18404
d77de738 18405@opindex Xpreprocessor
ddf6fe37 18406@item -Xpreprocessor @var{option}
d77de738
ML
18407Pass @var{option} as an option to the preprocessor. You can use this to
18408supply system-specific preprocessor options that GCC does not
18409recognize.
18410
18411If you want to pass an option that takes an argument, you must use
18412@option{-Xpreprocessor} twice, once for the option and once for the argument.
18413
d77de738 18414@opindex no-integrated-cpp
ddf6fe37 18415@item -no-integrated-cpp
d77de738
ML
18416Perform preprocessing as a separate pass before compilation.
18417By default, GCC performs preprocessing as an integrated part of
18418input tokenization and parsing.
18419If this option is provided, the appropriate language front end
18420(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
18421and Objective-C, respectively) is instead invoked twice,
18422once for preprocessing only and once for actual compilation
18423of the preprocessed input.
18424This option may be useful in conjunction with the @option{-B} or
18425@option{-wrapper} options to specify an alternate preprocessor or
18426perform additional processing of the program source between
18427normal preprocessing and compilation.
18428
d77de738 18429@opindex flarge-source-files
ddf6fe37 18430@item -flarge-source-files
d77de738
ML
18431Adjust GCC to expect large source files, at the expense of slower
18432compilation and higher memory usage.
18433
18434Specifically, GCC normally tracks both column numbers and line numbers
18435within source files and it normally prints both of these numbers in
18436diagnostics. However, once it has processed a certain number of source
18437lines, it stops tracking column numbers and only tracks line numbers.
18438This means that diagnostics for later lines do not include column numbers.
18439It also means that options like @option{-Wmisleading-indentation} cease to work
18440at that point, although the compiler prints a note if this happens.
18441Passing @option{-flarge-source-files} significantly increases the number
18442of source lines that GCC can process before it stops tracking columns.
18443
18444@end table
18445
18446@node Assembler Options
18447@section Passing Options to the Assembler
18448
18449@c prevent bad page break with this line
18450You can pass options to the assembler.
18451
18452@table @gcctabopt
d77de738 18453@opindex Wa
ddf6fe37 18454@item -Wa,@var{option}
d77de738
ML
18455Pass @var{option} as an option to the assembler. If @var{option}
18456contains commas, it is split into multiple options at the commas.
18457
d77de738 18458@opindex Xassembler
ddf6fe37 18459@item -Xassembler @var{option}
d77de738
ML
18460Pass @var{option} as an option to the assembler. You can use this to
18461supply system-specific assembler options that GCC does not
18462recognize.
18463
18464If you want to pass an option that takes an argument, you must use
18465@option{-Xassembler} twice, once for the option and once for the argument.
18466
18467@end table
18468
18469@node Link Options
18470@section Options for Linking
18471@cindex link options
18472@cindex options, linking
18473
18474These options come into play when the compiler links object files into
18475an executable output file. They are meaningless if the compiler is
18476not doing a link step.
18477
18478@table @gcctabopt
18479@cindex file names
18480@item @var{object-file-name}
18481A file name that does not end in a special recognized suffix is
18482considered to name an object file or library. (Object files are
18483distinguished from libraries by the linker according to the file
18484contents.) If linking is done, these object files are used as input
18485to the linker.
18486
d77de738
ML
18487@opindex c
18488@opindex S
18489@opindex E
ddf6fe37
AA
18490@item -c
18491@itemx -S
18492@itemx -E
d77de738
ML
18493If any of these options is used, then the linker is not run, and
18494object file names should not be used as arguments. @xref{Overall
18495Options}.
18496
d77de738 18497@opindex flinker-output
ddf6fe37 18498@item -flinker-output=@var{type}
d77de738
ML
18499This option controls code generation of the link-time optimizer. By
18500default the linker output is automatically determined by the linker
18501plugin. For debugging the compiler and if incremental linking with a
18502non-LTO object file is desired, it may be useful to control the type
18503manually.
18504
18505If @var{type} is @samp{exec}, code generation produces a static
18506binary. In this case @option{-fpic} and @option{-fpie} are both
18507disabled.
18508
18509If @var{type} is @samp{dyn}, code generation produces a shared
18510library. In this case @option{-fpic} or @option{-fPIC} is preserved,
18511but not enabled automatically. This allows to build shared libraries
18512without position-independent code on architectures where this is
18513possible, i.e.@: on x86.
18514
18515If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
18516executable. This results in similar optimizations as @samp{exec}
18517except that @option{-fpie} is not disabled if specified at compilation
18518time.
18519
18520If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
18521done. The sections containing intermediate code for link-time optimization are
18522merged, pre-optimized, and output to the resulting object file. In addition, if
18523@option{-ffat-lto-objects} is specified, binary code is produced for future
18524non-LTO linking. The object file produced by incremental linking is smaller
18525than a static library produced from the same object files. At link time the
18526result of incremental linking also loads faster than a static
18527library assuming that the majority of objects in the library are used.
18528
18529Finally @samp{nolto-rel} configures the compiler for incremental linking where
18530code generation is forced, a final binary is produced, and the intermediate
18531code for later link-time optimization is stripped. When multiple object files
18532are linked together the resulting code is better optimized than with
18533link-time optimizations disabled (for example, cross-module inlining
18534happens), but most of benefits of whole program optimizations are lost.
18535
18536During the incremental link (by @option{-r}) the linker plugin defaults to
18537@option{rel}. With current interfaces to GNU Binutils it is however not
18538possible to incrementally link LTO objects and non-LTO objects into a single
18539mixed object file. If any of object files in incremental link cannot
18540be used for link-time optimization, the linker plugin issues a warning and
18541uses @samp{nolto-rel}. To maintain whole program optimization, it is
18542recommended to link such objects into static library instead. Alternatively it
18543is possible to use H.J. Lu's binutils with support for mixed objects.
18544
d77de738 18545@opindex fuse-ld=bfd
ddf6fe37 18546@item -fuse-ld=bfd
d77de738
ML
18547Use the @command{bfd} linker instead of the default linker.
18548
d77de738 18549@opindex fuse-ld=gold
ddf6fe37 18550@item -fuse-ld=gold
d77de738
ML
18551Use the @command{gold} linker instead of the default linker.
18552
d77de738 18553@opindex fuse-ld=lld
ddf6fe37 18554@item -fuse-ld=lld
d77de738
ML
18555Use the LLVM @command{lld} linker instead of the default linker.
18556
d77de738 18557@opindex fuse-ld=mold
ddf6fe37 18558@item -fuse-ld=mold
d77de738
ML
18559Use the Modern Linker (@command{mold}) instead of the default linker.
18560
18561@cindex Libraries
ddf6fe37 18562@opindex l
d77de738
ML
18563@item -l@var{library}
18564@itemx -l @var{library}
d77de738
ML
18565Search the library named @var{library} when linking. (The second
18566alternative with the library as a separate argument is only for
18567POSIX compliance and is not recommended.)
18568
18569The @option{-l} option is passed directly to the linker by GCC. Refer
18570to your linker documentation for exact details. The general
18571description below applies to the GNU linker.
18572
18573The linker searches a standard list of directories for the library.
18574The directories searched include several standard system directories
18575plus any that you specify with @option{-L}.
18576
18577Static libraries are archives of object files, and have file names
18578like @file{lib@var{library}.a}. Some targets also support shared
18579libraries, which typically have names like @file{lib@var{library}.so}.
18580If both static and shared libraries are found, the linker gives
18581preference to linking with the shared library unless the
18582@option{-static} option is used.
18583
18584It makes a difference where in the command you write this option; the
18585linker searches and processes libraries and object files in the order they
18586are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
18587after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
18588to functions in @samp{z}, those functions may not be loaded.
18589
d77de738 18590@opindex lobjc
ddf6fe37 18591@item -lobjc
d77de738
ML
18592You need this special case of the @option{-l} option in order to
18593link an Objective-C or Objective-C++ program.
18594
d77de738 18595@opindex nostartfiles
ddf6fe37 18596@item -nostartfiles
d77de738
ML
18597Do not use the standard system startup files when linking.
18598The standard system libraries are used normally, unless @option{-nostdlib},
18599@option{-nolibc}, or @option{-nodefaultlibs} is used.
18600
d77de738 18601@opindex nodefaultlibs
ddf6fe37 18602@item -nodefaultlibs
d77de738
ML
18603Do not use the standard system libraries when linking.
18604Only the libraries you specify are passed to the linker, and options
18605specifying linkage of the system libraries, such as @option{-static-libgcc}
18606or @option{-shared-libgcc}, are ignored.
18607The standard startup files are used normally, unless @option{-nostartfiles}
18608is used.
18609
18610The compiler may generate calls to @code{memcmp},
18611@code{memset}, @code{memcpy} and @code{memmove}.
18612These entries are usually resolved by entries in
18613libc. These entry points should be supplied through some other
18614mechanism when this option is specified.
18615
d77de738 18616@opindex nolibc
ddf6fe37 18617@item -nolibc
d77de738
ML
18618Do not use the C library or system libraries tightly coupled with it when
18619linking. Still link with the startup files, @file{libgcc} or toolchain
18620provided language support libraries such as @file{libgnat}, @file{libgfortran}
18621or @file{libstdc++} unless options preventing their inclusion are used as
18622well. This typically removes @option{-lc} from the link command line, as well
18623as system libraries that normally go with it and become meaningless when
18624absence of a C library is assumed, for example @option{-lpthread} or
18625@option{-lm} in some configurations. This is intended for bare-board
18626targets when there is indeed no C library available.
18627
d77de738 18628@opindex nostdlib
ddf6fe37 18629@item -nostdlib
d77de738
ML
18630Do not use the standard system startup files or libraries when linking.
18631No startup files and only the libraries you specify are passed to
18632the linker, and options specifying linkage of the system libraries, such as
18633@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
18634
18635The compiler may generate calls to @code{memcmp}, @code{memset},
18636@code{memcpy} and @code{memmove}.
18637These entries are usually resolved by entries in
18638libc. These entry points should be supplied through some other
18639mechanism when this option is specified.
18640
18641@cindex @option{-lgcc}, use with @option{-nostdlib}
18642@cindex @option{-nostdlib} and unresolved references
18643@cindex unresolved references and @option{-nostdlib}
18644@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
18645@cindex @option{-nodefaultlibs} and unresolved references
18646@cindex unresolved references and @option{-nodefaultlibs}
18647One of the standard libraries bypassed by @option{-nostdlib} and
18648@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
18649which GCC uses to overcome shortcomings of particular machines, or special
18650needs for some languages.
18651(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
18652Collection (GCC) Internals},
18653for more discussion of @file{libgcc.a}.)
18654In most cases, you need @file{libgcc.a} even when you want to avoid
18655other standard libraries. In other words, when you specify @option{-nostdlib}
18656or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
18657This ensures that you have no unresolved references to internal GCC
18658library subroutines.
18659(An example of such an internal subroutine is @code{__main}, used to ensure C++
18660constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
18661GNU Compiler Collection (GCC) Internals}.)
18662
d77de738 18663@opindex nostdlib++
ddf6fe37 18664@item -nostdlib++
d77de738
ML
18665Do not implicitly link with standard C++ libraries.
18666
d77de738
ML
18667@opindex e
18668@opindex entry
ddf6fe37
AA
18669@item -e @var{entry}
18670@itemx --entry=@var{entry}
d77de738
ML
18671
18672Specify that the program entry point is @var{entry}. The argument is
18673interpreted by the linker; the GNU linker accepts either a symbol name
18674or an address.
18675
d77de738 18676@opindex pie
ddf6fe37 18677@item -pie
d77de738
ML
18678Produce a dynamically linked position independent executable on targets
18679that support it. For predictable results, you must also specify the same
18680set of options used for compilation (@option{-fpie}, @option{-fPIE},
18681or model suboptions) when you specify this linker option.
18682
d77de738 18683@opindex no-pie
ddf6fe37 18684@item -no-pie
d77de738
ML
18685Don't produce a dynamically linked position independent executable.
18686
d77de738 18687@opindex static-pie
ddf6fe37 18688@item -static-pie
d77de738
ML
18689Produce a static position independent executable on targets that support
18690it. A static position independent executable is similar to a static
18691executable, but can be loaded at any address without a dynamic linker.
18692For predictable results, you must also specify the same set of options
18693used for compilation (@option{-fpie}, @option{-fPIE}, or model
18694suboptions) when you specify this linker option.
18695
d77de738 18696@opindex pthread
ddf6fe37 18697@item -pthread
d77de738
ML
18698Link with the POSIX threads library. This option is supported on
18699GNU/Linux targets, most other Unix derivatives, and also on
18700x86 Cygwin and MinGW targets. On some targets this option also sets
18701flags for the preprocessor, so it should be used consistently for both
18702compilation and linking.
18703
d77de738 18704@opindex r
ddf6fe37 18705@item -r
d77de738
ML
18706Produce a relocatable object as output. This is also known as partial
18707linking.
18708
d77de738 18709@opindex rdynamic
ddf6fe37 18710@item -rdynamic
d77de738
ML
18711Pass the flag @option{-export-dynamic} to the ELF linker, on targets
18712that support it. This instructs the linker to add all symbols, not
18713only used ones, to the dynamic symbol table. This option is needed
18714for some uses of @code{dlopen} or to allow obtaining backtraces
18715from within a program.
18716
d77de738 18717@opindex s
ddf6fe37 18718@item -s
d77de738
ML
18719Remove all symbol table and relocation information from the executable.
18720
d77de738 18721@opindex static
ddf6fe37 18722@item -static
d77de738
ML
18723On systems that support dynamic linking, this overrides @option{-pie}
18724and prevents linking with the shared libraries. On other systems, this
18725option has no effect.
18726
d77de738 18727@opindex shared
ddf6fe37 18728@item -shared
d77de738
ML
18729Produce a shared object which can then be linked with other objects to
18730form an executable. Not all systems support this option. For predictable
18731results, you must also specify the same set of options used for compilation
18732(@option{-fpic}, @option{-fPIC}, or model suboptions) when
18733you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
18734needs to build supplementary stub code for constructors to work. On
18735multi-libbed systems, @samp{gcc -shared} must select the correct support
18736libraries to link against. Failing to supply the correct flags may lead
18737to subtle defects. Supplying them in cases where they are not necessary
b799acef
RB
18738is innocuous. @option{-shared} suppresses the addition of startup code
18739to alter the floating-point environment as done with @option{-ffast-math},
18740@option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
d77de738 18741
d77de738
ML
18742@opindex shared-libgcc
18743@opindex static-libgcc
ddf6fe37
AA
18744@item -shared-libgcc
18745@itemx -static-libgcc
d77de738
ML
18746On systems that provide @file{libgcc} as a shared library, these options
18747force the use of either the shared or static version, respectively.
18748If no shared version of @file{libgcc} was built when the compiler was
18749configured, these options have no effect.
18750
18751There are several situations in which an application should use the
18752shared @file{libgcc} instead of the static version. The most common
18753of these is when the application wishes to throw and catch exceptions
18754across different shared libraries. In that case, each of the libraries
18755as well as the application itself should use the shared @file{libgcc}.
18756
18757Therefore, the G++ driver automatically adds @option{-shared-libgcc}
18758whenever you build a shared library or a main executable, because C++
18759programs typically use exceptions, so this is the right thing to do.
18760
18761If, instead, you use the GCC driver to create shared libraries, you may
18762find that they are not always linked with the shared @file{libgcc}.
18763If GCC finds, at its configuration time, that you have a non-GNU linker
18764or a GNU linker that does not support option @option{--eh-frame-hdr},
18765it links the shared version of @file{libgcc} into shared libraries
18766by default. Otherwise, it takes advantage of the linker and optimizes
18767away the linking with the shared version of @file{libgcc}, linking with
18768the static version of libgcc by default. This allows exceptions to
18769propagate through such shared libraries, without incurring relocation
18770costs at library load time.
18771
18772However, if a library or main executable is supposed to throw or catch
18773exceptions, you must link it using the G++ driver, or using the option
18774@option{-shared-libgcc}, such that it is linked with the shared
18775@file{libgcc}.
18776
d77de738 18777@opindex static-libasan
ddf6fe37 18778@item -static-libasan
d77de738
ML
18779When the @option{-fsanitize=address} option is used to link a program,
18780the GCC driver automatically links against @option{libasan}. If
18781@file{libasan} is available as a shared library, and the @option{-static}
18782option is not used, then this links against the shared version of
18783@file{libasan}. The @option{-static-libasan} option directs the GCC
18784driver to link @file{libasan} statically, without necessarily linking
18785other libraries statically.
18786
d77de738 18787@opindex static-libtsan
ddf6fe37 18788@item -static-libtsan
d77de738
ML
18789When the @option{-fsanitize=thread} option is used to link a program,
18790the GCC driver automatically links against @option{libtsan}. If
18791@file{libtsan} is available as a shared library, and the @option{-static}
18792option is not used, then this links against the shared version of
18793@file{libtsan}. The @option{-static-libtsan} option directs the GCC
18794driver to link @file{libtsan} statically, without necessarily linking
18795other libraries statically.
18796
d77de738 18797@opindex static-liblsan
ddf6fe37 18798@item -static-liblsan
d77de738
ML
18799When the @option{-fsanitize=leak} option is used to link a program,
18800the GCC driver automatically links against @option{liblsan}. If
18801@file{liblsan} is available as a shared library, and the @option{-static}
18802option is not used, then this links against the shared version of
18803@file{liblsan}. The @option{-static-liblsan} option directs the GCC
18804driver to link @file{liblsan} statically, without necessarily linking
18805other libraries statically.
18806
d77de738 18807@opindex static-libubsan
ddf6fe37 18808@item -static-libubsan
d77de738
ML
18809When the @option{-fsanitize=undefined} option is used to link a program,
18810the GCC driver automatically links against @option{libubsan}. If
18811@file{libubsan} is available as a shared library, and the @option{-static}
18812option is not used, then this links against the shared version of
18813@file{libubsan}. The @option{-static-libubsan} option directs the GCC
18814driver to link @file{libubsan} statically, without necessarily linking
18815other libraries statically.
18816
d77de738 18817@opindex static-libstdc++
ddf6fe37 18818@item -static-libstdc++
d77de738
ML
18819When the @command{g++} program is used to link a C++ program, it
18820normally automatically links against @option{libstdc++}. If
18821@file{libstdc++} is available as a shared library, and the
18822@option{-static} option is not used, then this links against the
18823shared version of @file{libstdc++}. That is normally fine. However, it
18824is sometimes useful to freeze the version of @file{libstdc++} used by
18825the program without going all the way to a fully static link. The
18826@option{-static-libstdc++} option directs the @command{g++} driver to
18827link @file{libstdc++} statically, without necessarily linking other
18828libraries statically.
18829
d77de738 18830@opindex symbolic
ddf6fe37 18831@item -symbolic
d77de738
ML
18832Bind references to global symbols when building a shared object. Warn
18833about any unresolved references (unless overridden by the link editor
18834option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
18835this option.
18836
d77de738
ML
18837@opindex T
18838@cindex linker script
f33d7a88 18839@item -T @var{script}
d77de738
ML
18840Use @var{script} as the linker script. This option is supported by most
18841systems using the GNU linker. On some targets, such as bare-board
18842targets without an operating system, the @option{-T} option may be required
18843when linking to avoid references to undefined symbols.
18844
d77de738 18845@opindex Xlinker
ddf6fe37 18846@item -Xlinker @var{option}
d77de738
ML
18847Pass @var{option} as an option to the linker. You can use this to
18848supply system-specific linker options that GCC does not recognize.
18849
18850If you want to pass an option that takes a separate argument, you must use
18851@option{-Xlinker} twice, once for the option and once for the argument.
18852For example, to pass @option{-assert definitions}, you must write
18853@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
18854@option{-Xlinker "-assert definitions"}, because this passes the entire
18855string as a single argument, which is not what the linker expects.
18856
18857When using the GNU linker, it is usually more convenient to pass
18858arguments to linker options using the @option{@var{option}=@var{value}}
18859syntax than as separate arguments. For example, you can specify
18860@option{-Xlinker -Map=output.map} rather than
18861@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
18862this syntax for command-line options.
18863
d77de738 18864@opindex Wl
ddf6fe37 18865@item -Wl,@var{option}
d77de738
ML
18866Pass @var{option} as an option to the linker. If @var{option} contains
18867commas, it is split into multiple options at the commas. You can use this
18868syntax to pass an argument to the option.
18869For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
18870linker. When using the GNU linker, you can also get the same effect with
18871@option{-Wl,-Map=output.map}.
18872
d77de738 18873@opindex u
ddf6fe37 18874@item -u @var{symbol}
d77de738
ML
18875Pretend the symbol @var{symbol} is undefined, to force linking of
18876library modules to define it. You can use @option{-u} multiple times with
18877different symbols to force loading of additional library modules.
18878
d77de738 18879@opindex z
ddf6fe37 18880@item -z @var{keyword}
d77de738
ML
18881@option{-z} is passed directly on to the linker along with the keyword
18882@var{keyword}. See the section in the documentation of your linker for
18883permitted values and their meanings.
18884@end table
18885
18886@node Directory Options
18887@section Options for Directory Search
18888@cindex directory options
18889@cindex options, directory search
18890@cindex search path
18891
18892These options specify directories to search for header files, for
18893libraries and for parts of the compiler:
18894
18895@table @gcctabopt
18896@include cppdiropts.texi
18897
d77de738 18898@opindex iplugindir=
ddf6fe37 18899@item -iplugindir=@var{dir}
d77de738
ML
18900Set the directory to search for plugins that are passed
18901by @option{-fplugin=@var{name}} instead of
18902@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
18903to be used by the user, but only passed by the driver.
18904
d77de738 18905@opindex L
ddf6fe37 18906@item -L@var{dir}
d77de738
ML
18907Add directory @var{dir} to the list of directories to be searched
18908for @option{-l}.
18909
d77de738 18910@opindex B
ddf6fe37 18911@item -B@var{prefix}
d77de738
ML
18912This option specifies where to find the executables, libraries,
18913include files, and data files of the compiler itself.
18914
18915The compiler driver program runs one or more of the subprograms
18916@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
18917@var{prefix} as a prefix for each program it tries to run, both with and
18918without @samp{@var{machine}/@var{version}/} for the corresponding target
18919machine and compiler version.
18920
18921For each subprogram to be run, the compiler driver first tries the
18922@option{-B} prefix, if any. If that name is not found, or if @option{-B}
18923is not specified, the driver tries two standard prefixes,
18924@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
18925those results in a file name that is found, the unmodified program
18926name is searched for using the directories specified in your
18927@env{PATH} environment variable.
18928
18929The compiler checks to see if the path provided by @option{-B}
18930refers to a directory, and if necessary it adds a directory
18931separator character at the end of the path.
18932
18933@option{-B} prefixes that effectively specify directory names also apply
18934to libraries in the linker, because the compiler translates these
18935options into @option{-L} options for the linker. They also apply to
18936include files in the preprocessor, because the compiler translates these
18937options into @option{-isystem} options for the preprocessor. In this case,
18938the compiler appends @samp{include} to the prefix.
18939
18940The runtime support file @file{libgcc.a} can also be searched for using
18941the @option{-B} prefix, if needed. If it is not found there, the two
18942standard prefixes above are tried, and that is all. The file is left
18943out of the link if it is not found by those means.
18944
18945Another way to specify a prefix much like the @option{-B} prefix is to use
18946the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
18947Variables}.
18948
18949As a special kludge, if the path provided by @option{-B} is
18950@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
189519, then it is replaced by @file{[dir/]include}. This is to help
18952with boot-strapping the compiler.
18953
d77de738 18954@opindex no-canonical-prefixes
ddf6fe37 18955@item -no-canonical-prefixes
d77de738
ML
18956Do not expand any symbolic links, resolve references to @samp{/../}
18957or @samp{/./}, or make the path absolute when generating a relative
18958prefix.
18959
d77de738 18960@opindex sysroot
ddf6fe37 18961@item --sysroot=@var{dir}
d77de738
ML
18962Use @var{dir} as the logical root directory for headers and libraries.
18963For example, if the compiler normally searches for headers in
18964@file{/usr/include} and libraries in @file{/usr/lib}, it instead
18965searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
18966
18967If you use both this option and the @option{-isysroot} option, then
18968the @option{--sysroot} option applies to libraries, but the
18969@option{-isysroot} option applies to header files.
18970
18971The GNU linker (beginning with version 2.16) has the necessary support
18972for this option. If your linker does not support this option, the
18973header file aspect of @option{--sysroot} still works, but the
18974library aspect does not.
18975
d77de738 18976@opindex no-sysroot-suffix
ddf6fe37 18977@item --no-sysroot-suffix
d77de738
ML
18978For some targets, a suffix is added to the root directory specified
18979with @option{--sysroot}, depending on the other options used, so that
18980headers may for example be found in
18981@file{@var{dir}/@var{suffix}/usr/include} instead of
18982@file{@var{dir}/usr/include}. This option disables the addition of
18983such a suffix.
18984
18985@end table
18986
18987@node Code Gen Options
18988@section Options for Code Generation Conventions
18989@cindex code generation conventions
18990@cindex options, code generation
18991@cindex run-time options
18992
18993These machine-independent options control the interface conventions
18994used in code generation.
18995
18996Most of them have both positive and negative forms; the negative form
18997of @option{-ffoo} is @option{-fno-foo}. In the table below, only
18998one of the forms is listed---the one that is not the default. You
18999can figure out the other form by either removing @samp{no-} or adding
19000it.
19001
19002@table @gcctabopt
d77de738 19003@opindex fstack_reuse
ddf6fe37 19004@item -fstack-reuse=@var{reuse-level}
d77de738
ML
19005This option controls stack space reuse for user declared local/auto variables
19006and compiler generated temporaries. @var{reuse_level} can be @samp{all},
19007@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
19008local variables and temporaries, @samp{named_vars} enables the reuse only for
19009user defined local variables with names, and @samp{none} disables stack reuse
19010completely. The default value is @samp{all}. The option is needed when the
19011program extends the lifetime of a scoped local variable or a compiler generated
19012temporary beyond the end point defined by the language. When a lifetime of
19013a variable ends, and if the variable lives in memory, the optimizing compiler
19014has the freedom to reuse its stack space with other temporaries or scoped
19015local variables whose live range does not overlap with it. Legacy code extending
19016local lifetime is likely to break with the stack reuse optimization.
19017
19018For example,
19019
19020@smallexample
19021 int *p;
19022 @{
19023 int local1;
19024
19025 p = &local1;
19026 local1 = 10;
19027 ....
19028 @}
19029 @{
19030 int local2;
19031 local2 = 20;
19032 ...
19033 @}
19034
19035 if (*p == 10) // out of scope use of local1
19036 @{
19037
19038 @}
19039@end smallexample
19040
19041Another example:
19042@smallexample
19043
19044 struct A
19045 @{
19046 A(int k) : i(k), j(k) @{ @}
19047 int i;
19048 int j;
19049 @};
19050
19051 A *ap;
19052
19053 void foo(const A& ar)
19054 @{
19055 ap = &ar;
19056 @}
19057
19058 void bar()
19059 @{
19060 foo(A(10)); // temp object's lifetime ends when foo returns
19061
19062 @{
19063 A a(20);
19064 ....
19065 @}
19066 ap->i+= 10; // ap references out of scope temp whose space
19067 // is reused with a. What is the value of ap->i?
19068 @}
19069
19070@end smallexample
19071
19072The lifetime of a compiler generated temporary is well defined by the C++
19073standard. When a lifetime of a temporary ends, and if the temporary lives
19074in memory, the optimizing compiler has the freedom to reuse its stack
19075space with other temporaries or scoped local variables whose live range
19076does not overlap with it. However some of the legacy code relies on
19077the behavior of older compilers in which temporaries' stack space is
19078not reused, the aggressive stack reuse can lead to runtime errors. This
19079option is used to control the temporary stack reuse optimization.
19080
d77de738 19081@opindex ftrapv
ddf6fe37 19082@item -ftrapv
d77de738
ML
19083This option generates traps for signed overflow on addition, subtraction,
19084multiplication operations.
19085The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
19086@option{-ftrapv} @option{-fwrapv} on the command-line results in
19087@option{-fwrapv} being effective. Note that only active options override, so
19088using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
19089results in @option{-ftrapv} being effective.
19090
d77de738 19091@opindex fwrapv
ddf6fe37 19092@item -fwrapv
d77de738
ML
19093This option instructs the compiler to assume that signed arithmetic
19094overflow of addition, subtraction and multiplication wraps around
19095using twos-complement representation. This flag enables some optimizations
19096and disables others.
19097The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
19098@option{-ftrapv} @option{-fwrapv} on the command-line results in
19099@option{-fwrapv} being effective. Note that only active options override, so
19100using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
19101results in @option{-ftrapv} being effective.
19102
d77de738 19103@opindex fwrapv-pointer
ddf6fe37 19104@item -fwrapv-pointer
d77de738
ML
19105This option instructs the compiler to assume that pointer arithmetic
19106overflow on addition and subtraction wraps around using twos-complement
19107representation. This flag disables some optimizations which assume
19108pointer overflow is invalid.
19109
d77de738 19110@opindex fstrict-overflow
ddf6fe37 19111@item -fstrict-overflow
d77de738
ML
19112This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
19113negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
19114
d77de738 19115@opindex fexceptions
ddf6fe37 19116@item -fexceptions
d77de738
ML
19117Enable exception handling. Generates extra code needed to propagate
19118exceptions. For some targets, this implies GCC generates frame
19119unwind information for all functions, which can produce significant data
19120size overhead, although it does not affect execution. If you do not
19121specify this option, GCC enables it by default for languages like
19122C++ that normally require exception handling, and disables it for
19123languages like C that do not normally require it. However, you may need
19124to enable this option when compiling C code that needs to interoperate
19125properly with exception handlers written in C++. You may also wish to
19126disable this option if you are compiling older C++ programs that don't
19127use exception handling.
19128
d77de738 19129@opindex fnon-call-exceptions
ddf6fe37 19130@item -fnon-call-exceptions
d77de738
ML
19131Generate code that allows trapping instructions to throw exceptions.
19132Note that this requires platform-specific runtime support that does
19133not exist everywhere. Moreover, it only allows @emph{trapping}
19134instructions to throw exceptions, i.e.@: memory references or floating-point
19135instructions. It does not allow exceptions to be thrown from
19136arbitrary signal handlers such as @code{SIGALRM}. This enables
19137@option{-fexceptions}.
19138
d77de738 19139@opindex fdelete-dead-exceptions
ddf6fe37 19140@item -fdelete-dead-exceptions
d77de738
ML
19141Consider that instructions that may throw exceptions but don't otherwise
19142contribute to the execution of the program can be optimized away.
19143This does not affect calls to functions except those with the
19144@code{pure} or @code{const} attributes.
19145This option is enabled by default for the Ada and C++ compilers, as permitted by
19146the language specifications.
19147Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
19148
d77de738 19149@opindex funwind-tables
ddf6fe37 19150@item -funwind-tables
d77de738
ML
19151Similar to @option{-fexceptions}, except that it just generates any needed
19152static data, but does not affect the generated code in any other way.
19153You normally do not need to enable this option; instead, a language processor
19154that needs this handling enables it on your behalf.
19155
d77de738 19156@opindex fasynchronous-unwind-tables
ddf6fe37 19157@item -fasynchronous-unwind-tables
d77de738
ML
19158Generate unwind table in DWARF format, if supported by target machine. The
19159table is exact at each instruction boundary, so it can be used for stack
19160unwinding from asynchronous events (such as debugger or garbage collector).
19161
d77de738
ML
19162@opindex fno-gnu-unique
19163@opindex fgnu-unique
ddf6fe37 19164@item -fno-gnu-unique
d77de738
ML
19165On systems with recent GNU assembler and C library, the C++ compiler
19166uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
19167of template static data members and static local variables in inline
19168functions are unique even in the presence of @code{RTLD_LOCAL}; this
19169is necessary to avoid problems with a library used by two different
19170@code{RTLD_LOCAL} plugins depending on a definition in one of them and
19171therefore disagreeing with the other one about the binding of the
19172symbol. But this causes @code{dlclose} to be ignored for affected
19173DSOs; if your program relies on reinitialization of a DSO via
19174@code{dlclose} and @code{dlopen}, you can use
19175@option{-fno-gnu-unique}.
19176
d77de738 19177@opindex fpcc-struct-return
ddf6fe37 19178@item -fpcc-struct-return
d77de738
ML
19179Return ``short'' @code{struct} and @code{union} values in memory like
19180longer ones, rather than in registers. This convention is less
19181efficient, but it has the advantage of allowing intercallability between
19182GCC-compiled files and files compiled with other compilers, particularly
19183the Portable C Compiler (pcc).
19184
19185The precise convention for returning structures in memory depends
19186on the target configuration macros.
19187
19188Short structures and unions are those whose size and alignment match
19189that of some integer type.
19190
19191@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
19192switch is not binary compatible with code compiled with the
19193@option{-freg-struct-return} switch.
19194Use it to conform to a non-default application binary interface.
19195
d77de738 19196@opindex freg-struct-return
ddf6fe37 19197@item -freg-struct-return
d77de738
ML
19198Return @code{struct} and @code{union} values in registers when possible.
19199This is more efficient for small structures than
19200@option{-fpcc-struct-return}.
19201
19202If you specify neither @option{-fpcc-struct-return} nor
19203@option{-freg-struct-return}, GCC defaults to whichever convention is
19204standard for the target. If there is no standard convention, GCC
19205defaults to @option{-fpcc-struct-return}, except on targets where GCC is
19206the principal compiler. In those cases, we can choose the standard, and
19207we chose the more efficient register return alternative.
19208
19209@strong{Warning:} code compiled with the @option{-freg-struct-return}
19210switch is not binary compatible with code compiled with the
19211@option{-fpcc-struct-return} switch.
19212Use it to conform to a non-default application binary interface.
19213
d77de738 19214@opindex fshort-enums
ddf6fe37 19215@item -fshort-enums
d77de738
ML
19216Allocate to an @code{enum} type only as many bytes as it needs for the
19217declared range of possible values. Specifically, the @code{enum} type
19218is equivalent to the smallest integer type that has enough room.
d8a656d5
JW
19219This option has no effect for an enumeration type with a fixed underlying
19220type.
d77de738
ML
19221
19222@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
19223code that is not binary compatible with code generated without that switch.
19224Use it to conform to a non-default application binary interface.
19225
d77de738 19226@opindex fshort-wchar
ddf6fe37 19227@item -fshort-wchar
d77de738
ML
19228Override the underlying type for @code{wchar_t} to be @code{short
19229unsigned int} instead of the default for the target. This option is
19230useful for building programs to run under WINE@.
19231
19232@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
19233code that is not binary compatible with code generated without that switch.
19234Use it to conform to a non-default application binary interface.
19235
d77de738
ML
19236@opindex fcommon
19237@opindex fno-common
19238@cindex tentative definitions
f33d7a88 19239@item -fcommon
d77de738
ML
19240In C code, this option controls the placement of global variables
19241defined without an initializer, known as @dfn{tentative definitions}
19242in the C standard. Tentative definitions are distinct from declarations
19243of a variable with the @code{extern} keyword, which do not allocate storage.
19244
19245The default is @option{-fno-common}, which specifies that the compiler places
19246uninitialized global variables in the BSS section of the object file.
19247This inhibits the merging of tentative definitions by the linker so you get a
19248multiple-definition error if the same variable is accidentally defined in more
19249than one compilation unit.
19250
19251The @option{-fcommon} places uninitialized global variables in a common block.
19252This allows the linker to resolve all tentative definitions of the same variable
19253in different compilation units to the same object, or to a non-tentative
19254definition. This behavior is inconsistent with C++, and on many targets implies
19255a speed and code size penalty on global variable references. It is mainly
19256useful to enable legacy code to link without errors.
19257
d77de738
ML
19258@opindex fno-ident
19259@opindex fident
ddf6fe37 19260@item -fno-ident
d77de738
ML
19261Ignore the @code{#ident} directive.
19262
d77de738 19263@opindex finhibit-size-directive
ddf6fe37 19264@item -finhibit-size-directive
d77de738
ML
19265Don't output a @code{.size} assembler directive, or anything else that
19266would cause trouble if the function is split in the middle, and the
19267two halves are placed at locations far apart in memory. This option is
19268used when compiling @file{crtstuff.c}; you should not need to use it
19269for anything else.
19270
d77de738 19271@opindex fverbose-asm
ddf6fe37 19272@item -fverbose-asm
d77de738
ML
19273Put extra commentary information in the generated assembly code to
19274make it more readable. This option is generally only of use to those
19275who actually need to read the generated assembly code (perhaps while
19276debugging the compiler itself).
19277
19278@option{-fno-verbose-asm}, the default, causes the
19279extra information to be omitted and is useful when comparing two assembler
19280files.
19281
19282The added comments include:
19283
19284@itemize @bullet
19285
19286@item
19287information on the compiler version and command-line options,
19288
19289@item
19290the source code lines associated with the assembly instructions,
19291in the form FILENAME:LINENUMBER:CONTENT OF LINE,
19292
19293@item
19294hints on which high-level expressions correspond to
19295the various assembly instruction operands.
19296
19297@end itemize
19298
19299For example, given this C source file:
19300
19301@smallexample
19302int test (int n)
19303@{
19304 int i;
19305 int total = 0;
19306
19307 for (i = 0; i < n; i++)
19308 total += i * i;
19309
19310 return total;
19311@}
19312@end smallexample
19313
19314compiling to (x86_64) assembly via @option{-S} and emitting the result
19315direct to stdout via @option{-o} @option{-}
19316
19317@smallexample
19318gcc -S test.c -fverbose-asm -Os -o -
19319@end smallexample
19320
19321gives output similar to this:
19322
19323@smallexample
19324 .file "test.c"
19325# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
19326 [...snip...]
19327# options passed:
19328 [...snip...]
19329
19330 .text
19331 .globl test
19332 .type test, @@function
19333test:
19334.LFB0:
19335 .cfi_startproc
19336# test.c:4: int total = 0;
19337 xorl %eax, %eax # <retval>
19338# test.c:6: for (i = 0; i < n; i++)
19339 xorl %edx, %edx # i
19340.L2:
19341# test.c:6: for (i = 0; i < n; i++)
19342 cmpl %edi, %edx # n, i
19343 jge .L5 #,
19344# test.c:7: total += i * i;
19345 movl %edx, %ecx # i, tmp92
19346 imull %edx, %ecx # i, tmp92
19347# test.c:6: for (i = 0; i < n; i++)
19348 incl %edx # i
19349# test.c:7: total += i * i;
19350 addl %ecx, %eax # tmp92, <retval>
19351 jmp .L2 #
19352.L5:
19353# test.c:10: @}
19354 ret
19355 .cfi_endproc
19356.LFE0:
19357 .size test, .-test
19358 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
19359 .section .note.GNU-stack,"",@@progbits
19360@end smallexample
19361
19362The comments are intended for humans rather than machines and hence the
19363precise format of the comments is subject to change.
19364
d77de738 19365@opindex frecord-gcc-switches
ddf6fe37 19366@item -frecord-gcc-switches
d77de738
ML
19367This switch causes the command line used to invoke the
19368compiler to be recorded into the object file that is being created.
19369This switch is only implemented on some targets and the exact format
19370of the recording is target and binary file format dependent, but it
19371usually takes the form of a section containing ASCII text. This
19372switch is related to the @option{-fverbose-asm} switch, but that
19373switch only records information in the assembler output file as
19374comments, so it never reaches the object file.
19375See also @option{-grecord-gcc-switches} for another
19376way of storing compiler options into the object file.
19377
d77de738
ML
19378@opindex fpic
19379@cindex global offset table
19380@cindex PIC
f33d7a88 19381@item -fpic
d77de738
ML
19382Generate position-independent code (PIC) suitable for use in a shared
19383library, if supported for the target machine. Such code accesses all
19384constant addresses through a global offset table (GOT)@. The dynamic
19385loader resolves the GOT entries when the program starts (the dynamic
19386loader is not part of GCC; it is part of the operating system). If
19387the GOT size for the linked executable exceeds a machine-specific
19388maximum size, you get an error message from the linker indicating that
19389@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
19390instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
19391on the m68k and RS/6000. The x86 has no such limit.)
19392
19393Position-independent code requires special support, and therefore works
19394only on certain machines. For the x86, GCC supports PIC for System V
19395but not for the Sun 386i. Code generated for the IBM RS/6000 is always
19396position-independent.
19397
19398When this flag is set, the macros @code{__pic__} and @code{__PIC__}
19399are defined to 1.
19400
d77de738 19401@opindex fPIC
ddf6fe37 19402@item -fPIC
d77de738
ML
19403If supported for the target machine, emit position-independent code,
19404suitable for dynamic linking and avoiding any limit on the size of the
19405global offset table. This option makes a difference on AArch64, m68k,
19406PowerPC and SPARC@.
19407
19408Position-independent code requires special support, and therefore works
19409only on certain machines.
19410
19411When this flag is set, the macros @code{__pic__} and @code{__PIC__}
19412are defined to 2.
19413
d77de738
ML
19414@opindex fpie
19415@opindex fPIE
ddf6fe37
AA
19416@item -fpie
19417@itemx -fPIE
d77de738
ML
19418These options are similar to @option{-fpic} and @option{-fPIC}, but the
19419generated position-independent code can be only linked into executables.
19420Usually these options are used to compile code that will be linked using
19421the @option{-pie} GCC option.
19422
19423@option{-fpie} and @option{-fPIE} both define the macros
19424@code{__pie__} and @code{__PIE__}. The macros have the value 1
19425for @option{-fpie} and 2 for @option{-fPIE}.
19426
d77de738
ML
19427@opindex fno-plt
19428@opindex fplt
ddf6fe37 19429@item -fno-plt
d77de738
ML
19430Do not use the PLT for external function calls in position-independent code.
19431Instead, load the callee address at call sites from the GOT and branch to it.
19432This leads to more efficient code by eliminating PLT stubs and exposing
19433GOT loads to optimizations. On architectures such as 32-bit x86 where
19434PLT stubs expect the GOT pointer in a specific register, this gives more
19435register allocation freedom to the compiler.
19436Lazy binding requires use of the PLT;
19437with @option{-fno-plt} all external symbols are resolved at load time.
19438
19439Alternatively, the function attribute @code{noplt} can be used to avoid calls
19440through the PLT for specific external functions.
19441
19442In position-dependent code, a few targets also convert calls to
19443functions that are marked to not use the PLT to use the GOT instead.
19444
d77de738
ML
19445@opindex fno-jump-tables
19446@opindex fjump-tables
ddf6fe37 19447@item -fno-jump-tables
d77de738
ML
19448Do not use jump tables for switch statements even where it would be
19449more efficient than other code generation strategies. This option is
19450of use in conjunction with @option{-fpic} or @option{-fPIC} for
19451building code that forms part of a dynamic linker and cannot
19452reference the address of a jump table. On some targets, jump tables
19453do not require a GOT and this option is not needed.
19454
d77de738
ML
19455@opindex fno-bit-tests
19456@opindex fbit-tests
ddf6fe37 19457@item -fno-bit-tests
d77de738
ML
19458Do not use bit tests for switch statements even where it would be
19459more efficient than other code generation strategies.
19460
d77de738 19461@opindex ffixed
ddf6fe37 19462@item -ffixed-@var{reg}
d77de738
ML
19463Treat the register named @var{reg} as a fixed register; generated code
19464should never refer to it (except perhaps as a stack pointer, frame
19465pointer or in some other fixed role).
19466
19467@var{reg} must be the name of a register. The register names accepted
19468are machine-specific and are defined in the @code{REGISTER_NAMES}
19469macro in the machine description macro file.
19470
19471This flag does not have a negative form, because it specifies a
19472three-way choice.
19473
d77de738 19474@opindex fcall-used
ddf6fe37 19475@item -fcall-used-@var{reg}
d77de738
ML
19476Treat the register named @var{reg} as an allocable register that is
19477clobbered by function calls. It may be allocated for temporaries or
19478variables that do not live across a call. Functions compiled this way
19479do not save and restore the register @var{reg}.
19480
19481It is an error to use this flag with the frame pointer or stack pointer.
19482Use of this flag for other registers that have fixed pervasive roles in
19483the machine's execution model produces disastrous results.
19484
19485This flag does not have a negative form, because it specifies a
19486three-way choice.
19487
d77de738 19488@opindex fcall-saved
ddf6fe37 19489@item -fcall-saved-@var{reg}
d77de738
ML
19490Treat the register named @var{reg} as an allocable register saved by
19491functions. It may be allocated even for temporaries or variables that
19492live across a call. Functions compiled this way save and restore
19493the register @var{reg} if they use it.
19494
19495It is an error to use this flag with the frame pointer or stack pointer.
19496Use of this flag for other registers that have fixed pervasive roles in
19497the machine's execution model produces disastrous results.
19498
19499A different sort of disaster results from the use of this flag for
19500a register in which function values may be returned.
19501
19502This flag does not have a negative form, because it specifies a
19503three-way choice.
19504
d77de738 19505@opindex fpack-struct
ddf6fe37 19506@item -fpack-struct[=@var{n}]
d77de738
ML
19507Without a value specified, pack all structure members together without
19508holes. When a value is specified (which must be a small power of two), pack
19509structure members according to this value, representing the maximum
19510alignment (that is, objects with default alignment requirements larger than
19511this are output potentially unaligned at the next fitting location.
19512
19513@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
19514code that is not binary compatible with code generated without that switch.
19515Additionally, it makes the code suboptimal.
19516Use it to conform to a non-default application binary interface.
19517
d77de738 19518@opindex fleading-underscore
ddf6fe37 19519@item -fleading-underscore
d77de738
ML
19520This option and its counterpart, @option{-fno-leading-underscore}, forcibly
19521change the way C symbols are represented in the object file. One use
19522is to help link with legacy assembly code.
19523
19524@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
19525generate code that is not binary compatible with code generated without that
19526switch. Use it to conform to a non-default application binary interface.
19527Not all targets provide complete support for this switch.
19528
d77de738 19529@opindex ftls-model
ddf6fe37 19530@item -ftls-model=@var{model}
d77de738
ML
19531Alter the thread-local storage model to be used (@pxref{Thread-Local}).
19532The @var{model} argument should be one of @samp{global-dynamic},
19533@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
19534Note that the choice is subject to optimization: the compiler may use
19535a more efficient model for symbols not visible outside of the translation
19536unit, or if @option{-fpic} is not given on the command line.
19537
19538The default without @option{-fpic} is @samp{initial-exec}; with
19539@option{-fpic} the default is @samp{global-dynamic}.
19540
d77de738 19541@opindex ftrampolines
ddf6fe37 19542@item -ftrampolines
d77de738
ML
19543For targets that normally need trampolines for nested functions, always
19544generate them instead of using descriptors. Otherwise, for targets that
19545do not need them, like for example HP-PA or IA-64, do nothing.
19546
19547A trampoline is a small piece of code that is created at run time on the
19548stack when the address of a nested function is taken, and is used to call
19549the nested function indirectly. Therefore, it requires the stack to be
19550made executable in order for the program to work properly.
19551
19552@option{-fno-trampolines} is enabled by default on a language by language
19553basis to let the compiler avoid generating them, if it computes that this
19554is safe, and replace them with descriptors. Descriptors are made up of data
19555only, but the generated code must be prepared to deal with them. As of this
19556writing, @option{-fno-trampolines} is enabled by default only for Ada.
19557
19558Moreover, code compiled with @option{-ftrampolines} and code compiled with
19559@option{-fno-trampolines} are not binary compatible if nested functions are
19560present. This option must therefore be used on a program-wide basis and be
19561manipulated with extreme care.
19562
19563For languages other than Ada, the @code{-ftrampolines} and
19564@code{-fno-trampolines} options currently have no effect, and
19565trampolines are always generated on platforms that need them
19566for nested functions.
19567
28d8c680
AB
19568@opindex ftrampoline-impl
19569@item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]}
19570By default, trampolines are generated on stack. However, certain platforms
19571(such as the Apple M1) do not permit an executable stack. Compiling with
19572@option{-ftrampoline-impl=heap} generate calls to
837827f8
IS
19573@code{__gcc_nested_func_ptr_created} and
19574@code{__gcc_nested_func_ptr_deleted} in order to allocate and
28d8c680
AB
19575deallocate trampoline space on the executable heap. These functions are
19576implemented in libgcc, and will only be provided on specific targets:
19577x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap
19578trampolines are @emph{not} guaranteed to be correctly deallocated if you
19579@code{setjmp}, instantiate nested functions, and then @code{longjmp} back
19580to a state prior to having allocated those nested functions.
19581
d77de738 19582@opindex fvisibility
ddf6fe37 19583@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
19584Set the default ELF image symbol visibility to the specified option---all
19585symbols are marked with this unless overridden within the code.
19586Using this feature can very substantially improve linking and
19587load times of shared object libraries, produce more optimized
19588code, provide near-perfect API export and prevent symbol clashes.
19589It is @strong{strongly} recommended that you use this in any shared objects
19590you distribute.
19591
19592Despite the nomenclature, @samp{default} always means public; i.e.,
19593available to be linked against from outside the shared object.
19594@samp{protected} and @samp{internal} are pretty useless in real-world
19595usage so the only other commonly used option is @samp{hidden}.
19596The default if @option{-fvisibility} isn't specified is
19597@samp{default}, i.e., make every symbol public.
19598
19599A good explanation of the benefits offered by ensuring ELF
19600symbols have the correct visibility is given by ``How To Write
19601Shared Libraries'' by Ulrich Drepper (which can be found at
19602@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
19603solution made possible by this option to marking things hidden when
19604the default is public is to make the default hidden and mark things
19605public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
19606and @code{__attribute__ ((visibility("default")))} instead of
19607@code{__declspec(dllexport)} you get almost identical semantics with
19608identical syntax. This is a great boon to those working with
19609cross-platform projects.
19610
19611For those adding visibility support to existing code, you may find
19612@code{#pragma GCC visibility} of use. This works by you enclosing
19613the declarations you wish to set visibility for with (for example)
19614@code{#pragma GCC visibility push(hidden)} and
19615@code{#pragma GCC visibility pop}.
19616Bear in mind that symbol visibility should be viewed @strong{as
19617part of the API interface contract} and thus all new code should
19618always specify visibility when it is not the default; i.e., declarations
19619only for use within the local DSO should @strong{always} be marked explicitly
19620as hidden as so to avoid PLT indirection overheads---making this
19621abundantly clear also aids readability and self-documentation of the code.
19622Note that due to ISO C++ specification requirements, @code{operator new} and
19623@code{operator delete} must always be of default visibility.
19624
19625Be aware that headers from outside your project, in particular system
19626headers and headers from any other library you use, may not be
19627expecting to be compiled with visibility other than the default. You
19628may need to explicitly say @code{#pragma GCC visibility push(default)}
19629before including any such headers.
19630
19631@code{extern} declarations are not affected by @option{-fvisibility}, so
19632a lot of code can be recompiled with @option{-fvisibility=hidden} with
19633no modifications. However, this means that calls to @code{extern}
19634functions with no explicit visibility use the PLT, so it is more
19635effective to use @code{__attribute ((visibility))} and/or
19636@code{#pragma GCC visibility} to tell the compiler which @code{extern}
19637declarations should be treated as hidden.
19638
19639Note that @option{-fvisibility} does affect C++ vague linkage
19640entities. This means that, for instance, an exception class that is
19641be thrown between DSOs must be explicitly marked with default
19642visibility so that the @samp{type_info} nodes are unified between
19643the DSOs.
19644
19645An overview of these techniques, their benefits and how to use them
19646is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
19647
d77de738 19648@opindex fstrict-volatile-bitfields
ddf6fe37 19649@item -fstrict-volatile-bitfields
d77de738
ML
19650This option should be used if accesses to volatile bit-fields (or other
19651structure fields, although the compiler usually honors those types
19652anyway) should use a single access of the width of the
19653field's type, aligned to a natural alignment if possible. For
19654example, targets with memory-mapped peripheral registers might require
19655all such accesses to be 16 bits wide; with this flag you can
19656declare all peripheral bit-fields as @code{unsigned short} (assuming short
19657is 16 bits on these targets) to force GCC to use 16-bit accesses
19658instead of, perhaps, a more efficient 32-bit access.
19659
19660If this option is disabled, the compiler uses the most efficient
19661instruction. In the previous example, that might be a 32-bit load
19662instruction, even though that accesses bytes that do not contain
19663any portion of the bit-field, or memory-mapped registers unrelated to
19664the one being updated.
19665
19666In some cases, such as when the @code{packed} attribute is applied to a
19667structure field, it may not be possible to access the field with a single
19668read or write that is correctly aligned for the target machine. In this
19669case GCC falls back to generating multiple accesses rather than code that
19670will fault or truncate the result at run time.
19671
19672Note: Due to restrictions of the C/C++11 memory model, write accesses are
19673not allowed to touch non bit-field members. It is therefore recommended
19674to define all bits of the field's type as bit-field members.
19675
19676The default value of this option is determined by the application binary
19677interface for the target processor.
19678
d77de738 19679@opindex fsync-libcalls
ddf6fe37 19680@item -fsync-libcalls
d77de738
ML
19681This option controls whether any out-of-line instance of the @code{__sync}
19682family of functions may be used to implement the C++11 @code{__atomic}
19683family of functions.
19684
19685The default value of this option is enabled, thus the only useful form
19686of the option is @option{-fno-sync-libcalls}. This option is used in
19687the implementation of the @file{libatomic} runtime library.
19688
19689@end table
19690
19691@node Developer Options
19692@section GCC Developer Options
19693@cindex developer options
19694@cindex debugging GCC
19695@cindex debug dump options
19696@cindex dump options
19697@cindex compilation statistics
19698
19699This section describes command-line options that are primarily of
19700interest to GCC developers, including options to support compiler
19701testing and investigation of compiler bugs and compile-time
19702performance problems. This includes options that produce debug dumps
19703at various points in the compilation; that print statistics such as
19704memory use and execution time; and that print information about GCC's
19705configuration, such as where it searches for libraries. You should
19706rarely need to use any of these options for ordinary compilation and
19707linking tasks.
19708
19709Many developer options that cause GCC to dump output to a file take an
19710optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
19711or @samp{-} to dump to standard output, and @samp{stderr} for standard
19712error.
19713
19714If @samp{=@var{filename}} is omitted, a default dump file name is
19715constructed by concatenating the base dump file name, a pass number,
19716phase letter, and pass name. The base dump file name is the name of
19717output file produced by the compiler if explicitly specified and not
19718an executable; otherwise it is the source file name.
19719The pass number is determined by the order passes are registered with
19720the compiler's pass manager.
19721This is generally the same as the order of execution, but passes
19722registered by plugins, target-specific passes, or passes that are
19723otherwise registered late are numbered higher than the pass named
19724@samp{final}, even if they are executed earlier. The phase letter is
19725one of @samp{i} (inter-procedural analysis), @samp{l}
19726(language-specific), @samp{r} (RTL), or @samp{t} (tree).
19727The files are created in the directory of the output file.
19728
19729@table @gcctabopt
19730
ddf6fe37 19731@opindex fcallgraph-info
d77de738
ML
19732@item -fcallgraph-info
19733@itemx -fcallgraph-info=@var{MARKERS}
d77de738
ML
19734Makes the compiler output callgraph information for the program, on a
19735per-object-file basis. The information is generated in the common VCG
19736format. It can be decorated with additional, per-node and/or per-edge
19737information, if a list of comma-separated markers is additionally
19738specified. When the @code{su} marker is specified, the callgraph is
19739decorated with stack usage information; it is equivalent to
19740@option{-fstack-usage}. When the @code{da} marker is specified, the
19741callgraph is decorated with information about dynamically allocated
19742objects.
19743
19744When compiling with @option{-flto}, no callgraph information is output
19745along with the object file. At LTO link time, @option{-fcallgraph-info}
19746may generate multiple callgraph information files next to intermediate
19747LTO output files.
19748
ddf6fe37
AA
19749@opindex d
19750@opindex fdump-rtl-@var{pass}
d77de738
ML
19751@item -d@var{letters}
19752@itemx -fdump-rtl-@var{pass}
19753@itemx -fdump-rtl-@var{pass}=@var{filename}
d77de738
ML
19754Says to make debugging dumps during compilation at times specified by
19755@var{letters}. This is used for debugging the RTL-based passes of the
19756compiler.
19757
19758Some @option{-d@var{letters}} switches have different meaning when
19759@option{-E} is used for preprocessing. @xref{Preprocessor Options},
19760for information about preprocessor-specific dump options.
19761
19762Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
19763@option{-d} option @var{letters}. Here are the possible
19764letters for use in @var{pass} and @var{letters}, and their meanings:
19765
19766@table @gcctabopt
19767
d77de738 19768@opindex fdump-rtl-alignments
ddf6fe37 19769@item -fdump-rtl-alignments
d77de738
ML
19770Dump after branch alignments have been computed.
19771
d77de738 19772@opindex fdump-rtl-asmcons
ddf6fe37 19773@item -fdump-rtl-asmcons
d77de738
ML
19774Dump after fixing rtl statements that have unsatisfied in/out constraints.
19775
d77de738 19776@opindex fdump-rtl-auto_inc_dec
ddf6fe37 19777@item -fdump-rtl-auto_inc_dec
d77de738
ML
19778Dump after auto-inc-dec discovery. This pass is only run on
19779architectures that have auto inc or auto dec instructions.
19780
d77de738 19781@opindex fdump-rtl-barriers
ddf6fe37 19782@item -fdump-rtl-barriers
d77de738
ML
19783Dump after cleaning up the barrier instructions.
19784
d77de738 19785@opindex fdump-rtl-bbpart
ddf6fe37 19786@item -fdump-rtl-bbpart
d77de738
ML
19787Dump after partitioning hot and cold basic blocks.
19788
d77de738 19789@opindex fdump-rtl-bbro
ddf6fe37 19790@item -fdump-rtl-bbro
d77de738
ML
19791Dump after block reordering.
19792
d77de738
ML
19793@opindex fdump-rtl-btl2
19794@opindex fdump-rtl-btl2
ddf6fe37
AA
19795@item -fdump-rtl-btl1
19796@itemx -fdump-rtl-btl2
d77de738
ML
19797@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
19798after the two branch
19799target load optimization passes.
19800
d77de738 19801@opindex fdump-rtl-bypass
ddf6fe37 19802@item -fdump-rtl-bypass
d77de738
ML
19803Dump after jump bypassing and control flow optimizations.
19804
d77de738 19805@opindex fdump-rtl-combine
ddf6fe37 19806@item -fdump-rtl-combine
d77de738
ML
19807Dump after the RTL instruction combination pass.
19808
d77de738 19809@opindex fdump-rtl-compgotos
ddf6fe37 19810@item -fdump-rtl-compgotos
d77de738
ML
19811Dump after duplicating the computed gotos.
19812
d77de738
ML
19813@opindex fdump-rtl-ce1
19814@opindex fdump-rtl-ce2
19815@opindex fdump-rtl-ce3
ddf6fe37
AA
19816@item -fdump-rtl-ce1
19817@itemx -fdump-rtl-ce2
19818@itemx -fdump-rtl-ce3
d77de738
ML
19819@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
19820@option{-fdump-rtl-ce3} enable dumping after the three
19821if conversion passes.
19822
d77de738 19823@opindex fdump-rtl-cprop_hardreg
ddf6fe37 19824@item -fdump-rtl-cprop_hardreg
d77de738
ML
19825Dump after hard register copy propagation.
19826
d77de738 19827@opindex fdump-rtl-csa
ddf6fe37 19828@item -fdump-rtl-csa
d77de738
ML
19829Dump after combining stack adjustments.
19830
d77de738
ML
19831@opindex fdump-rtl-cse1
19832@opindex fdump-rtl-cse2
ddf6fe37
AA
19833@item -fdump-rtl-cse1
19834@itemx -fdump-rtl-cse2
d77de738
ML
19835@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
19836the two common subexpression elimination passes.
19837
d77de738 19838@opindex fdump-rtl-dce
ddf6fe37 19839@item -fdump-rtl-dce
d77de738
ML
19840Dump after the standalone dead code elimination passes.
19841
d77de738 19842@opindex fdump-rtl-dbr
ddf6fe37 19843@item -fdump-rtl-dbr
d77de738
ML
19844Dump after delayed branch scheduling.
19845
d77de738
ML
19846@opindex fdump-rtl-dce1
19847@opindex fdump-rtl-dce2
ddf6fe37
AA
19848@item -fdump-rtl-dce1
19849@itemx -fdump-rtl-dce2
d77de738
ML
19850@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
19851the two dead store elimination passes.
19852
d77de738 19853@opindex fdump-rtl-eh
ddf6fe37 19854@item -fdump-rtl-eh
d77de738
ML
19855Dump after finalization of EH handling code.
19856
d77de738 19857@opindex fdump-rtl-eh_ranges
ddf6fe37 19858@item -fdump-rtl-eh_ranges
d77de738
ML
19859Dump after conversion of EH handling range regions.
19860
d77de738 19861@opindex fdump-rtl-expand
ddf6fe37 19862@item -fdump-rtl-expand
d77de738
ML
19863Dump after RTL generation.
19864
d77de738
ML
19865@opindex fdump-rtl-fwprop1
19866@opindex fdump-rtl-fwprop2
ddf6fe37
AA
19867@item -fdump-rtl-fwprop1
19868@itemx -fdump-rtl-fwprop2
d77de738
ML
19869@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
19870dumping after the two forward propagation passes.
19871
d77de738
ML
19872@opindex fdump-rtl-gcse1
19873@opindex fdump-rtl-gcse2
ddf6fe37
AA
19874@item -fdump-rtl-gcse1
19875@itemx -fdump-rtl-gcse2
d77de738
ML
19876@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
19877after global common subexpression elimination.
19878
d77de738 19879@opindex fdump-rtl-init-regs
ddf6fe37 19880@item -fdump-rtl-init-regs
d77de738
ML
19881Dump after the initialization of the registers.
19882
d77de738 19883@opindex fdump-rtl-initvals
ddf6fe37 19884@item -fdump-rtl-initvals
d77de738
ML
19885Dump after the computation of the initial value sets.
19886
d77de738 19887@opindex fdump-rtl-into_cfglayout
ddf6fe37 19888@item -fdump-rtl-into_cfglayout
d77de738
ML
19889Dump after converting to cfglayout mode.
19890
d77de738 19891@opindex fdump-rtl-ira
ddf6fe37 19892@item -fdump-rtl-ira
d77de738
ML
19893Dump after iterated register allocation.
19894
d77de738 19895@opindex fdump-rtl-jump
ddf6fe37 19896@item -fdump-rtl-jump
d77de738
ML
19897Dump after the second jump optimization.
19898
d77de738 19899@opindex fdump-rtl-loop2
ddf6fe37 19900@item -fdump-rtl-loop2
d77de738
ML
19901@option{-fdump-rtl-loop2} enables dumping after the rtl
19902loop optimization passes.
19903
d77de738 19904@opindex fdump-rtl-mach
ddf6fe37 19905@item -fdump-rtl-mach
d77de738
ML
19906Dump after performing the machine dependent reorganization pass, if that
19907pass exists.
19908
d77de738 19909@opindex fdump-rtl-mode_sw
ddf6fe37 19910@item -fdump-rtl-mode_sw
d77de738
ML
19911Dump after removing redundant mode switches.
19912
d77de738 19913@opindex fdump-rtl-rnreg
ddf6fe37 19914@item -fdump-rtl-rnreg
d77de738
ML
19915Dump after register renumbering.
19916
d77de738 19917@opindex fdump-rtl-outof_cfglayout
ddf6fe37 19918@item -fdump-rtl-outof_cfglayout
d77de738
ML
19919Dump after converting from cfglayout mode.
19920
d77de738 19921@opindex fdump-rtl-peephole2
ddf6fe37 19922@item -fdump-rtl-peephole2
d77de738
ML
19923Dump after the peephole pass.
19924
d77de738 19925@opindex fdump-rtl-postreload
ddf6fe37 19926@item -fdump-rtl-postreload
d77de738
ML
19927Dump after post-reload optimizations.
19928
d77de738 19929@opindex fdump-rtl-pro_and_epilogue
ddf6fe37 19930@item -fdump-rtl-pro_and_epilogue
d77de738
ML
19931Dump after generating the function prologues and epilogues.
19932
d77de738
ML
19933@opindex fdump-rtl-sched1
19934@opindex fdump-rtl-sched2
ddf6fe37
AA
19935@item -fdump-rtl-sched1
19936@itemx -fdump-rtl-sched2
d77de738
ML
19937@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
19938after the basic block scheduling passes.
19939
d77de738 19940@opindex fdump-rtl-ree
ddf6fe37 19941@item -fdump-rtl-ree
d77de738
ML
19942Dump after sign/zero extension elimination.
19943
d77de738 19944@opindex fdump-rtl-seqabstr
ddf6fe37 19945@item -fdump-rtl-seqabstr
d77de738
ML
19946Dump after common sequence discovery.
19947
d77de738 19948@opindex fdump-rtl-shorten
ddf6fe37 19949@item -fdump-rtl-shorten
d77de738
ML
19950Dump after shortening branches.
19951
d77de738 19952@opindex fdump-rtl-sibling
ddf6fe37 19953@item -fdump-rtl-sibling
d77de738
ML
19954Dump after sibling call optimizations.
19955
d77de738
ML
19956@opindex fdump-rtl-split1
19957@opindex fdump-rtl-split2
19958@opindex fdump-rtl-split3
19959@opindex fdump-rtl-split4
19960@opindex fdump-rtl-split5
ddf6fe37
AA
19961@item -fdump-rtl-split1
19962@itemx -fdump-rtl-split2
19963@itemx -fdump-rtl-split3
19964@itemx -fdump-rtl-split4
19965@itemx -fdump-rtl-split5
d77de738
ML
19966These options enable dumping after five rounds of
19967instruction splitting.
19968
d77de738 19969@opindex fdump-rtl-sms
ddf6fe37 19970@item -fdump-rtl-sms
d77de738
ML
19971Dump after modulo scheduling. This pass is only run on some
19972architectures.
19973
d77de738 19974@opindex fdump-rtl-stack
ddf6fe37 19975@item -fdump-rtl-stack
d77de738
ML
19976Dump after conversion from GCC's ``flat register file'' registers to the
19977x87's stack-like registers. This pass is only run on x86 variants.
19978
d77de738
ML
19979@opindex fdump-rtl-subreg1
19980@opindex fdump-rtl-subreg2
ddf6fe37
AA
19981@item -fdump-rtl-subreg1
19982@itemx -fdump-rtl-subreg2
d77de738
ML
19983@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
19984the two subreg expansion passes.
19985
d77de738 19986@opindex fdump-rtl-unshare
ddf6fe37 19987@item -fdump-rtl-unshare
d77de738
ML
19988Dump after all rtl has been unshared.
19989
d77de738 19990@opindex fdump-rtl-vartrack
ddf6fe37 19991@item -fdump-rtl-vartrack
d77de738
ML
19992Dump after variable tracking.
19993
d77de738 19994@opindex fdump-rtl-vregs
ddf6fe37 19995@item -fdump-rtl-vregs
d77de738
ML
19996Dump after converting virtual registers to hard registers.
19997
d77de738 19998@opindex fdump-rtl-web
ddf6fe37 19999@item -fdump-rtl-web
d77de738
ML
20000Dump after live range splitting.
20001
d77de738
ML
20002@opindex fdump-rtl-regclass
20003@opindex fdump-rtl-subregs_of_mode_init
20004@opindex fdump-rtl-subregs_of_mode_finish
20005@opindex fdump-rtl-dfinit
20006@opindex fdump-rtl-dfinish
ddf6fe37
AA
20007@item -fdump-rtl-regclass
20008@itemx -fdump-rtl-subregs_of_mode_init
20009@itemx -fdump-rtl-subregs_of_mode_finish
20010@itemx -fdump-rtl-dfinit
20011@itemx -fdump-rtl-dfinish
d77de738
ML
20012These dumps are defined but always produce empty files.
20013
d77de738
ML
20014@opindex da
20015@opindex fdump-rtl-all
ddf6fe37
AA
20016@item -da
20017@itemx -fdump-rtl-all
d77de738
ML
20018Produce all the dumps listed above.
20019
d77de738 20020@opindex dA
ddf6fe37 20021@item -dA
d77de738
ML
20022Annotate the assembler output with miscellaneous debugging information.
20023
d77de738 20024@opindex dD
ddf6fe37 20025@item -dD
d77de738
ML
20026Dump all macro definitions, at the end of preprocessing, in addition to
20027normal output.
20028
d77de738 20029@opindex dH
ddf6fe37 20030@item -dH
d77de738
ML
20031Produce a core dump whenever an error occurs.
20032
d77de738 20033@opindex dp
ddf6fe37 20034@item -dp
d77de738
ML
20035Annotate the assembler output with a comment indicating which
20036pattern and alternative is used. The length and cost of each instruction are
20037also printed.
20038
d77de738 20039@opindex dP
ddf6fe37 20040@item -dP
d77de738
ML
20041Dump the RTL in the assembler output as a comment before each instruction.
20042Also turns on @option{-dp} annotation.
20043
d77de738 20044@opindex dx
ddf6fe37 20045@item -dx
d77de738
ML
20046Just generate RTL for a function instead of compiling it. Usually used
20047with @option{-fdump-rtl-expand}.
20048@end table
20049
d77de738 20050@opindex fdump-debug
ddf6fe37 20051@item -fdump-debug
d77de738
ML
20052Dump debugging information generated during the debug
20053generation phase.
20054
d77de738 20055@opindex fdump-earlydebug
ddf6fe37 20056@item -fdump-earlydebug
d77de738
ML
20057Dump debugging information generated during the early debug
20058generation phase.
20059
d77de738 20060@opindex fdump-noaddr
ddf6fe37 20061@item -fdump-noaddr
d77de738
ML
20062When doing debugging dumps, suppress address output. This makes it more
20063feasible to use diff on debugging dumps for compiler invocations with
20064different compiler binaries and/or different
20065text / bss / data / heap / stack / dso start locations.
20066
d77de738 20067@opindex freport-bug
ddf6fe37 20068@item -freport-bug
d77de738
ML
20069Collect and dump debug information into a temporary file if an
20070internal compiler error (ICE) occurs.
20071
d77de738 20072@opindex fdump-unnumbered
ddf6fe37 20073@item -fdump-unnumbered
d77de738
ML
20074When doing debugging dumps, suppress instruction numbers and address output.
20075This makes it more feasible to use diff on debugging dumps for compiler
20076invocations with different options, in particular with and without
20077@option{-g}.
20078
d77de738 20079@opindex fdump-unnumbered-links
ddf6fe37 20080@item -fdump-unnumbered-links
d77de738
ML
20081When doing debugging dumps (see @option{-d} option above), suppress
20082instruction numbers for the links to the previous and next instructions
20083in a sequence.
20084
ddf6fe37 20085@opindex fdump-ipa
d77de738
ML
20086@item -fdump-ipa-@var{switch}
20087@itemx -fdump-ipa-@var{switch}-@var{options}
d77de738
ML
20088Control the dumping at various stages of inter-procedural analysis
20089language tree to a file. The file name is generated by appending a
20090switch specific suffix to the source file name, and the file is created
20091in the same directory as the output file. The following dumps are
20092possible:
20093
20094@table @samp
20095@item all
20096Enables all inter-procedural analysis dumps.
20097
20098@item cgraph
20099Dumps information about call-graph optimization, unused function removal,
20100and inlining decisions.
20101
20102@item inline
20103Dump after function inlining.
20104
f0a90c7d
AO
20105@item strubm
20106Dump after selecting @code{strub} modes, and recording the selections as
20107function attributes.
20108
20109@item strub
20110Dump @code{strub} transformations: interface changes, function wrapping,
20111and insertion of builtin calls for stack scrubbing and watermarking.
20112
d77de738
ML
20113@end table
20114
20115Additionally, the options @option{-optimized}, @option{-missed},
20116@option{-note}, and @option{-all} can be provided, with the same meaning
20117as for @option{-fopt-info}, defaulting to @option{-optimized}.
20118
20119For example, @option{-fdump-ipa-inline-optimized-missed} will emit
20120information on callsites that were inlined, along with callsites
20121that were not inlined.
20122
20123By default, the dump will contain messages about successful
20124optimizations (equivalent to @option{-optimized}) together with
20125low-level details about the analysis.
20126
d77de738 20127@opindex fdump-lang
ddf6fe37 20128@item -fdump-lang
d77de738
ML
20129Dump language-specific information. The file name is made by appending
20130@file{.lang} to the source file name.
20131
ddf6fe37
AA
20132@opindex fdump-lang-all
20133@opindex fdump-lang
d77de738
ML
20134@item -fdump-lang-all
20135@itemx -fdump-lang-@var{switch}
20136@itemx -fdump-lang-@var{switch}-@var{options}
20137@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
d77de738
ML
20138Control the dumping of language-specific information. The @var{options}
20139and @var{filename} portions behave as described in the
20140@option{-fdump-tree} option. The following @var{switch} values are
20141accepted:
20142
20143@table @samp
20144@item all
20145
20146Enable all language-specific dumps.
20147
20148@item class
20149Dump class hierarchy information. Virtual table information is emitted
20150unless '@option{slim}' is specified. This option is applicable to C++ only.
20151
20152@item module
20153Dump module information. Options @option{lineno} (locations),
20154@option{graph} (reachability), @option{blocks} (clusters),
20155@option{uid} (serialization), @option{alias} (mergeable),
20156@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
20157(macros) may provide additional information. This option is
20158applicable to C++ only.
20159
20160@item raw
20161Dump the raw internal tree data. This option is applicable to C++ only.
20162
20163@end table
20164
d77de738 20165@opindex fdump-passes
ddf6fe37 20166@item -fdump-passes
d77de738
ML
20167Print on @file{stderr} the list of optimization passes that are turned
20168on and off by the current command-line options.
20169
d77de738 20170@opindex fdump-statistics
ddf6fe37 20171@item -fdump-statistics-@var{option}
d77de738
ML
20172Enable and control dumping of pass statistics in a separate file. The
20173file name is generated by appending a suffix ending in
20174@samp{.statistics} to the source file name, and the file is created in
20175the same directory as the output file. If the @samp{-@var{option}}
20176form is used, @samp{-stats} causes counters to be summed over the
20177whole compilation unit while @samp{-details} dumps every event as
20178the passes generate them. The default with no option is to sum
20179counters for each function compiled.
20180
ddf6fe37
AA
20181@opindex fdump-tree-all
20182@opindex fdump-tree
d77de738
ML
20183@item -fdump-tree-all
20184@itemx -fdump-tree-@var{switch}
20185@itemx -fdump-tree-@var{switch}-@var{options}
20186@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
d77de738
ML
20187Control the dumping at various stages of processing the intermediate
20188language tree to a file. If the @samp{-@var{options}}
20189form is used, @var{options} is a list of @samp{-} separated options
20190which control the details of the dump. Not all options are applicable
20191to all dumps; those that are not meaningful are ignored. The
20192following options are available
20193
20194@table @samp
20195@item address
20196Print the address of each node. Usually this is not meaningful as it
20197changes according to the environment and source file. Its primary use
20198is for tying up a dump file with a debug environment.
20199@item asmname
20200If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
20201in the dump instead of @code{DECL_NAME}. Its primary use is ease of
20202use working backward from mangled names in the assembly file.
20203@item slim
20204When dumping front-end intermediate representations, inhibit dumping
20205of members of a scope or body of a function merely because that scope
20206has been reached. Only dump such items when they are directly reachable
20207by some other path.
20208
20209When dumping pretty-printed trees, this option inhibits dumping the
20210bodies of control structures.
20211
20212When dumping RTL, print the RTL in slim (condensed) form instead of
20213the default LISP-like representation.
20214@item raw
20215Print a raw representation of the tree. By default, trees are
20216pretty-printed into a C-like representation.
20217@item details
20218Enable more detailed dumps (not honored by every dump option). Also
20219include information from the optimization passes.
20220@item stats
20221Enable dumping various statistics about the pass (not honored by every dump
20222option).
20223@item blocks
20224Enable showing basic block boundaries (disabled in raw dumps).
20225@item graph
20226For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
20227dump a representation of the control flow graph suitable for viewing with
20228GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
20229the file is pretty-printed as a subgraph, so that GraphViz can render them
20230all in a single plot.
20231
20232This option currently only works for RTL dumps, and the RTL is always
20233dumped in slim form.
20234@item vops
20235Enable showing virtual operands for every statement.
20236@item lineno
20237Enable showing line numbers for statements.
20238@item uid
20239Enable showing the unique ID (@code{DECL_UID}) for each variable.
20240@item verbose
20241Enable showing the tree dump for each statement.
20242@item eh
20243Enable showing the EH region number holding each statement.
20244@item scev
20245Enable showing scalar evolution analysis details.
20246@item optimized
20247Enable showing optimization information (only available in certain
20248passes).
20249@item missed
20250Enable showing missed optimization information (only available in certain
20251passes).
20252@item note
20253Enable other detailed optimization information (only available in
20254certain passes).
20255@item all
20256Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
20257and @option{lineno}.
20258@item optall
20259Turn on all optimization options, i.e., @option{optimized},
20260@option{missed}, and @option{note}.
20261@end table
20262
20263To determine what tree dumps are available or find the dump for a pass
20264of interest follow the steps below.
20265
20266@enumerate
20267@item
20268Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
20269look for a code that corresponds to the pass you are interested in.
20270For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
20271@code{tree-vrp2} correspond to the three Value Range Propagation passes.
20272The number at the end distinguishes distinct invocations of the same pass.
20273@item
20274To enable the creation of the dump file, append the pass code to
20275the @option{-fdump-} option prefix and invoke GCC with it. For example,
20276to enable the dump from the Early Value Range Propagation pass, invoke
20277GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
20278specify the name of the dump file. If you don't specify one, GCC
20279creates as described below.
20280@item
20281Find the pass dump in a file whose name is composed of three components
20282separated by a period: the name of the source file GCC was invoked to
20283compile, a numeric suffix indicating the pass number followed by the
20284letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
20285and finally the pass code. For example, the Early VRP pass dump might
20286be in a file named @file{myfile.c.038t.evrp} in the current working
20287directory. Note that the numeric codes are not stable and may change
20288from one version of GCC to another.
20289@end enumerate
20290
ddf6fe37 20291@opindex fopt-info
d77de738
ML
20292@item -fopt-info
20293@itemx -fopt-info-@var{options}
20294@itemx -fopt-info-@var{options}=@var{filename}
d77de738
ML
20295Controls optimization dumps from various optimization passes. If the
20296@samp{-@var{options}} form is used, @var{options} is a list of
20297@samp{-} separated option keywords to select the dump details and
20298optimizations.
20299
20300The @var{options} can be divided into three groups:
20301@enumerate
20302@item
20303options describing what kinds of messages should be emitted,
20304@item
20305options describing the verbosity of the dump, and
20306@item
20307options describing which optimizations should be included.
20308@end enumerate
20309The options from each group can be freely mixed as they are
20310non-overlapping. However, in case of any conflicts,
20311the later options override the earlier options on the command
20312line.
20313
20314The following options control which kinds of messages should be emitted:
20315
20316@table @samp
20317@item optimized
20318Print information when an optimization is successfully applied. It is
20319up to a pass to decide which information is relevant. For example, the
20320vectorizer passes print the source location of loops which are
20321successfully vectorized.
20322@item missed
20323Print information about missed optimizations. Individual passes
20324control which information to include in the output.
20325@item note
20326Print verbose information about optimizations, such as certain
20327transformations, more detailed messages about decisions etc.
20328@item all
20329Print detailed optimization information. This includes
20330@samp{optimized}, @samp{missed}, and @samp{note}.
20331@end table
20332
20333The following option controls the dump verbosity:
20334
20335@table @samp
20336@item internals
20337By default, only ``high-level'' messages are emitted. This option enables
20338additional, more detailed, messages, which are likely to only be of interest
20339to GCC developers.
20340@end table
20341
20342One or more of the following option keywords can be used to describe a
20343group of optimizations:
20344
20345@table @samp
20346@item ipa
20347Enable dumps from all interprocedural optimizations.
20348@item loop
20349Enable dumps from all loop optimizations.
20350@item inline
20351Enable dumps from all inlining optimizations.
20352@item omp
20353Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
20354@item vec
20355Enable dumps from all vectorization optimizations.
20356@item optall
20357Enable dumps from all optimizations. This is a superset of
20358the optimization groups listed above.
20359@end table
20360
20361If @var{options} is
20362omitted, it defaults to @samp{optimized-optall}, which means to dump messages
20363about successful optimizations from all the passes, omitting messages
20364that are treated as ``internals''.
20365
20366If the @var{filename} is provided, then the dumps from all the
20367applicable optimizations are concatenated into the @var{filename}.
20368Otherwise the dump is output onto @file{stderr}. Though multiple
20369@option{-fopt-info} options are accepted, only one of them can include
20370a @var{filename}. If other filenames are provided then all but the
20371first such option are ignored.
20372
20373Note that the output @var{filename} is overwritten
20374in case of multiple translation units. If a combined output from
20375multiple translation units is desired, @file{stderr} should be used
20376instead.
20377
20378In the following example, the optimization info is output to
20379@file{stderr}:
20380
20381@smallexample
20382gcc -O3 -fopt-info
20383@end smallexample
20384
20385This example:
20386@smallexample
20387gcc -O3 -fopt-info-missed=missed.all
20388@end smallexample
20389
20390@noindent
20391outputs missed optimization report from all the passes into
20392@file{missed.all}, and this one:
20393
20394@smallexample
20395gcc -O2 -ftree-vectorize -fopt-info-vec-missed
20396@end smallexample
20397
20398@noindent
20399prints information about missed optimization opportunities from
20400vectorization passes on @file{stderr}.
20401Note that @option{-fopt-info-vec-missed} is equivalent to
20402@option{-fopt-info-missed-vec}. The order of the optimization group
20403names and message types listed after @option{-fopt-info} does not matter.
20404
20405As another example,
20406@smallexample
20407gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
20408@end smallexample
20409
20410@noindent
20411outputs information about missed optimizations as well as
20412optimized locations from all the inlining passes into
20413@file{inline.txt}.
20414
20415Finally, consider:
20416
20417@smallexample
20418gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
20419@end smallexample
20420
20421@noindent
20422Here the two output filenames @file{vec.miss} and @file{loop.opt} are
20423in conflict since only one output file is allowed. In this case, only
20424the first option takes effect and the subsequent options are
20425ignored. Thus only @file{vec.miss} is produced which contains
20426dumps from the vectorizer about missed opportunities.
20427
d77de738 20428@opindex fsave-optimization-record
ddf6fe37 20429@item -fsave-optimization-record
d77de738
ML
20430Write a SRCFILE.opt-record.json.gz file detailing what optimizations
20431were performed, for those optimizations that support @option{-fopt-info}.
20432
20433This option is experimental and the format of the data within the
20434compressed JSON file is subject to change.
20435
20436It is roughly equivalent to a machine-readable version of
20437@option{-fopt-info-all}, as a collection of messages with source file,
20438line number and column number, with the following additional data for
20439each message:
20440
20441@itemize @bullet
20442
20443@item
20444the execution count of the code being optimized, along with metadata about
20445whether this was from actual profile data, or just an estimate, allowing
20446consumers to prioritize messages by code hotness,
20447
20448@item
20449the function name of the code being optimized, where applicable,
20450
20451@item
20452the ``inlining chain'' for the code being optimized, so that when
20453a function is inlined into several different places (which might
20454themselves be inlined), the reader can distinguish between the copies,
20455
20456@item
20457objects identifying those parts of the message that refer to expressions,
20458statements or symbol-table nodes, which of these categories they are, and,
20459when available, their source code location,
20460
20461@item
20462the GCC pass that emitted the message, and
20463
20464@item
20465the location in GCC's own code from which the message was emitted
20466
20467@end itemize
20468
20469Additionally, some messages are logically nested within other
20470messages, reflecting implementation details of the optimization
20471passes.
20472
d77de738 20473@opindex fsched-verbose
ddf6fe37 20474@item -fsched-verbose=@var{n}
d77de738
ML
20475On targets that use instruction scheduling, this option controls the
20476amount of debugging output the scheduler prints to the dump files.
20477
20478For @var{n} greater than zero, @option{-fsched-verbose} outputs the
20479same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
20480For @var{n} greater than one, it also output basic block probabilities,
20481detailed ready list information and unit/insn info. For @var{n} greater
20482than two, it includes RTL at abort point, control-flow and regions info.
20483And for @var{n} over four, @option{-fsched-verbose} also includes
20484dependence info.
20485
20486
20487
d77de738
ML
20488@opindex fdisable-
20489@opindex fenable-
ddf6fe37
AA
20490@item -fenable-@var{kind}-@var{pass}
20491@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
d77de738
ML
20492
20493This is a set of options that are used to explicitly disable/enable
20494optimization passes. These options are intended for use for debugging GCC.
20495Compiler users should use regular options for enabling/disabling
20496passes instead.
20497
20498@table @gcctabopt
20499
20500@item -fdisable-ipa-@var{pass}
20501Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
20502statically invoked in the compiler multiple times, the pass name should be
20503appended with a sequential number starting from 1.
20504
20505@item -fdisable-rtl-@var{pass}
20506@itemx -fdisable-rtl-@var{pass}=@var{range-list}
20507Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
20508statically invoked in the compiler multiple times, the pass name should be
20509appended with a sequential number starting from 1. @var{range-list} is a
20510comma-separated list of function ranges or assembler names. Each range is a number
20511pair separated by a colon. The range is inclusive in both ends. If the range
20512is trivial, the number pair can be simplified as a single number. If the
20513function's call graph node's @var{uid} falls within one of the specified ranges,
20514the @var{pass} is disabled for that function. The @var{uid} is shown in the
20515function header of a dump file, and the pass names can be dumped by using
20516option @option{-fdump-passes}.
20517
20518@item -fdisable-tree-@var{pass}
20519@itemx -fdisable-tree-@var{pass}=@var{range-list}
20520Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
20521option arguments.
20522
20523@item -fenable-ipa-@var{pass}
20524Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
20525statically invoked in the compiler multiple times, the pass name should be
20526appended with a sequential number starting from 1.
20527
20528@item -fenable-rtl-@var{pass}
20529@itemx -fenable-rtl-@var{pass}=@var{range-list}
20530Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
20531description and examples.
20532
20533@item -fenable-tree-@var{pass}
20534@itemx -fenable-tree-@var{pass}=@var{range-list}
20535Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
20536of option arguments.
20537
20538@end table
20539
20540Here are some examples showing uses of these options.
20541
20542@smallexample
20543
20544# disable ccp1 for all functions
20545 -fdisable-tree-ccp1
20546# disable complete unroll for function whose cgraph node uid is 1
20547 -fenable-tree-cunroll=1
20548# disable gcse2 for functions at the following ranges [1,1],
20549# [300,400], and [400,1000]
20550# disable gcse2 for functions foo and foo2
20551 -fdisable-rtl-gcse2=foo,foo2
20552# disable early inlining
20553 -fdisable-tree-einline
20554# disable ipa inlining
20555 -fdisable-ipa-inline
20556# enable tree full unroll
20557 -fenable-tree-unroll
20558
20559@end smallexample
20560
d77de738
ML
20561@opindex fchecking
20562@opindex fno-checking
ddf6fe37
AA
20563@item -fchecking
20564@itemx -fchecking=@var{n}
d77de738
ML
20565Enable internal consistency checking. The default depends on
20566the compiler configuration. @option{-fchecking=2} enables further
20567internal consistency checking that might affect code generation.
20568
d77de738 20569@opindex frandom-seed
ddf6fe37 20570@item -frandom-seed=@var{string}
d77de738
ML
20571This option provides a seed that GCC uses in place of
20572random numbers in generating certain symbol names
20573that have to be different in every compiled file. It is also used to
20574place unique stamps in coverage data files and the object files that
20575produce them. You can use the @option{-frandom-seed} option to produce
20576reproducibly identical object files.
20577
20578The @var{string} can either be a number (decimal, octal or hex) or an
20579arbitrary string (in which case it's converted to a number by
20580computing CRC32).
20581
20582The @var{string} should be different for every file you compile.
20583
d77de738 20584@opindex save-temps
ddf6fe37 20585@item -save-temps
d77de738
ML
20586Store the usual ``temporary'' intermediate files permanently; name them
20587as auxiliary output files, as specified described under
20588@option{-dumpbase} and @option{-dumpdir}.
20589
20590When used in combination with the @option{-x} command-line option,
20591@option{-save-temps} is sensible enough to avoid overwriting an
20592input source file with the same extension as an intermediate file.
20593The corresponding intermediate file may be obtained by renaming the
20594source file before using @option{-save-temps}.
20595
d77de738 20596@opindex save-temps=cwd
ddf6fe37 20597@item -save-temps=cwd
d77de738
ML
20598Equivalent to @option{-save-temps -dumpdir ./}.
20599
d77de738 20600@opindex save-temps=obj
ddf6fe37 20601@item -save-temps=obj
d77de738
ML
20602Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
20603@file{outdir/} is the directory of the output file specified after the
20604@option{-o} option, including any directory separators. If the
20605@option{-o} option is not used, the @option{-save-temps=obj} switch
20606behaves like @option{-save-temps=cwd}.
20607
d77de738 20608@opindex time
ddf6fe37 20609@item -time@r{[}=@var{file}@r{]}
d77de738
ML
20610Report the CPU time taken by each subprocess in the compilation
20611sequence. For C source files, this is the compiler proper and assembler
20612(plus the linker if linking is done).
20613
20614Without the specification of an output file, the output looks like this:
20615
20616@smallexample
20617# cc1 0.12 0.01
20618# as 0.00 0.01
20619@end smallexample
20620
20621The first number on each line is the ``user time'', that is time spent
20622executing the program itself. The second number is ``system time'',
20623time spent executing operating system routines on behalf of the program.
20624Both numbers are in seconds.
20625
20626With the specification of an output file, the output is appended to the
20627named file, and it looks like this:
20628
20629@smallexample
206300.12 0.01 cc1 @var{options}
206310.00 0.01 as @var{options}
20632@end smallexample
20633
20634The ``user time'' and the ``system time'' are moved before the program
20635name, and the options passed to the program are displayed, so that one
20636can later tell what file was being compiled, and with which options.
20637
d77de738 20638@opindex fdump-final-insns
ddf6fe37 20639@item -fdump-final-insns@r{[}=@var{file}@r{]}
d77de738
ML
20640Dump the final internal representation (RTL) to @var{file}. If the
20641optional argument is omitted (or if @var{file} is @code{.}), the name
20642of the dump file is determined by appending @code{.gkd} to the
20643dump base name, see @option{-dumpbase}.
20644
d77de738
ML
20645@opindex fcompare-debug
20646@opindex fno-compare-debug
ddf6fe37 20647@item -fcompare-debug@r{[}=@var{opts}@r{]}
d77de738
ML
20648If no error occurs during compilation, run the compiler a second time,
20649adding @var{opts} and @option{-fcompare-debug-second} to the arguments
20650passed to the second compilation. Dump the final internal
20651representation in both compilations, and print an error if they differ.
20652
20653If the equal sign is omitted, the default @option{-gtoggle} is used.
20654
20655The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
20656and nonzero, implicitly enables @option{-fcompare-debug}. If
20657@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
20658then it is used for @var{opts}, otherwise the default @option{-gtoggle}
20659is used.
20660
20661@option{-fcompare-debug=}, with the equal sign but without @var{opts},
20662is equivalent to @option{-fno-compare-debug}, which disables the dumping
20663of the final representation and the second compilation, preventing even
20664@env{GCC_COMPARE_DEBUG} from taking effect.
20665
20666To verify full coverage during @option{-fcompare-debug} testing, set
20667@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
20668which GCC rejects as an invalid option in any actual compilation
20669(rather than preprocessing, assembly or linking). To get just a
20670warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
20671not overridden} will do.
20672
d77de738 20673@opindex fcompare-debug-second
ddf6fe37 20674@item -fcompare-debug-second
d77de738
ML
20675This option is implicitly passed to the compiler for the second
20676compilation requested by @option{-fcompare-debug}, along with options to
20677silence warnings, and omitting other options that would cause the compiler
20678to produce output to files or to standard output as a side effect. Dump
20679files and preserved temporary files are renamed so as to contain the
20680@code{.gk} additional extension during the second compilation, to avoid
20681overwriting those generated by the first.
20682
20683When this option is passed to the compiler driver, it causes the
20684@emph{first} compilation to be skipped, which makes it useful for little
20685other than debugging the compiler proper.
20686
d77de738 20687@opindex gtoggle
ddf6fe37 20688@item -gtoggle
d77de738
ML
20689Turn off generation of debug info, if leaving out this option
20690generates it, or turn it on at level 2 otherwise. The position of this
20691argument in the command line does not matter; it takes effect after all
20692other options are processed, and it does so only once, no matter how
20693many times it is given. This is mainly intended to be used with
20694@option{-fcompare-debug}.
20695
d77de738
ML
20696@opindex fvar-tracking-assignments-toggle
20697@opindex fno-var-tracking-assignments-toggle
ddf6fe37 20698@item -fvar-tracking-assignments-toggle
d77de738
ML
20699Toggle @option{-fvar-tracking-assignments}, in the same way that
20700@option{-gtoggle} toggles @option{-g}.
20701
d77de738 20702@opindex Q
ddf6fe37 20703@item -Q
d77de738
ML
20704Makes the compiler print out each function name as it is compiled, and
20705print some statistics about each pass when it finishes.
20706
d77de738 20707@opindex ftime-report
ddf6fe37 20708@item -ftime-report
75d62394
DM
20709Makes the compiler print some statistics to stderr about the time consumed
20710by each pass when it finishes.
20711
20712If SARIF output of diagnostics was requested via
20713@option{-fdiagnostics-format=sarif-file} or
20714@option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report}
20715information is instead emitted in JSON form as part of SARIF output. The
20716precise format of this JSON data is subject to change, and the values may
20717not exactly match those emitted to stderr due to being written out at a
20718slightly different place within the compiler.
d77de738 20719
d77de738 20720@opindex ftime-report-details
ddf6fe37 20721@item -ftime-report-details
d77de738
ML
20722Record the time consumed by infrastructure parts separately for each pass.
20723
d77de738 20724@opindex fira-verbose
ddf6fe37 20725@item -fira-verbose=@var{n}
d77de738
ML
20726Control the verbosity of the dump file for the integrated register allocator.
20727The default value is 5. If the value @var{n} is greater or equal to 10,
20728the dump output is sent to stderr using the same format as @var{n} minus 10.
20729
d77de738 20730@opindex flto-report
ddf6fe37 20731@item -flto-report
d77de738
ML
20732Prints a report with internal details on the workings of the link-time
20733optimizer. The contents of this report vary from version to version.
20734It is meant to be useful to GCC developers when processing object
20735files in LTO mode (via @option{-flto}).
20736
20737Disabled by default.
20738
d77de738 20739@opindex flto-report-wpa
ddf6fe37 20740@item -flto-report-wpa
d77de738
ML
20741Like @option{-flto-report}, but only print for the WPA phase of link-time
20742optimization.
20743
d77de738 20744@opindex fmem-report
ddf6fe37 20745@item -fmem-report
d77de738
ML
20746Makes the compiler print some statistics about permanent memory
20747allocation when it finishes.
20748
d77de738 20749@opindex fmem-report-wpa
ddf6fe37 20750@item -fmem-report-wpa
d77de738
ML
20751Makes the compiler print some statistics about permanent memory
20752allocation for the WPA phase only.
20753
d77de738 20754@opindex fpre-ipa-mem-report
d77de738 20755@opindex fpost-ipa-mem-report
ddf6fe37
AA
20756@item -fpre-ipa-mem-report
20757@item -fpost-ipa-mem-report
d77de738
ML
20758Makes the compiler print some statistics about permanent memory
20759allocation before or after interprocedural optimization.
20760
d77de738 20761@opindex fmultiflags
ddf6fe37 20762@item -fmultiflags
d77de738
ML
20763This option enables multilib-aware @code{TFLAGS} to be used to build
20764target libraries with options different from those the compiler is
8e0568d8
AO
20765configured to use by default, through the use of specs (@pxref{Spec
20766Files}) set up by compiler internals, by the target, or by builders at
d77de738
ML
20767configure time.
20768
20769Like @code{TFLAGS}, this allows the target libraries to be built for
20770portable baseline environments, while the compiler defaults to more
20771demanding ones. That's useful because users can easily override the
20772defaults the compiler is configured to use to build their own programs,
20773if the defaults are not ideal for their target environment, whereas
20774rebuilding the runtime libraries is usually not as easy or desirable.
20775
20776Unlike @code{TFLAGS}, the use of specs enables different flags to be
20777selected for different multilibs. The way to accomplish that is to
20778build with @samp{make TFLAGS=-fmultiflags}, after configuring
20779@samp{--with-specs=%@{fmultiflags:...@}}.
20780
20781This option is discarded by the driver once it's done processing driver
20782self spec.
20783
20784It is also useful to check that @code{TFLAGS} are being used to build
20785all target libraries, by configuring a non-bootstrap compiler
20786@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
20787the compiler and target libraries.
20788
d77de738 20789@opindex fprofile-report
ddf6fe37 20790@item -fprofile-report
d77de738
ML
20791Makes the compiler print some statistics about consistency of the
20792(estimated) profile and effect of individual passes.
20793
d77de738 20794@opindex fstack-usage
ddf6fe37 20795@item -fstack-usage
d77de738
ML
20796Makes the compiler output stack usage information for the program, on a
20797per-function basis. The filename for the dump is made by appending
20798@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
20799the output file, if explicitly specified and it is not an executable,
20800otherwise it is the basename of the source file. An entry is made up
20801of three fields:
20802
20803@itemize
20804@item
20805The name of the function.
20806@item
20807A number of bytes.
20808@item
20809One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
20810@end itemize
20811
20812The qualifier @code{static} means that the function manipulates the stack
20813statically: a fixed number of bytes are allocated for the frame on function
20814entry and released on function exit; no stack adjustments are otherwise made
20815in the function. The second field is this fixed number of bytes.
20816
20817The qualifier @code{dynamic} means that the function manipulates the stack
20818dynamically: in addition to the static allocation described above, stack
20819adjustments are made in the body of the function, for example to push/pop
20820arguments around function calls. If the qualifier @code{bounded} is also
20821present, the amount of these adjustments is bounded at compile time and
20822the second field is an upper bound of the total amount of stack used by
20823the function. If it is not present, the amount of these adjustments is
20824not bounded at compile time and the second field only represents the
20825bounded part.
20826
d77de738 20827@opindex fstats
ddf6fe37 20828@item -fstats
d77de738
ML
20829Emit statistics about front-end processing at the end of the compilation.
20830This option is supported only by the C++ front end, and
20831the information is generally only useful to the G++ development team.
20832
d77de738 20833@opindex fdbg-cnt-list
ddf6fe37 20834@item -fdbg-cnt-list
d77de738
ML
20835Print the name and the counter upper bound for all debug counters.
20836
20837
d77de738 20838@opindex fdbg-cnt
ddf6fe37 20839@item -fdbg-cnt=@var{counter-value-list}
d77de738
ML
20840Set the internal debug counter lower and upper bound. @var{counter-value-list}
20841is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
20842[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
20843the name of the counter and list of closed intervals.
20844The @var{lower_bound} is optional and is zero
20845initialized if not set.
20846For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
20847@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
20848eleventh invocation.
20849For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
20850
d77de738 20851@opindex print-file-name
ddf6fe37 20852@item -print-file-name=@var{library}
d77de738
ML
20853Print the full absolute name of the library file @var{library} that
20854would be used when linking---and don't do anything else. With this
20855option, GCC does not compile or link anything; it just prints the
20856file name.
20857
d77de738 20858@opindex print-multi-directory
ddf6fe37 20859@item -print-multi-directory
d77de738
ML
20860Print the directory name corresponding to the multilib selected by any
20861other switches present in the command line. This directory is supposed
20862to exist in @env{GCC_EXEC_PREFIX}.
20863
d77de738 20864@opindex print-multi-lib
ddf6fe37 20865@item -print-multi-lib
d77de738
ML
20866Print the mapping from multilib directory names to compiler switches
20867that enable them. The directory name is separated from the switches by
20868@samp{;}, and each switch starts with an @samp{@@} instead of the
20869@samp{-}, without spaces between multiple switches. This is supposed to
20870ease shell processing.
20871
d77de738 20872@opindex print-multi-os-directory
ddf6fe37 20873@item -print-multi-os-directory
d77de738
ML
20874Print the path to OS libraries for the selected
20875multilib, relative to some @file{lib} subdirectory. If OS libraries are
20876present in the @file{lib} subdirectory and no multilibs are used, this is
20877usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
20878sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
20879@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
20880subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
20881
d77de738 20882@opindex print-multiarch
ddf6fe37 20883@item -print-multiarch
d77de738
ML
20884Print the path to OS libraries for the selected multiarch,
20885relative to some @file{lib} subdirectory.
20886
d77de738 20887@opindex print-prog-name
ddf6fe37 20888@item -print-prog-name=@var{program}
d77de738
ML
20889Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
20890
d77de738 20891@opindex print-libgcc-file-name
ddf6fe37 20892@item -print-libgcc-file-name
d77de738
ML
20893Same as @option{-print-file-name=libgcc.a}.
20894
20895This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
20896but you do want to link with @file{libgcc.a}. You can do:
20897
20898@smallexample
20899gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
20900@end smallexample
20901
d77de738 20902@opindex print-search-dirs
ddf6fe37 20903@item -print-search-dirs
d77de738
ML
20904Print the name of the configured installation directory and a list of
20905program and library directories @command{gcc} searches---and don't do anything else.
20906
20907This is useful when @command{gcc} prints the error message
20908@samp{installation problem, cannot exec cpp0: No such file or directory}.
20909To resolve this you either need to put @file{cpp0} and the other compiler
20910components where @command{gcc} expects to find them, or you can set the environment
20911variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
20912Don't forget the trailing @samp{/}.
20913@xref{Environment Variables}.
20914
d77de738 20915@opindex print-sysroot
ddf6fe37 20916@item -print-sysroot
d77de738
ML
20917Print the target sysroot directory that is used during
20918compilation. This is the target sysroot specified either at configure
20919time or using the @option{--sysroot} option, possibly with an extra
20920suffix that depends on compilation options. If no target sysroot is
20921specified, the option prints nothing.
20922
d77de738 20923@opindex print-sysroot-headers-suffix
ddf6fe37 20924@item -print-sysroot-headers-suffix
d77de738
ML
20925Print the suffix added to the target sysroot when searching for
20926headers, or give an error if the compiler is not configured with such
20927a suffix---and don't do anything else.
20928
d77de738 20929@opindex dumpmachine
ddf6fe37 20930@item -dumpmachine
d77de738
ML
20931Print the compiler's target machine (for example,
20932@samp{i686-pc-linux-gnu})---and don't do anything else.
20933
d77de738 20934@opindex dumpversion
ddf6fe37 20935@item -dumpversion
d77de738
ML
20936Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
20937anything else. This is the compiler version used in filesystem paths and
20938specs. Depending on how the compiler has been configured it can be just
20939a single number (major version), two numbers separated by a dot (major and
20940minor version) or three numbers separated by dots (major, minor and patchlevel
20941version).
20942
d77de738 20943@opindex dumpfullversion
ddf6fe37 20944@item -dumpfullversion
d77de738
ML
20945Print the full compiler version---and don't do anything else. The output is
20946always three numbers separated by dots, major, minor and patchlevel version.
20947
d77de738 20948@opindex dumpspecs
ddf6fe37 20949@item -dumpspecs
d77de738
ML
20950Print the compiler's built-in specs---and don't do anything else. (This
20951is used when GCC itself is being built.) @xref{Spec Files}.
20952@end table
20953
20954@node Submodel Options
20955@section Machine-Dependent Options
20956@cindex submodel options
20957@cindex specifying hardware config
20958@cindex hardware models and configurations, specifying
20959@cindex target-dependent options
20960@cindex machine-dependent options
20961
20962Each target machine supported by GCC can have its own options---for
20963example, to allow you to compile for a particular processor variant or
20964ABI, or to control optimizations specific to that machine. By
20965convention, the names of machine-specific options start with
20966@samp{-m}.
20967
20968Some configurations of the compiler also support additional target-specific
20969options, usually for compatibility with other compilers on the same
20970platform.
20971
20972@c This list is ordered alphanumerically by subsection name.
20973@c It should be the same order and spelling as these options are listed
20974@c in Machine Dependent Options
20975
20976@menu
20977* AArch64 Options::
20978* Adapteva Epiphany Options::
20979* AMD GCN Options::
20980* ARC Options::
20981* ARM Options::
20982* AVR Options::
20983* Blackfin Options::
20984* C6X Options::
20985* CRIS Options::
20986* C-SKY Options::
20987* Darwin Options::
20988* DEC Alpha Options::
20989* eBPF Options::
20990* FR30 Options::
20991* FT32 Options::
20992* FRV Options::
20993* GNU/Linux Options::
20994* H8/300 Options::
20995* HPPA Options::
20996* IA-64 Options::
20997* LM32 Options::
20998* LoongArch Options::
20999* M32C Options::
21000* M32R/D Options::
21001* M680x0 Options::
21002* MCore Options::
d77de738
ML
21003* MicroBlaze Options::
21004* MIPS Options::
21005* MMIX Options::
21006* MN10300 Options::
21007* Moxie Options::
21008* MSP430 Options::
21009* NDS32 Options::
21010* Nios II Options::
21011* Nvidia PTX Options::
21012* OpenRISC Options::
21013* PDP-11 Options::
d77de738
ML
21014* PowerPC Options::
21015* PRU Options::
21016* RISC-V Options::
21017* RL78 Options::
21018* RS/6000 and PowerPC Options::
21019* RX Options::
21020* S/390 and zSeries Options::
d77de738
ML
21021* SH Options::
21022* Solaris 2 Options::
21023* SPARC Options::
21024* System V Options::
21025* V850 Options::
21026* VAX Options::
21027* Visium Options::
21028* VMS Options::
21029* VxWorks Options::
21030* x86 Options::
21031* x86 Windows Options::
21032* Xstormy16 Options::
21033* Xtensa Options::
21034* zSeries Options::
21035@end menu
21036
21037@node AArch64 Options
21038@subsection AArch64 Options
21039@cindex AArch64 Options
21040
21041These options are defined for AArch64 implementations:
21042
21043@table @gcctabopt
21044
d77de738 21045@opindex mabi
ddf6fe37 21046@item -mabi=@var{name}
d77de738
ML
21047Generate code for the specified data model. Permissible values
21048are @samp{ilp32} for SysV-like data model where int, long int and pointers
21049are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
21050but long int and pointers are 64 bits.
21051
21052The default depends on the specific target configuration. Note that
21053the LP64 and ILP32 ABIs are not link-compatible; you must compile your
21054entire program with the same ABI, and link with a compatible set of libraries.
21055
d77de738 21056@opindex mbig-endian
ddf6fe37 21057@item -mbig-endian
d77de738
ML
21058Generate big-endian code. This is the default when GCC is configured for an
21059@samp{aarch64_be-*-*} target.
21060
d77de738 21061@opindex mgeneral-regs-only
ddf6fe37 21062@item -mgeneral-regs-only
d77de738
ML
21063Generate code which uses only the general-purpose registers. This will prevent
21064the compiler from using floating-point and Advanced SIMD registers but will not
21065impose any restrictions on the assembler.
21066
d77de738 21067@opindex mlittle-endian
ddf6fe37 21068@item -mlittle-endian
d77de738
ML
21069Generate little-endian code. This is the default when GCC is configured for an
21070@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
21071
d77de738 21072@opindex mcmodel=tiny
ddf6fe37 21073@item -mcmodel=tiny
d77de738
ML
21074Generate code for the tiny code model. The program and its statically defined
21075symbols must be within 1MB of each other. Programs can be statically or
21076dynamically linked.
21077
d77de738 21078@opindex mcmodel=small
ddf6fe37 21079@item -mcmodel=small
d77de738
ML
21080Generate code for the small code model. The program and its statically defined
21081symbols must be within 4GB of each other. Programs can be statically or
21082dynamically linked. This is the default code model.
21083
d77de738 21084@opindex mcmodel=large
ddf6fe37 21085@item -mcmodel=large
d77de738
ML
21086Generate code for the large code model. This makes no assumptions about
21087addresses and sizes of sections. Programs can be statically linked only. The
21088@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
21089@option{-fpic} and @option{-fPIC}.
21090
573624ec
KT
21091@item -mtp=@var{name}
21092@opindex mtp
21093Specify the system register to use as a thread pointer. The valid values
4389a2d2
KT
21094are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2},
21095@samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0},
21096@samp{el1}, @samp{el2}, @samp{el3} are also accepted.
21097The default setting is @samp{tpidr_el0}. It is recommended to compile all
21098code intended to interoperate with the same value of this option to avoid
21099accessing a different thread pointer from the wrong exception level.
573624ec 21100
d77de738
ML
21101@opindex mstrict-align
21102@opindex mno-strict-align
ddf6fe37
AA
21103@item -mstrict-align
21104@itemx -mno-strict-align
d77de738
ML
21105Avoid or allow generating memory accesses that may not be aligned on a natural
21106object boundary as described in the architecture specification.
21107
d77de738
ML
21108@opindex momit-leaf-frame-pointer
21109@opindex mno-omit-leaf-frame-pointer
ddf6fe37
AA
21110@item -momit-leaf-frame-pointer
21111@itemx -mno-omit-leaf-frame-pointer
d77de738
ML
21112Omit or keep the frame pointer in leaf functions. The former behavior is the
21113default.
21114
d77de738
ML
21115@opindex mstack-protector-guard
21116@opindex mstack-protector-guard-reg
21117@opindex mstack-protector-guard-offset
ddf6fe37
AA
21118@item -mstack-protector-guard=@var{guard}
21119@itemx -mstack-protector-guard-reg=@var{reg}
21120@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
21121Generate stack protection code using canary at @var{guard}. Supported
21122locations are @samp{global} for a global canary or @samp{sysreg} for a
21123canary in an appropriate system register.
21124
21125With the latter choice the options
21126@option{-mstack-protector-guard-reg=@var{reg}} and
21127@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
21128which system register to use as base register for reading the canary,
21129and from what offset from that base register. There is no default
21130register or offset as this is entirely for use within the Linux
21131kernel.
21132
d77de738 21133@opindex mtls-dialect=desc
ddf6fe37 21134@item -mtls-dialect=desc
d77de738
ML
21135Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
21136of TLS variables. This is the default.
21137
d77de738 21138@opindex mtls-dialect=traditional
ddf6fe37 21139@item -mtls-dialect=traditional
d77de738
ML
21140Use traditional TLS as the thread-local storage mechanism for dynamic accesses
21141of TLS variables.
21142
d77de738 21143@opindex mtls-size
ddf6fe37 21144@item -mtls-size=@var{size}
d77de738
ML
21145Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
21146This option requires binutils 2.26 or newer.
21147
d77de738
ML
21148@opindex mfix-cortex-a53-835769
21149@opindex mno-fix-cortex-a53-835769
ddf6fe37
AA
21150@item -mfix-cortex-a53-835769
21151@itemx -mno-fix-cortex-a53-835769
d77de738
ML
21152Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
21153This involves inserting a NOP instruction between memory instructions and
2115464-bit integer multiply-accumulate instructions.
21155
d77de738
ML
21156@opindex mfix-cortex-a53-843419
21157@opindex mno-fix-cortex-a53-843419
ddf6fe37
AA
21158@item -mfix-cortex-a53-843419
21159@itemx -mno-fix-cortex-a53-843419
d77de738
ML
21160Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
21161This erratum workaround is made at link time and this will only pass the
21162corresponding flag to the linker.
21163
d77de738
ML
21164@opindex mlow-precision-recip-sqrt
21165@opindex mno-low-precision-recip-sqrt
ddf6fe37
AA
21166@item -mlow-precision-recip-sqrt
21167@itemx -mno-low-precision-recip-sqrt
d77de738
ML
21168Enable or disable the reciprocal square root approximation.
21169This option only has an effect if @option{-ffast-math} or
21170@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
21171precision of reciprocal square root results to about 16 bits for
21172single precision and to 32 bits for double precision.
21173
d77de738
ML
21174@opindex mlow-precision-sqrt
21175@opindex mno-low-precision-sqrt
ddf6fe37
AA
21176@item -mlow-precision-sqrt
21177@itemx -mno-low-precision-sqrt
d77de738
ML
21178Enable or disable the square root approximation.
21179This option only has an effect if @option{-ffast-math} or
21180@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
21181precision of square root results to about 16 bits for
21182single precision and to 32 bits for double precision.
21183If enabled, it implies @option{-mlow-precision-recip-sqrt}.
21184
d77de738
ML
21185@opindex mlow-precision-div
21186@opindex mno-low-precision-div
ddf6fe37
AA
21187@item -mlow-precision-div
21188@itemx -mno-low-precision-div
d77de738
ML
21189Enable or disable the division approximation.
21190This option only has an effect if @option{-ffast-math} or
21191@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
21192precision of division results to about 16 bits for
21193single precision and to 32 bits for double precision.
21194
21195@item -mtrack-speculation
21196@itemx -mno-track-speculation
21197Enable or disable generation of additional code to track speculative
21198execution through conditional branches. The tracking state can then
21199be used by the compiler when expanding calls to
21200@code{__builtin_speculation_safe_copy} to permit a more efficient code
21201sequence to be generated.
21202
21203@item -moutline-atomics
21204@itemx -mno-outline-atomics
21205Enable or disable calls to out-of-line helpers to implement atomic operations.
21206These helpers will, at runtime, determine if the LSE instructions from
21207ARMv8.1-A can be used; if not, they will use the load/store-exclusive
21208instructions that are present in the base ARMv8.0 ISA.
21209
21210This option is only applicable when compiling for the base ARMv8.0
21211instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
21212or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
21213used directly. The same applies when using @option{-mcpu=} when the
21214selected cpu supports the @samp{lse} feature.
21215This option is on by default.
21216
d77de738 21217@opindex march
ddf6fe37 21218@item -march=@var{name}
d77de738
ML
21219Specify the name of the target architecture and, optionally, one or
21220more feature modifiers. This option has the form
21221@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
21222
21223The table below summarizes the permissible values for @var{arch}
21224and the features that they enable by default:
21225
21226@multitable @columnfractions 0.20 0.20 0.60
21227@headitem @var{arch} value @tab Architecture @tab Includes by default
21228@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
21229@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
21230@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
21231@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
21232@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
21233@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
21234@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
21235@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
21236@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
16a05fac 21237@item @samp{armv8.9-a} @tab Armv8.9-a @tab @samp{armv8.8-a}
d77de738
ML
21238@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
21239@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
21240@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
21241@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
16a05fac 21242@item @samp{armv9.4-a} @tab Armv9.4-A @tab @samp{armv9.3-a}
d77de738
ML
21243@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
21244@end multitable
21245
21246The value @samp{native} is available on native AArch64 GNU/Linux and
21247causes the compiler to pick the architecture of the host system. This
21248option has no effect if the compiler is unable to recognize the
21249architecture of the host system,
21250
21251The permissible values for @var{feature} are listed in the sub-section
21252on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
21253Feature Modifiers}. Where conflicting feature modifiers are
21254specified, the right-most feature is used.
21255
21256GCC uses @var{name} to determine what kind of instructions it can emit
21257when generating assembly code. If @option{-march} is specified
21258without either of @option{-mtune} or @option{-mcpu} also being
21259specified, the code is tuned to perform well across a range of target
21260processors implementing the target architecture.
21261
d77de738 21262@opindex mtune
ddf6fe37 21263@item -mtune=@var{name}
d77de738
ML
21264Specify the name of the target processor for which GCC should tune the
21265performance of the code. Permissible values for this option are:
21266@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
21267@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
21268@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
21269@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
21270@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
21271@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
21272@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
21273@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
21274@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
21275@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
21276@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
21277@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
21278@samp{octeontx2f95mm},
21279@samp{a64fx},
21280@samp{thunderx}, @samp{thunderxt88},
21281@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
21282@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
21283@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
21284@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
21285@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 21286@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
3bfde22c
SJ
21287@samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510}, @samp{cortex-a520},
21288@samp{cortex-a710}, @samp{cortex-a715}, @samp{cortex-a720}, @samp{ampere1},
a0d16e1c 21289@samp{ampere1a}, @samp{ampere1b}, @samp{cobalt-100} and @samp{native}.
d77de738
ML
21290
21291The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
21292@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
21293@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
21294should tune for a big.LITTLE system.
21295
21296The value @samp{neoverse-512tvb} specifies that GCC should tune
21297for Neoverse cores that (a) implement SVE and (b) have a total vector
21298bandwidth of 512 bits per cycle. In other words, the option tells GCC to
21299tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
21300instructions a cycle and that can execute an equivalent number of SVE
21301arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
21302This is more general than tuning for a specific core like Neoverse V1
21303but is more specific than the default tuning described below.
21304
21305Additionally on native AArch64 GNU/Linux systems the value
21306@samp{native} tunes performance to the host system. This option has no effect
21307if the compiler is unable to recognize the processor of the host system.
21308
21309Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
21310are specified, the code is tuned to perform well across a range
21311of target processors.
21312
21313This option cannot be suffixed by feature modifiers.
21314
d77de738 21315@opindex mcpu
ddf6fe37 21316@item -mcpu=@var{name}
d77de738
ML
21317Specify the name of the target processor, optionally suffixed by one
21318or more feature modifiers. This option has the form
21319@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
21320the permissible values for @var{cpu} are the same as those available
21321for @option{-mtune}. The permissible values for @var{feature} are
21322documented in the sub-section on
21323@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
21324Feature Modifiers}. Where conflicting feature modifiers are
21325specified, the right-most feature is used.
21326
21327GCC uses @var{name} to determine what kind of instructions it can emit when
21328generating assembly code (as if by @option{-march}) and to determine
21329the target processor for which to tune for performance (as if
21330by @option{-mtune}). Where this option is used in conjunction
21331with @option{-march} or @option{-mtune}, those options take precedence
21332over the appropriate part of this option.
21333
21334@option{-mcpu=neoverse-512tvb} is special in that it does not refer
21335to a specific core, but instead refers to all Neoverse cores that
21336(a) implement SVE and (b) have a total vector bandwidth of 512 bits
21337a cycle. Unless overridden by @option{-march},
21338@option{-mcpu=neoverse-512tvb} generates code that can run on a
21339Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
21340these properties. Unless overridden by @option{-mtune},
21341@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
21342@option{-mtune=neoverse-512tvb}.
21343
d77de738 21344@opindex moverride
ddf6fe37 21345@item -moverride=@var{string}
d77de738
ML
21346Override tuning decisions made by the back-end in response to a
21347@option{-mtune=} switch. The syntax, semantics, and accepted values
21348for @var{string} in this option are not guaranteed to be consistent
21349across releases.
21350
21351This option is only intended to be useful when developing GCC.
21352
d77de738 21353@opindex mverbose-cost-dump
ddf6fe37 21354@item -mverbose-cost-dump
d77de738
ML
21355Enable verbose cost model dumping in the debug dump files. This option is
21356provided for use in debugging the compiler.
21357
d77de738
ML
21358@opindex mpc-relative-literal-loads
21359@opindex mno-pc-relative-literal-loads
ddf6fe37
AA
21360@item -mpc-relative-literal-loads
21361@itemx -mno-pc-relative-literal-loads
d77de738
ML
21362Enable or disable PC-relative literal loads. With this option literal pools are
21363accessed using a single instruction and emitted after each function. This
21364limits the maximum size of functions to 1MB. This is enabled by default for
21365@option{-mcmodel=tiny}.
21366
d77de738 21367@opindex msign-return-address
ddf6fe37 21368@item -msign-return-address=@var{scope}
d77de738
ML
21369Select the function scope on which return address signing will be applied.
21370Permissible values are @samp{none}, which disables return address signing,
21371@samp{non-leaf}, which enables pointer signing for functions which are not leaf
21372functions, and @samp{all}, which enables pointer signing for all functions. The
21373default value is @samp{none}. This option has been deprecated by
21374-mbranch-protection.
21375
d77de738 21376@opindex mbranch-protection
ddf6fe37 21377@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
d77de738
ML
21378Select the branch protection features to use.
21379@samp{none} is the default and turns off all types of branch protection.
21380@samp{standard} turns on all types of branch protection features. If a feature
21381has additional tuning options, then @samp{standard} sets it to its standard
21382level.
21383@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
21384level: signing functions that save the return address to memory (non-leaf
21385functions will practically always do this) using the a-key. The optional
21386argument @samp{leaf} can be used to extend the signing to include leaf
21387functions. The optional argument @samp{b-key} can be used to sign the functions
21388with the B-key instead of the A-key.
21389@samp{bti} turns on branch target identification mechanism.
21390
d77de738 21391@opindex mharden-sls
ddf6fe37 21392@item -mharden-sls=@var{opts}
d77de738
ML
21393Enable compiler hardening against straight line speculation (SLS).
21394@var{opts} is a comma-separated list of the following options:
21395@table @samp
21396@item retbr
21397@item blr
21398@end table
21399In addition, @samp{-mharden-sls=all} enables all SLS hardening while
21400@samp{-mharden-sls=none} disables all SLS hardening.
21401
9f0f7d80
RS
21402@opindex mearly-ra
21403@item -mearly-ra=@var{scope}
21404Determine when to enable an early register allocation pass. This pass runs
21405before instruction scheduling and tries to find a spill-free allocation of
21406floating-point and vector code. It also tries to make use of strided
21407multi-register instructions, such as SME2's strided LD1 and ST1.
21408
21409The possible values of @var{scope} are: @var{all}, which runs the pass on
21410all functions; @var{strided}, which runs the pass on functions that have
21411access to strided multi-register instructions; and @var{none}, which
21412disables the pass.
21413
21414@option{-mearly-ra=all} is the default for @option{-O2} and above, and for
21415@option{-Os}. @option{-mearly-ra=none} is the default otherwise.
21416
c0911c6b
AC
21417@opindex mearly-ldp-fusion
21418@item -mearly-ldp-fusion
21419Enable the copy of the AArch64 load/store pair fusion pass that runs before
21420register allocation. Enabled by default at @samp{-O} and above.
21421
21422@opindex mlate-ldp-fusion
21423@item -mlate-ldp-fusion
21424Enable the copy of the AArch64 load/store pair fusion pass that runs after
21425register allocation. Enabled by default at @samp{-O} and above.
21426
d77de738 21427@opindex msve-vector-bits
ddf6fe37 21428@item -msve-vector-bits=@var{bits}
d77de738
ML
21429Specify the number of bits in an SVE vector register. This option only has
21430an effect when SVE is enabled.
21431
21432GCC supports two forms of SVE code generation: ``vector-length
21433agnostic'' output that works with any size of vector register and
21434``vector-length specific'' output that allows GCC to make assumptions
21435about the vector length when it is useful for optimization reasons.
21436The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
21437@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
21438Specifying @samp{scalable} selects vector-length agnostic
21439output. At present @samp{-msve-vector-bits=128} also generates vector-length
21440agnostic output for big-endian targets. All other values generate
21441vector-length specific code. The behavior of these values may change
21442in future releases and no value except @samp{scalable} should be
21443relied on for producing code that is portable across different
21444hardware SVE vector lengths.
21445
21446The default is @samp{-msve-vector-bits=scalable}, which produces
21447vector-length agnostic code.
21448@end table
21449
21450@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
21451@anchor{aarch64-feature-modifiers}
21452@cindex @option{-march} feature modifiers
21453@cindex @option{-mcpu} feature modifiers
21454Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
21455the following and their inverses @option{no@var{feature}}:
21456
21457@table @samp
21458@item crc
21459Enable CRC extension. This is on by default for
21460@option{-march=armv8.1-a}.
21461@item crypto
21462Enable Crypto extension. This also enables Advanced SIMD and floating-point
21463instructions.
21464@item fp
21465Enable floating-point instructions. This is on by default for all possible
21466values for options @option{-march} and @option{-mcpu}.
21467@item simd
21468Enable Advanced SIMD instructions. This also enables floating-point
21469instructions. This is on by default for all possible values for options
21470@option{-march} and @option{-mcpu}.
21471@item sve
21472Enable Scalable Vector Extension instructions. This also enables Advanced
21473SIMD and floating-point instructions.
21474@item lse
21475Enable Large System Extension instructions. This is on by default for
21476@option{-march=armv8.1-a}.
21477@item rdma
21478Enable Round Double Multiply Accumulate instructions. This is on by default
21479for @option{-march=armv8.1-a}.
21480@item fp16
21481Enable FP16 extension. This also enables floating-point instructions.
21482@item fp16fml
21483Enable FP16 fmla extension. This also enables FP16 extensions and
21484floating-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.
21485
21486@item rcpc
0431e8ae
AV
21487Enable the RCpc extension. This enables the use of the LDAPR instructions for
21488load-acquire atomic semantics, and passes it on to the assembler, enabling
21489inline asm statements to use instructions from the RCpc extension.
d77de738
ML
21490@item dotprod
21491Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21492@item aes
21493Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
21494SIMD instructions.
21495@item sha2
21496Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
21497@item sha3
21498Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
21499instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
21500@item sm4
21501Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
21502Use of this option with architectures prior to Armv8.2-A is not supported.
21503@item profile
21504Enable the Statistical Profiling extension. This option is only to enable the
21505extension at the assembler level and does not affect code generation.
21506@item rng
21507Enable the Armv8.5-a Random Number instructions. This option is only to
21508enable the extension at the assembler level and does not affect code
21509generation.
21510@item memtag
21511Enable the Armv8.5-a Memory Tagging Extensions.
21512Use of this option with architectures prior to Armv8.5-A is not supported.
21513@item sb
21514Enable the Armv8-a Speculation Barrier instruction. This option is only to
21515enable the extension at the assembler level and does not affect code
21516generation. This option is enabled by default for @option{-march=armv8.5-a}.
21517@item ssbs
21518Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
21519is only to enable the extension at the assembler level and does not affect code
21520generation. This option is enabled by default for @option{-march=armv8.5-a}.
21521@item predres
21522Enable the Armv8-a Execution and Data Prediction Restriction instructions.
21523This option is only to enable the extension at the assembler level and does
21524not affect code generation. This option is enabled by default for
21525@option{-march=armv8.5-a}.
21526@item sve2
21527Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
21528instructions.
21529@item sve2-bitperm
21530Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
21531@item sve2-sm4
21532Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
21533@item sve2-aes
21534Enable SVE2 aes instructions. This also enables SVE2 instructions.
21535@item sve2-sha3
21536Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
21537@item tme
21538Enable the Transactional Memory Extension.
21539@item i8mm
21540Enable 8-bit Integer Matrix Multiply instructions. This also enables
21541Advanced SIMD and floating-point instructions. This option is enabled by
21542default for @option{-march=armv8.6-a}. Use of this option with architectures
21543prior to Armv8.2-A is not supported.
21544@item f32mm
21545Enable 32-bit Floating point Matrix Multiply instructions. This also enables
21546SVE instructions. Use of this option with architectures prior to Armv8.2-A is
21547not supported.
21548@item f64mm
21549Enable 64-bit Floating point Matrix Multiply instructions. This also enables
21550SVE instructions. Use of this option with architectures prior to Armv8.2-A is
21551not supported.
21552@item bf16
21553Enable brain half-precision floating-point instructions. This also enables
21554Advanced SIMD and floating-point instructions. This option is enabled by
21555default for @option{-march=armv8.6-a}. Use of this option with architectures
21556prior to Armv8.2-A is not supported.
21557@item ls64
21558Enable the 64-byte atomic load and store instructions for accelerators.
21559This option is enabled by default for @option{-march=armv8.7-a}.
21560@item mops
21561Enable the instructions to accelerate memory operations like @code{memcpy},
21562@code{memmove}, @code{memset}. This option is enabled by default for
21563@option{-march=armv8.8-a}
21564@item flagm
21565Enable the Flag Manipulation instructions Extension.
21566@item pauth
21567Enable the Pointer Authentication Extension.
d758d190
KT
21568@item cssc
21569Enable the Common Short Sequence Compression instructions.
7e04bd1f
RS
21570@item sme
21571Enable the Scalable Matrix Extension.
4f6ab953
RS
21572@item sme-i16i64
21573Enable the FEAT_SME_I16I64 extension to SME.
21574@item sme-f64f64
21575Enable the FEAT_SME_F64F64 extension to SME.
3b58b220
RS
21576+@item sme2
21577Enable the Scalable Matrix Extension 2. This also enables SME instructions.
16a05fac
VDN
21578@item d128
21579Enable support for 128-bit system register read/write instructions.
3aba0458
VDN
21580@item gcs
21581Enable support for Armv9.4-a Guarded Control Stack extension.
16a05fac
VDN
21582@item the
21583Enable support for Armv8.9-a/9.4-a translation hardening extension.
df193bda
VDN
21584@item rcpc3
21585Enable the RCpc3 (Release Consistency) extension.
16a05fac 21586
d77de738
ML
21587@end table
21588
21589Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
21590which implies @option{fp}.
21591Conversely, @option{nofp} implies @option{nosimd}, which implies
21592@option{nocrypto}, @option{noaes} and @option{nosha2}.
21593
21594@node Adapteva Epiphany Options
21595@subsection Adapteva Epiphany Options
21596
21597These @samp{-m} options are defined for Adapteva Epiphany:
21598
21599@table @gcctabopt
d77de738 21600@opindex mhalf-reg-file
ddf6fe37 21601@item -mhalf-reg-file
d77de738
ML
21602Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
21603That allows code to run on hardware variants that lack these registers.
21604
d77de738 21605@opindex mprefer-short-insn-regs
ddf6fe37 21606@item -mprefer-short-insn-regs
d77de738
ML
21607Preferentially allocate registers that allow short instruction generation.
21608This can result in increased instruction count, so this may either reduce or
21609increase overall code size.
21610
d77de738 21611@opindex mbranch-cost
ddf6fe37 21612@item -mbranch-cost=@var{num}
d77de738
ML
21613Set the cost of branches to roughly @var{num} ``simple'' instructions.
21614This cost is only a heuristic and is not guaranteed to produce
21615consistent results across releases.
21616
d77de738 21617@opindex mcmove
ddf6fe37 21618@item -mcmove
d77de738
ML
21619Enable the generation of conditional moves.
21620
d77de738 21621@opindex mnops
ddf6fe37 21622@item -mnops=@var{num}
d77de738
ML
21623Emit @var{num} NOPs before every other generated instruction.
21624
d77de738
ML
21625@opindex mno-soft-cmpsf
21626@opindex msoft-cmpsf
ddf6fe37 21627@item -mno-soft-cmpsf
d77de738
ML
21628For single-precision floating-point comparisons, emit an @code{fsub} instruction
21629and test the flags. This is faster than a software comparison, but can
21630get incorrect results in the presence of NaNs, or when two different small
21631numbers are compared such that their difference is calculated as zero.
21632The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
21633software comparisons.
21634
d77de738 21635@opindex mstack-offset
ddf6fe37 21636@item -mstack-offset=@var{num}
d77de738
ML
21637Set the offset between the top of the stack and the stack pointer.
21638E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
21639can be used by leaf functions without stack allocation.
21640Values other than @samp{8} or @samp{16} are untested and unlikely to work.
21641Note also that this option changes the ABI; compiling a program with a
21642different stack offset than the libraries have been compiled with
21643generally does not work.
21644This option can be useful if you want to evaluate if a different stack
21645offset would give you better code, but to actually use a different stack
21646offset to build working programs, it is recommended to configure the
21647toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
21648
d77de738
ML
21649@opindex mno-round-nearest
21650@opindex mround-nearest
ddf6fe37 21651@item -mno-round-nearest
d77de738
ML
21652Make the scheduler assume that the rounding mode has been set to
21653truncating. The default is @option{-mround-nearest}.
21654
d77de738 21655@opindex mlong-calls
ddf6fe37 21656@item -mlong-calls
d77de738
ML
21657If not otherwise specified by an attribute, assume all calls might be beyond
21658the offset range of the @code{b} / @code{bl} instructions, and therefore load the
21659function address into a register before performing a (otherwise direct) call.
21660This is the default.
21661
d77de738 21662@opindex short-calls
ddf6fe37 21663@item -mshort-calls
d77de738
ML
21664If not otherwise specified by an attribute, assume all direct calls are
21665in the range of the @code{b} / @code{bl} instructions, so use these instructions
21666for direct calls. The default is @option{-mlong-calls}.
21667
d77de738 21668@opindex msmall16
ddf6fe37 21669@item -msmall16
d77de738
ML
21670Assume addresses can be loaded as 16-bit unsigned values. This does not
21671apply to function addresses for which @option{-mlong-calls} semantics
21672are in effect.
21673
d77de738 21674@opindex mfp-mode
ddf6fe37 21675@item -mfp-mode=@var{mode}
d77de738
ML
21676Set the prevailing mode of the floating-point unit.
21677This determines the floating-point mode that is provided and expected
21678at function call and return time. Making this mode match the mode you
21679predominantly need at function start can make your programs smaller and
21680faster by avoiding unnecessary mode switches.
21681
21682@var{mode} can be set to one the following values:
21683
21684@table @samp
21685@item caller
21686Any mode at function entry is valid, and retained or restored when
21687the function returns, and when it calls other functions.
21688This mode is useful for compiling libraries or other compilation units
21689you might want to incorporate into different programs with different
21690prevailing FPU modes, and the convenience of being able to use a single
21691object file outweighs the size and speed overhead for any extra
21692mode switching that might be needed, compared with what would be needed
21693with a more specific choice of prevailing FPU mode.
21694
21695@item truncate
21696This is the mode used for floating-point calculations with
21697truncating (i.e.@: round towards zero) rounding mode. That includes
21698conversion from floating point to integer.
21699
21700@item round-nearest
21701This is the mode used for floating-point calculations with
21702round-to-nearest-or-even rounding mode.
21703
21704@item int
21705This is the mode used to perform integer calculations in the FPU, e.g.@:
21706integer multiply, or integer multiply-and-accumulate.
21707@end table
21708
21709The default is @option{-mfp-mode=caller}
21710
d77de738
ML
21711@opindex mno-split-lohi
21712@opindex msplit-lohi
21713@opindex mno-postinc
21714@opindex mpostinc
21715@opindex mno-postmodify
21716@opindex mpostmodify
ddf6fe37
AA
21717@item -mno-split-lohi
21718@itemx -mno-postinc
21719@itemx -mno-postmodify
d77de738
ML
21720Code generation tweaks that disable, respectively, splitting of 32-bit
21721loads, generation of post-increment addresses, and generation of
21722post-modify addresses. The defaults are @option{msplit-lohi},
21723@option{-mpost-inc}, and @option{-mpost-modify}.
21724
d77de738
ML
21725@opindex mno-vect-double
21726@opindex mvect-double
ddf6fe37 21727@item -mnovect-double
d77de738
ML
21728Change the preferred SIMD mode to SImode. The default is
21729@option{-mvect-double}, which uses DImode as preferred SIMD mode.
21730
d77de738 21731@opindex max-vect-align
ddf6fe37 21732@item -max-vect-align=@var{num}
d77de738
ML
21733The maximum alignment for SIMD vector mode types.
21734@var{num} may be 4 or 8. The default is 8.
21735Note that this is an ABI change, even though many library function
21736interfaces are unaffected if they don't use SIMD vector modes
21737in places that affect size and/or alignment of relevant types.
21738
d77de738 21739@opindex msplit-vecmove-early
ddf6fe37 21740@item -msplit-vecmove-early
d77de738
ML
21741Split vector moves into single word moves before reload. In theory this
21742can give better register allocation, but so far the reverse seems to be
21743generally the case.
21744
d77de738 21745@opindex m1reg-
ddf6fe37 21746@item -m1reg-@var{reg}
d77de738
ML
21747Specify a register to hold the constant @minus{}1, which makes loading small negative
21748constants and certain bitmasks faster.
21749Allowable values for @var{reg} are @samp{r43} and @samp{r63},
21750which specify use of that register as a fixed register,
21751and @samp{none}, which means that no register is used for this
21752purpose. The default is @option{-m1reg-none}.
21753
21754@end table
21755
21756@node AMD GCN Options
21757@subsection AMD GCN Options
21758@cindex AMD GCN Options
21759
21760These options are defined specifically for the AMD GCN port.
21761
21762@table @gcctabopt
21763
d77de738 21764@opindex march
d77de738 21765@opindex mtune
ddf6fe37
AA
21766@item -march=@var{gpu}
21767@itemx -mtune=@var{gpu}
d77de738
ML
21768Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
21769are
21770
21771@table @samp
21772@item fiji
56ed1055
AS
21773Compile for GCN3 Fiji devices (gfx803). Support deprecated; availablility
21774depends on how GCC has been configured, see @option{--with-arch} and
21775@option{--with-multilib-list}.
d77de738
ML
21776
21777@item gfx900
21778Compile for GCN5 Vega 10 devices (gfx900).
21779
21780@item gfx906
21781Compile for GCN5 Vega 20 devices (gfx906).
21782
21783@item gfx908
21784Compile for CDNA1 Instinct MI100 series devices (gfx908).
21785
21786@item gfx90a
21787Compile for CDNA2 Instinct MI200 series devices (gfx90a).
21788
56d0aba1
TB
21789@item gfx1030
21790Compile for RDNA2 gfx1030 devices (GFX10 series).
21791
21792@item gfx1100
21793Compile for RDNA3 gfx1100 devices (GFX11 series).
21794
d77de738
ML
21795@end table
21796
ddf6fe37 21797@opindex msram-ecc
d77de738
ML
21798@item -msram-ecc=on
21799@itemx -msram-ecc=off
21800@itemx -msram-ecc=any
d77de738
ML
21801Compile binaries suitable for devices with the SRAM-ECC feature enabled,
21802disabled, or either mode. This feature can be enabled per-process on some
21803devices. The compiled code must match the device mode. The default is
21804@samp{any}, for devices that support it.
21805
d77de738 21806@opindex mstack-size
ddf6fe37 21807@item -mstack-size=@var{bytes}
d77de738
ML
21808Specify how many @var{bytes} of stack space will be requested for each GPU
21809thread (wave-front). Beware that there may be many threads and limited memory
21810available. The size of the stack allocation may also have an impact on
21811run-time performance. The default is 32KB when using OpenACC or OpenMP, and
218121MB otherwise.
21813
d77de738 21814@opindex mxnack
366e3d30
TB
21815@item -mxnack=on
21816@itemx -mxnack=off
21817@itemx -mxnack=any
21818Compile binaries suitable for devices with the XNACK feature enabled, disabled,
21819or either mode. Some devices always require XNACK and some allow the user to
21820configure XNACK. The compiled code must match the device mode.
4c12bcbe
AS
21821The default is @samp{-mxnack=any} on devices that support Unified Shared
21822Memory, and @samp{-mxnack=no} otherwise.
d77de738
ML
21823
21824@end table
21825
21826@node ARC Options
21827@subsection ARC Options
21828@cindex ARC options
21829
21830The following options control the architecture variant for which code
21831is being compiled:
21832
21833@c architecture variants
21834@table @gcctabopt
21835
d77de738 21836@opindex mbarrel-shifter
ddf6fe37 21837@item -mbarrel-shifter
d77de738
ML
21838Generate instructions supported by barrel shifter. This is the default
21839unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
21840
d77de738 21841@opindex mjli-always
ddf6fe37 21842@item -mjli-always
d77de738
ML
21843Force to call a function using jli_s instruction. This option is
21844valid only for ARCv2 architecture.
21845
d77de738 21846@opindex mcpu
ddf6fe37 21847@item -mcpu=@var{cpu}
d77de738
ML
21848Set architecture type, register usage, and instruction scheduling
21849parameters for @var{cpu}. There are also shortcut alias options
21850available for backward compatibility and convenience. Supported
21851values for @var{cpu} are
21852
21853@table @samp
21854@opindex mA6
21855@opindex mARC600
21856@item arc600
21857Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
21858
d77de738 21859@opindex mARC601
ddf6fe37 21860@item arc601
d77de738
ML
21861Compile for ARC601. Alias: @option{-mARC601}.
21862
d77de738
ML
21863@opindex mA7
21864@opindex mARC700
ddf6fe37 21865@item arc700
d77de738
ML
21866Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
21867This is the default when configured with @option{--with-cpu=arc700}@.
21868
21869@item arcem
21870Compile for ARC EM.
21871
21872@item archs
21873Compile for ARC HS.
21874
21875@item em
21876Compile for ARC EM CPU with no hardware extensions.
21877
21878@item em4
21879Compile for ARC EM4 CPU.
21880
21881@item em4_dmips
21882Compile for ARC EM4 DMIPS CPU.
21883
21884@item em4_fpus
21885Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
21886extension.
21887
21888@item em4_fpuda
21889Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
21890double assist instructions.
21891
21892@item hs
21893Compile for ARC HS CPU with no hardware extensions except the atomic
21894instructions.
21895
21896@item hs34
21897Compile for ARC HS34 CPU.
21898
21899@item hs38
21900Compile for ARC HS38 CPU.
21901
21902@item hs38_linux
21903Compile for ARC HS38 CPU with all hardware extensions on.
21904
21905@item hs4x
21906Compile for ARC HS4x CPU.
21907
21908@item hs4xd
21909Compile for ARC HS4xD CPU.
21910
21911@item hs4x_rel31
21912Compile for ARC HS4x CPU release 3.10a.
21913
21914@item arc600_norm
21915Compile for ARC 600 CPU with @code{norm} instructions enabled.
21916
21917@item arc600_mul32x16
21918Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
21919instructions enabled.
21920
21921@item arc600_mul64
21922Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
21923instructions enabled.
21924
21925@item arc601_norm
21926Compile for ARC 601 CPU with @code{norm} instructions enabled.
21927
21928@item arc601_mul32x16
21929Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
21930instructions enabled.
21931
21932@item arc601_mul64
21933Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
21934instructions enabled.
21935
21936@item nps400
21937Compile for ARC 700 on NPS400 chip.
21938
21939@item em_mini
21940Compile for ARC EM minimalist configuration featuring reduced register
21941set.
21942
21943@end table
21944
d77de738 21945@opindex mdpfp
d77de738 21946@opindex mdpfp-compact
ddf6fe37
AA
21947@item -mdpfp
21948@itemx -mdpfp-compact
d77de738
ML
21949Generate double-precision FPX instructions, tuned for the compact
21950implementation.
21951
d77de738 21952@opindex mdpfp-fast
ddf6fe37 21953@item -mdpfp-fast
d77de738
ML
21954Generate double-precision FPX instructions, tuned for the fast
21955implementation.
21956
d77de738 21957@opindex mno-dpfp-lrsr
ddf6fe37 21958@item -mno-dpfp-lrsr
d77de738
ML
21959Disable @code{lr} and @code{sr} instructions from using FPX extension
21960aux registers.
21961
d77de738 21962@opindex mea
ddf6fe37 21963@item -mea
d77de738
ML
21964Generate extended arithmetic instructions. Currently only
21965@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
21966supported. Only valid for @option{-mcpu=ARC700}.
21967
d77de738
ML
21968@opindex mno-mpy
21969@opindex mmpy
ddf6fe37 21970@item -mno-mpy
d77de738
ML
21971Do not generate @code{mpy}-family instructions for ARC700. This option is
21972deprecated.
21973
d77de738 21974@opindex mmul32x16
ddf6fe37 21975@item -mmul32x16
d77de738
ML
21976Generate 32x16-bit multiply and multiply-accumulate instructions.
21977
d77de738 21978@opindex mmul64
ddf6fe37 21979@item -mmul64
d77de738
ML
21980Generate @code{mul64} and @code{mulu64} instructions.
21981Only valid for @option{-mcpu=ARC600}.
21982
d77de738 21983@opindex mnorm
ddf6fe37 21984@item -mnorm
d77de738
ML
21985Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
21986is in effect.
21987
d77de738 21988@opindex mspfp
d77de738 21989@opindex mspfp-compact
ddf6fe37
AA
21990@item -mspfp
21991@itemx -mspfp-compact
d77de738
ML
21992Generate single-precision FPX instructions, tuned for the compact
21993implementation.
21994
d77de738 21995@opindex mspfp-fast
ddf6fe37 21996@item -mspfp-fast
d77de738
ML
21997Generate single-precision FPX instructions, tuned for the fast
21998implementation.
21999
d77de738 22000@opindex msimd
ddf6fe37 22001@item -msimd
d77de738
ML
22002Enable generation of ARC SIMD instructions via target-specific
22003builtins. Only valid for @option{-mcpu=ARC700}.
22004
d77de738 22005@opindex msoft-float
ddf6fe37 22006@item -msoft-float
d77de738
ML
22007This option ignored; it is provided for compatibility purposes only.
22008Software floating-point code is emitted by default, and this default
22009can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
22010@option{-mspfp-fast} for single precision, and @option{-mdpfp},
22011@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
22012
d77de738 22013@opindex mswap
ddf6fe37 22014@item -mswap
d77de738
ML
22015Generate @code{swap} instructions.
22016
d77de738 22017@opindex matomic
ddf6fe37 22018@item -matomic
d77de738
ML
22019This enables use of the locked load/store conditional extension to implement
22020atomic memory built-in functions. Not available for ARC 6xx or ARC
22021EM cores.
22022
d77de738 22023@opindex mdiv-rem
ddf6fe37 22024@item -mdiv-rem
d77de738
ML
22025Enable @code{div} and @code{rem} instructions for ARCv2 cores.
22026
d77de738 22027@opindex mcode-density
ddf6fe37 22028@item -mcode-density
d77de738
ML
22029Enable code density instructions for ARC EM.
22030This option is on by default for ARC HS.
22031
d77de738 22032@opindex mll64
ddf6fe37 22033@item -mll64
d77de738
ML
22034Enable double load/store operations for ARC HS cores.
22035
d77de738 22036@opindex mtp-regno
ddf6fe37 22037@item -mtp-regno=@var{regno}
d77de738
ML
22038Specify thread pointer register number.
22039
d77de738 22040@opindex mmpy-option
ddf6fe37 22041@item -mmpy-option=@var{multo}
d77de738
ML
22042Compile ARCv2 code with a multiplier design option. You can specify
22043the option using either a string or numeric value for @var{multo}.
22044@samp{wlh1} is the default value. The recognized values are:
22045
22046@table @samp
22047@item 0
22048@itemx none
22049No multiplier available.
22050
22051@item 1
22052@itemx w
2205316x16 multiplier, fully pipelined.
22054The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
22055
22056@item 2
22057@itemx wlh1
2205832x32 multiplier, fully
22059pipelined (1 stage). The following instructions are additionally
22060enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22061
22062@item 3
22063@itemx wlh2
2206432x32 multiplier, fully pipelined
22065(2 stages). The following instructions are additionally enabled: @code{mpy},
22066@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22067
22068@item 4
22069@itemx wlh3
22070Two 16x16 multipliers, blocking,
22071sequential. The following instructions are additionally enabled: @code{mpy},
22072@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22073
22074@item 5
22075@itemx wlh4
22076One 16x16 multiplier, blocking,
22077sequential. The following instructions are additionally enabled: @code{mpy},
22078@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22079
22080@item 6
22081@itemx wlh5
22082One 32x4 multiplier, blocking,
22083sequential. The following instructions are additionally enabled: @code{mpy},
22084@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
22085
22086@item 7
22087@itemx plus_dmpy
22088ARC HS SIMD support.
22089
22090@item 8
22091@itemx plus_macd
22092ARC HS SIMD support.
22093
22094@item 9
22095@itemx plus_qmacw
22096ARC HS SIMD support.
22097
22098@end table
22099
22100This option is only available for ARCv2 cores@.
22101
d77de738 22102@opindex mfpu
ddf6fe37 22103@item -mfpu=@var{fpu}
d77de738
ML
22104Enables support for specific floating-point hardware extensions for ARCv2
22105cores. Supported values for @var{fpu} are:
22106
22107@table @samp
22108
22109@item fpus
22110Enables support for single-precision floating-point hardware
22111extensions@.
22112
22113@item fpud
22114Enables support for double-precision floating-point hardware
22115extensions. The single-precision floating-point extension is also
22116enabled. Not available for ARC EM@.
22117
22118@item fpuda
22119Enables support for double-precision floating-point hardware
22120extensions using double-precision assist instructions. The single-precision
22121floating-point extension is also enabled. This option is
22122only available for ARC EM@.
22123
22124@item fpuda_div
22125Enables support for double-precision floating-point hardware
22126extensions using double-precision assist instructions.
22127The single-precision floating-point, square-root, and divide
22128extensions are also enabled. This option is
22129only available for ARC EM@.
22130
22131@item fpuda_fma
22132Enables support for double-precision floating-point hardware
22133extensions using double-precision assist instructions.
22134The single-precision floating-point and fused multiply and add
22135hardware extensions are also enabled. This option is
22136only available for ARC EM@.
22137
22138@item fpuda_all
22139Enables support for double-precision floating-point hardware
22140extensions using double-precision assist instructions.
22141All single-precision floating-point hardware extensions are also
22142enabled. This option is only available for ARC EM@.
22143
22144@item fpus_div
22145Enables support for single-precision floating-point, square-root and divide
22146hardware extensions@.
22147
22148@item fpud_div
22149Enables support for double-precision floating-point, square-root and divide
22150hardware extensions. This option
22151includes option @samp{fpus_div}. Not available for ARC EM@.
22152
22153@item fpus_fma
22154Enables support for single-precision floating-point and
22155fused multiply and add hardware extensions@.
22156
22157@item fpud_fma
22158Enables support for double-precision floating-point and
22159fused multiply and add hardware extensions. This option
22160includes option @samp{fpus_fma}. Not available for ARC EM@.
22161
22162@item fpus_all
22163Enables support for all single-precision floating-point hardware
22164extensions@.
22165
22166@item fpud_all
22167Enables support for all single- and double-precision floating-point
22168hardware extensions. Not available for ARC EM@.
22169
22170@end table
22171
d77de738 22172@opindex mirq-ctrl-saved
ddf6fe37 22173@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
d77de738
ML
22174Specifies general-purposes registers that the processor automatically
22175saves/restores on interrupt entry and exit. @var{register-range} is
22176specified as two registers separated by a dash. The register range
22177always starts with @code{r0}, the upper limit is @code{fp} register.
22178@var{blink} and @var{lp_count} are optional. This option is only
22179valid for ARC EM and ARC HS cores.
22180
d77de738 22181@opindex mrgf-banked-regs
ddf6fe37 22182@item -mrgf-banked-regs=@var{number}
d77de738
ML
22183Specifies the number of registers replicated in second register bank
22184on entry to fast interrupt. Fast interrupts are interrupts with the
22185highest priority level P0. These interrupts save only PC and STATUS32
22186registers to avoid memory transactions during interrupt entry and exit
22187sequences. Use this option when you are using fast interrupts in an
22188ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
22189
d77de738 22190@opindex mlpc-width
ddf6fe37 22191@item -mlpc-width=@var{width}
d77de738
ML
22192Specify the width of the @code{lp_count} register. Valid values for
22193@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
22194fixed to 32 bits. If the width is less than 32, the compiler does not
22195attempt to transform loops in your program to use the zero-delay loop
22196mechanism unless it is known that the @code{lp_count} register can
22197hold the required loop-counter value. Depending on the width
22198specified, the compiler and run-time library might continue to use the
22199loop mechanism for various needs. This option defines macro
22200@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
22201
d77de738 22202@opindex mrf16
ddf6fe37 22203@item -mrf16
d77de738
ML
22204This option instructs the compiler to generate code for a 16-entry
22205register file. This option defines the @code{__ARC_RF16__}
22206preprocessor macro.
22207
d77de738 22208@opindex mbranch-index
ddf6fe37 22209@item -mbranch-index
d77de738
ML
22210Enable use of @code{bi} or @code{bih} instructions to implement jump
22211tables.
22212
22213@end table
22214
22215The following options are passed through to the assembler, and also
22216define preprocessor macro symbols.
22217
22218@c Flags used by the assembler, but for which we define preprocessor
22219@c macro symbols as well.
22220@table @gcctabopt
d77de738 22221@opindex mdsp-packa
ddf6fe37 22222@item -mdsp-packa
d77de738
ML
22223Passed down to the assembler to enable the DSP Pack A extensions.
22224Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
22225deprecated.
22226
d77de738 22227@opindex mdvbf
ddf6fe37 22228@item -mdvbf
d77de738
ML
22229Passed down to the assembler to enable the dual Viterbi butterfly
22230extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
22231option is deprecated.
22232
22233@c ARC700 4.10 extension instruction
d77de738 22234@opindex mlock
ddf6fe37 22235@item -mlock
d77de738
ML
22236Passed down to the assembler to enable the locked load/store
22237conditional extension. Also sets the preprocessor symbol
22238@code{__Xlock}.
22239
d77de738 22240@opindex mmac-d16
ddf6fe37 22241@item -mmac-d16
d77de738
ML
22242Passed down to the assembler. Also sets the preprocessor symbol
22243@code{__Xxmac_d16}. This option is deprecated.
22244
d77de738 22245@opindex mmac-24
ddf6fe37 22246@item -mmac-24
d77de738
ML
22247Passed down to the assembler. Also sets the preprocessor symbol
22248@code{__Xxmac_24}. This option is deprecated.
22249
22250@c ARC700 4.10 extension instruction
d77de738 22251@opindex mrtsc
ddf6fe37 22252@item -mrtsc
d77de738
ML
22253Passed down to the assembler to enable the 64-bit time-stamp counter
22254extension instruction. Also sets the preprocessor symbol
22255@code{__Xrtsc}. This option is deprecated.
22256
22257@c ARC700 4.10 extension instruction
d77de738 22258@opindex mswape
ddf6fe37 22259@item -mswape
d77de738
ML
22260Passed down to the assembler to enable the swap byte ordering
22261extension instruction. Also sets the preprocessor symbol
22262@code{__Xswape}.
22263
d77de738 22264@opindex mtelephony
ddf6fe37 22265@item -mtelephony
d77de738
ML
22266Passed down to the assembler to enable dual- and single-operand
22267instructions for telephony. Also sets the preprocessor symbol
22268@code{__Xtelephony}. This option is deprecated.
22269
d77de738 22270@opindex mxy
ddf6fe37 22271@item -mxy
d77de738
ML
22272Passed down to the assembler to enable the XY memory extension. Also
22273sets the preprocessor symbol @code{__Xxy}.
22274
22275@end table
22276
22277The following options control how the assembly code is annotated:
22278
22279@c Assembly annotation options
22280@table @gcctabopt
d77de738 22281@opindex misize
ddf6fe37 22282@item -misize
d77de738
ML
22283Annotate assembler instructions with estimated addresses.
22284
d77de738 22285@opindex mannotate-align
ddf6fe37 22286@item -mannotate-align
e4b19406 22287Does nothing. Preserved for backward compatibility.
d77de738
ML
22288
22289@end table
22290
22291The following options are passed through to the linker:
22292
22293@c options passed through to the linker
22294@table @gcctabopt
d77de738 22295@opindex marclinux
ddf6fe37 22296@item -marclinux
d77de738
ML
22297Passed through to the linker, to specify use of the @code{arclinux} emulation.
22298This option is enabled by default in tool chains built for
22299@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
22300when profiling is not requested.
22301
d77de738 22302@opindex marclinux_prof
ddf6fe37 22303@item -marclinux_prof
d77de738
ML
22304Passed through to the linker, to specify use of the
22305@code{arclinux_prof} emulation. This option is enabled by default in
22306tool chains built for @w{@code{arc-linux-uclibc}} and
22307@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
22308
22309@end table
22310
22311The following options control the semantics of generated code:
22312
22313@c semantically relevant code generation options
22314@table @gcctabopt
d77de738 22315@opindex mlong-calls
ddf6fe37 22316@item -mlong-calls
d77de738
ML
22317Generate calls as register indirect calls, thus providing access
22318to the full 32-bit address range.
22319
d77de738 22320@opindex mmedium-calls
ddf6fe37 22321@item -mmedium-calls
d77de738
ML
22322Don't use less than 25-bit addressing range for calls, which is the
22323offset available for an unconditional branch-and-link
22324instruction. Conditional execution of function calls is suppressed, to
22325allow use of the 25-bit range, rather than the 21-bit range with
22326conditional branch-and-link. This is the default for tool chains built
22327for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
22328
d77de738 22329@opindex G
ddf6fe37 22330@item -G @var{num}
d77de738
ML
22331Put definitions of externally-visible data in a small data section if
22332that data is no bigger than @var{num} bytes. The default value of
22333@var{num} is 4 for any ARC configuration, or 8 when we have double
22334load/store operations.
22335
d77de738
ML
22336@opindex mno-sdata
22337@opindex msdata
ddf6fe37 22338@item -mno-sdata
d77de738
ML
22339Do not generate sdata references. This is the default for tool chains
22340built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
22341targets.
22342
d77de738 22343@opindex mvolatile-cache
ddf6fe37 22344@item -mvolatile-cache
d77de738
ML
22345Use ordinarily cached memory accesses for volatile references. This is the
22346default.
22347
d77de738
ML
22348@opindex mno-volatile-cache
22349@opindex mvolatile-cache
ddf6fe37 22350@item -mno-volatile-cache
d77de738
ML
22351Enable cache bypass for volatile references.
22352
22353@end table
22354
22355The following options fine tune code generation:
22356@c code generation tuning options
22357@table @gcctabopt
d77de738 22358@opindex malign-call
ddf6fe37 22359@item -malign-call
d77de738
ML
22360Does nothing. Preserved for backward compatibility.
22361
d77de738 22362@opindex mauto-modify-reg
ddf6fe37 22363@item -mauto-modify-reg
d77de738
ML
22364Enable the use of pre/post modify with register displacement.
22365
d77de738 22366@opindex mbbit-peephole
ddf6fe37 22367@item -mbbit-peephole
07f7615c 22368Does nothing. Preserved for backward compatibility.
d77de738 22369
d77de738 22370@opindex mno-brcc
ddf6fe37 22371@item -mno-brcc
d77de738
ML
22372This option disables a target-specific pass in @file{arc_reorg} to
22373generate compare-and-branch (@code{br@var{cc}}) instructions.
22374It has no effect on
22375generation of these instructions driven by the combiner pass.
22376
d77de738 22377@opindex mcase-vector-pcrel
ddf6fe37 22378@item -mcase-vector-pcrel
d77de738
ML
22379Use PC-relative switch case tables to enable case table shortening.
22380This is the default for @option{-Os}.
22381
d77de738 22382@opindex mcompact-casesi
ddf6fe37 22383@item -mcompact-casesi
d77de738
ML
22384Enable compact @code{casesi} pattern. This is the default for @option{-Os},
22385and only available for ARCv1 cores. This option is deprecated.
22386
d77de738 22387@opindex mno-cond-exec
ddf6fe37 22388@item -mno-cond-exec
d77de738
ML
22389Disable the ARCompact-specific pass to generate conditional
22390execution instructions.
22391
22392Due to delay slot scheduling and interactions between operand numbers,
22393literal sizes, instruction lengths, and the support for conditional execution,
22394the target-independent pass to generate conditional execution is often lacking,
22395so the ARC port has kept a special pass around that tries to find more
22396conditional execution generation opportunities after register allocation,
22397branch shortening, and delay slot scheduling have been done. This pass
22398generally, but not always, improves performance and code size, at the cost of
22399extra compilation time, which is why there is an option to switch it off.
22400If you have a problem with call instructions exceeding their allowable
22401offset range because they are conditionalized, you should consider using
22402@option{-mmedium-calls} instead.
22403
d77de738 22404@opindex mearly-cbranchsi
ddf6fe37 22405@item -mearly-cbranchsi
d77de738
ML
22406Enable pre-reload use of the @code{cbranchsi} pattern.
22407
d77de738 22408@opindex mexpand-adddi
ddf6fe37 22409@item -mexpand-adddi
d77de738
ML
22410Expand @code{adddi3} and @code{subdi3} at RTL generation time into
22411@code{add.f}, @code{adc} etc. This option is deprecated.
22412
d77de738 22413@opindex mindexed-loads
ddf6fe37 22414@item -mindexed-loads
d77de738
ML
22415Enable the use of indexed loads. This can be problematic because some
22416optimizers then assume that indexed stores exist, which is not
22417the case.
22418
d77de738 22419@opindex mlra
ddf6fe37 22420@item -mlra
d77de738
ML
22421Enable Local Register Allocation. This is still experimental for ARC,
22422so by default the compiler uses standard reload
22423(i.e.@: @option{-mno-lra}).
22424
d77de738 22425@opindex mlra-priority-none
ddf6fe37 22426@item -mlra-priority-none
d77de738
ML
22427Don't indicate any priority for target registers.
22428
d77de738 22429@opindex mlra-priority-compact
ddf6fe37 22430@item -mlra-priority-compact
d77de738
ML
22431Indicate target register priority for r0..r3 / r12..r15.
22432
d77de738 22433@opindex mlra-priority-noncompact
ddf6fe37 22434@item -mlra-priority-noncompact
d77de738
ML
22435Reduce target register priority for r0..r3 / r12..r15.
22436
d77de738 22437@opindex mmillicode
ddf6fe37 22438@item -mmillicode
d77de738
ML
22439When optimizing for size (using @option{-Os}), prologues and epilogues
22440that have to save or restore a large number of registers are often
22441shortened by using call to a special function in libgcc; this is
22442referred to as a @emph{millicode} call. As these calls can pose
22443performance issues, and/or cause linking issues when linking in a
22444nonstandard way, this option is provided to turn on or off millicode
22445call generation.
22446
d77de738 22447@opindex mcode-density-frame
ddf6fe37 22448@item -mcode-density-frame
d77de738
ML
22449This option enable the compiler to emit @code{enter} and @code{leave}
22450instructions. These instructions are only valid for CPUs with
22451code-density feature.
22452
d77de738 22453@opindex mmixed-code
ddf6fe37 22454@item -mmixed-code
d77de738
ML
22455Does nothing. Preserved for backward compatibility.
22456
d77de738 22457@opindex mq-class
ddf6fe37 22458@item -mq-class
d77de738
ML
22459Ths option is deprecated. Enable @samp{q} instruction alternatives.
22460This is the default for @option{-Os}.
22461
d77de738 22462@opindex mRcq
ddf6fe37 22463@item -mRcq
d77de738
ML
22464Does nothing. Preserved for backward compatibility.
22465
d77de738 22466@opindex mRcw
ddf6fe37 22467@item -mRcw
d77de738
ML
22468Does nothing. Preserved for backward compatibility.
22469
d77de738 22470@opindex msize-level
ddf6fe37 22471@item -msize-level=@var{level}
d77de738
ML
22472Fine-tune size optimization with regards to instruction lengths and alignment.
22473The recognized values for @var{level} are:
22474@table @samp
22475@item 0
22476No size optimization. This level is deprecated and treated like @samp{1}.
22477
22478@item 1
22479Short instructions are used opportunistically.
22480
22481@item 2
22482In addition, alignment of loops and of code after barriers are dropped.
22483
22484@item 3
22485In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
22486
22487@end table
22488
22489This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
22490the behavior when this is not set is equivalent to level @samp{1}.
22491
d77de738 22492@opindex mtune
ddf6fe37 22493@item -mtune=@var{cpu}
d77de738
ML
22494Set instruction scheduling parameters for @var{cpu}, overriding any implied
22495by @option{-mcpu=}.
22496
22497Supported values for @var{cpu} are
22498
22499@table @samp
22500@item ARC600
22501Tune for ARC600 CPU.
22502
22503@item ARC601
22504Tune for ARC601 CPU.
22505
22506@item ARC700
22507Tune for ARC700 CPU with standard multiplier block.
22508
22509@item ARC700-xmac
22510Tune for ARC700 CPU with XMAC block.
22511
22512@item ARC725D
22513Tune for ARC725D CPU.
22514
22515@item ARC750D
22516Tune for ARC750D CPU.
22517
22518@item core3
22519Tune for ARCv2 core3 type CPU. This option enable usage of
22520@code{dbnz} instruction.
22521
22522@item release31a
22523Tune for ARC4x release 3.10a.
22524
22525@end table
22526
d77de738 22527@opindex mmultcost
ddf6fe37 22528@item -mmultcost=@var{num}
d77de738
ML
22529Cost to assume for a multiply instruction, with @samp{4} being equal to a
22530normal instruction.
22531
d77de738 22532@opindex munalign-prob-threshold
ddf6fe37 22533@item -munalign-prob-threshold=@var{probability}
d77de738
ML
22534Does nothing. Preserved for backward compatibility.
22535
22536@end table
22537
22538The following options are maintained for backward compatibility, but
22539are now deprecated and will be removed in a future release:
22540
22541@c Deprecated options
22542@table @gcctabopt
22543
d77de738 22544@opindex margonaut
ddf6fe37 22545@item -margonaut
d77de738
ML
22546Obsolete FPX.
22547
d77de738 22548@opindex mbig-endian
d77de738 22549@opindex EB
ddf6fe37
AA
22550@item -mbig-endian
22551@itemx -EB
d77de738
ML
22552Compile code for big-endian targets. Use of these options is now
22553deprecated. Big-endian code is supported by configuring GCC to build
22554@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
22555for which big endian is the default.
22556
d77de738 22557@opindex mlittle-endian
d77de738 22558@opindex EL
ddf6fe37
AA
22559@item -mlittle-endian
22560@itemx -EL
d77de738
ML
22561Compile code for little-endian targets. Use of these options is now
22562deprecated. Little-endian code is supported by configuring GCC to build
22563@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
22564for which little endian is the default.
22565
d77de738 22566@opindex mbarrel_shifter
ddf6fe37 22567@item -mbarrel_shifter
d77de738
ML
22568Replaced by @option{-mbarrel-shifter}.
22569
d77de738 22570@opindex mdpfp_compact
ddf6fe37 22571@item -mdpfp_compact
d77de738
ML
22572Replaced by @option{-mdpfp-compact}.
22573
d77de738 22574@opindex mdpfp_fast
ddf6fe37 22575@item -mdpfp_fast
d77de738
ML
22576Replaced by @option{-mdpfp-fast}.
22577
d77de738 22578@opindex mdsp_packa
ddf6fe37 22579@item -mdsp_packa
d77de738
ML
22580Replaced by @option{-mdsp-packa}.
22581
d77de738 22582@opindex mEA
ddf6fe37 22583@item -mEA
d77de738
ML
22584Replaced by @option{-mea}.
22585
d77de738 22586@opindex mmac_24
ddf6fe37 22587@item -mmac_24
d77de738
ML
22588Replaced by @option{-mmac-24}.
22589
d77de738 22590@opindex mmac_d16
ddf6fe37 22591@item -mmac_d16
d77de738
ML
22592Replaced by @option{-mmac-d16}.
22593
d77de738 22594@opindex mspfp_compact
ddf6fe37 22595@item -mspfp_compact
d77de738
ML
22596Replaced by @option{-mspfp-compact}.
22597
d77de738 22598@opindex mspfp_fast
ddf6fe37 22599@item -mspfp_fast
d77de738
ML
22600Replaced by @option{-mspfp-fast}.
22601
d77de738 22602@opindex mtune
ddf6fe37 22603@item -mtune=@var{cpu}
d77de738
ML
22604Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
22605@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
22606@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
22607
d77de738 22608@opindex multcost
ddf6fe37 22609@item -multcost=@var{num}
d77de738
ML
22610Replaced by @option{-mmultcost}.
22611
22612@end table
22613
22614@node ARM Options
22615@subsection ARM Options
22616@cindex ARM options
22617
22618These @samp{-m} options are defined for the ARM port:
22619
22620@table @gcctabopt
d77de738 22621@opindex mabi
ddf6fe37 22622@item -mabi=@var{name}
d77de738
ML
22623Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
22624@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
22625
d77de738 22626@opindex mapcs-frame
ddf6fe37 22627@item -mapcs-frame
d77de738
ML
22628Generate a stack frame that is compliant with the ARM Procedure Call
22629Standard for all functions, even if this is not strictly necessary for
22630correct execution of the code. Specifying @option{-fomit-frame-pointer}
22631with this option causes the stack frames not to be generated for
22632leaf functions. The default is @option{-mno-apcs-frame}.
22633This option is deprecated.
22634
d77de738 22635@opindex mapcs
ddf6fe37 22636@item -mapcs
d77de738
ML
22637This is a synonym for @option{-mapcs-frame} and is deprecated.
22638
22639@ignore
22640@c not currently implemented
d77de738 22641@opindex mapcs-stack-check
ddf6fe37 22642@item -mapcs-stack-check
d77de738
ML
22643Generate code to check the amount of stack space available upon entry to
22644every function (that actually uses some stack space). If there is
22645insufficient space available then either the function
22646@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
22647called, depending upon the amount of stack space required. The runtime
22648system is required to provide these functions. The default is
22649@option{-mno-apcs-stack-check}, since this produces smaller code.
22650
22651@c not currently implemented
d77de738 22652@opindex mapcs-reentrant
ddf6fe37 22653@item -mapcs-reentrant
d77de738
ML
22654Generate reentrant, position-independent code. The default is
22655@option{-mno-apcs-reentrant}.
22656@end ignore
22657
d77de738 22658@opindex mthumb-interwork
ddf6fe37 22659@item -mthumb-interwork
d77de738
ML
22660Generate code that supports calling between the ARM and Thumb
22661instruction sets. Without this option, on pre-v5 architectures, the
22662two instruction sets cannot be reliably used inside one program. The
22663default is @option{-mno-thumb-interwork}, since slightly larger code
22664is generated when @option{-mthumb-interwork} is specified. In AAPCS
22665configurations this option is meaningless.
22666
d77de738
ML
22667@opindex mno-sched-prolog
22668@opindex msched-prolog
ddf6fe37 22669@item -mno-sched-prolog
d77de738
ML
22670Prevent the reordering of instructions in the function prologue, or the
22671merging of those instruction with the instructions in the function's
22672body. This means that all functions start with a recognizable set
22673of instructions (or in fact one of a choice from a small set of
22674different function prologues), and this information can be used to
22675locate the start of functions inside an executable piece of code. The
22676default is @option{-msched-prolog}.
22677
d77de738 22678@opindex mfloat-abi
ddf6fe37 22679@item -mfloat-abi=@var{name}
d77de738
ML
22680Specifies which floating-point ABI to use. Permissible values
22681are: @samp{soft}, @samp{softfp} and @samp{hard}.
22682
22683Specifying @samp{soft} causes GCC to generate output containing
22684library calls for floating-point operations.
22685@samp{softfp} allows the generation of code using hardware floating-point
22686instructions, but still uses the soft-float calling conventions.
22687@samp{hard} allows generation of floating-point instructions
22688and uses FPU-specific calling conventions.
22689
22690The default depends on the specific target configuration. Note that
22691the hard-float and soft-float ABIs are not link-compatible; you must
22692compile your entire program with the same ABI, and link with a
22693compatible set of libraries.
22694
d77de738 22695@opindex mgeneral-regs-only
ddf6fe37 22696@item -mgeneral-regs-only
d77de738
ML
22697Generate code which uses only the general-purpose registers. This will prevent
22698the compiler from using floating-point and Advanced SIMD registers but will not
22699impose any restrictions on the assembler.
22700
d77de738 22701@opindex mlittle-endian
ddf6fe37 22702@item -mlittle-endian
d77de738
ML
22703Generate code for a processor running in little-endian mode. This is
22704the default for all standard configurations.
22705
d77de738 22706@opindex mbig-endian
ddf6fe37 22707@item -mbig-endian
d77de738
ML
22708Generate code for a processor running in big-endian mode; the default is
22709to compile code for a little-endian processor.
22710
ddf6fe37 22711@opindex mbe8
d77de738
ML
22712@item -mbe8
22713@itemx -mbe32
d77de738
ML
22714When linking a big-endian image select between BE8 and BE32 formats.
22715The option has no effect for little-endian images and is ignored. The
22716default is dependent on the selected target architecture. For ARMv6
22717and later architectures the default is BE8, for older architectures
22718the default is BE32. BE32 format has been deprecated by ARM.
22719
d77de738 22720@opindex march
ddf6fe37 22721@item -march=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22722This specifies the name of the target ARM architecture. GCC uses this
22723name to determine what kind of instructions it can emit when generating
22724assembly code. This option can be used in conjunction with or instead
22725of the @option{-mcpu=} option.
22726
22727Permissible names are:
22728@samp{armv4t},
22729@samp{armv5t}, @samp{armv5te},
22730@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
22731@samp{armv6z}, @samp{armv6zk},
22732@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
22733@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
22734@samp{armv8.4-a},
22735@samp{armv8.5-a},
22736@samp{armv8.6-a},
22737@samp{armv9-a},
22738@samp{armv7-r},
22739@samp{armv8-r},
22740@samp{armv6-m}, @samp{armv6s-m},
22741@samp{armv7-m}, @samp{armv7e-m},
22742@samp{armv8-m.base}, @samp{armv8-m.main},
22743@samp{armv8.1-m.main},
22744@samp{armv9-a},
22745@samp{iwmmxt} and @samp{iwmmxt2}.
22746
22747Additionally, the following architectures, which lack support for the
22748Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
22749
22750Many of the architectures support extensions. These can be added by
22751appending @samp{+@var{extension}} to the architecture name. Extension
22752options are processed in order and capabilities accumulate. An extension
22753will also enable any necessary base extensions
22754upon which it depends. For example, the @samp{+crypto} extension
22755will always enable the @samp{+simd} extension. The exception to the
22756additive construction is for extensions that are prefixed with
22757@samp{+no@dots{}}: these extensions disable the specified option and
22758any other extensions that may depend on the presence of that
22759extension.
22760
22761For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
22762writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
22763entirely disabled by the @samp{+nofp} option that follows it.
22764
22765Most extension names are generically named, but have an effect that is
22766dependent upon the architecture to which it is applied. For example,
22767the @samp{+simd} option can be applied to both @samp{armv7-a} and
22768@samp{armv8-a} architectures, but will enable the original ARMv7-A
22769Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
22770variant for @samp{armv8-a}.
22771
22772The table below lists the supported extensions for each architecture.
22773Architectures not mentioned do not support any extensions.
22774
22775@table @samp
22776@item armv5te
22777@itemx armv6
22778@itemx armv6j
22779@itemx armv6k
22780@itemx armv6kz
22781@itemx armv6t2
22782@itemx armv6z
22783@itemx armv6zk
22784@table @samp
22785@item +fp
22786The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
22787used as an alias for this extension.
22788
22789@item +nofp
22790Disable the floating-point instructions.
22791@end table
22792
22793@item armv7
22794The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
22795@table @samp
22796@item +fp
22797The VFPv3 floating-point instructions, with 16 double-precision
22798registers. The extension @samp{+vfpv3-d16} can be used as an alias
22799for this extension. Note that floating-point is not supported by the
22800base ARMv7-M architecture, but is compatible with both the ARMv7-A and
22801ARMv7-R architectures.
22802
22803@item +nofp
22804Disable the floating-point instructions.
22805@end table
22806
22807@item armv7-a
22808@table @samp
22809@item +mp
22810The multiprocessing extension.
22811
22812@item +sec
22813The security extension.
22814
22815@item +fp
22816The VFPv3 floating-point instructions, with 16 double-precision
22817registers. The extension @samp{+vfpv3-d16} can be used as an alias
22818for this extension.
22819
22820@item +simd
22821The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22822The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
22823for this extension.
22824
22825@item +vfpv3
22826The VFPv3 floating-point instructions, with 32 double-precision
22827registers.
22828
22829@item +vfpv3-d16-fp16
22830The VFPv3 floating-point instructions, with 16 double-precision
22831registers and the half-precision floating-point conversion operations.
22832
22833@item +vfpv3-fp16
22834The VFPv3 floating-point instructions, with 32 double-precision
22835registers and the half-precision floating-point conversion operations.
22836
22837@item +vfpv4-d16
22838The VFPv4 floating-point instructions, with 16 double-precision
22839registers.
22840
22841@item +vfpv4
22842The VFPv4 floating-point instructions, with 32 double-precision
22843registers.
22844
22845@item +neon-fp16
22846The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22847the half-precision floating-point conversion operations.
22848
22849@item +neon-vfpv4
22850The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
22851
22852@item +nosimd
22853Disable the Advanced SIMD instructions (does not disable floating point).
22854
22855@item +nofp
22856Disable the floating-point and Advanced SIMD instructions.
22857@end table
22858
22859@item armv7ve
22860The extended version of the ARMv7-A architecture with support for
22861virtualization.
22862@table @samp
22863@item +fp
22864The VFPv4 floating-point instructions, with 16 double-precision registers.
22865The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
22866
22867@item +simd
22868The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
22869extension @samp{+neon-vfpv4} can be used as an alias for this extension.
22870
22871@item +vfpv3-d16
22872The VFPv3 floating-point instructions, with 16 double-precision
22873registers.
22874
22875@item +vfpv3
22876The VFPv3 floating-point instructions, with 32 double-precision
22877registers.
22878
22879@item +vfpv3-d16-fp16
22880The VFPv3 floating-point instructions, with 16 double-precision
22881registers and the half-precision floating-point conversion operations.
22882
22883@item +vfpv3-fp16
22884The VFPv3 floating-point instructions, with 32 double-precision
22885registers and the half-precision floating-point conversion operations.
22886
22887@item +vfpv4-d16
22888The VFPv4 floating-point instructions, with 16 double-precision
22889registers.
22890
22891@item +vfpv4
22892The VFPv4 floating-point instructions, with 32 double-precision
22893registers.
22894
22895@item +neon
22896The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
22897The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
22898
22899@item +neon-fp16
22900The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
22901the half-precision floating-point conversion operations.
22902
22903@item +nosimd
22904Disable the Advanced SIMD instructions (does not disable floating point).
22905
22906@item +nofp
22907Disable the floating-point and Advanced SIMD instructions.
22908@end table
22909
22910@item armv8-a
22911@table @samp
22912@item +crc
22913The Cyclic Redundancy Check (CRC) instructions.
22914@item +simd
22915The ARMv8-A Advanced SIMD and floating-point instructions.
22916@item +crypto
22917The cryptographic instructions.
22918@item +nocrypto
22919Disable the cryptographic instructions.
22920@item +nofp
22921Disable the floating-point, Advanced SIMD and cryptographic instructions.
22922@item +sb
22923Speculation Barrier Instruction.
22924@item +predres
22925Execution and Data Prediction Restriction Instructions.
22926@end table
22927
22928@item armv8.1-a
22929@table @samp
22930@item +simd
22931The ARMv8.1-A Advanced SIMD and floating-point instructions.
22932
22933@item +crypto
22934The cryptographic instructions. This also enables the Advanced SIMD and
22935floating-point instructions.
22936
22937@item +nocrypto
22938Disable the cryptographic instructions.
22939
22940@item +nofp
22941Disable the floating-point, Advanced SIMD and cryptographic instructions.
22942
22943@item +sb
22944Speculation Barrier Instruction.
22945
22946@item +predres
22947Execution and Data Prediction Restriction Instructions.
22948@end table
22949
22950@item armv8.2-a
22951@itemx armv8.3-a
22952@table @samp
22953@item +fp16
22954The half-precision floating-point data processing instructions.
22955This also enables the Advanced SIMD and floating-point instructions.
22956
22957@item +fp16fml
22958The half-precision floating-point fmla extension. This also enables
22959the half-precision floating-point extension and Advanced SIMD and
22960floating-point instructions.
22961
22962@item +simd
22963The ARMv8.1-A Advanced SIMD and floating-point instructions.
22964
22965@item +crypto
22966The cryptographic instructions. This also enables the Advanced SIMD and
22967floating-point instructions.
22968
22969@item +dotprod
22970Enable the Dot Product extension. This also enables Advanced SIMD instructions.
22971
22972@item +nocrypto
22973Disable the cryptographic extension.
22974
22975@item +nofp
22976Disable the floating-point, Advanced SIMD and cryptographic instructions.
22977
22978@item +sb
22979Speculation Barrier Instruction.
22980
22981@item +predres
22982Execution and Data Prediction Restriction Instructions.
22983
22984@item +i8mm
229858-bit Integer Matrix Multiply instructions.
22986This also enables Advanced SIMD and floating-point instructions.
22987
22988@item +bf16
22989Brain half-precision floating-point instructions.
22990This also enables Advanced SIMD and floating-point instructions.
22991@end table
22992
22993@item armv8.4-a
22994@table @samp
22995@item +fp16
22996The half-precision floating-point data processing instructions.
22997This also enables the Advanced SIMD and floating-point instructions as well
22998as the Dot Product extension and the half-precision floating-point fmla
22999extension.
23000
23001@item +simd
23002The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
23003Dot Product extension.
23004
23005@item +crypto
23006The cryptographic instructions. This also enables the Advanced SIMD and
23007floating-point instructions as well as the Dot Product extension.
23008
23009@item +nocrypto
23010Disable the cryptographic extension.
23011
23012@item +nofp
23013Disable the floating-point, Advanced SIMD and cryptographic instructions.
23014
23015@item +sb
23016Speculation Barrier Instruction.
23017
23018@item +predres
23019Execution and Data Prediction Restriction Instructions.
23020
23021@item +i8mm
230228-bit Integer Matrix Multiply instructions.
23023This also enables Advanced SIMD and floating-point instructions.
23024
23025@item +bf16
23026Brain half-precision floating-point instructions.
23027This also enables Advanced SIMD and floating-point instructions.
23028@end table
23029
23030@item armv8.5-a
23031@table @samp
23032@item +fp16
23033The half-precision floating-point data processing instructions.
23034This also enables the Advanced SIMD and floating-point instructions as well
23035as the Dot Product extension and the half-precision floating-point fmla
23036extension.
23037
23038@item +simd
23039The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
23040Dot Product extension.
23041
23042@item +crypto
23043The cryptographic instructions. This also enables the Advanced SIMD and
23044floating-point instructions as well as the Dot Product extension.
23045
23046@item +nocrypto
23047Disable the cryptographic extension.
23048
23049@item +nofp
23050Disable the floating-point, Advanced SIMD and cryptographic instructions.
23051
23052@item +i8mm
230538-bit Integer Matrix Multiply instructions.
23054This also enables Advanced SIMD and floating-point instructions.
23055
23056@item +bf16
23057Brain half-precision floating-point instructions.
23058This also enables Advanced SIMD and floating-point instructions.
23059@end table
23060
23061@item armv8.6-a
23062@table @samp
23063@item +fp16
23064The half-precision floating-point data processing instructions.
23065This also enables the Advanced SIMD and floating-point instructions as well
23066as the Dot Product extension and the half-precision floating-point fmla
23067extension.
23068
23069@item +simd
23070The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
23071Dot Product extension.
23072
23073@item +crypto
23074The cryptographic instructions. This also enables the Advanced SIMD and
23075floating-point instructions as well as the Dot Product extension.
23076
23077@item +nocrypto
23078Disable the cryptographic extension.
23079
23080@item +nofp
23081Disable the floating-point, Advanced SIMD and cryptographic instructions.
23082
23083@item +i8mm
230848-bit Integer Matrix Multiply instructions.
23085This also enables Advanced SIMD and floating-point instructions.
23086
23087@item +bf16
23088Brain half-precision floating-point instructions.
23089This also enables Advanced SIMD and floating-point instructions.
23090@end table
23091
23092@item armv7-r
23093@table @samp
23094@item +fp.sp
23095The single-precision VFPv3 floating-point instructions. The extension
23096@samp{+vfpv3xd} can be used as an alias for this extension.
23097
23098@item +fp
23099The VFPv3 floating-point instructions with 16 double-precision registers.
23100The extension +vfpv3-d16 can be used as an alias for this extension.
23101
23102@item +vfpv3xd-d16-fp16
23103The single-precision VFPv3 floating-point instructions with 16 double-precision
23104registers and the half-precision floating-point conversion operations.
23105
23106@item +vfpv3-d16-fp16
23107The VFPv3 floating-point instructions with 16 double-precision
23108registers and the half-precision floating-point conversion operations.
23109
23110@item +nofp
23111Disable the floating-point extension.
23112
23113@item +idiv
23114The ARM-state integer division instructions.
23115
23116@item +noidiv
23117Disable the ARM-state integer division extension.
23118@end table
23119
23120@item armv7e-m
23121@table @samp
23122@item +fp
23123The single-precision VFPv4 floating-point instructions.
23124
23125@item +fpv5
23126The single-precision FPv5 floating-point instructions.
23127
23128@item +fp.dp
23129The single- and double-precision FPv5 floating-point instructions.
23130
23131@item +nofp
23132Disable the floating-point extensions.
23133@end table
23134
23135@item armv8.1-m.main
23136@table @samp
23137
23138@item +dsp
23139The DSP instructions.
23140
23141@item +mve
23142The M-Profile Vector Extension (MVE) integer instructions.
23143
23144@item +mve.fp
23145The M-Profile Vector Extension (MVE) integer and single precision
23146floating-point instructions.
23147
23148@item +fp
23149The single-precision floating-point instructions.
23150
23151@item +fp.dp
23152The single- and double-precision floating-point instructions.
23153
23154@item +nofp
23155Disable the floating-point extension.
23156
23157@item +cdecp0, +cdecp1, ... , +cdecp7
23158Enable the Custom Datapath Extension (CDE) on selected coprocessors according
23159to the numbers given in the options in the range 0 to 7.
c91bb7b9
AC
23160
23161@item +pacbti
23162Enable the Pointer Authentication and Branch Target Identification Extension.
d77de738
ML
23163@end table
23164
23165@item armv8-m.main
23166@table @samp
23167@item +dsp
23168The DSP instructions.
23169
23170@item +nodsp
23171Disable the DSP extension.
23172
23173@item +fp
23174The single-precision floating-point instructions.
23175
23176@item +fp.dp
23177The single- and double-precision floating-point instructions.
23178
23179@item +nofp
23180Disable the floating-point extension.
23181
23182@item +cdecp0, +cdecp1, ... , +cdecp7
23183Enable the Custom Datapath Extension (CDE) on selected coprocessors according
23184to the numbers given in the options in the range 0 to 7.
23185@end table
23186
23187@item armv8-r
23188@table @samp
23189@item +crc
23190The Cyclic Redundancy Check (CRC) instructions.
23191@item +fp.sp
23192The single-precision FPv5 floating-point instructions.
23193@item +simd
23194The ARMv8-A Advanced SIMD and floating-point instructions.
23195@item +crypto
23196The cryptographic instructions.
23197@item +nocrypto
23198Disable the cryptographic instructions.
23199@item +nofp
23200Disable the floating-point, Advanced SIMD and cryptographic instructions.
23201@end table
23202
23203@end table
23204
23205@option{-march=native} causes the compiler to auto-detect the architecture
23206of the build computer. At present, this feature is only supported on
23207GNU/Linux, and not all architectures are recognized. If the auto-detect
23208is unsuccessful the option has no effect.
23209
d77de738 23210@opindex mtune
ddf6fe37 23211@item -mtune=@var{name}
d77de738
ML
23212This option specifies the name of the target ARM processor for
23213which GCC should tune the performance of the code.
23214For some ARM implementations better performance can be obtained by using
23215this option.
23216Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
23217@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
23218@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
23219@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
23220@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
23221@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
23222@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
23223@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
23224@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
23225@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
23226@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
23227@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
23228@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
23229@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
23230@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
23231@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
23232@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
23233@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
23234@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
43c4f982 23235@samp{cortex-m35p}, @samp{cortex-m52}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
ccfd1e7f 23236@samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
d77de738
ML
23237@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
23238@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
23239@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
23240@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
23241@samp{xgene1}.
23242
23243Additionally, this option can specify that GCC should tune the performance
23244of the code for a big.LITTLE system. Permissible names are:
23245@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
23246@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
23247@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
23248@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
23249
23250@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
23251performance for a blend of processors within architecture @var{arch}.
23252The aim is to generate code that run well on the current most popular
23253processors, balancing between optimizations that benefit some CPUs in the
23254range, and avoiding performance pitfalls of other CPUs. The effects of
23255this option may change in future GCC versions as CPU models come and go.
23256
23257@option{-mtune} permits the same extension options as @option{-mcpu}, but
23258the extension options do not affect the tuning of the generated code.
23259
23260@option{-mtune=native} causes the compiler to auto-detect the CPU
23261of the build computer. At present, this feature is only supported on
23262GNU/Linux, and not all architectures are recognized. If the auto-detect is
23263unsuccessful the option has no effect.
23264
d77de738 23265@opindex mcpu
ddf6fe37 23266@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
23267This specifies the name of the target ARM processor. GCC uses this name
23268to derive the name of the target ARM architecture (as if specified
23269by @option{-march}) and the ARM processor type for which to tune for
23270performance (as if specified by @option{-mtune}). Where this option
23271is used in conjunction with @option{-march} or @option{-mtune},
23272those options take precedence over the appropriate part of this option.
23273
23274Many of the supported CPUs implement optional architectural
23275extensions. Where this is so the architectural extensions are
23276normally enabled by default. If implementations that lack the
23277extension exist, then the extension syntax can be used to disable
23278those extensions that have been omitted. For floating-point and
23279Advanced SIMD (Neon) instructions, the settings of the options
23280@option{-mfloat-abi} and @option{-mfpu} must also be considered:
23281floating-point and Advanced SIMD instructions will only be used if
23282@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
23283@option{-mfpu} other than @samp{auto} will override the available
23284floating-point and SIMD extension instructions.
23285
23286For example, @samp{cortex-a9} can be found in three major
23287configurations: integer only, with just a floating-point unit or with
23288floating-point and Advanced SIMD. The default is to enable all the
23289instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
23290be used to disable just the SIMD or both the SIMD and floating-point
23291instructions respectively.
23292
23293Permissible names for this option are the same as those for
23294@option{-mtune}.
23295
23296The following extension options are common to the listed CPUs:
23297
23298@table @samp
23299@item +nodsp
ccfd1e7f 23300Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
43c4f982
CJW
23301@samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
23302Also disable the M-Profile Vector Extension (MVE) integer and
23303single precision floating-point instructions on
23304@samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
ccfd1e7f
SP
23305
23306@item +nopacbti
23307Disable the Pointer Authentication and Branch Target Identification Extension
43c4f982 23308on @samp{cortex-m52} and @samp{cortex-m85}.
d77de738
ML
23309
23310@item +nomve
23311Disable the M-Profile Vector Extension (MVE) integer and single precision
43c4f982 23312floating-point instructions on @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
23313
23314@item +nomve.fp
23315Disable the M-Profile Vector Extension (MVE) single precision floating-point
43c4f982 23316instructions on @samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
d77de738 23317
798a0d05
SP
23318@item +cdecp0, +cdecp1, ... , +cdecp7
23319Enable the Custom Datapath Extension (CDE) on selected coprocessors according
43c4f982 23320to the numbers given in the options in the range 0 to 7 on @samp{cortex-m52} and @samp{cortex-m55}.
798a0d05 23321
d77de738
ML
23322@item +nofp
23323Disables the floating-point instructions on @samp{arm9e},
23324@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
23325@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
23326@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
ccfd1e7f 23327@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
43c4f982 23328@samp{cortex-m52}, @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
23329Disables the floating-point and SIMD instructions on
23330@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
23331@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
23332@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
23333@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
23334@samp{cortex-a53} and @samp{cortex-a55}.
23335
23336@item +nofp.dp
23337Disables the double-precision component of the floating-point instructions
23338on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
23339@samp{cortex-r52plus} and @samp{cortex-m7}.
23340
23341@item +nosimd
23342Disables the SIMD (but not floating-point) instructions on
23343@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
23344and @samp{cortex-a9}.
23345
23346@item +crypto
23347Enables the cryptographic instructions on @samp{cortex-a32},
23348@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
23349@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
23350@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
23351@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
23352@samp{cortex-a75.cortex-a55}.
23353@end table
23354
23355Additionally the @samp{generic-armv7-a} pseudo target defaults to
23356VFPv3 with 16 double-precision registers. It supports the following
23357extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
23358@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
23359@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
23360@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
23361the extensions to @option{-march=armv7-a}.
23362
23363@option{-mcpu=generic-@var{arch}} is also permissible, and is
23364equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
23365See @option{-mtune} for more information.
23366
23367@option{-mcpu=native} causes the compiler to auto-detect the CPU
23368of the build computer. At present, this feature is only supported on
23369GNU/Linux, and not all architectures are recognized. If the auto-detect
23370is unsuccessful the option has no effect.
23371
d77de738 23372@opindex mfpu
ddf6fe37 23373@item -mfpu=@var{name}
d77de738
ML
23374This specifies what floating-point hardware (or hardware emulation) is
23375available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
23376@samp{vfpv3},
23377@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
23378@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
23379@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
23380@samp{fpv5-d16}, @samp{fpv5-sp-d16},
23381@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
23382Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
23383is an alias for @samp{vfpv2}.
23384
23385The setting @samp{auto} is the default and is special. It causes the
23386compiler to select the floating-point and Advanced SIMD instructions
23387based on the settings of @option{-mcpu} and @option{-march}.
23388
23389If the selected floating-point hardware includes the NEON extension
23390(e.g.@: @option{-mfpu=neon}), note that floating-point
23391operations are not generated by GCC's auto-vectorization pass unless
23392@option{-funsafe-math-optimizations} is also specified. This is
23393because NEON hardware does not fully implement the IEEE 754 standard for
23394floating-point arithmetic (in particular denormal values are treated as
23395zero), so the use of NEON instructions may lead to a loss of precision.
23396
23397You 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}).
23398
d77de738 23399@opindex mfp16-format
ddf6fe37 23400@item -mfp16-format=@var{name}
d77de738
ML
23401Specify the format of the @code{__fp16} half-precision floating-point type.
23402Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
23403the default is @samp{none}, in which case the @code{__fp16} type is not
23404defined. @xref{Half-Precision}, for more information.
23405
d77de738 23406@opindex mstructure-size-boundary
ddf6fe37 23407@item -mstructure-size-boundary=@var{n}
d77de738
ML
23408The sizes of all structures and unions are rounded up to a multiple
23409of the number of bits set by this option. Permissible values are 8, 32
23410and 64. The default value varies for different toolchains. For the COFF
23411targeted toolchain the default value is 8. A value of 64 is only allowed
23412if the underlying ABI supports it.
23413
23414Specifying a larger number can produce faster, more efficient code, but
23415can also increase the size of the program. Different values are potentially
23416incompatible. Code compiled with one value cannot necessarily expect to
23417work with code or libraries compiled with another value, if they exchange
23418information using structures or unions.
23419
23420This option is deprecated.
23421
d77de738 23422@opindex mabort-on-noreturn
ddf6fe37 23423@item -mabort-on-noreturn
d77de738
ML
23424Generate a call to the function @code{abort} at the end of a
23425@code{noreturn} function. It is executed if the function tries to
23426return.
23427
d77de738
ML
23428@opindex mlong-calls
23429@opindex mno-long-calls
ddf6fe37
AA
23430@item -mlong-calls
23431@itemx -mno-long-calls
d77de738
ML
23432Tells the compiler to perform function calls by first loading the
23433address of the function into a register and then performing a subroutine
23434call on this register. This switch is needed if the target function
23435lies outside of the 64-megabyte addressing range of the offset-based
23436version of subroutine call instruction.
23437
23438Even if this switch is enabled, not all function calls are turned
23439into long calls. The heuristic is that static functions, functions
23440that have the @code{short_call} attribute, functions that are inside
23441the scope of a @code{#pragma no_long_calls} directive, and functions whose
23442definitions have already been compiled within the current compilation
23443unit are not turned into long calls. The exceptions to this rule are
23444that weak function definitions, functions with the @code{long_call}
23445attribute or the @code{section} attribute, and functions that are within
23446the scope of a @code{#pragma long_calls} directive are always
23447turned into long calls.
23448
23449This feature is not enabled by default. Specifying
23450@option{-mno-long-calls} restores the default behavior, as does
23451placing the function calls within the scope of a @code{#pragma
23452long_calls_off} directive. Note these switches have no effect on how
23453the compiler generates code to handle function calls via function
23454pointers.
23455
d77de738 23456@opindex msingle-pic-base
ddf6fe37 23457@item -msingle-pic-base
d77de738
ML
23458Treat the register used for PIC addressing as read-only, rather than
23459loading it in the prologue for each function. The runtime system is
23460responsible for initializing this register with an appropriate value
23461before execution begins.
23462
d77de738 23463@opindex mpic-register
ddf6fe37 23464@item -mpic-register=@var{reg}
d77de738
ML
23465Specify the register to be used for PIC addressing.
23466For standard PIC base case, the default is any suitable register
23467determined by compiler. For single PIC base case, the default is
23468@samp{R9} if target is EABI based or stack-checking is enabled,
23469otherwise the default is @samp{R10}.
23470
d77de738 23471@opindex mpic-data-is-text-relative
ddf6fe37 23472@item -mpic-data-is-text-relative
d77de738
ML
23473Assume that the displacement between the text and data segments is fixed
23474at static link time. This permits using PC-relative addressing
23475operations to access data known to be in the data segment. For
23476non-VxWorks RTP targets, this option is enabled by default. When
23477disabled on such targets, it will enable @option{-msingle-pic-base} by
23478default.
23479
d77de738 23480@opindex mpoke-function-name
ddf6fe37 23481@item -mpoke-function-name
d77de738
ML
23482Write the name of each function into the text section, directly
23483preceding the function prologue. The generated code is similar to this:
23484
23485@smallexample
23486 t0
23487 .ascii "arm_poke_function_name", 0
23488 .align
23489 t1
23490 .word 0xff000000 + (t1 - t0)
23491 arm_poke_function_name
23492 mov ip, sp
23493 stmfd sp!, @{fp, ip, lr, pc@}
23494 sub fp, ip, #4
23495@end smallexample
23496
23497When performing a stack backtrace, code can inspect the value of
23498@code{pc} stored at @code{fp + 0}. If the trace function then looks at
23499location @code{pc - 12} and the top 8 bits are set, then we know that
23500there is a function name embedded immediately preceding this location
23501and has length @code{((pc[-3]) & 0xff000000)}.
23502
d77de738
ML
23503@opindex marm
23504@opindex mthumb
ddf6fe37
AA
23505@item -mthumb
23506@itemx -marm
d77de738
ML
23507
23508Select between generating code that executes in ARM and Thumb
23509states. The default for most configurations is to generate code
23510that executes in ARM state, but the default can be changed by
23511configuring GCC with the @option{--with-mode=}@var{state}
23512configure option.
23513
23514You can also override the ARM and Thumb mode for each function
23515by using the @code{target("thumb")} and @code{target("arm")} function attributes
23516(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
23517
d77de738 23518@opindex mflip-thumb
ddf6fe37 23519@item -mflip-thumb
d77de738
ML
23520Switch ARM/Thumb modes on alternating functions.
23521This option is provided for regression testing of mixed Thumb/ARM code
23522generation, and is not intended for ordinary use in compiling code.
23523
d77de738 23524@opindex mtpcs-frame
ddf6fe37 23525@item -mtpcs-frame
d77de738
ML
23526Generate a stack frame that is compliant with the Thumb Procedure Call
23527Standard for all non-leaf functions. (A leaf function is one that does
23528not call any other functions.) The default is @option{-mno-tpcs-frame}.
23529
d77de738 23530@opindex mtpcs-leaf-frame
ddf6fe37 23531@item -mtpcs-leaf-frame
d77de738
ML
23532Generate a stack frame that is compliant with the Thumb Procedure Call
23533Standard for all leaf functions. (A leaf function is one that does
23534not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
23535
d77de738 23536@opindex mcallee-super-interworking
ddf6fe37 23537@item -mcallee-super-interworking
d77de738
ML
23538Gives all externally visible functions in the file being compiled an ARM
23539instruction set header which switches to Thumb mode before executing the
23540rest of the function. This allows these functions to be called from
23541non-interworking code. This option is not valid in AAPCS configurations
23542because interworking is enabled by default.
23543
d77de738 23544@opindex mcaller-super-interworking
ddf6fe37 23545@item -mcaller-super-interworking
d77de738
ML
23546Allows calls via function pointers (including virtual functions) to
23547execute correctly regardless of whether the target code has been
23548compiled for interworking or not. There is a small overhead in the cost
23549of executing a function pointer if this option is enabled. This option
23550is not valid in AAPCS configurations because interworking is enabled
23551by default.
23552
d77de738 23553@opindex mtp
ddf6fe37 23554@item -mtp=@var{name}
cca8d9e5
KT
23555Specify the access model for the thread local storage pointer. The model
23556@samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted
23557models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch
23558the thread pointer from the corresponding system register directly
23559(supported from the arm6k architecture and later). These system registers
23560are accessed through the CP15 co-processor interface and the argument
23561@samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}.
23562The argument @samp{auto} uses the best available method for the selected
23563processor. The default setting is @samp{auto}.
d77de738 23564
d77de738 23565@opindex mtls-dialect
ddf6fe37 23566@item -mtls-dialect=@var{dialect}
d77de738
ML
23567Specify the dialect to use for accessing thread local storage. Two
23568@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
23569@samp{gnu} dialect selects the original GNU scheme for supporting
23570local and global dynamic TLS models. The @samp{gnu2} dialect
23571selects the GNU descriptor scheme, which provides better performance
23572for shared libraries. The GNU descriptor scheme is compatible with
23573the original scheme, but does require new assembler, linker and
23574library support. Initial and local exec TLS models are unaffected by
23575this option and always use the original scheme.
23576
d77de738 23577@opindex mword-relocations
ddf6fe37 23578@item -mword-relocations
d77de738
ML
23579Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
23580This is enabled by default on targets (uClinux, SymbianOS) where the runtime
23581loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
23582is specified. This option conflicts with @option{-mslow-flash-data}.
23583
d77de738 23584@opindex mfix-cortex-m3-ldrd
ddf6fe37 23585@item -mfix-cortex-m3-ldrd
d77de738
ML
23586Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
23587with overlapping destination and base registers are used. This option avoids
23588generating these instructions. This option is enabled by default when
23589@option{-mcpu=cortex-m3} is specified.
23590
23591@item -mfix-cortex-a57-aes-1742098
23592@itemx -mno-fix-cortex-a57-aes-1742098
23593@itemx -mfix-cortex-a72-aes-1655431
23594@itemx -mno-fix-cortex-a72-aes-1655431
23595Enable (disable) mitigation for an erratum on Cortex-A57 and
23596Cortex-A72 that affects the AES cryptographic instructions. This
23597option is enabled by default when either @option{-mcpu=cortex-a57} or
23598@option{-mcpu=cortex-a72} is specified.
23599
d77de738
ML
23600@opindex munaligned-access
23601@opindex mno-unaligned-access
ddf6fe37
AA
23602@item -munaligned-access
23603@itemx -mno-unaligned-access
d77de738
ML
23604Enables (or disables) reading and writing of 16- and 32- bit values
23605from addresses that are not 16- or 32- bit aligned. By default
23606unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
23607ARMv8-M Baseline architectures, and enabled for all other
23608architectures. If unaligned access is not enabled then words in packed
23609data structures are accessed a byte at a time.
23610
23611The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
23612generated object file to either true or false, depending upon the
23613setting of this option. If unaligned access is enabled then the
23614preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
23615defined.
23616
d77de738 23617@opindex mneon-for-64bits
ddf6fe37 23618@item -mneon-for-64bits
d77de738
ML
23619This option is deprecated and has no effect.
23620
d77de738 23621@opindex mslow-flash-data
ddf6fe37 23622@item -mslow-flash-data
d77de738
ML
23623Assume loading data from flash is slower than fetching instruction.
23624Therefore literal load is minimized for better performance.
23625This option is only supported when compiling for ARMv7 M-profile and
23626off by default. It conflicts with @option{-mword-relocations}.
23627
d77de738 23628@opindex masm-syntax-unified
ddf6fe37 23629@item -masm-syntax-unified
d77de738
ML
23630Assume inline assembler is using unified asm syntax. The default is
23631currently off which implies divided syntax. This option has no impact
23632on Thumb2. However, this may change in future releases of GCC.
23633Divided syntax should be considered deprecated.
23634
d77de738 23635@opindex mrestrict-it
ddf6fe37 23636@item -mrestrict-it
d77de738
ML
23637Restricts generation of IT blocks to conform to the rules of ARMv8-A.
23638IT blocks can only contain a single 16-bit instruction from a select
23639set of instructions. This option is on by default for ARMv8-A Thumb mode.
23640
d77de738 23641@opindex mprint-tune-info
ddf6fe37 23642@item -mprint-tune-info
d77de738
ML
23643Print CPU tuning information as comment in assembler file. This is
23644an option used only for regression testing of the compiler and not
23645intended for ordinary use in compiling code. This option is disabled
23646by default.
23647
d77de738 23648@opindex mverbose-cost-dump
ddf6fe37 23649@item -mverbose-cost-dump
d77de738
ML
23650Enable verbose cost model dumping in the debug dump files. This option is
23651provided for use in debugging the compiler.
23652
d77de738 23653@opindex mpure-code
ddf6fe37 23654@item -mpure-code
d77de738
ML
23655Do not allow constant data to be placed in code sections.
23656Additionally, when compiling for ELF object format give all text sections the
23657ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
23658is only available when generating non-pic code for M-profile targets.
23659
d77de738 23660@opindex mcmse
ddf6fe37 23661@item -mcmse
d77de738
ML
23662Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
23663Development Tools Engineering Specification", which can be found on
23664@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
23665
d77de738 23666@opindex mfix-cmse-cve-2021-35465
ddf6fe37 23667@item -mfix-cmse-cve-2021-35465
d77de738
ML
23668Mitigate against a potential security issue with the @code{VLLDM} instruction
23669in some M-profile devices when using CMSE (CVE-2021-365465). This option is
23670enabled by default when the option @option{-mcpu=} is used with
43c4f982
CJW
23671@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m52}, @code{cortex-m55},
23672@code{cortex-m85} or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465}
23673can be used to disable the mitigation.
d77de738 23674
d77de738
ML
23675@opindex mstack-protector-guard
23676@opindex mstack-protector-guard-offset
ddf6fe37
AA
23677@item -mstack-protector-guard=@var{guard}
23678@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
23679Generate stack protection code using canary at @var{guard}. Supported
23680locations are @samp{global} for a global canary or @samp{tls} for a
23681canary accessible via the TLS register. The option
23682@option{-mstack-protector-guard-offset=} is for use with
23683@option{-fstack-protector-guard=tls} and not for use in user-land code.
23684
d77de738
ML
23685@opindex mfdpic
23686@opindex mno-fdpic
ddf6fe37
AA
23687@item -mfdpic
23688@itemx -mno-fdpic
d77de738
ML
23689Select the FDPIC ABI, which uses 64-bit function descriptors to
23690represent pointers to functions. When the compiler is configured for
23691@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
23692and implies @option{-fPIE} if none of the PIC/PIE-related options is
23693provided. On other targets, it only enables the FDPIC-specific code
23694generation features, and the user should explicitly provide the
23695PIC/PIE-related options as needed.
23696
23697Note that static linking is not supported because it would still
23698involve the dynamic linker when the program self-relocates. If such
23699behavior is acceptable, use -static and -Wl,-dynamic-linker options.
23700
23701The opposite @option{-mno-fdpic} option is useful (and required) to
23702build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
23703toolchain as the one used to build the userland programs.
23704
14fab5fb 23705@opindex mbranch-protection
ddf6fe37 23706@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
14fab5fb
AC
23707Enable branch protection features (armv8.1-m.main only).
23708@samp{none} generate code without branch protection or return address
23709signing.
23710@samp{standard[+@var{leaf}]} generate code with all branch protection
23711features enabled at their standard level.
23712@samp{pac-ret[+@var{leaf}]} generate code with return address signing
23713set to its standard level, which is to sign all functions that save
23714the return address to memory.
23715@samp{leaf} When return address signing is enabled, also sign leaf
23716functions even if they do not write the return address to memory.
23717+@samp{bti} Add landing-pad instructions at the permitted targets of
23718indirect branch instructions.
23719
23720If the @samp{+pacbti} architecture extension is not enabled, then all
23721branch protection and return address signing operations are
23722constrained to use only the instructions defined in the
23723architectural-NOP space. The generated code will remain
23724backwards-compatible with earlier versions of the architecture, but
23725the additional security can be enabled at run time on processors that
23726support the @samp{PACBTI} extension.
23727
23728Branch target enforcement using BTI can only be enabled at runtime if
23729all code in the application has been compiled with at least
23730@samp{-mbranch-protection=bti}.
23731
23732Any setting other than @samp{none} is supported only on armv8-m.main
23733or later.
23734
23735The default is to generate code without branch protection or return
23736address signing.
23737
d77de738
ML
23738@end table
23739
23740@node AVR Options
23741@subsection AVR Options
23742@cindex AVR Options
23743
23744These options are defined for AVR implementations:
23745
23746@table @gcctabopt
d77de738 23747@opindex mmcu
ddf6fe37 23748@item -mmcu=@var{mcu}
e63ae908
GJL
23749Specify the AVR instruction set architecture (ISA) or device type.
23750The default for this option is@tie{}@code{avr2}.
23751
23752The following AVR devices and ISAs are supported.
23753@emph{Note:} A complete device support consists of
23754startup code @code{crt@var{mcu}.o}, a device header @code{avr/io*.h},
23755a device library @code{lib@var{mcu}.a} and a
23756@uref{https://gcc.gnu.org/wiki/avr-gcc#spec-files,device-specs} file
23757@code{specs-@var{mcu}}. Only the latter is provided by the compiler
23758according the supported @code{@var{mcu}}s below. The rest is supported
23759by @w{@uref{https://www.nongnu.org/avr-libc/,AVR-LibC}}, or by means of
23760@uref{https://gcc.gnu.org/wiki/avr-gcc#atpack,@code{atpack}} files
23761from the hardware manufacturer.
23762
23763@c Auto-generated. Re-build when new devices are added to avr-mcus.def
23764@c by running "make avr-mcus" in $builddir/gcc.
d77de738
ML
23765@include avr-mmcu.texi
23766
d77de738 23767@opindex mabsdata
ddf6fe37 23768@item -mabsdata
d77de738
ML
23769
23770Assume that all data in static storage can be accessed by LDS / STS
23771instructions. This option has only an effect on reduced Tiny devices like
23772ATtiny40. See also the @code{absdata}
23773@ref{AVR Variable Attributes,variable attribute}.
23774
d77de738 23775@opindex maccumulate-args
ddf6fe37 23776@item -maccumulate-args
d77de738
ML
23777Accumulate outgoing function arguments and acquire/release the needed
23778stack space for outgoing function arguments once in function
23779prologue/epilogue. Without this option, outgoing arguments are pushed
23780before calling a function and popped afterwards.
23781
23782Popping the arguments after the function call can be expensive on
23783AVR so that accumulating the stack space might lead to smaller
23784executables because arguments need not be removed from the
23785stack after such a function call.
23786
23787This option can lead to reduced code size for functions that perform
23788several calls to functions that get their arguments on the stack like
23789calls to printf-like functions.
23790
d77de738 23791@opindex mbranch-cost
ddf6fe37 23792@item -mbranch-cost=@var{cost}
d77de738
ML
23793Set the branch costs for conditional branch instructions to
23794@var{cost}. Reasonable values for @var{cost} are small, non-negative
23795integers. The default branch cost is 0.
23796
d77de738 23797@opindex mcall-prologues
ddf6fe37 23798@item -mcall-prologues
d77de738
ML
23799Functions prologues/epilogues are expanded as calls to appropriate
23800subroutines. Code size is smaller.
23801
cda38361
GJL
23802@opindex mfuse-add
23803@item -mfuse-add
23804@itemx -mno-fuse-add
23805@itemx -mfuse-add=@var{level}
23806Optimize indirect memory accesses on reduced Tiny devices.
23807The default uses @code{@var{level}=1} for optimizations @option{-Og}
23808and @option{-O1}, and @code{@var{level}=2} for higher optimizations.
270d0f69 23809Valid values for @var{level} are @code{0}, @code{1} and @code{2}.
cda38361 23810
d77de738
ML
23811@opindex mdouble
23812@opindex mlong-double
ddf6fe37
AA
23813@item -mdouble=@var{bits}
23814@itemx -mlong-double=@var{bits}
d77de738
ML
23815Set the size (in bits) of the @code{double} or @code{long double} type,
23816respectively. Possible values for @var{bits} are 32 and 64.
23817Whether or not a specific value for @var{bits} is allowed depends on
23818the @code{--with-double=} and @code{--with-long-double=}
23819@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
23820and the same applies for the default values of the options.
23821
d77de738 23822@opindex mgas-isr-prologues
ddf6fe37 23823@item -mgas-isr-prologues
d77de738
ML
23824Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
23825instruction supported by GNU Binutils.
23826If this option is on, the feature can still be disabled for individual
23827ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
23828function attribute. This feature is activated per default
23829if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
23830and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
23831
d77de738 23832@opindex mint8
ddf6fe37 23833@item -mint8
d77de738
ML
23834Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
23835@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
23836and @code{long long} is 4 bytes. Please note that this option does not
23837conform to the C standards, but it results in smaller code
23838size.
23839
d77de738 23840@opindex mmain-is-OS_task
ddf6fe37 23841@item -mmain-is-OS_task
d77de738
ML
23842Do not save registers in @code{main}. The effect is the same like
23843attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
23844to @code{main}. It is activated per default if optimization is on.
23845
d77de738 23846@opindex mno-interrupts
ddf6fe37 23847@item -mno-interrupts
d77de738
ML
23848Generated code is not compatible with hardware interrupts.
23849Code size is smaller.
23850
d77de738 23851@opindex mrelax
ddf6fe37 23852@item -mrelax
d77de738
ML
23853Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
23854@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
23855Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
23856the assembler's command line and the @option{--relax} option to the
23857linker's command line.
23858
23859Jump relaxing is performed by the linker because jump offsets are not
23860known before code is located. Therefore, the assembler code generated by the
23861compiler is the same, but the instructions in the executable may
23862differ from instructions in the assembler code.
23863
23864Relaxing must be turned on if linker stubs are needed, see the
23865section on @code{EIND} and linker stubs below.
23866
48448055
GJL
23867@opindex mrodata-in-ram
23868@item -mrodata-in-ram
23869@itemx -mno-rodata-in-ram
23870Locate the @code{.rodata} sections for read-only data in RAM resp.@:
23871in program memory.
23872For most devices, there is no choice and this option acts rather
23873like an assertion.
23874
23875Since v14 and for the AVR64* and AVR128* devices, @code{.rodata}
23876is located in flash memory per default, provided the required GNU Binutils
23877support (@w{@uref{https://sourceware.org/PR31124,PR31124}}) is available.
23878In that case, @option{-mrodata-in-ram} can be used to return to the old
23879layout with @code{.rodata} in RAM.
23880
d77de738 23881@opindex mstrict-X
ddf6fe37 23882@item -mstrict-X
d77de738
ML
23883Use address register @code{X} in a way proposed by the hardware. This means
23884that @code{X} is only used in indirect, post-increment or
23885pre-decrement addressing.
23886
23887Without this option, the @code{X} register may be used in the same way
23888as @code{Y} or @code{Z} which then is emulated by additional
23889instructions.
23890For example, loading a value with @code{X+const} addressing with a
23891small non-negative @code{const < 64} to a register @var{Rn} is
23892performed as
23893
23894@example
23895adiw r26, const ; X += const
23896ld @var{Rn}, X ; @var{Rn} = *X
23897sbiw r26, const ; X -= const
23898@end example
23899
d77de738 23900@opindex mtiny-stack
ddf6fe37 23901@item -mtiny-stack
d77de738
ML
23902Only change the lower 8@tie{}bits of the stack pointer.
23903
d77de738 23904@opindex mfract-convert-truncate
ddf6fe37 23905@item -mfract-convert-truncate
d77de738
ML
23906Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
23907
d77de738 23908@opindex nodevicelib
ddf6fe37 23909@item -nodevicelib
d77de738
ML
23910Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
23911
d77de738 23912@opindex nodevicespecs
ddf6fe37 23913@item -nodevicespecs
d77de738
ML
23914Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
23915command line. The user takes responsibility for supplying the sub-processes
23916like compiler proper, assembler and linker with appropriate command line
23917options. This means that the user has to supply her private device specs
23918file by means of @option{-specs=@var{path-to-specs-file}}. There is no
23919more need for option @option{-mmcu=@var{mcu}}.
23920
23921This option can also serve as a replacement for the older way of
23922specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
23923which contains a folder named @code{device-specs} which contains a specs file named
23924@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
23925
d77de738
ML
23926@opindex Waddr-space-convert
23927@opindex Wno-addr-space-convert
ddf6fe37 23928@item -Waddr-space-convert
d77de738
ML
23929Warn about conversions between address spaces in the case where the
23930resulting address space is not contained in the incoming address space.
23931
d77de738
ML
23932@opindex Wmisspelled-isr
23933@opindex Wno-misspelled-isr
ddf6fe37 23934@item -Wmisspelled-isr
d77de738
ML
23935Warn if the ISR is misspelled, i.e.@: without __vector prefix.
23936Enabled by default.
23937@end table
23938
b793c218 23939@anchor{eind}
d77de738
ML
23940@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
23941@cindex @code{EIND}
23942Pointers in the implementation are 16@tie{}bits wide.
23943The address of a function or label is represented as word address so
23944that indirect jumps and calls can target any code address in the
23945range of 64@tie{}Ki words.
23946
23947In order to facilitate indirect jump on devices with more than 128@tie{}Ki
23948bytes of program memory space, there is a special function register called
23949@code{EIND} that serves as most significant part of the target address
23950when @code{EICALL} or @code{EIJMP} instructions are used.
23951
23952Indirect jumps and calls on these devices are handled as follows by
23953the compiler and are subject to some limitations:
23954
23955@itemize @bullet
23956
23957@item
23958The compiler never sets @code{EIND}.
23959
23960@item
23961The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
23962instructions or might read @code{EIND} directly in order to emulate an
23963indirect call/jump by means of a @code{RET} instruction.
23964
23965@item
23966The compiler assumes that @code{EIND} never changes during the startup
23967code or during the application. In particular, @code{EIND} is not
23968saved/restored in function or interrupt service routine
23969prologue/epilogue.
23970
23971@item
23972For indirect calls to functions and computed goto, the linker
23973generates @emph{stubs}. Stubs are jump pads sometimes also called
23974@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
23975The stub contains a direct jump to the desired address.
23976
23977@item
23978Linker relaxation must be turned on so that the linker generates
23979the stubs correctly in all situations. See the compiler option
23980@option{-mrelax} and the linker option @option{--relax}.
23981There are corner cases where the linker is supposed to generate stubs
23982but aborts without relaxation and without a helpful error message.
23983
23984@item
23985The default linker script is arranged for code with @code{EIND = 0}.
23986If code is supposed to work for a setup with @code{EIND != 0}, a custom
23987linker script has to be used in order to place the sections whose
23988name start with @code{.trampolines} into the segment where @code{EIND}
23989points to.
23990
23991@item
23992The startup code from libgcc never sets @code{EIND}.
23993Notice that startup code is a blend of code from libgcc and AVR-LibC.
23994For the impact of AVR-LibC on @code{EIND}, see the
a65da9be 23995@w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
d77de738
ML
23996
23997@item
23998It is legitimate for user-specific startup code to set up @code{EIND}
23999early, for example by means of initialization code located in
24000section @code{.init3}. Such code runs prior to general startup code
24001that initializes RAM and calls constructors, but after the bit
24002of startup code from AVR-LibC that sets @code{EIND} to the segment
24003where the vector table is located.
24004@example
24005#include <avr/io.h>
24006
24007static void
24008__attribute__((section(".init3"),naked,used,no_instrument_function))
24009init3_set_eind (void)
24010@{
24011 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
24012 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
24013@}
24014@end example
24015
24016@noindent
24017The @code{__trampolines_start} symbol is defined in the linker script.
24018
24019@item
24020Stubs are generated automatically by the linker if
24021the following two conditions are met:
24022@itemize @minus
24023
24024@item The address of a label is taken by means of the @code{gs} modifier
24025(short for @emph{generate stubs}) like so:
24026@example
24027LDI r24, lo8(gs(@var{func}))
24028LDI r25, hi8(gs(@var{func}))
24029@end example
24030@item The final location of that label is in a code segment
24031@emph{outside} the segment where the stubs are located.
24032@end itemize
24033
24034@item
24035The compiler emits such @code{gs} modifiers for code labels in the
24036following situations:
24037@itemize @minus
24038@item Taking address of a function or code label.
24039@item Computed goto.
24040@item If prologue-save function is used, see @option{-mcall-prologues}
24041command-line option.
24042@item Switch/case dispatch tables. If you do not want such dispatch
24043tables you can specify the @option{-fno-jump-tables} command-line option.
24044@item C and C++ constructors/destructors called during startup/shutdown.
24045@item If the tools hit a @code{gs()} modifier explained above.
24046@end itemize
24047
24048@item
24049Jumping to non-symbolic addresses like so is @emph{not} supported:
24050
24051@example
24052int main (void)
24053@{
24054 /* Call function at word address 0x2 */
24055 return ((int(*)(void)) 0x2)();
24056@}
24057@end example
24058
24059Instead, a stub has to be set up, i.e.@: the function has to be called
24060through a symbol (@code{func_4} in the example):
24061
24062@example
24063int main (void)
24064@{
24065 extern int func_4 (void);
24066
24067 /* Call function at byte address 0x4 */
24068 return func_4();
24069@}
24070@end example
24071
24072and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
24073Alternatively, @code{func_4} can be defined in the linker script.
24074@end itemize
24075
b793c218 24076@anchor{ramp}
d77de738
ML
24077@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
24078@cindex @code{RAMPD}
24079@cindex @code{RAMPX}
24080@cindex @code{RAMPY}
24081@cindex @code{RAMPZ}
24082Some AVR devices support memories larger than the 64@tie{}KiB range
24083that can be accessed with 16-bit pointers. To access memory locations
24084outside this 64@tie{}KiB range, the content of a @code{RAMP}
24085register is used as high part of the address:
24086The @code{X}, @code{Y}, @code{Z} address register is concatenated
24087with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
24088register, respectively, to get a wide address. Similarly,
24089@code{RAMPD} is used together with direct addressing.
24090
24091@itemize
24092@item
24093The startup code initializes the @code{RAMP} special function
24094registers with zero.
24095
24096@item
24097If a @ref{AVR Named Address Spaces,named address space} other than
24098generic or @code{__flash} is used, then @code{RAMPZ} is set
24099as needed before the operation.
24100
24101@item
24102If the device supports RAM larger than 64@tie{}KiB and the compiler
24103needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
24104is reset to zero after the operation.
24105
24106@item
24107If the device comes with a specific @code{RAMP} register, the ISR
24108prologue/epilogue saves/restores that SFR and initializes it with
24109zero in case the ISR code might (implicitly) use it.
24110
24111@item
24112RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
24113If you use inline assembler to read from locations outside the
2411416-bit address range and change one of the @code{RAMP} registers,
24115you must reset it to zero after the access.
24116
24117@end itemize
24118
b793c218 24119@anchor{avr-macros}
d77de738
ML
24120@subsubsection AVR Built-in Macros
24121
24122GCC defines several built-in macros so that the user code can test
24123for the presence or absence of features. Almost any of the following
24124built-in macros are deduced from device capabilities and thus
24125triggered by the @option{-mmcu=} command-line option.
24126
24127For even more AVR-specific built-in macros see
24128@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
24129
24130@table @code
24131
24132@item __AVR_ARCH__
24133Build-in macro that resolves to a decimal number that identifies the
24134architecture and depends on the @option{-mmcu=@var{mcu}} option.
24135Possible values are:
24136
24137@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
24138@code{4}, @code{5}, @code{51}, @code{6}
24139
24140for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
24141@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
24142
24143respectively and
24144
24145@code{100},
24146@code{102}, @code{103}, @code{104},
24147@code{105}, @code{106}, @code{107}
24148
24149for @var{mcu}=@code{avrtiny},
24150@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
24151@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
24152If @var{mcu} specifies a device, this built-in macro is set
24153accordingly. For example, with @option{-mmcu=atmega8} the macro is
24154defined to @code{4}.
24155
24156@item __AVR_@var{Device}__
24157Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
24158the device's name. For example, @option{-mmcu=atmega8} defines the
24159built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
24160@code{__AVR_ATtiny261A__}, etc.
24161
24162The built-in macros' names follow
24163the scheme @code{__AVR_@var{Device}__} where @var{Device} is
24164the device name as from the AVR user manual. The difference between
24165@var{Device} in the built-in macro and @var{device} in
24166@option{-mmcu=@var{device}} is that the latter is always lowercase.
24167
24168If @var{device} is not a device but only a core architecture like
24169@samp{avr51}, this macro is not defined.
24170
24171@item __AVR_DEVICE_NAME__
24172Setting @option{-mmcu=@var{device}} defines this built-in macro to
24173the device's name. For example, with @option{-mmcu=atmega8} the macro
24174is defined to @code{atmega8}.
24175
24176If @var{device} is not a device but only a core architecture like
24177@samp{avr51}, this macro is not defined.
24178
24179@item __AVR_XMEGA__
24180The device / architecture belongs to the XMEGA family of devices.
24181
5cff288c
GJL
24182@item __AVR_HAVE_ADIW__
24183The device has the @code{ADIW} and @code{SBIW} instructions.
24184
d77de738
ML
24185@item __AVR_HAVE_ELPM__
24186The device has the @code{ELPM} instruction.
24187
24188@item __AVR_HAVE_ELPMX__
24189The device has the @code{ELPM R@var{n},Z} and @code{ELPM
24190R@var{n},Z+} instructions.
24191
d77de738
ML
24192@item __AVR_HAVE_LPMX__
24193The device has the @code{LPM R@var{n},Z} and
24194@code{LPM R@var{n},Z+} instructions.
24195
5cff288c
GJL
24196@item __AVR_HAVE_MOVW__
24197The device has the @code{MOVW} instruction to perform 16-bit
24198register-register moves.
24199
d77de738
ML
24200@item __AVR_HAVE_MUL__
24201The device has a hardware multiplier.
24202
24203@item __AVR_HAVE_JMP_CALL__
24204The device has the @code{JMP} and @code{CALL} instructions.
24205This is the case for devices with more than 8@tie{}KiB of program
24206memory.
24207
24208@item __AVR_HAVE_EIJMP_EICALL__
24209@itemx __AVR_3_BYTE_PC__
24210The device has the @code{EIJMP} and @code{EICALL} instructions.
24211This is the case for devices with more than 128@tie{}KiB of program memory.
24212This also means that the program counter
24213(PC) is 3@tie{}bytes wide.
24214
24215@item __AVR_2_BYTE_PC__
24216The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
24217with up to 128@tie{}KiB of program memory.
24218
24219@item __AVR_HAVE_8BIT_SP__
24220@itemx __AVR_HAVE_16BIT_SP__
24221The stack pointer (SP) register is treated as 8-bit respectively
2422216-bit register by the compiler.
24223The definition of these macros is affected by @option{-mtiny-stack}.
24224
24225@item __AVR_HAVE_SPH__
24226@itemx __AVR_SP8__
24227The device has the SPH (high part of stack pointer) special function
24228register or has an 8-bit stack pointer, respectively.
24229The definition of these macros is affected by @option{-mmcu=} and
24230in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
24231by @option{-msp8}.
24232
24233@item __AVR_HAVE_RAMPD__
24234@itemx __AVR_HAVE_RAMPX__
24235@itemx __AVR_HAVE_RAMPY__
24236@itemx __AVR_HAVE_RAMPZ__
24237The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
24238@code{RAMPZ} special function register, respectively.
24239
24240@item __NO_INTERRUPTS__
24241This macro reflects the @option{-mno-interrupts} command-line option.
24242
24243@item __AVR_ERRATA_SKIP__
24244@itemx __AVR_ERRATA_SKIP_JMP_CALL__
24245Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
24246instructions because of a hardware erratum. Skip instructions are
24247@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
24248The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
24249set.
24250
24251@item __AVR_ISA_RMW__
24252The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
24253
24254@item __AVR_SFR_OFFSET__=@var{offset}
24255Instructions that can address I/O special function registers directly
24256like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
24257address as if addressed by an instruction to access RAM like @code{LD}
24258or @code{STS}. This offset depends on the device architecture and has
24259to be subtracted from the RAM address in order to get the
24260respective I/O@tie{}address.
24261
24262@item __AVR_SHORT_CALLS__
24263The @option{-mshort-calls} command line option is set.
24264
24265@item __AVR_PM_BASE_ADDRESS__=@var{addr}
24266Some devices support reading from flash memory by means of @code{LD*}
24267instructions. The flash memory is seen in the data address space
24268at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
24269is not defined, this feature is not available. If defined,
24270the address space is linear and there is no need to put
24271@code{.rodata} into RAM. This is handled by the default linker
24272description file, and is currently available for
24273@code{avrtiny} and @code{avrxmega3}. Even more convenient,
24274there is no need to use address spaces like @code{__flash} or
24275features like attribute @code{progmem} and @code{pgm_read_*}.
24276
48448055
GJL
24277@item __AVR_HAVE_FLMAP__
24278This macro is defined provided the following conditions are met:
24279@itemize @bullet
24280@item The device has the @code{NVMCTRL_CTRLB.FLMAP} bitfield.
24281This applies to the AVR64* and AVR128* devices.
24282@item It's not known at assembler-time which emulation will be used.
24283@end itemize
24284This implies the compiler was configured with GNU Binutils that implement
24285@w{@uref{https://sourceware.org/PR31124,PR31124}}.
24286
24287@item __AVR_RODATA_IN_RAM__
24288This macro is undefined when the code is compiled for a core architecture.
24289
24290When the code is compiled for a device, the macro is defined to@tie{}1
24291when the @code{.rodata} sections for read-only data is located in RAM;
24292and defined to@tie{}0, otherwise.
24293
d77de738
ML
24294@item __WITH_AVRLIBC__
24295The compiler is configured to be used together with AVR-Libc.
24296See the @option{--with-avrlibc} configure option.
24297
24298@item __HAVE_DOUBLE_MULTILIB__
24299Defined if @option{-mdouble=} acts as a multilib option.
24300
24301@item __HAVE_DOUBLE32__
24302@itemx __HAVE_DOUBLE64__
24303Defined if the compiler supports 32-bit double resp. 64-bit double.
24304The actual layout is specified by option @option{-mdouble=}.
24305
24306@item __DEFAULT_DOUBLE__
24307The size in bits of @code{double} if @option{-mdouble=} is not set.
24308To test the layout of @code{double} in a program, use the built-in
24309macro @code{__SIZEOF_DOUBLE__}.
24310
24311@item __HAVE_LONG_DOUBLE32__
24312@itemx __HAVE_LONG_DOUBLE64__
24313@itemx __HAVE_LONG_DOUBLE_MULTILIB__
24314@itemx __DEFAULT_LONG_DOUBLE__
24315Same as above, but for @code{long double} instead of @code{double}.
24316
24317@item __WITH_DOUBLE_COMPARISON__
24318Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
24319@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
24320and is defined to @code{2} or @code{3}.
24321
24322@item __WITH_LIBF7_LIBGCC__
24323@itemx __WITH_LIBF7_MATH__
24324@itemx __WITH_LIBF7_MATH_SYMBOLS__
24325Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
24326@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
24327
24328@end table
24329
31461d2b
GJL
24330@subsubsection AVR Internal Options
24331The following options are used internally by the compiler and to communicate
24332between device specs files and the compiler proper. You don't need to set these
24333options by hand, in particular they are not optimization options.
24334Using these options in the wrong way may lead to sub-optimal or wrong code.
24335They are documented for completeness, and in order to get a better
24336understanding of
24337@w{@uref{https://gcc.gnu.org/wiki/avr-gcc#spec-files,device specs}}
24338files.
24339
24340@table @gcctabopt
24341
24342@opindex mn-flash
24343@item -mn-flash=@var{num}
24344Assume that the flash memory has a size of @var{num} times 64@tie{}KiB.
24345This determines which @code{__flash@var{N}} address spaces are available.
24346
48448055
GJL
24347@opindex mflmap
24348@item -mflmap
24349The device has the @code{FLMAP} bit field located in special function
24350register @code{NVMCTRL_CTRLB}.
24351
31461d2b
GJL
24352@opindex mrmw
24353@item -mrmw
24354Assume that the device supports the Read-Modify-Write
24355instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
24356
24357@opindex mshort-calls
24358@item -mshort-calls
24359
24360Assume that @code{RJMP} and @code{RCALL} can target the whole
24361program memory. This option is used for multilib generation and selection
24362for the devices from architecture @code{avrxmega3}.
24363
42503cc2
GJL
24364@opindex mskip-bug
24365@item -mskip-bug
24366
24367Generate code without skips (@code{CPSE}, @code{SBRS},
24368@code{SBRC}, @code{SBIS}, @code{SBIC}) over 32-bit instructions.
24369
31461d2b
GJL
24370@opindex msp8
24371@item -msp8
24372Treat the stack pointer register as an 8-bit register,
24373i.e.@: assume the high byte of the stack pointer is zero.
24374This option is used by the compiler to select and
24375build multilibs for architectures @code{avr2} and @code{avr25}.
24376These architectures mix devices with and without @code{SPH}.
24377
24378@end table
24379
d77de738
ML
24380@node Blackfin Options
24381@subsection Blackfin Options
24382@cindex Blackfin Options
24383
24384@table @gcctabopt
d77de738 24385@opindex mcpu=
ddf6fe37 24386@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
d77de738
ML
24387Specifies the name of the target Blackfin processor. Currently, @var{cpu}
24388can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
24389@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
24390@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
24391@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
24392@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
24393@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
24394@samp{bf561}, @samp{bf592}.
24395
24396The optional @var{sirevision} specifies the silicon revision of the target
24397Blackfin processor. Any workarounds available for the targeted silicon revision
24398are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
24399If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
24400are enabled. The @code{__SILICON_REVISION__} macro is defined to two
24401hexadecimal digits representing the major and minor numbers in the silicon
24402revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
24403is not defined. If @var{sirevision} is @samp{any}, the
24404@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
24405If this optional @var{sirevision} is not used, GCC assumes the latest known
24406silicon revision of the targeted Blackfin processor.
24407
24408GCC defines a preprocessor macro for the specified @var{cpu}.
24409For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
24410provided by libgloss to be linked in if @option{-msim} is not given.
24411
24412Without this option, @samp{bf532} is used as the processor by default.
24413
24414Note that support for @samp{bf561} is incomplete. For @samp{bf561},
24415only the preprocessor macro is defined.
24416
d77de738 24417@opindex msim
ddf6fe37 24418@item -msim
d77de738
ML
24419Specifies that the program will be run on the simulator. This causes
24420the simulator BSP provided by libgloss to be linked in. This option
24421has effect only for @samp{bfin-elf} toolchain.
24422Certain other options, such as @option{-mid-shared-library} and
24423@option{-mfdpic}, imply @option{-msim}.
24424
d77de738 24425@opindex momit-leaf-frame-pointer
ddf6fe37 24426@item -momit-leaf-frame-pointer
d77de738
ML
24427Don't keep the frame pointer in a register for leaf functions. This
24428avoids the instructions to save, set up and restore frame pointers and
24429makes an extra register available in leaf functions.
24430
d77de738 24431@opindex mspecld-anomaly
ddf6fe37 24432@item -mspecld-anomaly
d77de738
ML
24433When enabled, the compiler ensures that the generated code does not
24434contain speculative loads after jump instructions. If this option is used,
24435@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
24436
d77de738
ML
24437@opindex mno-specld-anomaly
24438@opindex mspecld-anomaly
ddf6fe37 24439@item -mno-specld-anomaly
d77de738
ML
24440Don't generate extra code to prevent speculative loads from occurring.
24441
d77de738 24442@opindex mcsync-anomaly
ddf6fe37 24443@item -mcsync-anomaly
d77de738
ML
24444When enabled, the compiler ensures that the generated code does not
24445contain CSYNC or SSYNC instructions too soon after conditional branches.
24446If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
24447
d77de738
ML
24448@opindex mno-csync-anomaly
24449@opindex mcsync-anomaly
ddf6fe37 24450@item -mno-csync-anomaly
d77de738
ML
24451Don't generate extra code to prevent CSYNC or SSYNC instructions from
24452occurring too soon after a conditional branch.
24453
d77de738 24454@opindex mlow64k
ddf6fe37 24455@item -mlow64k
d77de738
ML
24456When enabled, the compiler is free to take advantage of the knowledge that
24457the entire program fits into the low 64k of memory.
24458
d77de738 24459@opindex mno-low64k
ddf6fe37 24460@item -mno-low64k
d77de738
ML
24461Assume that the program is arbitrarily large. This is the default.
24462
d77de738 24463@opindex mstack-check-l1
ddf6fe37 24464@item -mstack-check-l1
d77de738
ML
24465Do stack checking using information placed into L1 scratchpad memory by the
24466uClinux kernel.
24467
d77de738 24468@opindex mid-shared-library
ddf6fe37 24469@item -mid-shared-library
d77de738
ML
24470Generate code that supports shared libraries via the library ID method.
24471This allows for execute in place and shared libraries in an environment
24472without virtual memory management. This option implies @option{-fPIC}.
24473With a @samp{bfin-elf} target, this option implies @option{-msim}.
24474
d77de738
ML
24475@opindex mno-id-shared-library
24476@opindex mid-shared-library
ddf6fe37 24477@item -mno-id-shared-library
d77de738
ML
24478Generate code that doesn't assume ID-based shared libraries are being used.
24479This is the default.
24480
d77de738 24481@opindex mleaf-id-shared-library
ddf6fe37 24482@item -mleaf-id-shared-library
d77de738
ML
24483Generate code that supports shared libraries via the library ID method,
24484but assumes that this library or executable won't link against any other
24485ID shared libraries. That allows the compiler to use faster code for jumps
24486and calls.
24487
d77de738
ML
24488@opindex mno-leaf-id-shared-library
24489@opindex mleaf-id-shared-library
ddf6fe37 24490@item -mno-leaf-id-shared-library
d77de738
ML
24491Do not assume that the code being compiled won't link against any ID shared
24492libraries. Slower code is generated for jump and call insns.
24493
d77de738 24494@opindex mshared-library-id
ddf6fe37 24495@item -mshared-library-id=n
d77de738
ML
24496Specifies the identification number of the ID-based shared library being
24497compiled. Specifying a value of 0 generates more compact code; specifying
24498other values forces the allocation of that number to the current
24499library but is no more space- or time-efficient than omitting this option.
24500
d77de738 24501@opindex msep-data
ddf6fe37 24502@item -msep-data
d77de738
ML
24503Generate code that allows the data segment to be located in a different
24504area of memory from the text segment. This allows for execute in place in
24505an environment without virtual memory management by eliminating relocations
24506against the text section.
24507
d77de738
ML
24508@opindex mno-sep-data
24509@opindex msep-data
ddf6fe37 24510@item -mno-sep-data
d77de738
ML
24511Generate code that assumes that the data segment follows the text segment.
24512This is the default.
24513
d77de738
ML
24514@opindex mlong-calls
24515@opindex mno-long-calls
ddf6fe37
AA
24516@item -mlong-calls
24517@itemx -mno-long-calls
d77de738
ML
24518Tells the compiler to perform function calls by first loading the
24519address of the function into a register and then performing a subroutine
24520call on this register. This switch is needed if the target function
24521lies outside of the 24-bit addressing range of the offset-based
24522version of subroutine call instruction.
24523
24524This feature is not enabled by default. Specifying
24525@option{-mno-long-calls} restores the default behavior. Note these
24526switches have no effect on how the compiler generates code to handle
24527function calls via function pointers.
24528
d77de738 24529@opindex mfast-fp
ddf6fe37 24530@item -mfast-fp
d77de738
ML
24531Link with the fast floating-point library. This library relaxes some of
24532the IEEE floating-point standard's rules for checking inputs against
24533Not-a-Number (NAN), in the interest of performance.
24534
d77de738 24535@opindex minline-plt
ddf6fe37 24536@item -minline-plt
d77de738
ML
24537Enable inlining of PLT entries in function calls to functions that are
24538not known to bind locally. It has no effect without @option{-mfdpic}.
24539
d77de738 24540@opindex mmulticore
ddf6fe37 24541@item -mmulticore
d77de738
ML
24542Build a standalone application for multicore Blackfin processors.
24543This option causes proper start files and link scripts supporting
24544multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
24545It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
24546
24547This option can be used with @option{-mcorea} or @option{-mcoreb}, which
24548selects the one-application-per-core programming model. Without
24549@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
24550programming model is used. In this model, the main function of Core B
24551should be named as @code{coreb_main}.
24552
24553If this option is not used, the single-core application programming
24554model is used.
24555
d77de738 24556@opindex mcorea
ddf6fe37 24557@item -mcorea
d77de738
ML
24558Build a standalone application for Core A of BF561 when using
24559the one-application-per-core programming model. Proper start files
24560and link scripts are used to support Core A, and the macro
24561@code{__BFIN_COREA} is defined.
24562This option can only be used in conjunction with @option{-mmulticore}.
24563
d77de738 24564@opindex mcoreb
ddf6fe37 24565@item -mcoreb
d77de738
ML
24566Build a standalone application for Core B of BF561 when using
24567the one-application-per-core programming model. Proper start files
24568and link scripts are used to support Core B, and the macro
24569@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
24570should be used instead of @code{main}.
24571This option can only be used in conjunction with @option{-mmulticore}.
24572
d77de738 24573@opindex msdram
ddf6fe37 24574@item -msdram
d77de738
ML
24575Build a standalone application for SDRAM. Proper start files and
24576link scripts are used to put the application into SDRAM, and the macro
24577@code{__BFIN_SDRAM} is defined.
24578The loader should initialize SDRAM before loading the application.
24579
d77de738 24580@opindex micplb
ddf6fe37 24581@item -micplb
d77de738
ML
24582Assume that ICPLBs are enabled at run time. This has an effect on certain
24583anomaly workarounds. For Linux targets, the default is to assume ICPLBs
24584are enabled; for standalone applications the default is off.
24585@end table
24586
24587@node C6X Options
24588@subsection C6X Options
24589@cindex C6X Options
24590
24591@table @gcctabopt
d77de738 24592@opindex march
ddf6fe37 24593@item -march=@var{name}
d77de738
ML
24594This specifies the name of the target architecture. GCC uses this
24595name to determine what kind of instructions it can emit when generating
24596assembly code. Permissible names are: @samp{c62x},
24597@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
24598
d77de738 24599@opindex mbig-endian
ddf6fe37 24600@item -mbig-endian
d77de738
ML
24601Generate code for a big-endian target.
24602
d77de738 24603@opindex mlittle-endian
ddf6fe37 24604@item -mlittle-endian
d77de738
ML
24605Generate code for a little-endian target. This is the default.
24606
d77de738 24607@opindex msim
ddf6fe37 24608@item -msim
d77de738
ML
24609Choose startup files and linker script suitable for the simulator.
24610
d77de738 24611@opindex msdata=default
ddf6fe37 24612@item -msdata=default
d77de738
ML
24613Put small global and static data in the @code{.neardata} section,
24614which is pointed to by register @code{B14}. Put small uninitialized
24615global and static data in the @code{.bss} section, which is adjacent
24616to the @code{.neardata} section. Put small read-only data into the
24617@code{.rodata} section. The corresponding sections used for large
24618pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
24619
d77de738 24620@opindex msdata=all
ddf6fe37 24621@item -msdata=all
d77de738
ML
24622Put all data, not just small objects, into the sections reserved for
24623small data, and use addressing relative to the @code{B14} register to
24624access them.
24625
d77de738 24626@opindex msdata=none
ddf6fe37 24627@item -msdata=none
d77de738
ML
24628Make no use of the sections reserved for small data, and use absolute
24629addresses to access all data. Put all initialized global and static
24630data in the @code{.fardata} section, and all uninitialized data in the
24631@code{.far} section. Put all constant data into the @code{.const}
24632section.
24633@end table
24634
24635@node CRIS Options
24636@subsection CRIS Options
24637@cindex CRIS Options
24638
24639These options are defined specifically for the CRIS ports.
24640
24641@table @gcctabopt
d77de738
ML
24642@opindex march
24643@opindex mcpu
ddf6fe37
AA
24644@item -march=@var{architecture-type}
24645@itemx -mcpu=@var{architecture-type}
d77de738
ML
24646Generate code for the specified architecture. The choices for
24647@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
24648respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
24649Default is @samp{v0}.
24650
d77de738 24651@opindex mtune
ddf6fe37 24652@item -mtune=@var{architecture-type}
d77de738
ML
24653Tune to @var{architecture-type} everything applicable about the generated
24654code, except for the ABI and the set of available instructions. The
24655choices for @var{architecture-type} are the same as for
24656@option{-march=@var{architecture-type}}.
24657
d77de738 24658@opindex mmax-stack-frame
ddf6fe37 24659@item -mmax-stack-frame=@var{n}
d77de738
ML
24660Warn when the stack frame of a function exceeds @var{n} bytes.
24661
d77de738
ML
24662@opindex metrax4
24663@opindex metrax100
ddf6fe37
AA
24664@item -metrax4
24665@itemx -metrax100
d77de738
ML
24666The options @option{-metrax4} and @option{-metrax100} are synonyms for
24667@option{-march=v3} and @option{-march=v8} respectively.
24668
d77de738
ML
24669@opindex mmul-bug-workaround
24670@opindex mno-mul-bug-workaround
ddf6fe37
AA
24671@item -mmul-bug-workaround
24672@itemx -mno-mul-bug-workaround
d77de738
ML
24673Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
24674models where it applies. This option is disabled by default.
24675
d77de738 24676@opindex mpdebug
ddf6fe37 24677@item -mpdebug
d77de738
ML
24678Enable CRIS-specific verbose debug-related information in the assembly
24679code. This option also has the effect of turning off the @samp{#NO_APP}
24680formatted-code indicator to the assembler at the beginning of the
24681assembly file.
24682
d77de738 24683@opindex mcc-init
ddf6fe37 24684@item -mcc-init
d77de738
ML
24685Do not use condition-code results from previous instruction; always emit
24686compare and test instructions before use of condition codes.
24687
d77de738
ML
24688@opindex mno-side-effects
24689@opindex mside-effects
ddf6fe37 24690@item -mno-side-effects
d77de738
ML
24691Do not emit instructions with side effects in addressing modes other than
24692post-increment.
24693
d77de738
ML
24694@opindex mstack-align
24695@opindex mno-stack-align
24696@opindex mdata-align
24697@opindex mno-data-align
24698@opindex mconst-align
24699@opindex mno-const-align
ddf6fe37
AA
24700@item -mstack-align
24701@itemx -mno-stack-align
24702@itemx -mdata-align
24703@itemx -mno-data-align
24704@itemx -mconst-align
24705@itemx -mno-const-align
d77de738
ML
24706These options (@samp{no-} options) arrange (eliminate arrangements) for the
24707stack frame, individual data and constants to be aligned for the maximum
24708single data access size for the chosen CPU model. The default is to
24709arrange for 32-bit alignment. ABI details such as structure layout are
24710not affected by these options.
24711
d77de738
ML
24712@opindex m32-bit
24713@opindex m16-bit
24714@opindex m8-bit
ddf6fe37
AA
24715@item -m32-bit
24716@itemx -m16-bit
24717@itemx -m8-bit
d77de738
ML
24718Similar to the stack- data- and const-align options above, these options
24719arrange for stack frame, writable data and constants to all be 32-bit,
2472016-bit or 8-bit aligned. The default is 32-bit alignment.
24721
d77de738
ML
24722@opindex mno-prologue-epilogue
24723@opindex mprologue-epilogue
ddf6fe37
AA
24724@item -mno-prologue-epilogue
24725@itemx -mprologue-epilogue
d77de738
ML
24726With @option{-mno-prologue-epilogue}, the normal function prologue and
24727epilogue which set up the stack frame are omitted and no return
24728instructions or return sequences are generated in the code. Use this
24729option only together with visual inspection of the compiled code: no
24730warnings or errors are generated when call-saved registers must be saved,
24731or storage for local variables needs to be allocated.
24732
d77de738 24733@opindex melf
ddf6fe37 24734@item -melf
d77de738
ML
24735Legacy no-op option.
24736
d77de738 24737@opindex sim
ddf6fe37 24738@item -sim
d77de738
ML
24739This option arranges
24740to link with input-output functions from a simulator library. Code,
24741initialized data and zero-initialized data are allocated consecutively.
24742
d77de738 24743@opindex sim2
ddf6fe37 24744@item -sim2
d77de738
ML
24745Like @option{-sim}, but pass linker options to locate initialized data at
247460x40000000 and zero-initialized data at 0x80000000.
24747@end table
24748
24749@node C-SKY Options
24750@subsection C-SKY Options
24751@cindex C-SKY Options
24752
24753GCC supports these options when compiling for C-SKY V2 processors.
24754
24755@table @gcctabopt
24756
d77de738 24757@opindex march=
ddf6fe37 24758@item -march=@var{arch}
d77de738
ML
24759Specify the C-SKY target architecture. Valid values for @var{arch} are:
24760@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
24761The default is @samp{ck810}.
24762
d77de738 24763@opindex mcpu=
ddf6fe37 24764@item -mcpu=@var{cpu}
d77de738
ML
24765Specify the C-SKY target processor. Valid values for @var{cpu} are:
24766@samp{ck801}, @samp{ck801t},
24767@samp{ck802}, @samp{ck802t}, @samp{ck802j},
24768@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
24769@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
24770@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
24771@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
24772@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
24773@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
24774@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
24775@samp{ck803eftr1}, @samp{ck803efhtr1},
24776@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
24777@samp{ck803sef}, @samp{ck803seft},
24778@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
24779@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
24780@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
24781@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
24782
d77de738 24783@opindex mbig-endian
d77de738 24784@opindex EB
d77de738 24785@opindex mlittle-endian
d77de738 24786@opindex EL
ddf6fe37
AA
24787@item -mbig-endian
24788@itemx -EB
24789@itemx -mlittle-endian
24790@itemx -EL
d77de738
ML
24791
24792Select big- or little-endian code. The default is little-endian.
24793
d77de738 24794@opindex mfloat-abi
ddf6fe37 24795@item -mfloat-abi=@var{name}
d77de738
ML
24796Specifies which floating-point ABI to use. Permissible values
24797are: @samp{soft}, @samp{softfp} and @samp{hard}.
24798
24799Specifying @samp{soft} causes GCC to generate output containing
24800library calls for floating-point operations.
24801@samp{softfp} allows the generation of code using hardware floating-point
24802instructions, but still uses the soft-float calling conventions.
24803@samp{hard} allows generation of floating-point instructions
24804and uses FPU-specific calling conventions.
24805
24806The default depends on the specific target configuration. Note that
24807the hard-float and soft-float ABIs are not link-compatible; you must
24808compile your entire program with the same ABI, and link with a
24809compatible set of libraries.
24810
d77de738 24811@opindex mhard-float
d77de738 24812@opindex msoft-float
ddf6fe37
AA
24813@item -mhard-float
24814@itemx -msoft-float
d77de738
ML
24815
24816Select hardware or software floating-point implementations.
24817The default is soft float.
24818
ddf6fe37 24819@opindex mdouble-float
d77de738
ML
24820@item -mdouble-float
24821@itemx -mno-double-float
d77de738
ML
24822When @option{-mhard-float} is in effect, enable generation of
24823double-precision float instructions. This is the default except
24824when compiling for CK803.
24825
ddf6fe37 24826@opindex mfdivdu
d77de738
ML
24827@item -mfdivdu
24828@itemx -mno-fdivdu
d77de738
ML
24829When @option{-mhard-float} is in effect, enable generation of
24830@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
24831This is the default except when compiling for CK803.
24832
d77de738 24833@opindex mfpu=
ddf6fe37 24834@item -mfpu=@var{fpu}
d77de738
ML
24835Select the floating-point processor. This option can only be used with
24836@option{-mhard-float}.
24837Values for @var{fpu} are
24838@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
24839@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
24840@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
24841
ddf6fe37 24842@opindex melrw
d77de738
ML
24843@item -melrw
24844@itemx -mno-elrw
d77de738
ML
24845Enable the extended @code{lrw} instruction. This option defaults to on
24846for CK801 and off otherwise.
24847
ddf6fe37 24848@opindex mistack
d77de738
ML
24849@item -mistack
24850@itemx -mno-istack
d77de738
ML
24851Enable interrupt stack instructions; the default is off.
24852
24853The @option{-mistack} option is required to handle the
24854@code{interrupt} and @code{isr} function attributes
24855(@pxref{C-SKY Function Attributes}).
24856
d77de738 24857@opindex mmp
ddf6fe37 24858@item -mmp
d77de738
ML
24859Enable multiprocessor instructions; the default is off.
24860
d77de738 24861@opindex mcp
ddf6fe37 24862@item -mcp
d77de738
ML
24863Enable coprocessor instructions; the default is off.
24864
d77de738 24865@opindex mcache
ddf6fe37 24866@item -mcache
d77de738
ML
24867Enable coprocessor instructions; the default is off.
24868
d77de738 24869@opindex msecurity
ddf6fe37 24870@item -msecurity
d77de738
ML
24871Enable C-SKY security instructions; the default is off.
24872
d77de738 24873@opindex mtrust
ddf6fe37 24874@item -mtrust
d77de738
ML
24875Enable C-SKY trust instructions; the default is off.
24876
d77de738 24877@opindex mdsp
d77de738 24878@opindex medsp
d77de738 24879@opindex mvdsp
ddf6fe37
AA
24880@item -mdsp
24881@itemx -medsp
24882@itemx -mvdsp
d77de738
ML
24883Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
24884All of these options default to off.
24885
ddf6fe37 24886@opindex mdiv
d77de738
ML
24887@item -mdiv
24888@itemx -mno-div
d77de738
ML
24889Generate divide instructions. Default is off.
24890
ddf6fe37 24891@opindex msmart
d77de738
ML
24892@item -msmart
24893@itemx -mno-smart
d77de738
ML
24894Generate code for Smart Mode, using only registers numbered 0-7 to allow
24895use of 16-bit instructions. This option is ignored for CK801 where this
24896is the required behavior, and it defaults to on for CK802.
24897For other targets, the default is off.
24898
ddf6fe37 24899@opindex mhigh-registers
d77de738
ML
24900@item -mhigh-registers
24901@itemx -mno-high-registers
d77de738
ML
24902Generate code using the high registers numbered 16-31. This option
24903is not supported on CK801, CK802, or CK803, and is enabled by default
24904for other processors.
24905
ddf6fe37 24906@opindex manchor
d77de738
ML
24907@item -manchor
24908@itemx -mno-anchor
d77de738
ML
24909Generate code using global anchor symbol addresses.
24910
ddf6fe37 24911@opindex mpushpop
d77de738
ML
24912@item -mpushpop
24913@itemx -mno-pushpop
d77de738
ML
24914Generate code using @code{push} and @code{pop} instructions. This option
24915defaults to on.
24916
ddf6fe37 24917@opindex mmultiple-stld
d77de738
ML
24918@item -mmultiple-stld
24919@itemx -mstm
24920@itemx -mno-multiple-stld
24921@itemx -mno-stm
d77de738
ML
24922Generate code using @code{stm} and @code{ldm} instructions. This option
24923isn't supported on CK801 but is enabled by default on other processors.
24924
ddf6fe37 24925@opindex mconstpool
d77de738
ML
24926@item -mconstpool
24927@itemx -mno-constpool
d77de738
ML
24928Create constant pools in the compiler instead of deferring it to the
24929assembler. This option is the default and required for correct code
24930generation on CK801 and CK802, and is optional on other processors.
24931
ddf6fe37 24932@opindex mstack-size
d77de738
ML
24933@item -mstack-size
24934@item -mno-stack-size
d77de738
ML
24935Emit @code{.stack_size} directives for each function in the assembly
24936output. This option defaults to off.
24937
ddf6fe37 24938@opindex mccrt
d77de738
ML
24939@item -mccrt
24940@itemx -mno-ccrt
d77de738
ML
24941Generate code for the C-SKY compiler runtime instead of libgcc. This
24942option defaults to off.
24943
d77de738 24944@opindex mbranch-cost=
ddf6fe37 24945@item -mbranch-cost=@var{n}
d77de738
ML
24946Set the branch costs to roughly @code{n} instructions. The default is 1.
24947
ddf6fe37 24948@opindex msched-prolog
d77de738
ML
24949@item -msched-prolog
24950@itemx -mno-sched-prolog
d77de738
ML
24951Permit scheduling of function prologue and epilogue sequences. Using
24952this option can result in code that is not compliant with the C-SKY V2 ABI
24953prologue requirements and that cannot be debugged or backtraced.
24954It is disabled by default.
24955
d77de738 24956@opindex msim
ddf6fe37 24957@item -msim
d77de738
ML
24958Links the library libsemi.a which is in compatible with simulator. Applicable
24959to ELF compiler only.
24960
24961@end table
24962
24963@node Darwin Options
24964@subsection Darwin Options
24965@cindex Darwin options
24966
24967These options are defined for all architectures running the Darwin operating
24968system.
24969
24970FSF GCC on Darwin does not create ``fat'' object files; it creates
24971an object file for the single architecture that GCC was built to
24972target. Apple's GCC on Darwin does create ``fat'' files if multiple
24973@option{-arch} options are used; it does so by running the compiler or
24974linker multiple times and joining the results together with
24975@file{lipo}.
24976
24977The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
24978@samp{i686}) is determined by the flags that specify the ISA
24979that GCC is targeting, like @option{-mcpu} or @option{-march}. The
24980@option{-force_cpusubtype_ALL} option can be used to override this.
24981
24982The Darwin tools vary in their behavior when presented with an ISA
24983mismatch. The assembler, @file{as}, only permits instructions to
24984be used that are valid for the subtype of the file it is generating,
24985so you cannot put 64-bit instructions in a @samp{ppc750} object file.
24986The linker for shared libraries, @file{/usr/bin/libtool}, fails
24987and prints an error if asked to create a shared library with a less
24988restrictive subtype than its input files (for instance, trying to put
24989a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
24990for executables, @command{ld}, quietly gives the executable the most
24991restrictive subtype of any of its input files.
24992
24993@table @gcctabopt
d77de738 24994@opindex F
ddf6fe37 24995@item -F@var{dir}
d77de738
ML
24996Add the framework directory @var{dir} to the head of the list of
24997directories to be searched for header files. These directories are
24998interleaved with those specified by @option{-I} options and are
24999scanned in a left-to-right order.
25000
25001A framework directory is a directory with frameworks in it. A
25002framework is a directory with a @file{Headers} and/or
25003@file{PrivateHeaders} directory contained directly in it that ends
25004in @file{.framework}. The name of a framework is the name of this
25005directory excluding the @file{.framework}. Headers associated with
25006the framework are found in one of those two directories, with
25007@file{Headers} being searched first. A subframework is a framework
25008directory that is in a framework's @file{Frameworks} directory.
25009Includes of subframework headers can only appear in a header of a
25010framework that contains the subframework, or in a sibling subframework
25011header. Two subframeworks are siblings if they occur in the same
25012framework. A subframework should not have the same name as a
25013framework; a warning is issued if this is violated. Currently a
25014subframework cannot have subframeworks; in the future, the mechanism
25015may be extended to support this. The standard frameworks can be found
25016in @file{/System/Library/Frameworks} and
25017@file{/Library/Frameworks}. An example include looks like
25018@code{#include <Framework/header.h>}, where @file{Framework} denotes
25019the name of the framework and @file{header.h} is found in the
25020@file{PrivateHeaders} or @file{Headers} directory.
25021
d77de738 25022@opindex iframework
ddf6fe37 25023@item -iframework@var{dir}
d77de738
ML
25024Like @option{-F} except the directory is a treated as a system
25025directory. The main difference between this @option{-iframework} and
25026@option{-F} is that with @option{-iframework} the compiler does not
25027warn about constructs contained within header files found via
25028@var{dir}. This option is valid only for the C family of languages.
25029
d77de738 25030@opindex gused
ddf6fe37 25031@item -gused
d77de738
ML
25032Emit debugging information for symbols that are used. For stabs
25033debugging format, this enables @option{-feliminate-unused-debug-symbols}.
25034This is by default ON@.
25035
d77de738 25036@opindex gfull
ddf6fe37 25037@item -gfull
d77de738
ML
25038Emit debugging information for all symbols and types.
25039
cdd4b3c0
IS
25040@opindex fconstant-cfstrings
25041@item -fconstant-cfstrings
25042The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}.
25043
25044@opindex mconstant-cfstrings
25045@item -mconstant-cfstrings
25046When the NeXT runtime is being used (the default on these systems), override
25047any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"}
25048literals to be laid out as constant CoreFoundation strings.
25049
25050@opindex mmacosx-version-min
d77de738 25051@item -mmacosx-version-min=@var{version}
cdd4b3c0
IS
25052The earliest version of MacOS X that this executable will run on is
25053@var{version}. Typical values supported for @var{version} include @code{12},
25054@code{10.12}, and @code{10.5.8}.
d77de738
ML
25055
25056If the compiler was built to use the system's headers by default,
25057then the default for this option is the system version on which the
25058compiler is running, otherwise the default is to make choices that
25059are compatible with as many systems and code bases as possible.
25060
d77de738 25061@opindex mkernel
ddf6fe37 25062@item -mkernel
d77de738
ML
25063Enable kernel development mode. The @option{-mkernel} option sets
25064@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
25065@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
25066@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
25067applicable. This mode also sets @option{-mno-altivec},
25068@option{-msoft-float}, @option{-fno-builtin} and
25069@option{-mlong-branch} for PowerPC targets.
25070
d77de738 25071@opindex mone-byte-bool
ddf6fe37 25072@item -mone-byte-bool
d77de738
ML
25073Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
25074By default @code{sizeof(bool)} is @code{4} when compiling for
25075Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
25076option has no effect on x86.
25077
25078@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
25079to generate code that is not binary compatible with code generated
25080without that switch. Using this switch may require recompiling all
25081other modules in a program, including system libraries. Use this
25082switch to conform to a non-default data model.
25083
d77de738
ML
25084@opindex mfix-and-continue
25085@opindex ffix-and-continue
25086@opindex findirect-data
ddf6fe37
AA
25087@item -mfix-and-continue
25088@itemx -ffix-and-continue
25089@itemx -findirect-data
d77de738
ML
25090Generate code suitable for fast turnaround development, such as to
25091allow GDB to dynamically load @file{.o} files into already-running
25092programs. @option{-findirect-data} and @option{-ffix-and-continue}
25093are provided for backwards compatibility.
25094
d77de738 25095@opindex all_load
ddf6fe37 25096@item -all_load
d77de738
ML
25097Loads all members of static archive libraries.
25098See man ld(1) for more information.
25099
d77de738 25100@opindex arch_errors_fatal
ddf6fe37 25101@item -arch_errors_fatal
d77de738
ML
25102Cause the errors having to do with files that have the wrong architecture
25103to be fatal.
25104
d77de738 25105@opindex bind_at_load
ddf6fe37 25106@item -bind_at_load
d77de738
ML
25107Causes the output file to be marked such that the dynamic linker will
25108bind all undefined references when the file is loaded or launched.
25109
d77de738 25110@opindex bundle
ddf6fe37 25111@item -bundle
d77de738
ML
25112Produce a Mach-o bundle format file.
25113See man ld(1) for more information.
25114
d77de738 25115@opindex bundle_loader
ddf6fe37 25116@item -bundle_loader @var{executable}
d77de738
ML
25117This option specifies the @var{executable} that will load the build
25118output file being linked. See man ld(1) for more information.
25119
d77de738 25120@opindex dynamiclib
ddf6fe37 25121@item -dynamiclib
d77de738
ML
25122When passed this option, GCC produces a dynamic library instead of
25123an executable when linking, using the Darwin @file{libtool} command.
25124
d77de738 25125@opindex force_cpusubtype_ALL
ddf6fe37 25126@item -force_cpusubtype_ALL
d77de738
ML
25127This causes GCC's output file to have the @samp{ALL} subtype, instead of
25128one controlled by the @option{-mcpu} or @option{-march} option.
25129
47b634a3
FXC
25130@opindex nodefaultrpaths
25131@item -nodefaultrpaths
25132Do not add default run paths for the compiler library directories to
25133executables, modules or dynamic libraries. On macOS 10.5 and later,
25134the embedded runpath is added by default unless the user adds
25135@option{-nodefaultrpaths} to the link line. Run paths are needed
25136(and therefore enforced) to build on macOS version 10.11 or later.
25137
d77de738
ML
25138@item -allowable_client @var{client_name}
25139@itemx -client_name
25140@itemx -compatibility_version
25141@itemx -current_version
25142@itemx -dead_strip
25143@itemx -dependency-file
25144@itemx -dylib_file
25145@itemx -dylinker_install_name
25146@itemx -dynamic
25147@itemx -exported_symbols_list
25148@itemx -filelist
25149@need 800
25150@itemx -flat_namespace
25151@itemx -force_flat_namespace
25152@itemx -headerpad_max_install_names
25153@itemx -image_base
25154@itemx -init
25155@itemx -install_name
25156@itemx -keep_private_externs
25157@itemx -multi_module
25158@itemx -multiply_defined
25159@itemx -multiply_defined_unused
25160@need 800
25161@itemx -noall_load
25162@itemx -no_dead_strip_inits_and_terms
25163@itemx -nofixprebinding
25164@itemx -nomultidefs
25165@itemx -noprebind
25166@itemx -noseglinkedit
25167@itemx -pagezero_size
25168@itemx -prebind
25169@itemx -prebind_all_twolevel_modules
25170@itemx -private_bundle
25171@need 800
25172@itemx -read_only_relocs
25173@itemx -sectalign
25174@itemx -sectobjectsymbols
25175@itemx -whyload
25176@itemx -seg1addr
25177@itemx -sectcreate
25178@itemx -sectobjectsymbols
25179@itemx -sectorder
25180@itemx -segaddr
25181@itemx -segs_read_only_addr
25182@need 800
25183@itemx -segs_read_write_addr
25184@itemx -seg_addr_table
25185@itemx -seg_addr_table_filename
25186@itemx -seglinkedit
25187@itemx -segprot
25188@itemx -segs_read_only_addr
25189@itemx -segs_read_write_addr
25190@itemx -single_module
25191@itemx -static
25192@itemx -sub_library
25193@need 800
d77de738
ML
25194@opindex allowable_client
25195@opindex client_name
25196@opindex compatibility_version
25197@opindex current_version
25198@opindex dead_strip
25199@opindex dependency-file
25200@opindex dylib_file
25201@opindex dylinker_install_name
25202@opindex dynamic
25203@opindex exported_symbols_list
25204@opindex filelist
25205@opindex flat_namespace
25206@opindex force_flat_namespace
25207@opindex headerpad_max_install_names
25208@opindex image_base
25209@opindex init
25210@opindex install_name
25211@opindex keep_private_externs
25212@opindex multi_module
25213@opindex multiply_defined
25214@opindex multiply_defined_unused
25215@opindex noall_load
25216@opindex no_dead_strip_inits_and_terms
25217@opindex nofixprebinding
25218@opindex nomultidefs
25219@opindex noprebind
25220@opindex noseglinkedit
25221@opindex pagezero_size
25222@opindex prebind
25223@opindex prebind_all_twolevel_modules
25224@opindex private_bundle
25225@opindex read_only_relocs
25226@opindex sectalign
25227@opindex sectobjectsymbols
25228@opindex whyload
25229@opindex seg1addr
25230@opindex sectcreate
25231@opindex sectobjectsymbols
25232@opindex sectorder
25233@opindex segaddr
25234@opindex segs_read_only_addr
25235@opindex segs_read_write_addr
25236@opindex seg_addr_table
25237@opindex seg_addr_table_filename
25238@opindex seglinkedit
25239@opindex segprot
25240@opindex segs_read_only_addr
25241@opindex segs_read_write_addr
25242@opindex single_module
25243@opindex static
25244@opindex sub_library
25245@opindex sub_umbrella
25246@opindex twolevel_namespace
25247@opindex umbrella
25248@opindex undefined
25249@opindex unexported_symbols_list
25250@opindex weak_reference_mismatches
25251@opindex whatsloaded
ddf6fe37
AA
25252@itemx -sub_umbrella
25253@itemx -twolevel_namespace
25254@itemx -umbrella
25255@itemx -undefined
25256@itemx -unexported_symbols_list
25257@itemx -weak_reference_mismatches
25258@itemx -whatsloaded
d77de738
ML
25259These options are passed to the Darwin linker. The Darwin linker man page
25260describes them in detail.
25261@end table
25262
25263@node DEC Alpha Options
25264@subsection DEC Alpha Options
25265
25266These @samp{-m} options are defined for the DEC Alpha implementations:
25267
25268@table @gcctabopt
d77de738
ML
25269@opindex mno-soft-float
25270@opindex msoft-float
ddf6fe37
AA
25271@item -mno-soft-float
25272@itemx -msoft-float
d77de738
ML
25273Use (do not use) the hardware floating-point instructions for
25274floating-point operations. When @option{-msoft-float} is specified,
25275functions in @file{libgcc.a} are used to perform floating-point
25276operations. Unless they are replaced by routines that emulate the
25277floating-point operations, or compiled in such a way as to call such
25278emulations routines, these routines issue floating-point
25279operations. If you are compiling for an Alpha without floating-point
25280operations, you must ensure that the library is built so as not to call
25281them.
25282
25283Note that Alpha implementations without floating-point operations are
25284required to have floating-point registers.
25285
d77de738
ML
25286@opindex mfp-reg
25287@opindex mno-fp-regs
ddf6fe37
AA
25288@item -mfp-reg
25289@itemx -mno-fp-regs
d77de738
ML
25290Generate code that uses (does not use) the floating-point register set.
25291@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
25292register set is not used, floating-point operands are passed in integer
25293registers as if they were integers and floating-point results are passed
25294in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
25295so any function with a floating-point argument or return value called by code
25296compiled with @option{-mno-fp-regs} must also be compiled with that
25297option.
25298
25299A typical use of this option is building a kernel that does not use,
25300and hence need not save and restore, any floating-point registers.
25301
d77de738 25302@opindex mieee
ddf6fe37 25303@item -mieee
d77de738
ML
25304The Alpha architecture implements floating-point hardware optimized for
25305maximum performance. It is mostly compliant with the IEEE floating-point
25306standard. However, for full compliance, software assistance is
25307required. This option generates code fully IEEE-compliant code
25308@emph{except} that the @var{inexact-flag} is not maintained (see below).
25309If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
25310defined during compilation. The resulting code is less efficient but is
25311able to correctly support denormalized numbers and exceptional IEEE
25312values such as not-a-number and plus/minus infinity. Other Alpha
25313compilers call this option @option{-ieee_with_no_inexact}.
25314
d77de738 25315@opindex mieee-with-inexact
ddf6fe37 25316@item -mieee-with-inexact
d77de738
ML
25317This is like @option{-mieee} except the generated code also maintains
25318the IEEE @var{inexact-flag}. Turning on this option causes the
25319generated code to implement fully-compliant IEEE math. In addition to
25320@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
25321macro. On some Alpha implementations the resulting code may execute
25322significantly slower than the code generated by default. Since there is
25323very little code that depends on the @var{inexact-flag}, you should
25324normally not specify this option. Other Alpha compilers call this
25325option @option{-ieee_with_inexact}.
25326
d77de738 25327@opindex mfp-trap-mode
ddf6fe37 25328@item -mfp-trap-mode=@var{trap-mode}
d77de738
ML
25329This option controls what floating-point related traps are enabled.
25330Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
25331The trap mode can be set to one of four values:
25332
25333@table @samp
25334@item n
25335This is the default (normal) setting. The only traps that are enabled
25336are the ones that cannot be disabled in software (e.g., division by zero
25337trap).
25338
25339@item u
25340In addition to the traps enabled by @samp{n}, underflow traps are enabled
25341as well.
25342
25343@item su
25344Like @samp{u}, but the instructions are marked to be safe for software
25345completion (see Alpha architecture manual for details).
25346
25347@item sui
25348Like @samp{su}, but inexact traps are enabled as well.
25349@end table
25350
d77de738 25351@opindex mfp-rounding-mode
ddf6fe37 25352@item -mfp-rounding-mode=@var{rounding-mode}
d77de738
ML
25353Selects the IEEE rounding mode. Other Alpha compilers call this option
25354@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
25355of:
25356
25357@table @samp
25358@item n
25359Normal IEEE rounding mode. Floating-point numbers are rounded towards
25360the nearest machine number or towards the even machine number in case
25361of a tie.
25362
25363@item m
25364Round towards minus infinity.
25365
25366@item c
25367Chopped rounding mode. Floating-point numbers are rounded towards zero.
25368
25369@item d
25370Dynamic rounding mode. A field in the floating-point control register
25371(@var{fpcr}, see Alpha architecture reference manual) controls the
25372rounding mode in effect. The C library initializes this register for
25373rounding towards plus infinity. Thus, unless your program modifies the
25374@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
25375@end table
25376
d77de738 25377@opindex mtrap-precision
ddf6fe37 25378@item -mtrap-precision=@var{trap-precision}
d77de738
ML
25379In the Alpha architecture, floating-point traps are imprecise. This
25380means without software assistance it is impossible to recover from a
25381floating trap and program execution normally needs to be terminated.
25382GCC can generate code that can assist operating system trap handlers
25383in determining the exact location that caused a floating-point trap.
25384Depending on the requirements of an application, different levels of
25385precisions can be selected:
25386
25387@table @samp
25388@item p
25389Program precision. This option is the default and means a trap handler
25390can only identify which program caused a floating-point exception.
25391
25392@item f
25393Function precision. The trap handler can determine the function that
25394caused a floating-point exception.
25395
25396@item i
25397Instruction precision. The trap handler can determine the exact
25398instruction that caused a floating-point exception.
25399@end table
25400
25401Other Alpha compilers provide the equivalent options called
25402@option{-scope_safe} and @option{-resumption_safe}.
25403
d77de738 25404@opindex mieee-conformant
ddf6fe37 25405@item -mieee-conformant
d77de738
ML
25406This option marks the generated code as IEEE conformant. You must not
25407use this option unless you also specify @option{-mtrap-precision=i} and either
25408@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
25409is to emit the line @samp{.eflag 48} in the function prologue of the
25410generated assembly file.
25411
d77de738 25412@opindex mbuild-constants
ddf6fe37 25413@item -mbuild-constants
d77de738
ML
25414Normally GCC examines a 32- or 64-bit integer constant to
25415see if it can construct it from smaller constants in two or three
25416instructions. If it cannot, it outputs the constant as a literal and
25417generates code to load it from the data segment at run time.
25418
25419Use this option to require GCC to construct @emph{all} integer constants
25420using code, even if it takes more instructions (the maximum is six).
25421
25422You typically use this option to build a shared library dynamic
25423loader. Itself a shared library, it must relocate itself in memory
25424before it can find the variables and constants in its own data segment.
25425
d77de738
ML
25426@opindex mbwx
25427@opindex mno-bwx
25428@opindex mcix
25429@opindex mno-cix
25430@opindex mfix
25431@opindex mno-fix
25432@opindex mmax
25433@opindex mno-max
ddf6fe37
AA
25434@item -mbwx
25435@itemx -mno-bwx
25436@itemx -mcix
25437@itemx -mno-cix
25438@itemx -mfix
25439@itemx -mno-fix
25440@itemx -mmax
25441@itemx -mno-max
d77de738
ML
25442Indicate whether GCC should generate code to use the optional BWX,
25443CIX, FIX and MAX instruction sets. The default is to use the instruction
25444sets supported by the CPU type specified via @option{-mcpu=} option or that
25445of the CPU on which GCC was built if none is specified.
25446
d77de738
ML
25447@opindex mfloat-vax
25448@opindex mfloat-ieee
ddf6fe37
AA
25449@item -mfloat-vax
25450@itemx -mfloat-ieee
d77de738
ML
25451Generate code that uses (does not use) VAX F and G floating-point
25452arithmetic instead of IEEE single and double precision.
25453
d77de738
ML
25454@opindex mexplicit-relocs
25455@opindex mno-explicit-relocs
ddf6fe37
AA
25456@item -mexplicit-relocs
25457@itemx -mno-explicit-relocs
d77de738
ML
25458Older Alpha assemblers provided no way to generate symbol relocations
25459except via assembler macros. Use of these macros does not allow
25460optimal instruction scheduling. GNU binutils as of version 2.12
25461supports a new syntax that allows the compiler to explicitly mark
25462which relocations should apply to which instructions. This option
25463is mostly useful for debugging, as GCC detects the capabilities of
25464the assembler when it is built and sets the default accordingly.
25465
d77de738
ML
25466@opindex msmall-data
25467@opindex mlarge-data
ddf6fe37
AA
25468@item -msmall-data
25469@itemx -mlarge-data
d77de738
ML
25470When @option{-mexplicit-relocs} is in effect, static data is
25471accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
25472is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
25473(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2547416-bit relocations off of the @code{$gp} register. This limits the
25475size of the small data area to 64KB, but allows the variables to be
25476directly accessed via a single instruction.
25477
25478The default is @option{-mlarge-data}. With this option the data area
25479is limited to just below 2GB@. Programs that require more than 2GB of
25480data must use @code{malloc} or @code{mmap} to allocate the data in the
25481heap instead of in the program's data segment.
25482
25483When generating code for shared libraries, @option{-fpic} implies
25484@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
25485
d77de738
ML
25486@opindex msmall-text
25487@opindex mlarge-text
ddf6fe37
AA
25488@item -msmall-text
25489@itemx -mlarge-text
d77de738
ML
25490When @option{-msmall-text} is used, the compiler assumes that the
25491code of the entire program (or shared library) fits in 4MB, and is
25492thus reachable with a branch instruction. When @option{-msmall-data}
25493is used, the compiler can assume that all local symbols share the
25494same @code{$gp} value, and thus reduce the number of instructions
25495required for a function call from 4 to 1.
25496
25497The default is @option{-mlarge-text}.
25498
d77de738 25499@opindex mcpu
ddf6fe37 25500@item -mcpu=@var{cpu_type}
d77de738
ML
25501Set the instruction set and instruction scheduling parameters for
25502machine type @var{cpu_type}. You can specify either the @samp{EV}
25503style name or the corresponding chip number. GCC supports scheduling
25504parameters for the EV4, EV5 and EV6 family of processors and
25505chooses the default values for the instruction set from the processor
25506you specify. If you do not specify a processor type, GCC defaults
25507to the processor on which the compiler was built.
25508
25509Supported values for @var{cpu_type} are
25510
25511@table @samp
25512@item ev4
25513@itemx ev45
25514@itemx 21064
25515Schedules as an EV4 and has no instruction set extensions.
25516
25517@item ev5
25518@itemx 21164
25519Schedules as an EV5 and has no instruction set extensions.
25520
25521@item ev56
25522@itemx 21164a
25523Schedules as an EV5 and supports the BWX extension.
25524
25525@item pca56
25526@itemx 21164pc
25527@itemx 21164PC
25528Schedules as an EV5 and supports the BWX and MAX extensions.
25529
25530@item ev6
25531@itemx 21264
25532Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
25533
25534@item ev67
25535@itemx 21264a
25536Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
25537@end table
25538
25539Native toolchains also support the value @samp{native},
25540which selects the best architecture option for the host processor.
25541@option{-mcpu=native} has no effect if GCC does not recognize
25542the processor.
25543
d77de738 25544@opindex mtune
ddf6fe37 25545@item -mtune=@var{cpu_type}
d77de738
ML
25546Set only the instruction scheduling parameters for machine type
25547@var{cpu_type}. The instruction set is not changed.
25548
25549Native toolchains also support the value @samp{native},
25550which selects the best architecture option for the host processor.
25551@option{-mtune=native} has no effect if GCC does not recognize
25552the processor.
25553
d77de738 25554@opindex mmemory-latency
ddf6fe37 25555@item -mmemory-latency=@var{time}
d77de738
ML
25556Sets the latency the scheduler should assume for typical memory
25557references as seen by the application. This number is highly
25558dependent on the memory access patterns used by the application
25559and the size of the external cache on the machine.
25560
25561Valid options for @var{time} are
25562
25563@table @samp
25564@item @var{number}
25565A decimal number representing clock cycles.
25566
25567@item L1
25568@itemx L2
25569@itemx L3
25570@itemx main
25571The compiler contains estimates of the number of clock cycles for
25572``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
25573(also called Dcache, Scache, and Bcache), as well as to main memory.
25574Note that L3 is only valid for EV5.
25575
25576@end table
25577@end table
25578
25579@node eBPF Options
25580@subsection eBPF Options
25581@cindex eBPF Options
25582
25583@table @gcctabopt
25584@item -mframe-limit=@var{bytes}
25585This specifies the hard limit for frame sizes, in bytes. Currently,
25586the value that can be specified should be less than or equal to
25587@samp{32767}. Defaults to whatever limit is imposed by the version of
25588the Linux kernel targeted.
25589
d77de738 25590@opindex mbig-endian
ddf6fe37 25591@item -mbig-endian
d77de738
ML
25592Generate code for a big-endian target.
25593
d77de738 25594@opindex mlittle-endian
ddf6fe37 25595@item -mlittle-endian
d77de738
ML
25596Generate code for a little-endian target. This is the default.
25597
d77de738 25598@opindex mjmpext
ddf6fe37 25599@item -mjmpext
9cbf4286
DF
25600@itemx -mno-jmpext
25601Enable or disable generation of extra conditional-branch instructions.
d77de738
ML
25602Enabled for CPU v2 and above.
25603
d77de738 25604@opindex mjmp32
ddf6fe37 25605@item -mjmp32
9cbf4286
DF
25606@itemx -mno-jmp32
25607Enable or disable generation of 32-bit jump instructions.
25608Enabled for CPU v3 and above.
d77de738 25609
d77de738 25610@opindex malu32
ddf6fe37 25611@item -malu32
9cbf4286
DF
25612@itemx -mno-alu32
25613Enable or disable generation of 32-bit ALU instructions.
25614Enabled for CPU v3 and above.
25615
25616@opindex mv3-atomics
25617@item -mv3-atomics
25618@itemx -mno-v3-atomics
25619Enable or disable instructions for general atomic operations introduced
25620in CPU v3. Enabled for CPU v3 and above.
d77de738 25621
f1e34551
JM
25622@opindex mbswap
25623@item -mbswap
9cbf4286
DF
25624@itemx -mno-bswap
25625Enable or disable byte swap instructions. Enabled for CPU v4 and above.
f1e34551 25626
4be3919f
JM
25627@opindex msdiv
25628@item -msdiv
9cbf4286
DF
25629@itemx -mno-sdiv
25630Enable or disable signed division and modulus instructions. Enabled for
25631CPU v4 and above.
db189d02 25632
14dab1a1
DF
25633@opindex msmov
25634@item -msmov
25635@itemx -mno-smov
25636Enable or disable sign-extending move and memory load instructions.
25637Enabled for CPU v4 and above.
25638
d77de738 25639@opindex mcpu
ddf6fe37 25640@item -mcpu=@var{version}
d77de738 25641This specifies which version of the eBPF ISA to target. Newer versions
f1e34551 25642may not be supported by all kernels. The default is @samp{v4}.
d77de738
ML
25643
25644Supported values for @var{version} are:
25645
25646@table @samp
25647@item v1
25648The first stable eBPF ISA with no special features or extensions.
25649
25650@item v2
25651Supports the jump extensions, as in @option{-mjmpext}.
25652
25653@item v3
25654All features of v2, plus:
25655@itemize @minus
25656@item 32-bit jump operations, as in @option{-mjmp32}
25657@item 32-bit ALU operations, as in @option{-malu32}
db189d02 25658@item general atomic operations, as in @option{-mv3-atomics}
d77de738
ML
25659@end itemize
25660
f1e34551
JM
25661@item v4
25662All features of v3, plus:
25663@itemize @minus
25664@item Byte swap instructions, as in @option{-mbswap}
9cbf4286 25665@item Signed division and modulus instructions, as in @option{-msdiv}
14dab1a1 25666@item Sign-extending move and memory load instructions, as in @option{-msmov}
f1e34551 25667@end itemize
d77de738
ML
25668@end table
25669
d77de738 25670@opindex mco-re
ddf6fe37 25671@item -mco-re
d77de738
ML
25672Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
25673is implied by @option{-gbtf}.
25674
d77de738 25675@opindex mno-co-re
ddf6fe37 25676@item -mno-co-re
d77de738
ML
25677Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
25678support is enabled by default when generating BTF debug information for
25679the BPF target.
25680
25681@item -mxbpf
25682Generate code for an expanded version of BPF, which relaxes some of
25683the restrictions imposed by the BPF architecture:
25684@itemize @minus
25685@item Save and restore callee-saved registers at function entry and
25686exit, respectively.
25687@end itemize
77d0f9ec
CM
25688
25689@opindex masm=@var{dialect}
25690@item -masm=@var{dialect}
25691Outputs assembly instructions using eBPF selected @var{dialect}. The default
25692is @samp{normal}.
25693
25694Supported values for @var{dialect} are:
25695
25696@table @samp
25697@item normal
25698Outputs normal assembly dialect.
25699
25700@item pseudoc
25701Outputs pseudo-c assembly dialect.
25702
25703@end table
25704
0e850eff
DF
25705@opindex -minline-memops-threshold
25706@item -minline-memops-threshold=@var{bytes}
25707Specifies a size threshold in bytes at or below which memmove, memcpy
25708and memset shall always be expanded inline. Operations dealing with
25709sizes larger than this threshold would have to be be implemented using
25710a library call instead of being expanded inline, but since BPF doesn't
25711allow libcalls, exceeding this threshold results in a compile-time
25712error. The default is @samp{1024} bytes.
25713
d77de738
ML
25714@end table
25715
25716@node FR30 Options
25717@subsection FR30 Options
25718@cindex FR30 Options
25719
25720These options are defined specifically for the FR30 port.
25721
25722@table @gcctabopt
25723
d77de738 25724@opindex msmall-model
ddf6fe37 25725@item -msmall-model
d77de738
ML
25726Use the small address space model. This can produce smaller code, but
25727it does assume that all symbolic values and addresses fit into a
2572820-bit range.
25729
d77de738 25730@opindex mno-lsim
ddf6fe37 25731@item -mno-lsim
d77de738
ML
25732Assume that runtime support has been provided and so there is no need
25733to include the simulator library (@file{libsim.a}) on the linker
25734command line.
25735
25736@end table
25737
25738@node FT32 Options
25739@subsection FT32 Options
25740@cindex FT32 Options
25741
25742These options are defined specifically for the FT32 port.
25743
25744@table @gcctabopt
25745
d77de738 25746@opindex msim
ddf6fe37 25747@item -msim
d77de738
ML
25748Specifies that the program will be run on the simulator. This causes
25749an alternate runtime startup and library to be linked.
25750You must not use this option when generating programs that will run on
25751real hardware; you must provide your own runtime library for whatever
25752I/O functions are needed.
25753
d77de738 25754@opindex mlra
ddf6fe37 25755@item -mlra
d77de738
ML
25756Enable Local Register Allocation. This is still experimental for FT32,
25757so by default the compiler uses standard reload.
25758
d77de738 25759@opindex mnodiv
ddf6fe37 25760@item -mnodiv
d77de738
ML
25761Do not use div and mod instructions.
25762
d77de738 25763@opindex mft32b
ddf6fe37 25764@item -mft32b
d77de738
ML
25765Enable use of the extended instructions of the FT32B processor.
25766
d77de738 25767@opindex mcompress
ddf6fe37 25768@item -mcompress
d77de738
ML
25769Compress all code using the Ft32B code compression scheme.
25770
d77de738 25771@opindex mnopm
ddf6fe37 25772@item -mnopm
d77de738
ML
25773Do not generate code that reads program memory.
25774
25775@end table
25776
25777@node FRV Options
25778@subsection FRV Options
25779@cindex FRV Options
25780
25781@table @gcctabopt
d77de738 25782@opindex mgpr-32
ddf6fe37 25783@item -mgpr-32
d77de738
ML
25784
25785Only use the first 32 general-purpose registers.
25786
d77de738 25787@opindex mgpr-64
ddf6fe37 25788@item -mgpr-64
d77de738
ML
25789
25790Use all 64 general-purpose registers.
25791
d77de738 25792@opindex mfpr-32
ddf6fe37 25793@item -mfpr-32
d77de738
ML
25794
25795Use only the first 32 floating-point registers.
25796
d77de738 25797@opindex mfpr-64
ddf6fe37 25798@item -mfpr-64
d77de738
ML
25799
25800Use all 64 floating-point registers.
25801
d77de738 25802@opindex mhard-float
ddf6fe37 25803@item -mhard-float
d77de738
ML
25804
25805Use hardware instructions for floating-point operations.
25806
d77de738 25807@opindex msoft-float
ddf6fe37 25808@item -msoft-float
d77de738
ML
25809
25810Use library routines for floating-point operations.
25811
d77de738 25812@opindex malloc-cc
ddf6fe37 25813@item -malloc-cc
d77de738
ML
25814
25815Dynamically allocate condition code registers.
25816
d77de738 25817@opindex mfixed-cc
ddf6fe37 25818@item -mfixed-cc
d77de738
ML
25819
25820Do not try to dynamically allocate condition code registers, only
25821use @code{icc0} and @code{fcc0}.
25822
d77de738 25823@opindex mdword
ddf6fe37 25824@item -mdword
d77de738
ML
25825
25826Change ABI to use double word insns.
25827
d77de738
ML
25828@opindex mno-dword
25829@opindex mdword
ddf6fe37 25830@item -mno-dword
d77de738
ML
25831
25832Do not use double word instructions.
25833
d77de738 25834@opindex mdouble
ddf6fe37 25835@item -mdouble
d77de738
ML
25836
25837Use floating-point double instructions.
25838
d77de738 25839@opindex mno-double
ddf6fe37 25840@item -mno-double
d77de738
ML
25841
25842Do not use floating-point double instructions.
25843
d77de738 25844@opindex mmedia
ddf6fe37 25845@item -mmedia
d77de738
ML
25846
25847Use media instructions.
25848
d77de738 25849@opindex mno-media
ddf6fe37 25850@item -mno-media
d77de738
ML
25851
25852Do not use media instructions.
25853
d77de738 25854@opindex mmuladd
ddf6fe37 25855@item -mmuladd
d77de738
ML
25856
25857Use multiply and add/subtract instructions.
25858
d77de738 25859@opindex mno-muladd
ddf6fe37 25860@item -mno-muladd
d77de738
ML
25861
25862Do not use multiply and add/subtract instructions.
25863
d77de738 25864@opindex mfdpic
ddf6fe37 25865@item -mfdpic
d77de738
ML
25866
25867Select the FDPIC ABI, which uses function descriptors to represent
25868pointers to functions. Without any PIC/PIE-related options, it
25869implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
25870assumes GOT entries and small data are within a 12-bit range from the
25871GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
25872are computed with 32 bits.
25873With a @samp{bfin-elf} target, this option implies @option{-msim}.
25874
d77de738 25875@opindex minline-plt
ddf6fe37 25876@item -minline-plt
d77de738
ML
25877
25878Enable inlining of PLT entries in function calls to functions that are
25879not known to bind locally. It has no effect without @option{-mfdpic}.
25880It's enabled by default if optimizing for speed and compiling for
25881shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
25882optimization option such as @option{-O3} or above is present in the
25883command line.
25884
d77de738 25885@opindex mTLS
ddf6fe37 25886@item -mTLS
d77de738
ML
25887
25888Assume a large TLS segment when generating thread-local code.
25889
d77de738 25890@opindex mtls
ddf6fe37 25891@item -mtls
d77de738
ML
25892
25893Do not assume a large TLS segment when generating thread-local code.
25894
d77de738 25895@opindex mgprel-ro
ddf6fe37 25896@item -mgprel-ro
d77de738
ML
25897
25898Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
25899that is known to be in read-only sections. It's enabled by default,
25900except for @option{-fpic} or @option{-fpie}: even though it may help
25901make the global offset table smaller, it trades 1 instruction for 4.
25902With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
25903one of which may be shared by multiple symbols, and it avoids the need
25904for a GOT entry for the referenced symbol, so it's more likely to be a
25905win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
25906
d77de738 25907@opindex multilib-library-pic
ddf6fe37 25908@item -multilib-library-pic
d77de738
ML
25909
25910Link with the (library, not FD) pic libraries. It's implied by
25911@option{-mlibrary-pic}, as well as by @option{-fPIC} and
25912@option{-fpic} without @option{-mfdpic}. You should never have to use
25913it explicitly.
25914
d77de738 25915@opindex mlinked-fp
ddf6fe37 25916@item -mlinked-fp
d77de738
ML
25917
25918Follow the EABI requirement of always creating a frame pointer whenever
25919a stack frame is allocated. This option is enabled by default and can
25920be disabled with @option{-mno-linked-fp}.
25921
d77de738 25922@opindex mlong-calls
ddf6fe37 25923@item -mlong-calls
d77de738
ML
25924
25925Use indirect addressing to call functions outside the current
25926compilation unit. This allows the functions to be placed anywhere
25927within the 32-bit address space.
25928
d77de738 25929@opindex malign-labels
ddf6fe37 25930@item -malign-labels
d77de738
ML
25931
25932Try to align labels to an 8-byte boundary by inserting NOPs into the
25933previous packet. This option only has an effect when VLIW packing
25934is enabled. It doesn't create new packets; it merely adds NOPs to
25935existing ones.
25936
d77de738 25937@opindex mlibrary-pic
ddf6fe37 25938@item -mlibrary-pic
d77de738
ML
25939
25940Generate position-independent EABI code.
25941
d77de738 25942@opindex macc-4
ddf6fe37 25943@item -macc-4
d77de738
ML
25944
25945Use only the first four media accumulator registers.
25946
d77de738 25947@opindex macc-8
ddf6fe37 25948@item -macc-8
d77de738
ML
25949
25950Use all eight media accumulator registers.
25951
d77de738 25952@opindex mpack
ddf6fe37 25953@item -mpack
d77de738
ML
25954
25955Pack VLIW instructions.
25956
d77de738 25957@opindex mno-pack
ddf6fe37 25958@item -mno-pack
d77de738
ML
25959
25960Do not pack VLIW instructions.
25961
d77de738 25962@opindex mno-eflags
ddf6fe37 25963@item -mno-eflags
d77de738
ML
25964
25965Do not mark ABI switches in e_flags.
25966
d77de738 25967@opindex mcond-move
ddf6fe37 25968@item -mcond-move
d77de738
ML
25969
25970Enable the use of conditional-move instructions (default).
25971
25972This switch is mainly for debugging the compiler and will likely be removed
25973in a future version.
25974
d77de738 25975@opindex mno-cond-move
ddf6fe37 25976@item -mno-cond-move
d77de738
ML
25977
25978Disable the use of conditional-move instructions.
25979
25980This switch is mainly for debugging the compiler and will likely be removed
25981in a future version.
25982
d77de738 25983@opindex mscc
ddf6fe37 25984@item -mscc
d77de738
ML
25985
25986Enable the use of conditional set instructions (default).
25987
25988This switch is mainly for debugging the compiler and will likely be removed
25989in a future version.
25990
d77de738 25991@opindex mno-scc
ddf6fe37 25992@item -mno-scc
d77de738
ML
25993
25994Disable the use of conditional set instructions.
25995
25996This switch is mainly for debugging the compiler and will likely be removed
25997in a future version.
25998
d77de738 25999@opindex mcond-exec
ddf6fe37 26000@item -mcond-exec
d77de738
ML
26001
26002Enable the use of conditional execution (default).
26003
26004This switch is mainly for debugging the compiler and will likely be removed
26005in a future version.
26006
d77de738 26007@opindex mno-cond-exec
ddf6fe37 26008@item -mno-cond-exec
d77de738
ML
26009
26010Disable the use of conditional execution.
26011
26012This switch is mainly for debugging the compiler and will likely be removed
26013in a future version.
26014
d77de738 26015@opindex mvliw-branch
ddf6fe37 26016@item -mvliw-branch
d77de738
ML
26017
26018Run a pass to pack branches into VLIW instructions (default).
26019
26020This switch is mainly for debugging the compiler and will likely be removed
26021in a future version.
26022
d77de738 26023@opindex mno-vliw-branch
ddf6fe37 26024@item -mno-vliw-branch
d77de738
ML
26025
26026Do not run a pass to pack branches into VLIW instructions.
26027
26028This switch is mainly for debugging the compiler and will likely be removed
26029in a future version.
26030
d77de738 26031@opindex mmulti-cond-exec
ddf6fe37 26032@item -mmulti-cond-exec
d77de738
ML
26033
26034Enable optimization of @code{&&} and @code{||} in conditional execution
26035(default).
26036
26037This switch is mainly for debugging the compiler and will likely be removed
26038in a future version.
26039
d77de738 26040@opindex mno-multi-cond-exec
ddf6fe37 26041@item -mno-multi-cond-exec
d77de738
ML
26042
26043Disable optimization of @code{&&} and @code{||} in conditional execution.
26044
26045This switch is mainly for debugging the compiler and will likely be removed
26046in a future version.
26047
d77de738 26048@opindex mnested-cond-exec
ddf6fe37 26049@item -mnested-cond-exec
d77de738
ML
26050
26051Enable nested conditional execution optimizations (default).
26052
26053This switch is mainly for debugging the compiler and will likely be removed
26054in a future version.
26055
d77de738 26056@opindex mno-nested-cond-exec
ddf6fe37 26057@item -mno-nested-cond-exec
d77de738
ML
26058
26059Disable nested conditional execution optimizations.
26060
26061This switch is mainly for debugging the compiler and will likely be removed
26062in a future version.
26063
d77de738 26064@opindex moptimize-membar
ddf6fe37 26065@item -moptimize-membar
d77de738
ML
26066
26067This switch removes redundant @code{membar} instructions from the
26068compiler-generated code. It is enabled by default.
26069
d77de738
ML
26070@opindex mno-optimize-membar
26071@opindex moptimize-membar
ddf6fe37 26072@item -mno-optimize-membar
d77de738
ML
26073
26074This switch disables the automatic removal of redundant @code{membar}
26075instructions from the generated code.
26076
d77de738 26077@opindex mtomcat-stats
ddf6fe37 26078@item -mtomcat-stats
d77de738
ML
26079
26080Cause gas to print out tomcat statistics.
26081
d77de738 26082@opindex mcpu
ddf6fe37 26083@item -mcpu=@var{cpu}
d77de738
ML
26084
26085Select the processor type for which to generate code. Possible values are
26086@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
26087@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
26088
26089@end table
26090
26091@node GNU/Linux Options
26092@subsection GNU/Linux Options
26093
26094These @samp{-m} options are defined for GNU/Linux targets:
26095
26096@table @gcctabopt
d77de738 26097@opindex mglibc
ddf6fe37 26098@item -mglibc
d77de738
ML
26099Use the GNU C library. This is the default except
26100on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
26101@samp{*-*-linux-*android*} targets.
26102
d77de738 26103@opindex muclibc
ddf6fe37 26104@item -muclibc
d77de738
ML
26105Use uClibc C library. This is the default on
26106@samp{*-*-linux-*uclibc*} targets.
26107
d77de738 26108@opindex mmusl
ddf6fe37 26109@item -mmusl
d77de738
ML
26110Use the musl C library. This is the default on
26111@samp{*-*-linux-*musl*} targets.
26112
d77de738 26113@opindex mbionic
ddf6fe37 26114@item -mbionic
d77de738
ML
26115Use Bionic C library. This is the default on
26116@samp{*-*-linux-*android*} targets.
26117
d77de738 26118@opindex mandroid
ddf6fe37 26119@item -mandroid
d77de738
ML
26120Compile code compatible with Android platform. This is the default on
26121@samp{*-*-linux-*android*} targets.
26122
26123When compiling, this option enables @option{-mbionic}, @option{-fPIC},
26124@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
26125this option makes the GCC driver pass Android-specific options to the linker.
26126Finally, this option causes the preprocessor macro @code{__ANDROID__}
26127to be defined.
26128
d77de738 26129@opindex tno-android-cc
ddf6fe37 26130@item -tno-android-cc
d77de738
ML
26131Disable compilation effects of @option{-mandroid}, i.e., do not enable
26132@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
26133@option{-fno-rtti} by default.
26134
d77de738 26135@opindex tno-android-ld
ddf6fe37 26136@item -tno-android-ld
d77de738
ML
26137Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
26138linking options to the linker.
26139
26140@end table
26141
26142@node H8/300 Options
26143@subsection H8/300 Options
26144
26145These @samp{-m} options are defined for the H8/300 implementations:
26146
26147@table @gcctabopt
d77de738 26148@opindex mrelax
ddf6fe37 26149@item -mrelax
d77de738
ML
26150Shorten some address references at link time, when possible; uses the
26151linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
26152ld, Using ld}, for a fuller description.
26153
d77de738 26154@opindex mh
ddf6fe37 26155@item -mh
d77de738
ML
26156Generate code for the H8/300H@.
26157
d77de738 26158@opindex ms
ddf6fe37 26159@item -ms
d77de738
ML
26160Generate code for the H8S@.
26161
d77de738 26162@opindex mn
ddf6fe37 26163@item -mn
d77de738
ML
26164Generate code for the H8S and H8/300H in the normal mode. This switch
26165must be used either with @option{-mh} or @option{-ms}.
26166
d77de738 26167@opindex ms2600
ddf6fe37 26168@item -ms2600
d77de738
ML
26169Generate code for the H8S/2600. This switch must be used with @option{-ms}.
26170
d77de738 26171@opindex mexr
ddf6fe37 26172@item -mexr
d77de738
ML
26173Extended registers are stored on stack before execution of function
26174with monitor attribute. Default option is @option{-mexr}.
26175This option is valid only for H8S targets.
26176
d77de738
ML
26177@opindex mno-exr
26178@opindex mexr
ddf6fe37 26179@item -mno-exr
d77de738
ML
26180Extended registers are not stored on stack before execution of function
26181with monitor attribute. Default option is @option{-mno-exr}.
26182This option is valid only for H8S targets.
26183
d77de738 26184@opindex mint32
ddf6fe37 26185@item -mint32
d77de738
ML
26186Make @code{int} data 32 bits by default.
26187
d77de738 26188@opindex malign-300
ddf6fe37 26189@item -malign-300
d77de738
ML
26190On the H8/300H and H8S, use the same alignment rules as for the H8/300.
26191The default for the H8/300H and H8S is to align longs and floats on
261924-byte boundaries.
26193@option{-malign-300} causes them to be aligned on 2-byte boundaries.
26194This option has no effect on the H8/300.
26195@end table
26196
26197@node HPPA Options
26198@subsection HPPA Options
26199@cindex HPPA Options
26200
26201These @samp{-m} options are defined for the HPPA family of computers:
26202
26203@table @gcctabopt
d77de738 26204@opindex march
ddf6fe37 26205@item -march=@var{architecture-type}
d77de738
ML
26206Generate code for the specified architecture. The choices for
26207@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
262081.1, and @samp{2.0} for PA 2.0 processors. Refer to
26209@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
26210architecture option for your machine. Code compiled for lower numbered
26211architectures runs on higher numbered architectures, but not the
26212other way around.
26213
d77de738
ML
26214@opindex mpa-risc-1-0
26215@opindex mpa-risc-1-1
26216@opindex mpa-risc-2-0
ddf6fe37
AA
26217@item -mpa-risc-1-0
26218@itemx -mpa-risc-1-1
26219@itemx -mpa-risc-2-0
d77de738
ML
26220Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
26221
cf467fb9
JDA
26222@opindex matomic-libcalls
26223@opindex mno-atomic-libcalls
ddf6fe37 26224@item -matomic-libcalls
cf467fb9
JDA
26225Generate libcalls for atomic loads and stores when sync libcalls are disabled.
26226This option is enabled by default. It only affects the generation of
26227atomic libcalls by the HPPA backend.
26228
26229Both the sync and @file{libatomic} libcall implementations use locking.
26230As a result, processor stores are not atomic with respect to other
26231atomic operations. Processor loads up to DImode are atomic with
26232respect to other atomic operations provided they are implemented as
26233a single access.
26234
26235The PA-RISC architecture does not support any atomic operations in
26236hardware except for the @code{ldcw} instruction. Thus, all atomic
26237support is implemented using sync and atomic libcalls. Sync libcall
26238support is in @file{libgcc.a}. Atomic libcall support is in
26239@file{libatomic}.
26240
26241This option generates @code{__atomic_exchange} calls for atomic stores.
26242It also provides special handling for atomic DImode accesses on 32-bit
26243targets.
26244
cf467fb9 26245@opindex mbig-switch
ddf6fe37 26246@item -mbig-switch
cf467fb9
JDA
26247Does nothing. Preserved for backward compatibility.
26248
d77de738 26249@opindex mcaller-copies
ddf6fe37 26250@item -mcaller-copies
d77de738
ML
26251The caller copies function arguments passed by hidden reference. This
26252option should be used with care as it is not compatible with the default
2625332-bit runtime. However, only aggregates larger than eight bytes are
26254passed by hidden reference and the option provides better compatibility
26255with OpenMP.
26256
cf467fb9 26257@opindex mcoherent-ldcw
ddf6fe37 26258@item -mcoherent-ldcw
cf467fb9 26259Use ldcw/ldcd coherent cache-control hint.
d77de738 26260
d77de738 26261@opindex mdisable-fpregs
ddf6fe37 26262@item -mdisable-fpregs
cf467fb9 26263Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738 26264
d77de738 26265@opindex mdisable-indexing
ddf6fe37 26266@item -mdisable-indexing
d77de738
ML
26267Prevent the compiler from using indexing address modes. This avoids some
26268rather obscure problems when compiling MIG generated code under MACH@.
26269
d77de738 26270@opindex mfast-indirect-calls
ddf6fe37 26271@item -mfast-indirect-calls
d77de738
ML
26272Generate code that assumes calls never cross space boundaries. This
26273allows GCC to emit code that performs faster indirect calls.
26274
26275This option does not work in the presence of shared libraries or nested
26276functions.
26277
d77de738 26278@opindex mfixed-range
ddf6fe37 26279@item -mfixed-range=@var{register-range}
d77de738
ML
26280Generate code treating the given register range as fixed registers.
26281A fixed register is one that the register allocator cannot use. This is
26282useful when compiling kernel code. A register range is specified as
26283two registers separated by a dash. Multiple register ranges can be
26284specified separated by a comma.
26285
d77de738 26286@opindex mgas
ddf6fe37 26287@item -mgas
d77de738
ML
26288Enable the use of assembler directives only GAS understands.
26289
d77de738 26290@opindex mgnu-ld
ddf6fe37 26291@item -mgnu-ld
d77de738
ML
26292Use options specific to GNU @command{ld}.
26293This passes @option{-shared} to @command{ld} when
26294building a shared library. It is the default when GCC is configured,
26295explicitly or implicitly, with the GNU linker. This option does not
26296affect which @command{ld} is called; it only changes what parameters
26297are passed to that @command{ld}.
26298The @command{ld} that is called is determined by the
26299@option{--with-ld} configure option, GCC's program search path, and
26300finally by the user's @env{PATH}. The linker used by GCC can be printed
26301using @samp{which `gcc -print-prog-name=ld`}. This option is only available
26302on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
26303
d77de738 26304@opindex mhp-ld
ddf6fe37 26305@item -mhp-ld
d77de738
ML
26306Use options specific to HP @command{ld}.
26307This passes @option{-b} to @command{ld} when building
26308a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
26309links. It is the default when GCC is configured, explicitly or
26310implicitly, with the HP linker. This option does not affect
26311which @command{ld} is called; it only changes what parameters are passed to that
26312@command{ld}.
26313The @command{ld} that is called is determined by the @option{--with-ld}
26314configure option, GCC's program search path, and finally by the user's
26315@env{PATH}. The linker used by GCC can be printed using @samp{which
26316`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
26317HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
26318
cf467fb9 26319@opindex mlinker-opt
ddf6fe37 26320@item -mlinker-opt
cf467fb9
JDA
26321Enable the optimization pass in the HP-UX linker. Note this makes symbolic
26322debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
26323linkers in which they give bogus error messages when linking some programs.
26324
d77de738
ML
26325@opindex mno-long-calls
26326@opindex mlong-calls
ddf6fe37 26327@item -mlong-calls
d77de738
ML
26328Generate code that uses long call sequences. This ensures that a call
26329is always able to reach linker generated stubs. The default is to generate
26330long calls only when the distance from the call site to the beginning
26331of the function or translation unit, as the case may be, exceeds a
26332predefined limit set by the branch type being used. The limits for
26333normal calls are 7,600,000 and 240,000 bytes, respectively for the
26334PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
26335240,000 bytes.
26336
26337Distances are measured from the beginning of functions when using the
26338@option{-ffunction-sections} option, or when using the @option{-mgas}
26339and @option{-mno-portable-runtime} options together under HP-UX with
26340the SOM linker.
26341
26342It is normally not desirable to use this option as it degrades
26343performance. However, it may be useful in large applications,
26344particularly when partial linking is used to build the application.
26345
26346The types of long calls used depends on the capabilities of the
26347assembler and linker, and the type of code being generated. The
26348impact on systems that support long absolute calls, and long pic
26349symbol-difference or pc-relative calls should be relatively small.
26350However, an indirect call is used on 32-bit ELF systems in pic code
26351and it is quite long.
26352
cf467fb9 26353@opindex mlong-load-store
ddf6fe37 26354@item -mlong-load-store
cf467fb9
JDA
26355Generate 3-instruction load and store sequences as sometimes required by
26356the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
26357the HP compilers.
26358
cf467fb9 26359@opindex mjump-in-delay
ddf6fe37 26360@item -mjump-in-delay
cf467fb9
JDA
26361This option is ignored and provided for compatibility purposes only.
26362
cf467fb9
JDA
26363@opindex mno-space-regs
26364@opindex mspace-regs
ddf6fe37 26365@item -mno-space-regs
cf467fb9
JDA
26366Generate code that assumes the target has no space registers. This allows
26367GCC to generate faster indirect calls and use unscaled index address modes.
26368
26369Such code is suitable for level 0 PA systems and kernels.
26370
cf467fb9 26371@opindex mordered
ddf6fe37 26372@item -mordered
cf467fb9
JDA
26373Assume memory references are ordered and barriers are not needed.
26374
cf467fb9 26375@opindex mportable-runtime
ddf6fe37 26376@item -mportable-runtime
cf467fb9
JDA
26377Use the portable calling conventions proposed by HP for ELF systems.
26378
cf467fb9 26379@opindex mschedule
ddf6fe37 26380@item -mschedule=@var{cpu-type}
cf467fb9
JDA
26381Schedule code according to the constraints for the machine type
26382@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
26383@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
26384to @file{/usr/lib/sched.models} on an HP-UX system to determine the
26385proper scheduling option for your machine. The default scheduling is
26386@samp{8000}.
26387
cf467fb9 26388@opindex msio
ddf6fe37 26389@item -msio
cf467fb9
JDA
26390Generate the predefine, @code{_SIO}, for server IO@. The default is
26391@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
26392@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
26393options are available under HP-UX and HI-UX@.
26394
cf467fb9 26395@opindex msoft-float
ddf6fe37 26396@item -msoft-float
cf467fb9
JDA
26397Generate output containing library calls for floating point.
26398@strong{Warning:} the requisite libraries are not available for all HPPA
26399targets. Normally the facilities of the machine's usual C compiler are
26400used, but this cannot be done directly in cross-compilation. You must make
26401your own arrangements to provide suitable library functions for
26402cross-compilation.
26403
26404@option{-msoft-float} changes the calling convention in the output file;
26405therefore, it is only useful if you compile @emph{all} of a program with
26406this option. In particular, you need to compile @file{libgcc.a}, the
26407library that comes with GCC, with @option{-msoft-float} in order for
26408this to work.
26409
cf467fb9 26410@opindex msoft-mult
ddf6fe37 26411@item -msoft-mult
cf467fb9
JDA
26412Use software integer multiplication.
26413
26414This disables the use of the @code{xmpyu} instruction.
26415
d77de738 26416@opindex march
ddf6fe37 26417@item -munix=@var{unix-std}
d77de738
ML
26418Generate compiler predefines and select a startfile for the specified
26419UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
26420and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
26421is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2642211.11 and later. The default values are @samp{93} for HP-UX 10.00,
26423@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
26424and later.
26425
26426@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
26427@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
26428and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
26429@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
26430@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
26431@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
26432
26433It is @emph{important} to note that this option changes the interfaces
26434for various library routines. It also affects the operational behavior
26435of the C library. Thus, @emph{extreme} care is needed in using this
26436option.
26437
26438Library code that is intended to operate with more than one UNIX
26439standard must test, set and restore the variable @code{__xpg4_extended_mask}
26440as appropriate. Most GNU software doesn't provide this capability.
26441
d77de738 26442@opindex nolibdld
ddf6fe37 26443@item -nolibdld
d77de738
ML
26444Suppress the generation of link options to search libdld.sl when the
26445@option{-static} option is specified on HP-UX 10 and later.
26446
d77de738 26447@opindex static
ddf6fe37 26448@item -static
d77de738
ML
26449The HP-UX implementation of setlocale in libc has a dependency on
26450libdld.sl. There isn't an archive version of libdld.sl. Thus,
26451when the @option{-static} option is specified, special link options
26452are needed to resolve this dependency.
26453
26454On HP-UX 10 and later, the GCC driver adds the necessary options to
26455link with libdld.sl when the @option{-static} option is specified.
26456This causes the resulting binary to be dynamic. On the 64-bit port,
26457the linkers generate dynamic binaries by default in any case. The
26458@option{-nolibdld} option can be used to prevent the GCC driver from
26459adding these link options.
26460
d77de738 26461@opindex threads
ddf6fe37 26462@item -threads
d77de738
ML
26463Add support for multithreading with the @dfn{dce thread} library
26464under HP-UX@. This option sets flags for both the preprocessor and
26465linker.
26466@end table
26467
26468@node IA-64 Options
26469@subsection IA-64 Options
26470@cindex IA-64 Options
26471
26472These are the @samp{-m} options defined for the Intel IA-64 architecture.
26473
26474@table @gcctabopt
d77de738 26475@opindex mbig-endian
ddf6fe37 26476@item -mbig-endian
d77de738
ML
26477Generate code for a big-endian target. This is the default for HP-UX@.
26478
d77de738 26479@opindex mlittle-endian
ddf6fe37 26480@item -mlittle-endian
d77de738
ML
26481Generate code for a little-endian target. This is the default for AIX5
26482and GNU/Linux.
26483
d77de738
ML
26484@opindex mgnu-as
26485@opindex mno-gnu-as
ddf6fe37
AA
26486@item -mgnu-as
26487@itemx -mno-gnu-as
d77de738
ML
26488Generate (or don't) code for the GNU assembler. This is the default.
26489@c Also, this is the default if the configure option @option{--with-gnu-as}
26490@c is used.
26491
d77de738
ML
26492@opindex mgnu-ld
26493@opindex mno-gnu-ld
ddf6fe37
AA
26494@item -mgnu-ld
26495@itemx -mno-gnu-ld
d77de738
ML
26496Generate (or don't) code for the GNU linker. This is the default.
26497@c Also, this is the default if the configure option @option{--with-gnu-ld}
26498@c is used.
26499
d77de738 26500@opindex mno-pic
ddf6fe37 26501@item -mno-pic
d77de738
ML
26502Generate code that does not use a global pointer register. The result
26503is not position independent code, and violates the IA-64 ABI@.
26504
d77de738
ML
26505@opindex mvolatile-asm-stop
26506@opindex mno-volatile-asm-stop
ddf6fe37
AA
26507@item -mvolatile-asm-stop
26508@itemx -mno-volatile-asm-stop
d77de738
ML
26509Generate (or don't) a stop bit immediately before and after volatile asm
26510statements.
26511
d77de738
ML
26512@opindex mregister-names
26513@opindex mno-register-names
ddf6fe37
AA
26514@item -mregister-names
26515@itemx -mno-register-names
d77de738
ML
26516Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
26517the stacked registers. This may make assembler output more readable.
26518
d77de738
ML
26519@opindex mno-sdata
26520@opindex msdata
ddf6fe37
AA
26521@item -mno-sdata
26522@itemx -msdata
d77de738
ML
26523Disable (or enable) optimizations that use the small data section. This may
26524be useful for working around optimizer bugs.
26525
d77de738 26526@opindex mconstant-gp
ddf6fe37 26527@item -mconstant-gp
d77de738
ML
26528Generate code that uses a single constant global pointer value. This is
26529useful when compiling kernel code.
26530
d77de738 26531@opindex mauto-pic
ddf6fe37 26532@item -mauto-pic
d77de738
ML
26533Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
26534This is useful when compiling firmware code.
26535
d77de738 26536@opindex minline-float-divide-min-latency
ddf6fe37 26537@item -minline-float-divide-min-latency
d77de738
ML
26538Generate code for inline divides of floating-point values
26539using the minimum latency algorithm.
26540
d77de738 26541@opindex minline-float-divide-max-throughput
ddf6fe37 26542@item -minline-float-divide-max-throughput
d77de738
ML
26543Generate code for inline divides of floating-point values
26544using the maximum throughput algorithm.
26545
d77de738 26546@opindex mno-inline-float-divide
ddf6fe37 26547@item -mno-inline-float-divide
d77de738
ML
26548Do not generate inline code for divides of floating-point values.
26549
d77de738 26550@opindex minline-int-divide-min-latency
ddf6fe37 26551@item -minline-int-divide-min-latency
d77de738
ML
26552Generate code for inline divides of integer values
26553using the minimum latency algorithm.
26554
d77de738 26555@opindex minline-int-divide-max-throughput
ddf6fe37 26556@item -minline-int-divide-max-throughput
d77de738
ML
26557Generate code for inline divides of integer values
26558using the maximum throughput algorithm.
26559
d77de738
ML
26560@opindex mno-inline-int-divide
26561@opindex minline-int-divide
ddf6fe37 26562@item -mno-inline-int-divide
d77de738
ML
26563Do not generate inline code for divides of integer values.
26564
d77de738 26565@opindex minline-sqrt-min-latency
ddf6fe37 26566@item -minline-sqrt-min-latency
d77de738
ML
26567Generate code for inline square roots
26568using the minimum latency algorithm.
26569
d77de738 26570@opindex minline-sqrt-max-throughput
ddf6fe37 26571@item -minline-sqrt-max-throughput
d77de738
ML
26572Generate code for inline square roots
26573using the maximum throughput algorithm.
26574
d77de738 26575@opindex mno-inline-sqrt
ddf6fe37 26576@item -mno-inline-sqrt
d77de738
ML
26577Do not generate inline code for @code{sqrt}.
26578
d77de738
ML
26579@opindex mfused-madd
26580@opindex mno-fused-madd
ddf6fe37
AA
26581@item -mfused-madd
26582@itemx -mno-fused-madd
d77de738
ML
26583Do (don't) generate code that uses the fused multiply/add or multiply/subtract
26584instructions. The default is to use these instructions.
26585
d77de738
ML
26586@opindex mno-dwarf2-asm
26587@opindex mdwarf2-asm
ddf6fe37
AA
26588@item -mno-dwarf2-asm
26589@itemx -mdwarf2-asm
d77de738
ML
26590Don't (or do) generate assembler code for the DWARF line number debugging
26591info. This may be useful when not using the GNU assembler.
26592
d77de738
ML
26593@opindex mearly-stop-bits
26594@opindex mno-early-stop-bits
ddf6fe37
AA
26595@item -mearly-stop-bits
26596@itemx -mno-early-stop-bits
d77de738
ML
26597Allow stop bits to be placed earlier than immediately preceding the
26598instruction that triggered the stop bit. This can improve instruction
26599scheduling, but does not always do so.
26600
d77de738 26601@opindex mfixed-range
ddf6fe37 26602@item -mfixed-range=@var{register-range}
d77de738
ML
26603Generate code treating the given register range as fixed registers.
26604A fixed register is one that the register allocator cannot use. This is
26605useful when compiling kernel code. A register range is specified as
26606two registers separated by a dash. Multiple register ranges can be
26607specified separated by a comma.
26608
d77de738 26609@opindex mtls-size
ddf6fe37 26610@item -mtls-size=@var{tls-size}
d77de738
ML
26611Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2661264.
26613
d77de738 26614@opindex mtune
ddf6fe37 26615@item -mtune=@var{cpu-type}
d77de738
ML
26616Tune the instruction scheduling for a particular CPU, Valid values are
26617@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
26618and @samp{mckinley}.
26619
d77de738
ML
26620@opindex milp32
26621@opindex mlp64
ddf6fe37
AA
26622@item -milp32
26623@itemx -mlp64
d77de738
ML
26624Generate code for a 32-bit or 64-bit environment.
26625The 32-bit environment sets int, long and pointer to 32 bits.
26626The 64-bit environment sets int to 32 bits and long and pointer
26627to 64 bits. These are HP-UX specific flags.
26628
d77de738
ML
26629@opindex mno-sched-br-data-spec
26630@opindex msched-br-data-spec
ddf6fe37
AA
26631@item -mno-sched-br-data-spec
26632@itemx -msched-br-data-spec
d77de738
ML
26633(Dis/En)able data speculative scheduling before reload.
26634This results in generation of @code{ld.a} instructions and
26635the corresponding check instructions (@code{ld.c} / @code{chk.a}).
26636The default setting is disabled.
26637
d77de738
ML
26638@opindex msched-ar-data-spec
26639@opindex mno-sched-ar-data-spec
ddf6fe37
AA
26640@item -msched-ar-data-spec
26641@itemx -mno-sched-ar-data-spec
d77de738
ML
26642(En/Dis)able data speculative scheduling after reload.
26643This results in generation of @code{ld.a} instructions and
26644the corresponding check instructions (@code{ld.c} / @code{chk.a}).
26645The default setting is enabled.
26646
d77de738
ML
26647@opindex mno-sched-control-spec
26648@opindex msched-control-spec
ddf6fe37
AA
26649@item -mno-sched-control-spec
26650@itemx -msched-control-spec
d77de738
ML
26651(Dis/En)able control speculative scheduling. This feature is
26652available only during region scheduling (i.e.@: before reload).
26653This results in generation of the @code{ld.s} instructions and
26654the corresponding check instructions @code{chk.s}.
26655The default setting is disabled.
26656
d77de738
ML
26657@opindex msched-br-in-data-spec
26658@opindex mno-sched-br-in-data-spec
ddf6fe37
AA
26659@item -msched-br-in-data-spec
26660@itemx -mno-sched-br-in-data-spec
d77de738
ML
26661(En/Dis)able speculative scheduling of the instructions that
26662are dependent on the data speculative loads before reload.
26663This is effective only with @option{-msched-br-data-spec} enabled.
26664The default setting is enabled.
26665
d77de738
ML
26666@opindex msched-ar-in-data-spec
26667@opindex mno-sched-ar-in-data-spec
ddf6fe37
AA
26668@item -msched-ar-in-data-spec
26669@itemx -mno-sched-ar-in-data-spec
d77de738
ML
26670(En/Dis)able speculative scheduling of the instructions that
26671are dependent on the data speculative loads after reload.
26672This is effective only with @option{-msched-ar-data-spec} enabled.
26673The default setting is enabled.
26674
d77de738
ML
26675@opindex msched-in-control-spec
26676@opindex mno-sched-in-control-spec
ddf6fe37
AA
26677@item -msched-in-control-spec
26678@itemx -mno-sched-in-control-spec
d77de738
ML
26679(En/Dis)able speculative scheduling of the instructions that
26680are dependent on the control speculative loads.
26681This is effective only with @option{-msched-control-spec} enabled.
26682The default setting is enabled.
26683
d77de738
ML
26684@opindex mno-sched-prefer-non-data-spec-insns
26685@opindex msched-prefer-non-data-spec-insns
ddf6fe37
AA
26686@item -mno-sched-prefer-non-data-spec-insns
26687@itemx -msched-prefer-non-data-spec-insns
d77de738
ML
26688If enabled, data-speculative instructions are chosen for schedule
26689only if there are no other choices at the moment. This makes
26690the use of the data speculation much more conservative.
26691The default setting is disabled.
26692
d77de738
ML
26693@opindex mno-sched-prefer-non-control-spec-insns
26694@opindex msched-prefer-non-control-spec-insns
ddf6fe37
AA
26695@item -mno-sched-prefer-non-control-spec-insns
26696@itemx -msched-prefer-non-control-spec-insns
d77de738
ML
26697If enabled, control-speculative instructions are chosen for schedule
26698only if there are no other choices at the moment. This makes
26699the use of the control speculation much more conservative.
26700The default setting is disabled.
26701
d77de738
ML
26702@opindex mno-sched-count-spec-in-critical-path
26703@opindex msched-count-spec-in-critical-path
ddf6fe37
AA
26704@item -mno-sched-count-spec-in-critical-path
26705@itemx -msched-count-spec-in-critical-path
d77de738
ML
26706If enabled, speculative dependencies are considered during
26707computation of the instructions priorities. This makes the use of the
26708speculation a bit more conservative.
26709The default setting is disabled.
26710
d77de738 26711@opindex msched-spec-ldc
ddf6fe37 26712@item -msched-spec-ldc
d77de738
ML
26713Use a simple data speculation check. This option is on by default.
26714
d77de738 26715@opindex msched-spec-ldc
ddf6fe37 26716@item -msched-control-spec-ldc
d77de738
ML
26717Use a simple check for control speculation. This option is on by default.
26718
d77de738 26719@opindex msched-stop-bits-after-every-cycle
ddf6fe37 26720@item -msched-stop-bits-after-every-cycle
d77de738
ML
26721Place a stop bit after every cycle when scheduling. This option is on
26722by default.
26723
d77de738 26724@opindex msched-fp-mem-deps-zero-cost
ddf6fe37 26725@item -msched-fp-mem-deps-zero-cost
d77de738
ML
26726Assume that floating-point stores and loads are not likely to cause a conflict
26727when placed into the same instruction group. This option is disabled by
26728default.
26729
d77de738 26730@opindex msel-sched-dont-check-control-spec
ddf6fe37 26731@item -msel-sched-dont-check-control-spec
d77de738
ML
26732Generate checks for control speculation in selective scheduling.
26733This flag is disabled by default.
26734
d77de738 26735@opindex msched-max-memory-insns
ddf6fe37 26736@item -msched-max-memory-insns=@var{max-insns}
d77de738
ML
26737Limit on the number of memory insns per instruction group, giving lower
26738priority to subsequent memory insns attempting to schedule in the same
26739instruction group. Frequently useful to prevent cache bank conflicts.
26740The default value is 1.
26741
d77de738 26742@opindex msched-max-memory-insns-hard-limit
ddf6fe37 26743@item -msched-max-memory-insns-hard-limit
d77de738
ML
26744Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
26745disallowing more than that number in an instruction group.
26746Otherwise, the limit is ``soft'', meaning that non-memory operations
26747are preferred when the limit is reached, but memory operations may still
26748be scheduled.
26749
26750@end table
26751
26752@node LM32 Options
26753@subsection LM32 Options
26754@cindex LM32 options
26755
26756These @option{-m} options are defined for the LatticeMico32 architecture:
26757
26758@table @gcctabopt
d77de738 26759@opindex mbarrel-shift-enabled
ddf6fe37 26760@item -mbarrel-shift-enabled
d77de738
ML
26761Enable barrel-shift instructions.
26762
d77de738 26763@opindex mdivide-enabled
ddf6fe37 26764@item -mdivide-enabled
d77de738
ML
26765Enable divide and modulus instructions.
26766
d77de738 26767@opindex multiply-enabled
ddf6fe37 26768@item -mmultiply-enabled
d77de738
ML
26769Enable multiply instructions.
26770
d77de738 26771@opindex msign-extend-enabled
ddf6fe37 26772@item -msign-extend-enabled
d77de738
ML
26773Enable sign extend instructions.
26774
d77de738 26775@opindex muser-enabled
ddf6fe37 26776@item -muser-enabled
d77de738
ML
26777Enable user-defined instructions.
26778
26779@end table
26780
26781@node LoongArch Options
26782@subsection LoongArch Options
26783@cindex LoongArch Options
26784
26785These command-line options are defined for LoongArch targets:
26786
26787@table @gcctabopt
9c19597c 26788@opindex march
ddf6fe37 26789@item -march=@var{cpu-type}
d77de738
ML
26790Generate instructions for the machine type @var{cpu-type}. In contrast to
26791@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
26792for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
26793to generate code that may not run at all on processors other than the one
26794indicated. Specifying @option{-march=@var{cpu-type}} implies
26795@option{-mtune=@var{cpu-type}}, except where noted otherwise.
26796
26797The choices for @var{cpu-type} are:
26798
26799@table @samp
26800@item native
26801This selects the CPU to generate code for at compilation time by determining
26802the processor type of the compiling machine. Using @option{-march=native}
26803enables all instruction subsets supported by the local machine (hence
26804the result might not run on different machines). Using @option{-mtune=native}
26805produces code optimized for the local machine under the constraints
26806of the selected instruction set.
26807@item loongarch64
26808A generic CPU with 64-bit extensions.
26809@item la464
26810LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
26811@end table
26812
d77de738 26813@opindex mtune
ddf6fe37 26814@item -mtune=@var{cpu-type}
d77de738
ML
26815Optimize the output for the given processor, specified by microarchitecture
26816name.
26817
d77de738 26818@opindex mabi
ddf6fe37 26819@item -mabi=@var{base-abi-type}
d77de738
ML
26820Generate code for the specified calling convention.
26821@var{base-abi-type} can be one of:
26822@table @samp
26823@item lp64d
26824Uses 64-bit general purpose registers and 32/64-bit floating-point
26825registers for parameter passing. Data model is LP64, where @samp{int}
26826is 32 bits, while @samp{long int} and pointers are 64 bits.
26827@item lp64f
26828Uses 64-bit general purpose registers and 32-bit floating-point
26829registers for parameter passing. Data model is LP64, where @samp{int}
26830is 32 bits, while @samp{long int} and pointers are 64 bits.
26831@item lp64s
26832Uses 64-bit general purpose registers and no floating-point
26833registers for parameter passing. Data model is LP64, where @samp{int}
26834is 32 bits, while @samp{long int} and pointers are 64 bits.
26835@end table
26836
d77de738 26837@opindex mfpu
ddf6fe37 26838@item -mfpu=@var{fpu-type}
d77de738
ML
26839Generate code for the specified FPU type, which can be one of:
26840@table @samp
26841@item 64
26842Allow the use of hardware floating-point instructions for 32-bit
26843and 64-bit operations.
26844@item 32
26845Allow the use of hardware floating-point instructions for 32-bit
26846operations.
26847@item none
26848@item 0
26849Prevent the use of hardware floating-point instructions.
26850@end table
26851
bb4a8198
YY
26852@opindex msimd
26853@item -msimd=@var{simd-type}
26854Enable generation of LoongArch SIMD instructions for vectorization
26855and via builtin functions. The value can be one of:
26856@table @samp
26857@item lasx
26858Enable generating instructions from the 256-bit LoongArch Advanced
26859SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX).
26860@item lsx
26861Enable generating instructions from the 128-bit LoongArch SIMD
26862Extension (LSX).
26863@item none
26864No LoongArch SIMD instruction may be generated.
26865@end table
26866
d77de738 26867@opindex msoft-float
ddf6fe37 26868@item -msoft-float
d77de738
ML
26869Force @option{-mfpu=none} and prevents the use of floating-point
26870registers for parameter passing. This option may change the target
26871ABI.
26872
9c19597c 26873@opindex msingle-float
ddf6fe37 26874@item -msingle-float
d77de738
ML
26875Force @option{-mfpu=32} and allow the use of 32-bit floating-point
26876registers for parameter passing. This option may change the target
26877ABI.
26878
9c19597c 26879@opindex mdouble-float
ddf6fe37 26880@item -mdouble-float
d77de738
ML
26881Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
26882registers for parameter passing. This option may change the target
26883ABI.
26884
bb4a8198
YY
26885@opindex ml[a]sx
26886@item -mlasx
26887@itemx -mno-lasx
26888@item -mlsx
26889@itemx -mno-lsx
26890Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX)
26891that can be used by the compiler for code generation. Enabling LASX with
26892@option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx}
26893automatically disables LASX. These driver-only options act upon the final
26894@option{msimd} configuration state and make incremental chagnes in the order
26895they appear on the GCC driver's command line, deriving the final / canonicalized
26896@option{msimd} option that is passed to the compiler proper.
26897
9c19597c 26898@opindex mbranch-cost
ddf6fe37 26899@item -mbranch-cost=@var{n}
d77de738
ML
26900Set the cost of branches to roughly @var{n} instructions.
26901
ddf6fe37 26902@opindex mcheck-zero-division
d77de738
ML
26903@item -mcheck-zero-division
26904@itemx -mno-check-zero-divison
d77de738
ML
26905Trap (do not trap) on integer division by zero. The default is
26906@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
26907@option{-mno-check-zero-division} for other optimization levels.
26908
ddf6fe37 26909@opindex mcond-move-int
d77de738
ML
26910@item -mcond-move-int
26911@itemx -mno-cond-move-int
d77de738
ML
26912Conditional moves for integral data in general-purpose registers
26913are enabled (disabled). The default is @option{-mcond-move-int}.
26914
ddf6fe37 26915@opindex mcond-move-float
d77de738
ML
26916@item -mcond-move-float
26917@itemx -mno-cond-move-float
d77de738
ML
26918Conditional moves for floating-point registers are enabled (disabled).
26919The default is @option{-mcond-move-float}.
26920
ddf6fe37 26921@opindex mmemcpy
d77de738
ML
26922@item -mmemcpy
26923@itemx -mno-memcpy
d77de738
ML
26924Force (do not force) the use of @code{memcpy} for non-trivial block moves.
26925The default is @option{-mno-memcpy}, which allows GCC to inline most
26926constant-sized copies. Setting optimization level to @option{-Os} also
26927forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
26928behavior if explicitly specified, regardless of the order these options on
26929the command line.
26930
ddf6fe37 26931@opindex mstrict-align
d77de738
ML
26932@item -mstrict-align
26933@itemx -mno-strict-align
d77de738
ML
26934Avoid or allow generating memory accesses that may not be aligned on a natural
26935object boundary as described in the architecture specification. The default is
26936@option{-mno-strict-align}.
26937
9c19597c 26938@opindex msmall-data-limit
ddf6fe37 26939@item -msmall-data-limit=@var{number}
d77de738
ML
26940Put global and static data smaller than @var{number} bytes into a special
26941section (on some targets). The default value is 0.
26942
9c19597c 26943@opindex mmax-inline-memcpy-size
ddf6fe37 26944@item -mmax-inline-memcpy-size=@var{n}
d77de738
ML
26945Inline all block moves (such as calls to @code{memcpy} or structure copies)
26946less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
26947
26948@item -mcmodel=@var{code-model}
26949Set the code model to one of:
26950@table @samp
26951@item tiny-static (Not implemented yet)
26952@item tiny (Not implemented yet)
26953
26954@item normal
26955The text segment must be within 128MB addressing space. The data segment must
26956be within 2GB addressing space.
26957
26958@item medium
26959The text segment and data segment must be within 2GB addressing space.
26960
26961@item large (Not implemented yet)
26962
26963@item extreme
26964This mode does not limit the size of the code segment and data segment.
8c8b40e1
XR
26965The @option{-mcmodel=extreme} option is incompatible with @option{-fplt}
26966and/or @option{-mexplicit-relocs=none}.
d77de738
ML
26967@end table
26968The default code model is @code{normal}.
26969
e1b1cba1
XR
26970@item -mexplicit-relocs=@var{style}
26971Set when to use assembler relocation operators when dealing with symbolic
d77de738 26972addresses. The alternative is to use assembler macros instead, which may
e1b1cba1
XR
26973limit instruction scheduling but allow linker relaxation.
26974with @option{-mexplicit-relocs=none} the assembler macros are always used,
26975with @option{-mexplicit-relocs=always} the assembler relocation operators
26976are always used, with @option{-mexplicit-relocs=auto} the compiler will
26977use the relocation operators where the linker relaxation is impossible to
26978improve the code quality, and macros elsewhere. The default
fe23a2ff
XR
26979value for the option is determined with the assembler capability detected
26980during GCC build-time and the setting of @option{-mrelax}:
e1b1cba1
XR
26981@option{-mexplicit-relocs=none} if the assembler does not support
26982relocation operators at all,
26983@option{-mexplicit-relocs=always} if the assembler supports relocation
fe23a2ff
XR
26984operators but @option{-mrelax} is not enabled,
26985@option{-mexplicit-relocs=auto} if the assembler supports relocation
26986operators and @option{-mrelax} is enabled.
d77de738 26987
e1b1cba1
XR
26988@opindex mexplicit-relocs
26989@item -mexplicit-relocs
26990An alias of @option{-mexplicit-relocs=always} for backward compatibility.
26991
26992@opindex mno-explicit-relocs
26993@item -mno-explicit-relocs
26994An alias of @option{-mexplicit-relocs=none} for backward compatibility.
26995
ddf6fe37 26996@opindex mdirect-extern-access
d77de738
ML
26997@item -mdirect-extern-access
26998@itemx -mno-direct-extern-access
d77de738
ML
26999Do not use or use GOT to access external symbols. The default is
27000@option{-mno-direct-extern-access}: GOT is used for external symbols with
27001default visibility, but not used for other external symbols.
27002
27003With @option{-mdirect-extern-access}, GOT is not used and all external
27004symbols are PC-relatively addressed. It is @strong{only} suitable for
27005environments where no dynamic link is performed, like firmwares, OS
27006kernels, executables linked with @option{-static} or @option{-static-pie}.
27007@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
27008@option{-fpic}.
8f4bbdc2 27009
fe23a2ff
XR
27010@item -mrelax
27011@itemx -mno-relax
27012Take (do not take) advantage of linker relaxations. If
27013@option{-mpass-mrelax-to-as} is enabled, this option is also passed to
27014the assembler. The default is determined during GCC build-time by
27015detecting corresponding assembler support:
27016@option{-mrelax} if the assembler supports both the @option{-mrelax}
27017option and the conditional branch relaxation (it's required or the
27018@code{.align} directives and conditional branch instructions in the
27019assembly code outputted by GCC may be rejected by the assembler because
27020of a relocation overflow), @option{-mno-relax} otherwise.
27021
27022@item -mpass-mrelax-to-as
27023@itemx -mno-pass-mrelax-to-as
27024Pass (do not pass) the @option{-mrelax} or @option{-mno-relax} option
27025to the assembler. The default is determined during GCC build-time by
27026detecting corresponding assembler support:
27027@option{-mpass-mrelax-to-as} if the assembler supports the
27028@option{-mrelax} option, @option{-mno-pass-mrelax-to-as} otherwise.
27029This option is mostly useful for debugging, or interoperation with
27030assemblers different from the build-time one.
27031
9a07bc47
JX
27032@opindex mrecip
27033@item -mrecip
27034This option enables use of the reciprocal estimate and reciprocal square
27035root estimate instructions with additional Newton-Raphson steps to increase
27036precision instead of doing a divide or square root and divide for
27037floating-point arguments.
27038These instructions are generated only when @option{-funsafe-math-optimizations}
27039is enabled together with @option{-ffinite-math-only} and
27040@option{-fno-trapping-math}.
27041This option is off by default. Before you can use this option, you must sure the
27042target CPU supports frecipe and frsqrte instructions.
27043Note that while the throughput of the sequence is higher than the throughput of
27044the non-reciprocal instruction, the precision of the sequence can be decreased
27045by up to 2 ulp (i.e. the inverse of 1.0 equals 0.99999994).
27046
27047@opindex mrecip=opt
27048@item -mrecip=@var{opt}
27049This option controls which reciprocal estimate instructions
27050may be used. @var{opt} is a comma-separated list of options, which may
27051be preceded by a @samp{!} to invert the option:
27052
27053@table @samp
27054@item all
27055Enable all estimate instructions.
27056
27057@item default
27058Enable the default instructions, equivalent to @option{-mrecip}.
27059
27060@item none
27061Disable all estimate instructions, equivalent to @option{-mno-recip}.
27062
27063@item div
27064Enable the approximation for scalar division.
27065
27066@item vec-div
27067Enable the approximation for vectorized division.
27068
27069@item sqrt
27070Enable the approximation for scalar square root.
27071
27072@item vec-sqrt
27073Enable the approximation for vectorized square root.
27074
27075@item rsqrt
27076Enable the approximation for scalar reciprocal square root.
27077
27078@item vec-rsqrt
27079Enable the approximation for vectorized reciprocal square root.
27080@end table
27081
27082So, for example, @option{-mrecip=all,!sqrt} enables
27083all of the reciprocal approximations, except for scalar square root.
27084
8f4bbdc2
JX
27085@item loongarch-vect-unroll-limit
27086The vectorizer will use available tuning information to determine whether it
27087would be beneficial to unroll the main vectorized loop and by how much. This
27088parameter set's the upper bound of how much the vectorizer will unroll the main
27089loop. The default value is six.
27090
d77de738
ML
27091@end table
27092
bb4a8198 27093
d77de738
ML
27094@node M32C Options
27095@subsection M32C Options
27096@cindex M32C options
27097
27098@table @gcctabopt
d77de738 27099@opindex mcpu=
ddf6fe37 27100@item -mcpu=@var{name}
d77de738
ML
27101Select the CPU for which code is generated. @var{name} may be one of
27102@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
27103/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
27104the M32C/80 series.
27105
d77de738 27106@opindex msim
ddf6fe37 27107@item -msim
d77de738
ML
27108Specifies that the program will be run on the simulator. This causes
27109an alternate runtime library to be linked in which supports, for
27110example, file I/O@. You must not use this option when generating
27111programs that will run on real hardware; you must provide your own
27112runtime library for whatever I/O functions are needed.
27113
d77de738 27114@opindex memregs=
ddf6fe37 27115@item -memregs=@var{number}
d77de738
ML
27116Specifies the number of memory-based pseudo-registers GCC uses
27117during code generation. These pseudo-registers are used like real
27118registers, so there is a tradeoff between GCC's ability to fit the
27119code into available registers, and the performance penalty of using
27120memory instead of registers. Note that all modules in a program must
27121be compiled with the same value for this option. Because of that, you
27122must not use this option with GCC's default runtime libraries.
27123
27124@end table
27125
27126@node M32R/D Options
27127@subsection M32R/D Options
27128@cindex M32R/D options
27129
27130These @option{-m} options are defined for Renesas M32R/D architectures:
27131
27132@table @gcctabopt
d77de738 27133@opindex m32r2
ddf6fe37 27134@item -m32r2
d77de738
ML
27135Generate code for the M32R/2@.
27136
d77de738 27137@opindex m32rx
ddf6fe37 27138@item -m32rx
d77de738
ML
27139Generate code for the M32R/X@.
27140
d77de738 27141@opindex m32r
ddf6fe37 27142@item -m32r
d77de738
ML
27143Generate code for the M32R@. This is the default.
27144
d77de738 27145@opindex mmodel=small
ddf6fe37 27146@item -mmodel=small
d77de738
ML
27147Assume all objects live in the lower 16MB of memory (so that their addresses
27148can be loaded with the @code{ld24} instruction), and assume all subroutines
27149are reachable with the @code{bl} instruction.
27150This is the default.
27151
27152The addressability of a particular object can be set with the
27153@code{model} attribute.
27154
d77de738 27155@opindex mmodel=medium
ddf6fe37 27156@item -mmodel=medium
d77de738
ML
27157Assume objects may be anywhere in the 32-bit address space (the compiler
27158generates @code{seth/add3} instructions to load their addresses), and
27159assume all subroutines are reachable with the @code{bl} instruction.
27160
d77de738 27161@opindex mmodel=large
ddf6fe37 27162@item -mmodel=large
d77de738
ML
27163Assume objects may be anywhere in the 32-bit address space (the compiler
27164generates @code{seth/add3} instructions to load their addresses), and
27165assume subroutines may not be reachable with the @code{bl} instruction
27166(the compiler generates the much slower @code{seth/add3/jl}
27167instruction sequence).
27168
d77de738 27169@opindex msdata=none
ddf6fe37 27170@item -msdata=none
d77de738
ML
27171Disable use of the small data area. Variables are put into
27172one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
27173@code{section} attribute has been specified).
27174This is the default.
27175
27176The small data area consists of sections @code{.sdata} and @code{.sbss}.
27177Objects may be explicitly put in the small data area with the
27178@code{section} attribute using one of these sections.
27179
d77de738 27180@opindex msdata=sdata
ddf6fe37 27181@item -msdata=sdata
d77de738
ML
27182Put small global and static data in the small data area, but do not
27183generate special code to reference them.
27184
d77de738 27185@opindex msdata=use
ddf6fe37 27186@item -msdata=use
d77de738
ML
27187Put small global and static data in the small data area, and generate
27188special instructions to reference them.
27189
d77de738
ML
27190@opindex G
27191@cindex smaller data references
f33d7a88 27192@item -G @var{num}
d77de738
ML
27193Put global and static objects less than or equal to @var{num} bytes
27194into the small data or BSS sections instead of the normal data or BSS
27195sections. The default value of @var{num} is 8.
27196The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
27197for this option to have any effect.
27198
27199All modules should be compiled with the same @option{-G @var{num}} value.
27200Compiling with different values of @var{num} may or may not work; if it
27201doesn't the linker gives an error message---incorrect code is not
27202generated.
27203
d77de738 27204@opindex mdebug
ddf6fe37 27205@item -mdebug
d77de738
ML
27206Makes the M32R-specific code in the compiler display some statistics
27207that might help in debugging programs.
27208
d77de738 27209@opindex malign-loops
ddf6fe37 27210@item -malign-loops
d77de738
ML
27211Align all loops to a 32-byte boundary.
27212
d77de738 27213@opindex mno-align-loops
ddf6fe37 27214@item -mno-align-loops
d77de738
ML
27215Do not enforce a 32-byte alignment for loops. This is the default.
27216
d77de738 27217@opindex missue-rate=@var{number}
ddf6fe37 27218@item -missue-rate=@var{number}
d77de738
ML
27219Issue @var{number} instructions per cycle. @var{number} can only be 1
27220or 2.
27221
d77de738 27222@opindex mbranch-cost=@var{number}
ddf6fe37 27223@item -mbranch-cost=@var{number}
d77de738
ML
27224@var{number} can only be 1 or 2. If it is 1 then branches are
27225preferred over conditional code, if it is 2, then the opposite applies.
27226
d77de738 27227@opindex mflush-trap=@var{number}
ddf6fe37 27228@item -mflush-trap=@var{number}
d77de738
ML
27229Specifies the trap number to use to flush the cache. The default is
2723012. Valid numbers are between 0 and 15 inclusive.
27231
d77de738 27232@opindex mno-flush-trap
ddf6fe37 27233@item -mno-flush-trap
d77de738
ML
27234Specifies that the cache cannot be flushed by using a trap.
27235
d77de738 27236@opindex mflush-func=@var{name}
ddf6fe37 27237@item -mflush-func=@var{name}
d77de738
ML
27238Specifies the name of the operating system function to call to flush
27239the cache. The default is @samp{_flush_cache}, but a function call
27240is only used if a trap is not available.
27241
d77de738 27242@opindex mno-flush-func
ddf6fe37 27243@item -mno-flush-func
d77de738
ML
27244Indicates that there is no OS function for flushing the cache.
27245
27246@end table
27247
27248@node M680x0 Options
27249@subsection M680x0 Options
27250@cindex M680x0 options
27251
27252These are the @samp{-m} options defined for M680x0 and ColdFire processors.
27253The default settings depend on which architecture was selected when
27254the compiler was configured; the defaults for the most common choices
27255are given below.
27256
27257@table @gcctabopt
d77de738 27258@opindex march
ddf6fe37 27259@item -march=@var{arch}
d77de738
ML
27260Generate code for a specific M680x0 or ColdFire instruction set
27261architecture. Permissible values of @var{arch} for M680x0
27262architectures are: @samp{68000}, @samp{68010}, @samp{68020},
27263@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
27264architectures are selected according to Freescale's ISA classification
27265and the permissible values are: @samp{isaa}, @samp{isaaplus},
27266@samp{isab} and @samp{isac}.
27267
27268GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
27269code for a ColdFire target. The @var{arch} in this macro is one of the
27270@option{-march} arguments given above.
27271
27272When used together, @option{-march} and @option{-mtune} select code
27273that runs on a family of similar processors but that is optimized
27274for a particular microarchitecture.
27275
d77de738 27276@opindex mcpu
ddf6fe37 27277@item -mcpu=@var{cpu}
d77de738
ML
27278Generate code for a specific M680x0 or ColdFire processor.
27279The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
27280@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
27281and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
27282below, which also classifies the CPUs into families:
27283
27284@multitable @columnfractions 0.20 0.80
27285@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
27286@item @samp{51} @tab @samp{51} @samp{51ac} @samp{51ag} @samp{51cn} @samp{51em} @samp{51je} @samp{51jf} @samp{51jg} @samp{51jm} @samp{51mm} @samp{51qe} @samp{51qm}
27287@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
27288@item @samp{5206e} @tab @samp{5206e}
27289@item @samp{5208} @tab @samp{5207} @samp{5208}
27290@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
27291@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
27292@item @samp{5216} @tab @samp{5214} @samp{5216}
27293@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
27294@item @samp{5225} @tab @samp{5224} @samp{5225}
27295@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
27296@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
27297@item @samp{5249} @tab @samp{5249}
27298@item @samp{5250} @tab @samp{5250}
27299@item @samp{5271} @tab @samp{5270} @samp{5271}
27300@item @samp{5272} @tab @samp{5272}
27301@item @samp{5275} @tab @samp{5274} @samp{5275}
27302@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
27303@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
27304@item @samp{5307} @tab @samp{5307}
27305@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
27306@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
27307@item @samp{5407} @tab @samp{5407}
27308@item @samp{5475} @tab @samp{5470} @samp{5471} @samp{5472} @samp{5473} @samp{5474} @samp{5475} @samp{547x} @samp{5480} @samp{5481} @samp{5482} @samp{5483} @samp{5484} @samp{5485}
27309@end multitable
27310
27311@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
27312@var{arch} is compatible with @var{cpu}. Other combinations of
27313@option{-mcpu} and @option{-march} are rejected.
27314
27315GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
27316@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
27317where the value of @var{family} is given by the table above.
27318
d77de738 27319@opindex mtune
ddf6fe37 27320@item -mtune=@var{tune}
d77de738
ML
27321Tune the code for a particular microarchitecture within the
27322constraints set by @option{-march} and @option{-mcpu}.
27323The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
27324@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
27325and @samp{cpu32}. The ColdFire microarchitectures
27326are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
27327
27328You can also use @option{-mtune=68020-40} for code that needs
27329to run relatively well on 68020, 68030 and 68040 targets.
27330@option{-mtune=68020-60} is similar but includes 68060 targets
27331as well. These two options select the same tuning decisions as
27332@option{-m68020-40} and @option{-m68020-60} respectively.
27333
27334GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
27335when tuning for 680x0 architecture @var{arch}. It also defines
27336@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
27337option is used. If GCC is tuning for a range of architectures,
27338as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
27339it defines the macros for every architecture in the range.
27340
27341GCC also defines the macro @code{__m@var{uarch}__} when tuning for
27342ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
27343of the arguments given above.
27344
d77de738
ML
27345@opindex m68000
27346@opindex mc68000
ddf6fe37
AA
27347@item -m68000
27348@itemx -mc68000
d77de738
ML
27349Generate output for a 68000. This is the default
27350when the compiler is configured for 68000-based systems.
27351It is equivalent to @option{-march=68000}.
27352
27353Use this option for microcontrollers with a 68000 or EC000 core,
27354including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
27355
d77de738 27356@opindex m68010
ddf6fe37 27357@item -m68010
d77de738
ML
27358Generate output for a 68010. This is the default
27359when the compiler is configured for 68010-based systems.
27360It is equivalent to @option{-march=68010}.
27361
d77de738
ML
27362@opindex m68020
27363@opindex mc68020
ddf6fe37
AA
27364@item -m68020
27365@itemx -mc68020
d77de738
ML
27366Generate output for a 68020. This is the default
27367when the compiler is configured for 68020-based systems.
27368It is equivalent to @option{-march=68020}.
27369
d77de738 27370@opindex m68030
ddf6fe37 27371@item -m68030
d77de738
ML
27372Generate output for a 68030. This is the default when the compiler is
27373configured for 68030-based systems. It is equivalent to
27374@option{-march=68030}.
27375
d77de738 27376@opindex m68040
ddf6fe37 27377@item -m68040
d77de738
ML
27378Generate output for a 68040. This is the default when the compiler is
27379configured for 68040-based systems. It is equivalent to
27380@option{-march=68040}.
27381
27382This option inhibits the use of 68881/68882 instructions that have to be
27383emulated by software on the 68040. Use this option if your 68040 does not
27384have code to emulate those instructions.
27385
d77de738 27386@opindex m68060
ddf6fe37 27387@item -m68060
d77de738
ML
27388Generate output for a 68060. This is the default when the compiler is
27389configured for 68060-based systems. It is equivalent to
27390@option{-march=68060}.
27391
27392This option inhibits the use of 68020 and 68881/68882 instructions that
27393have to be emulated by software on the 68060. Use this option if your 68060
27394does not have code to emulate those instructions.
27395
d77de738 27396@opindex mcpu32
ddf6fe37 27397@item -mcpu32
d77de738
ML
27398Generate output for a CPU32. This is the default
27399when the compiler is configured for CPU32-based systems.
27400It is equivalent to @option{-march=cpu32}.
27401
27402Use this option for microcontrollers with a
27403CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2740468336, 68340, 68341, 68349 and 68360.
27405
d77de738 27406@opindex m5200
ddf6fe37 27407@item -m5200
d77de738
ML
27408Generate output for a 520X ColdFire CPU@. This is the default
27409when the compiler is configured for 520X-based systems.
27410It is equivalent to @option{-mcpu=5206}, and is now deprecated
27411in favor of that option.
27412
27413Use this option for microcontroller with a 5200 core, including
27414the MCF5202, MCF5203, MCF5204 and MCF5206.
27415
d77de738 27416@opindex m5206e
ddf6fe37 27417@item -m5206e
d77de738
ML
27418Generate output for a 5206e ColdFire CPU@. The option is now
27419deprecated in favor of the equivalent @option{-mcpu=5206e}.
27420
d77de738 27421@opindex m528x
ddf6fe37 27422@item -m528x
d77de738
ML
27423Generate output for a member of the ColdFire 528X family.
27424The option is now deprecated in favor of the equivalent
27425@option{-mcpu=528x}.
27426
d77de738 27427@opindex m5307
ddf6fe37 27428@item -m5307
d77de738
ML
27429Generate output for a ColdFire 5307 CPU@. The option is now deprecated
27430in favor of the equivalent @option{-mcpu=5307}.
27431
d77de738 27432@opindex m5407
ddf6fe37 27433@item -m5407
d77de738
ML
27434Generate output for a ColdFire 5407 CPU@. The option is now deprecated
27435in favor of the equivalent @option{-mcpu=5407}.
27436
d77de738 27437@opindex mcfv4e
ddf6fe37 27438@item -mcfv4e
d77de738
ML
27439Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
27440This includes use of hardware floating-point instructions.
27441The option is equivalent to @option{-mcpu=547x}, and is now
27442deprecated in favor of that option.
27443
d77de738 27444@opindex m68020-40
ddf6fe37 27445@item -m68020-40
d77de738
ML
27446Generate output for a 68040, without using any of the new instructions.
27447This results in code that can run relatively efficiently on either a
2744868020/68881 or a 68030 or a 68040. The generated code does use the
2744968881 instructions that are emulated on the 68040.
27450
27451The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
27452
d77de738 27453@opindex m68020-60
ddf6fe37 27454@item -m68020-60
d77de738
ML
27455Generate output for a 68060, without using any of the new instructions.
27456This results in code that can run relatively efficiently on either a
2745768020/68881 or a 68030 or a 68040. The generated code does use the
2745868881 instructions that are emulated on the 68060.
27459
27460The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
27461
d77de738
ML
27462@opindex mhard-float
27463@opindex m68881
ddf6fe37
AA
27464@item -mhard-float
27465@itemx -m68881
d77de738
ML
27466Generate floating-point instructions. This is the default for 68020
27467and above, and for ColdFire devices that have an FPU@. It defines the
27468macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
27469on ColdFire targets.
27470
d77de738 27471@opindex msoft-float
ddf6fe37 27472@item -msoft-float
d77de738
ML
27473Do not generate floating-point instructions; use library calls instead.
27474This is the default for 68000, 68010, and 68832 targets. It is also
27475the default for ColdFire devices that have no FPU.
27476
d77de738
ML
27477@opindex mdiv
27478@opindex mno-div
ddf6fe37
AA
27479@item -mdiv
27480@itemx -mno-div
d77de738
ML
27481Generate (do not generate) ColdFire hardware divide and remainder
27482instructions. If @option{-march} is used without @option{-mcpu},
27483the default is ``on'' for ColdFire architectures and ``off'' for M680x0
27484architectures. Otherwise, the default is taken from the target CPU
27485(either the default CPU, or the one specified by @option{-mcpu}). For
27486example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
27487@option{-mcpu=5206e}.
27488
27489GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
27490
d77de738 27491@opindex mshort
ddf6fe37 27492@item -mshort
d77de738
ML
27493Consider type @code{int} to be 16 bits wide, like @code{short int}.
27494Additionally, parameters passed on the stack are also aligned to a
2749516-bit boundary even on targets whose API mandates promotion to 32-bit.
27496
d77de738 27497@opindex mno-short
ddf6fe37 27498@item -mno-short
d77de738
ML
27499Do not consider type @code{int} to be 16 bits wide. This is the default.
27500
d77de738
ML
27501@opindex mnobitfield
27502@opindex mno-bitfield
ddf6fe37
AA
27503@item -mnobitfield
27504@itemx -mno-bitfield
d77de738
ML
27505Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
27506and @option{-m5200} options imply @w{@option{-mnobitfield}}.
27507
d77de738 27508@opindex mbitfield
ddf6fe37 27509@item -mbitfield
d77de738
ML
27510Do use the bit-field instructions. The @option{-m68020} option implies
27511@option{-mbitfield}. This is the default if you use a configuration
27512designed for a 68020.
27513
d77de738 27514@opindex mrtd
ddf6fe37 27515@item -mrtd
d77de738
ML
27516Use a different function-calling convention, in which functions
27517that take a fixed number of arguments return with the @code{rtd}
27518instruction, which pops their arguments while returning. This
27519saves one instruction in the caller since there is no need to pop
27520the arguments there.
27521
27522This calling convention is incompatible with the one normally
27523used on Unix, so you cannot use it if you need to call libraries
27524compiled with the Unix compiler.
27525
27526Also, you must provide function prototypes for all functions that
27527take variable numbers of arguments (including @code{printf});
27528otherwise incorrect code is generated for calls to those
27529functions.
27530
27531In addition, seriously incorrect code results if you call a
27532function with too many arguments. (Normally, extra arguments are
27533harmlessly ignored.)
27534
27535The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2753668040, 68060 and CPU32 processors, but not by the 68000 or 5200.
27537
27538The default is @option{-mno-rtd}.
27539
d77de738
ML
27540@opindex malign-int
27541@opindex mno-align-int
ddf6fe37
AA
27542@item -malign-int
27543@itemx -mno-align-int
d77de738
ML
27544Control whether GCC aligns @code{int}, @code{long}, @code{long long},
27545@code{float}, @code{double}, and @code{long double} variables on a 32-bit
27546boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
27547Aligning variables on 32-bit boundaries produces code that runs somewhat
27548faster on processors with 32-bit busses at the expense of more memory.
27549
27550@strong{Warning:} if you use the @option{-malign-int} switch, GCC
27551aligns structures containing the above types differently than
27552most published application binary interface specifications for the m68k.
27553
27554@opindex mpcrel
27555Use the pc-relative addressing mode of the 68000 directly, instead of
27556using a global offset table. At present, this option implies @option{-fpic},
27557allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
27558not presently supported with @option{-mpcrel}, though this could be supported for
2755968020 and higher processors.
27560
d77de738
ML
27561@opindex mno-strict-align
27562@opindex mstrict-align
ddf6fe37
AA
27563@item -mno-strict-align
27564@itemx -mstrict-align
d77de738
ML
27565Do not (do) assume that unaligned memory references are handled by
27566the system.
27567
27568@item -msep-data
27569Generate code that allows the data segment to be located in a different
27570area of memory from the text segment. This allows for execute-in-place in
27571an environment without virtual memory management. This option implies
27572@option{-fPIC}.
27573
27574@item -mno-sep-data
27575Generate code that assumes that the data segment follows the text segment.
27576This is the default.
27577
27578@item -mid-shared-library
27579Generate code that supports shared libraries via the library ID method.
27580This allows for execute-in-place and shared libraries in an environment
27581without virtual memory management. This option implies @option{-fPIC}.
27582
27583@item -mno-id-shared-library
27584Generate code that doesn't assume ID-based shared libraries are being used.
27585This is the default.
27586
27587@item -mshared-library-id=n
27588Specifies the identification number of the ID-based shared library being
27589compiled. Specifying a value of 0 generates more compact code; specifying
27590other values forces the allocation of that number to the current
27591library, but is no more space- or time-efficient than omitting this option.
27592
d77de738
ML
27593@opindex mxgot
27594@opindex mno-xgot
ddf6fe37
AA
27595@item -mxgot
27596@itemx -mno-xgot
d77de738
ML
27597When generating position-independent code for ColdFire, generate code
27598that works if the GOT has more than 8192 entries. This code is
27599larger and slower than code generated without this option. On M680x0
27600processors, this option is not needed; @option{-fPIC} suffices.
27601
27602GCC normally uses a single instruction to load values from the GOT@.
27603While this is relatively efficient, it only works if the GOT
27604is smaller than about 64k. Anything larger causes the linker
27605to report an error such as:
27606
27607@cindex relocation truncated to fit (ColdFire)
27608@smallexample
27609relocation truncated to fit: R_68K_GOT16O foobar
27610@end smallexample
27611
27612If this happens, you should recompile your code with @option{-mxgot}.
27613It should then work with very large GOTs. However, code generated with
27614@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
27615the value of a global symbol.
27616
27617Note that some linkers, including newer versions of the GNU linker,
27618can create multiple GOTs and sort GOT entries. If you have such a linker,
27619you should only need to use @option{-mxgot} when compiling a single
27620object file that accesses more than 8192 GOT entries. Very few do.
27621
27622These options have no effect unless GCC is generating
27623position-independent code.
27624
d77de738 27625@opindex mlong-jump-table-offsets
ddf6fe37 27626@item -mlong-jump-table-offsets
d77de738
ML
27627Use 32-bit offsets in @code{switch} tables. The default is to use
2762816-bit offsets.
27629
27630@end table
27631
27632@node MCore Options
27633@subsection MCore Options
27634@cindex MCore options
27635
27636These are the @samp{-m} options defined for the Motorola M*Core
27637processors.
27638
27639@table @gcctabopt
27640
d77de738
ML
27641@opindex mhardlit
27642@opindex mno-hardlit
ddf6fe37
AA
27643@item -mhardlit
27644@itemx -mno-hardlit
d77de738
ML
27645Inline constants into the code stream if it can be done in two
27646instructions or less.
27647
d77de738
ML
27648@opindex mdiv
27649@opindex mno-div
ddf6fe37
AA
27650@item -mdiv
27651@itemx -mno-div
d77de738
ML
27652Use the divide instruction. (Enabled by default).
27653
d77de738
ML
27654@opindex mrelax-immediate
27655@opindex mno-relax-immediate
ddf6fe37
AA
27656@item -mrelax-immediate
27657@itemx -mno-relax-immediate
d77de738
ML
27658Allow arbitrary-sized immediates in bit operations.
27659
d77de738
ML
27660@opindex mwide-bitfields
27661@opindex mno-wide-bitfields
ddf6fe37
AA
27662@item -mwide-bitfields
27663@itemx -mno-wide-bitfields
d77de738
ML
27664Always treat bit-fields as @code{int}-sized.
27665
d77de738
ML
27666@opindex m4byte-functions
27667@opindex mno-4byte-functions
ddf6fe37
AA
27668@item -m4byte-functions
27669@itemx -mno-4byte-functions
d77de738
ML
27670Force all functions to be aligned to a 4-byte boundary.
27671
d77de738
ML
27672@opindex mcallgraph-data
27673@opindex mno-callgraph-data
ddf6fe37
AA
27674@item -mcallgraph-data
27675@itemx -mno-callgraph-data
d77de738
ML
27676Emit callgraph information.
27677
d77de738
ML
27678@opindex mslow-bytes
27679@opindex mno-slow-bytes
ddf6fe37
AA
27680@item -mslow-bytes
27681@itemx -mno-slow-bytes
d77de738
ML
27682Prefer word access when reading byte quantities.
27683
d77de738
ML
27684@opindex mlittle-endian
27685@opindex mbig-endian
ddf6fe37
AA
27686@item -mlittle-endian
27687@itemx -mbig-endian
d77de738
ML
27688Generate code for a little-endian target.
27689
d77de738
ML
27690@opindex m210
27691@opindex m340
ddf6fe37
AA
27692@item -m210
27693@itemx -m340
d77de738
ML
27694Generate code for the 210 processor.
27695
d77de738 27696@opindex mno-lsim
ddf6fe37 27697@item -mno-lsim
d77de738
ML
27698Assume that runtime support has been provided and so omit the
27699simulator library (@file{libsim.a)} from the linker command line.
27700
d77de738 27701@opindex mstack-increment
ddf6fe37 27702@item -mstack-increment=@var{size}
d77de738
ML
27703Set the maximum amount for a single stack increment operation. Large
27704values can increase the speed of programs that contain functions
27705that need a large amount of stack space, but they can also trigger a
27706segmentation fault if the stack is extended too much. The default
27707value is 0x1000.
27708
27709@end table
27710
d77de738
ML
27711@node MicroBlaze Options
27712@subsection MicroBlaze Options
27713@cindex MicroBlaze Options
27714
27715@table @gcctabopt
27716
d77de738 27717@opindex msoft-float
ddf6fe37 27718@item -msoft-float
d77de738
ML
27719Use software emulation for floating point (default).
27720
d77de738 27721@opindex mhard-float
ddf6fe37 27722@item -mhard-float
d77de738
ML
27723Use hardware floating-point instructions.
27724
d77de738 27725@opindex mmemcpy
ddf6fe37 27726@item -mmemcpy
d77de738
ML
27727Do not optimize block moves, use @code{memcpy}.
27728
d77de738 27729@opindex mno-clearbss
ddf6fe37 27730@item -mno-clearbss
d77de738
ML
27731This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
27732
d77de738 27733@opindex mcpu=
ddf6fe37 27734@item -mcpu=@var{cpu-type}
d77de738
ML
27735Use features of, and schedule code for, the given CPU.
27736Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
27737where @var{X} is a major version, @var{YY} is the minor version, and
27738@var{Z} is compatibility code. Example values are @samp{v3.00.a},
27739@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
27740
d77de738 27741@opindex mxl-soft-mul
ddf6fe37 27742@item -mxl-soft-mul
d77de738
ML
27743Use software multiply emulation (default).
27744
d77de738 27745@opindex mxl-soft-div
ddf6fe37 27746@item -mxl-soft-div
d77de738
ML
27747Use software emulation for divides (default).
27748
d77de738 27749@opindex mxl-barrel-shift
ddf6fe37 27750@item -mxl-barrel-shift
d77de738
ML
27751Use the hardware barrel shifter.
27752
d77de738 27753@opindex mxl-pattern-compare
ddf6fe37 27754@item -mxl-pattern-compare
d77de738
ML
27755Use pattern compare instructions.
27756
d77de738 27757@opindex msmall-divides
ddf6fe37 27758@item -msmall-divides
d77de738
ML
27759Use table lookup optimization for small signed integer divisions.
27760
d77de738 27761@opindex mxl-stack-check
ddf6fe37 27762@item -mxl-stack-check
d77de738
ML
27763This option is deprecated. Use @option{-fstack-check} instead.
27764
d77de738 27765@opindex mxl-gp-opt
ddf6fe37 27766@item -mxl-gp-opt
d77de738
ML
27767Use GP-relative @code{.sdata}/@code{.sbss} sections.
27768
d77de738 27769@opindex mxl-multiply-high
ddf6fe37 27770@item -mxl-multiply-high
d77de738
ML
27771Use multiply high instructions for high part of 32x32 multiply.
27772
d77de738 27773@opindex mxl-float-convert
ddf6fe37 27774@item -mxl-float-convert
d77de738
ML
27775Use hardware floating-point conversion instructions.
27776
d77de738 27777@opindex mxl-float-sqrt
ddf6fe37 27778@item -mxl-float-sqrt
d77de738
ML
27779Use hardware floating-point square root instruction.
27780
d77de738 27781@opindex mbig-endian
ddf6fe37 27782@item -mbig-endian
d77de738
ML
27783Generate code for a big-endian target.
27784
d77de738 27785@opindex mlittle-endian
ddf6fe37 27786@item -mlittle-endian
d77de738
ML
27787Generate code for a little-endian target.
27788
d77de738 27789@opindex mxl-reorder
ddf6fe37 27790@item -mxl-reorder
d77de738
ML
27791Use reorder instructions (swap and byte reversed load/store).
27792
27793@item -mxl-mode-@var{app-model}
27794Select application model @var{app-model}. Valid models are
27795@table @samp
27796@item executable
27797normal executable (default), uses startup code @file{crt0.o}.
27798
27799@item xmdstub
27800for use with Xilinx Microprocessor Debugger (XMD) based
27801software intrusive debug agent called xmdstub. This uses startup file
27802@file{crt1.o} and sets the start address of the program to 0x800.
27803
27804@item bootstrap
27805for applications that are loaded using a bootloader.
27806This model uses startup file @file{crt2.o} which does not contain a processor
27807reset vector handler. This is suitable for transferring control on a
27808processor reset to the bootloader rather than the application.
27809
27810@item novectors
27811for applications that do not require any of the
27812MicroBlaze vectors. This option may be useful for applications running
27813within a monitoring application. This model uses @file{crt3.o} as a startup file.
27814@end table
27815
27816Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
27817@option{-mxl-mode-@var{app-model}}.
27818
d77de738 27819@opindex mpic-data-is-text-relative
ddf6fe37 27820@item -mpic-data-is-text-relative
d77de738
ML
27821Assume that the displacement between the text and data segments is fixed
27822at static link time. This allows data to be referenced by offset from start of
27823text address instead of GOT since PC-relative addressing is not supported.
27824
27825@end table
27826
27827@node MIPS Options
27828@subsection MIPS Options
27829@cindex MIPS options
27830
27831@table @gcctabopt
27832
d77de738 27833@opindex EB
ddf6fe37 27834@item -EB
d77de738
ML
27835Generate big-endian code.
27836
d77de738 27837@opindex EL
ddf6fe37 27838@item -EL
d77de738
ML
27839Generate little-endian code. This is the default for @samp{mips*el-*-*}
27840configurations.
27841
d77de738 27842@opindex march
ddf6fe37 27843@item -march=@var{arch}
d77de738
ML
27844Generate code that runs on @var{arch}, which can be the name of a
27845generic MIPS ISA, or the name of a particular processor.
27846The ISA names are:
27847@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
27848@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
27849@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
27850@samp{mips64r5} and @samp{mips64r6}.
27851The processor names are:
27852@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
27853@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
27854@samp{5kc}, @samp{5kf},
27855@samp{20kc},
27856@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
27857@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
27858@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
27859@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
27860@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
27861@samp{i6400}, @samp{i6500},
27862@samp{interaptiv},
27863@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
27864@samp{gs464e}, @samp{gs264e},
27865@samp{m4k},
27866@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
27867@samp{m5100}, @samp{m5101},
27868@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
27869@samp{orion},
27870@samp{p5600}, @samp{p6600},
27871@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
27872@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
27873@samp{r6000}, @samp{r8000},
27874@samp{rm7000}, @samp{rm9000},
27875@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
27876@samp{sb1},
27877@samp{sr71000},
27878@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
27879@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
27880@samp{xlr} and @samp{xlp}.
27881The special value @samp{from-abi} selects the
27882most compatible architecture for the selected ABI (that is,
27883@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
27884
27885The native Linux/GNU toolchain also supports the value @samp{native},
27886which selects the best architecture option for the host processor.
27887@option{-march=native} has no effect if GCC does not recognize
27888the processor.
27889
27890In processor names, a final @samp{000} can be abbreviated as @samp{k}
27891(for example, @option{-march=r2k}). Prefixes are optional, and
27892@samp{vr} may be written @samp{r}.
27893
27894Names of the form @samp{@var{n}f2_1} refer to processors with
27895FPUs clocked at half the rate of the core, names of the form
27896@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
27897rate as the core, and names of the form @samp{@var{n}f3_2} refer to
27898processors with FPUs clocked a ratio of 3:2 with respect to the core.
27899For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
27900for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
27901accepted as synonyms for @samp{@var{n}f1_1}.
27902
27903GCC defines two macros based on the value of this option. The first
27904is @code{_MIPS_ARCH}, which gives the name of target architecture, as
27905a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
27906where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
27907For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
27908to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
27909
27910Note that the @code{_MIPS_ARCH} macro uses the processor names given
27911above. In other words, it has the full prefix and does not
27912abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
27913the macro names the resolved architecture (either @code{"mips1"} or
27914@code{"mips3"}). It names the default architecture when no
27915@option{-march} option is given.
27916
d77de738 27917@opindex mtune
ddf6fe37 27918@item -mtune=@var{arch}
d77de738
ML
27919Optimize for @var{arch}. Among other things, this option controls
27920the way instructions are scheduled, and the perceived cost of arithmetic
27921operations. The list of @var{arch} values is the same as for
27922@option{-march}.
27923
27924When this option is not used, GCC optimizes for the processor
27925specified by @option{-march}. By using @option{-march} and
27926@option{-mtune} together, it is possible to generate code that
27927runs on a family of processors, but optimize the code for one
27928particular member of that family.
27929
27930@option{-mtune} defines the macros @code{_MIPS_TUNE} and
27931@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
27932@option{-march} ones described above.
27933
d77de738 27934@opindex mips1
ddf6fe37 27935@item -mips1
d77de738
ML
27936Equivalent to @option{-march=mips1}.
27937
d77de738 27938@opindex mips2
ddf6fe37 27939@item -mips2
d77de738
ML
27940Equivalent to @option{-march=mips2}.
27941
d77de738 27942@opindex mips3
ddf6fe37 27943@item -mips3
d77de738
ML
27944Equivalent to @option{-march=mips3}.
27945
d77de738 27946@opindex mips4
ddf6fe37 27947@item -mips4
d77de738
ML
27948Equivalent to @option{-march=mips4}.
27949
d77de738 27950@opindex mips32
ddf6fe37 27951@item -mips32
d77de738
ML
27952Equivalent to @option{-march=mips32}.
27953
d77de738 27954@opindex mips32r3
ddf6fe37 27955@item -mips32r3
d77de738
ML
27956Equivalent to @option{-march=mips32r3}.
27957
d77de738 27958@opindex mips32r5
ddf6fe37 27959@item -mips32r5
d77de738
ML
27960Equivalent to @option{-march=mips32r5}.
27961
d77de738 27962@opindex mips32r6
ddf6fe37 27963@item -mips32r6
d77de738
ML
27964Equivalent to @option{-march=mips32r6}.
27965
d77de738 27966@opindex mips64
ddf6fe37 27967@item -mips64
d77de738
ML
27968Equivalent to @option{-march=mips64}.
27969
d77de738 27970@opindex mips64r2
ddf6fe37 27971@item -mips64r2
d77de738
ML
27972Equivalent to @option{-march=mips64r2}.
27973
d77de738 27974@opindex mips64r3
ddf6fe37 27975@item -mips64r3
d77de738
ML
27976Equivalent to @option{-march=mips64r3}.
27977
d77de738 27978@opindex mips64r5
ddf6fe37 27979@item -mips64r5
d77de738
ML
27980Equivalent to @option{-march=mips64r5}.
27981
d77de738 27982@opindex mips64r6
ddf6fe37 27983@item -mips64r6
d77de738
ML
27984Equivalent to @option{-march=mips64r6}.
27985
d77de738
ML
27986@opindex mips16
27987@opindex mno-mips16
ddf6fe37
AA
27988@item -mips16
27989@itemx -mno-mips16
d77de738
ML
27990Generate (do not generate) MIPS16 code. If GCC is targeting a
27991MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
27992
27993MIPS16 code generation can also be controlled on a per-function basis
27994by means of @code{mips16} and @code{nomips16} attributes.
27995@xref{Function Attributes}, for more information.
27996
926f2d09
JM
27997@opindex mmips16e2
27998@opindex mno-mips16e2
27999@item -mmips16e2
28000@itemx -mno-mips16e2
28001Use (do not use) the MIPS16e2 ASE. This option modifies the behavior
28002of the @option{-mips16} option such that it targets the MIPS16e2 ASE@.
28003
d77de738 28004@opindex mflip-mips16
ddf6fe37 28005@item -mflip-mips16
d77de738
ML
28006Generate MIPS16 code on alternating functions. This option is provided
28007for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
28008not intended for ordinary use in compiling user code.
28009
d77de738
ML
28010@opindex minterlink-compressed
28011@opindex mno-interlink-compressed
ddf6fe37
AA
28012@item -minterlink-compressed
28013@itemx -mno-interlink-compressed
d77de738
ML
28014Require (do not require) that code using the standard (uncompressed) MIPS ISA
28015be link-compatible with MIPS16 and microMIPS code, and vice versa.
28016
28017For example, code using the standard ISA encoding cannot jump directly
28018to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
28019@option{-minterlink-compressed} therefore disables direct jumps unless GCC
28020knows that the target of the jump is not compressed.
28021
d77de738
ML
28022@opindex minterlink-mips16
28023@opindex mno-interlink-mips16
ddf6fe37
AA
28024@item -minterlink-mips16
28025@itemx -mno-interlink-mips16
d77de738
ML
28026Aliases of @option{-minterlink-compressed} and
28027@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
28028and are retained for backwards compatibility.
28029
00bc8c09 28030@opindex mabi
ddf6fe37
AA
28031@item -mabi=32
28032@itemx -mabi=o64
28033@itemx -mabi=n32
28034@itemx -mabi=64
28035@itemx -mabi=eabi
d77de738
ML
28036Generate code for the given ABI@.
28037
28038Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
28039generates 64-bit code when you select a 64-bit architecture, but you
28040can use @option{-mgp32} to get 32-bit code instead.
28041
28042For information about the O64 ABI, see
28043@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
28044
28045GCC supports a variant of the o32 ABI in which floating-point registers
28046are 64 rather than 32 bits wide. You can select this combination with
28047@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
28048and @code{mfhc1} instructions and is therefore only supported for
28049MIPS32R2, MIPS32R3 and MIPS32R5 processors.
28050
28051The register assignments for arguments and return values remain the
28052same, but each scalar value is passed in a single 64-bit register
28053rather than a pair of 32-bit registers. For example, scalar
28054floating-point values are returned in @samp{$f0} only, not a
28055@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
28056remains the same in that the even-numbered double-precision registers
28057are saved.
28058
28059Two additional variants of the o32 ABI are supported to enable
28060a transition from 32-bit to 64-bit registers. These are FPXX
28061(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
28062The FPXX extension mandates that all code must execute correctly
28063when run using 32-bit or 64-bit registers. The code can be interlinked
28064with either FP32 or FP64, but not both.
28065The FP64A extension is similar to the FP64 extension but forbids the
28066use of odd-numbered single-precision registers. This can be used
28067in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
28068processors and allows both FP32 and FP64A code to interlink and
28069run in the same process without changing FPU modes.
28070
d77de738
ML
28071@opindex mabicalls
28072@opindex mno-abicalls
ddf6fe37
AA
28073@item -mabicalls
28074@itemx -mno-abicalls
d77de738
ML
28075Generate (do not generate) code that is suitable for SVR4-style
28076dynamic objects. @option{-mabicalls} is the default for SVR4-based
28077systems.
28078
28079@item -mshared
28080@itemx -mno-shared
28081Generate (do not generate) code that is fully position-independent,
28082and that can therefore be linked into shared libraries. This option
28083only affects @option{-mabicalls}.
28084
28085All @option{-mabicalls} code has traditionally been position-independent,
28086regardless of options like @option{-fPIC} and @option{-fpic}. However,
28087as an extension, the GNU toolchain allows executables to use absolute
28088accesses for locally-binding symbols. It can also use shorter GP
28089initialization sequences and generate direct calls to locally-defined
28090functions. This mode is selected by @option{-mno-shared}.
28091
28092@option{-mno-shared} depends on binutils 2.16 or higher and generates
28093objects that can only be linked by the GNU linker. However, the option
28094does not affect the ABI of the final executable; it only affects the ABI
28095of relocatable objects. Using @option{-mno-shared} generally makes
28096executables both smaller and quicker.
28097
28098@option{-mshared} is the default.
28099
d77de738
ML
28100@opindex mplt
28101@opindex mno-plt
ddf6fe37
AA
28102@item -mplt
28103@itemx -mno-plt
d77de738
ML
28104Assume (do not assume) that the static and dynamic linkers
28105support PLTs and copy relocations. This option only affects
28106@option{-mno-shared -mabicalls}. For the n64 ABI, this option
28107has no effect without @option{-msym32}.
28108
28109You can make @option{-mplt} the default by configuring
28110GCC with @option{--with-mips-plt}. The default is
28111@option{-mno-plt} otherwise.
28112
d77de738
ML
28113@opindex mxgot
28114@opindex mno-xgot
ddf6fe37
AA
28115@item -mxgot
28116@itemx -mno-xgot
d77de738
ML
28117Lift (do not lift) the usual restrictions on the size of the global
28118offset table.
28119
28120GCC normally uses a single instruction to load values from the GOT@.
28121While this is relatively efficient, it only works if the GOT
28122is smaller than about 64k. Anything larger causes the linker
28123to report an error such as:
28124
28125@cindex relocation truncated to fit (MIPS)
28126@smallexample
28127relocation truncated to fit: R_MIPS_GOT16 foobar
28128@end smallexample
28129
28130If this happens, you should recompile your code with @option{-mxgot}.
28131This works with very large GOTs, although the code is also
28132less efficient, since it takes three instructions to fetch the
28133value of a global symbol.
28134
28135Note that some linkers can create multiple GOTs. If you have such a
28136linker, you should only need to use @option{-mxgot} when a single object
28137file accesses more than 64k's worth of GOT entries. Very few do.
28138
28139These options have no effect unless GCC is generating position
28140independent code.
28141
d77de738 28142@opindex mgp32
ddf6fe37 28143@item -mgp32
d77de738
ML
28144Assume that general-purpose registers are 32 bits wide.
28145
d77de738 28146@opindex mgp64
ddf6fe37 28147@item -mgp64
d77de738
ML
28148Assume that general-purpose registers are 64 bits wide.
28149
d77de738 28150@opindex mfp32
ddf6fe37 28151@item -mfp32
d77de738
ML
28152Assume that floating-point registers are 32 bits wide.
28153
d77de738 28154@opindex mfp64
ddf6fe37 28155@item -mfp64
d77de738
ML
28156Assume that floating-point registers are 64 bits wide.
28157
d77de738 28158@opindex mfpxx
ddf6fe37 28159@item -mfpxx
d77de738
ML
28160Do not assume the width of floating-point registers.
28161
d77de738 28162@opindex mhard-float
ddf6fe37 28163@item -mhard-float
d77de738
ML
28164Use floating-point coprocessor instructions.
28165
d77de738 28166@opindex msoft-float
ddf6fe37 28167@item -msoft-float
d77de738
ML
28168Do not use floating-point coprocessor instructions. Implement
28169floating-point calculations using library calls instead.
28170
d77de738 28171@opindex mno-float
ddf6fe37 28172@item -mno-float
d77de738
ML
28173Equivalent to @option{-msoft-float}, but additionally asserts that the
28174program being compiled does not perform any floating-point operations.
28175This option is presently supported only by some bare-metal MIPS
28176configurations, where it may select a special set of libraries
28177that lack all floating-point support (including, for example, the
28178floating-point @code{printf} formats).
28179If code compiled with @option{-mno-float} accidentally contains
28180floating-point operations, it is likely to suffer a link-time
28181or run-time failure.
28182
d77de738 28183@opindex msingle-float
ddf6fe37 28184@item -msingle-float
d77de738
ML
28185Assume that the floating-point coprocessor only supports single-precision
28186operations.
28187
d77de738 28188@opindex mdouble-float
ddf6fe37 28189@item -mdouble-float
d77de738
ML
28190Assume that the floating-point coprocessor supports double-precision
28191operations. This is the default.
28192
d77de738
ML
28193@opindex modd-spreg
28194@opindex mno-odd-spreg
ddf6fe37
AA
28195@item -modd-spreg
28196@itemx -mno-odd-spreg
d77de738
ML
28197Enable the use of odd-numbered single-precision floating-point registers
28198for the o32 ABI. This is the default for processors that are known to
28199support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
28200is set by default.
28201
d77de738
ML
28202@opindex mabs=2008
28203@opindex mabs=legacy
ddf6fe37
AA
28204@item -mabs=2008
28205@itemx -mabs=legacy
d77de738
ML
28206These options control the treatment of the special not-a-number (NaN)
28207IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
28208@code{neg.@i{fmt}} machine instructions.
28209
28210By default or when @option{-mabs=legacy} is used the legacy
28211treatment is selected. In this case these instructions are considered
28212arithmetic and avoided where correct operation is required and the
28213input operand might be a NaN. A longer sequence of instructions that
28214manipulate the sign bit of floating-point datum manually is used
28215instead unless the @option{-ffinite-math-only} option has also been
28216specified.
28217
28218The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
28219this case these instructions are considered non-arithmetic and therefore
28220operating correctly in all cases, including in particular where the
28221input operand is a NaN. These instructions are therefore always used
28222for the respective operations.
28223
d77de738
ML
28224@opindex mnan=2008
28225@opindex mnan=legacy
ddf6fe37
AA
28226@item -mnan=2008
28227@itemx -mnan=legacy
d77de738
ML
28228These options control the encoding of the special not-a-number (NaN)
28229IEEE 754 floating-point data.
28230
28231The @option{-mnan=legacy} option selects the legacy encoding. In this
28232case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
28233significand field being 0, whereas signaling NaNs (sNaNs) are denoted
28234by the first bit of their trailing significand field being 1.
28235
28236The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
28237this case qNaNs are denoted by the first bit of their trailing
28238significand field being 1, whereas sNaNs are denoted by the first bit of
28239their trailing significand field being 0.
28240
28241The default is @option{-mnan=legacy} unless GCC has been configured with
28242@option{--with-nan=2008}.
28243
d77de738
ML
28244@opindex mllsc
28245@opindex mno-llsc
ddf6fe37
AA
28246@item -mllsc
28247@itemx -mno-llsc
d77de738
ML
28248Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
28249implement atomic memory built-in functions. When neither option is
28250specified, GCC uses the instructions if the target architecture
28251supports them.
28252
28253@option{-mllsc} is useful if the runtime environment can emulate the
28254instructions and @option{-mno-llsc} can be useful when compiling for
28255nonstandard ISAs. You can make either option the default by
28256configuring GCC with @option{--with-llsc} and @option{--without-llsc}
28257respectively. @option{--with-llsc} is the default for some
28258configurations; see the installation documentation for details.
28259
d77de738
ML
28260@opindex mdsp
28261@opindex mno-dsp
ddf6fe37
AA
28262@item -mdsp
28263@itemx -mno-dsp
d77de738
ML
28264Use (do not use) revision 1 of the MIPS DSP ASE@.
28265@xref{MIPS DSP Built-in Functions}. This option defines the
28266preprocessor macro @code{__mips_dsp}. It also defines
28267@code{__mips_dsp_rev} to 1.
28268
d77de738
ML
28269@opindex mdspr2
28270@opindex mno-dspr2
ddf6fe37
AA
28271@item -mdspr2
28272@itemx -mno-dspr2
d77de738
ML
28273Use (do not use) revision 2 of the MIPS DSP ASE@.
28274@xref{MIPS DSP Built-in Functions}. This option defines the
28275preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
28276It also defines @code{__mips_dsp_rev} to 2.
28277
d77de738
ML
28278@opindex msmartmips
28279@opindex mno-smartmips
ddf6fe37
AA
28280@item -msmartmips
28281@itemx -mno-smartmips
d77de738
ML
28282Use (do not use) the MIPS SmartMIPS ASE.
28283
d77de738
ML
28284@opindex mpaired-single
28285@opindex mno-paired-single
ddf6fe37
AA
28286@item -mpaired-single
28287@itemx -mno-paired-single
d77de738
ML
28288Use (do not use) paired-single floating-point instructions.
28289@xref{MIPS Paired-Single Support}. This option requires
28290hardware floating-point support to be enabled.
28291
d77de738
ML
28292@opindex mdmx
28293@opindex mno-mdmx
ddf6fe37
AA
28294@item -mdmx
28295@itemx -mno-mdmx
d77de738
ML
28296Use (do not use) MIPS Digital Media Extension instructions.
28297This option can only be used when generating 64-bit code and requires
28298hardware floating-point support to be enabled.
28299
d77de738
ML
28300@opindex mips3d
28301@opindex mno-mips3d
ddf6fe37
AA
28302@item -mips3d
28303@itemx -mno-mips3d
d77de738
ML
28304Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
28305The option @option{-mips3d} implies @option{-mpaired-single}.
28306
d77de738
ML
28307@opindex mmicromips
28308@opindex mno-mmicromips
ddf6fe37
AA
28309@item -mmicromips
28310@itemx -mno-micromips
d77de738
ML
28311Generate (do not generate) microMIPS code.
28312
28313MicroMIPS code generation can also be controlled on a per-function basis
28314by means of @code{micromips} and @code{nomicromips} attributes.
28315@xref{Function Attributes}, for more information.
28316
d77de738
ML
28317@opindex mmt
28318@opindex mno-mt
ddf6fe37
AA
28319@item -mmt
28320@itemx -mno-mt
d77de738
ML
28321Use (do not use) MT Multithreading instructions.
28322
d77de738
ML
28323@opindex mmcu
28324@opindex mno-mcu
ddf6fe37
AA
28325@item -mmcu
28326@itemx -mno-mcu
d77de738
ML
28327Use (do not use) the MIPS MCU ASE instructions.
28328
d77de738
ML
28329@opindex meva
28330@opindex mno-eva
ddf6fe37
AA
28331@item -meva
28332@itemx -mno-eva
d77de738
ML
28333Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
28334
d77de738
ML
28335@opindex mvirt
28336@opindex mno-virt
ddf6fe37
AA
28337@item -mvirt
28338@itemx -mno-virt
d77de738
ML
28339Use (do not use) the MIPS Virtualization (VZ) instructions.
28340
d77de738
ML
28341@opindex mxpa
28342@opindex mno-xpa
ddf6fe37
AA
28343@item -mxpa
28344@itemx -mno-xpa
d77de738
ML
28345Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
28346
d77de738
ML
28347@opindex mcrc
28348@opindex mno-crc
ddf6fe37
AA
28349@item -mcrc
28350@itemx -mno-crc
d77de738
ML
28351Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
28352
d77de738
ML
28353@opindex mginv
28354@opindex mno-ginv
ddf6fe37
AA
28355@item -mginv
28356@itemx -mno-ginv
d77de738
ML
28357Use (do not use) the MIPS Global INValidate (GINV) instructions.
28358
d77de738
ML
28359@opindex mloongson-mmi
28360@opindex mno-loongson-mmi
ddf6fe37
AA
28361@item -mloongson-mmi
28362@itemx -mno-loongson-mmi
d77de738
ML
28363Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
28364
d77de738
ML
28365@opindex mloongson-ext
28366@opindex mno-loongson-ext
ddf6fe37
AA
28367@item -mloongson-ext
28368@itemx -mno-loongson-ext
d77de738
ML
28369Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
28370
d77de738
ML
28371@opindex mloongson-ext2
28372@opindex mno-loongson-ext2
ddf6fe37
AA
28373@item -mloongson-ext2
28374@itemx -mno-loongson-ext2
d77de738
ML
28375Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
28376
d77de738 28377@opindex mlong64
ddf6fe37 28378@item -mlong64
d77de738
ML
28379Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
28380an explanation of the default and the way that the pointer size is
28381determined.
28382
d77de738 28383@opindex mlong32
ddf6fe37 28384@item -mlong32
d77de738
ML
28385Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
28386
28387The default size of @code{int}s, @code{long}s and pointers depends on
28388the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
28389uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2839032-bit @code{long}s. Pointers are the same size as @code{long}s,
28391or the same size as integer registers, whichever is smaller.
28392
d77de738
ML
28393@opindex msym32
28394@opindex mno-sym32
ddf6fe37
AA
28395@item -msym32
28396@itemx -mno-sym32
d77de738
ML
28397Assume (do not assume) that all symbols have 32-bit values, regardless
28398of the selected ABI@. This option is useful in combination with
28399@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
28400to generate shorter and faster references to symbolic addresses.
28401
d77de738 28402@opindex G
ddf6fe37 28403@item -G @var{num}
d77de738
ML
28404Put definitions of externally-visible data in a small data section
28405if that data is no bigger than @var{num} bytes. GCC can then generate
28406more efficient accesses to the data; see @option{-mgpopt} for details.
28407
28408The default @option{-G} option depends on the configuration.
28409
d77de738
ML
28410@opindex mlocal-sdata
28411@opindex mno-local-sdata
ddf6fe37
AA
28412@item -mlocal-sdata
28413@itemx -mno-local-sdata
d77de738
ML
28414Extend (do not extend) the @option{-G} behavior to local data too,
28415such as to static variables in C@. @option{-mlocal-sdata} is the
28416default for all configurations.
28417
28418If the linker complains that an application is using too much small data,
28419you might want to try rebuilding the less performance-critical parts with
28420@option{-mno-local-sdata}. You might also want to build large
28421libraries with @option{-mno-local-sdata}, so that the libraries leave
28422more room for the main program.
28423
d77de738
ML
28424@opindex mextern-sdata
28425@opindex mno-extern-sdata
ddf6fe37
AA
28426@item -mextern-sdata
28427@itemx -mno-extern-sdata
d77de738
ML
28428Assume (do not assume) that externally-defined data is in
28429a small data section if the size of that data is within the @option{-G} limit.
28430@option{-mextern-sdata} is the default for all configurations.
28431
28432If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
28433@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
28434that is no bigger than @var{num} bytes, you must make sure that @var{Var}
28435is placed in a small data section. If @var{Var} is defined by another
28436module, you must either compile that module with a high-enough
28437@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
28438definition. If @var{Var} is common, you must link the application
28439with a high-enough @option{-G} setting.
28440
28441The easiest way of satisfying these restrictions is to compile
28442and link every module with the same @option{-G} option. However,
28443you may wish to build a library that supports several different
28444small data limits. You can do this by compiling the library with
28445the highest supported @option{-G} setting and additionally using
28446@option{-mno-extern-sdata} to stop the library from making assumptions
28447about externally-defined data.
28448
d77de738
ML
28449@opindex mgpopt
28450@opindex mno-gpopt
ddf6fe37
AA
28451@item -mgpopt
28452@itemx -mno-gpopt
d77de738
ML
28453Use (do not use) GP-relative accesses for symbols that are known to be
28454in a small data section; see @option{-G}, @option{-mlocal-sdata} and
28455@option{-mextern-sdata}. @option{-mgpopt} is the default for all
28456configurations.
28457
28458@option{-mno-gpopt} is useful for cases where the @code{$gp} register
28459might not hold the value of @code{_gp}. For example, if the code is
28460part of a library that might be used in a boot monitor, programs that
28461call boot monitor routines pass an unknown value in @code{$gp}.
28462(In such situations, the boot monitor itself is usually compiled
28463with @option{-G0}.)
28464
28465@option{-mno-gpopt} implies @option{-mno-local-sdata} and
28466@option{-mno-extern-sdata}.
28467
d77de738
ML
28468@opindex membedded-data
28469@opindex mno-embedded-data
ddf6fe37
AA
28470@item -membedded-data
28471@itemx -mno-embedded-data
d77de738
ML
28472Allocate variables to the read-only data section first if possible, then
28473next in the small data section if possible, otherwise in data. This gives
28474slightly slower code than the default, but reduces the amount of RAM required
28475when executing, and thus may be preferred for some embedded systems.
28476
d77de738
ML
28477@opindex muninit-const-in-rodata
28478@opindex mno-uninit-const-in-rodata
ddf6fe37
AA
28479@item -muninit-const-in-rodata
28480@itemx -mno-uninit-const-in-rodata
d77de738
ML
28481Put uninitialized @code{const} variables in the read-only data section.
28482This option is only meaningful in conjunction with @option{-membedded-data}.
28483
d77de738 28484@opindex mcode-readable
ddf6fe37 28485@item -mcode-readable=@var{setting}
d77de738
ML
28486Specify whether GCC may generate code that reads from executable sections.
28487There are three possible settings:
28488
28489@table @gcctabopt
28490@item -mcode-readable=yes
28491Instructions may freely access executable sections. This is the
28492default setting.
28493
28494@item -mcode-readable=pcrel
28495MIPS16 PC-relative load instructions can access executable sections,
28496but other instructions must not do so. This option is useful on 4KSc
28497and 4KSd processors when the code TLBs have the Read Inhibit bit set.
28498It is also useful on processors that can be configured to have a dual
28499instruction/data SRAM interface and that, like the M4K, automatically
28500redirect PC-relative loads to the instruction RAM.
28501
28502@item -mcode-readable=no
28503Instructions must not access executable sections. This option can be
28504useful on targets that are configured to have a dual instruction/data
28505SRAM interface but that (unlike the M4K) do not automatically redirect
28506PC-relative loads to the instruction RAM.
28507@end table
28508
d77de738
ML
28509@opindex msplit-addresses
28510@opindex mno-split-addresses
ddf6fe37
AA
28511@item -msplit-addresses
28512@itemx -mno-split-addresses
d77de738
ML
28513Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
28514relocation operators. This option has been superseded by
28515@option{-mexplicit-relocs} but is retained for backwards compatibility.
28516
00bc8c09
YS
28517@opindex mexplicit-relocs
28518@opindex mno-explicit-relocs
46df1369
YS
28519@item -mexplicit-relocs=none
28520@itemx -mexplicit-relocs=base
28521@itemx -mexplicit-relocs=pcrel
28522@itemx -mexplicit-relocs
ddf6fe37 28523@itemx -mno-explicit-relocs
46df1369
YS
28524These options control whether explicit relocs (such as %gp_rel) are used.
28525The default value depends on the version of GAS when GCC itself was built.
d77de738 28526
46df1369
YS
28527The @code{base} explicit-relocs support introdunced into GAS in 2001.
28528The @code{pcrel} explicit-relocs support introdunced into GAS in 2014,
28529which supports @code{%pcrel_hi} and @code{%pcrel_lo}.
d77de738 28530
d77de738
ML
28531@opindex mcheck-zero-division
28532@opindex mno-check-zero-division
ddf6fe37
AA
28533@item -mcheck-zero-division
28534@itemx -mno-check-zero-division
d77de738
ML
28535Trap (do not trap) on integer division by zero.
28536
28537The default is @option{-mcheck-zero-division}.
28538
d77de738
ML
28539@opindex mdivide-traps
28540@opindex mdivide-breaks
ddf6fe37
AA
28541@item -mdivide-traps
28542@itemx -mdivide-breaks
d77de738
ML
28543MIPS systems check for division by zero by generating either a
28544conditional trap or a break instruction. Using traps results in
28545smaller code, but is only supported on MIPS II and later. Also, some
28546versions of the Linux kernel have a bug that prevents trap from
28547generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
28548allow conditional traps on architectures that support them and
28549@option{-mdivide-breaks} to force the use of breaks.
28550
28551The default is usually @option{-mdivide-traps}, but this can be
28552overridden at configure time using @option{--with-divide=breaks}.
28553Divide-by-zero checks can be completely disabled using
28554@option{-mno-check-zero-division}.
28555
d77de738
ML
28556@opindex mload-store-pairs
28557@opindex mno-load-store-pairs
ddf6fe37
AA
28558@item -mload-store-pairs
28559@itemx -mno-load-store-pairs
d77de738
ML
28560Enable (disable) an optimization that pairs consecutive load or store
28561instructions to enable load/store bonding. This option is enabled by
28562default but only takes effect when the selected architecture is known
28563to support bonding.
28564
acc38ff5
YS
28565@opindex mstrict-align
28566@opindex mno-strict-align
d77de738
ML
28567@opindex munaligned-access
28568@opindex mno-unaligned-access
acc38ff5
YS
28569@item -mstrict-align
28570@itemx -mno-strict-align
28571@itemx -munaligned-access
ddf6fe37 28572@itemx -mno-unaligned-access
acc38ff5
YS
28573Disable (enable) direct unaligned access for MIPS Release 6.
28574MIPSr6 requires load/store unaligned-access support, by hardware or
28575trap&emulate. So @option{-mstrict-align} may be needed by kernel. The
28576options @option{-munaligned-access} and @option{-mno-unaligned-access}
28577are obsoleted, and only for backward-compatible.
d77de738 28578
d77de738
ML
28579@opindex mmemcpy
28580@opindex mno-memcpy
ddf6fe37
AA
28581@item -mmemcpy
28582@itemx -mno-memcpy
d77de738
ML
28583Force (do not force) the use of @code{memcpy} for non-trivial block
28584moves. The default is @option{-mno-memcpy}, which allows GCC to inline
28585most constant-sized copies.
28586
d77de738
ML
28587@opindex mlong-calls
28588@opindex mno-long-calls
ddf6fe37
AA
28589@item -mlong-calls
28590@itemx -mno-long-calls
d77de738
ML
28591Disable (do not disable) use of the @code{jal} instruction. Calling
28592functions using @code{jal} is more efficient but requires the caller
28593and callee to be in the same 256 megabyte segment.
28594
28595This option has no effect on abicalls code. The default is
28596@option{-mno-long-calls}.
28597
d77de738
ML
28598@opindex mmad
28599@opindex mno-mad
ddf6fe37
AA
28600@item -mmad
28601@itemx -mno-mad
d77de738
ML
28602Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
28603instructions, as provided by the R4650 ISA@.
28604
d77de738
ML
28605@opindex mimadd
28606@opindex mno-imadd
ddf6fe37
AA
28607@item -mimadd
28608@itemx -mno-imadd
d77de738
ML
28609Enable (disable) use of the @code{madd} and @code{msub} integer
28610instructions. The default is @option{-mimadd} on architectures
28611that support @code{madd} and @code{msub} except for the 74k
28612architecture where it was found to generate slower code.
28613
d77de738
ML
28614@opindex mfused-madd
28615@opindex mno-fused-madd
ddf6fe37
AA
28616@item -mfused-madd
28617@itemx -mno-fused-madd
d77de738
ML
28618Enable (disable) use of the floating-point multiply-accumulate
28619instructions, when they are available. The default is
28620@option{-mfused-madd}.
28621
28622On the R8000 CPU when multiply-accumulate instructions are used,
28623the intermediate product is calculated to infinite precision
28624and is not subject to the FCSR Flush to Zero bit. This may be
28625undesirable in some circumstances. On other processors the result
28626is numerically identical to the equivalent computation using
28627separate multiply, add, subtract and negate instructions.
28628
d77de738 28629@opindex nocpp
ddf6fe37 28630@item -nocpp
d77de738
ML
28631Tell the MIPS assembler to not run its preprocessor over user
28632assembler files (with a @samp{.s} suffix) when assembling them.
28633
d77de738
ML
28634@opindex mfix-24k
28635@opindex mno-fix-24k
ddf6fe37
AA
28636@item -mfix-24k
28637@itemx -mno-fix-24k
d77de738
ML
28638Work around the 24K E48 (lost data on stores during refill) errata.
28639The workarounds are implemented by the assembler rather than by GCC@.
28640
d77de738
ML
28641@opindex mfix-r4000
28642@opindex mno-fix-r4000
ddf6fe37
AA
28643@item -mfix-r4000
28644@itemx -mno-fix-r4000
d77de738
ML
28645Work around certain R4000 CPU errata:
28646@itemize @minus
28647@item
28648A double-word or a variable shift may give an incorrect result if executed
28649immediately after starting an integer division.
28650@item
28651A double-word or a variable shift may give an incorrect result if executed
28652while an integer multiplication is in progress.
28653@item
28654An integer division may give an incorrect result if started in a delay slot
28655of a taken branch or a jump.
28656@end itemize
28657
d77de738
ML
28658@opindex mfix-r4400
28659@opindex mno-fix-r4400
ddf6fe37
AA
28660@item -mfix-r4400
28661@itemx -mno-fix-r4400
d77de738
ML
28662Work around certain R4400 CPU errata:
28663@itemize @minus
28664@item
28665A double-word or a variable shift may give an incorrect result if executed
28666immediately after starting an integer division.
28667@end itemize
28668
d77de738
ML
28669@opindex mfix-r10000
28670@opindex mno-fix-r10000
ddf6fe37
AA
28671@item -mfix-r10000
28672@itemx -mno-fix-r10000
d77de738
ML
28673Work around certain R10000 errata:
28674@itemize @minus
28675@item
28676@code{ll}/@code{sc} sequences may not behave atomically on revisions
28677prior to 3.0. They may deadlock on revisions 2.6 and earlier.
28678@end itemize
28679
28680This option can only be used if the target architecture supports
28681branch-likely instructions. @option{-mfix-r10000} is the default when
28682@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
28683otherwise.
28684
ddf6fe37 28685@opindex mfix-r5900
d77de738
ML
28686@item -mfix-r5900
28687@itemx -mno-fix-r5900
d77de738
ML
28688Do not attempt to schedule the preceding instruction into the delay slot
28689of a branch instruction placed at the end of a short loop of six
28690instructions or fewer and always schedule a @code{nop} instruction there
28691instead. The short loop bug under certain conditions causes loops to
28692execute only once or twice, due to a hardware bug in the R5900 chip. The
28693workaround is implemented by the assembler rather than by GCC@.
28694
ddf6fe37 28695@opindex mfix-rm7000
d77de738
ML
28696@item -mfix-rm7000
28697@itemx -mno-fix-rm7000
d77de738
ML
28698Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
28699workarounds are implemented by the assembler rather than by GCC@.
28700
ddf6fe37 28701@opindex mfix-vr4120
d77de738
ML
28702@item -mfix-vr4120
28703@itemx -mno-fix-vr4120
d77de738
ML
28704Work around certain VR4120 errata:
28705@itemize @minus
28706@item
28707@code{dmultu} does not always produce the correct result.
28708@item
28709@code{div} and @code{ddiv} do not always produce the correct result if one
28710of the operands is negative.
28711@end itemize
28712The workarounds for the division errata rely on special functions in
28713@file{libgcc.a}. At present, these functions are only provided by
28714the @code{mips64vr*-elf} configurations.
28715
28716Other VR4120 errata require a NOP to be inserted between certain pairs of
28717instructions. These errata are handled by the assembler, not by GCC itself.
28718
d77de738 28719@opindex mfix-vr4130
ddf6fe37 28720@item -mfix-vr4130
d77de738
ML
28721Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
28722workarounds are implemented by the assembler rather than by GCC,
28723although GCC avoids using @code{mflo} and @code{mfhi} if the
28724VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
28725instructions are available instead.
28726
ddf6fe37 28727@opindex mfix-sb1
d77de738
ML
28728@item -mfix-sb1
28729@itemx -mno-fix-sb1
d77de738
ML
28730Work around certain SB-1 CPU core errata.
28731(This flag currently works around the SB-1 revision 2
28732``F1'' and ``F2'' floating-point errata.)
28733
d77de738 28734@opindex mr10k-cache-barrier
ddf6fe37 28735@item -mr10k-cache-barrier=@var{setting}
d77de738
ML
28736Specify whether GCC should insert cache barriers to avoid the
28737side effects of speculation on R10K processors.
28738
28739In common with many processors, the R10K tries to predict the outcome
28740of a conditional branch and speculatively executes instructions from
28741the ``taken'' branch. It later aborts these instructions if the
28742predicted outcome is wrong. However, on the R10K, even aborted
28743instructions can have side effects.
28744
28745This problem only affects kernel stores and, depending on the system,
28746kernel loads. As an example, a speculatively-executed store may load
28747the target memory into cache and mark the cache line as dirty, even if
28748the store itself is later aborted. If a DMA operation writes to the
28749same area of memory before the ``dirty'' line is flushed, the cached
28750data overwrites the DMA-ed data. See the R10K processor manual
28751for a full description, including other potential problems.
28752
28753One workaround is to insert cache barrier instructions before every memory
28754access that might be speculatively executed and that might have side
28755effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
28756controls GCC's implementation of this workaround. It assumes that
28757aborted accesses to any byte in the following regions does not have
28758side effects:
28759
28760@enumerate
28761@item
28762the memory occupied by the current function's stack frame;
28763
28764@item
28765the memory occupied by an incoming stack argument;
28766
28767@item
28768the memory occupied by an object with a link-time-constant address.
28769@end enumerate
28770
28771It is the kernel's responsibility to ensure that speculative
28772accesses to these regions are indeed safe.
28773
28774If the input program contains a function declaration such as:
28775
28776@smallexample
28777void foo (void);
28778@end smallexample
28779
28780then the implementation of @code{foo} must allow @code{j foo} and
28781@code{jal foo} to be executed speculatively. GCC honors this
28782restriction for functions it compiles itself. It expects non-GCC
28783functions (such as hand-written assembly code) to do the same.
28784
28785The option has three forms:
28786
28787@table @gcctabopt
28788@item -mr10k-cache-barrier=load-store
28789Insert a cache barrier before a load or store that might be
28790speculatively executed and that might have side effects even
28791if aborted.
28792
28793@item -mr10k-cache-barrier=store
28794Insert a cache barrier before a store that might be speculatively
28795executed and that might have side effects even if aborted.
28796
28797@item -mr10k-cache-barrier=none
28798Disable the insertion of cache barriers. This is the default setting.
28799@end table
28800
ddf6fe37 28801@opindex mflush-func
00bc8c09 28802@opindex mno-flush-func
d77de738
ML
28803@item -mflush-func=@var{func}
28804@itemx -mno-flush-func
d77de738
ML
28805Specifies the function to call to flush the I and D caches, or to not
28806call any such function. If called, the function must take the same
28807arguments as the common @code{_flush_func}, that is, the address of the
28808memory range for which the cache is being flushed, the size of the
28809memory range, and the number 3 (to flush both caches). The default
28810depends on the target GCC was configured for, but commonly is either
28811@code{_flush_func} or @code{__cpu_flush}.
28812
d77de738 28813@opindex mbranch-cost
00bc8c09 28814@item -mbranch-cost=@var{num}
d77de738
ML
28815Set the cost of branches to roughly @var{num} ``simple'' instructions.
28816This cost is only a heuristic and is not guaranteed to produce
28817consistent results across releases. A zero cost redundantly selects
28818the default, which is based on the @option{-mtune} setting.
28819
d77de738
ML
28820@opindex mbranch-likely
28821@opindex mno-branch-likely
ddf6fe37
AA
28822@item -mbranch-likely
28823@itemx -mno-branch-likely
d77de738
ML
28824Enable or disable use of Branch Likely instructions, regardless of the
28825default for the selected architecture. By default, Branch Likely
28826instructions may be generated if they are supported by the selected
28827architecture. An exception is for the MIPS32 and MIPS64 architectures
28828and processors that implement those architectures; for those, Branch
28829Likely instructions are not be generated by default because the MIPS32
28830and MIPS64 architectures specifically deprecate their use.
28831
d77de738
ML
28832@opindex mcompact-branches=never
28833@opindex mcompact-branches=optimal
28834@opindex mcompact-branches=always
ddf6fe37
AA
28835@item -mcompact-branches=never
28836@itemx -mcompact-branches=optimal
28837@itemx -mcompact-branches=always
d77de738
ML
28838These options control which form of branches will be generated. The
28839default is @option{-mcompact-branches=optimal}.
28840
28841The @option{-mcompact-branches=never} option ensures that compact branch
28842instructions will never be generated.
28843
28844The @option{-mcompact-branches=always} option ensures that a compact
28845branch instruction will be generated if available for MIPS Release 6 onwards.
28846If a compact branch instruction is not available (or pre-R6),
28847a delay slot form of the branch will be used instead.
28848
28849If it is used for MIPS16/microMIPS targets, it will be just ignored now.
28850The behaviour for MIPS16/microMIPS may change in future,
28851since they do have some compact branch instructions.
28852
28853The @option{-mcompact-branches=optimal} option will cause a delay slot
28854branch to be used if one is available in the current ISA and the delay
28855slot is successfully filled. If the delay slot is not filled, a compact
28856branch will be chosen if one is available.
28857
ddf6fe37 28858@opindex mfp-exceptions
d77de738
ML
28859@item -mfp-exceptions
28860@itemx -mno-fp-exceptions
d77de738
ML
28861Specifies whether FP exceptions are enabled. This affects how
28862FP instructions are scheduled for some processors.
28863The default is that FP exceptions are
28864enabled.
28865
28866For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2886764-bit code, then we can use both FP pipes. Otherwise, we can only use one
28868FP pipe.
28869
ddf6fe37 28870@opindex mvr4130-align
d77de738
ML
28871@item -mvr4130-align
28872@itemx -mno-vr4130-align
d77de738
ML
28873The VR4130 pipeline is two-way superscalar, but can only issue two
28874instructions together if the first one is 8-byte aligned. When this
28875option is enabled, GCC aligns pairs of instructions that it
28876thinks should execute in parallel.
28877
28878This option only has an effect when optimizing for the VR4130.
28879It normally makes code faster, but at the expense of making it bigger.
28880It is enabled by default at optimization level @option{-O3}.
28881
ddf6fe37 28882@opindex msynci
d77de738
ML
28883@item -msynci
28884@itemx -mno-synci
d77de738
ML
28885Enable (disable) generation of @code{synci} instructions on
28886architectures that support it. The @code{synci} instructions (if
28887enabled) are generated when @code{__builtin___clear_cache} is
28888compiled.
28889
28890This option defaults to @option{-mno-synci}, but the default can be
28891overridden by configuring GCC with @option{--with-synci}.
28892
28893When compiling code for single processor systems, it is generally safe
28894to use @code{synci}. However, on many multi-core (SMP) systems, it
28895does not invalidate the instruction caches on all cores and may lead
28896to undefined behavior.
28897
ddf6fe37 28898@opindex mrelax-pic-calls
d77de738
ML
28899@item -mrelax-pic-calls
28900@itemx -mno-relax-pic-calls
d77de738
ML
28901Try to turn PIC calls that are normally dispatched via register
28902@code{$25} into direct calls. This is only possible if the linker can
28903resolve the destination at link time and if the destination is within
28904range for a direct call.
28905
28906@option{-mrelax-pic-calls} is the default if GCC was configured to use
28907an assembler and a linker that support the @code{.reloc} assembly
28908directive and @option{-mexplicit-relocs} is in effect. With
28909@option{-mno-explicit-relocs}, this optimization can be performed by the
28910assembler and the linker alone without help from the compiler.
28911
d77de738
ML
28912@opindex mmcount-ra-address
28913@opindex mno-mcount-ra-address
ddf6fe37
AA
28914@item -mmcount-ra-address
28915@itemx -mno-mcount-ra-address
d77de738
ML
28916Emit (do not emit) code that allows @code{_mcount} to modify the
28917calling function's return address. When enabled, this option extends
28918the usual @code{_mcount} interface with a new @var{ra-address}
28919parameter, which has type @code{intptr_t *} and is passed in register
28920@code{$12}. @code{_mcount} can then modify the return address by
28921doing both of the following:
28922@itemize
28923@item
28924Returning the new address in register @code{$31}.
28925@item
28926Storing the new address in @code{*@var{ra-address}},
28927if @var{ra-address} is nonnull.
28928@end itemize
28929
28930The default is @option{-mno-mcount-ra-address}.
28931
ddf6fe37 28932@opindex mframe-header-opt
d77de738
ML
28933@item -mframe-header-opt
28934@itemx -mno-frame-header-opt
d77de738
ML
28935Enable (disable) frame header optimization in the o32 ABI. When using the
28936o32 ABI, calling functions will allocate 16 bytes on the stack for the called
28937function to write out register arguments. When enabled, this optimization
28938will suppress the allocation of the frame header if it can be determined that
28939it is unused.
28940
28941This optimization is off by default at all optimization levels.
28942
ddf6fe37 28943@opindex mlxc1-sxc1
d77de738
ML
28944@item -mlxc1-sxc1
28945@itemx -mno-lxc1-sxc1
d77de738
ML
28946When applicable, enable (disable) the generation of @code{lwxc1},
28947@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
28948
ddf6fe37 28949@opindex mmadd4
d77de738
ML
28950@item -mmadd4
28951@itemx -mno-madd4
d77de738
ML
28952When applicable, enable (disable) the generation of 4-operand @code{madd.s},
28953@code{madd.d} and related instructions. Enabled by default.
28954
28955@end table
28956
28957@node MMIX Options
28958@subsection MMIX Options
28959@cindex MMIX Options
28960
28961These options are defined for the MMIX:
28962
28963@table @gcctabopt
d77de738
ML
28964@opindex mlibfuncs
28965@opindex mno-libfuncs
ddf6fe37
AA
28966@item -mlibfuncs
28967@itemx -mno-libfuncs
d77de738
ML
28968Specify that intrinsic library functions are being compiled, passing all
28969values in registers, no matter the size.
28970
d77de738
ML
28971@opindex mepsilon
28972@opindex mno-epsilon
ddf6fe37
AA
28973@item -mepsilon
28974@itemx -mno-epsilon
d77de738
ML
28975Generate floating-point comparison instructions that compare with respect
28976to the @code{rE} epsilon register.
28977
d77de738
ML
28978@opindex mabi=mmixware
28979@opindex mabi=gnu
ddf6fe37
AA
28980@item -mabi=mmixware
28981@itemx -mabi=gnu
d77de738
ML
28982Generate code that passes function parameters and return values that (in
28983the called function) are seen as registers @code{$0} and up, as opposed to
28984the GNU ABI which uses global registers @code{$231} and up.
28985
d77de738
ML
28986@opindex mzero-extend
28987@opindex mno-zero-extend
ddf6fe37
AA
28988@item -mzero-extend
28989@itemx -mno-zero-extend
d77de738
ML
28990When reading data from memory in sizes shorter than 64 bits, use (do not
28991use) zero-extending load instructions by default, rather than
28992sign-extending ones.
28993
d77de738
ML
28994@opindex mknuthdiv
28995@opindex mno-knuthdiv
ddf6fe37
AA
28996@item -mknuthdiv
28997@itemx -mno-knuthdiv
d77de738
ML
28998Make the result of a division yielding a remainder have the same sign as
28999the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
29000remainder follows the sign of the dividend. Both methods are
29001arithmetically valid, the latter being almost exclusively used.
29002
d77de738
ML
29003@opindex mtoplevel-symbols
29004@opindex mno-toplevel-symbols
ddf6fe37
AA
29005@item -mtoplevel-symbols
29006@itemx -mno-toplevel-symbols
d77de738
ML
29007Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
29008code can be used with the @code{PREFIX} assembly directive.
29009
d77de738 29010@opindex melf
ddf6fe37 29011@item -melf
d77de738
ML
29012Generate an executable in the ELF format, rather than the default
29013@samp{mmo} format used by the @command{mmix} simulator.
29014
d77de738
ML
29015@opindex mbranch-predict
29016@opindex mno-branch-predict
ddf6fe37
AA
29017@item -mbranch-predict
29018@itemx -mno-branch-predict
d77de738
ML
29019Use (do not use) the probable-branch instructions, when static branch
29020prediction indicates a probable branch.
29021
d77de738
ML
29022@opindex mbase-addresses
29023@opindex mno-base-addresses
ddf6fe37
AA
29024@item -mbase-addresses
29025@itemx -mno-base-addresses
d77de738
ML
29026Generate (do not generate) code that uses @emph{base addresses}. Using a
29027base address automatically generates a request (handled by the assembler
29028and the linker) for a constant to be set up in a global register. The
29029register is used for one or more base address requests within the range 0
29030to 255 from the value held in the register. The generally leads to short
29031and fast code, but the number of different data items that can be
29032addressed is limited. This means that a program that uses lots of static
29033data may require @option{-mno-base-addresses}.
29034
d77de738
ML
29035@opindex msingle-exit
29036@opindex mno-single-exit
ddf6fe37
AA
29037@item -msingle-exit
29038@itemx -mno-single-exit
d77de738
ML
29039Force (do not force) generated code to have a single exit point in each
29040function.
29041@end table
29042
29043@node MN10300 Options
29044@subsection MN10300 Options
29045@cindex MN10300 options
29046
29047These @option{-m} options are defined for Matsushita MN10300 architectures:
29048
29049@table @gcctabopt
d77de738 29050@opindex mmult-bug
ddf6fe37 29051@item -mmult-bug
d77de738
ML
29052Generate code to avoid bugs in the multiply instructions for the MN10300
29053processors. This is the default.
29054
d77de738 29055@opindex mno-mult-bug
ddf6fe37 29056@item -mno-mult-bug
d77de738
ML
29057Do not generate code to avoid bugs in the multiply instructions for the
29058MN10300 processors.
29059
d77de738 29060@opindex mam33
ddf6fe37 29061@item -mam33
d77de738
ML
29062Generate code using features specific to the AM33 processor.
29063
d77de738 29064@opindex mno-am33
ddf6fe37 29065@item -mno-am33
d77de738
ML
29066Do not generate code using features specific to the AM33 processor. This
29067is the default.
29068
d77de738 29069@opindex mam33-2
ddf6fe37 29070@item -mam33-2
d77de738
ML
29071Generate code using features specific to the AM33/2.0 processor.
29072
d77de738 29073@opindex mam34
ddf6fe37 29074@item -mam34
d77de738
ML
29075Generate code using features specific to the AM34 processor.
29076
d77de738 29077@opindex mtune
ddf6fe37 29078@item -mtune=@var{cpu-type}
d77de738
ML
29079Use the timing characteristics of the indicated CPU type when
29080scheduling instructions. This does not change the targeted processor
29081type. The CPU type must be one of @samp{mn10300}, @samp{am33},
29082@samp{am33-2} or @samp{am34}.
29083
d77de738 29084@opindex mreturn-pointer-on-d0
ddf6fe37 29085@item -mreturn-pointer-on-d0
d77de738
ML
29086When generating a function that returns a pointer, return the pointer
29087in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
29088only in @code{a0}, and attempts to call such functions without a prototype
29089result in errors. Note that this option is on by default; use
29090@option{-mno-return-pointer-on-d0} to disable it.
29091
d77de738 29092@opindex mno-crt0
ddf6fe37 29093@item -mno-crt0
d77de738
ML
29094Do not link in the C run-time initialization object file.
29095
d77de738 29096@opindex mrelax
ddf6fe37 29097@item -mrelax
d77de738
ML
29098Indicate to the linker that it should perform a relaxation optimization pass
29099to shorten branches, calls and absolute memory addresses. This option only
29100has an effect when used on the command line for the final link step.
29101
29102This option makes symbolic debugging impossible.
29103
d77de738 29104@opindex mliw
ddf6fe37 29105@item -mliw
d77de738
ML
29106Allow the compiler to generate @emph{Long Instruction Word}
29107instructions if the target is the @samp{AM33} or later. This is the
29108default. This option defines the preprocessor macro @code{__LIW__}.
29109
d77de738 29110@opindex mno-liw
ddf6fe37 29111@item -mno-liw
d77de738
ML
29112Do not allow the compiler to generate @emph{Long Instruction Word}
29113instructions. This option defines the preprocessor macro
29114@code{__NO_LIW__}.
29115
d77de738 29116@opindex msetlb
ddf6fe37 29117@item -msetlb
d77de738
ML
29118Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
29119instructions if the target is the @samp{AM33} or later. This is the
29120default. This option defines the preprocessor macro @code{__SETLB__}.
29121
d77de738 29122@opindex mno-setlb
ddf6fe37 29123@item -mno-setlb
d77de738
ML
29124Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
29125instructions. This option defines the preprocessor macro
29126@code{__NO_SETLB__}.
29127
29128@end table
29129
29130@node Moxie Options
29131@subsection Moxie Options
29132@cindex Moxie Options
29133
29134@table @gcctabopt
29135
d77de738 29136@opindex meb
ddf6fe37 29137@item -meb
d77de738
ML
29138Generate big-endian code. This is the default for @samp{moxie-*-*}
29139configurations.
29140
d77de738 29141@opindex mel
ddf6fe37 29142@item -mel
d77de738
ML
29143Generate little-endian code.
29144
d77de738 29145@opindex mmul.x
ddf6fe37 29146@item -mmul.x
d77de738
ML
29147Generate mul.x and umul.x instructions. This is the default for
29148@samp{moxiebox-*-*} configurations.
29149
d77de738 29150@opindex mno-crt0
ddf6fe37 29151@item -mno-crt0
d77de738
ML
29152Do not link in the C run-time initialization object file.
29153
29154@end table
29155
29156@node MSP430 Options
29157@subsection MSP430 Options
29158@cindex MSP430 Options
29159
29160These options are defined for the MSP430:
29161
29162@table @gcctabopt
29163
d77de738 29164@opindex masm-hex
ddf6fe37 29165@item -masm-hex
d77de738
ML
29166Force assembly output to always use hex constants. Normally such
29167constants are signed decimals, but this option is available for
29168testsuite and/or aesthetic purposes.
29169
d77de738 29170@opindex mmcu=
ddf6fe37 29171@item -mmcu=
d77de738
ML
29172Select the MCU to target. This is used to create a C preprocessor
29173symbol based upon the MCU name, converted to upper case and pre- and
29174post-fixed with @samp{__}. This in turn is used by the
29175@file{msp430.h} header file to select an MCU-specific supplementary
29176header file.
29177
29178The option also sets the ISA to use. If the MCU name is one that is
29179known to only support the 430 ISA then that is selected, otherwise the
29180430X ISA is selected. A generic MCU name of @samp{msp430} can also be
29181used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
29182name selects the 430X ISA.
29183
29184In addition an MCU-specific linker script is added to the linker
29185command line. The script's name is the name of the MCU with
29186@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
29187command line defines the C preprocessor symbol @code{__XXX__} and
29188cause the linker to search for a script called @file{xxx.ld}.
29189
29190The ISA and hardware multiply supported for the different MCUs is hard-coded
29191into GCC. However, an external @samp{devices.csv} file can be used to
29192extend device support beyond those that have been hard-coded.
29193
29194GCC searches for the @samp{devices.csv} file using the following methods in the
29195given precedence order, where the first method takes precendence over the
29196second which takes precedence over the third.
29197
29198@table @asis
29199@item Include path specified with @code{-I} and @code{-L}
29200@samp{devices.csv} will be searched for in each of the directories specified by
29201include paths and linker library search paths.
29202@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
29203Define the value of the global environment variable
29204@samp{MSP430_GCC_INCLUDE_DIR}
29205to the full path to the directory containing devices.csv, and GCC will search
29206this directory for devices.csv. If devices.csv is found, this directory will
29207also be registered as an include path, and linker library path. Header files
29208and linker scripts in this directory can therefore be used without manually
29209specifying @code{-I} and @code{-L} on the command line.
29210@item The @samp{msp430-elf@{,bare@}/include/devices} directory
29211Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
29212toolchain root directory. This directory does not exist in a default
29213installation, but if the user has created it and copied @samp{devices.csv}
29214there, then the MCU data will be read. As above, this directory will
29215also be registered as an include path, and linker library path.
29216
29217@end table
29218If none of the above search methods find @samp{devices.csv}, then the
29219hard-coded MCU data is used.
29220
29221
d77de738
ML
29222@opindex mwarn-mcu
29223@opindex mno-warn-mcu
ddf6fe37
AA
29224@item -mwarn-mcu
29225@itemx -mno-warn-mcu
d77de738
ML
29226This option enables or disables warnings about conflicts between the
29227MCU name specified by the @option{-mmcu} option and the ISA set by the
29228@option{-mcpu} option and/or the hardware multiply support set by the
29229@option{-mhwmult} option. It also toggles warnings about unrecognized
29230MCU names. This option is on by default.
29231
d77de738 29232@opindex mcpu=
ddf6fe37 29233@item -mcpu=
d77de738
ML
29234Specifies the ISA to use. Accepted values are @samp{msp430},
29235@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
29236@option{-mmcu=} option should be used to select the ISA.
29237
d77de738 29238@opindex msim
ddf6fe37 29239@item -msim
d77de738
ML
29240Link to the simulator runtime libraries and linker script. Overrides
29241any scripts that would be selected by the @option{-mmcu=} option.
29242
d77de738 29243@opindex mlarge
ddf6fe37 29244@item -mlarge
d77de738
ML
29245Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
29246
d77de738 29247@opindex msmall
ddf6fe37 29248@item -msmall
d77de738
ML
29249Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
29250
d77de738 29251@opindex mrelax
ddf6fe37 29252@item -mrelax
d77de738
ML
29253This option is passed to the assembler and linker, and allows the
29254linker to perform certain optimizations that cannot be done until
29255the final link.
29256
d77de738 29257@opindex mhwmult=
ddf6fe37 29258@item mhwmult=
d77de738
ML
29259Describes the type of hardware multiply supported by the target.
29260Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
29261for the original 16-bit-only multiply supported by early MCUs.
29262@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
29263@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
29264A value of @samp{auto} can also be given. This tells GCC to deduce
29265the hardware multiply support based upon the MCU name provided by the
29266@option{-mmcu} option. If no @option{-mmcu} option is specified or if
29267the MCU name is not recognized then no hardware multiply support is
29268assumed. @code{auto} is the default setting.
29269
29270Hardware multiplies are normally performed by calling a library
29271routine. This saves space in the generated code. When compiling at
29272@option{-O3} or higher however the hardware multiplier is invoked
29273inline. This makes for bigger, but faster code.
29274
29275The hardware multiply routines disable interrupts whilst running and
29276restore the previous interrupt state when they finish. This makes
29277them safe to use inside interrupt handlers as well as in normal code.
29278
d77de738 29279@opindex minrt
ddf6fe37 29280@item -minrt
d77de738
ML
29281Enable the use of a minimum runtime environment - no static
29282initializers or constructors. This is intended for memory-constrained
29283devices. The compiler includes special symbols in some objects
29284that tell the linker and runtime which code fragments are required.
29285
d77de738 29286@opindex mtiny-printf
ddf6fe37 29287@item -mtiny-printf
d77de738
ML
29288Enable reduced code size @code{printf} and @code{puts} library functions.
29289The @samp{tiny} implementations of these functions are not reentrant, so
29290must be used with caution in multi-threaded applications.
29291
29292Support for streams has been removed and the string to be printed will
29293always be sent to stdout via the @code{write} syscall. The string is not
29294buffered before it is sent to write.
29295
29296This option requires Newlib Nano IO, so GCC must be configured with
29297@samp{--enable-newlib-nano-formatted-io}.
29298
d77de738 29299@opindex mmax-inline-shift=
ddf6fe37 29300@item -mmax-inline-shift=
d77de738
ML
29301This option takes an integer between 0 and 64 inclusive, and sets
29302the maximum number of inline shift instructions which should be emitted to
29303perform a shift operation by a constant amount. When this value needs to be
29304exceeded, an mspabi helper function is used instead. The default value is 4.
29305
29306This only affects cases where a shift by multiple positions cannot be
29307completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
29308
29309Shifts of a 32-bit value are at least twice as costly, so the value passed for
29310this option is divided by 2 and the resulting value used instead.
29311
d77de738
ML
29312@opindex mcode-region
29313@opindex mdata-region
ddf6fe37
AA
29314@item -mcode-region=
29315@itemx -mdata-region=
d77de738
ML
29316These options tell the compiler where to place functions and data that
29317do not have one of the @code{lower}, @code{upper}, @code{either} or
29318@code{section} attributes. Possible values are @code{lower},
29319@code{upper}, @code{either} or @code{any}. The first three behave
29320like the corresponding attribute. The fourth possible value -
29321@code{any} - is the default. It leaves placement entirely up to the
29322linker script and how it assigns the standard sections
29323(@code{.text}, @code{.data}, etc) to the memory regions.
29324
d77de738 29325@opindex msilicon-errata
ddf6fe37 29326@item -msilicon-errata=
d77de738
ML
29327This option passes on a request to assembler to enable the fixes for
29328the named silicon errata.
29329
d77de738 29330@opindex msilicon-errata-warn
ddf6fe37 29331@item -msilicon-errata-warn=
d77de738
ML
29332This option passes on a request to the assembler to enable warning
29333messages when a silicon errata might need to be applied.
29334
d77de738
ML
29335@opindex mwarn-devices-csv
29336@opindex mno-warn-devices-csv
ddf6fe37
AA
29337@item -mwarn-devices-csv
29338@itemx -mno-warn-devices-csv
d77de738
ML
29339Warn if @samp{devices.csv} is not found or there are problem parsing it
29340(default: on).
29341
29342@end table
29343
29344@node NDS32 Options
29345@subsection NDS32 Options
29346@cindex NDS32 Options
29347
29348These options are defined for NDS32 implementations:
29349
29350@table @gcctabopt
29351
d77de738 29352@opindex mbig-endian
ddf6fe37 29353@item -mbig-endian
d77de738
ML
29354Generate code in big-endian mode.
29355
d77de738 29356@opindex mlittle-endian
ddf6fe37 29357@item -mlittle-endian
d77de738
ML
29358Generate code in little-endian mode.
29359
d77de738 29360@opindex mreduced-regs
ddf6fe37 29361@item -mreduced-regs
d77de738
ML
29362Use reduced-set registers for register allocation.
29363
d77de738 29364@opindex mfull-regs
ddf6fe37 29365@item -mfull-regs
d77de738
ML
29366Use full-set registers for register allocation.
29367
d77de738 29368@opindex mcmov
ddf6fe37 29369@item -mcmov
d77de738
ML
29370Generate conditional move instructions.
29371
d77de738 29372@opindex mno-cmov
ddf6fe37 29373@item -mno-cmov
d77de738
ML
29374Do not generate conditional move instructions.
29375
d77de738 29376@opindex mext-perf
ddf6fe37 29377@item -mext-perf
d77de738
ML
29378Generate performance extension instructions.
29379
d77de738 29380@opindex mno-ext-perf
ddf6fe37 29381@item -mno-ext-perf
d77de738
ML
29382Do not generate performance extension instructions.
29383
d77de738 29384@opindex mext-perf2
ddf6fe37 29385@item -mext-perf2
d77de738
ML
29386Generate performance extension 2 instructions.
29387
d77de738 29388@opindex mno-ext-perf2
ddf6fe37 29389@item -mno-ext-perf2
d77de738
ML
29390Do not generate performance extension 2 instructions.
29391
d77de738 29392@opindex mext-string
ddf6fe37 29393@item -mext-string
d77de738
ML
29394Generate string extension instructions.
29395
d77de738 29396@opindex mno-ext-string
ddf6fe37 29397@item -mno-ext-string
d77de738
ML
29398Do not generate string extension instructions.
29399
d77de738 29400@opindex mv3push
ddf6fe37 29401@item -mv3push
d77de738
ML
29402Generate v3 push25/pop25 instructions.
29403
d77de738 29404@opindex mno-v3push
ddf6fe37 29405@item -mno-v3push
d77de738
ML
29406Do not generate v3 push25/pop25 instructions.
29407
d77de738 29408@opindex m16-bit
ddf6fe37 29409@item -m16-bit
d77de738
ML
29410Generate 16-bit instructions.
29411
d77de738 29412@opindex mno-16-bit
ddf6fe37 29413@item -mno-16-bit
d77de738
ML
29414Do not generate 16-bit instructions.
29415
d77de738 29416@opindex misr-vector-size
ddf6fe37 29417@item -misr-vector-size=@var{num}
d77de738
ML
29418Specify the size of each interrupt vector, which must be 4 or 16.
29419
d77de738 29420@opindex mcache-block-size
ddf6fe37 29421@item -mcache-block-size=@var{num}
d77de738
ML
29422Specify the size of each cache block,
29423which must be a power of 2 between 4 and 512.
29424
d77de738 29425@opindex march
ddf6fe37 29426@item -march=@var{arch}
d77de738
ML
29427Specify the name of the target architecture.
29428
d77de738 29429@opindex mcmodel
ddf6fe37 29430@item -mcmodel=@var{code-model}
d77de738
ML
29431Set the code model to one of
29432@table @asis
29433@item @samp{small}
29434All the data and read-only data segments must be within 512KB addressing space.
29435The text segment must be within 16MB addressing space.
29436@item @samp{medium}
29437The data segment must be within 512KB while the read-only data segment can be
29438within 4GB addressing space. The text segment should be still within 16MB
29439addressing space.
29440@item @samp{large}
29441All the text and data segments can be within 4GB addressing space.
29442@end table
29443
d77de738 29444@opindex mctor-dtor
ddf6fe37 29445@item -mctor-dtor
d77de738
ML
29446Enable constructor/destructor feature.
29447
d77de738 29448@opindex mrelax
ddf6fe37 29449@item -mrelax
d77de738
ML
29450Guide linker to relax instructions.
29451
29452@end table
29453
29454@node Nios II Options
29455@subsection Nios II Options
29456@cindex Nios II options
29457@cindex Altera Nios II options
29458
29459These are the options defined for the Altera Nios II processor.
29460
29461@table @gcctabopt
29462
d77de738
ML
29463@opindex G
29464@cindex smaller data references
f33d7a88 29465@item -G @var{num}
d77de738
ML
29466Put global and static objects less than or equal to @var{num} bytes
29467into the small data or BSS sections instead of the normal data or BSS
29468sections. The default value of @var{num} is 8.
29469
ddf6fe37
AA
29470@opindex mgpopt
29471@opindex mno-gpopt
d77de738
ML
29472@item -mgpopt=@var{option}
29473@itemx -mgpopt
29474@itemx -mno-gpopt
d77de738
ML
29475Generate (do not generate) GP-relative accesses. The following
29476@var{option} names are recognized:
29477
29478@table @samp
29479
29480@item none
29481Do not generate GP-relative accesses.
29482
29483@item local
29484Generate GP-relative accesses for small data objects that are not
29485external, weak, or uninitialized common symbols.
29486Also use GP-relative addressing for objects that
29487have been explicitly placed in a small data section via a @code{section}
29488attribute.
29489
29490@item global
29491As for @samp{local}, but also generate GP-relative accesses for
29492small data objects that are external, weak, or common. If you use this option,
29493you must ensure that all parts of your program (including libraries) are
29494compiled with the same @option{-G} setting.
29495
29496@item data
29497Generate GP-relative accesses for all data objects in the program. If you
29498use this option, the entire data and BSS segments
29499of your program must fit in 64K of memory and you must use an appropriate
29500linker script to allocate them within the addressable range of the
29501global pointer.
29502
29503@item all
29504Generate GP-relative addresses for function pointers as well as data
29505pointers. If you use this option, the entire text, data, and BSS segments
29506of your program must fit in 64K of memory and you must use an appropriate
29507linker script to allocate them within the addressable range of the
29508global pointer.
29509
29510@end table
29511
29512@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
29513@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
29514
29515The default is @option{-mgpopt} except when @option{-fpic} or
29516@option{-fPIC} is specified to generate position-independent code.
29517Note that the Nios II ABI does not permit GP-relative accesses from
29518shared libraries.
29519
29520You may need to specify @option{-mno-gpopt} explicitly when building
29521programs that include large amounts of small data, including large
29522GOT data sections. In this case, the 16-bit offset for GP-relative
29523addressing may not be large enough to allow access to the entire
29524small data section.
29525
d77de738 29526@opindex mgprel-sec
ddf6fe37 29527@item -mgprel-sec=@var{regexp}
d77de738
ML
29528This option specifies additional section names that can be accessed via
29529GP-relative addressing. It is most useful in conjunction with
29530@code{section} attributes on variable declarations
29531(@pxref{Common Variable Attributes}) and a custom linker script.
29532The @var{regexp} is a POSIX Extended Regular Expression.
29533
29534This option does not affect the behavior of the @option{-G} option, and
29535the specified sections are in addition to the standard @code{.sdata}
29536and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
29537
d77de738 29538@opindex mr0rel-sec
ddf6fe37 29539@item -mr0rel-sec=@var{regexp}
d77de738
ML
29540This option specifies names of sections that can be accessed via a
2954116-bit offset from @code{r0}; that is, in the low 32K or high 32K
29542of the 32-bit address space. It is most useful in conjunction with
29543@code{section} attributes on variable declarations
29544(@pxref{Common Variable Attributes}) and a custom linker script.
29545The @var{regexp} is a POSIX Extended Regular Expression.
29546
29547In contrast to the use of GP-relative addressing for small data,
29548zero-based addressing is never generated by default and there are no
29549conventional section names used in standard linker scripts for sections
29550in the low or high areas of memory.
29551
d77de738
ML
29552@opindex mel
29553@opindex meb
ddf6fe37
AA
29554@item -mel
29555@itemx -meb
d77de738
ML
29556Generate little-endian (default) or big-endian (experimental) code,
29557respectively.
29558
d77de738 29559@opindex march
ddf6fe37 29560@item -march=@var{arch}
d77de738
ML
29561This specifies the name of the target Nios II architecture. GCC uses this
29562name to determine what kind of instructions it can emit when generating
29563assembly code. Permissible names are: @samp{r1}, @samp{r2}.
29564
29565The preprocessor macro @code{__nios2_arch__} is available to programs,
29566with value 1 or 2, indicating the targeted ISA level.
29567
d77de738
ML
29568@opindex mno-bypass-cache
29569@opindex mbypass-cache
ddf6fe37
AA
29570@item -mbypass-cache
29571@itemx -mno-bypass-cache
d77de738
ML
29572Force all load and store instructions to always bypass cache by
29573using I/O variants of the instructions. The default is not to
29574bypass the cache.
29575
d77de738
ML
29576@opindex mcache-volatile
29577@opindex mno-cache-volatile
ddf6fe37
AA
29578@item -mno-cache-volatile
29579@itemx -mcache-volatile
d77de738
ML
29580Volatile memory access bypass the cache using the I/O variants of
29581the load and store instructions. The default is not to bypass the cache.
29582
d77de738
ML
29583@opindex mno-fast-sw-div
29584@opindex mfast-sw-div
ddf6fe37
AA
29585@item -mno-fast-sw-div
29586@itemx -mfast-sw-div
d77de738
ML
29587Do not use table-based fast divide for small numbers. The default
29588is to use the fast divide at @option{-O3} and above.
29589
d77de738
ML
29590@opindex mno-hw-mul
29591@opindex mhw-mul
29592@opindex mno-hw-mulx
29593@opindex mhw-mulx
29594@opindex mno-hw-div
29595@opindex mhw-div
ddf6fe37
AA
29596@item -mno-hw-mul
29597@itemx -mhw-mul
29598@itemx -mno-hw-mulx
29599@itemx -mhw-mulx
29600@itemx -mno-hw-div
29601@itemx -mhw-div
d77de738
ML
29602Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
29603instructions by the compiler. The default is to emit @code{mul}
29604and not emit @code{div} and @code{mulx}.
29605
29606@item -mbmx
29607@itemx -mno-bmx
29608@itemx -mcdx
29609@itemx -mno-cdx
29610Enable or disable generation of Nios II R2 BMX (bit manipulation) and
29611CDX (code density) instructions. Enabling these instructions also
29612requires @option{-march=r2}. Since these instructions are optional
29613extensions to the R2 architecture, the default is not to emit them.
29614
d77de738
ML
29615@opindex mcustom-@var{insn}
29616@opindex mno-custom-@var{insn}
ddf6fe37
AA
29617@item -mcustom-@var{insn}=@var{N}
29618@itemx -mno-custom-@var{insn}
d77de738
ML
29619Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
29620custom instruction with encoding @var{N} when generating code that uses
29621@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
29622instruction 253 for single-precision floating-point add operations instead
29623of the default behavior of using a library call.
29624
29625The following values of @var{insn} are supported. Except as otherwise
29626noted, floating-point operations are expected to be implemented with
29627normal IEEE 754 semantics and correspond directly to the C operators or the
29628equivalent GCC built-in functions (@pxref{Other Builtins}).
29629
29630Single-precision floating point:
29631@table @asis
29632
29633@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
29634Binary arithmetic operations.
29635
29636@item @samp{fnegs}
29637Unary negation.
29638
29639@item @samp{fabss}
29640Unary absolute value.
29641
29642@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
29643Comparison operations.
29644
29645@item @samp{fmins}, @samp{fmaxs}
29646Floating-point minimum and maximum. These instructions are only
29647generated if @option{-ffinite-math-only} is specified.
29648
29649@item @samp{fsqrts}
29650Unary square root operation.
29651
29652@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
29653Floating-point trigonometric and exponential functions. These instructions
29654are only generated if @option{-funsafe-math-optimizations} is also specified.
29655
29656@end table
29657
29658Double-precision floating point:
29659@table @asis
29660
29661@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
29662Binary arithmetic operations.
29663
29664@item @samp{fnegd}
29665Unary negation.
29666
29667@item @samp{fabsd}
29668Unary absolute value.
29669
29670@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
29671Comparison operations.
29672
29673@item @samp{fmind}, @samp{fmaxd}
29674Double-precision minimum and maximum. These instructions are only
29675generated if @option{-ffinite-math-only} is specified.
29676
29677@item @samp{fsqrtd}
29678Unary square root operation.
29679
29680@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
29681Double-precision trigonometric and exponential functions. These instructions
29682are only generated if @option{-funsafe-math-optimizations} is also specified.
29683
29684@end table
29685
29686Conversions:
29687@table @asis
29688@item @samp{fextsd}
29689Conversion from single precision to double precision.
29690
29691@item @samp{ftruncds}
29692Conversion from double precision to single precision.
29693
29694@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
29695Conversion from floating point to signed or unsigned integer types, with
29696truncation towards zero.
29697
29698@item @samp{round}
29699Conversion from single-precision floating point to signed integer,
29700rounding to the nearest integer and ties away from zero.
29701This corresponds to the @code{__builtin_lroundf} function when
29702@option{-fno-math-errno} is used.
29703
29704@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
29705Conversion from signed or unsigned integer types to floating-point types.
29706
29707@end table
29708
29709In addition, all of the following transfer instructions for internal
29710registers X and Y must be provided to use any of the double-precision
29711floating-point instructions. Custom instructions taking two
29712double-precision source operands expect the first operand in the
2971364-bit register X. The other operand (or only operand of a unary
29714operation) is given to the custom arithmetic instruction with the
29715least significant half in source register @var{src1} and the most
29716significant half in @var{src2}. A custom instruction that returns a
29717double-precision result returns the most significant 32 bits in the
29718destination register and the other half in 32-bit register Y.
29719GCC automatically generates the necessary code sequences to write
29720register X and/or read register Y when double-precision floating-point
29721instructions are used.
29722
29723@table @asis
29724
29725@item @samp{fwrx}
29726Write @var{src1} into the least significant half of X and @var{src2} into
29727the most significant half of X.
29728
29729@item @samp{fwry}
29730Write @var{src1} into Y.
29731
29732@item @samp{frdxhi}, @samp{frdxlo}
29733Read the most or least (respectively) significant half of X and store it in
29734@var{dest}.
29735
29736@item @samp{frdy}
29737Read the value of Y and store it into @var{dest}.
29738@end table
29739
29740Note that you can gain more local control over generation of Nios II custom
29741instructions by using the @code{target("custom-@var{insn}=@var{N}")}
29742and @code{target("no-custom-@var{insn}")} function attributes
29743(@pxref{Function Attributes})
29744or pragmas (@pxref{Function Specific Option Pragmas}).
29745
d77de738 29746@opindex mcustom-fpu-cfg
ddf6fe37 29747@item -mcustom-fpu-cfg=@var{name}
d77de738
ML
29748
29749This option enables a predefined, named set of custom instruction encodings
29750(see @option{-mcustom-@var{insn}} above).
29751Currently, the following sets are defined:
29752
29753@option{-mcustom-fpu-cfg=60-1} is equivalent to:
43b72ede
AA
29754@gccoptlist{-mcustom-fmuls=252
29755-mcustom-fadds=253
29756-mcustom-fsubs=254
d77de738
ML
29757-fsingle-precision-constant}
29758
29759@option{-mcustom-fpu-cfg=60-2} is equivalent to:
43b72ede
AA
29760@gccoptlist{-mcustom-fmuls=252
29761-mcustom-fadds=253
29762-mcustom-fsubs=254
29763-mcustom-fdivs=255
d77de738
ML
29764-fsingle-precision-constant}
29765
29766@option{-mcustom-fpu-cfg=72-3} is equivalent to:
43b72ede
AA
29767@gccoptlist{-mcustom-floatus=243
29768-mcustom-fixsi=244
29769-mcustom-floatis=245
29770-mcustom-fcmpgts=246
29771-mcustom-fcmples=249
29772-mcustom-fcmpeqs=250
29773-mcustom-fcmpnes=251
29774-mcustom-fmuls=252
29775-mcustom-fadds=253
29776-mcustom-fsubs=254
29777-mcustom-fdivs=255
d77de738
ML
29778-fsingle-precision-constant}
29779
29780@option{-mcustom-fpu-cfg=fph2} is equivalent to:
43b72ede
AA
29781@gccoptlist{-mcustom-fabss=224
29782-mcustom-fnegs=225
29783-mcustom-fcmpnes=226
29784-mcustom-fcmpeqs=227
29785-mcustom-fcmpges=228
29786-mcustom-fcmpgts=229
29787-mcustom-fcmples=230
29788-mcustom-fcmplts=231
29789-mcustom-fmaxs=232
29790-mcustom-fmins=233
29791-mcustom-round=248
29792-mcustom-fixsi=249
29793-mcustom-floatis=250
29794-mcustom-fsqrts=251
29795-mcustom-fmuls=252
29796-mcustom-fadds=253
29797-mcustom-fsubs=254
29798-mcustom-fdivs=255}
d77de738
ML
29799
29800Custom instruction assignments given by individual
29801@option{-mcustom-@var{insn}=} options override those given by
29802@option{-mcustom-fpu-cfg=}, regardless of the
29803order of the options on the command line.
29804
29805Note that you can gain more local control over selection of a FPU
29806configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
29807function attribute (@pxref{Function Attributes})
29808or pragma (@pxref{Function Specific Option Pragmas}).
29809
29810The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
29811Hardware 2 Component}. Please note that the custom instructions enabled by
29812@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
29813if @option{-ffinite-math-only} is specified. The custom instruction enabled by
29814@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
29815specified. In contrast to the other configurations,
29816@option{-fsingle-precision-constant} is not set.
29817
29818@end table
29819
29820These additional @samp{-m} options are available for the Altera Nios II
29821ELF (bare-metal) target:
29822
29823@table @gcctabopt
29824
d77de738 29825@opindex mhal
ddf6fe37 29826@item -mhal
d77de738
ML
29827Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
29828startup and termination code, and is typically used in conjunction with
29829@option{-msys-crt0=} to specify the location of the alternate startup code
29830provided by the HAL BSP.
29831
d77de738 29832@opindex msmallc
ddf6fe37 29833@item -msmallc
d77de738
ML
29834Link with a limited version of the C library, @option{-lsmallc}, rather than
29835Newlib.
29836
d77de738 29837@opindex msys-crt0
ddf6fe37 29838@item -msys-crt0=@var{startfile}
d77de738
ML
29839@var{startfile} is the file name of the startfile (crt0) to use
29840when linking. This option is only useful in conjunction with @option{-mhal}.
29841
d77de738 29842@opindex msys-lib
ddf6fe37 29843@item -msys-lib=@var{systemlib}
d77de738
ML
29844@var{systemlib} is the library name of the library that provides
29845low-level system calls required by the C library,
29846e.g.@: @code{read} and @code{write}.
29847This option is typically used to link with a library provided by a HAL BSP.
29848
29849@end table
29850
29851@node Nvidia PTX Options
29852@subsection Nvidia PTX Options
29853@cindex Nvidia PTX options
29854@cindex nvptx options
29855
29856These options are defined for Nvidia PTX:
29857
29858@table @gcctabopt
29859
d77de738 29860@opindex m64
ddf6fe37 29861@item -m64
d77de738
ML
29862Ignored, but preserved for backward compatibility. Only 64-bit ABI is
29863supported.
29864
d77de738 29865@opindex march
ddf6fe37 29866@item -march=@var{architecture-string}
d77de738
ML
29867Generate code for the specified PTX ISA target architecture
29868(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
29869@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
29870@samp{sm_80}.
29871The default depends on how the compiler has been configured, see
29872@option{--with-arch}.
29873
29874This option sets the value of the preprocessor macro
29875@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
29876@samp{350}.
29877
d77de738 29878@opindex misa
ddf6fe37 29879@item -misa=@var{architecture-string}
d77de738
ML
29880Alias of @option{-march=}.
29881
d77de738 29882@opindex march
ddf6fe37 29883@item -march-map=@var{architecture-string}
d77de738
ML
29884Select the closest available @option{-march=} value that is not more
29885capable. For instance, for @option{-march-map=sm_50} select
29886@option{-march=sm_35}, and for @option{-march-map=sm_53} select
29887@option{-march=sm_53}.
29888
d77de738 29889@opindex mptx
ddf6fe37 29890@item -mptx=@var{version-string}
d77de738
ML
29891Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
29892Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
29893@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
29894version is required for specified PTX ISA target architecture via
29895option @option{-march=}.
29896
29897This option sets the values of the preprocessor macros
29898@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
29899for instance, for @samp{3.1} the macros have the values @samp{3} and
29900@samp{1}, respectively.
29901
d77de738 29902@opindex mmainkernel
ddf6fe37 29903@item -mmainkernel
d77de738
ML
29904Link in code for a __main kernel. This is for stand-alone instead of
29905offloading execution.
29906
d77de738 29907@opindex moptimize
ddf6fe37 29908@item -moptimize
d77de738
ML
29909Apply partitioned execution optimizations. This is the default when any
29910level of optimization is selected.
29911
d77de738 29912@opindex msoft-stack
ddf6fe37 29913@item -msoft-stack
d77de738
ML
29914Generate code that does not use @code{.local} memory
29915directly for stack storage. Instead, a per-warp stack pointer is
29916maintained explicitly. This enables variable-length stack allocation (with
29917variable-length arrays or @code{alloca}), and when global memory is used for
29918underlying storage, makes it possible to access automatic variables from other
29919threads, or with atomic instructions. This code generation variant is used
29920for OpenMP offloading, but the option is exposed on its own for the purpose
29921of testing the compiler; to generate code suitable for linking into programs
29922using OpenMP offloading, use option @option{-mgomp}.
29923
d77de738 29924@opindex muniform-simt
ddf6fe37 29925@item -muniform-simt
d77de738
ML
29926Switch to code generation variant that allows to execute all threads in each
29927warp, while maintaining memory state and side effects as if only one thread
29928in each warp was active outside of OpenMP SIMD regions. All atomic operations
29929and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
29930current lane index equals the master lane index), and the register being
29931assigned is copied via a shuffle instruction from the master lane. Outside of
29932SIMD regions lane 0 is the master; inside, each thread sees itself as the
29933master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
29934all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
29935regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
29936with current lane index to compute the master lane index.
29937
d77de738 29938@opindex mgomp
ddf6fe37 29939@item -mgomp
d77de738
ML
29940Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
29941@option{-muniform-simt} options, and selects corresponding multilib variant.
29942
29943@end table
29944
29945@node OpenRISC Options
29946@subsection OpenRISC Options
29947@cindex OpenRISC Options
29948
29949These options are defined for OpenRISC:
29950
29951@table @gcctabopt
29952
d77de738 29953@opindex mboard
ddf6fe37 29954@item -mboard=@var{name}
d77de738
ML
29955Configure a board specific runtime. This will be passed to the linker for
29956newlib board library linking. The default is @code{or1ksim}.
29957
d77de738 29958@opindex mnewlib
ddf6fe37 29959@item -mnewlib
d77de738
ML
29960This option is ignored; it is for compatibility purposes only. This used to
29961select linker and preprocessor options for use with newlib.
29962
d77de738
ML
29963@opindex msoft-div
29964@opindex mhard-div
ddf6fe37
AA
29965@item -msoft-div
29966@itemx -mhard-div
d77de738
ML
29967Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
29968This default is hardware divide.
29969
d77de738
ML
29970@opindex msoft-mul
29971@opindex mhard-mul
ddf6fe37
AA
29972@item -msoft-mul
29973@itemx -mhard-mul
d77de738
ML
29974Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
29975This default is hardware multiply.
29976
d77de738
ML
29977@opindex msoft-float
29978@opindex mhard-float
ddf6fe37
AA
29979@item -msoft-float
29980@itemx -mhard-float
d77de738
ML
29981Select software or hardware for floating point operations.
29982The default is software.
29983
d77de738 29984@opindex mdouble-float
ddf6fe37 29985@item -mdouble-float
d77de738
ML
29986When @option{-mhard-float} is selected, enables generation of double-precision
29987floating point instructions. By default functions from @file{libgcc} are used
29988to perform double-precision floating point operations.
29989
d77de738 29990@opindex munordered-float
ddf6fe37 29991@item -munordered-float
d77de738
ML
29992When @option{-mhard-float} is selected, enables generation of unordered
29993floating point compare and set flag (@code{lf.sfun*}) instructions. By default
29994functions from @file{libgcc} are used to perform unordered floating point
29995compare and set flag operations.
29996
d77de738 29997@opindex mcmov
ddf6fe37 29998@item -mcmov
d77de738
ML
29999Enable generation of conditional move (@code{l.cmov}) instructions. By
30000default the equivalent will be generated using set and branch.
30001
d77de738 30002@opindex mror
ddf6fe37 30003@item -mror
d77de738
ML
30004Enable generation of rotate right (@code{l.ror}) instructions. By default
30005functions from @file{libgcc} are used to perform rotate right operations.
30006
d77de738 30007@opindex mrori
ddf6fe37 30008@item -mrori
d77de738
ML
30009Enable generation of rotate right with immediate (@code{l.rori}) instructions.
30010By default functions from @file{libgcc} are used to perform rotate right with
30011immediate operations.
30012
d77de738 30013@opindex msext
ddf6fe37 30014@item -msext
d77de738
ML
30015Enable generation of sign extension (@code{l.ext*}) instructions. By default
30016memory loads are used to perform sign extension.
30017
d77de738 30018@opindex msfimm
ddf6fe37 30019@item -msfimm
d77de738
ML
30020Enable generation of compare and set flag with immediate (@code{l.sf*i})
30021instructions. By default extra instructions will be generated to store the
30022immediate to a register first.
30023
d77de738 30024@opindex mshftimm
ddf6fe37 30025@item -mshftimm
d77de738
ML
30026Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
30027@code{l.slli}) instructions. By default extra instructions will be generated
30028to store the immediate to a register first.
30029
d77de738 30030@opindex mcmodel=small
ddf6fe37 30031@item -mcmodel=small
d77de738
ML
30032Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
30033the default model.
30034
d77de738 30035@opindex mcmodel=large
ddf6fe37 30036@item -mcmodel=large
d77de738
ML
30037Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
30038
30039
30040@end table
30041
30042@node PDP-11 Options
30043@subsection PDP-11 Options
30044@cindex PDP-11 Options
30045
30046These options are defined for the PDP-11:
30047
30048@table @gcctabopt
d77de738 30049@opindex mfpu
ddf6fe37 30050@item -mfpu
d77de738
ML
30051Use hardware FPP floating point. This is the default. (FIS floating
30052point on the PDP-11/40 is not supported.) Implies -m45.
30053
d77de738 30054@opindex msoft-float
ddf6fe37 30055@item -msoft-float
d77de738
ML
30056Do not use hardware floating point.
30057
d77de738 30058@opindex mac0
ddf6fe37 30059@item -mac0
d77de738
ML
30060Return floating-point results in ac0 (fr0 in Unix assembler syntax).
30061
d77de738 30062@opindex mno-ac0
ddf6fe37 30063@item -mno-ac0
d77de738
ML
30064Return floating-point results in memory. This is the default.
30065
d77de738 30066@opindex m40
ddf6fe37 30067@item -m40
d77de738
ML
30068Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
30069
d77de738 30070@opindex m45
ddf6fe37 30071@item -m45
d77de738
ML
30072Generate code for a PDP-11/45. This is the default.
30073
d77de738 30074@opindex m10
ddf6fe37 30075@item -m10
d77de738
ML
30076Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
30077
d77de738
ML
30078@opindex mint16
30079@opindex mno-int32
ddf6fe37
AA
30080@item -mint16
30081@itemx -mno-int32
d77de738
ML
30082Use 16-bit @code{int}. This is the default.
30083
d77de738
ML
30084@opindex mint32
30085@opindex mno-int16
ddf6fe37
AA
30086@item -mint32
30087@itemx -mno-int16
d77de738
ML
30088Use 32-bit @code{int}.
30089
d77de738 30090@opindex msplit
ddf6fe37 30091@item -msplit
d77de738
ML
30092Target has split instruction and data space. Implies -m45.
30093
d77de738 30094@opindex munix-asm
ddf6fe37 30095@item -munix-asm
d77de738
ML
30096Use Unix assembler syntax.
30097
d77de738 30098@opindex mdec-asm
ddf6fe37 30099@item -mdec-asm
d77de738
ML
30100Use DEC assembler syntax.
30101
d77de738 30102@opindex mgnu-asm
ddf6fe37 30103@item -mgnu-asm
d77de738
ML
30104Use GNU assembler syntax. This is the default.
30105
d77de738 30106@opindex mlra
ddf6fe37 30107@item -mlra
d77de738
ML
30108Use the new LRA register allocator. By default, the old ``reload''
30109allocator is used.
30110@end table
30111
d77de738
ML
30112@node PowerPC Options
30113@subsection PowerPC Options
30114@cindex PowerPC options
30115
30116These are listed under @xref{RS/6000 and PowerPC Options}.
30117
30118@node PRU Options
30119@subsection PRU Options
30120@cindex PRU Options
30121
30122These command-line options are defined for PRU target:
30123
30124@table @gcctabopt
d77de738 30125@opindex minrt
ddf6fe37 30126@item -minrt
e3dfc150
DD
30127Link with a minimum runtime environment. This can significantly reduce
30128the size of the final ELF binary, but some standard C runtime features
30129are removed.
30130
30131This option disables support for static initializers and constructors.
30132Beware that the compiler could still generate code with static initializers
30133and constructors. It is up to the programmer to ensure that the source
30134program will not use those features.
30135
30136The minimal startup code would not pass @code{argc} and @code{argv} arguments
30137to @code{main}, so the latter must be declared as @code{int main (void)}.
30138This is already the norm for most firmware projects.
d77de738 30139
d77de738 30140@opindex mmcu
ddf6fe37 30141@item -mmcu=@var{mcu}
608d40fd
DD
30142Specify the PRU hardware variant to use. A correspondingly named
30143spec file would be loaded, passing the memory region sizes to
30144the linker and defining hardware-specific C macros.
30145
30146Newlib provides only the @code{sim} spec, intended for running
30147regression tests using a simulator. Specs for real hardware can be
30148obtained by installing the
30149@w{@uref{https://github.com/dinuxbg/gnuprumcu/,GnuPruMcu}} package.
d77de738 30150
d77de738 30151@opindex mno-relax
ddf6fe37 30152@item -mno-relax
d77de738
ML
30153Make GCC pass the @option{--no-relax} command-line option to the linker
30154instead of the @option{--relax} option.
30155
d77de738 30156@opindex mloop
ddf6fe37 30157@item -mloop
d77de738
ML
30158Allow (or do not allow) GCC to use the LOOP instruction.
30159
d77de738 30160@opindex mabi
ddf6fe37 30161@item -mabi=@var{variant}
d77de738
ML
30162Specify the ABI variant to output code for. @option{-mabi=ti} selects the
30163unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
30164more naturally with certain GCC assumptions. These are the differences:
30165
30166@table @samp
30167@item Function Pointer Size
30168TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
30169supports only 32-bit data and code pointers.
30170
30171@item Optional Return Value Pointer
30172Function return values larger than 64 bits are passed by using a hidden
30173pointer as the first argument of the function. TI ABI, though, mandates that
30174the pointer can be NULL in case the caller is not using the returned value.
30175GNU always passes and expects a valid return value pointer.
30176
30177@end table
30178
30179The current @option{-mabi=ti} implementation simply raises a compile error
30180when any of the above code constructs is detected. As a consequence
30181the standard C library cannot be built and it is omitted when linking with
30182@option{-mabi=ti}.
30183
30184Relaxation is a GNU feature and for safety reasons is disabled when using
30185@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
30186instructions, so the GNU linker cannot adjust them when shortening adjacent
30187LDI32 pseudo instructions.
30188
30189@end table
30190
30191@node RISC-V Options
30192@subsection RISC-V Options
30193@cindex RISC-V Options
30194
30195These command-line options are defined for RISC-V targets:
30196
30197@table @gcctabopt
d77de738 30198@opindex mbranch-cost
ddf6fe37 30199@item -mbranch-cost=@var{n}
d77de738
ML
30200Set the cost of branches to roughly @var{n} instructions.
30201
ddf6fe37 30202@opindex plt
d77de738
ML
30203@item -mplt
30204@itemx -mno-plt
d77de738
ML
30205When generating PIC code, do or don't allow the use of PLTs. Ignored for
30206non-PIC. The default is @option{-mplt}.
30207
d77de738 30208@opindex mabi
ddf6fe37 30209@item -mabi=@var{ABI-string}
d77de738
ML
30210Specify integer and floating-point calling convention. @var{ABI-string}
30211contains two parts: the size of integer types and the registers used for
30212floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
30213@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
3021432-bit), and that floating-point values up to 64 bits wide are passed in F
30215registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
30216allows the compiler to generate code that uses the F and D extensions but only
30217allows floating-point values up to 32 bits long to be passed in registers; or
30218@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
30219passed in registers.
30220
30221The default for this argument is system dependent, users who want a specific
30222calling convention should specify one explicitly. The valid calling
30223conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
30224@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
30225implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
30226invalid because the ABI requires 64-bit values be passed in F registers, but F
006e90e1
TO
30227registers are only 32 bits wide. There are also the @samp{ilp32e} ABI that can
30228only be used with the @samp{rv32e} architecture and the @samp{lp64e} ABI that
30229can only be used with the @samp{rv64e}. Those ABIs are not well specified at
30230present, and are subject to change.
d77de738 30231
ddf6fe37 30232@opindex mfdiv
d77de738
ML
30233@item -mfdiv
30234@itemx -mno-fdiv
d77de738
ML
30235Do or don't use hardware floating-point divide and square root instructions.
30236This requires the F or D extensions for floating-point registers. The default
30237is to use them if the specified architecture has these instructions.
30238
ddf6fe37 30239@opindex mdiv
d77de738
ML
30240@item -mdiv
30241@itemx -mno-div
d77de738
ML
30242Do or don't use hardware instructions for integer division. This requires the
30243M extension. The default is to use them if the specified architecture has
30244these instructions.
30245
d77de738 30246@opindex misa-spec
ddf6fe37 30247@item -misa-spec=@var{ISA-spec-string}
d77de738
ML
30248Specify the version of the RISC-V Unprivileged (formerly User-Level)
30249ISA specification to produce code conforming to. The possibilities
30250for @var{ISA-spec-string} are:
30251@table @code
30252@item 2.2
30253Produce code conforming to version 2.2.
30254@item 20190608
30255Produce code conforming to version 20190608.
30256@item 20191213
30257Produce code conforming to version 20191213.
30258@end table
30259The default is @option{-misa-spec=20191213} unless GCC has been configured
30260with @option{--with-isa-spec=} specifying a different default version.
30261
d77de738 30262@opindex march
ddf6fe37 30263@item -march=@var{ISA-string}
d77de738
ML
30264Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
30265lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
7af0f1e1
KC
30266@samp{rv32imaf}. Additionally, a special value @option{help}
30267(@option{-march=help}) is accepted to list all supported extensions.
d77de738 30268
5a22bb25
KC
30269The syntax of the ISA string is defined as follows:
30270
30271@table @code
30272@item The string must start with @samp{rv32} or @samp{rv64}, followed by
30273@samp{i}, @samp{e}, or @samp{g}, referred to as the base ISA.
30274@item The subsequent part of the string is a list of extension names. Extension
30275names can be categorized as multi-letter (e.g.@: @samp{zba}) and single-letter
30276(e.g.@: @samp{v}). Single-letter extensions can appear consecutively,
30277but multi-letter extensions must be separated by underscores.
30278@item An underscore can appear anywhere after the base ISA. It has no specific
30279effect but is used to improve readability and can act as a separator.
30280@item Extension names may include an optional version number, following the
30281syntax @samp{<major>p<minor>} or @samp{<major>}, (e.g.@: @samp{m2p1} or
30282@samp{m2}).
30283@end table
30284
19260a04
KC
30285Supported extension are listed below:
30286@multitable @columnfractions .10 .10 .80
30287@headitem Extension Name @tab Supported Version @tab Description
30288@item i
30289@tab 2.0, 2.1
30290@tab Base integer extension.
30291
30292@item e
30293@tab 2.0
30294@tab Reduced base integer extension.
30295
30296@item g
30297@tab -
30298@tab General-purpose computing base extension, @samp{g} will expand to
30299@samp{i}, @samp{m}, @samp{a}, @samp{f}, @samp{d}, @samp{zicsr} and
30300@samp{zifencei}.
30301
30302@item m
30303@tab 2.0
30304@tab Integer multiplication and division extension.
30305
30306@item a
30307@tab 2.0, 2.1
30308@tab Atomic extension.
30309
30310@item f
30311@tab 2.0, 2.2
30312@tab Single-precision floating-point extension.
30313
30314@item d
30315@tab 2.0, 2.2
30316@tab Double-precision floating-point extension.
30317
30318@item c
30319@tab 2.0
30320@tab Compressed extension.
30321
30322@item h
30323@tab 1.0
30324@tab Hypervisor extension.
30325
30326@item v
30327@tab 1.0
30328@tab Vector extension.
30329
30330@item zicsr
30331@tab 2.0
30332@tab Control and status register access extension.
30333
30334@item zifencei
30335@tab 2.0
30336@tab Instruction-fetch fence extension.
30337
30338@item zicond
30339@tab 1.0
30340@tab Integer conditional operations extension.
30341
5c18df44
MC
30342@item za64rs
30343@tab 1.0
30344@tab Reservation set size of 64 bytes.
30345
30346@item za128rs
30347@tab 1.0
30348@tab Reservation set size of 128 bytes.
30349
19260a04
KC
30350@item zawrs
30351@tab 1.0
30352@tab Wait-on-reservation-set extension.
30353
30354@item zba
30355@tab 1.0
30356@tab Address calculation extension.
30357
30358@item zbb
30359@tab 1.0
30360@tab Basic bit manipulation extension.
30361
30362@item zbc
30363@tab 1.0
30364@tab Carry-less multiplication extension.
30365
30366@item zbs
30367@tab 1.0
30368@tab Single-bit operation extension.
30369
30370@item zfinx
30371@tab 1.0
30372@tab Single-precision floating-point in integer registers extension.
30373
30374@item zdinx
30375@tab 1.0
30376@tab Double-precision floating-point in integer registers extension.
30377
30378@item zhinx
30379@tab 1.0
30380@tab Half-precision floating-point in integer registers extension.
30381
30382@item zhinxmin
30383@tab 1.0
30384@tab Minimal half-precision floating-point in integer registers extension.
30385
30386@item zbkb
30387@tab 1.0
30388@tab Cryptography bit-manipulation extension.
30389
30390@item zbkc
30391@tab 1.0
30392@tab Cryptography carry-less multiply extension.
30393
30394@item zbkx
30395@tab 1.0
30396@tab Cryptography crossbar permutation extension.
30397
30398@item zkne
30399@tab 1.0
30400@tab AES Encryption extension.
30401
30402@item zknd
30403@tab 1.0
30404@tab AES Decryption extension.
30405
30406@item zknh
30407@tab 1.0
30408@tab Hash function extension.
30409
30410@item zkr
30411@tab 1.0
30412@tab Entropy source extension.
30413
30414@item zksed
30415@tab 1.0
30416@tab SM4 block cipher extension.
30417
30418@item zksh
30419@tab 1.0
30420@tab SM3 hash function extension.
30421
30422@item zkt
30423@tab 1.0
30424@tab Data independent execution latency extension.
30425
30426@item zk
30427@tab 1.0
30428@tab Standard scalar cryptography extension.
30429
30430@item zkn
30431@tab 1.0
30432@tab NIST algorithm suite extension.
30433
30434@item zks
30435@tab 1.0
30436@tab ShangMi algorithm suite extension.
30437
30438@item zihintntl
30439@tab 1.0
30440@tab Non-temporal locality hints extension.
30441
30442@item zihintpause
30443@tab 1.0
30444@tab Pause hint extension.
30445
30446@item zicboz
30447@tab 1.0
30448@tab Cache-block zero extension.
30449
30450@item zicbom
30451@tab 1.0
30452@tab Cache-block management extension.
30453
30454@item zicbop
30455@tab 1.0
30456@tab Cache-block prefetch extension.
30457
5c18df44
MC
30458@item zic64b
30459@tab 1.0
30460@tab Cache block size isf 64 bytes.
30461
30462@item ziccamoa
30463@tab 1.0
30464@tab Main memory supports all atomics in A.
30465
30466@item ziccif
30467@tab 1.0
30468@tab Main memory supports instruction fetch with atomicity requirement.
30469
30470@item zicclsm
30471@tab 1.0
30472@tab Main memory supports misaligned loads/stores.
30473
30474@item ziccrse
30475@tab 1.0
30476@tab Main memory supports forward progress on LR/SC sequences.
30477
19260a04
KC
30478@item zicntr
30479@tab 2.0
30480@tab Standard extension for base counters and timers.
30481
30482@item zihpm
30483@tab 2.0
30484@tab Standard extension for hardware performance counters.
30485
30486@item ztso
30487@tab 1.0
30488@tab Total store ordering extension.
30489
30490@item zve32x
30491@tab 1.0
30492@tab Vector extensions for embedded processors.
30493
30494@item zve32f
30495@tab 1.0
30496@tab Vector extensions for embedded processors.
30497
30498@item zve64x
30499@tab 1.0
30500@tab Vector extensions for embedded processors.
30501
30502@item zve64f
30503@tab 1.0
30504@tab Vector extensions for embedded processors.
30505
30506@item zve64d
30507@tab 1.0
30508@tab Vector extensions for embedded processors.
30509
30510@item zvl32b
30511@tab 1.0
30512@tab Minimum vector length standard extensions
30513
30514@item zvl64b
30515@tab 1.0
30516@tab Minimum vector length standard extensions
30517
30518@item zvl128b
30519@tab 1.0
30520@tab Minimum vector length standard extensions
30521
30522@item zvl256b
30523@tab 1.0
30524@tab Minimum vector length standard extensions
30525
30526@item zvl512b
30527@tab 1.0
30528@tab Minimum vector length standard extensions
30529
30530@item zvl1024b
30531@tab 1.0
30532@tab Minimum vector length standard extensions
30533
30534@item zvl2048b
30535@tab 1.0
30536@tab Minimum vector length standard extensions
30537
30538@item zvl4096b
30539@tab 1.0
30540@tab Minimum vector length standard extensions
30541
30542@item zvbb
30543@tab 1.0
30544@tab Vector basic bit-manipulation extension.
30545
30546@item zvbc
30547@tab 1.0
30548@tab Vector carryless multiplication extension.
30549
30550@item zvkb
30551@tab 1.0
30552@tab Vector cryptography bit-manipulation extension.
30553
30554@item zvkg
30555@tab 1.0
30556@tab Vector GCM/GMAC extension.
30557
30558@item zvkned
30559@tab 1.0
30560@tab Vector AES block cipher extension.
30561
30562@item zvknha
30563@tab 1.0
30564@tab Vector SHA-2 secure hash extension.
30565
30566@item zvknhb
30567@tab 1.0
30568@tab Vector SHA-2 secure hash extension.
30569
30570@item zvksed
30571@tab 1.0
30572@tab Vector SM4 Block Cipher extension.
30573
30574@item zvksh
30575@tab 1.0
30576@tab Vector SM3 Secure Hash extension.
30577
30578@item zvkn
30579@tab 1.0
30580@tab Vector NIST Algorithm Suite extension, @samp{zvkn} will expand to
30581@samp{zvkned}, @samp{zvknhb}, @samp{zvkb} and @samp{zvkt}.
30582
30583@item zvknc
30584@tab 1.0
30585@tab Vector NIST Algorithm Suite with carryless multiply extension, @samp{zvknc}
30586will expand to @samp{zvkn} and @samp{zvbc}.
30587
30588@item zvkng
30589@tab 1.0
30590@tab Vector NIST Algorithm Suite with GCM extension, @samp{zvkng} will expand
30591to @samp{zvkn} and @samp{zvkg}.
30592
30593@item zvks
30594@tab 1.0
30595@tab Vector ShangMi algorithm suite extension, @samp{zvks} will expand
30596to @samp{zvksed}, @samp{zvksh}, @samp{zvkb} and @samp{zvkt}.
30597
30598@item zvksc
30599@tab 1.0
30600@tab Vector ShangMi algorithm suite with carryless multiplication extension,
30601@samp{zvksc} will expand to @samp{zvks} and @samp{zvbc}.
30602
30603@item zvksg
30604@tab 1.0
30605@tab Vector ShangMi algorithm suite with GCM extension, @samp{zvksg} will expand
30606to @samp{zvks} and @samp{zvkg}.
30607
30608@item zvkt
30609@tab 1.0
30610@tab Vector data independent execution latency extension.
30611
30612@item zfh
30613@tab 1.0
30614@tab Half-precision floating-point extension.
30615
30616@item zfhmin
30617@tab 1.0
30618@tab Minimal half-precision floating-point extension.
30619
30620@item zvfh
30621@tab 1.0
30622@tab Vector half-precision floating-point extension.
30623
30624@item zvfhmin
30625@tab 1.0
30626@tab Vector minimal half-precision floating-point extension.
30627
30628@item zvfbfmin
30629@tab 1.0
30630@tab Vector BF16 converts extension.
30631
30632@item zfa
30633@tab 1.0
30634@tab Additional floating-point extension.
30635
30636@item zmmul
30637@tab 1.0
30638@tab Integer multiplication extension.
30639
30640@item zca
30641@tab 1.0
30642@tab Integer compressed instruction extension.
30643
30644@item zcf
30645@tab 1.0
30646@tab Compressed single-precision floating point loads and stores extension.
30647
30648@item zcd
30649@tab 1.0
30650@tab Compressed double-precision floating point loads and stores extension.
30651
30652@item zcb
30653@tab 1.0
30654@tab Simple compressed instruction extension.
30655
30656@item zce
30657@tab 1.0
30658@tab Compressed instruction extensions for embedded processors.
30659
30660@item zcmp
30661@tab 1.0
30662@tab Compressed push pop extension.
30663
30664@item zcmt
30665@tab 1.0
30666@tab Table jump instruction extension.
30667
30668@item smaia
30669@tab 1.0
30670@tab Advanced interrupt architecture extension.
30671
30672@item smepmp
30673@tab 1.0
30674@tab PMP Enhancements for memory access and execution prevention on Machine mode.
30675
30676@item smstateen
30677@tab 1.0
30678@tab State enable extension.
30679
30680@item ssaia
30681@tab 1.0
30682@tab Advanced interrupt architecture extension for supervisor-mode.
30683
30684@item sscofpmf
30685@tab 1.0
30686@tab Count overflow & filtering extension.
30687
30688@item ssstateen
30689@tab 1.0
30690@tab State-enable extension for supervisor-mode.
30691
30692@item sstc
30693@tab 1.0
30694@tab Supervisor-mode timer interrupts extension.
30695
30696@item svinval
30697@tab 1.0
30698@tab Fine-grained address-translation cache invalidation extension.
30699
30700@item svnapot
30701@tab 1.0
30702@tab NAPOT translation contiguity extension.
30703
30704@item svpbmt
30705@tab 1.0
30706@tab Page-based memory types extension.
30707
30708@item xcvmac
30709@tab 1.0
30710@tab Core-V multiply-accumulate extension.
30711
30712@item xcvalu
30713@tab 1.0
30714@tab Core-V miscellaneous ALU extension.
30715
30716@item xcvelw
30717@tab 1.0
30718@tab Core-V event load word extension.
30719
30720@item xtheadba
30721@tab 1.0
30722@tab T-head address calculation extension.
30723
30724@item xtheadbb
30725@tab 1.0
30726@tab T-head basic bit-manipulation extension.
30727
30728@item xtheadbs
30729@tab 1.0
30730@tab T-head single-bit instructions extension.
30731
30732@item xtheadcmo
30733@tab 1.0
30734@tab T-head cache management operations extension.
30735
30736@item xtheadcondmov
30737@tab 1.0
30738@tab T-head conditional move extension.
30739
30740@item xtheadfmemidx
30741@tab 1.0
30742@tab T-head indexed memory operations for floating-point registers extension.
30743
30744@item xtheadfmv
30745@tab 1.0
30746@tab T-head double floating-point high-bit data transmission extension.
30747
30748@item xtheadint
30749@tab 1.0
30750@tab T-head acceleration interruption extension.
30751
30752@item xtheadmac
30753@tab 1.0
30754@tab T-head multiply-accumulate extension.
30755
30756@item xtheadmemidx
30757@tab 1.0
30758@tab T-head indexed memory operation extension.
30759
30760@item xtheadmempair
30761@tab 1.0
30762@tab T-head two-GPR memory operation extension.
30763
30764@item xtheadsync
30765@tab 1.0
30766@tab T-head multi-core synchronization extension.
30767
30768@item xventanacondops
30769@tab 1.0
30770@tab Ventana integer conditional operations extension.
30771
30772@end multitable
30773
d77de738
ML
30774When @option{-march=} is not specified, use the setting from @option{-mcpu}.
30775
30776If both @option{-march} and @option{-mcpu=} are not specified, the default for
30777this argument is system dependent, users who want a specific architecture
30778extensions should specify one explicitly.
30779
d77de738 30780@opindex mcpu
ddf6fe37 30781@item -mcpu=@var{processor-string}
d77de738
ML
30782Use architecture of and optimize the output for the given processor, specified
30783by particular CPU name.
30784Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
30785@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
30786@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
91e09b3a
MC
30787@samp{sifive-u54}, @samp{sifive-u74}, @samp{sifive-x280}, @samp{sifive-xp450},
30788@samp{sifive-x670}.
d77de738 30789
1c5da882
PD
30790Note that @option{-mcpu} does not override @option{-march} or @option{-mtune}.
30791
d77de738 30792@opindex mtune
ddf6fe37 30793@item -mtune=@var{processor-string}
d77de738
ML
30794Optimize the output for the given processor, specified by microarchitecture or
30795particular CPU name. Permissible values for this option are: @samp{rocket},
30796@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
7c190f93
MC
30797@samp{thead-c906}, @samp{size}, @samp{sifive-p400-series},
30798@samp{sifive-p600-series}, and all valid options for @option{-mcpu=}.
d77de738
ML
30799
30800When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
30801the default is @samp{rocket} if both are not specified.
30802
30803The @samp{size} choice is not intended for use by end-users. This is used
30804when @option{-Os} is specified. It overrides the instruction cost info
30805provided by @option{-mtune=}, but does not override the pipeline info. This
30806helps reduce code size while still giving good performance.
30807
d77de738 30808@opindex mpreferred-stack-boundary
ddf6fe37 30809@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
30810Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
30811byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
30812the default is 4 (16 bytes or 128-bits).
30813
30814@strong{Warning:} If you use this switch, then you must build all modules with
30815the same value, including any libraries. This includes the system libraries
30816and startup modules.
30817
d77de738 30818@opindex msmall-data-limit
ddf6fe37 30819@item -msmall-data-limit=@var{n}
d77de738
ML
30820Put global and static data smaller than @var{n} bytes into a special section
30821(on some targets).
30822
ddf6fe37 30823@opindex msave-restore
d77de738
ML
30824@item -msave-restore
30825@itemx -mno-save-restore
d77de738
ML
30826Do or don't use smaller but slower prologue and epilogue code that uses
30827library function calls. The default is to use fast inline prologues and
30828epilogues.
30829
dc95b338
MR
30830@opindex mmovcc
30831@item -mmovcc
30832@itemx -mno-movcc
30833Do or don't produce branchless conditional-move code sequences even with
30834targets that do not have specific instructions for conditional operations.
30835If enabled, sequences of ALU operations are produced using base integer
30836ISA instructions where profitable.
30837
f797260a
PN
30838@opindex minline-atomics
30839@item -minline-atomics
30840@itemx -mno-inline-atomics
30841Do or don't use smaller but slower subword atomic emulation code that uses
30842libatomic function calls. The default is to use fast inline subword atomics
30843that do not require libatomic.
30844
df48285b
CM
30845@opindex minline-strlen
30846@item -minline-strlen
30847@itemx -mno-inline-strlen
30848Do or do not attempt to inline strlen calls if possible.
30849Inlining will only be done if the string is properly aligned
30850and instructions for accelerated processing are available.
30851The default is to not inline strlen calls.
30852
949f1ccf
CM
30853@opindex minline-strcmp
30854@item -minline-strcmp
30855@itemx -mno-inline-strcmp
30856Do or do not attempt to inline strcmp calls if possible.
30857Inlining will only be done if the strings are properly aligned
30858and instructions for accelerated processing are available.
30859The default is to not inline strcmp calls.
30860
82576a6e
CM
30861The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls
30862the maximum number of bytes compared by the inlined code.
30863The default value is 64.
30864
949f1ccf
CM
30865@opindex minline-strncmp
30866@item -minline-strncmp
30867@itemx -mno-inline-strncmp
30868Do or do not attempt to inline strncmp calls if possible.
30869Inlining will only be done if the strings are properly aligned
30870and instructions for accelerated processing are available.
30871The default is to not inline strncmp calls.
30872
82576a6e
CM
30873The @option{--param riscv-strcmp-inline-limit=@var{n}} parameter controls
30874the maximum number of bytes compared by the inlined code.
30875The default value is 64.
30876
ddf6fe37 30877@opindex mshorten-memrefs
d77de738
ML
30878@item -mshorten-memrefs
30879@itemx -mno-shorten-memrefs
d77de738
ML
30880Do or do not attempt to make more use of compressed load/store instructions by
30881replacing a load/store of 'base register + large offset' with a new load/store
30882of 'new base + small offset'. If the new base gets stored in a compressed
30883register, then the new load/store can be compressed. Currently targets 32-bit
30884integer load/stores only.
30885
ddf6fe37 30886@opindex mstrict-align
d77de738
ML
30887@item -mstrict-align
30888@itemx -mno-strict-align
d77de738
ML
30889Do not or do generate unaligned memory accesses. The default is set depending
30890on whether the processor we are optimizing for supports fast unaligned access
30891or not.
30892
d77de738 30893@opindex mcmodel=medlow
ddf6fe37 30894@item -mcmodel=medlow
d77de738
ML
30895Generate code for the medium-low code model. The program and its statically
30896defined symbols must lie within a single 2 GiB address range and must lie
30897between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
30898statically or dynamically linked. This is the default code model.
30899
d77de738 30900@opindex mcmodel=medany
ddf6fe37 30901@item -mcmodel=medany
d77de738
ML
30902Generate code for the medium-any code model. The program and its statically
30903defined symbols must be within any single 2 GiB address range. Programs can be
30904statically or dynamically linked.
30905
30906The code generated by the medium-any code model is position-independent, but is
30907not guaranteed to function correctly when linked into position-independent
30908executables or libraries.
30909
30910@item -mexplicit-relocs
30911@itemx -mno-exlicit-relocs
30912Use or do not use assembler relocation operators when dealing with symbolic
30913addresses. The alternative is to use assembler macros instead, which may
30914limit optimization.
30915
ddf6fe37 30916@opindex mrelax
d77de738
ML
30917@item -mrelax
30918@itemx -mno-relax
d77de738
ML
30919Take advantage of linker relaxations to reduce the number of instructions
30920required to materialize symbol addresses. The default is to take advantage of
30921linker relaxations.
30922
ddf6fe37 30923@opindex mriscv-attribute
d77de738
ML
30924@item -mriscv-attribute
30925@itemx -mno-riscv-attribute
d77de738
ML
30926Emit (do not emit) RISC-V attribute to record extra information into ELF
30927objects. This feature requires at least binutils 2.32.
30928
ddf6fe37 30929@opindex mcsr-check
d77de738
ML
30930@item -mcsr-check
30931@itemx -mno-csr-check
d77de738
ML
30932Enables or disables the CSR checking.
30933
d77de738 30934@opindex malign-data
ddf6fe37 30935@item -malign-data=@var{type}
d77de738
ML
30936Control how GCC aligns variables and constants of array, structure, or union
30937types. Supported values for @var{type} are @samp{xlen} which uses x register
30938width as the alignment value, and @samp{natural} which uses natural alignment.
30939@samp{xlen} is the default.
30940
d77de738 30941@opindex mbig-endian
ddf6fe37 30942@item -mbig-endian
d77de738
ML
30943Generate big-endian code. This is the default when GCC is configured for a
30944@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
30945
d77de738 30946@opindex mlittle-endian
ddf6fe37 30947@item -mlittle-endian
d77de738
ML
30948Generate little-endian code. This is the default when GCC is configured for a
30949@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
30950@samp{riscv32be-*-*} target.
30951
d77de738
ML
30952@opindex mstack-protector-guard
30953@opindex mstack-protector-guard-reg
30954@opindex mstack-protector-guard-offset
ddf6fe37
AA
30955@item -mstack-protector-guard=@var{guard}
30956@itemx -mstack-protector-guard-reg=@var{reg}
30957@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
30958Generate stack protection code using canary at @var{guard}. Supported
30959locations are @samp{global} for a global canary or @samp{tls} for per-thread
30960canary in the TLS block.
30961
30962With the latter choice the options
30963@option{-mstack-protector-guard-reg=@var{reg}} and
30964@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30965which register to use as base register for reading the canary,
30966and from what offset from that base register. There is no default
30967register or offset as this is entirely for use within the Linux
30968kernel.
30969@end table
30970
30971@node RL78 Options
30972@subsection RL78 Options
30973@cindex RL78 Options
30974
30975@table @gcctabopt
30976
d77de738 30977@opindex msim
ddf6fe37 30978@item -msim
d77de738
ML
30979Links in additional target libraries to support operation within a
30980simulator.
30981
ddf6fe37 30982@opindex mmul
d77de738
ML
30983@item -mmul=none
30984@itemx -mmul=g10
30985@itemx -mmul=g13
30986@itemx -mmul=g14
30987@itemx -mmul=rl78
d77de738
ML
30988Specifies the type of hardware multiplication and division support to
30989be used. The simplest is @code{none}, which uses software for both
30990multiplication and division. This is the default. The @code{g13}
30991value is for the hardware multiply/divide peripheral found on the
30992RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
30993the multiplication and division instructions supported by the RL78/G14
30994(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
30995the value @code{mg10} is an alias for @code{none}.
30996
30997In addition a C preprocessor macro is defined, based upon the setting
30998of this option. Possible values are: @code{__RL78_MUL_NONE__},
30999@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
31000
ddf6fe37 31001@opindex mcpu
d77de738
ML
31002@item -mcpu=g10
31003@itemx -mcpu=g13
31004@itemx -mcpu=g14
31005@itemx -mcpu=rl78
d77de738
ML
31006Specifies the RL78 core to target. The default is the G14 core, also
31007known as an S3 core or just RL78. The G13 or S2 core does not have
31008multiply or divide instructions, instead it uses a hardware peripheral
31009for these operations. The G10 or S1 core does not have register
31010banks, so it uses a different calling convention.
31011
31012If this option is set it also selects the type of hardware multiply
31013support to use, unless this is overridden by an explicit
31014@option{-mmul=none} option on the command line. Thus specifying
31015@option{-mcpu=g13} enables the use of the G13 hardware multiply
31016peripheral and specifying @option{-mcpu=g10} disables the use of
31017hardware multiplications altogether.
31018
31019Note, although the RL78/G14 core is the default target, specifying
31020@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
31021change the behavior of the toolchain since it also enables G14
31022hardware multiply support. If these options are not specified on the
31023command line then software multiplication routines will be used even
31024though the code targets the RL78 core. This is for backwards
31025compatibility with older toolchains which did not have hardware
31026multiply and divide support.
31027
31028In addition a C preprocessor macro is defined, based upon the setting
31029of this option. Possible values are: @code{__RL78_G10__},
31030@code{__RL78_G13__} or @code{__RL78_G14__}.
31031
d77de738
ML
31032@opindex mg10
31033@opindex mg13
31034@opindex mg14
31035@opindex mrl78
ddf6fe37
AA
31036@item -mg10
31037@itemx -mg13
31038@itemx -mg14
31039@itemx -mrl78
d77de738
ML
31040These are aliases for the corresponding @option{-mcpu=} option. They
31041are provided for backwards compatibility.
31042
d77de738 31043@opindex mallregs
ddf6fe37 31044@item -mallregs
d77de738
ML
31045Allow the compiler to use all of the available registers. By default
31046registers @code{r24..r31} are reserved for use in interrupt handlers.
31047With this option enabled these registers can be used in ordinary
31048functions as well.
31049
d77de738
ML
31050@opindex m64bit-doubles
31051@opindex m32bit-doubles
ddf6fe37
AA
31052@item -m64bit-doubles
31053@itemx -m32bit-doubles
d77de738
ML
31054Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
31055or 32 bits (@option{-m32bit-doubles}) in size. The default is
31056@option{-m32bit-doubles}.
31057
d77de738
ML
31058@opindex msave-mduc-in-interrupts
31059@opindex mno-save-mduc-in-interrupts
ddf6fe37
AA
31060@item -msave-mduc-in-interrupts
31061@itemx -mno-save-mduc-in-interrupts
d77de738
ML
31062Specifies that interrupt handler functions should preserve the
31063MDUC registers. This is only necessary if normal code might use
31064the MDUC registers, for example because it performs multiplication
31065and division operations. The default is to ignore the MDUC registers
31066as this makes the interrupt handlers faster. The target option -mg13
31067needs to be passed for this to work as this feature is only available
31068on the G13 target (S2 core). The MDUC registers will only be saved
31069if the interrupt handler performs a multiplication or division
31070operation or it calls another function.
31071
31072@end table
31073
31074@node RS/6000 and PowerPC Options
31075@subsection IBM RS/6000 and PowerPC Options
31076@cindex RS/6000 and PowerPC Options
31077@cindex IBM RS/6000 and PowerPC Options
31078
31079These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
31080@table @gcctabopt
31081@item -mpowerpc-gpopt
31082@itemx -mno-powerpc-gpopt
31083@itemx -mpowerpc-gfxopt
31084@itemx -mno-powerpc-gfxopt
31085@need 800
31086@itemx -mpowerpc64
31087@itemx -mno-powerpc64
31088@itemx -mmfcrf
31089@itemx -mno-mfcrf
31090@itemx -mpopcntb
31091@itemx -mno-popcntb
31092@itemx -mpopcntd
31093@itemx -mno-popcntd
31094@itemx -mfprnd
31095@itemx -mno-fprnd
31096@need 800
d77de738
ML
31097@opindex mpowerpc-gpopt
31098@opindex mno-powerpc-gpopt
31099@opindex mpowerpc-gfxopt
31100@opindex mno-powerpc-gfxopt
31101@opindex mpowerpc64
31102@opindex mno-powerpc64
31103@opindex mmfcrf
31104@opindex mno-mfcrf
31105@opindex mpopcntb
31106@opindex mno-popcntb
31107@opindex mpopcntd
31108@opindex mno-popcntd
31109@opindex mfprnd
31110@opindex mno-fprnd
31111@opindex mcmpb
31112@opindex mno-cmpb
31113@opindex mhard-dfp
31114@opindex mno-hard-dfp
ddf6fe37
AA
31115@itemx -mcmpb
31116@itemx -mno-cmpb
31117@itemx -mhard-dfp
31118@itemx -mno-hard-dfp
d77de738
ML
31119You use these options to specify which instructions are available on the
31120processor you are using. The default value of these options is
31121determined when configuring GCC@. Specifying the
31122@option{-mcpu=@var{cpu_type}} overrides the specification of these
31123options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
31124rather than the options listed above.
31125
31126Specifying @option{-mpowerpc-gpopt} allows
31127GCC to use the optional PowerPC architecture instructions in the
31128General Purpose group, including floating-point square root. Specifying
31129@option{-mpowerpc-gfxopt} allows GCC to
31130use the optional PowerPC architecture instructions in the Graphics
31131group, including floating-point select.
31132
31133The @option{-mmfcrf} option allows GCC to generate the move from
31134condition register field instruction implemented on the POWER4
31135processor and other processors that support the PowerPC V2.01
31136architecture.
31137The @option{-mpopcntb} option allows GCC to generate the popcount and
31138double-precision FP reciprocal estimate instruction implemented on the
31139POWER5 processor and other processors that support the PowerPC V2.02
31140architecture.
31141The @option{-mpopcntd} option allows GCC to generate the popcount
31142instruction implemented on the POWER7 processor and other processors
31143that support the PowerPC V2.06 architecture.
31144The @option{-mfprnd} option allows GCC to generate the FP round to
31145integer instructions implemented on the POWER5+ processor and other
31146processors that support the PowerPC V2.03 architecture.
31147The @option{-mcmpb} option allows GCC to generate the compare bytes
31148instruction implemented on the POWER6 processor and other processors
31149that support the PowerPC V2.05 architecture.
31150The @option{-mhard-dfp} option allows GCC to generate the decimal
31151floating-point instructions implemented on some POWER processors.
31152
31153The @option{-mpowerpc64} option allows GCC to generate the additional
3115464-bit instructions that are found in the full PowerPC64 architecture
31155and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
31156@option{-mno-powerpc64}.
31157
d77de738 31158@opindex mcpu
ddf6fe37 31159@item -mcpu=@var{cpu_type}
d77de738
ML
31160Set architecture type, register usage, and
31161instruction scheduling parameters for machine type @var{cpu_type}.
31162Supported values for @var{cpu_type} are @samp{401}, @samp{403},
31163@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
31164@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
31165@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
31166@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
31167@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
31168@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
31169@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
31170@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
31171@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
dc0f9a74
MM
31172@samp{power9}, @samp{power10}, @samp{power11},
31173@samp{powerpc}, @samp{powerpc64}, @samp{powerpc64le},
31174@samp{rs64}, and @samp{native}.
d77de738
ML
31175
31176@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
31177@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
31178endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
31179architecture machine types, with an appropriate, generic processor
31180model assumed for scheduling purposes.
31181
31182Specifying @samp{native} as cpu type detects and selects the
31183architecture option that corresponds to the host processor of the
31184system performing the compilation.
31185@option{-mcpu=native} has no effect if GCC does not recognize the
31186processor.
31187
31188The other options specify a specific processor. Code generated under
31189those options runs best on that processor, and may not run at all on
31190others.
31191
31192The @option{-mcpu} options automatically enable or disable the
31193following options:
31194
43b72ede
AA
31195@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple
31196-mpopcntb -mpopcntd -mpowerpc64
31197-mpowerpc-gpopt -mpowerpc-gfxopt
31198-mmulhw -mdlmzb -mmfpgpr -mvsx
438ef143 31199-mcrypto -mhtm -mpower8-fusion
43b72ede
AA
31200-mquad-memory -mquad-memory-atomic -mfloat128
31201-mfloat128-hardware -mprefixed -mpcrel -mmma
d77de738
ML
31202-mrop-protect}
31203
31204The particular options set for any particular CPU varies between
31205compiler versions, depending on what setting seems to produce optimal
31206code for that CPU; it doesn't necessarily reflect the actual hardware's
31207capabilities. If you wish to set an individual option to a particular
31208value, you may specify it after the @option{-mcpu} option, like
31209@option{-mcpu=970 -mno-altivec}.
31210
31211On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
31212not enabled or disabled by the @option{-mcpu} option at present because
31213AIX does not have full support for these options. You may still
31214enable or disable them individually if you're sure it'll work in your
31215environment.
31216
d77de738 31217@opindex mtune
ddf6fe37 31218@item -mtune=@var{cpu_type}
d77de738
ML
31219Set the instruction scheduling parameters for machine type
31220@var{cpu_type}, but do not set the architecture type or register usage,
31221as @option{-mcpu=@var{cpu_type}} does. The same
31222values for @var{cpu_type} are used for @option{-mtune} as for
31223@option{-mcpu}. If both are specified, the code generated uses the
31224architecture and registers set by @option{-mcpu}, but the
31225scheduling parameters set by @option{-mtune}.
31226
d77de738 31227@opindex mcmodel=small
ddf6fe37 31228@item -mcmodel=small
d77de738
ML
31229Generate PowerPC64 code for the small model: The TOC is limited to
3123064k.
31231
d77de738 31232@opindex mcmodel=medium
ddf6fe37 31233@item -mcmodel=medium
d77de738
ML
31234Generate PowerPC64 code for the medium model: The TOC and other static
31235data may be up to a total of 4G in size. This is the default for 64-bit
31236Linux.
31237
d77de738 31238@opindex mcmodel=large
ddf6fe37 31239@item -mcmodel=large
d77de738
ML
31240Generate PowerPC64 code for the large model: The TOC may be up to 4G
31241in size. Other data and code is only limited by the 64-bit address
31242space.
31243
d77de738
ML
31244@opindex maltivec
31245@opindex mno-altivec
ddf6fe37
AA
31246@item -maltivec
31247@itemx -mno-altivec
d77de738
ML
31248Generate code that uses (does not use) AltiVec instructions, and also
31249enable the use of built-in functions that allow more direct access to
31250the AltiVec instruction set. You may also need to set
31251@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
31252enhancements.
31253
31254When @option{-maltivec} is used, the element order for AltiVec intrinsics
31255such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
31256match array element order corresponding to the endianness of the
31257target. That is, element zero identifies the leftmost element in a
31258vector register when targeting a big-endian platform, and identifies
31259the rightmost element in a vector register when targeting a
31260little-endian platform.
31261
d77de738
ML
31262@opindex mvrsave
31263@opindex mno-vrsave
ddf6fe37
AA
31264@item -mvrsave
31265@itemx -mno-vrsave
d77de738
ML
31266Generate VRSAVE instructions when generating AltiVec code.
31267
d77de738 31268@opindex msecure-plt
ddf6fe37 31269@item -msecure-plt
d77de738
ML
31270Generate code that allows @command{ld} and @command{ld.so}
31271to build executables and shared
31272libraries with non-executable @code{.plt} and @code{.got} sections.
31273This is a PowerPC
3127432-bit SYSV ABI option.
31275
d77de738 31276@opindex mbss-plt
ddf6fe37 31277@item -mbss-plt
d77de738
ML
31278Generate code that uses a BSS @code{.plt} section that @command{ld.so}
31279fills in, and
31280requires @code{.plt} and @code{.got}
31281sections that are both writable and executable.
31282This is a PowerPC 32-bit SYSV ABI option.
31283
d77de738
ML
31284@opindex misel
31285@opindex mno-isel
ddf6fe37
AA
31286@item -misel
31287@itemx -mno-isel
d77de738
ML
31288This switch enables or disables the generation of ISEL instructions.
31289
d77de738
ML
31290@opindex mvsx
31291@opindex mno-vsx
ddf6fe37
AA
31292@item -mvsx
31293@itemx -mno-vsx
d77de738
ML
31294Generate code that uses (does not use) vector/scalar (VSX)
31295instructions, and also enable the use of built-in functions that allow
31296more direct access to the VSX instruction set.
31297
d77de738
ML
31298@opindex mcrypto
31299@opindex mno-crypto
ddf6fe37
AA
31300@item -mcrypto
31301@itemx -mno-crypto
d77de738
ML
31302Enable the use (disable) of the built-in functions that allow direct
31303access to the cryptographic instructions that were added in version
313042.07 of the PowerPC ISA.
31305
d77de738
ML
31306@opindex mhtm
31307@opindex mno-htm
ddf6fe37
AA
31308@item -mhtm
31309@itemx -mno-htm
d77de738
ML
31310Enable (disable) the use of the built-in functions that allow direct
31311access to the Hardware Transactional Memory (HTM) instructions that
31312were added in version 2.07 of the PowerPC ISA.
31313
d77de738
ML
31314@opindex mpower8-fusion
31315@opindex mno-power8-fusion
ddf6fe37
AA
31316@item -mpower8-fusion
31317@itemx -mno-power8-fusion
d77de738
ML
31318Generate code that keeps (does not keeps) some integer operations
31319adjacent so that the instructions can be fused together on power8 and
31320later processors.
31321
d77de738
ML
31322@opindex mquad-memory
31323@opindex mno-quad-memory
ddf6fe37
AA
31324@item -mquad-memory
31325@itemx -mno-quad-memory
d77de738
ML
31326Generate code that uses (does not use) the non-atomic quad word memory
31327instructions. The @option{-mquad-memory} option requires use of
3132864-bit mode.
31329
d77de738
ML
31330@opindex mquad-memory-atomic
31331@opindex mno-quad-memory-atomic
ddf6fe37
AA
31332@item -mquad-memory-atomic
31333@itemx -mno-quad-memory-atomic
d77de738
ML
31334Generate code that uses (does not use) the atomic quad word memory
31335instructions. The @option{-mquad-memory-atomic} option requires use of
3133664-bit mode.
31337
d77de738
ML
31338@opindex mfloat128
31339@opindex mno-float128
ddf6fe37
AA
31340@item -mfloat128
31341@itemx -mno-float128
d77de738
ML
31342Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
31343and use either software emulation for IEEE 128-bit floating point or
31344hardware instructions.
31345
31346The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
31347128-bit floating point support. The IEEE 128-bit floating point is only
31348supported on Linux.
31349
31350The default for @option{-mfloat128} is enabled on PowerPC Linux
31351systems using the VSX instruction set, and disabled on other systems.
31352
438ef143
KL
31353If you use the ISA 3.0 instruction set (@option{-mcpu=power9}) on a
3135464-bit system, the IEEE 128-bit floating point support will also enable
31355the generation of ISA 3.0 IEEE 128-bit floating point instructions.
31356Otherwise, if you do not specify to generate ISA 3.0 instructions or you
31357are targeting a 32-bit big endian system, IEEE 128-bit floating point
31358will be done with software emulation.
d77de738 31359
d77de738
ML
31360@opindex mfloat128-hardware
31361@opindex mno-float128-hardware
ddf6fe37
AA
31362@item -mfloat128-hardware
31363@itemx -mno-float128-hardware
d77de738
ML
31364Enable/disable using ISA 3.0 hardware instructions to support the
31365@var{__float128} data type.
31366
31367The default for @option{-mfloat128-hardware} is enabled on PowerPC
31368Linux systems using the ISA 3.0 instruction set, and disabled on other
31369systems.
31370
d77de738
ML
31371@opindex m32
31372@opindex m64
ddf6fe37
AA
31373@item -m32
31374@itemx -m64
d77de738
ML
31375Generate code for 32-bit or 64-bit environments of Darwin and SVR4
31376targets (including GNU/Linux). The 32-bit environment sets int, long
31377and pointer to 32 bits and generates code that runs on any PowerPC
31378variant. The 64-bit environment sets int to 32 bits and long and
31379pointer to 64 bits, and generates code for PowerPC64, as for
31380@option{-mpowerpc64}.
31381
d77de738
ML
31382@opindex mfull-toc
31383@opindex mno-fp-in-toc
31384@opindex mno-sum-in-toc
31385@opindex mminimal-toc
ddf6fe37
AA
31386@item -mfull-toc
31387@itemx -mno-fp-in-toc
31388@itemx -mno-sum-in-toc
31389@itemx -mminimal-toc
d77de738
ML
31390Modify generation of the TOC (Table Of Contents), which is created for
31391every executable file. The @option{-mfull-toc} option is selected by
31392default. In that case, GCC allocates at least one TOC entry for
31393each unique non-automatic variable reference in your program. GCC
31394also places floating-point constants in the TOC@. However, only
3139516,384 entries are available in the TOC@.
31396
31397If you receive a linker error message that saying you have overflowed
31398the available TOC space, you can reduce the amount of TOC space used
31399with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
31400@option{-mno-fp-in-toc} prevents GCC from putting floating-point
31401constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
31402generate code to calculate the sum of an address and a constant at
31403run time instead of putting that sum into the TOC@. You may specify one
31404or both of these options. Each causes GCC to produce very slightly
31405slower and larger code at the expense of conserving TOC space.
31406
31407If you still run out of space in the TOC even when you specify both of
31408these options, specify @option{-mminimal-toc} instead. This option causes
31409GCC to make only one TOC entry for every file. When you specify this
31410option, GCC produces code that is slower and larger but which
31411uses extremely little TOC space. You may wish to use this option
31412only on files that contain less frequently-executed code.
31413
d77de738
ML
31414@opindex maix64
31415@opindex maix32
ddf6fe37
AA
31416@item -maix64
31417@itemx -maix32
d77de738
ML
31418Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
31419@code{long} type, and the infrastructure needed to support them.
31420Specifying @option{-maix64} implies @option{-mpowerpc64},
31421while @option{-maix32} disables the 64-bit ABI and
31422implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
31423
d77de738
ML
31424@opindex mxl-compat
31425@opindex mno-xl-compat
ddf6fe37
AA
31426@item -mxl-compat
31427@itemx -mno-xl-compat
d77de738
ML
31428Produce code that conforms more closely to IBM XL compiler semantics
31429when using AIX-compatible ABI@. Pass floating-point arguments to
31430prototyped functions beyond the register save area (RSA) on the stack
31431in addition to argument FPRs. Do not assume that most significant
31432double in 128-bit long double value is properly rounded when comparing
31433values and converting to double. Use XL symbol names for long double
31434support routines.
31435
31436The AIX calling convention was extended but not initially documented to
31437handle an obscure K&R C case of calling a function that takes the
31438address of its arguments with fewer arguments than declared. IBM XL
31439compilers access floating-point arguments that do not fit in the
31440RSA from the stack when a subroutine is compiled without
31441optimization. Because always storing floating-point arguments on the
31442stack is inefficient and rarely needed, this option is not enabled by
31443default and only is necessary when calling subroutines compiled by IBM
31444XL compilers without optimization.
31445
d77de738 31446@opindex mpe
ddf6fe37 31447@item -mpe
d77de738
ML
31448Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
31449application written to use message passing with special startup code to
31450enable the application to run. The system must have PE installed in the
31451standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
31452must be overridden with the @option{-specs=} option to specify the
31453appropriate directory location. The Parallel Environment does not
31454support threads, so the @option{-mpe} option and the @option{-pthread}
31455option are incompatible.
31456
d77de738
ML
31457@opindex malign-natural
31458@opindex malign-power
ddf6fe37
AA
31459@item -malign-natural
31460@itemx -malign-power
d77de738
ML
31461On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
31462@option{-malign-natural} overrides the ABI-defined alignment of larger
31463types, such as floating-point doubles, on their natural size-based boundary.
31464The option @option{-malign-power} instructs GCC to follow the ABI-specified
31465alignment rules. GCC defaults to the standard alignment defined in the ABI@.
31466
31467On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
31468is not supported.
31469
d77de738
ML
31470@opindex msoft-float
31471@opindex mhard-float
ddf6fe37
AA
31472@item -msoft-float
31473@itemx -mhard-float
d77de738
ML
31474Generate code that does not use (uses) the floating-point register set.
31475Software floating-point emulation is provided if you use the
31476@option{-msoft-float} option, and pass the option to GCC when linking.
31477
d77de738
ML
31478@opindex mmultiple
31479@opindex mno-multiple
ddf6fe37
AA
31480@item -mmultiple
31481@itemx -mno-multiple
d77de738
ML
31482Generate code that uses (does not use) the load multiple word
31483instructions and the store multiple word instructions. These
31484instructions are generated by default on POWER systems, and not
31485generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
31486PowerPC systems, since those instructions do not work when the
31487processor is in little-endian mode. The exceptions are PPC740 and
31488PPC750 which permit these instructions in little-endian mode.
31489
d77de738
ML
31490@opindex mupdate
31491@opindex mno-update
ddf6fe37
AA
31492@item -mupdate
31493@itemx -mno-update
d77de738
ML
31494Generate code that uses (does not use) the load or store instructions
31495that update the base register to the address of the calculated memory
31496location. These instructions are generated by default. If you use
31497@option{-mno-update}, there is a small window between the time that the
31498stack pointer is updated and the address of the previous frame is
31499stored, which means code that walks the stack frame across interrupts or
31500signals may get corrupted data.
31501
d77de738
ML
31502@opindex mavoid-indexed-addresses
31503@opindex mno-avoid-indexed-addresses
ddf6fe37
AA
31504@item -mavoid-indexed-addresses
31505@itemx -mno-avoid-indexed-addresses
d77de738
ML
31506Generate code that tries to avoid (not avoid) the use of indexed load
31507or store instructions. These instructions can incur a performance
31508penalty on Power6 processors in certain situations, such as when
31509stepping through large arrays that cross a 16M boundary. This option
31510is enabled by default when targeting Power6 and disabled otherwise.
31511
d77de738
ML
31512@opindex mfused-madd
31513@opindex mno-fused-madd
ddf6fe37
AA
31514@item -mfused-madd
31515@itemx -mno-fused-madd
d77de738
ML
31516Generate code that uses (does not use) the floating-point multiply and
31517accumulate instructions. These instructions are generated by default
31518if hardware floating point is used. The machine-dependent
31519@option{-mfused-madd} option is now mapped to the machine-independent
31520@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31521mapped to @option{-ffp-contract=off}.
31522
d77de738
ML
31523@opindex mmulhw
31524@opindex mno-mulhw
ddf6fe37
AA
31525@item -mmulhw
31526@itemx -mno-mulhw
d77de738
ML
31527Generate code that uses (does not use) the half-word multiply and
31528multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
31529These instructions are generated by default when targeting those
31530processors.
31531
d77de738
ML
31532@opindex mdlmzb
31533@opindex mno-dlmzb
ddf6fe37
AA
31534@item -mdlmzb
31535@itemx -mno-dlmzb
d77de738
ML
31536Generate code that uses (does not use) the string-search @samp{dlmzb}
31537instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
31538generated by default when targeting those processors.
31539
d77de738
ML
31540@opindex mno-bit-align
31541@opindex mbit-align
ddf6fe37
AA
31542@item -mno-bit-align
31543@itemx -mbit-align
d77de738
ML
31544On System V.4 and embedded PowerPC systems do not (do) force structures
31545and unions that contain bit-fields to be aligned to the base type of the
31546bit-field.
31547
31548For example, by default a structure containing nothing but 8
31549@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
31550boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
31551the structure is aligned to a 1-byte boundary and is 1 byte in
31552size.
31553
d77de738
ML
31554@opindex mno-strict-align
31555@opindex mstrict-align
ddf6fe37
AA
31556@item -mno-strict-align
31557@itemx -mstrict-align
d77de738
ML
31558On System V.4 and embedded PowerPC systems do not (do) assume that
31559unaligned memory references are handled by the system.
31560
d77de738
ML
31561@opindex mrelocatable
31562@opindex mno-relocatable
ddf6fe37
AA
31563@item -mrelocatable
31564@itemx -mno-relocatable
d77de738
ML
31565Generate code that allows (does not allow) a static executable to be
31566relocated to a different address at run time. A simple embedded
31567PowerPC system loader should relocate the entire contents of
31568@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
31569a table of 32-bit addresses generated by this option. For this to
31570work, all objects linked together must be compiled with
31571@option{-mrelocatable} or @option{-mrelocatable-lib}.
31572@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
31573
d77de738
ML
31574@opindex mrelocatable-lib
31575@opindex mno-relocatable-lib
ddf6fe37
AA
31576@item -mrelocatable-lib
31577@itemx -mno-relocatable-lib
d77de738
ML
31578Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
31579@code{.fixup} section to allow static executables to be relocated at
31580run time, but @option{-mrelocatable-lib} does not use the smaller stack
31581alignment of @option{-mrelocatable}. Objects compiled with
31582@option{-mrelocatable-lib} may be linked with objects compiled with
31583any combination of the @option{-mrelocatable} options.
31584
d77de738
ML
31585@opindex mno-toc
31586@opindex mtoc
ddf6fe37
AA
31587@item -mno-toc
31588@itemx -mtoc
d77de738
ML
31589On System V.4 and embedded PowerPC systems do not (do) assume that
31590register 2 contains a pointer to a global area pointing to the addresses
31591used in the program.
31592
d77de738
ML
31593@opindex mlittle
31594@opindex mlittle-endian
ddf6fe37
AA
31595@item -mlittle
31596@itemx -mlittle-endian
d77de738
ML
31597On System V.4 and embedded PowerPC systems compile code for the
31598processor in little-endian mode. The @option{-mlittle-endian} option is
31599the same as @option{-mlittle}.
31600
d77de738
ML
31601@opindex mbig
31602@opindex mbig-endian
ddf6fe37
AA
31603@item -mbig
31604@itemx -mbig-endian
d77de738
ML
31605On System V.4 and embedded PowerPC systems compile code for the
31606processor in big-endian mode. The @option{-mbig-endian} option is
31607the same as @option{-mbig}.
31608
d77de738 31609@opindex mdynamic-no-pic
ddf6fe37 31610@item -mdynamic-no-pic
a335cf24 31611On Darwin / macOS systems, compile code so that it is not
d77de738
ML
31612relocatable, but that its external references are relocatable. The
31613resulting code is suitable for applications, but not shared
31614libraries.
31615
d77de738 31616@opindex msingle-pic-base
ddf6fe37 31617@item -msingle-pic-base
d77de738
ML
31618Treat the register used for PIC addressing as read-only, rather than
31619loading it in the prologue for each function. The runtime system is
31620responsible for initializing this register with an appropriate value
31621before execution begins.
31622
d77de738 31623@opindex mprioritize-restricted-insns
ddf6fe37 31624@item -mprioritize-restricted-insns=@var{priority}
d77de738
ML
31625This option controls the priority that is assigned to
31626dispatch-slot restricted instructions during the second scheduling
31627pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
31628or @samp{2} to assign no, highest, or second-highest (respectively)
31629priority to dispatch-slot restricted
31630instructions.
31631
d77de738 31632@opindex msched-costly-dep
ddf6fe37 31633@item -msched-costly-dep=@var{dependence_type}
d77de738
ML
31634This option controls which dependences are considered costly
31635by the target during instruction scheduling. The argument
31636@var{dependence_type} takes one of the following values:
31637
31638@table @asis
31639@item @samp{no}
31640No dependence is costly.
31641
31642@item @samp{all}
31643All dependences are costly.
31644
31645@item @samp{true_store_to_load}
31646A true dependence from store to load is costly.
31647
31648@item @samp{store_to_load}
31649Any dependence from store to load is costly.
31650
31651@item @var{number}
31652Any dependence for which the latency is greater than or equal to
31653@var{number} is costly.
31654@end table
31655
d77de738 31656@opindex minsert-sched-nops
ddf6fe37 31657@item -minsert-sched-nops=@var{scheme}
d77de738
ML
31658This option controls which NOP insertion scheme is used during
31659the second scheduling pass. The argument @var{scheme} takes one of the
31660following values:
31661
31662@table @asis
31663@item @samp{no}
31664Don't insert NOPs.
31665
31666@item @samp{pad}
31667Pad with NOPs any dispatch group that has vacant issue slots,
31668according to the scheduler's grouping.
31669
31670@item @samp{regroup_exact}
31671Insert NOPs to force costly dependent insns into
31672separate groups. Insert exactly as many NOPs as needed to force an insn
31673to a new group, according to the estimated processor grouping.
31674
31675@item @var{number}
31676Insert NOPs to force costly dependent insns into
31677separate groups. Insert @var{number} NOPs to force an insn to a new group.
31678@end table
31679
d77de738 31680@opindex mcall-sysv
ddf6fe37 31681@item -mcall-sysv
d77de738
ML
31682On System V.4 and embedded PowerPC systems compile code using calling
31683conventions that adhere to the March 1995 draft of the System V
31684Application Binary Interface, PowerPC processor supplement. This is the
31685default unless you configured GCC using @samp{powerpc-*-eabiaix}.
31686
d77de738
ML
31687@opindex mcall-sysv-eabi
31688@opindex mcall-eabi
ddf6fe37
AA
31689@item -mcall-sysv-eabi
31690@itemx -mcall-eabi
d77de738
ML
31691Specify both @option{-mcall-sysv} and @option{-meabi} options.
31692
d77de738 31693@opindex mcall-sysv-noeabi
ddf6fe37 31694@item -mcall-sysv-noeabi
d77de738
ML
31695Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
31696
d7971cf7 31697@opindex mcall-aixdesc
ddf6fe37 31698@item -mcall-aixdesc
d77de738
ML
31699On System V.4 and embedded PowerPC systems compile code for the AIX
31700operating system.
31701
d77de738 31702@opindex mcall-linux
ddf6fe37 31703@item -mcall-linux
d77de738
ML
31704On System V.4 and embedded PowerPC systems compile code for the
31705Linux-based GNU system.
31706
d77de738 31707@opindex mcall-freebsd
ddf6fe37 31708@item -mcall-freebsd
d77de738
ML
31709On System V.4 and embedded PowerPC systems compile code for the
31710FreeBSD operating system.
31711
d77de738 31712@opindex mcall-netbsd
ddf6fe37 31713@item -mcall-netbsd
d77de738
ML
31714On System V.4 and embedded PowerPC systems compile code for the
31715NetBSD operating system.
31716
d7971cf7 31717@opindex mcall-openbsd
ddf6fe37 31718@item -mcall-openbsd
d77de738
ML
31719On System V.4 and embedded PowerPC systems compile code for the
31720OpenBSD operating system.
31721
d77de738 31722@opindex mtraceback
ddf6fe37 31723@item -mtraceback=@var{traceback_type}
d77de738
ML
31724Select the type of traceback table. Valid values for @var{traceback_type}
31725are @samp{full}, @samp{part}, and @samp{no}.
31726
d77de738 31727@opindex maix-struct-return
ddf6fe37 31728@item -maix-struct-return
d77de738
ML
31729Return all structures in memory (as specified by the AIX ABI)@.
31730
d77de738 31731@opindex msvr4-struct-return
ddf6fe37 31732@item -msvr4-struct-return
d77de738
ML
31733Return structures smaller than 8 bytes in registers (as specified by the
31734SVR4 ABI)@.
31735
d77de738 31736@opindex mabi
ddf6fe37 31737@item -mabi=@var{abi-type}
d77de738
ML
31738Extend the current ABI with a particular extension, or remove such extension.
31739Valid values are: @samp{altivec}, @samp{no-altivec},
31740@samp{ibmlongdouble}, @samp{ieeelongdouble},
31741@samp{elfv1}, @samp{elfv2},
31742and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
31743
d77de738 31744@opindex mabi=ibmlongdouble
ddf6fe37 31745@item -mabi=ibmlongdouble
d77de738
ML
31746Change the current ABI to use IBM extended-precision long double.
31747This is not likely to work if your system defaults to using IEEE
31748extended-precision long double. If you change the long double type
31749from IEEE extended-precision, the compiler will issue a warning unless
31750you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
31751to be enabled.
31752
d77de738 31753@opindex mabi=ieeelongdouble
ddf6fe37 31754@item -mabi=ieeelongdouble
d77de738
ML
31755Change the current ABI to use IEEE extended-precision long double.
31756This is not likely to work if your system defaults to using IBM
31757extended-precision long double. If you change the long double type
31758from IBM extended-precision, the compiler will issue a warning unless
31759you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
31760to be enabled.
31761
d77de738 31762@opindex mabi=elfv1
ddf6fe37 31763@item -mabi=elfv1
d77de738
ML
31764Change the current ABI to use the ELFv1 ABI.
31765This is the default ABI for big-endian PowerPC 64-bit Linux.
31766Overriding the default ABI requires special system support and is
31767likely to fail in spectacular ways.
31768
d77de738 31769@opindex mabi=elfv2
ddf6fe37 31770@item -mabi=elfv2
d77de738
ML
31771Change the current ABI to use the ELFv2 ABI.
31772This is the default ABI for little-endian PowerPC 64-bit Linux.
31773Overriding the default ABI requires special system support and is
31774likely to fail in spectacular ways.
31775
d77de738
ML
31776@opindex mgnu-attribute
31777@opindex mno-gnu-attribute
ddf6fe37
AA
31778@item -mgnu-attribute
31779@itemx -mno-gnu-attribute
d77de738
ML
31780Emit .gnu_attribute assembly directives to set tag/value pairs in a
31781.gnu.attributes section that specify ABI variations in function
31782parameters or return values.
31783
d77de738
ML
31784@opindex mprototype
31785@opindex mno-prototype
ddf6fe37
AA
31786@item -mprototype
31787@itemx -mno-prototype
d77de738
ML
31788On System V.4 and embedded PowerPC systems assume that all calls to
31789variable argument functions are properly prototyped. Otherwise, the
31790compiler must insert an instruction before every non-prototyped call to
31791set or clear bit 6 of the condition code register (@code{CR}) to
31792indicate whether floating-point values are passed in the floating-point
31793registers in case the function takes variable arguments. With
31794@option{-mprototype}, only calls to prototyped variable argument functions
31795set or clear the bit.
31796
d77de738 31797@opindex msim
ddf6fe37 31798@item -msim
d77de738
ML
31799On embedded PowerPC systems, assume that the startup module is called
31800@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
31801@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
31802configurations.
31803
d77de738 31804@opindex mmvme
ddf6fe37 31805@item -mmvme
d77de738
ML
31806On embedded PowerPC systems, assume that the startup module is called
31807@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
31808@file{libc.a}.
31809
d77de738 31810@opindex mads
ddf6fe37 31811@item -mads
d77de738
ML
31812On embedded PowerPC systems, assume that the startup module is called
31813@file{crt0.o} and the standard C libraries are @file{libads.a} and
31814@file{libc.a}.
31815
d77de738 31816@opindex myellowknife
ddf6fe37 31817@item -myellowknife
d77de738
ML
31818On embedded PowerPC systems, assume that the startup module is called
31819@file{crt0.o} and the standard C libraries are @file{libyk.a} and
31820@file{libc.a}.
31821
d77de738 31822@opindex mvxworks
ddf6fe37 31823@item -mvxworks
d77de738
ML
31824On System V.4 and embedded PowerPC systems, specify that you are
31825compiling for a VxWorks system.
31826
d77de738 31827@opindex memb
ddf6fe37 31828@item -memb
d77de738
ML
31829On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
31830header to indicate that @samp{eabi} extended relocations are used.
31831
d77de738
ML
31832@opindex meabi
31833@opindex mno-eabi
ddf6fe37
AA
31834@item -meabi
31835@itemx -mno-eabi
d77de738
ML
31836On System V.4 and embedded PowerPC systems do (do not) adhere to the
31837Embedded Applications Binary Interface (EABI), which is a set of
31838modifications to the System V.4 specifications. Selecting @option{-meabi}
31839means that the stack is aligned to an 8-byte boundary, a function
31840@code{__eabi} is called from @code{main} to set up the EABI
31841environment, and the @option{-msdata} option can use both @code{r2} and
31842@code{r13} to point to two separate small data areas. Selecting
31843@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
31844no EABI initialization function is called from @code{main}, and the
31845@option{-msdata} option only uses @code{r13} to point to a single
31846small data area. The @option{-meabi} option is on by default if you
31847configured GCC using one of the @samp{powerpc*-*-eabi*} options.
31848
d77de738 31849@opindex msdata=eabi
ddf6fe37 31850@item -msdata=eabi
d77de738
ML
31851On System V.4 and embedded PowerPC systems, put small initialized
31852@code{const} global and static data in the @code{.sdata2} section, which
31853is pointed to by register @code{r2}. Put small initialized
31854non-@code{const} global and static data in the @code{.sdata} section,
31855which is pointed to by register @code{r13}. Put small uninitialized
31856global and static data in the @code{.sbss} section, which is adjacent to
31857the @code{.sdata} section. The @option{-msdata=eabi} option is
31858incompatible with the @option{-mrelocatable} option. The
31859@option{-msdata=eabi} option also sets the @option{-memb} option.
31860
d77de738 31861@opindex msdata=sysv
ddf6fe37 31862@item -msdata=sysv
d77de738
ML
31863On System V.4 and embedded PowerPC systems, put small global and static
31864data in the @code{.sdata} section, which is pointed to by register
31865@code{r13}. Put small uninitialized global and static data in the
31866@code{.sbss} section, which is adjacent to the @code{.sdata} section.
31867The @option{-msdata=sysv} option is incompatible with the
31868@option{-mrelocatable} option.
31869
d77de738
ML
31870@opindex msdata=default
31871@opindex msdata
ddf6fe37
AA
31872@item -msdata=default
31873@itemx -msdata
d77de738
ML
31874On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
31875compile code the same as @option{-msdata=eabi}, otherwise compile code the
31876same as @option{-msdata=sysv}.
31877
d77de738 31878@opindex msdata=data
ddf6fe37 31879@item -msdata=data
d77de738
ML
31880On System V.4 and embedded PowerPC systems, put small global
31881data in the @code{.sdata} section. Put small uninitialized global
31882data in the @code{.sbss} section. Do not use register @code{r13}
31883to address small data however. This is the default behavior unless
31884other @option{-msdata} options are used.
31885
d77de738
ML
31886@opindex msdata=none
31887@opindex mno-sdata
ddf6fe37
AA
31888@item -msdata=none
31889@itemx -mno-sdata
d77de738
ML
31890On embedded PowerPC systems, put all initialized global and static data
31891in the @code{.data} section, and all uninitialized data in the
31892@code{.bss} section.
31893
d77de738
ML
31894@opindex mreadonly-in-sdata
31895@opindex mno-readonly-in-sdata
ddf6fe37 31896@item -mreadonly-in-sdata
d77de738
ML
31897Put read-only objects in the @code{.sdata} section as well. This is the
31898default.
31899
d77de738 31900@opindex mblock-move-inline-limit
ddf6fe37 31901@item -mblock-move-inline-limit=@var{num}
d77de738
ML
31902Inline all block moves (such as calls to @code{memcpy} or structure
31903copies) less than or equal to @var{num} bytes. The minimum value for
31904@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
31905targets. The default value is target-specific.
31906
d77de738 31907@opindex mblock-compare-inline-limit
ddf6fe37 31908@item -mblock-compare-inline-limit=@var{num}
d77de738
ML
31909Generate non-looping inline code for all block compares (such as calls
31910to @code{memcmp} or structure compares) less than or equal to @var{num}
31911bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
31912block compare is disabled. The default value is target-specific.
31913
d77de738 31914@opindex mblock-compare-inline-loop-limit
ddf6fe37 31915@item -mblock-compare-inline-loop-limit=@var{num}
d77de738
ML
31916Generate an inline expansion using loop code for all block compares that
31917are less than or equal to @var{num} bytes, but greater than the limit
31918for non-loop inline block compare expansion. If the block length is not
31919constant, at most @var{num} bytes will be compared before @code{memcmp}
31920is called to compare the remainder of the block. The default value is
31921target-specific.
31922
d77de738 31923@opindex mstring-compare-inline-limit
ddf6fe37 31924@item -mstring-compare-inline-limit=@var{num}
d77de738
ML
31925Compare at most @var{num} string bytes with inline code.
31926If the difference or end of string is not found at the
31927end of the inline compare a call to @code{strcmp} or @code{strncmp} will
31928take care of the rest of the comparison. The default is 64 bytes.
31929
d77de738
ML
31930@opindex G
31931@cindex smaller data references (PowerPC)
31932@cindex .sdata/.sdata2 references (PowerPC)
f33d7a88 31933@item -G @var{num}
d77de738
ML
31934On embedded PowerPC systems, put global and static items less than or
31935equal to @var{num} bytes into the small data or BSS sections instead of
31936the normal data or BSS section. By default, @var{num} is 8. The
31937@option{-G @var{num}} switch is also passed to the linker.
31938All modules should be compiled with the same @option{-G @var{num}} value.
31939
d77de738
ML
31940@opindex mregnames
31941@opindex mno-regnames
ddf6fe37
AA
31942@item -mregnames
31943@itemx -mno-regnames
d77de738
ML
31944On System V.4 and embedded PowerPC systems do (do not) emit register
31945names in the assembly language output using symbolic forms.
31946
d77de738
ML
31947@opindex mlongcall
31948@opindex mno-longcall
ddf6fe37
AA
31949@item -mlongcall
31950@itemx -mno-longcall
d77de738
ML
31951By default assume that all calls are far away so that a longer and more
31952expensive calling sequence is required. This is required for calls
31953farther than 32 megabytes (33,554,432 bytes) from the current location.
31954A short call is generated if the compiler knows
31955the call cannot be that far away. This setting can be overridden by
31956the @code{shortcall} function attribute, or by @code{#pragma
31957longcall(0)}.
31958
31959Some linkers are capable of detecting out-of-range calls and generating
31960glue code on the fly. On these systems, long calls are unnecessary and
31961generate slower code. As of this writing, the AIX linker can do this,
31962as can the GNU linker for PowerPC/64. It is planned to add this feature
31963to the GNU linker for 32-bit PowerPC systems as well.
31964
31965On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
31966GCC can generate long calls using an inline PLT call sequence (see
31967@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
31968ELFv1 (big-endian) do not support inline PLT calls.
31969
31970On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
31971callee, L42}, plus a @dfn{branch island} (glue code). The two target
31972addresses represent the callee and the branch island. The
31973Darwin/PPC linker prefers the first address and generates a @code{bl
31974callee} if the PPC @code{bl} instruction reaches the callee directly;
31975otherwise, the linker generates @code{bl L42} to call the branch
31976island. The branch island is appended to the body of the
31977calling function; it computes the full 32-bit address of the callee
31978and jumps to it.
31979
31980On Mach-O (Darwin) systems, this option directs the compiler emit to
31981the glue for every direct call, and the Darwin linker decides whether
31982to use or discard it.
31983
31984In the future, GCC may ignore all longcall specifications
31985when the linker is known to generate glue.
31986
d77de738
ML
31987@opindex mpltseq
31988@opindex mno-pltseq
ddf6fe37
AA
31989@item -mpltseq
31990@itemx -mno-pltseq
d77de738
ML
31991Implement (do not implement) -fno-plt and long calls using an inline
31992PLT call sequence that supports lazy linking and long calls to
31993functions in dlopen'd shared libraries. Inline PLT calls are only
31994supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
31995linkers, and are enabled by default if the support is detected when
31996configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
31997configured with @option{--enable-secureplt}. @option{-mpltseq} code
31998and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
31999linked together.
32000
d77de738
ML
32001@opindex mtls-markers
32002@opindex mno-tls-markers
ddf6fe37
AA
32003@item -mtls-markers
32004@itemx -mno-tls-markers
d77de738
ML
32005Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
32006specifying the function argument. The relocation allows the linker to
32007reliably associate function call with argument setup instructions for
32008TLS optimization, which in turn allows GCC to better schedule the
32009sequence.
32010
ddf6fe37 32011@opindex mrecip
d77de738
ML
32012@item -mrecip
32013@itemx -mno-recip
d77de738
ML
32014This option enables use of the reciprocal estimate and
32015reciprocal square root estimate instructions with additional
32016Newton-Raphson steps to increase precision instead of doing a divide or
32017square root and divide for floating-point arguments. You should use
32018the @option{-ffast-math} option when using @option{-mrecip} (or at
32019least @option{-funsafe-math-optimizations},
32020@option{-ffinite-math-only}, @option{-freciprocal-math} and
32021@option{-fno-trapping-math}). Note that while the throughput of the
32022sequence is generally higher than the throughput of the non-reciprocal
32023instruction, the precision of the sequence can be decreased by up to 2
32024ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
32025roots.
32026
d77de738 32027@opindex mrecip=opt
ddf6fe37 32028@item -mrecip=@var{opt}
d77de738
ML
32029This option controls which reciprocal estimate instructions
32030may be used. @var{opt} is a comma-separated list of options, which may
32031be preceded by a @code{!} to invert the option:
32032
32033@table @samp
32034
32035@item all
32036Enable all estimate instructions.
32037
32038@item default
32039Enable the default instructions, equivalent to @option{-mrecip}.
32040
32041@item none
32042Disable all estimate instructions, equivalent to @option{-mno-recip}.
32043
32044@item div
32045Enable the reciprocal approximation instructions for both
32046single and double precision.
32047
32048@item divf
32049Enable the single-precision reciprocal approximation instructions.
32050
32051@item divd
32052Enable the double-precision reciprocal approximation instructions.
32053
32054@item rsqrt
32055Enable the reciprocal square root approximation instructions for both
32056single and double precision.
32057
32058@item rsqrtf
32059Enable the single-precision reciprocal square root approximation instructions.
32060
32061@item rsqrtd
32062Enable the double-precision reciprocal square root approximation instructions.
32063
32064@end table
32065
32066So, for example, @option{-mrecip=all,!rsqrtd} enables
32067all of the reciprocal estimate instructions, except for the
32068@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
32069which handle the double-precision reciprocal square root calculations.
32070
ddf6fe37 32071@opindex mrecip-precision
d77de738
ML
32072@item -mrecip-precision
32073@itemx -mno-recip-precision
d77de738
ML
32074Assume (do not assume) that the reciprocal estimate instructions
32075provide higher-precision estimates than is mandated by the PowerPC
32076ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
32077@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
32078The double-precision square root estimate instructions are not generated by
32079default on low-precision machines, since they do not provide an
32080estimate that converges after three steps.
32081
d77de738 32082@opindex mveclibabi
ddf6fe37 32083@item -mveclibabi=@var{type}
d77de738
ML
32084Specifies the ABI type to use for vectorizing intrinsics using an
32085external library. The only type supported at present is @samp{mass},
32086which specifies to use IBM's Mathematical Acceleration Subsystem
32087(MASS) libraries for vectorizing intrinsics using external libraries.
32088GCC currently emits calls to @code{acosd2}, @code{acosf4},
32089@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
32090@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
32091@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
32092@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
32093@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
32094@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
32095@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
32096@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
32097@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
32098@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
32099@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
32100@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
32101@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
32102for power7. Both @option{-ftree-vectorize} and
32103@option{-funsafe-math-optimizations} must also be enabled. The MASS
32104libraries must be specified at link time.
32105
ddf6fe37 32106@opindex mfriz
d77de738
ML
32107@item -mfriz
32108@itemx -mno-friz
d77de738
ML
32109Generate (do not generate) the @code{friz} instruction when the
32110@option{-funsafe-math-optimizations} option is used to optimize
32111rounding of floating-point values to 64-bit integer and back to floating
32112point. The @code{friz} instruction does not return the same value if
32113the floating-point number is too large to fit in an integer.
32114
ddf6fe37 32115@opindex mpointers-to-nested-functions
d77de738
ML
32116@item -mpointers-to-nested-functions
32117@itemx -mno-pointers-to-nested-functions
d77de738
ML
32118Generate (do not generate) code to load up the static chain register
32119(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
32120systems where a function pointer points to a 3-word descriptor giving
32121the function address, TOC value to be loaded in register @code{r2}, and
32122static chain value to be loaded in register @code{r11}. The
32123@option{-mpointers-to-nested-functions} is on by default. You cannot
32124call through pointers to nested functions or pointers
32125to functions compiled in other languages that use the static chain if
32126you use @option{-mno-pointers-to-nested-functions}.
32127
ddf6fe37 32128@opindex msave-toc-indirect
d77de738
ML
32129@item -msave-toc-indirect
32130@itemx -mno-save-toc-indirect
d77de738
ML
32131Generate (do not generate) code to save the TOC value in the reserved
32132stack location in the function prologue if the function calls through
32133a pointer on AIX and 64-bit Linux systems. If the TOC value is not
32134saved in the prologue, it is saved just before the call through the
32135pointer. The @option{-mno-save-toc-indirect} option is the default.
32136
ddf6fe37 32137@opindex mcompat-align-parm
d77de738
ML
32138@item -mcompat-align-parm
32139@itemx -mno-compat-align-parm
d77de738
ML
32140Generate (do not generate) code to pass structure parameters with a
32141maximum alignment of 64 bits, for compatibility with older versions
32142of GCC.
32143
32144Older versions of GCC (prior to 4.9.0) incorrectly did not align a
32145structure parameter on a 128-bit boundary when that structure contained
32146a member requiring 128-bit alignment. This is corrected in more
32147recent versions of GCC. This option may be used to generate code
32148that is compatible with functions compiled with older versions of
32149GCC.
32150
32151The @option{-mno-compat-align-parm} option is the default.
32152
d77de738
ML
32153@opindex mstack-protector-guard
32154@opindex mstack-protector-guard-reg
32155@opindex mstack-protector-guard-offset
32156@opindex mstack-protector-guard-symbol
ddf6fe37
AA
32157@item -mstack-protector-guard=@var{guard}
32158@itemx -mstack-protector-guard-reg=@var{reg}
32159@itemx -mstack-protector-guard-offset=@var{offset}
32160@itemx -mstack-protector-guard-symbol=@var{symbol}
d77de738
ML
32161Generate stack protection code using canary at @var{guard}. Supported
32162locations are @samp{global} for global canary or @samp{tls} for per-thread
32163canary in the TLS block (the default with GNU libc version 2.4 or later).
32164
32165With the latter choice the options
32166@option{-mstack-protector-guard-reg=@var{reg}} and
32167@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
32168which register to use as base register for reading the canary, and from what
32169offset from that base register. The default for those is as specified in the
32170relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
32171the offset with a symbol reference to a canary in the TLS block.
32172
d77de738
ML
32173@opindex mpcrel
32174@opindex mno-pcrel
ddf6fe37
AA
32175@item -mpcrel
32176@itemx -mno-pcrel
d77de738
ML
32177Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
32178option requires that the medium code model (@option{-mcmodel=medium})
32179and prefixed addressing (@option{-mprefixed}) options are enabled.
32180
d77de738
ML
32181@opindex mprefixed
32182@opindex mno-prefixed
ddf6fe37
AA
32183@item -mprefixed
32184@itemx -mno-prefixed
d77de738
ML
32185Generate (do not generate) addressing modes using prefixed load and
32186store instructions. The @option{-mprefixed} option requires that
32187the option @option{-mcpu=power10} (or later) is enabled.
32188
d77de738
ML
32189@opindex mmma
32190@opindex mno-mma
ddf6fe37
AA
32191@item -mmma
32192@itemx -mno-mma
d77de738
ML
32193Generate (do not generate) the MMA instructions. The @option{-mma}
32194option requires that the option @option{-mcpu=power10} (or later)
32195is enabled.
32196
d77de738
ML
32197@opindex mrop-protect
32198@opindex mno-rop-protect
ddf6fe37
AA
32199@item -mrop-protect
32200@itemx -mno-rop-protect
d77de738
ML
32201Generate (do not generate) ROP protection instructions when the target
32202processor supports them. Currently this option disables the shrink-wrap
32203optimization (@option{-fshrink-wrap}).
32204
d77de738
ML
32205@opindex mprivileged
32206@opindex mno-privileged
ddf6fe37
AA
32207@item -mprivileged
32208@itemx -mno-privileged
d77de738
ML
32209Generate (do not generate) code that will run in privileged state.
32210
d77de738
ML
32211@opindex block-ops-unaligned-vsx
32212@opindex no-block-ops-unaligned-vsx
ddf6fe37
AA
32213@item -mblock-ops-unaligned-vsx
32214@itemx -mno-block-ops-unaligned-vsx
d77de738
ML
32215Generate (do not generate) unaligned vsx loads and stores for
32216inline expansion of @code{memcpy} and @code{memmove}.
32217
32218@item --param rs6000-vect-unroll-limit=
32219The vectorizer will check with target information to determine whether it
32220would be beneficial to unroll the main vectorized loop and by how much. This
32221parameter sets the upper bound of how much the vectorizer will unroll the main
32222loop. The default value is four.
32223
32224@end table
32225
32226@node RX Options
32227@subsection RX Options
32228@cindex RX Options
32229
32230These command-line options are defined for RX targets:
32231
32232@table @gcctabopt
d77de738
ML
32233@opindex m64bit-doubles
32234@opindex m32bit-doubles
ddf6fe37
AA
32235@item -m64bit-doubles
32236@itemx -m32bit-doubles
d77de738
ML
32237Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
32238or 32 bits (@option{-m32bit-doubles}) in size. The default is
32239@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
32240works on 32-bit values, which is why the default is
32241@option{-m32bit-doubles}.
32242
d77de738
ML
32243@opindex fpu
32244@opindex nofpu
ddf6fe37
AA
32245@item -fpu
32246@itemx -nofpu
d77de738
ML
32247Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
32248floating-point hardware. The default is enabled for the RX600
32249series and disabled for the RX200 series.
32250
32251Floating-point instructions are only generated for 32-bit floating-point
32252values, however, so the FPU hardware is not used for doubles if the
32253@option{-m64bit-doubles} option is used.
32254
32255@emph{Note} If the @option{-fpu} option is enabled then
32256@option{-funsafe-math-optimizations} is also enabled automatically.
32257This is because the RX FPU instructions are themselves unsafe.
32258
d77de738 32259@opindex mcpu
ddf6fe37 32260@item -mcpu=@var{name}
d77de738
ML
32261Selects the type of RX CPU to be targeted. Currently three types are
32262supported, the generic @samp{RX600} and @samp{RX200} series hardware and
32263the specific @samp{RX610} CPU. The default is @samp{RX600}.
32264
32265The only difference between @samp{RX600} and @samp{RX610} is that the
32266@samp{RX610} does not support the @code{MVTIPL} instruction.
32267
32268The @samp{RX200} series does not have a hardware floating-point unit
32269and so @option{-nofpu} is enabled by default when this type is
32270selected.
32271
d77de738
ML
32272@opindex mbig-endian-data
32273@opindex mlittle-endian-data
ddf6fe37
AA
32274@item -mbig-endian-data
32275@itemx -mlittle-endian-data
d77de738
ML
32276Store data (but not code) in the big-endian format. The default is
32277@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
32278format.
32279
d77de738 32280@opindex msmall-data-limit
ddf6fe37 32281@item -msmall-data-limit=@var{N}
d77de738
ML
32282Specifies the maximum size in bytes of global and static variables
32283which can be placed into the small data area. Using the small data
32284area can lead to smaller and faster code, but the size of area is
32285limited and it is up to the programmer to ensure that the area does
32286not overflow. Also when the small data area is used one of the RX's
32287registers (usually @code{r13}) is reserved for use pointing to this
32288area, so it is no longer available for use by the compiler. This
32289could result in slower and/or larger code if variables are pushed onto
32290the stack instead of being held in this register.
32291
32292Note, common variables (variables that have not been initialized) and
32293constants are not placed into the small data area as they are assigned
32294to other sections in the output executable.
32295
32296The default value is zero, which disables this feature. Note, this
32297feature is not enabled by default with higher optimization levels
32298(@option{-O2} etc) because of the potentially detrimental effects of
32299reserving a register. It is up to the programmer to experiment and
32300discover whether this feature is of benefit to their program. See the
32301description of the @option{-mpid} option for a description of how the
32302actual register to hold the small data area pointer is chosen.
32303
d77de738
ML
32304@opindex msim
32305@opindex mno-sim
ddf6fe37
AA
32306@item -msim
32307@itemx -mno-sim
d77de738
ML
32308Use the simulator runtime. The default is to use the libgloss
32309board-specific runtime.
32310
d77de738
ML
32311@opindex mas100-syntax
32312@opindex mno-as100-syntax
ddf6fe37
AA
32313@item -mas100-syntax
32314@itemx -mno-as100-syntax
d77de738
ML
32315When generating assembler output use a syntax that is compatible with
32316Renesas's AS100 assembler. This syntax can also be handled by the GAS
32317assembler, but it has some restrictions so it is not generated by default.
32318
d77de738 32319@opindex mmax-constant-size
ddf6fe37 32320@item -mmax-constant-size=@var{N}
d77de738
ML
32321Specifies the maximum size, in bytes, of a constant that can be used as
32322an operand in a RX instruction. Although the RX instruction set does
32323allow constants of up to 4 bytes in length to be used in instructions,
32324a longer value equates to a longer instruction. Thus in some
32325circumstances it can be beneficial to restrict the size of constants
32326that are used in instructions. Constants that are too big are instead
32327placed into a constant pool and referenced via register indirection.
32328
32329The value @var{N} can be between 0 and 4. A value of 0 (the default)
32330or 4 means that constants of any size are allowed.
32331
d77de738 32332@opindex mrelax
ddf6fe37 32333@item -mrelax
d77de738
ML
32334Enable linker relaxation. Linker relaxation is a process whereby the
32335linker attempts to reduce the size of a program by finding shorter
32336versions of various instructions. Disabled by default.
32337
d77de738 32338@opindex mint-register
ddf6fe37 32339@item -mint-register=@var{N}
d77de738
ML
32340Specify the number of registers to reserve for fast interrupt handler
32341functions. The value @var{N} can be between 0 and 4. A value of 1
32342means that register @code{r13} is reserved for the exclusive use
32343of fast interrupt handlers. A value of 2 reserves @code{r13} and
32344@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
32345@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
32346A value of 0, the default, does not reserve any registers.
32347
d77de738 32348@opindex msave-acc-in-interrupts
ddf6fe37 32349@item -msave-acc-in-interrupts
d77de738
ML
32350Specifies that interrupt handler functions should preserve the
32351accumulator register. This is only necessary if normal code might use
32352the accumulator register, for example because it performs 64-bit
32353multiplications. The default is to ignore the accumulator as this
32354makes the interrupt handlers faster.
32355
d77de738
ML
32356@opindex mpid
32357@opindex mno-pid
ddf6fe37
AA
32358@item -mpid
32359@itemx -mno-pid
d77de738
ML
32360Enables the generation of position independent data. When enabled any
32361access to constant data is done via an offset from a base address
32362held in a register. This allows the location of constant data to be
32363determined at run time without requiring the executable to be
32364relocated, which is a benefit to embedded applications with tight
32365memory constraints. Data that can be modified is not affected by this
32366option.
32367
32368Note, using this feature reserves a register, usually @code{r13}, for
32369the constant data base address. This can result in slower and/or
32370larger code, especially in complicated functions.
32371
32372The actual register chosen to hold the constant data base address
32373depends upon whether the @option{-msmall-data-limit} and/or the
32374@option{-mint-register} command-line options are enabled. Starting
32375with register @code{r13} and proceeding downwards, registers are
32376allocated first to satisfy the requirements of @option{-mint-register},
32377then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
32378is possible for the small data area register to be @code{r8} if both
32379@option{-mint-register=4} and @option{-mpid} are specified on the
32380command line.
32381
32382By default this feature is not enabled. The default can be restored
32383via the @option{-mno-pid} command-line option.
32384
d77de738
ML
32385@opindex mno-warn-multiple-fast-interrupts
32386@opindex mwarn-multiple-fast-interrupts
ddf6fe37
AA
32387@item -mno-warn-multiple-fast-interrupts
32388@itemx -mwarn-multiple-fast-interrupts
d77de738
ML
32389Prevents GCC from issuing a warning message if it finds more than one
32390fast interrupt handler when it is compiling a file. The default is to
32391issue a warning for each extra fast interrupt handler found, as the RX
32392only supports one such interrupt.
32393
d77de738
ML
32394@opindex mallow-string-insns
32395@opindex mno-allow-string-insns
ddf6fe37
AA
32396@item -mallow-string-insns
32397@itemx -mno-allow-string-insns
d77de738
ML
32398Enables or disables the use of the string manipulation instructions
32399@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
32400@code{SWHILE} and also the @code{RMPA} instruction. These
32401instructions may prefetch data, which is not safe to do if accessing
32402an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
32403for more information).
32404
32405The default is to allow these instructions, but it is not possible for
32406GCC to reliably detect all circumstances where a string instruction
32407might be used to access an I/O register, so their use cannot be
32408disabled automatically. Instead it is reliant upon the programmer to
32409use the @option{-mno-allow-string-insns} option if their program
32410accesses I/O space.
32411
32412When the instructions are enabled GCC defines the C preprocessor
32413symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
32414symbol @code{__RX_DISALLOW_STRING_INSNS__}.
32415
d77de738
ML
32416@opindex mjsr
32417@opindex mno-jsr
ddf6fe37
AA
32418@item -mjsr
32419@itemx -mno-jsr
d77de738
ML
32420Use only (or not only) @code{JSR} instructions to access functions.
32421This option can be used when code size exceeds the range of @code{BSR}
32422instructions. Note that @option{-mno-jsr} does not mean to not use
32423@code{JSR} but instead means that any type of branch may be used.
32424@end table
32425
32426@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
32427has special significance to the RX port when used with the
32428@code{interrupt} function attribute. This attribute indicates a
32429function intended to process fast interrupts. GCC ensures
32430that it only uses the registers @code{r10}, @code{r11}, @code{r12}
32431and/or @code{r13} and only provided that the normal use of the
32432corresponding registers have been restricted via the
32433@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
32434options.
32435
32436@node S/390 and zSeries Options
32437@subsection S/390 and zSeries Options
32438@cindex S/390 and zSeries Options
32439
32440These are the @samp{-m} options defined for the S/390 and zSeries architecture.
32441
32442@table @gcctabopt
d77de738
ML
32443@opindex mhard-float
32444@opindex msoft-float
ddf6fe37
AA
32445@item -mhard-float
32446@itemx -msoft-float
d77de738
ML
32447Use (do not use) the hardware floating-point instructions and registers
32448for floating-point operations. When @option{-msoft-float} is specified,
32449functions in @file{libgcc.a} are used to perform floating-point
32450operations. When @option{-mhard-float} is specified, the compiler
32451generates IEEE floating-point instructions. This is the default.
32452
d77de738
ML
32453@opindex mhard-dfp
32454@opindex mno-hard-dfp
ddf6fe37
AA
32455@item -mhard-dfp
32456@itemx -mno-hard-dfp
d77de738
ML
32457Use (do not use) the hardware decimal-floating-point instructions for
32458decimal-floating-point operations. When @option{-mno-hard-dfp} is
32459specified, functions in @file{libgcc.a} are used to perform
32460decimal-floating-point operations. When @option{-mhard-dfp} is
32461specified, the compiler generates decimal-floating-point hardware
32462instructions. This is the default for @option{-march=z9-ec} or higher.
32463
d77de738
ML
32464@opindex mlong-double-64
32465@opindex mlong-double-128
ddf6fe37
AA
32466@item -mlong-double-64
32467@itemx -mlong-double-128
d77de738
ML
32468These switches control the size of @code{long double} type. A size
32469of 64 bits makes the @code{long double} type equivalent to the @code{double}
32470type. This is the default.
32471
d77de738
ML
32472@opindex mbackchain
32473@opindex mno-backchain
ddf6fe37
AA
32474@item -mbackchain
32475@itemx -mno-backchain
d77de738
ML
32476Store (do not store) the address of the caller's frame as backchain pointer
32477into the callee's stack frame.
32478A backchain may be needed to allow debugging using tools that do not understand
32479DWARF call frame information.
32480When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
32481at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
32482the backchain is placed into the topmost word of the 96/160 byte register
32483save area.
32484
32485In general, code compiled with @option{-mbackchain} is call-compatible with
32486code compiled with @option{-mno-backchain}; however, use of the backchain
32487for debugging purposes usually requires that the whole binary is built with
32488@option{-mbackchain}. Note that the combination of @option{-mbackchain},
32489@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
32490to build a linux kernel use @option{-msoft-float}.
32491
32492The default is to not maintain the backchain.
32493
d77de738
ML
32494@opindex mpacked-stack
32495@opindex mno-packed-stack
ddf6fe37
AA
32496@item -mpacked-stack
32497@itemx -mno-packed-stack
d77de738
ML
32498Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
32499specified, the compiler uses the all fields of the 96/160 byte register save
32500area only for their default purpose; unused fields still take up stack space.
32501When @option{-mpacked-stack} is specified, register save slots are densely
32502packed at the top of the register save area; unused space is reused for other
32503purposes, allowing for more efficient use of the available stack space.
32504However, when @option{-mbackchain} is also in effect, the topmost word of
32505the save area is always used to store the backchain, and the return address
32506register is always saved two words below the backchain.
32507
32508As long as the stack frame backchain is not used, code generated with
32509@option{-mpacked-stack} is call-compatible with code generated with
32510@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
32511S/390 or zSeries generated code that uses the stack frame backchain at run
32512time, not just for debugging purposes. Such code is not call-compatible
32513with code compiled with @option{-mpacked-stack}. Also, note that the
32514combination of @option{-mbackchain},
32515@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
32516to build a linux kernel use @option{-msoft-float}.
32517
32518The default is to not use the packed stack layout.
32519
d77de738
ML
32520@opindex msmall-exec
32521@opindex mno-small-exec
ddf6fe37
AA
32522@item -msmall-exec
32523@itemx -mno-small-exec
d77de738
ML
32524Generate (or do not generate) code using the @code{bras} instruction
32525to do subroutine calls.
32526This only works reliably if the total executable size does not
32527exceed 64k. The default is to use the @code{basr} instruction instead,
32528which does not have this limitation.
32529
d77de738
ML
32530@opindex m64
32531@opindex m31
ddf6fe37
AA
32532@item -m64
32533@itemx -m31
d77de738
ML
32534When @option{-m31} is specified, generate code compliant to the
32535GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
32536code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
32537particular to generate 64-bit instructions. For the @samp{s390}
32538targets, the default is @option{-m31}, while the @samp{s390x}
32539targets default to @option{-m64}.
32540
d77de738
ML
32541@opindex mzarch
32542@opindex mesa
ddf6fe37
AA
32543@item -mzarch
32544@itemx -mesa
d77de738
ML
32545When @option{-mzarch} is specified, generate code using the
32546instructions available on z/Architecture.
32547When @option{-mesa} is specified, generate code using the
32548instructions available on ESA/390. Note that @option{-mesa} is
32549not possible with @option{-m64}.
32550When generating code compliant to the GNU/Linux for S/390 ABI,
32551the default is @option{-mesa}. When generating code compliant
32552to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
32553
d77de738
ML
32554@opindex mhtm
32555@opindex mno-htm
ddf6fe37
AA
32556@item -mhtm
32557@itemx -mno-htm
d77de738
ML
32558The @option{-mhtm} option enables a set of builtins making use of
32559instructions available with the transactional execution facility
32560introduced with the IBM zEnterprise EC12 machine generation
32561@ref{S/390 System z Built-in Functions}.
32562@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
32563
d77de738
ML
32564@opindex mvx
32565@opindex mno-vx
ddf6fe37
AA
32566@item -mvx
32567@itemx -mno-vx
d77de738
ML
32568When @option{-mvx} is specified, generate code using the instructions
32569available with the vector extension facility introduced with the IBM
32570z13 machine generation.
32571This option changes the ABI for some vector type values with regard to
32572alignment and calling conventions. In case vector type values are
32573being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
32574command will be added to mark the resulting binary with the ABI used.
32575@option{-mvx} is enabled by default when using @option{-march=z13}.
32576
d77de738
ML
32577@opindex mzvector
32578@opindex mno-zvector
ddf6fe37
AA
32579@item -mzvector
32580@itemx -mno-zvector
d77de738
ML
32581The @option{-mzvector} option enables vector language extensions and
32582builtins using instructions available with the vector extension
32583facility introduced with the IBM z13 machine generation.
32584This option adds support for @samp{vector} to be used as a keyword to
32585define vector type variables and arguments. @samp{vector} is only
32586available when GNU extensions are enabled. It will not be expanded
32587when requesting strict standard compliance e.g.@: with @option{-std=c99}.
32588In addition to the GCC low-level builtins @option{-mzvector} enables
32589a set of builtins added for compatibility with AltiVec-style
32590implementations like Power and Cell. In order to make use of these
32591builtins the header file @file{vecintrin.h} needs to be included.
32592@option{-mzvector} is disabled by default.
32593
d77de738
ML
32594@opindex mmvcle
32595@opindex mno-mvcle
ddf6fe37
AA
32596@item -mmvcle
32597@itemx -mno-mvcle
d77de738
ML
32598Generate (or do not generate) code using the @code{mvcle} instruction
32599to perform block moves. When @option{-mno-mvcle} is specified,
32600use a @code{mvc} loop instead. This is the default unless optimizing for
32601size.
32602
d77de738
ML
32603@opindex mdebug
32604@opindex mno-debug
ddf6fe37
AA
32605@item -mdebug
32606@itemx -mno-debug
d77de738
ML
32607Print (or do not print) additional debug information when compiling.
32608The default is to not print debug information.
32609
d77de738 32610@opindex march
ddf6fe37 32611@item -march=@var{cpu-type}
d77de738
ML
32612Generate code that runs on @var{cpu-type}, which is the name of a
32613system representing a certain processor type. Possible values for
32614@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
32615@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
32616@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
32617@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
32618@samp{z16}/@samp{arch14}, and @samp{native}.
32619
32620The default is @option{-march=z900}.
32621
32622Specifying @samp{native} as cpu type can be used to select the best
32623architecture option for the host processor.
32624@option{-march=native} has no effect if GCC does not recognize the
32625processor.
32626
d77de738 32627@opindex mtune
ddf6fe37 32628@item -mtune=@var{cpu-type}
d77de738
ML
32629Tune to @var{cpu-type} everything applicable about the generated code,
32630except for the ABI and the set of available instructions.
32631The list of @var{cpu-type} values is the same as for @option{-march}.
32632The default is the value used for @option{-march}.
32633
d77de738
ML
32634@opindex mtpf-trace
32635@opindex mno-tpf-trace
ddf6fe37
AA
32636@item -mtpf-trace
32637@itemx -mno-tpf-trace
d77de738
ML
32638Generate code that adds (does not add) in TPF OS specific branches to trace
32639routines in the operating system. This option is off by default, even
32640when compiling for the TPF OS@.
32641
d77de738
ML
32642@opindex mtpf-trace-skip
32643@opindex mno-tpf-trace-skip
ddf6fe37
AA
32644@item -mtpf-trace-skip
32645@itemx -mno-tpf-trace-skip
d77de738
ML
32646Generate code that changes (does not change) the default branch
32647targets enabled by @option{-mtpf-trace} to point to specialized trace
32648routines providing the ability of selectively skipping function trace
32649entries for the TPF OS. This option is off by default, even when
32650compiling for the TPF OS and specifying @option{-mtpf-trace}.
32651
d77de738
ML
32652@opindex mfused-madd
32653@opindex mno-fused-madd
ddf6fe37
AA
32654@item -mfused-madd
32655@itemx -mno-fused-madd
d77de738
ML
32656Generate code that uses (does not use) the floating-point multiply and
32657accumulate instructions. These instructions are generated by default if
32658hardware floating point is used.
32659
d77de738 32660@opindex mwarn-framesize
ddf6fe37 32661@item -mwarn-framesize=@var{framesize}
d77de738
ML
32662Emit a warning if the current function exceeds the given frame size. Because
32663this is a compile-time check it doesn't need to be a real problem when the program
32664runs. It is intended to identify functions that most probably cause
32665a stack overflow. It is useful to be used in an environment with limited stack
32666size e.g.@: the linux kernel.
32667
d77de738 32668@opindex mwarn-dynamicstack
ddf6fe37 32669@item -mwarn-dynamicstack
d77de738
ML
32670Emit a warning if the function calls @code{alloca} or uses dynamically-sized
32671arrays. This is generally a bad idea with a limited stack size.
32672
d77de738
ML
32673@opindex mstack-guard
32674@opindex mstack-size
ddf6fe37
AA
32675@item -mstack-guard=@var{stack-guard}
32676@itemx -mstack-size=@var{stack-size}
d77de738
ML
32677If these options are provided the S/390 back end emits additional instructions in
32678the function prologue that trigger a trap if the stack size is @var{stack-guard}
32679bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
32680If the @var{stack-guard} option is omitted the smallest power of 2 larger than
32681the frame size of the compiled function is chosen.
32682These options are intended to be used to help debugging stack overflow problems.
32683The additionally emitted code causes only little overhead and hence can also be
32684used in production-like systems without greater performance degradation. The given
32685values have to be exact powers of 2 and @var{stack-size} has to be greater than
32686@var{stack-guard} without exceeding 64k.
32687In order to be efficient the extra code makes the assumption that the stack starts
32688at an address aligned to the value given by @var{stack-size}.
32689The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
32690
d77de738 32691@opindex mhotpatch
ddf6fe37 32692@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
d77de738
ML
32693If the hotpatch option is enabled, a ``hot-patching'' function
32694prologue is generated for all functions in the compilation unit.
32695The funtion label is prepended with the given number of two-byte
32696NOP instructions (@var{pre-halfwords}, maximum 1000000). After
32697the label, 2 * @var{post-halfwords} bytes are appended, using the
32698largest NOP like instructions the architecture allows (maximum
326991000000).
32700
32701If both arguments are zero, hotpatching is disabled.
32702
32703This option can be overridden for individual functions with the
32704@code{hotpatch} attribute.
32705@end table
32706
d77de738
ML
32707@node SH Options
32708@subsection SH Options
32709
32710These @samp{-m} options are defined for the SH implementations:
32711
32712@table @gcctabopt
d77de738 32713@opindex m1
ddf6fe37 32714@item -m1
d77de738
ML
32715Generate code for the SH1.
32716
d77de738 32717@opindex m2
ddf6fe37 32718@item -m2
d77de738
ML
32719Generate code for the SH2.
32720
32721@item -m2e
32722Generate code for the SH2e.
32723
d77de738 32724@opindex m2a-nofpu
ddf6fe37 32725@item -m2a-nofpu
d77de738
ML
32726Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
32727that the floating-point unit is not used.
32728
d77de738 32729@opindex m2a-single-only
ddf6fe37 32730@item -m2a-single-only
d77de738
ML
32731Generate code for the SH2a-FPU, in such a way that no double-precision
32732floating-point operations are used.
32733
d77de738 32734@opindex m2a-single
ddf6fe37 32735@item -m2a-single
d77de738
ML
32736Generate code for the SH2a-FPU assuming the floating-point unit is in
32737single-precision mode by default.
32738
d77de738 32739@opindex m2a
ddf6fe37 32740@item -m2a
d77de738
ML
32741Generate code for the SH2a-FPU assuming the floating-point unit is in
32742double-precision mode by default.
32743
d77de738 32744@opindex m3
ddf6fe37 32745@item -m3
d77de738
ML
32746Generate code for the SH3.
32747
d77de738 32748@opindex m3e
ddf6fe37 32749@item -m3e
d77de738
ML
32750Generate code for the SH3e.
32751
d77de738 32752@opindex m4-nofpu
ddf6fe37 32753@item -m4-nofpu
d77de738
ML
32754Generate code for the SH4 without a floating-point unit.
32755
d77de738 32756@opindex m4-single-only
ddf6fe37 32757@item -m4-single-only
d77de738
ML
32758Generate code for the SH4 with a floating-point unit that only
32759supports single-precision arithmetic.
32760
d77de738 32761@opindex m4-single
ddf6fe37 32762@item -m4-single
d77de738
ML
32763Generate code for the SH4 assuming the floating-point unit is in
32764single-precision mode by default.
32765
d77de738 32766@opindex m4
ddf6fe37 32767@item -m4
d77de738
ML
32768Generate code for the SH4.
32769
d77de738 32770@opindex m4-100
ddf6fe37 32771@item -m4-100
d77de738
ML
32772Generate code for SH4-100.
32773
d77de738 32774@opindex m4-100-nofpu
ddf6fe37 32775@item -m4-100-nofpu
d77de738
ML
32776Generate code for SH4-100 in such a way that the
32777floating-point unit is not used.
32778
d77de738 32779@opindex m4-100-single
ddf6fe37 32780@item -m4-100-single
d77de738
ML
32781Generate code for SH4-100 assuming the floating-point unit is in
32782single-precision mode by default.
32783
d77de738 32784@opindex m4-100-single-only
ddf6fe37 32785@item -m4-100-single-only
d77de738
ML
32786Generate code for SH4-100 in such a way that no double-precision
32787floating-point operations are used.
32788
d77de738 32789@opindex m4-200
ddf6fe37 32790@item -m4-200
d77de738
ML
32791Generate code for SH4-200.
32792
d77de738 32793@opindex m4-200-nofpu
ddf6fe37 32794@item -m4-200-nofpu
d77de738
ML
32795Generate code for SH4-200 without in such a way that the
32796floating-point unit is not used.
32797
d77de738 32798@opindex m4-200-single
ddf6fe37 32799@item -m4-200-single
d77de738
ML
32800Generate code for SH4-200 assuming the floating-point unit is in
32801single-precision mode by default.
32802
d77de738 32803@opindex m4-200-single-only
ddf6fe37 32804@item -m4-200-single-only
d77de738
ML
32805Generate code for SH4-200 in such a way that no double-precision
32806floating-point operations are used.
32807
d77de738 32808@opindex m4-300
ddf6fe37 32809@item -m4-300
d77de738
ML
32810Generate code for SH4-300.
32811
d77de738 32812@opindex m4-300-nofpu
ddf6fe37 32813@item -m4-300-nofpu
d77de738
ML
32814Generate code for SH4-300 without in such a way that the
32815floating-point unit is not used.
32816
d77de738 32817@opindex m4-300-single
ddf6fe37 32818@item -m4-300-single
d77de738
ML
32819Generate code for SH4-300 in such a way that no double-precision
32820floating-point operations are used.
32821
d77de738 32822@opindex m4-300-single-only
ddf6fe37 32823@item -m4-300-single-only
d77de738
ML
32824Generate code for SH4-300 in such a way that no double-precision
32825floating-point operations are used.
32826
d77de738 32827@opindex m4-340
ddf6fe37 32828@item -m4-340
d77de738
ML
32829Generate code for SH4-340 (no MMU, no FPU).
32830
d77de738 32831@opindex m4-500
ddf6fe37 32832@item -m4-500
d77de738
ML
32833Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
32834assembler.
32835
d77de738 32836@opindex m4a-nofpu
ddf6fe37 32837@item -m4a-nofpu
d77de738
ML
32838Generate code for the SH4al-dsp, or for a SH4a in such a way that the
32839floating-point unit is not used.
32840
d77de738 32841@opindex m4a-single-only
ddf6fe37 32842@item -m4a-single-only
d77de738
ML
32843Generate code for the SH4a, in such a way that no double-precision
32844floating-point operations are used.
32845
d77de738 32846@opindex m4a-single
ddf6fe37 32847@item -m4a-single
d77de738
ML
32848Generate code for the SH4a assuming the floating-point unit is in
32849single-precision mode by default.
32850
d77de738 32851@opindex m4a
ddf6fe37 32852@item -m4a
d77de738
ML
32853Generate code for the SH4a.
32854
d77de738 32855@opindex m4al
ddf6fe37 32856@item -m4al
d77de738
ML
32857Same as @option{-m4a-nofpu}, except that it implicitly passes
32858@option{-dsp} to the assembler. GCC doesn't generate any DSP
32859instructions at the moment.
32860
d77de738 32861@opindex mb
ddf6fe37 32862@item -mb
d77de738
ML
32863Compile code for the processor in big-endian mode.
32864
d77de738 32865@opindex ml
ddf6fe37 32866@item -ml
d77de738
ML
32867Compile code for the processor in little-endian mode.
32868
d77de738 32869@opindex mdalign
ddf6fe37 32870@item -mdalign
d77de738
ML
32871Align doubles at 64-bit boundaries. Note that this changes the calling
32872conventions, and thus some functions from the standard C library do
32873not work unless you recompile it first with @option{-mdalign}.
32874
d77de738 32875@opindex mrelax
ddf6fe37 32876@item -mrelax
d77de738
ML
32877Shorten some address references at link time, when possible; uses the
32878linker option @option{-relax}.
32879
d77de738 32880@opindex mbigtable
ddf6fe37 32881@item -mbigtable
d77de738
ML
32882Use 32-bit offsets in @code{switch} tables. The default is to use
3288316-bit offsets.
32884
d77de738 32885@opindex mbitops
ddf6fe37 32886@item -mbitops
d77de738
ML
32887Enable the use of bit manipulation instructions on SH2A.
32888
d77de738 32889@opindex mfmovd
ddf6fe37 32890@item -mfmovd
d77de738
ML
32891Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
32892alignment constraints.
32893
d77de738 32894@opindex mrenesas
ddf6fe37 32895@item -mrenesas
d77de738
ML
32896Comply with the calling conventions defined by Renesas.
32897
d77de738 32898@opindex mno-renesas
ddf6fe37 32899@item -mno-renesas
d77de738
ML
32900Comply with the calling conventions defined for GCC before the Renesas
32901conventions were available. This option is the default for all
32902targets of the SH toolchain.
32903
d77de738 32904@opindex mnomacsave
ddf6fe37 32905@item -mnomacsave
d77de738
ML
32906Mark the @code{MAC} register as call-clobbered, even if
32907@option{-mrenesas} is given.
32908
d77de738
ML
32909@opindex mieee
32910@opindex mno-ieee
ddf6fe37
AA
32911@item -mieee
32912@itemx -mno-ieee
d77de738
ML
32913Control the IEEE compliance of floating-point comparisons, which affects the
32914handling of cases where the result of a comparison is unordered. By default
32915@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
32916enabled @option{-mno-ieee} is implicitly set, which results in faster
32917floating-point greater-equal and less-equal comparisons. The implicit settings
32918can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
32919
d77de738 32920@opindex minline-ic_invalidate
ddf6fe37 32921@item -minline-ic_invalidate
d77de738
ML
32922Inline code to invalidate instruction cache entries after setting up
32923nested function trampolines.
32924This option has no effect if @option{-musermode} is in effect and the selected
32925code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
32926instruction.
32927If the selected code generation option does not allow the use of the @code{icbi}
32928instruction, and @option{-musermode} is not in effect, the inlined code
32929manipulates the instruction cache address array directly with an associative
32930write. This not only requires privileged mode at run time, but it also
32931fails if the cache line had been mapped via the TLB and has become unmapped.
32932
d77de738 32933@opindex misize
ddf6fe37 32934@item -misize
d77de738
ML
32935Dump instruction size and location in the assembly code.
32936
d77de738 32937@opindex mpadstruct
ddf6fe37 32938@item -mpadstruct
d77de738
ML
32939This option is deprecated. It pads structures to multiple of 4 bytes,
32940which is incompatible with the SH ABI@.
32941
d77de738 32942@opindex matomic-model=@var{model}
ddf6fe37 32943@item -matomic-model=@var{model}
d77de738
ML
32944Sets the model of atomic operations and additional parameters as a comma
32945separated list. For details on the atomic built-in functions see
32946@ref{__atomic Builtins}. The following models and parameters are supported:
32947
32948@table @samp
32949
32950@item none
32951Disable compiler generated atomic sequences and emit library calls for atomic
32952operations. This is the default if the target is not @code{sh*-*-linux*}.
32953
32954@item soft-gusa
32955Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
32956built-in functions. The generated atomic sequences require additional support
32957from the interrupt/exception handling code of the system and are only suitable
32958for SH3* and SH4* single-core systems. This option is enabled by default when
32959the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
32960this option also partially utilizes the hardware atomic instructions
32961@code{movli.l} and @code{movco.l} to create more efficient code, unless
32962@samp{strict} is specified.
32963
32964@item soft-tcb
32965Generate software atomic sequences that use a variable in the thread control
32966block. This is a variation of the gUSA sequences which can also be used on
32967SH1* and SH2* targets. The generated atomic sequences require additional
32968support from the interrupt/exception handling code of the system and are only
32969suitable for single-core systems. When using this model, the @samp{gbr-offset=}
32970parameter has to be specified as well.
32971
32972@item soft-imask
32973Generate software atomic sequences that temporarily disable interrupts by
32974setting @code{SR.IMASK = 1111}. This model works only when the program runs
32975in privileged mode and is only suitable for single-core systems. Additional
32976support from the interrupt/exception handling code of the system is not
32977required. This model is enabled by default when the target is
32978@code{sh*-*-linux*} and SH1* or SH2*.
32979
32980@item hard-llcs
32981Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
32982instructions only. This is only available on SH4A and is suitable for
32983multi-core systems. Since the hardware instructions support only 32 bit atomic
32984variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
32985Code compiled with this option is also compatible with other software
32986atomic model interrupt/exception handling systems if executed on an SH4A
32987system. Additional support from the interrupt/exception handling code of the
32988system is not required for this model.
32989
32990@item gbr-offset=
32991This parameter specifies the offset in bytes of the variable in the thread
32992control block structure that should be used by the generated atomic sequences
32993when the @samp{soft-tcb} model has been selected. For other models this
32994parameter is ignored. The specified value must be an integer multiple of four
32995and in the range 0-1020.
32996
32997@item strict
32998This parameter prevents mixed usage of multiple atomic models, even if they
32999are compatible, and makes the compiler generate atomic sequences of the
33000specified model only.
33001
33002@end table
33003
d77de738 33004@opindex mtas
ddf6fe37 33005@item -mtas
d77de738
ML
33006Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
33007Notice that depending on the particular hardware and software configuration
33008this can degrade overall performance due to the operand cache line flushes
33009that are implied by the @code{tas.b} instruction. On multi-core SH4A
33010processors the @code{tas.b} instruction must be used with caution since it
33011can result in data corruption for certain cache configurations.
33012
d77de738 33013@opindex mprefergot
ddf6fe37 33014@item -mprefergot
d77de738
ML
33015When generating position-independent code, emit function calls using
33016the Global Offset Table instead of the Procedure Linkage Table.
33017
d77de738
ML
33018@opindex musermode
33019@opindex mno-usermode
ddf6fe37
AA
33020@item -musermode
33021@itemx -mno-usermode
d77de738
ML
33022Don't allow (allow) the compiler generating privileged mode code. Specifying
33023@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
33024inlined code would not work in user mode. @option{-musermode} is the default
33025when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
33026@option{-musermode} has no effect, since there is no user mode.
33027
d77de738 33028@opindex multcost=@var{number}
ddf6fe37 33029@item -multcost=@var{number}
d77de738
ML
33030Set the cost to assume for a multiply insn.
33031
d77de738 33032@opindex mdiv=@var{strategy}
ddf6fe37 33033@item -mdiv=@var{strategy}
d77de738
ML
33034Set the division strategy to be used for integer division operations.
33035@var{strategy} can be one of:
33036
33037@table @samp
33038
33039@item call-div1
33040Calls a library function that uses the single-step division instruction
33041@code{div1} to perform the operation. Division by zero calculates an
33042unspecified result and does not trap. This is the default except for SH4,
33043SH2A and SHcompact.
33044
33045@item call-fp
33046Calls a library function that performs the operation in double precision
33047floating point. Division by zero causes a floating-point exception. This is
33048the default for SHcompact with FPU. Specifying this for targets that do not
33049have a double precision FPU defaults to @code{call-div1}.
33050
33051@item call-table
33052Calls a library function that uses a lookup table for small divisors and
33053the @code{div1} instruction with case distinction for larger divisors. Division
33054by zero calculates an unspecified result and does not trap. This is the default
33055for SH4. Specifying this for targets that do not have dynamic shift
33056instructions defaults to @code{call-div1}.
33057
33058@end table
33059
33060When a division strategy has not been specified the default strategy is
33061selected based on the current target. For SH2A the default strategy is to
33062use the @code{divs} and @code{divu} instructions instead of library function
33063calls.
33064
d77de738 33065@opindex maccumulate-outgoing-args
ddf6fe37 33066@item -maccumulate-outgoing-args
d77de738
ML
33067Reserve space once for outgoing arguments in the function prologue rather
33068than around each call. Generally beneficial for performance and size. Also
33069needed for unwinding to avoid changing the stack frame around conditional code.
33070
d77de738 33071@opindex mdivsi3_libfunc=@var{name}
ddf6fe37 33072@item -mdivsi3_libfunc=@var{name}
d77de738
ML
33073Set the name of the library function used for 32-bit signed division to
33074@var{name}.
33075This only affects the name used in the @samp{call} division strategies, and
33076the compiler still expects the same sets of input/output/clobbered registers as
33077if this option were not present.
33078
d77de738 33079@opindex mfixed-range
ddf6fe37 33080@item -mfixed-range=@var{register-range}
d77de738
ML
33081Generate code treating the given register range as fixed registers.
33082A fixed register is one that the register allocator cannot use. This is
33083useful when compiling kernel code. A register range is specified as
33084two registers separated by a dash. Multiple register ranges can be
33085specified separated by a comma.
33086
d77de738 33087@opindex mbranch-cost=@var{num}
ddf6fe37 33088@item -mbranch-cost=@var{num}
d77de738
ML
33089Assume @var{num} to be the cost for a branch instruction. Higher numbers
33090make the compiler try to generate more branch-free code if possible.
33091If not specified the value is selected depending on the processor type that
33092is being compiled for.
33093
d77de738
ML
33094@opindex mzdcbranch
33095@opindex mno-zdcbranch
ddf6fe37
AA
33096@item -mzdcbranch
33097@itemx -mno-zdcbranch
d77de738
ML
33098Assume (do not assume) that zero displacement conditional branch instructions
33099@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
33100compiler prefers zero displacement branch code sequences. This is
33101enabled by default when generating code for SH4 and SH4A. It can be explicitly
33102disabled by specifying @option{-mno-zdcbranch}.
33103
d77de738 33104@opindex mcbranch-force-delay-slot
ddf6fe37 33105@item -mcbranch-force-delay-slot
d77de738
ML
33106Force the usage of delay slots for conditional branches, which stuffs the delay
33107slot with a @code{nop} if a suitable instruction cannot be found. By default
33108this option is disabled. It can be enabled to work around hardware bugs as
33109found in the original SH7055.
33110
d77de738
ML
33111@opindex mfused-madd
33112@opindex mno-fused-madd
ddf6fe37
AA
33113@item -mfused-madd
33114@itemx -mno-fused-madd
d77de738
ML
33115Generate code that uses (does not use) the floating-point multiply and
33116accumulate instructions. These instructions are generated by default
33117if hardware floating point is used. The machine-dependent
33118@option{-mfused-madd} option is now mapped to the machine-independent
33119@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
33120mapped to @option{-ffp-contract=off}.
33121
d77de738
ML
33122@opindex mfsca
33123@opindex mno-fsca
ddf6fe37
AA
33124@item -mfsca
33125@itemx -mno-fsca
d77de738
ML
33126Allow or disallow the compiler to emit the @code{fsca} instruction for sine
33127and cosine approximations. The option @option{-mfsca} must be used in
33128combination with @option{-funsafe-math-optimizations}. It is enabled by default
33129when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
33130approximations even if @option{-funsafe-math-optimizations} is in effect.
33131
d77de738
ML
33132@opindex mfsrra
33133@opindex mno-fsrra
ddf6fe37
AA
33134@item -mfsrra
33135@itemx -mno-fsrra
d77de738
ML
33136Allow or disallow the compiler to emit the @code{fsrra} instruction for
33137reciprocal square root approximations. The option @option{-mfsrra} must be used
33138in combination with @option{-funsafe-math-optimizations} and
33139@option{-ffinite-math-only}. It is enabled by default when generating code for
33140SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
33141even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
33142in effect.
33143
d77de738 33144@opindex mpretend-cmove
ddf6fe37 33145@item -mpretend-cmove
d77de738
ML
33146Prefer zero-displacement conditional branches for conditional move instruction
33147patterns. This can result in faster code on the SH4 processor.
33148
d77de738 33149@opindex fdpic
ddf6fe37 33150@item -mfdpic
d77de738
ML
33151Generate code using the FDPIC ABI.
33152
33153@end table
33154
33155@node Solaris 2 Options
33156@subsection Solaris 2 Options
33157@cindex Solaris 2 options
33158
33159These @samp{-m} options are supported on Solaris 2:
33160
33161@table @gcctabopt
d77de738 33162@opindex mclear-hwcap
ddf6fe37 33163@item -mclear-hwcap
d77de738
ML
33164@option{-mclear-hwcap} tells the compiler to remove the hardware
33165capabilities generated by the Solaris assembler. This is only necessary
33166when object files use ISA extensions not supported by the current
33167machine, but check at runtime whether or not to use them.
33168
d77de738 33169@opindex mimpure-text
ddf6fe37 33170@item -mimpure-text
d77de738
ML
33171@option{-mimpure-text}, used in addition to @option{-shared}, tells
33172the compiler to not pass @option{-z text} to the linker when linking a
33173shared object. Using this option, you can link position-dependent
33174code into a shared object.
33175
33176@option{-mimpure-text} suppresses the ``relocations remain against
33177allocatable but non-writable sections'' linker error message.
33178However, the necessary relocations trigger copy-on-write, and the
33179shared object is not actually shared across processes. Instead of
33180using @option{-mimpure-text}, you should compile all source code with
33181@option{-fpic} or @option{-fPIC}.
33182
33183@end table
33184
33185These switches are supported in addition to the above on Solaris 2:
33186
33187@table @gcctabopt
d77de738 33188@opindex pthreads
ddf6fe37 33189@item -pthreads
d77de738
ML
33190This is a synonym for @option{-pthread}.
33191@end table
33192
33193@node SPARC Options
33194@subsection SPARC Options
33195@cindex SPARC options
33196
33197These @samp{-m} options are supported on the SPARC:
33198
33199@table @gcctabopt
d77de738
ML
33200@opindex mno-app-regs
33201@opindex mapp-regs
ddf6fe37
AA
33202@item -mno-app-regs
33203@itemx -mapp-regs
d77de738
ML
33204Specify @option{-mapp-regs} to generate output using the global registers
332052 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
33206global register 1, each global register 2 through 4 is then treated as an
33207allocable register that is clobbered by function calls. This is the default.
33208
33209To be fully SVR4 ABI-compliant at the cost of some performance loss,
33210specify @option{-mno-app-regs}. You should compile libraries and system
33211software with this option.
33212
d77de738
ML
33213@opindex mflat
33214@opindex mno-flat
ddf6fe37
AA
33215@item -mflat
33216@itemx -mno-flat
d77de738
ML
33217With @option{-mflat}, the compiler does not generate save/restore instructions
33218and uses a ``flat'' or single register window model. This model is compatible
33219with the regular register window model. The local registers and the input
33220registers (0--5) are still treated as ``call-saved'' registers and are
33221saved on the stack as needed.
33222
33223With @option{-mno-flat} (the default), the compiler generates save/restore
33224instructions (except for leaf functions). This is the normal operating mode.
33225
d77de738
ML
33226@opindex mfpu
33227@opindex mhard-float
ddf6fe37
AA
33228@item -mfpu
33229@itemx -mhard-float
d77de738
ML
33230Generate output containing floating-point instructions. This is the
33231default.
33232
d77de738
ML
33233@opindex mno-fpu
33234@opindex msoft-float
ddf6fe37
AA
33235@item -mno-fpu
33236@itemx -msoft-float
d77de738
ML
33237Generate output containing library calls for floating point.
33238@strong{Warning:} the requisite libraries are not available for all SPARC
33239targets. Normally the facilities of the machine's usual C compiler are
33240used, but this cannot be done directly in cross-compilation. You must make
33241your own arrangements to provide suitable library functions for
33242cross-compilation. The embedded targets @samp{sparc-*-aout} and
33243@samp{sparclite-*-*} do provide software floating-point support.
33244
33245@option{-msoft-float} changes the calling convention in the output file;
33246therefore, it is only useful if you compile @emph{all} of a program with
33247this option. In particular, you need to compile @file{libgcc.a}, the
33248library that comes with GCC, with @option{-msoft-float} in order for
33249this to work.
33250
d77de738 33251@opindex mhard-quad-float
ddf6fe37 33252@item -mhard-quad-float
d77de738
ML
33253Generate output containing quad-word (long double) floating-point
33254instructions.
33255
d77de738 33256@opindex msoft-quad-float
ddf6fe37 33257@item -msoft-quad-float
d77de738
ML
33258Generate output containing library calls for quad-word (long double)
33259floating-point instructions. The functions called are those specified
33260in the SPARC ABI@. This is the default.
33261
33262As of this writing, there are no SPARC implementations that have hardware
33263support for the quad-word floating-point instructions. They all invoke
33264a trap handler for one of these instructions, and then the trap handler
33265emulates the effect of the instruction. Because of the trap handler overhead,
33266this is much slower than calling the ABI library routines. Thus the
33267@option{-msoft-quad-float} option is the default.
33268
d77de738
ML
33269@opindex mno-unaligned-doubles
33270@opindex munaligned-doubles
ddf6fe37
AA
33271@item -mno-unaligned-doubles
33272@itemx -munaligned-doubles
d77de738
ML
33273Assume that doubles have 8-byte alignment. This is the default.
33274
33275With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
33276alignment only if they are contained in another type, or if they have an
33277absolute address. Otherwise, it assumes they have 4-byte alignment.
33278Specifying this option avoids some rare compatibility problems with code
33279generated by other compilers. It is not the default because it results
33280in a performance loss, especially for floating-point code.
33281
d77de738
ML
33282@opindex muser-mode
33283@opindex mno-user-mode
ddf6fe37
AA
33284@item -muser-mode
33285@itemx -mno-user-mode
d77de738
ML
33286Do not generate code that can only run in supervisor mode. This is relevant
33287only for the @code{casa} instruction emitted for the LEON3 processor. This
33288is the default.
33289
d77de738
ML
33290@opindex mfaster-structs
33291@opindex mno-faster-structs
ddf6fe37
AA
33292@item -mfaster-structs
33293@itemx -mno-faster-structs
d77de738
ML
33294With @option{-mfaster-structs}, the compiler assumes that structures
33295should have 8-byte alignment. This enables the use of pairs of
33296@code{ldd} and @code{std} instructions for copies in structure
33297assignment, in place of twice as many @code{ld} and @code{st} pairs.
33298However, the use of this changed alignment directly violates the SPARC
33299ABI@. Thus, it's intended only for use on targets where the developer
33300acknowledges that their resulting code is not directly in line with
33301the rules of the ABI@.
33302
d77de738
ML
33303@opindex mstd-struct-return
33304@opindex mno-std-struct-return
ddf6fe37
AA
33305@item -mstd-struct-return
33306@itemx -mno-std-struct-return
d77de738
ML
33307With @option{-mstd-struct-return}, the compiler generates checking code
33308in functions returning structures or unions to detect size mismatches
33309between the two sides of function calls, as per the 32-bit ABI@.
33310
33311The default is @option{-mno-std-struct-return}. This option has no effect
33312in 64-bit mode.
33313
d77de738
ML
33314@opindex mlra
33315@opindex mno-lra
ddf6fe37
AA
33316@item -mlra
33317@itemx -mno-lra
d77de738
ML
33318Enable Local Register Allocation. This is the default for SPARC since GCC 7
33319so @option{-mno-lra} needs to be passed to get old Reload.
33320
d77de738 33321@opindex mcpu
ddf6fe37 33322@item -mcpu=@var{cpu_type}
d77de738
ML
33323Set the instruction set, register set, and instruction scheduling parameters
33324for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
33325@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
33326@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
33327@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
33328@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
33329@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
33330@samp{m8}.
33331
33332Native Solaris and GNU/Linux toolchains also support the value @samp{native},
33333which selects the best architecture option for the host processor.
33334@option{-mcpu=native} has no effect if GCC does not recognize
33335the processor.
33336
33337Default instruction scheduling parameters are used for values that select
33338an architecture and not an implementation. These are @samp{v7}, @samp{v8},
33339@samp{sparclite}, @samp{sparclet}, @samp{v9}.
33340
33341Here is a list of each supported architecture and their supported
33342implementations.
33343
33344@table @asis
33345@item v7
33346cypress, leon3v7
33347
33348@item v8
33349supersparc, hypersparc, leon, leon3, leon5
33350
33351@item sparclite
33352f930, f934, sparclite86x
33353
33354@item sparclet
33355tsc701
33356
33357@item v9
33358ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
33359niagara7, m8
33360@end table
33361
33362By default (unless configured otherwise), GCC generates code for the V7
33363variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
33364additionally optimizes it for the Cypress CY7C602 chip, as used in the
33365SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
33366SPARCStation 1, 2, IPX etc.
33367
33368With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
33369architecture. The only difference from V7 code is that the compiler emits
33370the integer multiply and integer divide instructions which exist in SPARC-V8
33371but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
33372optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
333732000 series.
33374
33375With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
33376the SPARC architecture. This adds the integer multiply, integer divide step
33377and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
33378With @option{-mcpu=f930}, the compiler additionally optimizes it for the
33379Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
33380@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
33381MB86934 chip, which is the more recent SPARClite with FPU@.
33382
33383With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
33384the SPARC architecture. This adds the integer multiply, multiply/accumulate,
33385integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
33386but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
33387optimizes it for the TEMIC SPARClet chip.
33388
33389With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
33390architecture. This adds 64-bit integer and floating-point move instructions,
333913 additional floating-point condition code registers and conditional move
33392instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
33393optimizes it for the Sun UltraSPARC I/II/IIi chips. With
33394@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
33395Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
33396@option{-mcpu=niagara}, the compiler additionally optimizes it for
33397Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
33398additionally optimizes it for Sun UltraSPARC T2 chips. With
33399@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
33400UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
33401additionally optimizes it for Sun UltraSPARC T4 chips. With
33402@option{-mcpu=niagara7}, the compiler additionally optimizes it for
33403Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
33404additionally optimizes it for Oracle M8 chips.
33405
d77de738 33406@opindex mtune
ddf6fe37 33407@item -mtune=@var{cpu_type}
d77de738
ML
33408Set the instruction scheduling parameters for machine type
33409@var{cpu_type}, but do not set the instruction set or register set that the
33410option @option{-mcpu=@var{cpu_type}} does.
33411
33412The same values for @option{-mcpu=@var{cpu_type}} can be used for
33413@option{-mtune=@var{cpu_type}}, but the only useful values are those
33414that select a particular CPU implementation. Those are
33415@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
33416@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
33417@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
33418@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
33419@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
33420and GNU/Linux toolchains, @samp{native} can also be used.
33421
d77de738
ML
33422@opindex mv8plus
33423@opindex mno-v8plus
ddf6fe37
AA
33424@item -mv8plus
33425@itemx -mno-v8plus
d77de738
ML
33426With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
33427difference from the V8 ABI is that the global and out registers are
33428considered 64 bits wide. This is enabled by default on Solaris in 32-bit
33429mode for all SPARC-V9 processors.
33430
d77de738
ML
33431@opindex mvis
33432@opindex mno-vis
ddf6fe37
AA
33433@item -mvis
33434@itemx -mno-vis
d77de738
ML
33435With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
33436Visual Instruction Set extensions. The default is @option{-mno-vis}.
33437
d77de738
ML
33438@opindex mvis2
33439@opindex mno-vis2
ddf6fe37
AA
33440@item -mvis2
33441@itemx -mno-vis2
d77de738
ML
33442With @option{-mvis2}, GCC generates code that takes advantage of
33443version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
33444default is @option{-mvis2} when targeting a cpu that supports such
33445instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
33446also sets @option{-mvis}.
33447
d77de738
ML
33448@opindex mvis3
33449@opindex mno-vis3
ddf6fe37
AA
33450@item -mvis3
33451@itemx -mno-vis3
d77de738
ML
33452With @option{-mvis3}, GCC generates code that takes advantage of
33453version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
33454default is @option{-mvis3} when targeting a cpu that supports such
33455instructions, such as niagara-3 and later. Setting @option{-mvis3}
33456also sets @option{-mvis2} and @option{-mvis}.
33457
d77de738
ML
33458@opindex mvis4
33459@opindex mno-vis4
ddf6fe37
AA
33460@item -mvis4
33461@itemx -mno-vis4
d77de738
ML
33462With @option{-mvis4}, GCC generates code that takes advantage of
33463version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
33464default is @option{-mvis4} when targeting a cpu that supports such
33465instructions, such as niagara-7 and later. Setting @option{-mvis4}
33466also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
33467
d77de738
ML
33468@opindex mvis4b
33469@opindex mno-vis4b
ddf6fe37
AA
33470@item -mvis4b
33471@itemx -mno-vis4b
d77de738
ML
33472With @option{-mvis4b}, GCC generates code that takes advantage of
33473version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
33474the additional VIS instructions introduced in the Oracle SPARC
33475Architecture 2017. The default is @option{-mvis4b} when targeting a
33476cpu that supports such instructions, such as m8 and later. Setting
33477@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
33478@option{-mvis2} and @option{-mvis}.
33479
d77de738
ML
33480@opindex mcbcond
33481@opindex mno-cbcond
ddf6fe37
AA
33482@item -mcbcond
33483@itemx -mno-cbcond
d77de738
ML
33484With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
33485Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
33486when targeting a CPU that supports such instructions, such as Niagara-4 and
33487later.
33488
d77de738
ML
33489@opindex mfmaf
33490@opindex mno-fmaf
ddf6fe37
AA
33491@item -mfmaf
33492@itemx -mno-fmaf
d77de738
ML
33493With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
33494Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
33495when targeting a CPU that supports such instructions, such as Niagara-3 and
33496later.
33497
d77de738
ML
33498@opindex mfsmuld
33499@opindex mno-fsmuld
ddf6fe37
AA
33500@item -mfsmuld
33501@itemx -mno-fsmuld
d77de738
ML
33502With @option{-mfsmuld}, GCC generates code that takes advantage of the
33503Floating-point Multiply Single to Double (FsMULd) instruction. The default is
33504@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
33505or V9 with FPU except @option{-mcpu=leon}.
33506
d77de738
ML
33507@opindex mpopc
33508@opindex mno-popc
ddf6fe37
AA
33509@item -mpopc
33510@itemx -mno-popc
d77de738
ML
33511With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
33512Population Count instruction. The default is @option{-mpopc}
33513when targeting a CPU that supports such an instruction, such as Niagara-2 and
33514later.
33515
d77de738
ML
33516@opindex msubxc
33517@opindex mno-subxc
ddf6fe37
AA
33518@item -msubxc
33519@itemx -mno-subxc
d77de738
ML
33520With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
33521Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
33522when targeting a CPU that supports such an instruction, such as Niagara-7 and
33523later.
33524
d77de738 33525@opindex mfix-at697f
ddf6fe37 33526@item -mfix-at697f
d77de738
ML
33527Enable the documented workaround for the single erratum of the Atmel AT697F
33528processor (which corresponds to erratum #13 of the AT697E processor).
33529
d77de738 33530@opindex mfix-ut699
ddf6fe37 33531@item -mfix-ut699
d77de738
ML
33532Enable the documented workarounds for the floating-point errata and the data
33533cache nullify errata of the UT699 processor.
33534
d77de738 33535@opindex mfix-ut700
ddf6fe37 33536@item -mfix-ut700
d77de738
ML
33537Enable the documented workaround for the back-to-back store errata of
33538the UT699E/UT700 processor.
33539
d77de738 33540@opindex mfix-gr712rc
ddf6fe37 33541@item -mfix-gr712rc
d77de738
ML
33542Enable the documented workaround for the back-to-back store errata of
33543the GR712RC processor.
33544@end table
33545
33546These @samp{-m} options are supported in addition to the above
33547on SPARC-V9 processors in 64-bit environments:
33548
33549@table @gcctabopt
d77de738
ML
33550@opindex m32
33551@opindex m64
ddf6fe37
AA
33552@item -m32
33553@itemx -m64
d77de738
ML
33554Generate code for a 32-bit or 64-bit environment.
33555The 32-bit environment sets int, long and pointer to 32 bits.
33556The 64-bit environment sets int to 32 bits and long and pointer
33557to 64 bits.
33558
d77de738 33559@opindex mcmodel
ddf6fe37 33560@item -mcmodel=@var{which}
d77de738
ML
33561Set the code model to one of
33562
33563@table @samp
33564@item medlow
33565The Medium/Low code model: 64-bit addresses, programs
33566must be linked in the low 32 bits of memory. Programs can be statically
33567or dynamically linked.
33568
33569@item medmid
33570The Medium/Middle code model: 64-bit addresses, programs
33571must be linked in the low 44 bits of memory, the text and data segments must
33572be less than 2GB in size and the data segment must be located within 2GB of
33573the text segment.
33574
33575@item medany
33576The Medium/Anywhere code model: 64-bit addresses, programs
33577may be linked anywhere in memory, the text and data segments must be less
33578than 2GB in size and the data segment must be located within 2GB of the
33579text segment.
33580
33581@item embmedany
33582The Medium/Anywhere code model for embedded systems:
3358364-bit addresses, the text and data segments must be less than 2GB in
33584size, both starting anywhere in memory (determined at link time). The
33585global register %g4 points to the base of the data segment. Programs
33586are statically linked and PIC is not supported.
33587@end table
33588
d77de738 33589@opindex mmemory-model
ddf6fe37 33590@item -mmemory-model=@var{mem-model}
d77de738
ML
33591Set the memory model in force on the processor to one of
33592
33593@table @samp
33594@item default
33595The default memory model for the processor and operating system.
33596
33597@item rmo
33598Relaxed Memory Order
33599
33600@item pso
33601Partial Store Order
33602
33603@item tso
33604Total Store Order
33605
33606@item sc
33607Sequential Consistency
33608@end table
33609
33610These memory models are formally defined in Appendix D of the SPARC-V9
33611architecture manual, as set in the processor's @code{PSTATE.MM} field.
33612
d77de738
ML
33613@opindex mstack-bias
33614@opindex mno-stack-bias
ddf6fe37
AA
33615@item -mstack-bias
33616@itemx -mno-stack-bias
d77de738
ML
33617With @option{-mstack-bias}, GCC assumes that the stack pointer, and
33618frame pointer if present, are offset by @minus{}2047 which must be added back
33619when making stack frame references. This is the default in 64-bit mode.
33620Otherwise, assume no such offset is present.
33621@end table
33622
33623@node System V Options
33624@subsection Options for System V
33625
33626These additional options are available on System V Release 4 for
33627compatibility with other compilers on those systems:
33628
33629@table @gcctabopt
d77de738 33630@opindex G
ddf6fe37 33631@item -G
d77de738
ML
33632Create a shared object.
33633It is recommended that @option{-symbolic} or @option{-shared} be used instead.
33634
d77de738 33635@opindex Qy
ddf6fe37 33636@item -Qy
d77de738
ML
33637Identify the versions of each tool used by the compiler, in a
33638@code{.ident} assembler directive in the output.
33639
d77de738 33640@opindex Qn
ddf6fe37 33641@item -Qn
d77de738
ML
33642Refrain from adding @code{.ident} directives to the output file (this is
33643the default).
33644
d77de738 33645@opindex YP
ddf6fe37 33646@item -YP,@var{dirs}
d77de738
ML
33647Search the directories @var{dirs}, and no others, for libraries
33648specified with @option{-l}.
33649
d77de738 33650@opindex Ym
ddf6fe37 33651@item -Ym,@var{dir}
d77de738
ML
33652Look in the directory @var{dir} to find the M4 preprocessor.
33653The assembler uses this option.
33654@c This is supposed to go with a -Yd for predefined M4 macro files, but
33655@c the generic assembler that comes with Solaris takes just -Ym.
33656@end table
33657
33658@node V850 Options
33659@subsection V850 Options
33660@cindex V850 Options
33661
33662These @samp{-m} options are defined for V850 implementations:
33663
33664@table @gcctabopt
d77de738
ML
33665@opindex mlong-calls
33666@opindex mno-long-calls
ddf6fe37
AA
33667@item -mlong-calls
33668@itemx -mno-long-calls
d77de738
ML
33669Treat all calls as being far away (near). If calls are assumed to be
33670far away, the compiler always loads the function's address into a
33671register, and calls indirect through the pointer.
33672
d77de738
ML
33673@opindex mno-ep
33674@opindex mep
ddf6fe37
AA
33675@item -mno-ep
33676@itemx -mep
d77de738
ML
33677Do not optimize (do optimize) basic blocks that use the same index
33678pointer 4 or more times to copy pointer into the @code{ep} register, and
33679use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
33680option is on by default if you optimize.
33681
d77de738
ML
33682@opindex mno-prolog-function
33683@opindex mprolog-function
ddf6fe37
AA
33684@item -mno-prolog-function
33685@itemx -mprolog-function
d77de738
ML
33686Do not use (do use) external functions to save and restore registers
33687at the prologue and epilogue of a function. The external functions
33688are slower, but use less code space if more than one function saves
33689the same number of registers. The @option{-mprolog-function} option
33690is on by default if you optimize.
33691
d77de738 33692@opindex mspace
ddf6fe37 33693@item -mspace
d77de738
ML
33694Try to make the code as small as possible. At present, this just turns
33695on the @option{-mep} and @option{-mprolog-function} options.
33696
d77de738 33697@opindex mtda
ddf6fe37 33698@item -mtda=@var{n}
d77de738
ML
33699Put static or global variables whose size is @var{n} bytes or less into
33700the tiny data area that register @code{ep} points to. The tiny data
33701area can hold up to 256 bytes in total (128 bytes for byte references).
33702
d77de738 33703@opindex msda
ddf6fe37 33704@item -msda=@var{n}
d77de738
ML
33705Put static or global variables whose size is @var{n} bytes or less into
33706the small data area that register @code{gp} points to. The small data
33707area can hold up to 64 kilobytes.
33708
d77de738 33709@opindex mzda
ddf6fe37 33710@item -mzda=@var{n}
d77de738
ML
33711Put static or global variables whose size is @var{n} bytes or less into
33712the first 32 kilobytes of memory.
33713
d77de738 33714@opindex mv850
ddf6fe37 33715@item -mv850
d77de738
ML
33716Specify that the target processor is the V850.
33717
d77de738 33718@opindex mv850e3v5
ddf6fe37 33719@item -mv850e3v5
d77de738
ML
33720Specify that the target processor is the V850E3V5. The preprocessor
33721constant @code{__v850e3v5__} is defined if this option is used.
33722
d77de738 33723@opindex mv850e2v4
ddf6fe37 33724@item -mv850e2v4
d77de738
ML
33725Specify that the target processor is the V850E3V5. This is an alias for
33726the @option{-mv850e3v5} option.
33727
d77de738 33728@opindex mv850e2v3
ddf6fe37 33729@item -mv850e2v3
d77de738
ML
33730Specify that the target processor is the V850E2V3. The preprocessor
33731constant @code{__v850e2v3__} is defined if this option is used.
33732
d77de738 33733@opindex mv850e2
ddf6fe37 33734@item -mv850e2
d77de738
ML
33735Specify that the target processor is the V850E2. The preprocessor
33736constant @code{__v850e2__} is defined if this option is used.
33737
d77de738 33738@opindex mv850e1
ddf6fe37 33739@item -mv850e1
d77de738
ML
33740Specify that the target processor is the V850E1. The preprocessor
33741constants @code{__v850e1__} and @code{__v850e__} are defined if
33742this option is used.
33743
d77de738 33744@opindex mv850es
ddf6fe37 33745@item -mv850es
d77de738
ML
33746Specify that the target processor is the V850ES. This is an alias for
33747the @option{-mv850e1} option.
33748
d77de738 33749@opindex mv850e
ddf6fe37 33750@item -mv850e
d77de738
ML
33751Specify that the target processor is the V850E@. The preprocessor
33752constant @code{__v850e__} is defined if this option is used.
33753
33754If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
33755nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
33756are defined then a default target processor is chosen and the
33757relevant @samp{__v850*__} preprocessor constant is defined.
33758
33759The preprocessor constants @code{__v850} and @code{__v851__} are always
33760defined, regardless of which processor variant is the target.
33761
d77de738
ML
33762@opindex mdisable-callt
33763@opindex mno-disable-callt
ddf6fe37
AA
33764@item -mdisable-callt
33765@itemx -mno-disable-callt
d77de738
ML
33766This option suppresses generation of the @code{CALLT} instruction for the
33767v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
33768architecture.
33769
33770This option is enabled by default when the RH850 ABI is
33771in use (see @option{-mrh850-abi}), and disabled by default when the
33772GCC ABI is in use. If @code{CALLT} instructions are being generated
33773then the C preprocessor symbol @code{__V850_CALLT__} is defined.
33774
d77de738
ML
33775@opindex mrelax
33776@opindex mno-relax
ddf6fe37
AA
33777@item -mrelax
33778@itemx -mno-relax
d77de738
ML
33779Pass on (or do not pass on) the @option{-mrelax} command-line option
33780to the assembler.
33781
d77de738
ML
33782@opindex mlong-jumps
33783@opindex mno-long-jumps
ddf6fe37
AA
33784@item -mlong-jumps
33785@itemx -mno-long-jumps
d77de738
ML
33786Disable (or re-enable) the generation of PC-relative jump instructions.
33787
d77de738
ML
33788@opindex msoft-float
33789@opindex mhard-float
ddf6fe37
AA
33790@item -msoft-float
33791@itemx -mhard-float
d77de738
ML
33792Disable (or re-enable) the generation of hardware floating point
33793instructions. This option is only significant when the target
33794architecture is @samp{V850E2V3} or higher. If hardware floating point
33795instructions are being generated then the C preprocessor symbol
33796@code{__FPU_OK__} is defined, otherwise the symbol
33797@code{__NO_FPU__} is defined.
33798
d77de738 33799@opindex mloop
ddf6fe37 33800@item -mloop
d77de738
ML
33801Enables the use of the e3v5 LOOP instruction. The use of this
33802instruction is not enabled by default when the e3v5 architecture is
33803selected because its use is still experimental.
33804
d77de738
ML
33805@opindex mrh850-abi
33806@opindex mghs
ddf6fe37
AA
33807@item -mrh850-abi
33808@itemx -mghs
d77de738
ML
33809Enables support for the RH850 version of the V850 ABI. This is the
33810default. With this version of the ABI the following rules apply:
33811
33812@itemize
33813@item
33814Integer sized structures and unions are returned via a memory pointer
33815rather than a register.
33816
33817@item
33818Large structures and unions (more than 8 bytes in size) are passed by
33819value.
33820
33821@item
33822Functions are aligned to 16-bit boundaries.
33823
33824@item
33825The @option{-m8byte-align} command-line option is supported.
33826
33827@item
33828The @option{-mdisable-callt} command-line option is enabled by
33829default. The @option{-mno-disable-callt} command-line option is not
33830supported.
33831@end itemize
33832
33833When this version of the ABI is enabled the C preprocessor symbol
33834@code{__V850_RH850_ABI__} is defined.
33835
d77de738 33836@opindex mgcc-abi
ddf6fe37 33837@item -mgcc-abi
d77de738
ML
33838Enables support for the old GCC version of the V850 ABI. With this
33839version of the ABI the following rules apply:
33840
33841@itemize
33842@item
33843Integer sized structures and unions are returned in register @code{r10}.
33844
33845@item
33846Large structures and unions (more than 8 bytes in size) are passed by
33847reference.
33848
33849@item
33850Functions are aligned to 32-bit boundaries, unless optimizing for
33851size.
33852
33853@item
33854The @option{-m8byte-align} command-line option is not supported.
33855
33856@item
33857The @option{-mdisable-callt} command-line option is supported but not
33858enabled by default.
33859@end itemize
33860
33861When this version of the ABI is enabled the C preprocessor symbol
33862@code{__V850_GCC_ABI__} is defined.
33863
d77de738
ML
33864@opindex m8byte-align
33865@opindex mno-8byte-align
ddf6fe37
AA
33866@item -m8byte-align
33867@itemx -mno-8byte-align
d77de738
ML
33868Enables support for @code{double} and @code{long long} types to be
33869aligned on 8-byte boundaries. The default is to restrict the
33870alignment of all objects to at most 4-bytes. When
33871@option{-m8byte-align} is in effect the C preprocessor symbol
33872@code{__V850_8BYTE_ALIGN__} is defined.
33873
d77de738 33874@opindex mbig-switch
ddf6fe37 33875@item -mbig-switch
d77de738
ML
33876Generate code suitable for big switch tables. Use this option only if
33877the assembler/linker complain about out of range branches within a switch
33878table.
33879
d77de738 33880@opindex mapp-regs
ddf6fe37 33881@item -mapp-regs
d77de738
ML
33882This option causes r2 and r5 to be used in the code generated by
33883the compiler. This setting is the default.
33884
d77de738 33885@opindex mno-app-regs
ddf6fe37 33886@item -mno-app-regs
d77de738
ML
33887This option causes r2 and r5 to be treated as fixed registers.
33888
33889@end table
33890
33891@node VAX Options
33892@subsection VAX Options
33893@cindex VAX options
33894
33895These @samp{-m} options are defined for the VAX:
33896
33897@table @gcctabopt
d77de738 33898@opindex munix
ddf6fe37 33899@item -munix
d77de738
ML
33900Do not output certain jump instructions (@code{aobleq} and so on)
33901that the Unix assembler for the VAX cannot handle across long
33902ranges.
33903
d77de738 33904@opindex mgnu
ddf6fe37 33905@item -mgnu
d77de738
ML
33906Do output those jump instructions, on the assumption that the
33907GNU assembler is being used.
33908
d77de738 33909@opindex mg
ddf6fe37 33910@item -mg
d77de738
ML
33911Output code for G-format floating-point numbers instead of D-format.
33912
d77de738
ML
33913@opindex mlra
33914@opindex mno-lra
ddf6fe37
AA
33915@item -mlra
33916@itemx -mno-lra
d77de738
ML
33917Enable Local Register Allocation. This is still experimental for the VAX,
33918so by default the compiler uses standard reload.
33919@end table
33920
33921@node Visium Options
33922@subsection Visium Options
33923@cindex Visium options
33924
33925@table @gcctabopt
33926
d77de738 33927@opindex mdebug
ddf6fe37 33928@item -mdebug
d77de738
ML
33929A program which performs file I/O and is destined to run on an MCM target
33930should be linked with this option. It causes the libraries libc.a and
33931libdebug.a to be linked. The program should be run on the target under
33932the control of the GDB remote debugging stub.
33933
d77de738 33934@opindex msim
ddf6fe37 33935@item -msim
d77de738
ML
33936A program which performs file I/O and is destined to run on the simulator
33937should be linked with option. This causes libraries libc.a and libsim.a to
33938be linked.
33939
d77de738
ML
33940@opindex mfpu
33941@opindex mhard-float
ddf6fe37
AA
33942@item -mfpu
33943@itemx -mhard-float
d77de738
ML
33944Generate code containing floating-point instructions. This is the
33945default.
33946
d77de738
ML
33947@opindex mno-fpu
33948@opindex msoft-float
ddf6fe37
AA
33949@item -mno-fpu
33950@itemx -msoft-float
d77de738
ML
33951Generate code containing library calls for floating-point.
33952
33953@option{-msoft-float} changes the calling convention in the output file;
33954therefore, it is only useful if you compile @emph{all} of a program with
33955this option. In particular, you need to compile @file{libgcc.a}, the
33956library that comes with GCC, with @option{-msoft-float} in order for
33957this to work.
33958
d77de738 33959@opindex mcpu
ddf6fe37 33960@item -mcpu=@var{cpu_type}
d77de738
ML
33961Set the instruction set, register set, and instruction scheduling parameters
33962for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
33963@samp{mcm}, @samp{gr5} and @samp{gr6}.
33964
33965@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
33966
33967By default (unless configured otherwise), GCC generates code for the GR5
33968variant of the Visium architecture.
33969
33970With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
33971architecture. The only difference from GR5 code is that the compiler will
33972generate block move instructions.
33973
d77de738 33974@opindex mtune
ddf6fe37 33975@item -mtune=@var{cpu_type}
d77de738
ML
33976Set the instruction scheduling parameters for machine type @var{cpu_type},
33977but do not set the instruction set or register set that the option
33978@option{-mcpu=@var{cpu_type}} would.
33979
d77de738 33980@opindex msv-mode
ddf6fe37 33981@item -msv-mode
d77de738
ML
33982Generate code for the supervisor mode, where there are no restrictions on
33983the access to general registers. This is the default.
33984
d77de738 33985@opindex muser-mode
ddf6fe37 33986@item -muser-mode
d77de738
ML
33987Generate code for the user mode, where the access to some general registers
33988is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
33989mode; on the GR6, only registers r29 to r31 are affected.
33990@end table
33991
33992@node VMS Options
33993@subsection VMS Options
33994
33995These @samp{-m} options are defined for the VMS implementations:
33996
33997@table @gcctabopt
d77de738 33998@opindex mvms-return-codes
ddf6fe37 33999@item -mvms-return-codes
d77de738
ML
34000Return VMS condition codes from @code{main}. The default is to return POSIX-style
34001condition (e.g.@: error) codes.
34002
d77de738 34003@opindex mdebug-main=@var{prefix}
ddf6fe37 34004@item -mdebug-main=@var{prefix}
d77de738
ML
34005Flag the first routine whose name starts with @var{prefix} as the main
34006routine for the debugger.
34007
d77de738 34008@opindex mmalloc64
ddf6fe37 34009@item -mmalloc64
d77de738
ML
34010Default to 64-bit memory allocation routines.
34011
d77de738 34012@opindex mpointer-size=@var{size}
ddf6fe37 34013@item -mpointer-size=@var{size}
d77de738
ML
34014Set the default size of pointers. Possible options for @var{size} are
34015@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
34016for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
34017The later option disables @code{pragma pointer_size}.
34018@end table
34019
34020@node VxWorks Options
34021@subsection VxWorks Options
34022@cindex VxWorks Options
34023
34024The options in this section are defined for all VxWorks targets.
34025Options specific to the target hardware are listed with the other
34026options for that target.
34027
34028@table @gcctabopt
d77de738 34029@opindex mrtp
ddf6fe37 34030@item -mrtp
d77de738
ML
34031GCC can generate code for both VxWorks kernels and real time processes
34032(RTPs). This option switches from the former to the latter. It also
34033defines the preprocessor macro @code{__RTP__}.
34034
b6f4b000
AO
34035@opindex msmp
34036@item -msmp
34037Select SMP runtimes for linking. Not available on architectures other
34038than PowerPC, nor on VxWorks version 7 or later, in which the selection
34039is part of the VxWorks build configuration and the library paths are the
34040same for either choice.
34041
d77de738 34042@opindex non-static
ddf6fe37 34043@item -non-static
d77de738
ML
34044Link an RTP executable against shared libraries rather than static
34045libraries. The options @option{-static} and @option{-shared} can
34046also be used for RTPs (@pxref{Link Options}); @option{-static}
34047is the default.
34048
d77de738
ML
34049@opindex Bstatic
34050@opindex Bdynamic
ddf6fe37
AA
34051@item -Bstatic
34052@itemx -Bdynamic
d77de738
ML
34053These options are passed down to the linker. They are defined for
34054compatibility with Diab.
34055
d77de738 34056@opindex Xbind-lazy
ddf6fe37 34057@item -Xbind-lazy
d77de738
ML
34058Enable lazy binding of function calls. This option is equivalent to
34059@option{-Wl,-z,now} and is defined for compatibility with Diab.
34060
d77de738 34061@opindex Xbind-now
ddf6fe37 34062@item -Xbind-now
d77de738
ML
34063Disable lazy binding of function calls. This option is the default and
34064is defined for compatibility with Diab.
34065@end table
34066
34067@node x86 Options
34068@subsection x86 Options
34069@cindex x86 Options
34070
34071These @samp{-m} options are defined for the x86 family of computers.
34072
34073@table @gcctabopt
34074
d77de738 34075@opindex march
ddf6fe37 34076@item -march=@var{cpu-type}
d77de738
ML
34077Generate instructions for the machine type @var{cpu-type}. In contrast to
34078@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
34079for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
34080to generate code that may not run at all on processors other than the one
34081indicated. Specifying @option{-march=@var{cpu-type}} implies
34082@option{-mtune=@var{cpu-type}}, except where noted otherwise.
34083
34084The choices for @var{cpu-type} are:
34085
34086@table @samp
34087@item native
34088This selects the CPU to generate code for at compilation time by determining
34089the processor type of the compiling machine. Using @option{-march=native}
34090enables all instruction subsets supported by the local machine (hence
34091the result might not run on different machines). Using @option{-mtune=native}
34092produces code optimized for the local machine under the constraints
34093of the selected instruction set.
34094
34095@item x86-64
34096A generic CPU with 64-bit extensions.
34097
34098@item x86-64-v2
34099@itemx x86-64-v3
34100@itemx x86-64-v4
34101These choices for @var{cpu-type} select the corresponding
34102micro-architecture level from the x86-64 psABI. On ABIs other than
34103the x86-64 psABI they select the same CPU features as the x86-64 psABI
34104documents for the particular micro-architecture level.
34105
34106Since these @var{cpu-type} values do not have a corresponding
34107@option{-mtune} setting, using @option{-march} with these values enables
34108generic tuning. Specific tuning can be enabled using the
34109@option{-mtune=@var{other-cpu-type}} option with an appropriate
34110@var{other-cpu-type} value.
34111
34112@item i386
34113Original Intel i386 CPU@.
34114
34115@item i486
34116Intel i486 CPU@. (No scheduling is implemented for this chip.)
34117
34118@item i586
34119@itemx pentium
34120Intel Pentium CPU with no MMX support.
34121
34122@item lakemont
34123Intel Lakemont MCU, based on Intel Pentium CPU.
34124
34125@item pentium-mmx
34126Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
34127
34128@item pentiumpro
34129Intel Pentium Pro CPU@.
34130
34131@item i686
34132When used with @option{-march}, the Pentium Pro
34133instruction set is used, so the code runs on all i686 family chips.
34134When used with @option{-mtune}, it has the same meaning as @samp{generic}.
34135
34136@item pentium2
34137Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
34138set support.
34139
34140@item pentium3
34141@itemx pentium3m
34142Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
34143instruction set support.
34144
34145@item pentium-m
34146Intel Pentium M; low-power version of Intel Pentium III CPU
34147with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
34148notebooks.
34149
34150@item pentium4
34151@itemx pentium4m
34152Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
34153
34154@item prescott
34155Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
34156instruction set support.
34157
34158@item nocona
34159Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
34160SSE2, SSE3 and FXSR instruction set support.
34161
34162@item core2
34163Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
34164SAHF and FXSR instruction set support.
34165
34166@item nehalem
34167Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34168SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
34169
34170@item westmere
34171Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34172SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
34173
34174@item sandybridge
34175Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34176SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
34177support.
34178
34179@item ivybridge
34180Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
34181SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
34182and F16C instruction set support.
34183
34184@item haswell
34185Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34186SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34187F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
34188
34189@item broadwell
34190Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34191SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34192F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
34193instruction set support.
34194
34195@item skylake
34196Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34197SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34198F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34199CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
34200
34201@item bonnell
34202Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
34203instruction set support.
34204
34205@item silvermont
34206Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34207SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
34208instruction set support.
34209
34210@item goldmont
34211Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34212SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
34213RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
34214set support.
34215
34216@item goldmont-plus
34217Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34218SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
34219SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
34220RDPID and SGX instruction set support.
34221
34222@item tremont
34223Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34224SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
34225RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
34226SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
34227support.
34228
34229@item sierraforest
34230Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34231SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34232XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34233MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34234PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
503643e8
LC
34235AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
34236support.
d77de738
ML
34237
34238@item grandridge
34239Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34240SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34241XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34242MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34243PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
9b4f535e
HJ
34244AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set
34245support.
d77de738 34246
7370c479
HJ
34247@item clearwaterforest
34248Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
34249SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE,
34250XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
34251MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA,
34252LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
faa0e82b
HJ
34253ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16,
34254SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support.
f019251a 34255
d77de738
ML
34256@item knl
34257Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34258SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34259RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34260AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
34261
34262@item knm
34263Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34264SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34265RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34266AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
34267AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
34268
34269@item skylake-avx512
34270Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34271SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34272RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34273AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
34274AVX512DQ and AVX512CD instruction set support.
34275
34276@item cannonlake
34277Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
34278SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
34279FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
34280PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
34281AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
34282support.
34283
34284@item icelake-client
34285Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34286SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34287RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34288AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34289AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
34290, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
34291
34292@item icelake-server
34293Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34294SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34295RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34296AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34297AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
34298, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
34299instruction set support.
34300
34301@item cascadelake
34302Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34303SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34304F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34305CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
34306AVX512CD and AVX512VNNI instruction set support.
34307
34308@item cooperlake
34309Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34310SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34311F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34312CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
34313AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
34314
34315@item tigerlake
34316Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34317SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34318F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34319CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
34320PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34321VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
34322AVX512VP2INTERSECT and KEYLOCKER instruction set support.
34323
34324@item sapphirerapids
34325Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34326SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34327RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34328AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34329AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34330VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
34331MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
29ecb952 34332UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
d77de738
ML
34333instruction set support.
34334
34335@item alderlake
34336Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
34337SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
34338XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
34339CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
34340VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
34341support.
34342
34343@item rocketlake
34344Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
34345, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
34346F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
34347CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
34348PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34349VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
34350
34351@item graniterapids
34352Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34353SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34354RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34355AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34356AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34357VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
34358MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34359UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16
34360and PREFETCHI instruction set support.
d77de738 34361
a0cb65d3
MZ
34362@item graniterapids-d
34363Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34364SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
34365RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
34366AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
34367AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
34368VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
38daaaa9
HJ
34369MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
34370UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16,
34371PREFETCHI and AMX-COMPLEX instruction set support.
a0cb65d3 34372
faa0e82b
HJ
34373@item arrowlake
34374Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34375SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34376XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34377MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34378PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34379UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set
34380support.
34381
34382@item arrowlake-s
34383Intel Arrow Lake S CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34384SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34385XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34386MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34387PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34388UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
34389SM3 and SM4 instruction set support.
34390
34391@item pantherlake
34392Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
34393SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
34394XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
34395MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
34396PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
34397UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
34398SM3, SM4 and PREFETCHI instruction set support.
34399
d77de738
ML
34400@item k6
34401AMD K6 CPU with MMX instruction set support.
34402
34403@item k6-2
34404@itemx k6-3
34405Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
34406
34407@item athlon
34408@itemx athlon-tbird
34409AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
34410support.
34411
34412@item athlon-4
34413@itemx athlon-xp
34414@itemx athlon-mp
34415Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
34416instruction set support.
34417
34418@item k8
34419@itemx opteron
34420@itemx athlon64
34421@itemx athlon-fx
34422Processors based on the AMD K8 core with x86-64 instruction set support,
34423including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
34424(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
34425instruction set extensions.)
34426
34427@item k8-sse3
34428@itemx opteron-sse3
34429@itemx athlon64-sse3
34430Improved versions of AMD K8 cores with SSE3 instruction set support.
34431
34432@item amdfam10
34433@itemx barcelona
34434CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
34435supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
34436instruction set extensions.)
34437
34438@item bdver1
34439CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
34440supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
34441SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
34442
34443@item bdver2
34444AMD Family 15h core based CPUs with x86-64 instruction set support. (This
34445supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
34446SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
34447extensions.)
34448
34449@item bdver3
34450AMD Family 15h core based CPUs with x86-64 instruction set support. (This
34451supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
34452PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3445364-bit instruction set extensions.)
34454
34455@item bdver4
34456AMD Family 15h core based CPUs with x86-64 instruction set support. (This
34457supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
34458AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
34459SSE4.2, ABM and 64-bit instruction set extensions.)
34460
34461@item znver1
34462AMD Family 17h core based CPUs with x86-64 instruction set support. (This
34463supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
34464SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
34465SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
34466instruction set extensions.)
34467
34468@item znver2
34469AMD Family 17h core based CPUs with x86-64 instruction set support. (This
34470supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
34471MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
34472SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
34473WBNOINVD, and 64-bit instruction set extensions.)
34474
34475@item znver3
34476AMD Family 19h core based CPUs with x86-64 instruction set support. (This
34477supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
34478MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
34479SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
34480WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
34481
34482@item znver4
34483AMD Family 19h core based CPUs with x86-64 instruction set support. (This
34484supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
34485MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
34486SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
34487WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
34488AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
34489AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
34490
d0aa0af9
JH
34491@item znver5
34492AMD Family 1ah core based CPUs with x86-64 instruction set support. (This
34493supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
34494MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
34495SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
34496WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
34497AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
34498AVX512BITALG, AVX512VPOPCNTDQ, GFNI, AVXVNNI, MOVDIRI, MOVDIR64B,
34499AVX512VP2INTERSECT, PREFETCHI and 64-bit instruction set extensions.)
34500
d77de738
ML
34501@item btver1
34502CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
34503supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
34504instruction set extensions.)
34505
34506@item btver2
34507CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
34508includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
34509SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
34510
34511@item winchip-c6
34512IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
34513set support.
34514
34515@item winchip2
34516IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
34517instruction set support.
34518
34519@item c3
34520VIA C3 CPU with MMX and 3DNow!@: instruction set support.
34521(No scheduling is implemented for this chip.)
34522
34523@item c3-2
34524VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
34525(No scheduling is implemented for this chip.)
34526
34527@item c7
34528VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
34529(No scheduling is implemented for this chip.)
34530
34531@item samuel-2
34532VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
34533(No scheduling is implemented for this chip.)
34534
34535@item nehemiah
34536VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
34537(No scheduling is implemented for this chip.)
34538
34539@item esther
34540VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
34541(No scheduling is implemented for this chip.)
34542
34543@item eden-x2
34544VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
34545(No scheduling is implemented for this chip.)
34546
34547@item eden-x4
34548VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
34549AVX and AVX2 instruction set support.
34550(No scheduling is implemented for this chip.)
34551
34552@item nano
34553Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
34554instruction set support.
34555(No scheduling is implemented for this chip.)
34556
34557@item nano-1000
34558VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
34559instruction set support.
34560(No scheduling is implemented for this chip.)
34561
34562@item nano-2000
34563VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
34564instruction set support.
34565(No scheduling is implemented for this chip.)
34566
34567@item nano-3000
34568VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
34569instruction set support.
34570(No scheduling is implemented for this chip.)
34571
34572@item nano-x2
34573VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
34574instruction set support.
34575(No scheduling is implemented for this chip.)
34576
34577@item nano-x4
34578VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
34579instruction set support.
34580(No scheduling is implemented for this chip.)
34581
34582@item lujiazui
34583ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
34584SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
34585ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
34586
94c0b26f
M
34587@item yongfeng
34588ZHAOXIN yongfeng CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
34589SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
34590ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT
34591instruction set support.
34592
d77de738
ML
34593@item geode
34594AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
34595@end table
34596
d77de738 34597@opindex mtune
ddf6fe37 34598@item -mtune=@var{cpu-type}
d77de738
ML
34599Tune to @var{cpu-type} everything applicable about the generated code, except
34600for the ABI and the set of available instructions.
34601While picking a specific @var{cpu-type} schedules things appropriately
34602for that particular chip, the compiler does not generate any code that
34603cannot run on the default machine type unless you use a
34604@option{-march=@var{cpu-type}} option.
34605For example, if GCC is configured for i686-pc-linux-gnu
34606then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
34607but still runs on i686 machines.
34608
34609The choices for @var{cpu-type} are the same as for @option{-march}.
34610In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
34611
34612@table @samp
34613@item generic
34614Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
34615If you know the CPU on which your code will run, then you should use
34616the corresponding @option{-mtune} or @option{-march} option instead of
34617@option{-mtune=generic}. But, if you do not know exactly what CPU users
34618of your application will have, then you should use this option.
34619
34620As new processors are deployed in the marketplace, the behavior of this
34621option will change. Therefore, if you upgrade to a newer version of
34622GCC, code generation controlled by this option will change to reflect
34623the processors
34624that are most common at the time that version of GCC is released.
34625
34626There is no @option{-march=generic} option because @option{-march}
34627indicates the instruction set the compiler can use, and there is no
34628generic instruction set applicable to all processors. In contrast,
34629@option{-mtune} indicates the processor (or, in this case, collection of
34630processors) for which the code is optimized.
34631
34632@item intel
34633Produce code optimized for the most current Intel processors, which are
34634Haswell and Silvermont for this version of GCC. If you know the CPU
34635on which your code will run, then you should use the corresponding
34636@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
34637But, if you want your application performs better on both Haswell and
34638Silvermont, then you should use this option.
34639
34640As new Intel processors are deployed in the marketplace, the behavior of
34641this option will change. Therefore, if you upgrade to a newer version of
34642GCC, code generation controlled by this option will change to reflect
34643the most current Intel processors at the time that version of GCC is
34644released.
34645
34646There is no @option{-march=intel} option because @option{-march} indicates
34647the instruction set the compiler can use, and there is no common
34648instruction set applicable to all processors. In contrast,
34649@option{-mtune} indicates the processor (or, in this case, collection of
34650processors) for which the code is optimized.
34651@end table
34652
d77de738 34653@opindex mcpu
ddf6fe37 34654@item -mcpu=@var{cpu-type}
d77de738
ML
34655A deprecated synonym for @option{-mtune}.
34656
d77de738 34657@opindex mfpmath
ddf6fe37 34658@item -mfpmath=@var{unit}
d77de738
ML
34659Generate floating-point arithmetic for selected unit @var{unit}. The choices
34660for @var{unit} are:
34661
34662@table @samp
34663@item 387
34664Use the standard 387 floating-point coprocessor present on the majority of chips and
34665emulated otherwise. Code compiled with this option runs almost everywhere.
34666The temporary results are computed in 80-bit precision instead of the precision
34667specified by the type, resulting in slightly different results compared to most
34668of other chips. See @option{-ffloat-store} for more detailed description.
34669
34670This is the default choice for non-Darwin x86-32 targets.
34671
34672@item sse
34673Use scalar floating-point instructions present in the SSE instruction set.
34674This instruction set is supported by Pentium III and newer chips,
34675and in the AMD line
34676by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
34677instruction set supports only single-precision arithmetic, thus the double and
34678extended-precision arithmetic are still done using 387. A later version, present
34679only in Pentium 4 and AMD x86-64 chips, supports double-precision
34680arithmetic too.
34681
34682For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
34683or @option{-msse2} switches to enable SSE extensions and make this option
34684effective. For the x86-64 compiler, these extensions are enabled by default.
34685
34686The resulting code should be considerably faster in the majority of cases and avoid
34687the numerical instability problems of 387 code, but may break some existing
34688code that expects temporaries to be 80 bits.
34689
34690This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
34691and the default choice for x86-32 targets with the SSE2 instruction set
34692when @option{-ffast-math} is enabled.
34693
34694@item sse,387
34695@itemx sse+387
34696@itemx both
34697Attempt to utilize both instruction sets at once. This effectively doubles the
34698amount of available registers, and on chips with separate execution units for
34699387 and SSE the execution resources too. Use this option with care, as it is
34700still experimental, because the GCC register allocator does not model separate
34701functional units well, resulting in unstable performance.
34702@end table
34703
d77de738 34704@opindex masm=@var{dialect}
ddf6fe37 34705@item -masm=@var{dialect}
d77de738
ML
34706Output assembly instructions using selected @var{dialect}. Also affects
34707which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
34708extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
34709order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
34710not support @samp{intel}.
34711
d77de738
ML
34712@opindex mieee-fp
34713@opindex mno-ieee-fp
ddf6fe37
AA
34714@item -mieee-fp
34715@itemx -mno-ieee-fp
d77de738
ML
34716Control whether or not the compiler uses IEEE floating-point
34717comparisons. These correctly handle the case where the result of a
34718comparison is unordered.
34719
30348d30 34720@opindex m80387
d77de738 34721@opindex mhard-float
ddf6fe37
AA
34722@item -m80387
34723@itemx -mhard-float
d77de738
ML
34724Generate output containing 80387 instructions for floating point.
34725
d77de738
ML
34726@opindex no-80387
34727@opindex msoft-float
ddf6fe37
AA
34728@item -mno-80387
34729@itemx -msoft-float
d77de738
ML
34730Generate output containing library calls for floating point.
34731
34732@strong{Warning:} the requisite libraries are not part of GCC@.
34733Normally the facilities of the machine's usual C compiler are used, but
34734this cannot be done directly in cross-compilation. You must make your
34735own arrangements to provide suitable library functions for
34736cross-compilation.
34737
34738On machines where a function returns floating-point results in the 80387
34739register stack, some floating-point opcodes may be emitted even if
34740@option{-msoft-float} is used.
34741
d77de738
ML
34742@opindex mno-fp-ret-in-387
34743@opindex mfp-ret-in-387
ddf6fe37 34744@item -mno-fp-ret-in-387
d77de738
ML
34745Do not use the FPU registers for return values of functions.
34746
34747The usual calling convention has functions return values of types
34748@code{float} and @code{double} in an FPU register, even if there
34749is no FPU@. The idea is that the operating system should emulate
34750an FPU@.
34751
34752The option @option{-mno-fp-ret-in-387} causes such values to be returned
34753in ordinary CPU registers instead.
34754
d77de738
ML
34755@opindex mno-fancy-math-387
34756@opindex mfancy-math-387
ddf6fe37 34757@item -mno-fancy-math-387
d77de738
ML
34758Some 387 emulators do not support the @code{sin}, @code{cos} and
34759@code{sqrt} instructions for the 387. Specify this option to avoid
34760generating those instructions.
34761This option is overridden when @option{-march}
34762indicates that the target CPU always has an FPU and so the
34763instruction does not need emulation. These
34764instructions are not generated unless you also use the
34765@option{-funsafe-math-optimizations} switch.
34766
d77de738
ML
34767@opindex malign-double
34768@opindex mno-align-double
ddf6fe37
AA
34769@item -malign-double
34770@itemx -mno-align-double
d77de738
ML
34771Control whether GCC aligns @code{double}, @code{long double}, and
34772@code{long long} variables on a two-word boundary or a one-word
34773boundary. Aligning @code{double} variables on a two-word boundary
34774produces code that runs somewhat faster on a Pentium at the
34775expense of more memory.
34776
34777On x86-64, @option{-malign-double} is enabled by default.
34778
34779@strong{Warning:} if you use the @option{-malign-double} switch,
34780structures containing the above types are aligned differently than
34781the published application binary interface specifications for the x86-32
34782and are not binary compatible with structures in code compiled
34783without that switch.
34784
d77de738
ML
34785@opindex m96bit-long-double
34786@opindex m128bit-long-double
ddf6fe37
AA
34787@item -m96bit-long-double
34788@itemx -m128bit-long-double
d77de738
ML
34789These switches control the size of @code{long double} type. The x86-32
34790application binary interface specifies the size to be 96 bits,
34791so @option{-m96bit-long-double} is the default in 32-bit mode.
34792
34793Modern architectures (Pentium and newer) prefer @code{long double}
34794to be aligned to an 8- or 16-byte boundary. In arrays or structures
34795conforming to the ABI, this is not possible. So specifying
34796@option{-m128bit-long-double} aligns @code{long double}
34797to a 16-byte boundary by padding the @code{long double} with an additional
3479832-bit zero.
34799
34800In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
34801its ABI specifies that @code{long double} is aligned on 16-byte boundary.
34802
34803Notice that neither of these options enable any extra precision over the x87
34804standard of 80 bits for a @code{long double}.
34805
34806@strong{Warning:} if you override the default value for your target ABI, this
34807changes the size of
34808structures and arrays containing @code{long double} variables,
34809as well as modifying the function calling convention for functions taking
34810@code{long double}. Hence they are not binary-compatible
34811with code compiled without that switch.
34812
d77de738
ML
34813@opindex mlong-double-64
34814@opindex mlong-double-80
34815@opindex mlong-double-128
ddf6fe37
AA
34816@item -mlong-double-64
34817@itemx -mlong-double-80
34818@itemx -mlong-double-128
d77de738
ML
34819These switches control the size of @code{long double} type. A size
34820of 64 bits makes the @code{long double} type equivalent to the @code{double}
34821type. This is the default for 32-bit Bionic C library. A size
34822of 128 bits makes the @code{long double} type equivalent to the
34823@code{__float128} type. This is the default for 64-bit Bionic C library.
34824
34825@strong{Warning:} if you override the default value for your target ABI, this
34826changes the size of
34827structures and arrays containing @code{long double} variables,
34828as well as modifying the function calling convention for functions taking
34829@code{long double}. Hence they are not binary-compatible
34830with code compiled without that switch.
34831
d77de738 34832@opindex malign-data
ddf6fe37 34833@item -malign-data=@var{type}
d77de738
ML
34834Control how GCC aligns variables. Supported values for @var{type} are
34835@samp{compat} uses increased alignment value compatible uses GCC 4.8
34836and earlier, @samp{abi} uses alignment value as specified by the
34837psABI, and @samp{cacheline} uses increased alignment value to match
34838the cache line size. @samp{compat} is the default.
34839
d77de738 34840@opindex mlarge-data-threshold
ddf6fe37 34841@item -mlarge-data-threshold=@var{threshold}
1a64156c
UB
34842When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data
34843objects larger than @var{threshold} are placed in large data sections. The
34844default is 65535.
d77de738 34845
d77de738 34846@opindex mrtd
ddf6fe37 34847@item -mrtd
d77de738
ML
34848Use a different function-calling convention, in which functions that
34849take a fixed number of arguments return with the @code{ret @var{num}}
34850instruction, which pops their arguments while returning. This saves one
34851instruction in the caller since there is no need to pop the arguments
34852there.
34853
34854You can specify that an individual function is called with this calling
34855sequence with the function attribute @code{stdcall}. You can also
34856override the @option{-mrtd} option by using the function attribute
34857@code{cdecl}. @xref{Function Attributes}.
34858
34859@strong{Warning:} this calling convention is incompatible with the one
34860normally used on Unix, so you cannot use it if you need to call
34861libraries compiled with the Unix compiler.
34862
34863Also, you must provide function prototypes for all functions that
34864take variable numbers of arguments (including @code{printf});
34865otherwise incorrect code is generated for calls to those
34866functions.
34867
34868In addition, seriously incorrect code results if you call a
34869function with too many arguments. (Normally, extra arguments are
34870harmlessly ignored.)
34871
d77de738 34872@opindex mregparm
ddf6fe37 34873@item -mregparm=@var{num}
d77de738
ML
34874Control how many registers are used to pass integer arguments. By
34875default, no registers are used to pass arguments, and at most 3
34876registers can be used. You can control this behavior for a specific
34877function by using the function attribute @code{regparm}.
34878@xref{Function Attributes}.
34879
34880@strong{Warning:} if you use this switch, and
34881@var{num} is nonzero, then you must build all modules with the same
34882value, including any libraries. This includes the system libraries and
34883startup modules.
34884
d77de738 34885@opindex msseregparm
ddf6fe37 34886@item -msseregparm
d77de738
ML
34887Use SSE register passing conventions for float and double arguments
34888and return values. You can control this behavior for a specific
34889function by using the function attribute @code{sseregparm}.
34890@xref{Function Attributes}.
34891
34892@strong{Warning:} if you use this switch then you must build all
34893modules with the same value, including any libraries. This includes
34894the system libraries and startup modules.
34895
d77de738 34896@opindex mvect8-ret-in-mem
ddf6fe37 34897@item -mvect8-ret-in-mem
d77de738
ML
34898Return 8-byte vectors in memory instead of MMX registers. This is the
34899default on VxWorks to match the ABI of the Sun Studio compilers until
34900version 12. @emph{Only} use this option if you need to remain
34901compatible with existing code produced by those previous compiler
34902versions or older versions of GCC@.
34903
d77de738
ML
34904@opindex mpc32
34905@opindex mpc64
34906@opindex mpc80
ddf6fe37
AA
34907@item -mpc32
34908@itemx -mpc64
34909@itemx -mpc80
d77de738
ML
34910
34911Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
34912is specified, the significands of results of floating-point operations are
34913rounded to 24 bits (single precision); @option{-mpc64} rounds the
34914significands of results of floating-point operations to 53 bits (double
34915precision) and @option{-mpc80} rounds the significands of results of
34916floating-point operations to 64 bits (extended double precision), which is
34917the default. When this option is used, floating-point operations in higher
34918precisions are not available to the programmer without setting the FPU
34919control word explicitly.
34920
34921Setting the rounding of floating-point operations to less than the default
3492280 bits can speed some programs by 2% or more. Note that some mathematical
34923libraries assume that extended-precision (80-bit) floating-point operations
34924are enabled by default; routines in such libraries could suffer significant
34925loss of accuracy, typically through so-called ``catastrophic cancellation'',
34926when this option is used to set the precision to less than extended precision.
34927
e54375d8 34928@opindex mdaz-ftz
ddf6fe37 34929@item -mdaz-ftz
e54375d8 34930
34931The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
34932are used to control floating-point calculations.SSE and AVX instructions
34933including scalar and vector instructions could benefit from enabling the FTZ
34934and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
34935when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
34936will set FTZ/DAZ flags even with @option{-shared}.
34937
d77de738 34938@opindex mstackrealign
ddf6fe37 34939@item -mstackrealign
d77de738
ML
34940Realign the stack at entry. On the x86, the @option{-mstackrealign}
34941option generates an alternate prologue and epilogue that realigns the
34942run-time stack if necessary. This supports mixing legacy codes that keep
349434-byte stack alignment with modern codes that keep 16-byte stack alignment for
34944SSE compatibility. See also the attribute @code{force_align_arg_pointer},
34945applicable to individual functions.
34946
d77de738 34947@opindex mpreferred-stack-boundary
ddf6fe37 34948@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
34949Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
34950byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
34951the default is 4 (16 bytes or 128 bits).
34952
34953@strong{Warning:} When generating code for the x86-64 architecture with
34954SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
34955used to keep the stack boundary aligned to 8 byte boundary. Since
34956x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
34957intended to be used in controlled environment where stack space is
34958important limitation. This option leads to wrong code when functions
34959compiled with 16 byte stack alignment (such as functions from a standard
34960library) are called with misaligned stack. In this case, SSE
34961instructions may lead to misaligned memory access traps. In addition,
34962variable arguments are handled incorrectly for 16 byte aligned
34963objects (including x87 long double and __int128), leading to wrong
34964results. You must build all modules with
34965@option{-mpreferred-stack-boundary=3}, including any libraries. This
34966includes the system libraries and startup modules.
34967
d77de738 34968@opindex mincoming-stack-boundary
ddf6fe37 34969@item -mincoming-stack-boundary=@var{num}
d77de738
ML
34970Assume the incoming stack is aligned to a 2 raised to @var{num} byte
34971boundary. If @option{-mincoming-stack-boundary} is not specified,
34972the one specified by @option{-mpreferred-stack-boundary} is used.
34973
34974On Pentium and Pentium Pro, @code{double} and @code{long double} values
34975should be aligned to an 8-byte boundary (see @option{-malign-double}) or
34976suffer significant run time performance penalties. On Pentium III, the
34977Streaming SIMD Extension (SSE) data type @code{__m128} may not work
34978properly if it is not 16-byte aligned.
34979
34980To ensure proper alignment of this values on the stack, the stack boundary
34981must be as aligned as that required by any value stored on the stack.
34982Further, every function must be generated such that it keeps the stack
34983aligned. Thus calling a function compiled with a higher preferred
34984stack boundary from a function compiled with a lower preferred stack
34985boundary most likely misaligns the stack. It is recommended that
34986libraries that use callbacks always use the default setting.
34987
34988This extra alignment does consume extra stack space, and generally
34989increases code size. Code that is sensitive to stack space usage, such
34990as embedded systems and operating system kernels, may want to reduce the
34991preferred alignment to @option{-mpreferred-stack-boundary=2}.
34992
34993@need 200
d77de738 34994@opindex mmmx
ddf6fe37 34995@item -mmmx
d77de738 34996@need 200
d77de738 34997@opindex msse
ddf6fe37 34998@itemx -msse
d77de738 34999@need 200
d77de738 35000@opindex msse2
ddf6fe37 35001@itemx -msse2
d77de738 35002@need 200
d77de738 35003@opindex msse3
ddf6fe37 35004@itemx -msse3
d77de738 35005@need 200
d77de738 35006@opindex mssse3
ddf6fe37 35007@itemx -mssse3
d77de738 35008@need 200
d77de738 35009@opindex msse4
ddf6fe37 35010@itemx -msse4
d77de738 35011@need 200
d77de738 35012@opindex msse4a
ddf6fe37 35013@itemx -msse4a
d77de738 35014@need 200
d77de738 35015@opindex msse4.1
ddf6fe37 35016@itemx -msse4.1
d77de738 35017@need 200
d77de738 35018@opindex msse4.2
ddf6fe37 35019@itemx -msse4.2
d77de738 35020@need 200
d77de738 35021@opindex mavx
ddf6fe37 35022@itemx -mavx
d77de738 35023@need 200
d77de738 35024@opindex mavx2
ddf6fe37 35025@itemx -mavx2
d77de738 35026@need 200
d77de738 35027@opindex mavx512f
ddf6fe37 35028@itemx -mavx512f
d77de738 35029@need 200
d77de738 35030@opindex mavx512pf
ddf6fe37 35031@itemx -mavx512pf
d77de738 35032@need 200
d77de738 35033@opindex mavx512er
ddf6fe37 35034@itemx -mavx512er
d77de738 35035@need 200
d77de738 35036@opindex mavx512cd
ddf6fe37 35037@itemx -mavx512cd
d77de738 35038@need 200
d77de738 35039@opindex mavx512vl
ddf6fe37 35040@itemx -mavx512vl
d77de738 35041@need 200
d77de738 35042@opindex mavx512bw
ddf6fe37 35043@itemx -mavx512bw
d77de738 35044@need 200
d77de738 35045@opindex mavx512dq
ddf6fe37 35046@itemx -mavx512dq
d77de738 35047@need 200
d77de738 35048@opindex mavx512ifma
ddf6fe37 35049@itemx -mavx512ifma
d77de738 35050@need 200
d77de738 35051@opindex mavx512vbmi
ddf6fe37 35052@itemx -mavx512vbmi
d77de738 35053@need 200
d77de738 35054@opindex msha
ddf6fe37 35055@itemx -msha
d77de738 35056@need 200
d77de738 35057@opindex maes
ddf6fe37 35058@itemx -maes
d77de738 35059@need 200
d77de738 35060@opindex mpclmul
ddf6fe37 35061@itemx -mpclmul
d77de738 35062@need 200
d77de738 35063@opindex mclflushopt
ddf6fe37 35064@itemx -mclflushopt
d77de738 35065@need 200
d77de738 35066@opindex mclwb
ddf6fe37 35067@itemx -mclwb
d77de738 35068@need 200
d77de738 35069@opindex mfsgsbase
ddf6fe37 35070@itemx -mfsgsbase
d77de738 35071@need 200
d77de738 35072@opindex mptwrite
ddf6fe37 35073@itemx -mptwrite
d77de738 35074@need 200
d77de738 35075@opindex mrdrnd
ddf6fe37 35076@itemx -mrdrnd
d77de738 35077@need 200
d77de738 35078@opindex mf16c
ddf6fe37 35079@itemx -mf16c
d77de738 35080@need 200
d77de738 35081@opindex mfma
ddf6fe37 35082@itemx -mfma
d77de738 35083@need 200
d77de738 35084@opindex mpconfig
ddf6fe37 35085@itemx -mpconfig
d77de738 35086@need 200
d77de738 35087@opindex mwbnoinvd
ddf6fe37 35088@itemx -mwbnoinvd
d77de738 35089@need 200
d77de738 35090@opindex mfma4
ddf6fe37 35091@itemx -mfma4
d77de738 35092@need 200
d77de738 35093@opindex mprfchw
ddf6fe37 35094@itemx -mprfchw
d77de738 35095@need 200
d77de738 35096@opindex mrdpid
ddf6fe37 35097@itemx -mrdpid
d77de738 35098@need 200
d77de738 35099@opindex mprefetchwt1
ddf6fe37 35100@itemx -mprefetchwt1
d77de738 35101@need 200
d77de738 35102@opindex mrdseed
ddf6fe37 35103@itemx -mrdseed
d77de738 35104@need 200
d77de738 35105@opindex msgx
ddf6fe37 35106@itemx -msgx
d77de738 35107@need 200
d77de738 35108@opindex mxop
ddf6fe37 35109@itemx -mxop
d77de738 35110@need 200
d77de738 35111@opindex mlwp
ddf6fe37 35112@itemx -mlwp
d77de738 35113@need 200
d77de738 35114@opindex m3dnow
ddf6fe37 35115@itemx -m3dnow
d77de738 35116@need 200
d77de738 35117@opindex m3dnowa
ddf6fe37 35118@itemx -m3dnowa
d77de738 35119@need 200
d77de738 35120@opindex mpopcnt
ddf6fe37 35121@itemx -mpopcnt
d77de738 35122@need 200
d77de738 35123@opindex mabm
ddf6fe37 35124@itemx -mabm
d77de738 35125@need 200
d77de738 35126@opindex madx
ddf6fe37 35127@itemx -madx
d77de738 35128@need 200
d77de738 35129@opindex mbmi
ddf6fe37 35130@itemx -mbmi
d77de738 35131@need 200
d77de738 35132@opindex mbmi2
ddf6fe37 35133@itemx -mbmi2
d77de738 35134@need 200
d77de738 35135@opindex mlzcnt
ddf6fe37 35136@itemx -mlzcnt
d77de738 35137@need 200
d77de738 35138@opindex mfxsr
ddf6fe37 35139@itemx -mfxsr
d77de738 35140@need 200
d77de738 35141@opindex mxsave
ddf6fe37 35142@itemx -mxsave
d77de738 35143@need 200
d77de738 35144@opindex mxsaveopt
ddf6fe37 35145@itemx -mxsaveopt
d77de738 35146@need 200
d77de738 35147@opindex mxsavec
ddf6fe37 35148@itemx -mxsavec
d77de738 35149@need 200
d77de738 35150@opindex mxsaves
ddf6fe37 35151@itemx -mxsaves
d77de738 35152@need 200
d77de738 35153@opindex mrtm
ddf6fe37 35154@itemx -mrtm
d77de738 35155@need 200
d77de738 35156@opindex mhle
ddf6fe37 35157@itemx -mhle
d77de738 35158@need 200
d77de738 35159@opindex mtbm
ddf6fe37 35160@itemx -mtbm
d77de738 35161@need 200
d77de738 35162@opindex mmwaitx
ddf6fe37 35163@itemx -mmwaitx
d77de738 35164@need 200
d77de738 35165@opindex mclzero
ddf6fe37 35166@itemx -mclzero
d77de738 35167@need 200
d77de738 35168@opindex mpku
ddf6fe37 35169@itemx -mpku
d77de738 35170@need 200
d77de738 35171@opindex mavx512vbmi2
ddf6fe37 35172@itemx -mavx512vbmi2
d77de738 35173@need 200
d77de738 35174@opindex mavx512bf16
ddf6fe37 35175@itemx -mavx512bf16
d77de738 35176@need 200
d77de738 35177@opindex mavx512fp16
ddf6fe37 35178@itemx -mavx512fp16
d77de738 35179@need 200
d77de738 35180@opindex mgfni
ddf6fe37 35181@itemx -mgfni
d77de738 35182@need 200
d77de738 35183@opindex mvaes
ddf6fe37 35184@itemx -mvaes
d77de738 35185@need 200
d77de738 35186@opindex mwaitpkg
ddf6fe37 35187@itemx -mwaitpkg
d77de738 35188@need 200
d77de738 35189@opindex mvpclmulqdq
ddf6fe37 35190@itemx -mvpclmulqdq
d77de738 35191@need 200
d77de738 35192@opindex mavx512bitalg
ddf6fe37 35193@itemx -mavx512bitalg
d77de738 35194@need 200
d77de738 35195@opindex mmovdiri
ddf6fe37 35196@itemx -mmovdiri
d77de738 35197@need 200
d77de738 35198@opindex mmovdir64b
ddf6fe37 35199@itemx -mmovdir64b
d77de738 35200@need 200
d77de738 35201@opindex menqcmd
d77de738 35202@opindex muintr
ddf6fe37
AA
35203@itemx -menqcmd
35204@itemx -muintr
d77de738 35205@need 200
d77de738 35206@opindex mtsxldtrk
ddf6fe37 35207@itemx -mtsxldtrk
d77de738 35208@need 200
d77de738 35209@opindex mavx512vpopcntdq
ddf6fe37 35210@itemx -mavx512vpopcntdq
d77de738 35211@need 200
d77de738 35212@opindex mavx512vp2intersect
ddf6fe37 35213@itemx -mavx512vp2intersect
d77de738 35214@need 200
d77de738 35215@opindex mavx5124fmaps
ddf6fe37 35216@itemx -mavx5124fmaps
d77de738 35217@need 200
d77de738 35218@opindex mavx512vnni
ddf6fe37 35219@itemx -mavx512vnni
d77de738 35220@need 200
d77de738 35221@opindex mavxvnni
ddf6fe37 35222@itemx -mavxvnni
d77de738 35223@need 200
d77de738 35224@opindex mavx5124vnniw
ddf6fe37 35225@itemx -mavx5124vnniw
d77de738 35226@need 200
d77de738 35227@opindex mcldemote
ddf6fe37 35228@itemx -mcldemote
d77de738 35229@need 200
d77de738 35230@opindex mserialize
ddf6fe37 35231@itemx -mserialize
d77de738 35232@need 200
d77de738 35233@opindex mamx-tile
ddf6fe37 35234@itemx -mamx-tile
d77de738 35235@need 200
d77de738 35236@opindex mamx-int8
ddf6fe37 35237@itemx -mamx-int8
d77de738 35238@need 200
d77de738 35239@opindex mamx-bf16
ddf6fe37 35240@itemx -mamx-bf16
d77de738 35241@need 200
d77de738 35242@opindex mhreset
d77de738 35243@opindex mkl
ddf6fe37
AA
35244@itemx -mhreset
35245@itemx -mkl
d77de738 35246@need 200
d77de738 35247@opindex mwidekl
ddf6fe37 35248@itemx -mwidekl
d77de738 35249@need 200
d77de738 35250@opindex mavxifma
ddf6fe37 35251@itemx -mavxifma
d77de738 35252@need 200
d77de738 35253@opindex mavxvnniint8
ddf6fe37 35254@itemx -mavxvnniint8
d77de738 35255@need 200
d77de738 35256@opindex mavxneconvert
ddf6fe37 35257@itemx -mavxneconvert
d77de738 35258@need 200
d77de738 35259@opindex mcmpccxadd
ddf6fe37 35260@itemx -mcmpccxadd
d77de738 35261@need 200
d77de738 35262@opindex mamx-fp16
ddf6fe37 35263@itemx -mamx-fp16
d77de738 35264@need 200
d77de738 35265@opindex mprefetchi
ddf6fe37 35266@itemx -mprefetchi
d77de738 35267@need 200
d77de738 35268@opindex mraoint
ddf6fe37 35269@itemx -mraoint
efa6a82b
HJ
35270@need 200
35271@opindex mamx-complex
35272@itemx -mamx-complex
1dbc1081
KL
35273@need 200
35274@opindex mavxvnniint16
35275@itemx -mavxvnniint16
8643bcba
HJ
35276@need 200
35277@opindex msm3
35278@itemx -msm3
86446132
HJ
35279@need 200
35280@opindex msha512
35281@itemx -msha512
37bdeb8f
HJ
35282@need 200
35283@opindex msm4
35284@itemx -msm4
e686416b
KL
35285@need 200
35286@opindex mapxf
35287@itemx -mapxf
5fbd91b1
HL
35288@need 200
35289@opindex musermsr
35290@itemx -musermsr
2f8f7ee2
HJ
35291@need 200
35292@opindex mavx10.1
35293@itemx -mavx10.1
35294@need 200
35295@opindex mavx10.1-256
35296@itemx -mavx10.1-256
35297@need 200
35298@opindex mavx10.1-512
35299@itemx -mavx10.1-512
d77de738 35300These switches enable the use of instructions in the MMX, SSE,
d77de738
ML
35301AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
35302AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
35303WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
353043DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
35305XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
35306GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
35307ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
29ecb952 35308UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
efa6a82b 35309AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT,
2f8f7ee2
HJ
35310AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512, SM4, APX_F, USER_MSR, AVX10.1 or
35311CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-}
35312option to disable use of these instructions.
d77de738
ML
35313
35314These extensions are also available as built-in functions: see
35315@ref{x86 Built-in Functions}, for details of the functions enabled and
35316disabled by these switches.
35317
35318To generate SSE/SSE2 instructions automatically from floating-point
35319code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
35320
35321GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
35322generates new AVX instructions or AVX equivalence for all SSEx instructions
35323when needed.
35324
35325These options enable GCC to use these extended instructions in
35326generated code, even without @option{-mfpmath=sse}. Applications that
35327perform run-time CPU detection must compile separate files for each
35328supported architecture, using the appropriate flags. In particular,
35329the file containing the CPU detection code should be compiled without
35330these options.
35331
d77de738 35332@opindex mdump-tune-features
ddf6fe37 35333@item -mdump-tune-features
d77de738
ML
35334This option instructs GCC to dump the names of the x86 performance
35335tuning features and default settings. The names can be used in
35336@option{-mtune-ctrl=@var{feature-list}}.
35337
d77de738 35338@opindex mtune-ctrl=@var{feature-list}
ddf6fe37 35339@item -mtune-ctrl=@var{feature-list}
d77de738
ML
35340This option is used to do fine grain control of x86 code generation features.
35341@var{feature-list} is a comma separated list of @var{feature} names. See also
35342@option{-mdump-tune-features}. When specified, the @var{feature} is turned
35343on if it is not preceded with @samp{^}, otherwise, it is turned off.
35344@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
35345developers. Using it may lead to code paths not covered by testing and can
35346potentially result in compiler ICEs or runtime errors.
35347
d77de738 35348@opindex mno-default
ddf6fe37 35349@item -mno-default
d77de738
ML
35350This option instructs GCC to turn off all tunable features. See also
35351@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
35352
d77de738 35353@opindex mcld
ddf6fe37 35354@item -mcld
d77de738
ML
35355This option instructs GCC to emit a @code{cld} instruction in the prologue
35356of functions that use string instructions. String instructions depend on
35357the DF flag to select between autoincrement or autodecrement mode. While the
35358ABI specifies the DF flag to be cleared on function entry, some operating
35359systems violate this specification by not clearing the DF flag in their
35360exception dispatchers. The exception handler can be invoked with the DF flag
35361set, which leads to wrong direction mode when string instructions are used.
35362This option can be enabled by default on 32-bit x86 targets by configuring
35363GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
35364instructions can be suppressed with the @option{-mno-cld} compiler option
35365in this case.
35366
d77de738 35367@opindex mvzeroupper
ddf6fe37 35368@item -mvzeroupper
d77de738
ML
35369This option instructs GCC to emit a @code{vzeroupper} instruction
35370before a transfer of control flow out of the function to minimize
35371the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
35372intrinsics.
35373
d77de738 35374@opindex mprefer-avx128
ddf6fe37 35375@item -mprefer-avx128
d77de738
ML
35376This option instructs GCC to use 128-bit AVX instructions instead of
35377256-bit AVX instructions in the auto-vectorizer.
35378
d77de738 35379@opindex mprefer-vector-width
ddf6fe37 35380@item -mprefer-vector-width=@var{opt}
d77de738
ML
35381This option instructs GCC to use @var{opt}-bit vector width in instructions
35382instead of default on the selected platform.
35383
ad5b757d
UB
35384@opindex mpartial-vector-fp-math
35385@item -mpartial-vector-fp-math
35386This option enables GCC to generate floating-point operations that might
35387affect the set of floating-point status flags on partial vectors, where
35388vector elements reside in the low part of the 128-bit SSE register. Unless
35389@option{-fno-trapping-math} is specified, the compiler guarantees correct
35390behavior by sanitizing all input operands to have zeroes in the unused
35391upper part of the vector register. Note that by using built-in functions
35392or inline assembly with partial vector arguments, NaNs, denormal or invalid
35393values can leak into the upper part of the vector, causing possible
35394performance issues when @option{-fno-trapping-math} is in effect. These
35395issues can be mitigated by manually sanitizing the upper part of the partial
35396vector argument register or by using @option{-mdaz-ftz} to set
35397denormals-are-zero (DAZ) flag in the MXCSR register.
35398
35399This option is enabled by default.
35400
d77de738 35401@opindex mmove-max
ddf6fe37 35402@item -mmove-max=@var{bits}
d77de738
ML
35403This option instructs GCC to set the maximum number of bits can be
35404moved from memory to memory efficiently to @var{bits}. The valid
35405@var{bits} are 128, 256 and 512.
35406
d77de738 35407@opindex mstore-max
ddf6fe37 35408@item -mstore-max=@var{bits}
d77de738
ML
35409This option instructs GCC to set the maximum number of bits can be
35410stored to memory efficiently to @var{bits}. The valid @var{bits} are
35411128, 256 and 512.
35412
35413@table @samp
35414@item none
35415No extra limitations applied to GCC other than defined by the selected platform.
35416
35417@item 128
35418Prefer 128-bit vector width for instructions.
35419
35420@item 256
35421Prefer 256-bit vector width for instructions.
35422
35423@item 512
35424Prefer 512-bit vector width for instructions.
35425@end table
35426
a307a26e
JJ
35427@opindex mnoreturn-no-callee-saved-registers
35428@item -mnoreturn-no-callee-saved-registers
35429This option optimizes functions with @code{noreturn} attribute or
35430@code{_Noreturn} specifier by not saving in the function prologue callee-saved
35431registers which are used in the function (except for the @code{BP}
35432register). This option can interfere with debugging of the caller of the
35433@code{noreturn} function or any function further up in the call stack, so it
35434is not enabled by default.
35435
d77de738 35436@opindex mcx16
ddf6fe37 35437@item -mcx16
d77de738
ML
35438This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
35439code to implement compare-and-exchange operations on 16-byte aligned 128-bit
35440objects. This is useful for atomic updates of data structures exceeding one
35441machine word in size. The compiler uses this instruction to implement
35442@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
35443128-bit integers, a library call is always used.
35444
d77de738 35445@opindex msahf
ddf6fe37 35446@item -msahf
d77de738
ML
35447This option enables generation of @code{SAHF} instructions in 64-bit code.
35448Early Intel Pentium 4 CPUs with Intel 64 support,
35449prior to the introduction of Pentium 4 G1 step in December 2005,
35450lacked the @code{LAHF} and @code{SAHF} instructions
35451which are supported by AMD64.
35452These are load and store instructions, respectively, for certain status flags.
35453In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
35454@code{drem}, and @code{remainder} built-in functions;
35455see @ref{Other Builtins} for details.
35456
d77de738 35457@opindex mmovbe
ddf6fe37 35458@item -mmovbe
4b358f9b
RB
35459This option enables use of the @code{movbe} instruction to optimize
35460byte swapping of four and eight byte entities.
d77de738 35461
d77de738 35462@opindex mshstk
ddf6fe37 35463@item -mshstk
d77de738
ML
35464The @option{-mshstk} option enables shadow stack built-in functions
35465from x86 Control-flow Enforcement Technology (CET).
35466
d77de738 35467@opindex mcrc32
ddf6fe37 35468@item -mcrc32
d77de738
ML
35469This option enables built-in functions @code{__builtin_ia32_crc32qi},
35470@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
35471@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
35472
d77de738 35473@opindex mmwait
ddf6fe37 35474@item -mmwait
d77de738
ML
35475This option enables built-in functions @code{__builtin_ia32_monitor},
35476and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
35477@code{mwait} machine instructions.
35478
d77de738 35479@opindex mrecip
ddf6fe37 35480@item -mrecip
d77de738
ML
35481This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
35482(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
35483with an additional Newton-Raphson step
35484to increase precision instead of @code{DIVSS} and @code{SQRTSS}
35485(and their vectorized
35486variants) for single-precision floating-point arguments. These instructions
35487are generated only when @option{-funsafe-math-optimizations} is enabled
35488together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
35489Note that while the throughput of the sequence is higher than the throughput
35490of the non-reciprocal instruction, the precision of the sequence can be
35491decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
35492
35493Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
35494(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
35495combination), and doesn't need @option{-mrecip}.
35496
35497Also note that GCC emits the above sequence with additional Newton-Raphson step
35498for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
35499already with @option{-ffast-math} (or the above option combination), and
35500doesn't need @option{-mrecip}.
35501
d77de738 35502@opindex mrecip=opt
ddf6fe37 35503@item -mrecip=@var{opt}
d77de738
ML
35504This option controls which reciprocal estimate instructions
35505may be used. @var{opt} is a comma-separated list of options, which may
35506be preceded by a @samp{!} to invert the option:
35507
35508@table @samp
35509@item all
35510Enable all estimate instructions.
35511
35512@item default
35513Enable the default instructions, equivalent to @option{-mrecip}.
35514
35515@item none
35516Disable all estimate instructions, equivalent to @option{-mno-recip}.
35517
35518@item div
35519Enable the approximation for scalar division.
35520
35521@item vec-div
35522Enable the approximation for vectorized division.
35523
35524@item sqrt
35525Enable the approximation for scalar square root.
35526
35527@item vec-sqrt
35528Enable the approximation for vectorized square root.
35529@end table
35530
35531So, for example, @option{-mrecip=all,!sqrt} enables
35532all of the reciprocal approximations, except for square root.
35533
d77de738 35534@opindex mveclibabi
ddf6fe37 35535@item -mveclibabi=@var{type}
d77de738
ML
35536Specifies the ABI type to use for vectorizing intrinsics using an
35537external library. Supported values for @var{type} are @samp{svml}
35538for the Intel short
35539vector math library and @samp{acml} for the AMD math core library.
35540To use this option, both @option{-ftree-vectorize} and
35541@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
35542ABI-compatible library must be specified at link time.
35543
35544GCC currently emits calls to @code{vmldExp2},
35545@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
35546@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
35547@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
35548@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
35549@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
35550@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
35551@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
35552@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
35553@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
35554function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
35555@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
35556@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
35557@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
35558@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
35559when @option{-mveclibabi=acml} is used.
35560
d77de738 35561@opindex mabi
ddf6fe37 35562@item -mabi=@var{name}
d77de738
ML
35563Generate code for the specified calling convention. Permissible values
35564are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
35565@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
35566ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
35567You can control this behavior for specific functions by
35568using the function attributes @code{ms_abi} and @code{sysv_abi}.
35569@xref{Function Attributes}.
35570
d77de738 35571@opindex mforce-indirect-call
ddf6fe37 35572@item -mforce-indirect-call
d77de738
ML
35573Force all calls to functions to be indirect. This is useful
35574when using Intel Processor Trace where it generates more precise timing
35575information for function calls.
35576
d77de738 35577@opindex mmanual-endbr
ddf6fe37 35578@item -mmanual-endbr
d77de738
ML
35579Insert ENDBR instruction at function entry only via the @code{cf_check}
35580function attribute. This is useful when used with the option
35581@option{-fcf-protection=branch} to control ENDBR insertion at the
35582function entry.
35583
d77de738 35584@opindex mcet-switch
ddf6fe37 35585@item -mcet-switch
d77de738
ML
35586By default, CET instrumentation is turned off on switch statements that
35587use a jump table and indirect branch track is disabled. Since jump
35588tables are stored in read-only memory, this does not result in a direct
35589loss of hardening. But if the jump table index is attacker-controlled,
35590the indirect jump may not be constrained by CET. This option turns on
35591CET instrumentation to enable indirect branch track for switch statements
35592with jump tables which leads to the jump targets reachable via any indirect
35593jumps.
35594
d77de738
ML
35595@opindex mcall-ms2sysv-xlogues
35596@opindex mno-call-ms2sysv-xlogues
ddf6fe37 35597@item -mcall-ms2sysv-xlogues
d77de738
ML
35598Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
35599System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
35600default, the code for saving and restoring these registers is emitted inline,
35601resulting in fairly lengthy prologues and epilogues. Using
35602@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
35603use stubs in the static portion of libgcc to perform these saves and restores,
35604thus reducing function size at the cost of a few extra instructions.
35605
d77de738 35606@opindex mtls-dialect
ddf6fe37 35607@item -mtls-dialect=@var{type}
d77de738
ML
35608Generate code to access thread-local storage using the @samp{gnu} or
35609@samp{gnu2} conventions. @samp{gnu} is the conservative default;
35610@samp{gnu2} is more efficient, but it may add compile- and run-time
35611requirements that cannot be satisfied on all systems.
35612
d77de738
ML
35613@opindex mpush-args
35614@opindex mno-push-args
ddf6fe37
AA
35615@item -mpush-args
35616@itemx -mno-push-args
d77de738
ML
35617Use PUSH operations to store outgoing parameters. This method is shorter
35618and usually equally fast as method using SUB/MOV operations and is enabled
35619by default. In some cases disabling it may improve performance because of
35620improved scheduling and reduced dependencies.
35621
d77de738 35622@opindex maccumulate-outgoing-args
ddf6fe37 35623@item -maccumulate-outgoing-args
d77de738
ML
35624If enabled, the maximum amount of space required for outgoing arguments is
35625computed in the function prologue. This is faster on most modern CPUs
35626because of reduced dependencies, improved scheduling and reduced stack usage
35627when the preferred stack boundary is not equal to 2. The drawback is a notable
35628increase in code size. This switch implies @option{-mno-push-args}.
35629
d77de738 35630@opindex mthreads
ddf6fe37 35631@item -mthreads
d77de738
ML
35632Support thread-safe exception handling on MinGW. Programs that rely
35633on thread-safe exception handling must compile and link all code with the
35634@option{-mthreads} option. When compiling, @option{-mthreads} defines
35635@option{-D_MT}; when linking, it links in a special thread helper library
35636@option{-lmingwthrd} which cleans up per-thread exception-handling data.
35637
d77de738
ML
35638@opindex mms-bitfields
35639@opindex mno-ms-bitfields
ddf6fe37
AA
35640@item -mms-bitfields
35641@itemx -mno-ms-bitfields
d77de738
ML
35642
35643Enable/disable bit-field layout compatible with the native Microsoft
35644Windows compiler.
35645
35646If @code{packed} is used on a structure, or if bit-fields are used,
35647it may be that the Microsoft ABI lays out the structure differently
35648than the way GCC normally does. Particularly when moving packed
35649data between functions compiled with GCC and the native Microsoft compiler
35650(either via function call or as data in a file), it may be necessary to access
35651either format.
35652
35653This option is enabled by default for Microsoft Windows
35654targets. This behavior can also be controlled locally by use of variable
35655or type attributes. For more information, see @ref{x86 Variable Attributes}
35656and @ref{x86 Type Attributes}.
35657
35658The Microsoft structure layout algorithm is fairly simple with the exception
35659of the bit-field packing.
35660The padding and alignment of members of structures and whether a bit-field
35661can straddle a storage-unit boundary are determine by these rules:
35662
35663@enumerate
35664@item Structure members are stored sequentially in the order in which they are
35665declared: the first member has the lowest memory address and the last member
35666the highest.
35667
35668@item Every data object has an alignment requirement. The alignment requirement
35669for all data except structures, unions, and arrays is either the size of the
35670object or the current packing size (specified with either the
35671@code{aligned} attribute or the @code{pack} pragma),
35672whichever is less. For structures, unions, and arrays,
35673the alignment requirement is the largest alignment requirement of its members.
35674Every object is allocated an offset so that:
35675
35676@smallexample
35677offset % alignment_requirement == 0
35678@end smallexample
35679
35680@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
35681unit if the integral types are the same size and if the next bit-field fits
35682into the current allocation unit without crossing the boundary imposed by the
35683common alignment requirements of the bit-fields.
35684@end enumerate
35685
35686MSVC interprets zero-length bit-fields in the following ways:
35687
35688@enumerate
35689@item If a zero-length bit-field is inserted between two bit-fields that
35690are normally coalesced, the bit-fields are not coalesced.
35691
35692For example:
35693
35694@smallexample
35695struct
35696 @{
35697 unsigned long bf_1 : 12;
35698 unsigned long : 0;
35699 unsigned long bf_2 : 12;
35700 @} t1;
35701@end smallexample
35702
35703@noindent
35704The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
35705zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
35706
35707@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
35708alignment of the zero-length bit-field is greater than the member that follows it,
35709@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
35710
35711For example:
35712
35713@smallexample
35714struct
35715 @{
35716 char foo : 4;
35717 short : 0;
35718 char bar;
35719 @} t2;
35720
35721struct
35722 @{
35723 char foo : 4;
35724 short : 0;
35725 double bar;
35726 @} t3;
35727@end smallexample
35728
35729@noindent
35730For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
35731Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
35732bit-field does not affect the alignment of @code{bar} or, as a result, the size
35733of the structure.
35734
35735Taking this into account, it is important to note the following:
35736
35737@enumerate
35738@item If a zero-length bit-field follows a normal bit-field, the type of the
35739zero-length bit-field may affect the alignment of the structure as whole. For
35740example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
35741normal bit-field, and is of type short.
35742
35743@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
35744still affect the alignment of the structure:
35745
35746@smallexample
35747struct
35748 @{
35749 char foo : 6;
35750 long : 0;
35751 @} t4;
35752@end smallexample
35753
35754@noindent
35755Here, @code{t4} takes up 4 bytes.
35756@end enumerate
35757
35758@item Zero-length bit-fields following non-bit-field members are ignored:
35759
35760@smallexample
35761struct
35762 @{
35763 char foo;
35764 long : 0;
35765 char bar;
35766 @} t5;
35767@end smallexample
35768
35769@noindent
35770Here, @code{t5} takes up 2 bytes.
35771@end enumerate
35772
35773
d77de738
ML
35774@opindex mno-align-stringops
35775@opindex malign-stringops
ddf6fe37 35776@item -mno-align-stringops
d77de738
ML
35777Do not align the destination of inlined string operations. This switch reduces
35778code size and improves performance in case the destination is already aligned,
35779but GCC doesn't know about it.
35780
d77de738 35781@opindex minline-all-stringops
ddf6fe37 35782@item -minline-all-stringops
d77de738
ML
35783By default GCC inlines string operations only when the destination is
35784known to be aligned to least a 4-byte boundary.
35785This enables more inlining and increases code
35786size, but may improve performance of code that depends on fast
35787@code{memcpy} and @code{memset} for short lengths.
35788The option enables inline expansion of @code{strlen} for all
35789pointer alignments.
35790
d77de738 35791@opindex minline-stringops-dynamically
ddf6fe37 35792@item -minline-stringops-dynamically
d77de738
ML
35793For string operations of unknown size, use run-time checks with
35794inline code for small blocks and a library call for large blocks.
35795
d77de738 35796@opindex mstringop-strategy=@var{alg}
ddf6fe37 35797@item -mstringop-strategy=@var{alg}
d77de738
ML
35798Override the internal decision heuristic for the particular algorithm to use
35799for inlining string operations. The allowed values for @var{alg} are:
35800
35801@table @samp
35802@item rep_byte
35803@itemx rep_4byte
35804@itemx rep_8byte
35805Expand using i386 @code{rep} prefix of the specified size.
35806
35807@item byte_loop
35808@itemx loop
35809@itemx unrolled_loop
35810Expand into an inline loop.
35811
35812@item libcall
35813Always use a library call.
35814@end table
35815
d77de738 35816@opindex mmemcpy-strategy=@var{strategy}
ddf6fe37 35817@item -mmemcpy-strategy=@var{strategy}
d77de738
ML
35818Override the internal decision heuristic to decide if @code{__builtin_memcpy}
35819should be inlined and what inline algorithm to use when the expected size
35820of the copy operation is known. @var{strategy}
35821is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
35822@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
35823the max byte size with which inline algorithm @var{alg} is allowed. For the last
35824triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
35825in the list must be specified in increasing order. The minimal byte size for
35826@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
35827preceding range.
35828
d77de738 35829@opindex mmemset-strategy=@var{strategy}
ddf6fe37 35830@item -mmemset-strategy=@var{strategy}
d77de738
ML
35831The option is similar to @option{-mmemcpy-strategy=} except that it is to control
35832@code{__builtin_memset} expansion.
35833
d77de738 35834@opindex momit-leaf-frame-pointer
ddf6fe37 35835@item -momit-leaf-frame-pointer
d77de738
ML
35836Don't keep the frame pointer in a register for leaf functions. This
35837avoids the instructions to save, set up, and restore frame pointers and
35838makes an extra register available in leaf functions. The option
35839@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
35840which might make debugging harder.
35841
ddf6fe37 35842@opindex mtls-direct-seg-refs
d77de738
ML
35843@item -mtls-direct-seg-refs
35844@itemx -mno-tls-direct-seg-refs
d77de738
ML
35845Controls whether TLS variables may be accessed with offsets from the
35846TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
35847or whether the thread base pointer must be added. Whether or not this
35848is valid depends on the operating system, and whether it maps the
35849segment to cover the entire TLS area.
35850
35851For systems that use the GNU C Library, the default is on.
35852
ddf6fe37 35853@opindex msse2avx
d77de738
ML
35854@item -msse2avx
35855@itemx -mno-sse2avx
d77de738
ML
35856Specify that the assembler should encode SSE instructions with VEX
35857prefix. The option @option{-mavx} turns this on by default.
35858
ddf6fe37 35859@opindex mfentry
d77de738
ML
35860@item -mfentry
35861@itemx -mno-fentry
d77de738
ML
35862If profiling is active (@option{-pg}), put the profiling
35863counter call before the prologue.
35864Note: On x86 architectures the attribute @code{ms_hook_prologue}
35865isn't possible at the moment for @option{-mfentry} and @option{-pg}.
35866
ddf6fe37 35867@opindex mrecord-mcount
d77de738
ML
35868@item -mrecord-mcount
35869@itemx -mno-record-mcount
d77de738
ML
35870If profiling is active (@option{-pg}), generate a __mcount_loc section
35871that contains pointers to each profiling call. This is useful for
35872automatically patching and out calls.
35873
ddf6fe37 35874@opindex mnop-mcount
d77de738
ML
35875@item -mnop-mcount
35876@itemx -mno-nop-mcount
d77de738
ML
35877If profiling is active (@option{-pg}), generate the calls to
35878the profiling functions as NOPs. This is useful when they
35879should be patched in later dynamically. This is likely only
35880useful together with @option{-mrecord-mcount}.
35881
d77de738 35882@opindex minstrument-return
ddf6fe37 35883@item -minstrument-return=@var{type}
d77de738
ML
35884Instrument function exit in -pg -mfentry instrumented functions with
35885call to specified function. This only instruments true returns ending
35886with ret, but not sibling calls ending with jump. Valid types
35887are @var{none} to not instrument, @var{call} to generate a call to __return__,
35888or @var{nop5} to generate a 5 byte nop.
35889
ddf6fe37 35890@opindex mrecord-return
d77de738
ML
35891@item -mrecord-return
35892@itemx -mno-record-return
d77de738
ML
35893Generate a __return_loc section pointing to all return instrumentation code.
35894
d77de738 35895@opindex mfentry-name
ddf6fe37 35896@item -mfentry-name=@var{name}
d77de738
ML
35897Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
35898
d77de738 35899@opindex mfentry-section
ddf6fe37 35900@item -mfentry-section=@var{name}
d77de738
ML
35901Set name of section to record -mrecord-mcount calls (default __mcount_loc).
35902
ddf6fe37 35903@opindex mskip-rax-setup
d77de738
ML
35904@item -mskip-rax-setup
35905@itemx -mno-skip-rax-setup
d77de738
ML
35906When generating code for the x86-64 architecture with SSE extensions
35907disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
35908register when there are no variable arguments passed in vector registers.
35909
35910@strong{Warning:} Since RAX register is used to avoid unnecessarily
35911saving vector registers on stack when passing variable arguments, the
35912impacts of this option are callees may waste some stack space,
35913misbehave or jump to a random location. GCC 4.4 or newer don't have
35914those issues, regardless the RAX register value.
35915
ddf6fe37 35916@opindex m8bit-idiv
d77de738
ML
35917@item -m8bit-idiv
35918@itemx -mno-8bit-idiv
d77de738
ML
35919On some processors, like Intel Atom, 8-bit unsigned integer divide is
35920much faster than 32-bit/64-bit integer divide. This option generates a
35921run-time check. If both dividend and divisor are within range of 0
35922to 255, 8-bit unsigned integer divide is used instead of
3592332-bit/64-bit integer divide.
35924
d77de738
ML
35925@opindex mavx256-split-unaligned-load
35926@opindex mavx256-split-unaligned-store
ddf6fe37
AA
35927@item -mavx256-split-unaligned-load
35928@itemx -mavx256-split-unaligned-store
d77de738
ML
35929Split 32-byte AVX unaligned load and store.
35930
d77de738
ML
35931@opindex mstack-protector-guard
35932@opindex mstack-protector-guard-reg
35933@opindex mstack-protector-guard-offset
ddf6fe37
AA
35934@item -mstack-protector-guard=@var{guard}
35935@itemx -mstack-protector-guard-reg=@var{reg}
35936@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
35937Generate stack protection code using canary at @var{guard}. Supported
35938locations are @samp{global} for global canary or @samp{tls} for per-thread
35939canary in the TLS block (the default). This option has effect only when
35940@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
35941
35942With the latter choice the options
35943@option{-mstack-protector-guard-reg=@var{reg}} and
35944@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
35945which segment register (@code{%fs} or @code{%gs}) to use as base register
35946for reading the canary, and from what offset from that base register.
35947The default for those is as specified in the relevant ABI.
35948
d77de738 35949@opindex mgeneral-regs-only
ddf6fe37 35950@item -mgeneral-regs-only
d77de738
ML
35951Generate code that uses only the general-purpose registers. This
35952prevents the compiler from using floating-point, vector, mask and bound
35953registers.
35954
d77de738 35955@opindex mrelax-cmpxchg-loop
ddf6fe37 35956@item -mrelax-cmpxchg-loop
85966f0d
AM
35957When emitting a compare-and-swap loop for @ref{__sync Builtins}
35958and @ref{__atomic Builtins} lacking a native instruction, optimize
35959for the highly contended case by issuing an atomic load before the
35960@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
35961to save CPU power when restarting the loop.
d77de738 35962
d77de738 35963@opindex mindirect-branch
ddf6fe37 35964@item -mindirect-branch=@var{choice}
d77de738
ML
35965Convert indirect call and jump with @var{choice}. The default is
35966@samp{keep}, which keeps indirect call and jump unmodified.
35967@samp{thunk} converts indirect call and jump to call and return thunk.
35968@samp{thunk-inline} converts indirect call and jump to inlined call
35969and return thunk. @samp{thunk-extern} converts indirect call and jump
35970to external call and return thunk provided in a separate object file.
35971You can control this behavior for a specific function by using the
35972function attribute @code{indirect_branch}. @xref{Function Attributes}.
35973
35974Note that @option{-mcmodel=large} is incompatible with
35975@option{-mindirect-branch=thunk} and
35976@option{-mindirect-branch=thunk-extern} since the thunk function may
35977not be reachable in the large code model.
35978
35979Note that @option{-mindirect-branch=thunk-extern} is compatible with
35980@option{-fcf-protection=branch} since the external thunk can be made
35981to enable control-flow check.
35982
d77de738 35983@opindex mfunction-return
ddf6fe37 35984@item -mfunction-return=@var{choice}
d77de738
ML
35985Convert function return with @var{choice}. The default is @samp{keep},
35986which keeps function return unmodified. @samp{thunk} converts function
35987return to call and return thunk. @samp{thunk-inline} converts function
35988return to inlined call and return thunk. @samp{thunk-extern} converts
35989function return to external call and return thunk provided in a separate
35990object file. You can control this behavior for a specific function by
35991using the function attribute @code{function_return}.
35992@xref{Function Attributes}.
35993
35994Note that @option{-mindirect-return=thunk-extern} is compatible with
35995@option{-fcf-protection=branch} since the external thunk can be made
35996to enable control-flow check.
35997
35998Note that @option{-mcmodel=large} is incompatible with
35999@option{-mfunction-return=thunk} and
36000@option{-mfunction-return=thunk-extern} since the thunk function may
36001not be reachable in the large code model.
36002
36003
d77de738 36004@opindex mindirect-branch-register
ddf6fe37 36005@item -mindirect-branch-register
d77de738
ML
36006Force indirect call and jump via register.
36007
d77de738 36008@opindex mharden-sls
ddf6fe37 36009@item -mharden-sls=@var{choice}
d77de738
ML
36010Generate code to mitigate against straight line speculation (SLS) with
36011@var{choice}. The default is @samp{none} which disables all SLS
36012hardening. @samp{return} enables SLS hardening for function returns.
36013@samp{indirect-jmp} enables SLS hardening for indirect jumps.
36014@samp{all} enables all SLS hardening.
36015
d77de738 36016@opindex mindirect-branch-cs-prefix
ddf6fe37 36017@item -mindirect-branch-cs-prefix
d77de738
ML
36018Add CS prefix to call and jmp to indirect thunk with branch target in
36019r8-r15 registers so that the call and jmp instruction length is 6 bytes
36020to allow them to be replaced with @samp{lfence; call *%r8-r15} or
36021@samp{lfence; jmp *%r8-r15} at run-time.
36022
7de5bb64
HW
36023@opindex mapx-inline-asm-use-gpr32
36024@item -mapx-inline-asm-use-gpr32
36025For inline asm support with APX, by default the EGPR feature was
36026disabled to prevent potential illegal instruction with EGPR occurs.
36027To invoke egpr usage in inline asm, use new compiler option
36028-mapx-inline-asm-use-gpr32 and user should ensure the instruction
36029supports EGPR.
36030
49a14ee4
HJ
36031@opindex mevex512
36032@item -mevex512
36033@itemx -mno-evex512
36034Enables/disables 512-bit vector. It will be default on if AVX512F is enabled.
36035
d77de738
ML
36036@end table
36037
36038These @samp{-m} switches are supported in addition to the above
36039on x86-64 processors in 64-bit environments.
36040
36041@table @gcctabopt
d77de738
ML
36042@opindex m32
36043@opindex m64
36044@opindex mx32
36045@opindex m16
36046@opindex miamcu
ddf6fe37
AA
36047@item -m32
36048@itemx -m64
36049@itemx -mx32
36050@itemx -m16
36051@itemx -miamcu
d77de738
ML
36052Generate code for a 16-bit, 32-bit or 64-bit environment.
36053The @option{-m32} option sets @code{int}, @code{long}, and pointer types
36054to 32 bits, and
eeb92704 36055generates code that runs in 32-bit mode.
d77de738
ML
36056
36057The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
36058types to 64 bits, and generates code for the x86-64 architecture.
36059For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
36060and @option{-mdynamic-no-pic} options.
36061
36062The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
36063to 32 bits, and
36064generates code for the x86-64 architecture.
36065
36066The @option{-m16} option is the same as @option{-m32}, except for that
36067it outputs the @code{.code16gcc} assembly directive at the beginning of
36068the assembly output so that the binary can run in 16-bit mode.
36069
36070The @option{-miamcu} option generates code which conforms to Intel MCU
36071psABI. It requires the @option{-m32} option to be turned on.
36072
d77de738
ML
36073@opindex mno-red-zone
36074@opindex mred-zone
ddf6fe37 36075@item -mno-red-zone
d77de738
ML
36076Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
36077by the x86-64 ABI; it is a 128-byte area beyond the location of the
36078stack pointer that is not modified by signal or interrupt handlers
36079and therefore can be used for temporary data without adjusting the stack
36080pointer. The flag @option{-mno-red-zone} disables this red zone.
36081
d77de738 36082@opindex mcmodel=small
ddf6fe37 36083@item -mcmodel=small
d77de738
ML
36084Generate code for the small code model: the program and its symbols must
36085be linked in the lower 2 GB of the address space. Pointers are 64 bits.
36086Programs can be statically or dynamically linked. This is the default
36087code model.
36088
d77de738 36089@opindex mcmodel=kernel
ddf6fe37 36090@item -mcmodel=kernel
d77de738
ML
36091Generate code for the kernel code model. The kernel runs in the
36092negative 2 GB of the address space.
36093This model has to be used for Linux kernel code.
36094
d77de738 36095@opindex mcmodel=medium
ddf6fe37 36096@item -mcmodel=medium
d77de738
ML
36097Generate code for the medium model: the program is linked in the lower 2
36098GB of the address space. Small symbols are also placed there. Symbols
36099with sizes larger than @option{-mlarge-data-threshold} are put into
36100large data or BSS sections and can be located above 2GB. Programs can
36101be statically or dynamically linked.
36102
d77de738 36103@opindex mcmodel=large
ddf6fe37 36104@item -mcmodel=large
d77de738
ML
36105Generate code for the large model. This model makes no assumptions
36106about addresses and sizes of sections.
36107
d77de738 36108@opindex maddress-mode=long
ddf6fe37 36109@item -maddress-mode=long
d77de738
ML
36110Generate code for long address mode. This is only supported for 64-bit
36111and x32 environments. It is the default address mode for 64-bit
36112environments.
36113
d77de738 36114@opindex maddress-mode=short
ddf6fe37 36115@item -maddress-mode=short
d77de738
ML
36116Generate code for short address mode. This is only supported for 32-bit
36117and x32 environments. It is the default address mode for 32-bit and
36118x32 environments.
36119
ddf6fe37 36120@opindex mneeded
d77de738
ML
36121@item -mneeded
36122@itemx -mno-needed
d77de738
ML
36123Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
36124indicate the micro-architecture ISA level required to execute the binary.
36125
d77de738
ML
36126@opindex mno-direct-extern-access
36127@opindex mdirect-extern-access
ddf6fe37 36128@item -mno-direct-extern-access
d77de738
ML
36129Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
36130to access external symbols. With @option{-fpic} or @option{-fPIC},
36131treat access to protected symbols as local symbols. The default is
36132@option{-mdirect-extern-access}.
36133
36134@strong{Warning:} shared libraries compiled with
36135@option{-mno-direct-extern-access} and executable compiled with
36136@option{-mdirect-extern-access} may not be binary compatible if
36137protected symbols are used in shared libraries and executable.
ce51e843 36138
ce51e843
ML
36139@opindex munroll-only-small-loops
36140@opindex mno-unroll-only-small-loops
ddf6fe37 36141@item -munroll-only-small-loops
ce51e843
ML
36142Controls conservative small loop unrolling. It is default enabled by
36143O2, and unrolls loop with less than 4 insns by 1 time. Explicit
36144-f[no-]unroll-[all-]loops would disable this flag to avoid any
36145unintended unrolling behavior that user does not want.
bb576017 36146
bb576017 36147@opindex mlam
ddf6fe37 36148@item -mlam=@var{choice}
bb576017 36149LAM(linear-address masking) allows special bits in the pointer to be used
36150for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
36151positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
36152positions 62:57 can be used for metadata.
d77de738
ML
36153@end table
36154
36155@node x86 Windows Options
36156@subsection x86 Windows Options
36157@cindex x86 Windows Options
36158@cindex Windows Options for x86
36159
36160These additional options are available for Microsoft Windows targets:
36161
36162@table @gcctabopt
d77de738 36163@opindex mconsole
ddf6fe37 36164@item -mconsole
d77de738
ML
36165This option
36166specifies that a console application is to be generated, by
36167instructing the linker to set the PE header subsystem type
36168required for console applications.
36169This option is available for Cygwin and MinGW targets and is
36170enabled by default on those targets.
36171
453cb585
PR
36172@opindex mcrtdll
36173@item -mcrtdll=@var{library}
36174Preprocess, compile or link with specified C RunTime DLL @var{library}.
36175This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__}
36176and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose
36177start file for CRT @var{library} and link with CRT @var{library}.
36178Recognized CRT library names for proprocessor are:
36179@code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40},
36180@code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90},
36181@code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}.
36182If this options is not specified then the default MinGW import library
36183@code{msvcrt} is used for linking and no other adjustment for
36184preprocessor is done. MinGW import library @code{msvcrt} is just a
36185symlink to (or a copy of) another MinGW CRT import library
36186chosen during MinGW compilation. MinGW import library @code{msvcrt-os}
36187is for Windows system CRT DLL library @code{msvcrt.dll} and
36188in most cases is the default MinGW import library.
36189Generally speaking, changing the CRT DLL requires recompiling
36190the entire MinGW CRT. This option is for experimental and testing
36191purposes only.
36192This option is available for MinGW targets.
36193
d77de738 36194@opindex mdll
ddf6fe37 36195@item -mdll
d77de738
ML
36196This option is available for Cygwin and MinGW targets. It
36197specifies that a DLL---a dynamic link library---is to be
36198generated, enabling the selection of the required runtime
36199startup object and entry point.
36200
d77de738 36201@opindex mnop-fun-dllimport
ddf6fe37 36202@item -mnop-fun-dllimport
d77de738
ML
36203This option is available for Cygwin and MinGW targets. It
36204specifies that the @code{dllimport} attribute should be ignored.
36205
d77de738 36206@opindex mthreads
ddf6fe37 36207@item -mthreads
d77de738
ML
36208This option is available for MinGW targets. It specifies
36209that MinGW-specific thread support is to be used.
36210
d77de738 36211@opindex municode
ddf6fe37 36212@item -municode
d77de738
ML
36213This option is available for MinGW-w64 targets. It causes
36214the @code{UNICODE} preprocessor macro to be predefined, and
36215chooses Unicode-capable runtime startup code.
36216
d77de738 36217@opindex mwin32
ddf6fe37 36218@item -mwin32
d77de738
ML
36219This option is available for Cygwin and MinGW targets. It
36220specifies that the typical Microsoft Windows predefined macros are to
36221be set in the pre-processor, but does not influence the choice
36222of runtime library/startup code.
36223
d77de738 36224@opindex mwindows
ddf6fe37 36225@item -mwindows
d77de738
ML
36226This option is available for Cygwin and MinGW targets. It
36227specifies that a GUI application is to be generated by
36228instructing the linker to set the PE header subsystem type
36229appropriately.
36230
d77de738
ML
36231@opindex fno-set-stack-executable
36232@opindex fset-stack-executable
ddf6fe37 36233@item -fno-set-stack-executable
d77de738
ML
36234This option is available for MinGW targets. It specifies that
36235the executable flag for the stack used by nested functions isn't
36236set. This is necessary for binaries running in kernel mode of
36237Microsoft Windows, as there the User32 API, which is used to set executable
36238privileges, isn't available.
36239
d77de738
ML
36240@opindex fno-writable-relocated-rdata
36241@opindex fwritable-relocated-rdata
ddf6fe37 36242@item -fwritable-relocated-rdata
d77de738
ML
36243This option is available for MinGW and Cygwin targets. It specifies
36244that relocated-data in read-only section is put into the @code{.data}
36245section. This is a necessary for older runtimes not supporting
36246modification of @code{.rdata} sections for pseudo-relocation.
36247
d77de738 36248@opindex mpe-aligned-commons
ddf6fe37 36249@item -mpe-aligned-commons
d77de738
ML
36250This option is available for Cygwin and MinGW targets. It
36251specifies that the GNU extension to the PE file format that
36252permits the correct alignment of COMMON variables should be
36253used when generating code. It is enabled by default if
36254GCC detects that the target assembler found during configuration
36255supports the feature.
36256@end table
36257
36258See also under @ref{x86 Options} for standard options.
36259
36260@node Xstormy16 Options
36261@subsection Xstormy16 Options
36262@cindex Xstormy16 Options
36263
36264These options are defined for Xstormy16:
36265
36266@table @gcctabopt
d77de738 36267@opindex msim
ddf6fe37 36268@item -msim
d77de738
ML
36269Choose startup files and linker script suitable for the simulator.
36270@end table
36271
36272@node Xtensa Options
36273@subsection Xtensa Options
36274@cindex Xtensa Options
36275
36276These options are supported for Xtensa targets:
36277
36278@table @gcctabopt
d77de738
ML
36279@opindex mconst16
36280@opindex mno-const16
ddf6fe37
AA
36281@item -mconst16
36282@itemx -mno-const16
d77de738
ML
36283Enable or disable use of @code{CONST16} instructions for loading
36284constant values. The @code{CONST16} instruction is currently not a
36285standard option from Tensilica. When enabled, @code{CONST16}
36286instructions are always used in place of the standard @code{L32R}
36287instructions. The use of @code{CONST16} is enabled by default only if
36288the @code{L32R} instruction is not available.
36289
d77de738
ML
36290@opindex mfused-madd
36291@opindex mno-fused-madd
ddf6fe37
AA
36292@item -mfused-madd
36293@itemx -mno-fused-madd
d77de738
ML
36294Enable or disable use of fused multiply/add and multiply/subtract
36295instructions in the floating-point option. This has no effect if the
36296floating-point option is not also enabled. Disabling fused multiply/add
36297and multiply/subtract instructions forces the compiler to use separate
36298instructions for the multiply and add/subtract operations. This may be
36299desirable in some cases where strict IEEE 754-compliant results are
36300required: the fused multiply add/subtract instructions do not round the
36301intermediate result, thereby producing results with @emph{more} bits of
36302precision than specified by the IEEE standard. Disabling fused multiply
36303add/subtract instructions also ensures that the program output is not
36304sensitive to the compiler's ability to combine multiply and add/subtract
36305operations.
36306
d77de738
ML
36307@opindex mserialize-volatile
36308@opindex mno-serialize-volatile
ddf6fe37
AA
36309@item -mserialize-volatile
36310@itemx -mno-serialize-volatile
d77de738
ML
36311When this option is enabled, GCC inserts @code{MEMW} instructions before
36312@code{volatile} memory references to guarantee sequential consistency.
36313The default is @option{-mserialize-volatile}. Use
36314@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
36315
d77de738 36316@opindex mforce-no-pic
ddf6fe37 36317@item -mforce-no-pic
d77de738
ML
36318For targets, like GNU/Linux, where all user-mode Xtensa code must be
36319position-independent code (PIC), this option disables PIC for compiling
36320kernel code.
36321
d77de738
ML
36322@opindex mtext-section-literals
36323@opindex mno-text-section-literals
ddf6fe37
AA
36324@item -mtext-section-literals
36325@itemx -mno-text-section-literals
d77de738
ML
36326These options control the treatment of literal pools. The default is
36327@option{-mno-text-section-literals}, which places literals in a separate
36328section in the output file. This allows the literal pool to be placed
36329in a data RAM/ROM, and it also allows the linker to combine literal
36330pools from separate object files to remove redundant literals and
36331improve code size. With @option{-mtext-section-literals}, the literals
36332are interspersed in the text section in order to keep them as close as
36333possible to their references. This may be necessary for large assembly
36334files. Literals for each function are placed right before that function.
36335
d77de738
ML
36336@opindex mauto-litpools
36337@opindex mno-auto-litpools
ddf6fe37
AA
36338@item -mauto-litpools
36339@itemx -mno-auto-litpools
d77de738
ML
36340These options control the treatment of literal pools. The default is
36341@option{-mno-auto-litpools}, which places literals in a separate
36342section in the output file unless @option{-mtext-section-literals} is
36343used. With @option{-mauto-litpools} the literals are interspersed in
36344the text section by the assembler. Compiler does not produce explicit
36345@code{.literal} directives and loads literals into registers with
36346@code{MOVI} instructions instead of @code{L32R} to let the assembler
36347do relaxation and place literals as necessary. This option allows
36348assembler to create several literal pools per function and assemble
36349very big functions, which may not be possible with
36350@option{-mtext-section-literals}.
36351
d77de738
ML
36352@opindex mtarget-align
36353@opindex mno-target-align
ddf6fe37
AA
36354@item -mtarget-align
36355@itemx -mno-target-align
d77de738
ML
36356When this option is enabled, GCC instructs the assembler to
36357automatically align instructions to reduce branch penalties at the
36358expense of some code density. The assembler attempts to widen density
36359instructions to align branch targets and the instructions following call
36360instructions. If there are not enough preceding safe density
36361instructions to align a target, no widening is performed. The
36362default is @option{-mtarget-align}. These options do not affect the
36363treatment of auto-aligned instructions like @code{LOOP}, which the
36364assembler always aligns, either by widening density instructions or
36365by inserting NOP instructions.
36366
d77de738
ML
36367@opindex mlongcalls
36368@opindex mno-longcalls
ddf6fe37
AA
36369@item -mlongcalls
36370@itemx -mno-longcalls
d77de738
ML
36371When this option is enabled, GCC instructs the assembler to translate
36372direct calls to indirect calls unless it can determine that the target
36373of a direct call is in the range allowed by the call instruction. This
36374translation typically occurs for calls to functions in other source
36375files. Specifically, the assembler translates a direct @code{CALL}
36376instruction into an @code{L32R} followed by a @code{CALLX} instruction.
36377The default is @option{-mno-longcalls}. This option should be used in
36378programs where the call target can potentially be out of range. This
36379option is implemented in the assembler, not the compiler, so the
36380assembly code generated by GCC still shows direct call
36381instructions---look at the disassembled object code to see the actual
36382instructions. Note that the assembler uses an indirect call for
36383every cross-file call, not just those that really are out of range.
36384
d77de738 36385@opindex mabi
ddf6fe37 36386@item -mabi=@var{name}
d77de738
ML
36387Generate code for the specified ABI@. Permissible values are: @samp{call0},
36388@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
36389
d77de738 36390@opindex mabi=call0
ddf6fe37 36391@item -mabi=call0
d77de738
ML
36392When this option is enabled function parameters are passed in registers
36393@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
36394caller-saved, and register @code{a15} may be used as a frame pointer.
36395When this version of the ABI is enabled the C preprocessor symbol
36396@code{__XTENSA_CALL0_ABI__} is defined.
36397
d77de738 36398@opindex mabi=windowed
ddf6fe37 36399@item -mabi=windowed
d77de738
ML
36400When this option is enabled function parameters are passed in registers
36401@code{a10} through @code{a15}, and called function rotates register window
36402by 8 registers on entry so that its arguments are found in registers
36403@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
36404pointer. Register window is rotated 8 registers back upon return.
36405When this version of the ABI is enabled the C preprocessor symbol
36406@code{__XTENSA_WINDOWED_ABI__} is defined.
36407
d77de738 36408@opindex mextra-l32r-costs
ddf6fe37 36409@item -mextra-l32r-costs=@var{n}
d77de738
ML
36410Specify an extra cost of instruction RAM/ROM access for @code{L32R}
36411instructions, in clock cycles. This affects, when optimizing for speed,
36412whether loading a constant from literal pool using @code{L32R} or
36413synthesizing the constant from a small one with a couple of arithmetic
36414instructions. The default value is 0.
675b390e
MF
36415
36416@opindex mstrict-align
36417@opindex mno-strict-align
36418@item -mstrict-align
36419@itemx -mno-strict-align
36420Avoid or allow generating memory accesses that may not be aligned on a natural
36421object boundary as described in the architecture specification.
36422The default is @option{-mno-strict-align} for cores that support both
36423unaligned loads and stores in hardware and @option{-mstrict-align} for all
36424other cores.
36425
d77de738
ML
36426@end table
36427
36428@node zSeries Options
36429@subsection zSeries Options
36430@cindex zSeries options
36431
36432These are listed under @xref{S/390 and zSeries Options}.
36433
36434
36435@c man end
36436
36437@node Spec Files
36438@section Specifying Subprocesses and the Switches to Pass to Them
36439@cindex Spec Files
36440
36441@command{gcc} is a driver program. It performs its job by invoking a
36442sequence of other programs to do the work of compiling, assembling and
36443linking. GCC interprets its command-line parameters and uses these to
36444deduce which programs it should invoke, and which command-line options
36445it ought to place on their command lines. This behavior is controlled
36446by @dfn{spec strings}. In most cases there is one spec string for each
36447program that GCC can invoke, but a few programs have multiple spec
36448strings to control their behavior. The spec strings built into GCC can
36449be overridden by using the @option{-specs=} command-line switch to specify
36450a spec file.
36451
36452@dfn{Spec files} are plain-text files that are used to construct spec
36453strings. They consist of a sequence of directives separated by blank
36454lines. The type of directive is determined by the first non-whitespace
36455character on the line, which can be one of the following:
36456
36457@table @code
36458@item %@var{command}
36459Issues a @var{command} to the spec file processor. The commands that can
36460appear here are:
36461
36462@table @code
d77de738 36463@cindex @code{%include}
f33d7a88 36464@item %include <@var{file}>
d77de738
ML
36465Search for @var{file} and insert its text at the current point in the
36466specs file.
36467
d77de738 36468@cindex @code{%include_noerr}
f33d7a88 36469@item %include_noerr <@var{file}>
d77de738
ML
36470Just like @samp{%include}, but do not generate an error message if the include
36471file cannot be found.
36472
d77de738 36473@cindex @code{%rename}
f33d7a88 36474@item %rename @var{old_name} @var{new_name}
d77de738
ML
36475Rename the spec string @var{old_name} to @var{new_name}.
36476
36477@end table
36478
36479@item *[@var{spec_name}]:
36480This tells the compiler to create, override or delete the named spec
36481string. All lines after this directive up to the next directive or
36482blank line are considered to be the text for the spec string. If this
36483results in an empty string then the spec is deleted. (Or, if the
36484spec did not exist, then nothing happens.) Otherwise, if the spec
36485does not currently exist a new spec is created. If the spec does
36486exist then its contents are overridden by the text of this
36487directive, unless the first character of that text is the @samp{+}
36488character, in which case the text is appended to the spec.
36489
36490@item [@var{suffix}]:
36491Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
36492and up to the next directive or blank line are considered to make up the
36493spec string for the indicated suffix. When the compiler encounters an
36494input file with the named suffix, it processes the spec string in
36495order to work out how to compile that file. For example:
36496
36497@smallexample
36498.ZZ:
36499z-compile -input %i
36500@end smallexample
36501
36502This says that any input file whose name ends in @samp{.ZZ} should be
36503passed to the program @samp{z-compile}, which should be invoked with the
36504command-line switch @option{-input} and with the result of performing the
36505@samp{%i} substitution. (See below.)
36506
36507As an alternative to providing a spec string, the text following a
36508suffix directive can be one of the following:
36509
36510@table @code
36511@item @@@var{language}
36512This says that the suffix is an alias for a known @var{language}. This is
36513similar to using the @option{-x} command-line switch to GCC to specify a
36514language explicitly. For example:
36515
36516@smallexample
36517.ZZ:
36518@@c++
36519@end smallexample
36520
36521Says that .ZZ files are, in fact, C++ source files.
36522
36523@item #@var{name}
36524This causes an error messages saying:
36525
36526@smallexample
36527@var{name} compiler not installed on this system.
36528@end smallexample
36529@end table
36530
36531GCC already has an extensive list of suffixes built into it.
36532This directive adds an entry to the end of the list of suffixes, but
36533since the list is searched from the end backwards, it is effectively
36534possible to override earlier entries using this technique.
36535
36536@end table
36537
36538GCC has the following spec strings built into it. Spec files can
36539override these strings or create their own. Note that individual
36540targets can also add their own spec strings to this list.
36541
36542@smallexample
36543asm Options to pass to the assembler
36544asm_final Options to pass to the assembler post-processor
36545cpp Options to pass to the C preprocessor
36546cc1 Options to pass to the C compiler
36547cc1plus Options to pass to the C++ compiler
36548endfile Object files to include at the end of the link
36549link Options to pass to the linker
36550lib Libraries to include on the command line to the linker
36551libgcc Decides which GCC support library to pass to the linker
36552linker Sets the name of the linker
36553predefines Defines to be passed to the C preprocessor
36554signed_char Defines to pass to CPP to say whether @code{char} is signed
36555 by default
36556startfile Object files to include at the start of the link
36557@end smallexample
36558
36559Here is a small example of a spec file:
36560
36561@smallexample
36562%rename lib old_lib
36563
36564*lib:
36565--start-group -lgcc -lc -leval1 --end-group %(old_lib)
36566@end smallexample
36567
36568This example renames the spec called @samp{lib} to @samp{old_lib} and
36569then overrides the previous definition of @samp{lib} with a new one.
36570The new definition adds in some extra command-line options before
36571including the text of the old definition.
36572
36573@dfn{Spec strings} are a list of command-line options to be passed to their
36574corresponding program. In addition, the spec strings can contain
36575@samp{%}-prefixed sequences to substitute variable text or to
36576conditionally insert text into the command line. Using these constructs
36577it is possible to generate quite complex command lines.
36578
36579Here is a table of all defined @samp{%}-sequences for spec
36580strings. Note that spaces are not generated automatically around the
36581results of expanding these sequences. Therefore you can concatenate them
36582together or combine them with constant text in a single argument.
36583
36584@table @code
36585@item %%
36586Substitute one @samp{%} into the program name or argument.
36587
36588@item %"
36589Substitute an empty argument.
36590
36591@item %i
36592Substitute the name of the input file being processed.
36593
36594@item %b
36595Substitute the basename for outputs related with the input file being
36596processed. This is often the substring up to (and not including) the
36597last period and not including the directory but, unless %w is active, it
36598expands to the basename for auxiliary outputs, which may be influenced
36599by an explicit output name, and by various other options that control
36600how auxiliary outputs are named.
36601
36602@item %B
36603This is the same as @samp{%b}, but include the file suffix (text after
36604the last period). Without %w, it expands to the basename for dump
36605outputs.
36606
36607@item %d
36608Marks the argument containing or following the @samp{%d} as a
36609temporary file name, so that that file is deleted if GCC exits
36610successfully. Unlike @samp{%g}, this contributes no text to the
36611argument.
36612
36613@item %g@var{suffix}
36614Substitute a file name that has suffix @var{suffix} and is chosen
36615once per compilation, and mark the argument in the same way as
36616@samp{%d}. To reduce exposure to denial-of-service attacks, the file
36617name is now chosen in a way that is hard to predict even when previously
36618chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
36619might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
36620the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
36621treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
36622was simply substituted with a file name chosen once per compilation,
36623without regard to any appended suffix (which was therefore treated
36624just like ordinary text), making such attacks more likely to succeed.
36625
36626@item %u@var{suffix}
36627Like @samp{%g}, but generates a new temporary file name
36628each time it appears instead of once per compilation.
36629
36630@item %U@var{suffix}
36631Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
36632new one if there is no such last file name. In the absence of any
36633@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
36634the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
36635involves the generation of two distinct file names, one
36636for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
36637simply substituted with a file name chosen for the previous @samp{%u},
36638without regard to any appended suffix.
36639
36640@item %j@var{suffix}
36641Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
36642writable, and if @option{-save-temps} is not used;
36643otherwise, substitute the name
36644of a temporary file, just like @samp{%u}. This temporary file is not
36645meant for communication between processes, but rather as a junk
36646disposal mechanism.
36647
36648@item %|@var{suffix}
36649@itemx %m@var{suffix}
36650Like @samp{%g}, except if @option{-pipe} is in effect. In that case
36651@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
36652all. These are the two most common ways to instruct a program that it
36653should read from standard input or write to standard output. If you
36654need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
36655construct: see for example @file{gcc/fortran/lang-specs.h}.
36656
36657@item %.@var{SUFFIX}
36658Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
36659when it is subsequently output with @samp{%*}. @var{SUFFIX} is
36660terminated by the next space or %.
36661
36662@item %w
36663Marks the argument containing or following the @samp{%w} as the
36664designated output file of this compilation. This puts the argument
36665into the sequence of arguments that @samp{%o} substitutes.
36666
36667@item %V
36668Indicates that this compilation produces no output file.
36669
36670@item %o
36671Substitutes the names of all the output files, with spaces
36672automatically placed around them. You should write spaces
36673around the @samp{%o} as well or the results are undefined.
36674@samp{%o} is for use in the specs for running the linker.
36675Input files whose names have no recognized suffix are not compiled
36676at all, but they are included among the output files, so they are
36677linked.
36678
36679@item %O
36680Substitutes the suffix for object files. Note that this is
36681handled specially when it immediately follows @samp{%g, %u, or %U},
36682because of the need for those to form complete file names. The
36683handling is such that @samp{%O} is treated exactly as if it had already
36684been substituted, except that @samp{%g, %u, and %U} do not currently
36685support additional @var{suffix} characters following @samp{%O} as they do
36686following, for example, @samp{.o}.
36687
36688@item %I
36689Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
36690@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
36691@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
36692and @option{-imultilib} as necessary.
36693
36694@item %s
36695Current argument is the name of a library or startup file of some sort.
36696Search for that file in a standard list of directories and substitute
36697the full name found. The current working directory is included in the
36698list of directories scanned.
36699
36700@item %T
36701Current argument is the name of a linker script. Search for that file
36702in the current list of directories to scan for libraries. If the file
36703is located insert a @option{--script} option into the command line
36704followed by the full path name found. If the file is not found then
36705generate an error message. Note: the current working directory is not
36706searched.
36707
36708@item %e@var{str}
36709Print @var{str} as an error message. @var{str} is terminated by a newline.
36710Use this when inconsistent options are detected.
36711
36712@item %n@var{str}
36713Print @var{str} as a notice. @var{str} is terminated by a newline.
36714
36715@item %(@var{name})
36716Substitute the contents of spec string @var{name} at this point.
36717
36718@item %x@{@var{option}@}
36719Accumulate an option for @samp{%X}.
36720
36721@item %X
36722Output the accumulated linker options specified by a @samp{%x} spec string.
36723
36724@item %Y
36725Output the accumulated assembler options specified by @option{-Wa}.
36726
36727@item %Z
36728Output the accumulated preprocessor options specified by @option{-Wp}.
36729
36730@item %M
36731Output @code{multilib_os_dir}.
36732
36733@item %R
36734Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
36735
36736@item %a
36737Process the @code{asm} spec. This is used to compute the
36738switches to be passed to the assembler.
36739
36740@item %A
36741Process the @code{asm_final} spec. This is a spec string for
36742passing switches to an assembler post-processor, if such a program is
36743needed.
36744
36745@item %l
36746Process the @code{link} spec. This is the spec for computing the
36747command line passed to the linker. Typically it makes use of the
36748@samp{%L %G %S %D and %E} sequences.
36749
36750@item %D
36751Dump out a @option{-L} option for each directory that GCC believes might
36752contain startup files. If the target supports multilibs then the
36753current multilib directory is prepended to each of these paths.
36754
36755@item %L
36756Process the @code{lib} spec. This is a spec string for deciding which
36757libraries are included on the command line to the linker.
36758
36759@item %G
36760Process the @code{libgcc} spec. This is a spec string for deciding
36761which GCC support library is included on the command line to the linker.
36762
36763@item %S
36764Process the @code{startfile} spec. This is a spec for deciding which
36765object files are the first ones passed to the linker. Typically
36766this might be a file named @file{crt0.o}.
36767
36768@item %E
36769Process the @code{endfile} spec. This is a spec string that specifies
36770the last object files that are passed to the linker.
36771
36772@item %C
36773Process the @code{cpp} spec. This is used to construct the arguments
36774to be passed to the C preprocessor.
36775
36776@item %1
36777Process the @code{cc1} spec. This is used to construct the options to be
36778passed to the actual C compiler (@command{cc1}).
36779
36780@item %2
36781Process the @code{cc1plus} spec. This is used to construct the options to be
36782passed to the actual C++ compiler (@command{cc1plus}).
36783
36784@item %*
36785Substitute the variable part of a matched option. See below.
36786Note that each comma in the substituted string is replaced by
36787a single space.
36788
36789@item %<S
36790Remove all occurrences of @code{-S} from the command line. Note---this
36791command is position dependent. @samp{%} commands in the spec string
36792before this one see @code{-S}, @samp{%} commands in the spec string
36793after this one do not.
36794
36795@item %<S*
36796Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
36797
36798@item %>S
36799Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
36800
36801@item %:@var{function}(@var{args})
36802Call the named function @var{function}, passing it @var{args}.
36803@var{args} is first processed as a nested spec string, then split
36804into an argument vector in the usual fashion. The function returns
36805a string which is processed as if it had appeared literally as part
36806of the current spec.
36807
36808The following built-in spec functions are provided:
36809
36810@table @code
36811@item @code{getenv}
36812The @code{getenv} spec function takes two arguments: an environment
36813variable name and a string. If the environment variable is not
36814defined, a fatal error is issued. Otherwise, the return value is the
36815value of the environment variable concatenated with the string. For
36816example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
36817
36818@smallexample
36819%:getenv(TOPDIR /include)
36820@end smallexample
36821
36822expands to @file{/path/to/top/include}.
36823
36824@item @code{if-exists}
36825The @code{if-exists} spec function takes one argument, an absolute
36826pathname to a file. If the file exists, @code{if-exists} returns the
36827pathname. Here is a small example of its usage:
36828
36829@smallexample
36830*startfile:
36831crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
36832@end smallexample
36833
36834@item @code{if-exists-else}
36835The @code{if-exists-else} spec function is similar to the @code{if-exists}
36836spec function, except that it takes two arguments. The first argument is
36837an absolute pathname to a file. If the file exists, @code{if-exists-else}
36838returns the pathname. If it does not exist, it returns the second argument.
36839This way, @code{if-exists-else} can be used to select one file or another,
36840based on the existence of the first. Here is a small example of its usage:
36841
36842@smallexample
36843*startfile:
36844crt0%O%s %:if-exists(crti%O%s) \
36845%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
36846@end smallexample
36847
36848@item @code{if-exists-then-else}
36849The @code{if-exists-then-else} spec function takes at least two arguments
36850and an optional third one. The first argument is an absolute pathname to a
36851file. If the file exists, the function returns the second argument.
36852If the file does not exist, the function returns the third argument if there
36853is one, or NULL otherwise. This can be used to expand one text, or optionally
36854another, based on the existence of a file. Here is a small example of its
36855usage:
36856
36857@smallexample
36858-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
36859@end smallexample
36860
36861@item @code{sanitize}
36862The @code{sanitize} spec function takes no arguments. It returns non-NULL if
36863any address, thread or undefined behavior sanitizers are active.
36864
36865@smallexample
36866%@{%:sanitize(address):-funwind-tables@}
36867@end smallexample
36868
36869@item @code{replace-outfile}
36870The @code{replace-outfile} spec function takes two arguments. It looks for the
36871first argument in the outfiles array and replaces it with the second argument. Here
36872is a small example of its usage:
36873
36874@smallexample
36875%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
36876@end smallexample
36877
36878@item @code{remove-outfile}
36879The @code{remove-outfile} spec function takes one argument. It looks for the
36880first argument in the outfiles array and removes it. Here is a small example
36881its usage:
36882
36883@smallexample
36884%:remove-outfile(-lm)
36885@end smallexample
36886
36887@item @code{version-compare}
36888The @code{version-compare} spec function takes four or five arguments of the following
36889form:
36890
36891@smallexample
36892<comparison-op> <arg1> [<arg2>] <switch> <result>
36893@end smallexample
36894
36895It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
36896The supported @code{comparison-op} values are:
36897
36898@table @code
36899@item >=
36900True if @code{switch} is a later (or same) version than @code{arg1}
36901
36902@item !>
36903Opposite of @code{>=}
36904
36905@item <
36906True if @code{switch} is an earlier version than @code{arg1}
36907
36908@item !<
36909Opposite of @code{<}
36910
36911@item ><
36912True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
36913
36914@item <>
36915True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
36916@end table
36917
36918If the @code{switch} is not present at all, the condition is false unless the first character
36919of the @code{comparison-op} is @code{!}.
36920
36921@smallexample
36922%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
36923@end smallexample
36924
36925The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
36926passed.
36927
36928@item @code{include}
36929The @code{include} spec function behaves much like @code{%include}, with the advantage
36930that it can be nested inside a spec and thus be conditionalized. It takes one argument,
36931the filename, and looks for it in the startfile path. It always returns NULL.
36932
36933@smallexample
36934%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
36935@end smallexample
36936
36937@item @code{pass-through-libs}
36938The @code{pass-through-libs} spec function takes any number of arguments. It
36939finds any @option{-l} options and any non-options ending in @file{.a} (which it
36940assumes are the names of linker input library archive files) and returns a
36941result containing all the found arguments each prepended by
36942@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
36943intended to be passed to the LTO linker plugin.
36944
36945@smallexample
36946%:pass-through-libs(%G %L %G)
36947@end smallexample
36948
36949@item @code{print-asm-header}
36950The @code{print-asm-header} function takes no arguments and simply
36951prints a banner like:
36952
36953@smallexample
36954Assembler options
36955=================
36956
36957Use "-Wa,OPTION" to pass "OPTION" to the assembler.
36958@end smallexample
36959
36960It is used to separate compiler options from assembler options
36961in the @option{--target-help} output.
36962
36963@item @code{gt}
36964The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
36965empty string) if the second-to-last argument is greater than the last argument, and NULL
36966otherwise. The following example inserts the @code{link_gomp} spec if the last
36967@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
36968
36969@smallexample
36970%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
36971@end smallexample
36972
36973@item @code{debug-level-gt}
36974The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
36975empty string) if @code{debug_info_level} is greater than the specified number, and NULL
36976otherwise.
36977
36978@smallexample
36979%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
36980@end smallexample
36981@end table
36982
36983@item %@{S@}
36984Substitutes the @code{-S} switch, if that switch is given to GCC@.
36985If that switch is not specified, this substitutes nothing. Note that
36986the leading dash is omitted when specifying this option, and it is
36987automatically inserted if the substitution is performed. Thus the spec
36988string @samp{%@{foo@}} matches the command-line option @option{-foo}
36989and outputs the command-line option @option{-foo}.
36990
36991@item %W@{S@}
36992Like %@{@code{S}@} but mark last argument supplied within as a file to be
36993deleted on failure.
36994
36995@item %@@@{S@}
36996Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
36997@code{@@FILE} if an @code{@@file} argument has been supplied.
36998
36999@item %@{S*@}
37000Substitutes all the switches specified to GCC whose names start
37001with @code{-S}, but which also take an argument. This is used for
37002switches like @option{-o}, @option{-D}, @option{-I}, etc.
37003GCC considers @option{-o foo} as being
37004one switch whose name starts with @samp{o}. %@{o*@} substitutes this
37005text, including the space. Thus two arguments are generated.
37006
37007@item %@{S*&T*@}
37008Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
37009(the order of @code{S} and @code{T} in the spec is not significant).
37010There can be any number of ampersand-separated variables; for each the
37011wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
37012
37013@item %@{S:X@}
37014Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
37015
37016@item %@{!S:X@}
37017Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
37018
37019@item %@{S*:X@}
37020Substitutes @code{X} if one or more switches whose names start with
37021@code{-S} are specified to GCC@. Normally @code{X} is substituted only
37022once, no matter how many such switches appeared. However, if @code{%*}
37023appears somewhere in @code{X}, then @code{X} is substituted once
37024for each matching switch, with the @code{%*} replaced by the part of
37025that switch matching the @code{*}.
37026
37027If @code{%*} appears as the last part of a spec sequence then a space
37028is added after the end of the last substitution. If there is more
37029text in the sequence, however, then a space is not generated. This
37030allows the @code{%*} substitution to be used as part of a larger
37031string. For example, a spec string like this:
37032
37033@smallexample
37034%@{mcu=*:--script=%*/memory.ld@}
37035@end smallexample
37036
37037@noindent
37038when matching an option like @option{-mcu=newchip} produces:
37039
37040@smallexample
37041--script=newchip/memory.ld
37042@end smallexample
37043
37044@item %@{.S:X@}
37045Substitutes @code{X}, if processing a file with suffix @code{S}.
37046
37047@item %@{!.S:X@}
37048Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
37049
37050@item %@{,S:X@}
37051Substitutes @code{X}, if processing a file for language @code{S}.
37052
37053@item %@{!,S:X@}
37054Substitutes @code{X}, if not processing a file for language @code{S}.
37055
37056@item %@{S|P:X@}
37057Substitutes @code{X} if either @code{-S} or @code{-P} is given to
37058GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
37059@code{*} sequences as well, although they have a stronger binding than
37060the @samp{|}. If @code{%*} appears in @code{X}, all of the
37061alternatives must be starred, and only the first matching alternative
37062is substituted.
37063
37064For example, a spec string like this:
37065
37066@smallexample
37067%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
37068@end smallexample
37069
37070@noindent
37071outputs the following command-line options from the following input
37072command-line options:
37073
37074@smallexample
37075fred.c -foo -baz
37076jim.d -bar -boggle
37077-d fred.c -foo -baz -boggle
37078-d jim.d -bar -baz -boggle
37079@end smallexample
37080
37081@item %@{%:@var{function}(@var{args}):X@}
37082
37083Call function named @var{function} with args @var{args}. If the
37084function returns non-NULL, then @code{X} is substituted, if it returns
37085NULL, it isn't substituted.
37086
37087@item %@{S:X; T:Y; :D@}
37088
37089If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
37090given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
37091be as many clauses as you need. This may be combined with @code{.},
37092@code{,}, @code{!}, @code{|}, and @code{*} as needed.
37093
37094
37095@end table
37096
37097The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
37098or similar construct can use a backslash to ignore the special meaning
37099of the character following it, thus allowing literal matching of a
37100character that is otherwise specially treated. For example,
37101@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
37102@option{-std=iso9899:1999} option is given.
37103
37104The conditional text @code{X} in a @samp{%@{S:X@}} or similar
37105construct may contain other nested @samp{%} constructs or spaces, or
37106even newlines. They are processed as usual, as described above.
37107Trailing white space in @code{X} is ignored. White space may also
37108appear anywhere on the left side of the colon in these constructs,
37109except between @code{.} or @code{*} and the corresponding word.
37110
37111The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
37112handled specifically in these constructs. If another value of
37113@option{-O} or the negated form of a @option{-f}, @option{-m}, or
37114@option{-W} switch is found later in the command line, the earlier
37115switch value is ignored, except with @{@code{S}*@} where @code{S} is
37116just one letter, which passes all matching options.
37117
37118The character @samp{|} at the beginning of the predicate text is used to
37119indicate that a command should be piped to the following command, but
37120only if @option{-pipe} is specified.
37121
37122It is built into GCC which switches take arguments and which do not.
37123(You might think it would be useful to generalize this to allow each
37124compiler's spec to say which switches take arguments. But this cannot
37125be done in a consistent fashion. GCC cannot even decide which input
37126files have been specified without knowing which switches take arguments,
37127and it must know which input files to compile in order to tell which
37128compilers to run).
37129
37130GCC also knows implicitly that arguments starting in @option{-l} are to be
37131treated as compiler output files, and passed to the linker in their
37132proper position among the other output files.
37133
37134@node Environment Variables
37135@section Environment Variables Affecting GCC
37136@cindex environment variables
37137
37138@c man begin ENVIRONMENT
37139This section describes several environment variables that affect how GCC
37140operates. Some of them work by specifying directories or prefixes to use
37141when searching for various kinds of files. Some are used to specify other
37142aspects of the compilation environment.
37143
37144Note that you can also specify places to search using options such as
37145@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
37146take precedence over places specified using environment variables, which
37147in turn take precedence over those specified by the configuration of GCC@.
37148@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
37149GNU Compiler Collection (GCC) Internals}.
37150
37151@table @env
f33d7a88
AA
37152@vindex LANG
37153@vindex LC_CTYPE
37154@c @vindex LC_COLLATE
37155@vindex LC_MESSAGES
37156@c @vindex LC_MONETARY
37157@c @vindex LC_NUMERIC
37158@c @vindex LC_TIME
37159@vindex LC_ALL
37160@cindex locale
d77de738
ML
37161@item LANG
37162@itemx LC_CTYPE
37163@c @itemx LC_COLLATE
37164@itemx LC_MESSAGES
37165@c @itemx LC_MONETARY
37166@c @itemx LC_NUMERIC
37167@c @itemx LC_TIME
37168@itemx LC_ALL
d77de738
ML
37169These environment variables control the way that GCC uses
37170localization information which allows GCC to work with different
37171national conventions. GCC inspects the locale categories
37172@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
37173so. These locale categories can be set to any value supported by your
37174installation. A typical value is @samp{en_GB.UTF-8} for English in the United
37175Kingdom encoded in UTF-8.
37176
37177The @env{LC_CTYPE} environment variable specifies character
37178classification. GCC uses it to determine the character boundaries in
37179a string; this is needed for some multibyte encodings that contain quote
37180and escape characters that are otherwise interpreted as a string
37181end or escape.
37182
37183The @env{LC_MESSAGES} environment variable specifies the language to
37184use in diagnostic messages.
37185
37186If the @env{LC_ALL} environment variable is set, it overrides the value
37187of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
37188and @env{LC_MESSAGES} default to the value of the @env{LANG}
37189environment variable. If none of these variables are set, GCC
37190defaults to traditional C English behavior.
37191
f33d7a88 37192@vindex TMPDIR
d77de738 37193@item TMPDIR
d77de738
ML
37194If @env{TMPDIR} is set, it specifies the directory to use for temporary
37195files. GCC uses temporary files to hold the output of one stage of
37196compilation which is to be used as input to the next stage: for example,
37197the output of the preprocessor, which is the input to the compiler
37198proper.
37199
f33d7a88 37200@vindex GCC_COMPARE_DEBUG
d77de738 37201@item GCC_COMPARE_DEBUG
d77de738
ML
37202Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
37203@option{-fcompare-debug} to the compiler driver. See the documentation
37204of this option for more details.
37205
f33d7a88 37206@vindex GCC_EXEC_PREFIX
d77de738 37207@item GCC_EXEC_PREFIX
d77de738
ML
37208If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
37209names of the subprograms executed by the compiler. No slash is added
37210when this prefix is combined with the name of a subprogram, but you can
37211specify a prefix that ends with a slash if you wish.
37212
37213If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
37214an appropriate prefix to use based on the pathname it is invoked with.
37215
37216If GCC cannot find the subprogram using the specified prefix, it
37217tries looking in the usual places for the subprogram.
37218
37219The default value of @env{GCC_EXEC_PREFIX} is
37220@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
37221the installed compiler. In many cases @var{prefix} is the value
37222of @code{prefix} when you ran the @file{configure} script.
37223
37224Other prefixes specified with @option{-B} take precedence over this prefix.
37225
37226This prefix is also used for finding files such as @file{crt0.o} that are
37227used for linking.
37228
37229In addition, the prefix is used in an unusual way in finding the
37230directories to search for header files. For each of the standard
37231directories whose name normally begins with @samp{/usr/local/lib/gcc}
37232(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
37233replacing that beginning with the specified prefix to produce an
37234alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
37235@file{foo/bar} just before it searches the standard directory
37236@file{/usr/local/lib/bar}.
37237If a standard directory begins with the configured
37238@var{prefix} then the value of @var{prefix} is replaced by
37239@env{GCC_EXEC_PREFIX} when looking for header files.
37240
f33d7a88 37241@vindex COMPILER_PATH
d77de738 37242@item COMPILER_PATH
d77de738
ML
37243The value of @env{COMPILER_PATH} is a colon-separated list of
37244directories, much like @env{PATH}. GCC tries the directories thus
37245specified when searching for subprograms, if it cannot find the
37246subprograms using @env{GCC_EXEC_PREFIX}.
37247
f33d7a88 37248@vindex LIBRARY_PATH
d77de738 37249@item LIBRARY_PATH
d77de738
ML
37250The value of @env{LIBRARY_PATH} is a colon-separated list of
37251directories, much like @env{PATH}. When configured as a native compiler,
37252GCC tries the directories thus specified when searching for special
37253linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
37254using GCC also uses these directories when searching for ordinary
37255libraries for the @option{-l} option (but directories specified with
37256@option{-L} come first).
37257
f33d7a88 37258@vindex LANG
d77de738 37259@cindex locale definition
f33d7a88 37260@item LANG
d77de738
ML
37261This variable is used to pass locale information to the compiler. One way in
37262which this information is used is to determine the character set to be used
37263when character literals, string literals and comments are parsed in C and C++.
37264When the compiler is configured to allow multibyte characters,
37265the following values for @env{LANG} are recognized:
37266
37267@table @samp
37268@item C-JIS
37269Recognize JIS characters.
37270@item C-SJIS
37271Recognize SJIS characters.
37272@item C-EUCJP
37273Recognize EUCJP characters.
37274@end table
37275
37276If @env{LANG} is not defined, or if it has some other value, then the
37277compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
37278recognize and translate multibyte characters.
37279
f33d7a88 37280@vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738 37281@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738
ML
37282If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
37283then additional text will be emitted to stderr when fix-it hints are
37284emitted. @option{-fdiagnostics-parseable-fixits} and
37285@option{-fno-diagnostics-parseable-fixits} take precedence over this
37286environment variable.
37287
37288@table @samp
37289@item fixits-v1
37290Emit parseable fix-it hints, equivalent to
37291@option{-fdiagnostics-parseable-fixits}. In particular, columns are
37292expressed as a count of bytes, starting at byte 1 for the initial column.
37293
37294@item fixits-v2
37295As @code{fixits-v1}, but columns are expressed as display columns,
37296as per @option{-fdiagnostics-column-unit=display}.
37297@end table
37298
37299@end table
37300
37301@noindent
37302Some additional environment variables affect the behavior of the
37303preprocessor.
37304
37305@include cppenv.texi
37306
37307@c man end
37308
37309@node Precompiled Headers
37310@section Using Precompiled Headers
37311@cindex precompiled headers
37312@cindex speed of compilation
37313
37314Often large projects have many header files that are included in every
37315source file. The time the compiler takes to process these header files
37316over and over again can account for nearly all of the time required to
37317build the project. To make builds faster, GCC allows you to
37318@dfn{precompile} a header file.
37319
37320To create a precompiled header file, simply compile it as you would any
37321other file, if necessary using the @option{-x} option to make the driver
37322treat it as a C or C++ header file. You may want to use a
37323tool like @command{make} to keep the precompiled header up-to-date when
37324the headers it contains change.
37325
37326A precompiled header file is searched for when @code{#include} is
37327seen in the compilation. As it searches for the included file
37328(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
37329compiler looks for a precompiled header in each directory just before it
37330looks for the include file in that directory. The name searched for is
37331the name specified in the @code{#include} with @samp{.gch} appended. If
37332the precompiled header file cannot be used, it is ignored.
37333
37334For instance, if you have @code{#include "all.h"}, and you have
37335@file{all.h.gch} in the same directory as @file{all.h}, then the
37336precompiled header file is used if possible, and the original
37337header is used otherwise.
37338
37339Alternatively, you might decide to put the precompiled header file in a
37340directory and use @option{-I} to ensure that directory is searched
37341before (or instead of) the directory containing the original header.
37342Then, if you want to check that the precompiled header file is always
37343used, you can put a file of the same name as the original header in this
37344directory containing an @code{#error} command.
37345
37346This also works with @option{-include}. So yet another way to use
37347precompiled headers, good for projects not designed with precompiled
37348header files in mind, is to simply take most of the header files used by
37349a project, include them from another header file, precompile that header
37350file, and @option{-include} the precompiled header. If the header files
37351have guards against multiple inclusion, they are skipped because
37352they've already been included (in the precompiled header).
37353
37354If you need to precompile the same header file for different
37355languages, targets, or compiler options, you can instead make a
37356@emph{directory} named like @file{all.h.gch}, and put each precompiled
37357header in the directory, perhaps using @option{-o}. It doesn't matter
37358what you call the files in the directory; every precompiled header in
37359the directory is considered. The first precompiled header
37360encountered in the directory that is valid for this compilation is
37361used; they're searched in no particular order.
37362
37363There are many other possibilities, limited only by your imagination,
37364good sense, and the constraints of your build system.
37365
37366A precompiled header file can be used only when these conditions apply:
37367
37368@itemize
37369@item
37370Only one precompiled header can be used in a particular compilation.
37371
37372@item
37373A precompiled header cannot be used once the first C token is seen. You
37374can have preprocessor directives before a precompiled header; you cannot
37375include a precompiled header from inside another header.
37376
37377@item
37378The precompiled header file must be produced for the same language as
37379the current compilation. You cannot use a C precompiled header for a C++
37380compilation.
37381
37382@item
37383The precompiled header file must have been produced by the same compiler
37384binary as the current compilation is using.
37385
37386@item
37387Any macros defined before the precompiled header is included must
37388either be defined in the same way as when the precompiled header was
37389generated, or must not affect the precompiled header, which usually
37390means that they don't appear in the precompiled header at all.
37391
37392The @option{-D} option is one way to define a macro before a
37393precompiled header is included; using a @code{#define} can also do it.
37394There are also some options that define macros implicitly, like
37395@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
37396defined this way.
37397
37398@item If debugging information is output when using the precompiled
37399header, using @option{-g} or similar, the same kind of debugging information
37400must have been output when building the precompiled header. However,
37401a precompiled header built using @option{-g} can be used in a compilation
37402when no debugging information is being output.
37403
37404@item The same @option{-m} options must generally be used when building
37405and using the precompiled header. @xref{Submodel Options},
37406for any cases where this rule is relaxed.
37407
37408@item Each of the following options must be the same when building and using
37409the precompiled header:
37410
37411@gccoptlist{-fexceptions}
37412
37413@item
37414Some other command-line options starting with @option{-f},
37415@option{-p}, or @option{-O} must be defined in the same way as when
37416the precompiled header was generated. At present, it's not clear
37417which options are safe to change and which are not; the safest choice
37418is to use exactly the same options when generating and using the
37419precompiled header. The following are known to be safe:
37420
43b72ede
AA
37421@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock
37422-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
37423-fsched-verbose=@var{number} -fschedule-insns -fvisibility=
d77de738
ML
37424-pedantic-errors}
37425
37426@item Address space layout randomization (ASLR) can lead to not binary identical
37427PCH files. If you rely on stable PCH file contents disable ASLR when generating
37428PCH files.
37429
37430@end itemize
37431
37432For all of these except the last, the compiler automatically
37433ignores the precompiled header if the conditions aren't met. If you
37434find an option combination that doesn't work and doesn't cause the
37435precompiled header to be ignored, please consider filing a bug report,
37436see @ref{Bugs}.
37437
37438If you do use differing options when generating and using the
37439precompiled header, the actual behavior is a mixture of the
37440behavior for the options. For instance, if you use @option{-g} to
37441generate the precompiled header but not when using it, you may or may
37442not get debugging information for routines in the precompiled header.
37443
37444@node C++ Modules
37445@section C++ Modules
37446@cindex speed of compilation
37447
37448Modules are a C++20 language feature. As the name suggests, they
37449provides a modular compilation system, intending to provide both
37450faster builds and better library isolation. The ``Merging Modules''
37451paper @uref{https://wg21.link/p1103}, provides the easiest to read set
37452of changes to the standard, although it does not capture later
37453changes.
37454
37455@emph{G++'s modules support is not complete.} Other than bugs, the
37456known missing pieces are:
37457
37458@table @emph
37459
37460@item Private Module Fragment
37461The Private Module Fragment is recognized, but an error is emitted.
37462
37463@item Partition definition visibility rules
37464Entities may be defined in implementation partitions, and those
37465definitions are not available outside of the module. This is not
37466implemented, and the definitions are available to extra-module use.
37467
37468@item Textual merging of reachable GM entities
37469Entities may be multiply defined across different header-units.
37470These must be de-duplicated, and this is implemented across imports,
37471or when an import redefines a textually-defined entity. However the
37472reverse is not implemented---textually redefining an entity that has
37473been defined in an imported header-unit. A redefinition error is
37474emitted.
37475
37476@item Translation-Unit local referencing rules
37477Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
37478(@uref{https://wg21.link/p2003}) add limitations on which entities an
37479exported region may reference (for instance, the entities an exported
37480template definition may reference). These are not fully implemented.
37481
37482@item Standard Library Header Units
37483The Standard Library is not provided as importable header units. If
37484you want to import such units, you must explicitly build them first.
37485If you do not do this with care, you may have multiple declarations,
37486which the module machinery must merge---compiler resource usage can be
37487affected by how you partition header files into header units.
37488
37489@end table
37490
37491Modular compilation is @emph{not} enabled with just the
37492@option{-std=c++20} option. You must explicitly enable it with the
37493@option{-fmodules-ts} option. It is independent of the language
37494version selected, although in pre-C++20 versions, it is of course an
37495extension.
37496
37497No new source file suffixes are required or supported. If you wish to
37498use a non-standard suffix (@pxref{Overall Options}), you also need
37499to provide a @option{-x c++} option too.@footnote{Some users like to
37500distinguish module interface files with a new suffix, such as naming
37501the source @code{module.cppm}, which involves
37502teaching all tools about the new suffix. A different scheme, such as
37503naming @code{module-m.cpp} would be less invasive.}
37504
37505Compiling a module interface unit produces an additional output (to
37506the assembly or object file), called a Compiled Module Interface
37507(CMI). This encodes the exported declarations of the module.
37508Importing a module reads in the CMI. The import graph is a Directed
37509Acyclic Graph (DAG). You must build imports before the importer.
37510
37511Header files may themselves be compiled to header units, which are a
37512transitional ability aiming at faster compilation. The
37513@option{-fmodule-header} option is used to enable this, and implies
37514the @option{-fmodules-ts} option. These CMIs are named by the fully
37515resolved underlying header file, and thus may be a complete pathname
37516containing subdirectories. If the header file is found at an absolute
37517pathname, the CMI location is still relative to a CMI root directory.
37518
37519As header files often have no suffix, you commonly have to specify a
37520@option{-x} option to tell the compiler the source is a header file.
37521You may use @option{-x c++-header}, @option{-x c++-user-header} or
37522@option{-x c++-system-header}. When used in conjunction with
37523@option{-fmodules-ts}, these all imply an appropriate
37524@option{-fmodule-header} option. The latter two variants use the
37525user or system include path to search for the file specified. This
37526allows you to, for instance, compile standard library header files as
37527header units, without needing to know exactly where they are
37528installed. Specifying the language as one of these variants also
37529inhibits output of the object file, as header files have no associated
37530object file.
37531
37532The @option{-fmodule-only} option disables generation of the
37533associated object file for compiling a module interface. Only the CMI
37534is generated. This option is implied when using the
37535@option{-fmodule-header} option.
37536
37537The @option{-flang-info-include-translate} and
37538@option{-flang-info-include-translate-not} options notes whether
37539include translation occurs or not. With no argument, the first will
37540note all include translation. The second will note all
37541non-translations of include files not known to intentionally be
37542textual. With an argument, queries about include translation of a
37543header files with that particular trailing pathname are noted. You
37544may repeat this form to cover several different header files. This
37545option may be helpful in determining whether include translation is
37546happening---if it is working correctly, it behaves as if it isn't
37547there at all.
37548
37549The @option{-flang-info-module-cmi} option can be used to determine
37550where the compiler is reading a CMI from. Without the option, the
37551compiler is silent when such a read is successful. This option has an
37552optional argument, which will restrict the notification to just the
37553set of named modules or header units specified.
37554
37555The @option{-Winvalid-imported-macros} option causes all imported macros
37556to be resolved at the end of compilation. Without this, imported
37557macros are only resolved when expanded or (re)defined. This option
37558detects conflicting import definitions for all macros.
37559
37560For details of the @option{-fmodule-mapper} family of options,
37561@pxref{C++ Module Mapper}.
37562
37563@menu
37564* C++ Module Mapper:: Module Mapper
37565* C++ Module Preprocessing:: Module Preprocessing
37566* C++ Compiled Module Interface:: Compiled Module Interface
37567@end menu
37568
37569@node C++ Module Mapper
37570@subsection Module Mapper
37571@cindex C++ Module Mapper
37572
37573A module mapper provides a server or file that the compiler queries to
37574determine the mapping between module names and CMI files. It is also
37575used to build CMIs on demand. @emph{Mapper functionality is in its
37576infancy and is intended for experimentation with build system
37577interactions.}
37578
37579You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
37580option or @env{CXX_MODULE_MAPPER} environment variable. The value may
37581have one of the following forms:
37582
37583@table @gcctabopt
37584
37585@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
37586An optional hostname and a numeric port number to connect to. If the
37587hostname is omitted, the loopback address is used. If the hostname
37588corresponds to multiple IPV6 addresses, these are tried in turn, until
37589one is successful. If your host lacks IPv6, this form is
37590non-functional. If you must use IPv4 use
37591@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
37592
37593@item =@var{socket}@r{[}?@var{ident}@r{]}
37594A local domain socket. If your host lacks local domain sockets, this
37595form is non-functional.
37596
37597@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
37598A program to spawn, and communicate with on its stdin/stdout streams.
37599Your @var{PATH} environment variable is searched for the program.
37600Arguments are separated by space characters, (it is not possible for
37601one of the arguments delivered to the program to contain a space). An
37602exception is if @var{program} begins with @@. In that case
37603@var{program} (sans @@) is looked for in the compiler's internal
37604binary directory. Thus the sample mapper-server can be specified
37605with @code{@@g++-mapper-server}.
37606
37607@item <>@r{[}?@var{ident}@r{]}
37608@item <>@var{inout}@r{[}?@var{ident}@r{]}
37609@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
37610Named pipes or file descriptors to communicate over. The first form,
37611@option{<>}, communicates over stdin and stdout. The other forms
37612allow you to specify a file descriptor or name a pipe. A numeric value
37613is interpreted as a file descriptor, otherwise named pipe is opened.
37614The second form specifies a bidirectional pipe and the last form
37615allows specifying two independent pipes. Using file descriptors
37616directly in this manner is fragile in general, as it can require the
37617cooperation of intermediate processes. In particular using stdin &
37618stdout is fraught with danger as other compiler options might also
37619cause the compiler to read stdin or write stdout, and it can have
37620unfortunate interactions with signal delivery from the terminal.
37621
37622@item @var{file}@r{[}?@var{ident}@r{]}
37623A mapping file consisting of space-separated module-name, filename
37624pairs, one per line. Only the mappings for the direct imports and any
37625module export name need be provided. If other mappings are provided,
37626they override those stored in any imported CMI files. A repository
37627root may be specified in the mapping file by using @samp{$root} as the
37628module name in the first active line. Use of this option will disable
37629any default module->CMI name mapping.
37630
37631@end table
37632
37633As shown, an optional @var{ident} may suffix the first word of the
37634option, indicated by a @samp{?} prefix. The value is used in the
37635initial handshake with the module server, or to specify a prefix on
37636mapping file lines. In the server case, the main source file name is
37637used if no @var{ident} is specified. In the file case, all non-blank
37638lines are significant, unless a value is specified, in which case only
37639lines beginning with @var{ident} are significant. The @var{ident}
37640must be separated by whitespace from the module name. Be aware that
37641@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
37642significant to the shell, and therefore may need quoting.
37643
37644The mapper is connected to or loaded lazily, when the first module
37645mapping is required. The networking protocols are only supported on
37646hosts that provide networking. If no mapper is specified a default is
37647provided.
37648
37649A project-specific mapper is expected to be provided by the build
37650system that invokes the compiler. It is not expected that a
37651general-purpose server is provided for all compilations. As such, the
37652server will know the build configuration, the compiler it invoked, and
37653the environment (such as working directory) in which that is
37654operating. As it may parallelize builds, several compilations may
37655connect to the same socket.
37656
37657The default mapper generates CMI files in a @samp{gcm.cache}
37658directory. CMI files have a @samp{.gcm} suffix. The module unit name
37659is used directly to provide the basename. Header units construct a
37660relative path using the underlying header file name. If the path is
37661already relative, a @samp{,} directory is prepended. Internal
37662@samp{..} components are translated to @samp{,,}. No attempt is made
37663to canonicalize these filenames beyond that done by the preprocessor's
37664include search algorithm, as in general it is ambiguous when symbolic
37665links are present.
37666
37667The mapper protocol was published as ``A Module Mapper''
37668@uref{https://wg21.link/p1184}. The implementation is provided by
37669@command{libcody}, @uref{https://github.com/urnathan/libcody},
37670which specifies the canonical protocol definition. A proof of concept
37671server implementation embedded in @command{make} was described in
37672''Make Me A Module'', @uref{https://wg21.link/p1602}.
37673
37674@node C++ Module Preprocessing
37675@subsection Module Preprocessing
37676@cindex C++ Module Preprocessing
37677
37678Modules affect preprocessing because of header units and include
37679translation. Some uses of the preprocessor as a separate step either
37680do not produce a correct output, or require CMIs to be available.
37681
37682Header units import macros. These macros can affect later conditional
37683inclusion, which therefore can cascade to differing import sets. When
37684preprocessing, it is necessary to load the CMI. If a header unit is
37685unavailable, the preprocessor issues a warning and continue (when
37686not just preprocessing, an error is emitted). Detecting such imports
37687requires preprocessor tokenization of the input stream to phase 4
37688(macro expansion).
37689
37690Include translation converts @code{#include}, @code{#include_next} and
37691@code{#import} directives to internal @code{import} declarations.
37692Whether a particular directive is translated is controlled by the
37693module mapper. Header unit names are canonicalized during
37694preprocessing.
37695
37696Dependency information can be emitted for macro import, extending the
37697functionality of @option{-MD} and @option{-MMD} options. Detection of
37698import declarations also requires phase 4 preprocessing, and thus
37699requires full preprocessing (or compilation).
37700
37701The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
37702preprocessing before phase 4.
37703
37704The @option{-save-temps} option uses @option{-fdirectives-only} for
37705preprocessing, and preserve the macro definitions in the preprocessed
37706output. Usually you also want to use this option when explicitly
37707preprocessing a header-unit, or consuming such preprocessed output:
37708
37709@smallexample
37710g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
37711g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
37712@end smallexample
37713
37714@node C++ Compiled Module Interface
37715@subsection Compiled Module Interface
37716@cindex C++ Compiled Module Interface
37717
37718CMIs are an additional artifact when compiling named module
37719interfaces, partitions or header units. These are read when
37720importing. CMI contents are implementation-specific, and in GCC's
37721case tied to the compiler version. Consider them a rebuildable cache
37722artifact, not a distributable object.
37723
37724When creating an output CMI, any missing directory components are
37725created in a manner that is safe for concurrent builds creating
37726multiple, different, CMIs within a common subdirectory tree.
37727
37728CMI contents are written to a temporary file, which is then atomically
37729renamed. Observers either see old contents (if there is an
37730existing file), or complete new contents. They do not observe the
37731CMI during its creation. This is unlike object file writing, which
37732may be observed by an external process.
37733
37734CMIs are read in lazily, if the host OS provides @code{mmap}
37735functionality. Generally blocks are read when name lookup or template
37736instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
37737option may be used.
37738
37739The @option{--param lazy-modules=@var{n}} parameter controls the limit
37740on the number of concurrently open module files during lazy loading.
37741Should more modules be imported, an LRU algorithm is used to determine
37742which files to close---until that file is needed again. This limit
37743may be exceeded with deep module dependency hierarchies. With large
37744code bases there may be more imports than the process limit of file
37745descriptors. By default, the limit is a few less than the per-process
37746file descriptor hard limit, if that is determinable.@footnote{Where
37747applicable the soft limit is incremented as needed towards the hard limit.}
37748
37749GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
37750You may use @command{readelf} to inspect them, although section
37751contents are largely undecipherable. There is a section named
37752@code{.gnu.c++.README}, which contains human-readable text. Other
37753than the first line, each line consists of @code{@var{tag}: @code{value}}
37754tuples.
37755
37756@smallexample
37757> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
37758
37759String dump of section '.gnu.c++.README':
37760 [ 0] GNU C++ primary module interface
37761 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
37762 [ 6f] version: 2020/11/16-04:54
37763 [ 89] module: foo
37764 [ 95] source: c_b.ii
37765 [ a4] dialect: C++20/coroutines
37766 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
37767 [ ee] repository: gcm.cache
37768 [ 104] buildtime: 2020/11/16 15:03:21 UTC
37769 [ 127] localtime: 2020/11/16 07:03:21 PST
37770 [ 14a] export: foo:part1 foo-part1.gcm
37771@end smallexample
37772
37773Amongst other things, this lists the source that was built, C++
37774dialect used and imports of the module.@footnote{The precise contents
37775of this output may change.} The timestamp is the same value as that
37776provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
37777explicitly specified with the environment variable
37778@code{SOURCE_DATE_EPOCH}. For further details
37779@pxref{Environment Variables}.
37780
37781A set of related CMIs may be copied, provided the relative pathnames
37782are preserved.
37783
37784The @code{.gnu.c++.README} contents do not affect CMI integrity, and
37785it may be removed or altered. The section numbering of the sections
37786whose names do not begin with @code{.gnu.c++.}, or are not the string
37787section is significant and must not be altered.
This page took 5.779288 seconds and 5 git commands to generate.